Skip to content

Commit

Permalink
Merge pull request #16 from ux3d/fix/dropMoreObsoleteCode
Browse files Browse the repository at this point in the history
Drop extension-related code
  • Loading branch information
UX3D-haertl authored Nov 18, 2020
2 parents 50b80d4 + d1b7b76 commit 546562a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 166 deletions.
118 changes: 0 additions & 118 deletions src/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,21 +335,6 @@ class gltfMaterial extends GltfObject
this.properties.set("u_SheenColorFactor", sheenColor);
this.properties.set("u_SheenRoughness", sheenRoughness);
}

// KHR Extension: Transmission
if (this.extensions.KHR_materials_transmission !== undefined)
{
let transmission = this.extensions.KHR_materials_transmission.transmission;

if (transmission === undefined)
{
transmission = 0.0;
}

this.defines.push("MATERIAL_TRANSMISSION 1");

this.properties.set("u_Transmission", transmission);
}
}

initGlForMembers(this, gltf);
Expand Down Expand Up @@ -390,7 +375,6 @@ class gltfMaterial extends GltfObject
this.fromJsonMaterialExtensions(jsonMaterial.extensions);
}

// dont do MR if we parsed SG before
if (jsonMaterial.pbrMetallicRoughness !== undefined && this.type !== "SG")
{
this.type = "MR";
Expand Down Expand Up @@ -420,36 +404,6 @@ class gltfMaterial extends GltfObject
{
this.fromJsonSheen(jsonExtensions.KHR_materials_sheen);
}

if(jsonExtensions.KHR_materials_specular !== undefined)
{
this.fromJsonMetallicRoughnessSpecular(jsonExtensions.KHR_materials_specular);
}

if(jsonExtensions.KHR_materials_subsurface !== undefined)
{
this.fromJsonSubsurface(jsonExtensions.KHR_materials_subsurface);
}

if(jsonExtensions.KHR_materials_thinfilm !== undefined)
{
this.fromJsonThinFilm(jsonExtensions.KHR_materials_thinfilm);
}

if(jsonExtensions.KHR_materials_transmission !== undefined)
{
this.fromJsonTransmission(jsonExtensions.KHR_materials_transmission);
}

if(jsonExtensions.KHR_materials_thickness !== undefined)
{
this.fromJsonThickness(jsonExtensions.KHR_materials_thickness);
}

if(jsonExtensions.KHR_materials_anisotropy !== undefined)
{
this.fromJsonAnisotropy(jsonExtensions.KHR_materials_anisotropy);
}
}

fromJsonMetallicRoughness(jsonMetallicRoughness)
Expand Down Expand Up @@ -519,78 +473,6 @@ class gltfMaterial extends GltfObject
this.colorIntensityTexture = colorIntensityTexture;
}
}

fromJsonMetallicRoughnessSpecular(jsonMRSpecular)
{
if(jsonMRSpecular.specularTexture !== undefined)
{
const specularTexture = new gltfTextureInfo();
specularTexture.fromJson(jsonMRSpecular.specularTexture);
this.metallicRoughnessSpecularTexture = specularTexture;
}
}

fromJsonSubsurface(jsonSubsurface)
{
if(jsonSubsurface.colorTexture !== undefined)
{
const colorTexture = new gltfTextureInfo();
colorTexture.fromJson(jsonSubsurface.colorTexture);
this.subsurfaceColorTexture = colorTexture;
}

if(jsonSubsurface.thicknessTexture !== undefined)
{
const thicknessTexture = new gltfTextureInfo();
thicknessTexture.fromJson(jsonSubsurface.thicknessTexture);
this.subsurfaceThicknessTexture = thicknessTexture;
}
}

fromJsonThinFilm(jsonThinFilm)
{
if(jsonThinFilm.thinfilmTexture !== undefined)
{
const thinfilmTexture = new gltfTextureInfo();
thinfilmTexture.fromJson(jsonThinFilm.thinfilmTexture);
this.thinfilmTexture = thinfilmTexture;
}

if(jsonThinFilm.thinfilmThicknessTexture !== undefined)
{
const thinfilmThicknessTexture = new gltfTextureInfo();
thinfilmThicknessTexture.fromJson(jsonThinFilm.thinfilmThicknessTexture);
this.thinfilmThicknessTexture = thinfilmThicknessTexture;
}
}

fromJsonTransmission(jsonTransmission)
{
jsonTransmission;
}

fromJsonThickness(jsonThickness)
{
if(jsonThickness.thicknessTexture !== undefined)
{
this.thicknessTexture = new gltfTextureInfo();
this.thicknessTexture.fromJson(jsonThickness.thicknessTexture);
}
}

fromJsonAnisotropy(jsonAnisotropy)
{
if(jsonAnisotropy.anisotropyTexture !== undefined)
{
this.anisotropyTexture = new gltfTextureInfo();
this.anisotropyTexture.fromJson(jsonAnisotropy.anisotropyTexture);
}
if(jsonAnisotropy.anisotropyDirectionTexture !== undefined)
{
this.anisotropyDirectionTexture = new gltfTextureInfo();
this.anisotropyDirectionTexture.fromJson(jsonAnisotropy.anisotropyDirectionTexture);
}
}
}

export { gltfMaterial };
10 changes: 0 additions & 10 deletions src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,10 @@ class gltfRenderer
}
}

const hasThinFilm = material.extensions != undefined && material.extensions.KHR_materials_thinfilm !== undefined;
if (this.parameters.useIBL)
{
this.applyEnvironmentMap(gltf, envData, material.textures.length);
}
else if (hasThinFilm)
{
WebGl.setTexture(this.shader.getUniformLocation("u_ThinFilmLUT"), gltf, envData.thinFilmLUT, material.textures.length);
}

