diff --git a/src/material.js b/src/material.js index 5a9084c6..9abdd67a 100644 --- a/src/material.js +++ b/src/material.js @@ -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); @@ -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"; @@ -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) @@ -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 }; diff --git a/src/renderer.js b/src/renderer.js index 98198c48..e826b2f9 100644 --- a/src/renderer.js +++ b/src/renderer.js @@ -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) { @@ -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) @@ -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); } diff --git a/src/shaders/pbr.frag b/src/shaders/pbr.frag index 40ee31f1..e259c680 100644 --- a/src/shaders/pbr.frag +++ b/src/shaders/pbr.frag @@ -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; @@ -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; @@ -85,11 +76,6 @@ struct MaterialInfo float clearcoatFactor; vec3 clearcoatNormal; float clearcoatRoughness; - - float thinFilmFactor; - float thinFilmThickness; - - float transmission; }; // Get normal, tangent and bitangent vectors. diff --git a/src/shaders/textures.glsl b/src/shaders/textures.glsl index 411bf6c5..900d2139 100644 --- a/src/shaders/textures.glsl +++ b/src/shaders/textures.glsl @@ -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; @@ -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; @@ -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); @@ -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; -}