material { name : transmission_${SHADINGMODEL}_${BLENDING}, requires : [ uv0, uv1, color ], shadingModel : ${SHADINGMODEL}, blending : fade, depthWrite : true, doubleSided : ${DOUBLESIDED}, flipUV : false, specularAmbientOcclusion : simple, specularAntiAliasing : true, refractionMode: screenspace, refractionType: thin, parameters : [ // Base Color { type : int, name : baseColorIndex }, { type : float4, name : baseColorFactor }, { type : sampler2d, name : baseColorMap }, { type : mat3, name : baseColorUvMatrix }, // Metallic-Roughness Map { type : int, name : metallicRoughnessIndex }, { type : float, name : metallicFactor }, { type : float, name : roughnessFactor }, { type : sampler2d, name : metallicRoughnessMap }, { type : mat3, name : metallicRoughnessUvMatrix }, // Normal Map { type : int, name : normalIndex }, { type : float, name : normalScale }, { type : sampler2d, name : normalMap }, { type : mat3, name : normalUvMatrix }, // Ambient Occlusion { type : int, name : aoIndex }, { type : float, name : aoStrength }, { type : sampler2d, name : occlusionMap }, { type : mat3, name : occlusionUvMatrix }, // Emissive Map { type : int, name : emissiveIndex }, { type : float3, name : emissiveFactor }, { type : sampler2d, name : emissiveMap }, { type : mat3, name : emissiveUvMatrix }, // Transmission Map { type : int, name : transmissionIndex }, { type : float, name : transmissionFactor }, { type : sampler2d, name : transmissionMap }, { type : mat3, name : transmissionUvMatrix } ], } fragment { void material(inout MaterialInputs material) { highp float2 uvs[2]; uvs[0] = getUV0(); uvs[1] = getUV1(); if (materialParams.normalIndex > -1) { highp float2 uv = uvs[materialParams.normalIndex]; uv = (vec3(uv, 1.0) * materialParams.normalUvMatrix).xy; material.normal = texture(materialParams_normalMap, uv).xyz * 2.0 - 1.0; material.normal.xy *= materialParams.normalScale; } prepareMaterial(material); material.baseColor = materialParams.baseColorFactor; if (materialParams.baseColorIndex > -1) { highp float2 uv = uvs[materialParams.baseColorIndex]; uv = (vec3(uv, 1.0) * materialParams.baseColorUvMatrix).xy; material.baseColor *= texture(materialParams_baseColorMap, uv); } #if defined(BLEND_MODE_TRANSPARENT) material.baseColor.rgb *= material.baseColor.a; #endif material.baseColor *= getColor(); material.roughness = materialParams.roughnessFactor; material.metallic = materialParams.metallicFactor; material.emissive = vec4(materialParams.emissiveFactor.rgb, 0.0); material.transmission = materialParams.transmissionFactor; material.absorption = 1.0 - material.baseColor.rgb; if (materialParams.transmissionIndex > -1) { highp float2 uv = uvs[materialParams.transmissionIndex]; uv = (vec3(uv, 1.0) * materialParams.transmissionUvMatrix).xy; material.transmission *= texture(materialParams_transmissionMap, uv).r; } if (materialParams.metallicRoughnessIndex > -1) { highp float2 uv = uvs[materialParams.metallicRoughnessIndex]; uv = (vec3(uv, 1.0) * materialParams.metallicRoughnessUvMatrix).xy; vec4 mr = texture(materialParams_metallicRoughnessMap, uv); material.roughness *= mr.g; material.metallic *= mr.b; } if (materialParams.aoIndex > -1) { highp float2 uv = uvs[materialParams.aoIndex]; uv = (vec3(uv, 1.0) * materialParams.occlusionUvMatrix).xy; material.ambientOcclusion = texture(materialParams_occlusionMap, uv).r * materialParams.aoStrength; } if (materialParams.emissiveIndex > -1) { highp float2 uv = uvs[materialParams.emissiveIndex]; uv = (vec3(uv, 1.0) * materialParams.emissiveUvMatrix).xy; material.emissive.rgb *= texture(materialParams_emissiveMap, uv).rgb; } } }