if (drawIndexed)
{
Expand Down Expand Up @@ -536,9 +531,6 @@ class gltfRenderer

scene.envData.sheenLUT = new gltfTextureInfo(gltf.textures.length - 2);
scene.envData.sheenLUT.generateMips = false;

scene.envData.thinFilmLUT = new gltfTextureInfo(gltf.textures.length - 1);
scene.envData.thinFilmLUT.generateMips = false;
}

applyEnvironmentMap(gltf, envData, texSlotOffset)
Expand All @@ -551,8 +543,6 @@ class gltfRenderer
WebGl.setTexture(this.shader.getUniformLocation("u_CharlieEnvSampler"), gltf, envData.sheenEnvMap, texSlotOffset + 3);
WebGl.setTexture(this.shader.getUniformLocation("u_CharlieLUT"), gltf, envData.sheenLUT, texSlotOffset + 4);

WebGl.setTexture(this.shader.getUniformLocation("u_ThinFilmLUT"), gltf, envData.thinFilmLUT, texSlotOffset + 5);

this.shader.updateUniform("u_MipCount", envData.mipCount);
}

Expand Down
14 changes: 0 additions & 14 deletions src/shaders/pbr.frag
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
// https://www.cs.virginia.edu/~jdl/bib/appearance/analytic%20models/schlick94b.pdf
// [5] "KHR_materials_clearcoat"
// https://github.com/ux3d/glTF/tree/KHR_materials_pbrClearcoat/extensions/2.0/Khronos/KHR_materials_clearcoat
// [6] "KHR_materials_specular"
// https://github.com/ux3d/glTF/tree/KHR_materials_pbrClearcoat/extensions/2.0/Khronos/KHR_materials_specular
// [7] "KHR_materials_subsurface"
// https://github.com/KhronosGroup/glTF/pull/1766
// [8] "KHR_materials_thinfilm"
// https://github.com/ux3d/glTF/tree/extensions/KHR_materials_thinfilm/extensions/2.0/Khronos/KHR_materials_thinfilm

precision highp float;

Expand Down Expand Up @@ -54,9 +48,6 @@ uniform float u_SheenRoughness;
uniform float u_ClearcoatFactor;
uniform float u_ClearcoatRoughnessFactor;

// Transmission
uniform float u_Transmission;

// Alpha mode
uniform float u_AlphaCutoff;

Expand Down Expand Up @@ -85,11 +76,6 @@ struct MaterialInfo
float clearcoatFactor;
vec3 clearcoatNormal;
float clearcoatRoughness;

float thinFilmFactor;
float thinFilmThickness;

float transmission;
};

// Get normal, tangent and bitangent vectors.
Expand Down
34 changes: 10 additions & 24 deletions src/shaders/textures.glsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
in vec2 v_UVCoord1;
in vec2 v_UVCoord2;

// IBL
uniform int u_MipCount;
uniform samplerCube u_LambertianEnvSampler;
uniform samplerCube u_GGXEnvSampler;
uniform sampler2D u_GGXLUT;
uniform samplerCube u_CharlieEnvSampler;
uniform sampler2D u_CharlieLUT;

// General Material
uniform sampler2D u_NormalSampler;
uniform float u_NormalScale;
Expand Down Expand Up @@ -35,15 +43,7 @@ uniform sampler2D u_SpecularGlossinessSampler;
uniform int u_SpecularGlossinessUVSet;
uniform mat3 u_SpecularGlossinessUVTransform;

// IBL
uniform int u_MipCount;
uniform samplerCube u_LambertianEnvSampler;
uniform samplerCube u_GGXEnvSampler;
uniform sampler2D u_GGXLUT;
uniform samplerCube u_CharlieEnvSampler;
uniform sampler2D u_CharlieLUT;

//clearcoat
// Clearcoat Material
uniform sampler2D u_ClearcoatSampler;
uniform int u_ClearcoatUVSet;
uniform mat3 u_ClearcoatUVTransform;
Expand All @@ -56,16 +56,11 @@ uniform sampler2D u_ClearcoatNormalSampler;
uniform int u_ClearcoatNormalUVSet;
uniform mat3 u_ClearcoatNormalUVTransform;

//sheen
// Sheen Material
uniform sampler2D u_SheenColorIntensitySampler;
uniform int u_SheenColorIntensityUVSet;
uniform mat3 u_SheenColorIntensityUVTransform;

//specular
uniform sampler2D u_MetallicRoughnessSpecularSampler;
uniform int u_MetallicRougnessSpecularTextureUVSet;
uniform mat3 u_MetallicRougnessSpecularUVTransform;

vec2 getNormalUV()
{
vec3 uv = vec3(u_NormalUVSet < 1 ? v_UVCoord1 : v_UVCoord2, 1.0);
Expand Down Expand Up @@ -178,12 +173,3 @@ vec2 getSheenUV()
#endif
return uv.xy;
}

vec2 getMetallicRoughnessSpecularUV()
{
vec3 uv = vec3(u_MetallicRougnessSpecularTextureUVSet < 1 ? v_UVCoord1 : v_UVCoord2, 1.0);
#ifdef HAS_METALLICROUGHNESSSPECULAR_UV_TRANSFORM
uv *= u_MetallicRougnessSpecularUVTransform;
#endif
return uv.xy;
}

0 comments on commit 546562a

Please sign in to comment.