From 9a381e27f70e5cfab2dd2c9646040f52eda9a613 Mon Sep 17 00:00:00 2001 From: "Matias N. Goldberg" Date: Sun, 27 Jun 2021 17:22:47 -0300 Subject: [PATCH] Remove problematic leftover files from 2.1 The mere presence of these files can cause incorrect shader generation or unknown visual bugs. IMPORTANT: The installation folder (i.e. CMAKE_INSTALL_PREFIX) must remove them as well. `make install` won't be enough because it won't remove files, only add new ones or update existing ones. This folder is usually installed in ign/install/share/ignition/ignition-rendering6/ogre2/media/Hlms Signed-off-by: Matias N. Goldberg --- .../media/Hlms/Pbs/GLSL/BRDFs_piece_ps.glsl | 239 ----------------- .../Hlms/Pbs/GLSL/BlendModes_piece_ps.glsl | 105 -------- .../Hlms/Pbs/GLSL/DetailMaps_piece_ps.glsl | 26 -- .../Pbs/GLSL/IrradianceVolume_piece_ps.glsl | 67 ----- .../Pbs/GLSL/Structs_piece_vs_piece_ps.glsl | 244 ----------------- .../Hlms/Pbs/GLSL/Textures_piece_ps.glsl | 107 -------- .../media/Hlms/Pbs/Metal/BRDFs_piece_ps.metal | 242 ----------------- .../Hlms/Pbs/Metal/BlendModes_piece_ps.metal | 105 -------- .../Hlms/Pbs/Metal/DetailMaps_piece_ps.metal | 26 -- .../Pbs/Metal/IrradianceVolume_piece_ps.metal | 75 ------ .../Pbs/Metal/Structs_piece_vs_piece_ps.metal | 252 ------------------ 11 files changed, 1488 deletions(-) delete mode 100644 ogre2/src/media/Hlms/Pbs/GLSL/BRDFs_piece_ps.glsl delete mode 100644 ogre2/src/media/Hlms/Pbs/GLSL/BlendModes_piece_ps.glsl delete mode 100644 ogre2/src/media/Hlms/Pbs/GLSL/DetailMaps_piece_ps.glsl delete mode 100644 ogre2/src/media/Hlms/Pbs/GLSL/IrradianceVolume_piece_ps.glsl delete mode 100644 ogre2/src/media/Hlms/Pbs/GLSL/Structs_piece_vs_piece_ps.glsl delete mode 100644 ogre2/src/media/Hlms/Pbs/GLSL/Textures_piece_ps.glsl delete mode 100644 ogre2/src/media/Hlms/Pbs/Metal/BRDFs_piece_ps.metal delete mode 100644 ogre2/src/media/Hlms/Pbs/Metal/BlendModes_piece_ps.metal delete mode 100644 ogre2/src/media/Hlms/Pbs/Metal/DetailMaps_piece_ps.metal delete mode 100644 ogre2/src/media/Hlms/Pbs/Metal/IrradianceVolume_piece_ps.metal delete mode 100644 ogre2/src/media/Hlms/Pbs/Metal/Structs_piece_vs_piece_ps.metal diff --git a/ogre2/src/media/Hlms/Pbs/GLSL/BRDFs_piece_ps.glsl b/ogre2/src/media/Hlms/Pbs/GLSL/BRDFs_piece_ps.glsl deleted file mode 100644 index 2aba21aa7..000000000 --- a/ogre2/src/media/Hlms/Pbs/GLSL/BRDFs_piece_ps.glsl +++ /dev/null @@ -1,239 +0,0 @@ -@property( !metallic_workflow && (!specular_map || !fresnel_workflow) ) - @property( !transparent_mode ) - @piece( F0 )material.F0@end - @end @property( transparent_mode ) - //Premultiply F0.xyz with the alpha from the texture, but only in transparent mode. - @piece( F0 )(material.F0.@insertpiece( FresnelSwizzle ) * diffuseCol.w)@end - @end -@end @property( metallic_workflow || (specular_map && fresnel_workflow) ) - @piece( F0 )F0@end -@end - -@property( !fresnel_scalar ) - @piece( maxR1F0 )max( 1.0 - ROUGHNESS, @insertpiece( F0 ).x )@end -@end @property( fresnel_scalar ) - @piece( maxR1F0 )max( (1.0 - ROUGHNESS).xxx, @insertpiece( F0 ).xyz )@end -@end - -//For mortals: -// getSpecularFresnel = F0 + pow( 1.0 - VdotH, 5.0 ) * (1.0 - F0) -// getDiffuseFresnel = 1.0 - F0 + pow( 1.0 - NdotL, 5.0 ) * F0 -// getSpecularFresnelWithRoughness = F0 + pow( 1.0 - VdotH, 5.0 ) * (max(ROUGHNESS, (1.0 - F0)) - F0) -// getDiffuseFresnelWithRoughness = max(ROUGHNESS, (1.0 - F0) - F0 + pow( 1.0 - NdotL, 5.0 ) * F0 -@piece( getSpecularFresnel )@insertpiece( F0 ).@insertpiece( FresnelSwizzle ) + pow( 1.0 - VdotH, 5.0 ) * (1.0 - @insertpiece( F0 ).@insertpiece( FresnelSwizzle ))@end -@piece( getDiffuseFresnel )1.0 - @insertpiece( F0 ).@insertpiece( FresnelSwizzle ) + pow( 1.0 - NdotL, 5.0 ) * @insertpiece( F0 ).@insertpiece( FresnelSwizzle )@end - -@piece( getSpecularFresnelWithRoughness )@insertpiece( F0 ).@insertpiece( FresnelSwizzle ) + pow( 1.0 - VdotH, 5.0 ) * (@insertpiece( maxR1F0 ) - @insertpiece( F0 ).@insertpiece( FresnelSwizzle ))@end -@piece( getDiffuseFresnelWithRoughness )@insertpiece( maxR1F0 ) - @insertpiece( F0 ).@insertpiece( FresnelSwizzle ) + pow( 1.0 - NdotL, 5.0 ) * @insertpiece( F0 ).@insertpiece( FresnelSwizzle )@end - -@property( !fresnel_scalar ) - @piece( getMaxFresnelS )fresnelS@end -@end @property( fresnel_scalar ) - @property( hlms_amd_trinary_minmax )@piece( getMaxFresnelS )max3( fresnelS.x, fresnelS.y, fresnelS.z )@end @end - @property( !hlms_amd_trinary_minmax )@piece( getMaxFresnelS )max( fresnelS.x, max( fresnelS.y, fresnelS.z ) )@end @end -@end - -@property( BRDF_BlinnPhong ) -@piece( DeclareBRDF ) -//Blinn-Phong -vec3 BRDF( vec3 lightDir, vec3 viewDir, float NdotV, vec3 lightDiffuse, vec3 lightSpecular ) -{ - vec3 halfWay= normalize( lightDir + viewDir ); - float NdotL = clamp( dot( nNormal, lightDir ), 0.0, 1.0 ); //Diffuse (Lambert) - float NdotH = clamp( dot( nNormal, halfWay ), 0.001, 1.0 ); //Specular - @property( !legacy_math_brdf ) - float VdotH = clamp( dot( viewDir, halfWay ), 0.001, 1.0 ); //Fresnel - - //Fresnel term (Schlick's approximation) - @insertpiece( FresnelType ) fresnelS = @insertpiece( getSpecularFresnel ); - @property( fresnel_separate_diffuse ) - @insertpiece( FresnelType ) fresnelD = @insertpiece( getDiffuseFresnel ); - @end @property( !fresnel_separate_diffuse ) - float fresnelD = 1.0f - @insertpiece( getMaxFresnelS ); - @end - @end - - @property( !roughness_is_shininess ) - float shininess = exp2( 10.0 * (1.0 - ROUGHNESS) + 1.0 ) * 0.25; - @end @property( roughness_is_shininess ) - float shininess = ROUGHNESS; - @end - float blinnPhong = pow( NdotH, shininess ); - - @property( !legacy_math_brdf ) - //Normalize Blinn-Phong using (n + 8) / (8 * pi) - //Note this factor is an approximation. The real normalization is - //*much* more expensive. See: - //http://www.rorydriscoll.com/2009/01/25/energy-conservation-in-games/ - blinnPhong *= (shininess + 8.0) / (8.0 * 3.141592654); - - //Avoid very small denominators, they go to NaN or cause aliasing artifacts - //Note: For blinn-phong we use larger denominators otherwise specular blows out of proportion - @insertpiece( FresnelType ) Rs = ( fresnelS * blinnPhong ) / max( 4.0 * NdotV * NdotL, 0.75 ); - //Make diffuse look closer to Default. - fresnelD *= mix( 1.0, 1.0 / 1.51, ROUGHNESS ); - @end @property( legacy_math_brdf ) - float Rs = blinnPhong; - float fresnelD = 1.0; - @end - - return NdotL * (@insertpiece( kS ).xyz * lightSpecular * Rs + - @insertpiece( kD ).xyz * lightDiffuse * fresnelD); -} -@end -@end - -@property( BRDF_CookTorrance ) -@piece( DeclareBRDF ) -//Cook-Torrance -vec3 BRDF( vec3 lightDir, vec3 viewDir, float NdotV, vec3 lightDiffuse, vec3 lightSpecular ) -{ - vec3 halfWay= normalize( lightDir + viewDir ); - float NdotL = clamp( dot( nNormal, lightDir ), 0.0, 1.0 ); - float NdotH = clamp( dot( nNormal, halfWay ), 0.001, 1.0 ); - float VdotH = clamp( dot( viewDir, halfWay ), 0.001, 1.0 ); - - float sqR = ROUGHNESS * ROUGHNESS; - - //Roughness/Distribution/NDF term (Beckmann distribution) - //Formula: - // Where alpha = NdotH and m = roughness - // R = [ 1 / (m^2 x cos(alpha)^4 ] x [ e^( -tan(alpha)^2 / m^2 ) ] - // R = [ 1 / (m^2 x cos(alpha)^4 ] x [ e^( ( cos(alpha)^2 - 1 ) / (m^2 cos(alpha)^2 ) ] - float NdotH_sq = NdotH * NdotH; - float roughness_a = 1.0 / ( 3.141592654 * sqR * NdotH_sq * NdotH_sq );//( 1 / (m^2 x cos(alpha)^4 ) - float roughness_b = NdotH_sq - 1.0; //( cos(alpha)^2 - 1 ) - float roughness_c = sqR * NdotH_sq; //( m^2 cos(alpha)^2 ) - - //Avoid Inf * 0 = NaN; we need Inf * 0 = 0 - float R = min( roughness_a, 65504.0 ) * exp( roughness_b / roughness_c ); - - //Geometric/Visibility term (Cook Torrance) - float shared_geo = 2.0 * NdotH / VdotH; - float geo_b = shared_geo * NdotV; - float geo_c = shared_geo * NdotL; - @property( !hlms_amd_trinary_minmax )float G = min( 1.0, min( geo_b, geo_c ) );@end - @property( hlms_amd_trinary_minmax )float G = min3( 1.0, geo_b, geo_c );@end - - //Fresnel term (Schlick's approximation) - //Formula: - // fresnelS = lerp( (1 - V*H)^5, 1, F0 ) - // fresnelD = lerp( (1 - N*L)^5, 1, 1 - F0 ) [See s2010_course_note_practical_implementation_at_triace.pdf] - @insertpiece( FresnelType ) fresnelS = @insertpiece( getSpecularFresnel ); -@property( fresnel_separate_diffuse ) - @insertpiece( FresnelType ) fresnelD = @insertpiece( getDiffuseFresnel ); -@end @property( !fresnel_separate_diffuse ) - float fresnelD = 1.0f - @insertpiece( getMaxFresnelS );@end - - //Avoid very small denominators, they go to NaN or cause aliasing artifacts - @insertpiece( FresnelType ) Rs = ( fresnelS * (R * G) ) / max( 4.0 * NdotV * NdotL, 0.01 ); - - return NdotL * (@insertpiece( kS ).xyz * lightSpecular * Rs + - @insertpiece( kD ).xyz * lightDiffuse * fresnelD); -} -@end -@end - -@property( BRDF_Default ) -@piece( DeclareBRDF ) -//Default BRDF -vec3 BRDF( vec3 lightDir, vec3 viewDir, float NdotV, vec3 lightDiffuse, vec3 lightSpecular ) -{ - vec3 halfWay= normalize( lightDir + viewDir ); - float NdotL = clamp( dot( nNormal, lightDir ), 0.0, 1.0 ); - float NdotH = clamp( dot( nNormal, halfWay ), 0.0, 1.0 ); - float VdotH = clamp( dot( viewDir, halfWay ), 0.0, 1.0 ); - - float sqR = ROUGHNESS * ROUGHNESS; - - //Roughness/Distribution/NDF term (GGX) - //Formula: - // Where alpha = roughness - // R = alpha^2 / [ PI * [ ( NdotH^2 * (alpha^2 - 1) ) + 1 ]^2 ] - float f = ( NdotH * sqR - NdotH ) * NdotH + 1.0; - float R = sqR / (f * f + 1e-6f); - - //Geometric/Visibility term (Smith GGX Height-Correlated) -@property( GGX_height_correlated ) - float Lambda_GGXV = NdotL * sqrt( (-NdotV * sqR + NdotV) * NdotV + sqR ); - float Lambda_GGXL = NdotV * sqrt( (-NdotL * sqR + NdotL) * NdotL + sqR ); - - float G = 0.5 / (( Lambda_GGXV + Lambda_GGXL + 1e-6f ) * 3.141592654); -@end @property( !GGX_height_correlated ) - float gL = NdotL * (1-sqR) + sqR; - float gV = NdotV * (1-sqR) + sqR; - float G = 1.0 / (( gL * gV + 1e-4f ) * 4 * 3.141592654); -@end - - //Formula: - // fresnelS = lerp( (1 - V*H)^5, 1, F0 ) - @insertpiece( FresnelType ) fresnelS = @insertpiece( getSpecularFresnel ); - - //We should divide Rs by PI, but it was done inside G for performance - vec3 Rs = ( fresnelS * (R * G) ) * @insertpiece( kS ).xyz * lightSpecular; - - //Diffuse BRDF (*Normalized* Disney, see course_notes_moving_frostbite_to_pbr.pdf - //"Moving Frostbite to Physically Based Rendering" Sebastien Lagarde & Charles de Rousiers) - float energyBias = ROUGHNESS * 0.5; - float energyFactor = mix( 1.0, 1.0 / 1.51, ROUGHNESS ); - float fd90 = energyBias + 2.0 * VdotH * VdotH * ROUGHNESS; - float lightScatter = 1.0 + (fd90 - 1.0) * pow( 1.0 - NdotL, 5.0 ); - float viewScatter = 1.0 + (fd90 - 1.0) * pow( 1.0 - NdotV, 5.0 ); - -@property( fresnel_separate_diffuse ) - @insertpiece( FresnelType ) fresnelD = @insertpiece( getDiffuseFresnel ); -@end @property( !fresnel_separate_diffuse ) - float fresnelD = 1.0f - @insertpiece( getMaxFresnelS );@end - - //We should divide Rd by PI, but it is already included in kD - vec3 Rd = (lightScatter * viewScatter * energyFactor * fresnelD) * @insertpiece( kD ).xyz * lightDiffuse; - - return NdotL * (Rs + Rd); -} -@end -@end - -@property( hlms_enable_vpls ) -@piece( DeclareBRDF_InstantRadiosity ) -//Simplified cheap BRDF for Instant Radiosity. -vec3 BRDF_IR( vec3 lightDir, vec3 lightDiffuse ) -{ - float NdotL = clamp( dot( nNormal, lightDir ), 0.0, 1.0 ); - @insertpiece( FresnelType ) fresnelD = @insertpiece( getDiffuseFresnel ); - - //We should divide Rd by PI, but it is already included in kD - return NdotL * fresnelD * @insertpiece( kD ).xyz * lightDiffuse; -} -@end -@end - -/// Applying Fresnel term to prefiltered cubemap has a bad effect of always showing high specular -/// color at edge, even for rough surface. See https://seblagarde.wordpress.com/2011/08/17/hello-world/ -/// and see http://www.ogre3d.org/forums/viewtopic.php?f=25&p=523550#p523544 -/// "The same Fresnel term which is appropriate for unfiltered environment maps (i.e. perfectly smooth -/// mirror surfaces) is not appropriate for filtered environment maps since there you are averaging -/// incoming light colors from many directions, but using a single Fresnel value computed for the -/// reflection direction. The correct function has similar values as the regular Fresnel expression -/// at v=n, but at glancing angle it behaves differently. In particular, the lerp(from base specular -/// to white) does not go all the way to white at glancing angles in the case of rough surfaces." -/// So we use getSpecularFresnelWithRoughness instead. -@piece( BRDF_EnvMap ) - float NdotL = clamp( dot( nNormal, reflDir ), 0.0, 1.0 ); - float VdotH = clamp( dot( viewDir, normalize( reflDir + viewDir ) ), 0.0, 1.0 ); - @insertpiece( FresnelType ) fresnelS = @insertpiece( getSpecularFresnelWithRoughness ); - - @property( fresnel_separate_diffuse ) - @insertpiece( FresnelType ) fresnelD = @insertpiece( getDiffuseFresnelWithRoughness ); - @end @property( !fresnel_separate_diffuse ) - float fresnelD = 1.0f - @insertpiece( getMaxFresnelS );@end - - finalColour += envColourD * @insertpiece( kD ).xyz * fresnelD + - envColourS * @insertpiece( kS ).xyz * fresnelS; -@end - -@property( hlms_fine_light_mask ) - @piece( DeclareObjLightMask )uint objLightMask = instance.worldMaterialIdx[inPs.drawId].z;@end - @piece( ObjLightMaskCmp )if( (objLightMask & floatBitsToUint( passBuf.lights[@counter(fineMaskLightIdx)].position.w )) != 0u )@end - @piece( andObjLightMaskCmp )&& ((objLightMask & floatBitsToUint( passBuf.lights[@counter(fineMaskLightIdx)].position.w )) != 0u)@end - @piece( andObjAreaApproxLightMaskCmp )&& ((objLightMask & floatBitsToUint( passBuf.areaApproxLights[@counter(fineMaskAreaApproxLightIdx)].position.w )) != 0u)@end -@end diff --git a/ogre2/src/media/Hlms/Pbs/GLSL/BlendModes_piece_ps.glsl b/ogre2/src/media/Hlms/Pbs/GLSL/BlendModes_piece_ps.glsl deleted file mode 100644 index f77d20385..000000000 --- a/ogre2/src/media/Hlms/Pbs/GLSL/BlendModes_piece_ps.glsl +++ /dev/null @@ -1,105 +0,0 @@ -//Reset t to 0 just in case (values are preserved from previous stages) -@pset( t, 0 ) - -@property( !hlms_shadowcaster ) -@piece( NormalNonPremul ) - //Normal Non Premultiplied @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, detailCol@value(t).xyz, detailCol@value(t).a ); - diffuseCol.w = mix( diffuseCol.w, 1.0, detailCol@value(t).w ); -@end - -@piece( NormalPremul ) - //Normal Premultiplied @value(t) - diffuseCol.xyz = (1.0 - detailCol@value(t).a) * diffuseCol.xyz + detailCol@value(t).xyz; - diffuseCol.w = mix( diffuseCol.w, 1.0, detailCol@value(t).w ); -@end - -@piece( Add ) - //Add @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - min( diffuseCol.xyz + detailCol@value(t).xyz, vec3(1.0, 1.0, 1.0) ), - detailCol@value(t).a ); -@end - -@piece( Subtract ) - //Subtract @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - max( diffuseCol.xyz - detailCol@value(t).xyz, vec3(0.0, 0.0, 0.0) ), - detailCol@value(t).a ); -@end - -@piece( Multiply ) - //Multiply @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - diffuseCol.xyz * detailCol@value(t).xyz, - detailCol@value(t).a ); -@end - -@piece( Multiply2x ) - //Multiply2x @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - min( diffuseCol.xyz * detailCol@value(t).xyz * 2.0, vec3(1.0, 1.0, 1.0) ), - detailCol@value(t).a ); -@end - -@piece( Screen ) - //Screen @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - 1.0 - (1.0 - diffuseCol.xyz) * (1.0 - detailCol@value(t).xyz), - detailCol@value(t).a ); -@end - -@piece( Overlay ) - //Overlay @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - diffuseCol.xyz * ( diffuseCol.xyz + 2.0 * detailCol@value(t).xyz * (1.0 - diffuseCol.xyz) ), - detailCol@value(t).a ); -@end - -@piece( Lighten ) - //Lighten @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - max( diffuseCol.xyz, detailCol@value(t).xyz ), - detailCol@value(t).a ); -@end - -@piece( Darken ) - //Darken @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - min( diffuseCol.xyz, detailCol@value(t).xyz ), - detailCol@value(t).a ); -@end - -@piece( GrainExtract ) - //GrainExtract @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - (diffuseCol.xyz - detailCol@value(t).xyz) + 0.5f, - detailCol@value(t).a ); -@end - -@piece( GrainMerge ) - //GrainMerge @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - (diffuseCol.xyz + detailCol@value(t).xyz) - 0.5f, - detailCol@value(t).a ); -@end - -@piece( Difference ) - //Difference @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - abs(diffuseCol.xyz - detailCol@value(t).xyz), - detailCol@value(t).a ); -@end -@end @property( hlms_shadowcaster ) - -@piece( NormalNonPremul ) - //Normal Non Premultiplied @value(t) - diffuseCol = mix( diffuseCol, 1.0, detailCol@value(t) ); -@end - -@piece( NormalPremul ) - //Normal Premultiplied @value(t) - diffuseCol = mix( diffuseCol, 1.0, detailCol@value(t) ); -@end - -@end diff --git a/ogre2/src/media/Hlms/Pbs/GLSL/DetailMaps_piece_ps.glsl b/ogre2/src/media/Hlms/Pbs/GLSL/DetailMaps_piece_ps.glsl deleted file mode 100644 index 4f6a1ab30..000000000 --- a/ogre2/src/media/Hlms/Pbs/GLSL/DetailMaps_piece_ps.glsl +++ /dev/null @@ -1,26 +0,0 @@ -// detail_maps_diffuse & detail_maps_normal are either 0 or 4 - -@pmax( NumDetailMaps, detail_maps_diffuse, detail_maps_normal ) -@foreach( NumDetailMaps, n ) - @property( detail_offsets@n ) - @piece( offsetDetail@n ) * material.detailOffsetScale[@n].zw + material.detailOffsetScale[@n].xy@end - @end -@end - -@piece( detail_swizzle0 )x@end; -@piece( detail_swizzle1 )y@end; -@piece( detail_swizzle2 )z@end; -@piece( detail_swizzle3 )w@end; - -/* -Down below we perform: - if( detail_maps_normal ) - second_valid_detail_map_nm = first_valid_detail_map_nm + 1; - else - second_valid_detail_map_nm = 0; -*/ -@property( detail_maps_normal ) - @add( second_valid_detail_map_nm, first_valid_detail_map_nm, 1 ) -@end @property( !detail_maps_normal ) - @set( second_valid_detail_map_nm, 0 ) -@end diff --git a/ogre2/src/media/Hlms/Pbs/GLSL/IrradianceVolume_piece_ps.glsl b/ogre2/src/media/Hlms/Pbs/GLSL/IrradianceVolume_piece_ps.glsl deleted file mode 100644 index d0bb837af..000000000 --- a/ogre2/src/media/Hlms/Pbs/GLSL/IrradianceVolume_piece_ps.glsl +++ /dev/null @@ -1,67 +0,0 @@ -@property( irradiance_volumes ) -@piece( applyIrradianceVolumes ) - vec3 worldNormal = nNormal.xyz * mat3(passBuf.invView); - vec3 worldPos = (vec4( inPs.pos.xyz, 1.0 ) * passBuf.invView).xyz; - - vec3 irradiancePos = worldPos.xyz * passBuf.irradianceSize.xyz - passBuf.irradianceOrigin.xyz; - //Floor irradiancePos.y and put the fractional part so we can lerp. - irradiancePos.y -= 0.5f; //Texel centers are at center. Move it to origin. - float origYPos; - float fIrradianceYWeight = modf( irradiancePos.y, origYPos ); - origYPos *= 6.0; - origYPos += 0.5f; //Make sure we sample at center (so HW doesn't do linear - //filtering on the Y axis. We'll do that manually) - - vec3 isNegative = vec3( lessThan( worldNormal.xyz, vec3( 0, 0, 0 ) ) ); - - vec3 tmpAmbientSample; - - //We need to make 3 samples (actually 6), one for each axis. - /* The code is basically doing: - vec3 cAmbientCube[6]; - int3 isNegative = ( worldNormal < 0.0 ); - float3 linearColor; - linearColor = worldNormalSq.x * cAmbientCube[isNegative.x] + - worldNormalSq.y * cAmbientCube[isNegative.y+2] + - worldNormalSq.z * cAmbientCube[isNegative.z+4]; - - We have 6 colour values per voxel. But GPUs can only store 1 colour value per cell. - So we 6x the height to workaround that limitation. This also means we loose the ability - to do HW bilinear filtering around the Y axis; therefore we do it ourselves manually. - Because of this, instead of doing 3 samples, we end up doing 6 (in order to perform - filtering around the Y axis) - **/ - - float irradianceTexInvHeight = passBuf.irradianceSize.w; - - irradiancePos.y = (origYPos + isNegative.x) * irradianceTexInvHeight; - vec3 xAmbientSample = texture( irradianceVolume, irradiancePos ).xyz; - irradiancePos.y += 6.0f * irradianceTexInvHeight; - tmpAmbientSample = texture( irradianceVolume, irradiancePos ).xyz; - - xAmbientSample = mix( xAmbientSample, tmpAmbientSample, fIrradianceYWeight ); - - irradiancePos.y = (origYPos + (2.0f + isNegative.y)) * irradianceTexInvHeight; - vec3 yAmbientSample = texture( irradianceVolume, irradiancePos ).xyz; - irradiancePos.y += 6.0f * irradianceTexInvHeight; - tmpAmbientSample = texture( irradianceVolume, irradiancePos ).xyz; - - yAmbientSample = mix( yAmbientSample, tmpAmbientSample, fIrradianceYWeight ); - - irradiancePos.y = (origYPos + (4.0f + isNegative.z)) * irradianceTexInvHeight; - vec3 zAmbientSample = texture( irradianceVolume, irradiancePos ).xyz; - irradiancePos.y += 6.0f * irradianceTexInvHeight; - tmpAmbientSample = texture( irradianceVolume, irradiancePos ).xyz; - - zAmbientSample = mix( zAmbientSample, tmpAmbientSample, fIrradianceYWeight ); - - - vec3 worldNormalSq = worldNormal.xyz * worldNormal.xyz; - vec3 ambientTerm = worldNormalSq.x * xAmbientSample.xyz + - worldNormalSq.y * yAmbientSample.xyz + - worldNormalSq.z * zAmbientSample.xyz; - ambientTerm *= passBuf.irradianceOrigin.w; //irradianceOrigin.w = irradianceMaxPower - - finalColour.xyz += ambientTerm.xyz * @insertpiece( kD ).xyz; -@end -@end diff --git a/ogre2/src/media/Hlms/Pbs/GLSL/Structs_piece_vs_piece_ps.glsl b/ogre2/src/media/Hlms/Pbs/GLSL/Structs_piece_vs_piece_ps.glsl deleted file mode 100644 index 8ef0c15aa..000000000 --- a/ogre2/src/media/Hlms/Pbs/GLSL/Structs_piece_vs_piece_ps.glsl +++ /dev/null @@ -1,244 +0,0 @@ -@piece( PassDecl ) -struct ShadowReceiverData -{ - mat4 texViewProj; -@property( exponential_shadow_maps ) - vec4 texViewZRow; -@end - vec2 shadowDepthRange; - vec4 invShadowMapSize; -}; - -struct Light -{ - vec4 position; //.w contains the objLightMask - vec3 diffuse; - vec3 specular; -@property( hlms_num_shadow_map_lights ) - vec3 attenuation; - //Spotlights: - // spotDirection.xyz is direction - // spotParams.xyz contains falloff params - //Custom 2D Shape: - // spotDirection.xyz direction - // spotDirection.w customShapeHalfRectSize.x - // spotParams.xyz tangent - // spotParams.w customShapeHalfRectSize.y - vec4 spotDirection; - vec4 spotParams; -@end -}; - -#define areaLightDiffuseMipmapStart areaApproxLights[0].diffuse.w -#define areaLightNumMipmapsSpecFactor areaApproxLights[0].specular.w - -struct AreaLight -{ - vec4 position; //.w contains the objLightMask - vec4 diffuse; //[0].w contains diffuse mipmap start - vec4 specular; //[0].w contains mipmap scale - vec4 attenuation; //.w contains texture array idx - //Custom 2D Shape: - // direction.xyz direction - // direction.w invHalfRectSize.x - // tangent.xyz tangent - // tangent.w invHalfRectSize.y - vec4 direction; - vec4 tangent; - vec4 doubleSided; -}; - -@insertpiece( DeclCubemapProbeStruct ) - -//Uniforms that change per pass -layout_constbuffer(binding = 0) uniform PassBuffer -{ - //Vertex shader (common to both receiver and casters) - mat4 viewProj; - -@property( hlms_global_clip_planes ) - vec4 clipPlane0; -@end - -@property( hlms_shadowcaster_point ) - vec4 cameraPosWS; //Camera position in world space -@end - -@property( !hlms_shadowcaster ) - //Vertex shader - mat4 view; - @property( hlms_num_shadow_map_lights )ShadowReceiverData shadowRcv[@value(hlms_num_shadow_map_lights)];@end - - //------------------------------------------------------------------------- - - //Pixel shader - mat3 invViewMatCubemap; - - -@property( hlms_use_prepass ) - vec4 windowHeight; -@end - -@property( ambient_hemisphere || ambient_fixed || envmap_scale ) - vec4 ambientUpperHemi; -@end -@property( ambient_hemisphere ) - vec4 ambientLowerHemi; - vec4 ambientHemisphereDir; -@end - -@property( irradiance_volumes ) - vec4 irradianceOrigin; //.w = maxPower - vec4 irradianceSize; //.w = 1.0f / irradianceTexture->getHeight() - mat4 invView; -@end - -@property( hlms_pssm_splits )@psub( hlms_pssm_splits_minus_one, hlms_pssm_splits, 1 )@foreach( hlms_pssm_splits, n ) - float pssmSplitPoints@n;@end @end -@property( hlms_pssm_blend )@foreach( hlms_pssm_splits_minus_one, n ) - float pssmBlendPoints@n;@end @end -@property( hlms_pssm_fade ) - float pssmFadePoint;@end - @property( hlms_lights_spot )Light lights[@value(hlms_lights_spot)];@end - @property( hlms_lights_area_approx )AreaLight areaApproxLights[@value(hlms_lights_area_approx)];@end -@end @property( hlms_shadowcaster ) - //Vertex shader - @property( exponential_shadow_maps )vec4 viewZRow;@end - vec2 depthRange; -@end - -@property( hlms_forwardplus ) - //Forward3D - //f3dData.x = minDistance; - //f3dData.y = invMaxDistance; - //f3dData.z = f3dNumSlicesSub1; - //f3dData.w = uint cellsPerTableOnGrid0 (floatBitsToUint); - - //Clustered Forward: - //f3dData.x = minDistance; - //f3dData.y = invExponentK; - //f3dData.z = f3dNumSlicesSub1; - //f3dData.w = renderWindow->getHeight(); - vec4 f3dData; - @property( hlms_forwardplus == forward3d ) - vec4 f3dGridHWW[@value( forward3d_num_slices )]; - vec4 f3dViewportOffset; - @end - @property( hlms_forwardplus != forward3d ) - vec4 fwdScreenToGrid; - @end -@end - - @insertpiece( DeclPlanarReflUniforms ) - -@property( parallax_correct_cubemaps ) - CubemapProbe autoProbe; -@end - - @insertpiece( custom_passBuffer ) -} passBuf; -@end - -@property( fresnel_scalar )@piece( FresnelType )vec3@end @piece( FresnelSwizzle )xyz@end @end -@property( !fresnel_scalar )@piece( FresnelType )float@end @piece( FresnelSwizzle )x@end @end - -@piece( MaterialDecl ) -//Uniforms that change per Item/Entity, but change very infrequently -struct Material -{ - /* kD is already divided by PI to make it energy conserving. - (formula is finalDiffuse = NdotL * surfaceDiffuse / PI) - */ - vec4 bgDiffuse; - vec4 kD; //kD.w is alpha_test_threshold - vec4 kS; //kS.w is roughness - //Fresnel coefficient, may be per colour component (vec3) or scalar (float) - //F0.w is transparency - vec4 F0; - vec4 normalWeights; - vec4 cDetailWeights; - vec4 detailOffsetScale[4]; - vec4 emissive; //emissive.w contains mNormalMapWeight. - vec4 userValue[3]; - - uvec4 indices0_3; - uvec4 indices4_7; - - @insertpiece( custom_materialBuffer ) -}; - -layout_constbuffer(binding = 1) uniform MaterialBuf -{ - Material m[@value( materials_per_buffer )]; -} materialArray; -@end - -@piece( InstanceDecl ) -//Uniforms that change per Item/Entity -layout_constbuffer(binding = 2) uniform InstanceBuffer -{ - //.x = - //The lower 9 bits contain the material's start index. - //The higher 23 bits contain the world matrix start index. - // - //.y = - //shadowConstantBias. Send the bias directly to avoid an - //unnecessary indirection during the shadow mapping pass. - //Must be loaded with uintBitsToFloat - // - //.z = - //lightMask. Ogre must have been compiled with OGRE_NO_FINE_LIGHT_MASK_GRANULARITY - uvec4 worldMaterialIdx[4096]; -} instance; -@end - -@property( envprobe_map && envprobe_map != target_envprobe_map && use_parallax_correct_cubemaps ) -@piece( PccManualProbeDecl ) -layout_constbuffer(binding = 3) uniform ManualProbe -{ - CubemapProbe probe; -} manualProbe; -@end -@end - -@piece( VStoPS_block ) - @property( !hlms_shadowcaster ) - @property( !lower_gpu_overhead ) - flat uint drawId; - @end - @property( hlms_normal || hlms_qtangent ) - vec3 pos; - vec3 normal; - @property( normal_map )vec3 tangent; - @property( hlms_qtangent )flat float biNormalReflection;@end - @end - @end - @foreach( hlms_uv_count, n ) - vec@value( hlms_uv_count@n ) uv@n;@end - - @foreach( hlms_num_shadow_map_lights, n ) - @property( !hlms_shadowmap@n_is_point_light ) - vec4 posL@n;@end @end - @property( hlms_pssm_splits )float depth;@end - @property( hlms_use_prepass_msaa > 1 ) - float2 zwDepth; - @end - @end - @property( hlms_shadowcaster ) - @property( alpha_test ) - flat uint drawId; - @foreach( hlms_uv_count, n ) - vec@value( hlms_uv_count@n ) uv@n;@end - @end - @property( (!hlms_shadow_uses_depth_texture || exponential_shadow_maps) && !hlms_shadowcaster_point ) - float depth; - @end - @property( hlms_shadowcaster_point ) - vec3 toCameraWS; - @property( !exponential_shadow_maps ) - flat float constBias; - @end - @end - @end - @insertpiece( custom_VStoPS ) -@end diff --git a/ogre2/src/media/Hlms/Pbs/GLSL/Textures_piece_ps.glsl b/ogre2/src/media/Hlms/Pbs/GLSL/Textures_piece_ps.glsl deleted file mode 100644 index cbc01aec0..000000000 --- a/ogre2/src/media/Hlms/Pbs/GLSL/Textures_piece_ps.glsl +++ /dev/null @@ -1,107 +0,0 @@ -@property( diffuse_map ) - @property( !hlms_shadowcaster ) - @piece( SampleDiffuseMap ) diffuseCol = texture( textureMaps[@value( diffuse_map_idx )], - vec3( UV_DIFFUSE( inPs.uv@value(uv_diffuse).xy ), - diffuseIdx ) ); - @property( !hw_gamma_read ) diffuseCol = diffuseCol * diffuseCol;@end - @end - @end @property( hlms_shadowcaster ) - @piece( SampleDiffuseMap ) diffuseCol = texture( textureMaps[@value( diffuse_map_idx )], - vec3( UV_DIFFUSE( inPs.uv@value(uv_diffuse).xy ), - diffuseIdx ) ).w;@end - @end -@end - -//diffuseCol always has some colour and is multiplied against material.kD in PixelShader_ps. -@piece( kD )diffuseCol@end - -@property( !hlms_prepass ) -@property( !metallic_workflow ) - @property( specular_map && !fresnel_workflow ) - @piece( SampleSpecularMap ) specularCol = texture( textureMaps[@value( specular_map_idx )], - vec3( UV_SPECULAR( inPs.uv@value(uv_specular).xy ), - specularIdx) ).xyz * material.kS.xyz;@end - @piece( kS )specularCol@end - @end - @property( specular_map && fresnel_workflow ) - @piece( SampleSpecularMap ) F0 = texture( textureMaps[@value( specular_map_idx )], - vec3( UV_SPECULAR( inPs.uv@value(uv_specular).xy ), - specularIdx) ).@insertpiece( FresnelSwizzle ) * material.F0.@insertpiece( FresnelSwizzle );@end - @end - @property( !specular_map || fresnel_workflow ) - @piece( kS )material.kS@end - @end -@end @property( metallic_workflow ) -@piece( SampleSpecularMap ) - @property( specular_map ) - float metalness = texture( textureMaps[@value( specular_map_idx )], - vec3( UV_SPECULAR( inPs.uv@value(uv_specular).xy ), - specularIdx) ).x * material.F0.x; - F0 = mix( vec3( 0.03f ), @insertpiece( kD ).xyz * 3.14159f, metalness ); - @insertpiece( kD ).xyz = @insertpiece( kD ).xyz - @insertpiece( kD ).xyz * metalness; - @end @property( !specular_map ) - F0 = mix( vec3( 0.03f ), @insertpiece( kD ).xyz * 3.14159f, material.F0.x ); - @insertpiece( kD ).xyz = @insertpiece( kD ).xyz - @insertpiece( kD ).xyz * material.F0.x; - @end - @property( hlms_alphablend )F0 *= material.F0.w;@end - @property( transparent_mode )F0 *= diffuseCol.w;@end -@end /// SampleSpecularMap - - @piece( kS )material.kS.xyz@end -@end -@end - -@property( roughness_map ) - @piece( SampleRoughnessMap ) - ROUGHNESS = material.kS.w * texture( textureMaps[@value( roughness_map_idx )], - vec3( UV_ROUGHNESS( inPs.uv@value(uv_roughness).xy ), - roughnessIdx) ).x; - ROUGHNESS = max( ROUGHNESS, 0.001f ); - @end -@end - -@foreach( detail_maps_normal, n ) - @piece( SampleDetailMapNm@n )getTSDetailNormal( textureMaps[@value(detail_map_nm@n_idx)], - vec3( UV_DETAIL_NM@n( inPs.uv@value(uv_detail_nm@n).xy@insertpiece( offsetDetail@n ) ), - detailNormMapIdx@n ) ) * detailWeights.@insertpiece(detail_swizzle@n) - @insertpiece( detail@n_nm_weight_mul )@end -@end - -@property( detail_weight_map ) - @piece( SamplerDetailWeightMap )texture( textureMaps[@value(detail_weight_map_idx)], - vec3( UV_DETAIL_WEIGHT( inPs.uv@value(uv_detail_weight).xy ), weightMapIdx) )@end -@end - -@property( envmap_scale ) - @piece( ApplyEnvMapScale )* passBuf.ambientUpperHemi.w@end -@end - -@property( (envprobe_map && envprobe_map != target_envprobe_map) || parallax_correct_cubemaps ) - @set( use_envprobe_map, 1 ) - - @property( !envprobe_map || envprobe_map == target_envprobe_map ) - /// "No cubemap"? Then we're in auto mode or... - /// We're rendering to the cubemap probe we're using as manual. Use the auto mode as fallback. - @piece( pccProbeSource )passBuf.autoProbe@end - @set( use_parallax_correct_cubemaps, 1 ) - @end - @property( envprobe_map && envprobe_map != target_envprobe_map && use_parallax_correct_cubemaps ) - @piece( pccProbeSource )manualProbe.probe@end - @end -@end - -@property( emissive_map ) - @piece( SampleEmissiveMap ) - vec3 emissiveCol = texture( textureMaps[@value( emissive_map_idx )], - vec3( UV_EMISSIVE( inPs.uv@value(uv_emissive).xy ), - emissiveMapIdx ) ).xyz; - @property( emissive_constant ) - emissiveCol *= material.emissive.xyz; - @end - @end -@end -@property( !emissive_map && emissive_constant ) - @piece( SampleEmissiveMap ) - vec3 emissiveCol = material.emissive.xyz; - @end -@end diff --git a/ogre2/src/media/Hlms/Pbs/Metal/BRDFs_piece_ps.metal b/ogre2/src/media/Hlms/Pbs/Metal/BRDFs_piece_ps.metal deleted file mode 100644 index 4ecc346f2..000000000 --- a/ogre2/src/media/Hlms/Pbs/Metal/BRDFs_piece_ps.metal +++ /dev/null @@ -1,242 +0,0 @@ -@property( !metallic_workflow && (!specular_map || !fresnel_workflow) ) - @property( !transparent_mode ) - @piece( F0 )material.F0@end - @end @property( transparent_mode ) - //Premultiply F0.xyz with the alpha from the texture, but only in transparent mode. - @property( fresnel_scalar ) - @piece( F0 )(material.F0.@insertpiece( FresnelSwizzle ) * diffuseCol.w)@end - @end @property( !fresnel_scalar ) - @piece( F0 )float1(material.F0.@insertpiece( FresnelSwizzle ) * diffuseCol.w)@end - @end - @end -@end @property( metallic_workflow || (specular_map && fresnel_workflow) ) - @piece( F0 )F0@end -@end - -@property( !fresnel_scalar ) - @piece( maxR1F0 )max( 1.0 - ROUGHNESS, @insertpiece( F0 ).x )@end -@end @property( fresnel_scalar ) - @piece( maxR1F0 )max( (1.0 - ROUGHNESS), @insertpiece( F0 ).xyz )@end -@end - -//For mortals: -// getSpecularFresnel = F0 + pow( 1.0 - VdotH, 5.0 ) * (1.0 - F0) -// getDiffuseFresnel = 1.0 - F0 + pow( 1.0 - NdotL, 5.0 ) * F0 -// getSpecularFresnelWithRoughness = F0 + pow( 1.0 - VdotH, 5.0 ) * (max(ROUGHNESS, (1.0 - F0)) - F0) -// getDiffuseFresnelWithRoughness = max(ROUGHNESS, (1.0 - F0) - F0 + pow( 1.0 - NdotL, 5.0 ) * F0 -@piece( getSpecularFresnel )@insertpiece( F0 ).@insertpiece( FresnelSwizzle ) + pow( 1.0 - VdotH, 5.0 ) * (1.0 - @insertpiece( F0 ).@insertpiece( FresnelSwizzle ))@end -@piece( getDiffuseFresnel )1.0 - @insertpiece( F0 ).@insertpiece( FresnelSwizzle ) + pow( 1.0 - NdotL, 5.0 ) * @insertpiece( F0 ).@insertpiece( FresnelSwizzle )@end - -@piece( getSpecularFresnelWithRoughness )@insertpiece( F0 ).@insertpiece( FresnelSwizzle ) + pow( 1.0 - VdotH, 5.0 ) * (@insertpiece( maxR1F0 ) - @insertpiece( F0 ).@insertpiece( FresnelSwizzle ))@end -@piece( getDiffuseFresnelWithRoughness )@insertpiece( maxR1F0 ) - @insertpiece( F0 ).@insertpiece( FresnelSwizzle ) + pow( 1.0 - NdotL, 5.0 ) * @insertpiece( F0 ).@insertpiece( FresnelSwizzle )@end - -@property( !fresnel_scalar ) - @piece( getMaxFresnelS )fresnelS@end -@end @property( fresnel_scalar ) - @piece( getMaxFresnelS )max( fresnelS.x, max( fresnelS.y, fresnelS.z ) )@end -@end - -@property( BRDF_BlinnPhong ) -@piece( DeclareBRDF ) -//Blinn-Phong -inline float3 BRDF( float3 lightDir, float3 viewDir, float NdotV, float3 lightDiffuse, - float3 lightSpecular, Material material, float3 nNormal @insertpiece( brdfExtraParamDefs ) ) -{ - float3 halfWay= normalize( lightDir + viewDir ); - float NdotL = saturate( dot( nNormal, lightDir ) ); //Diffuse (Lambert) - float NdotH = clamp( dot( nNormal, halfWay ), 0.001, 1.0 ); //Specular - @property( !legacy_math_brdf ) - float VdotH = clamp( dot( viewDir, halfWay ), 0.001, 1.0 ); //Fresnel - - //Fresnel term (Schlick's approximation) - @insertpiece( FresnelType ) fresnelS = @insertpiece( getSpecularFresnel ); - @property( fresnel_separate_diffuse ) - @insertpiece( FresnelType ) fresnelD = @insertpiece( getDiffuseFresnel ); - @end @property( !fresnel_separate_diffuse ) - float fresnelD = 1.0f - @insertpiece( getMaxFresnelS ); - @end - @end - - @property( !roughness_is_shininess ) - float shininess = exp2( 10.0 * (1.0 - ROUGHNESS) + 1.0 ) * 0.25; - @end @property( roughness_is_shininess ) - float shininess = ROUGHNESS; - @end - float blinnPhong = pow( NdotH, shininess ); - - @property( !legacy_math_brdf ) - //Normalize Blinn-Phong using (n + 8) / (8 * pi) - //Note this factor is an approximation. The real normalization is - //*much* more expensive. See: - //http://www.rorydriscoll.com/2009/01/25/energy-conservation-in-games/ - blinnPhong *= (shininess + 8.0) / (8.0 * 3.141592654); - - //Avoid very small denominators, they go to NaN or cause aliasing artifacts - //Note: For blinn-phong we use larger denominators otherwise specular blows out of proportion - @insertpiece( FresnelType ) Rs = ( fresnelS * blinnPhong ) / max( 4.0 * NdotV * NdotL, 0.75 ); - //Make diffuse look closer to Default. - fresnelD *= mix( 1.0, 1.0 / 1.51, ROUGHNESS ); - @end @property( legacy_math_brdf ) - float Rs = blinnPhong; - float fresnelD = 1.0; - @end - - return NdotL * (@insertpiece( kS ).xyz * lightSpecular * Rs + - @insertpiece( kD ).xyz * lightDiffuse * fresnelD); -} -@end -@end - -@property( BRDF_CookTorrance ) -@piece( DeclareBRDF ) -//Cook-Torrance -inline float3 BRDF( float3 lightDir, float3 viewDir, float NdotV, float3 lightDiffuse, float3 lightSpecular, Material material, float3 nNormal @insertpiece( brdfExtraParamDefs ) ) -{ - float3 halfWay= normalize( lightDir + viewDir ); - float NdotL = saturate( dot( nNormal, lightDir ) ); - float NdotH = clamp( dot( nNormal, halfWay ), 0.001, 1.0 ); - float VdotH = clamp( dot( viewDir, halfWay ), 0.001, 1.0 ); - - float sqR = ROUGHNESS * ROUGHNESS; - - //Roughness/Distribution/NDF term (Beckmann distribution) - //Formula: - // Where alpha = NdotH and m = roughness - // R = [ 1 / (m^2 x cos(alpha)^4 ] x [ e^( -tan(alpha)^2 / m^2 ) ] - // R = [ 1 / (m^2 x cos(alpha)^4 ] x [ e^( ( cos(alpha)^2 - 1 ) / (m^2 cos(alpha)^2 ) ] - float NdotH_sq = NdotH * NdotH; - float roughness_a = 1.0 / ( 3.141592654 * sqR * NdotH_sq * NdotH_sq );//( 1 / (m^2 x cos(alpha)^4 ) - float roughness_b = NdotH_sq - 1.0; //( cos(alpha)^2 - 1 ) - float roughness_c = sqR * NdotH_sq; //( m^2 cos(alpha)^2 ) - - //Avoid Inf * 0 = NaN; we need Inf * 0 = 0 - float R = min( roughness_a, 65504.0 ) * exp( roughness_b / roughness_c ); - - //Geometric/Visibility term (Cook Torrance) - float shared_geo = 2.0 * NdotH / VdotH; - float geo_b = shared_geo * NdotV; - float geo_c = shared_geo * NdotL; - float G = min( 1.0, min( geo_b, geo_c ) ); - - //Fresnel term (Schlick's approximation) - //Formula: - // fresnelS = lerp( (1 - V*H)^5, 1, F0 ) - // fresnelD = lerp( (1 - N*L)^5, 1, 1 - F0 ) [See s2010_course_note_practical_implementation_at_triace.pdf] - @insertpiece( FresnelType ) fresnelS = @insertpiece( getSpecularFresnel ); -@property( fresnel_separate_diffuse ) - @insertpiece( FresnelType ) fresnelD = @insertpiece( getDiffuseFresnel ); -@end @property( !fresnel_separate_diffuse ) - float fresnelD = 1.0f - @insertpiece( getMaxFresnelS );@end - - //Avoid very small denominators, they go to NaN or cause aliasing artifacts - @insertpiece( FresnelType ) Rs = ( fresnelS * (R * G) ) / max( 4.0 * NdotV * NdotL, 0.01 ); - - return NdotL * (@insertpiece( kS ).xyz * lightSpecular * Rs + - @insertpiece( kD ).xyz * lightDiffuse * fresnelD); -} -@end -@end - -@property( BRDF_Default ) -@piece( DeclareBRDF ) -//Default BRDF -inline float3 BRDF( float3 lightDir, float3 viewDir, float NdotV, float3 lightDiffuse, float3 lightSpecular, Material material, float3 nNormal @insertpiece( brdfExtraParamDefs ) ) -{ - float3 halfWay= normalize( lightDir + viewDir ); - float NdotL = saturate( dot( nNormal, lightDir ) ); - float NdotH = saturate( dot( nNormal, halfWay ) ); - float VdotH = saturate( dot( viewDir, halfWay ) ); - - float sqR = ROUGHNESS * ROUGHNESS; - - //Roughness/Distribution/NDF term (GGX) - //Formula: - // Where alpha = roughness - // R = alpha^2 / [ PI * [ ( NdotH^2 * (alpha^2 - 1) ) + 1 ]^2 ] - float f = ( NdotH * sqR - NdotH ) * NdotH + 1.0; - float R = sqR / (f * f + 1e-6f); - - //Geometric/Visibility term (Smith GGX Height-Correlated) -@property( GGX_height_correlated ) - float Lambda_GGXV = NdotL * sqrt( (-NdotV * sqR + NdotV) * NdotV + sqR ); - float Lambda_GGXL = NdotV * sqrt( (-NdotL * sqR + NdotL) * NdotL + sqR ); - - float G = 0.5 / (( Lambda_GGXV + Lambda_GGXL + 1e-6f ) * 3.141592654); -@end @property( !GGX_height_correlated ) - float gL = NdotL * (1-sqR) + sqR; - float gV = NdotV * (1-sqR) + sqR; - float G = 1.0 / (( gL * gV + 1e-4f ) * 4 * 3.141592654); -@end - - //Formula: - // fresnelS = lerp( (1 - V*H)^5, 1, F0 ) - @insertpiece( FresnelType ) fresnelS = @insertpiece( getSpecularFresnel ); - - //We should divide Rs by PI, but it was done inside G for performance - float3 Rs = ( fresnelS * (R * G) ) * @insertpiece( kS ).xyz * lightSpecular; - - //Diffuse BRDF (*Normalized* Disney, see course_notes_moving_frostbite_to_pbr.pdf - //"Moving Frostbite to Physically Based Rendering" Sebastien Lagarde & Charles de Rousiers) - float energyBias = ROUGHNESS * 0.5; - float energyFactor = mix( 1.0, 1.0 / 1.51, ROUGHNESS ); - float fd90 = energyBias + 2.0 * VdotH * VdotH * ROUGHNESS; - float lightScatter = 1.0 + (fd90 - 1.0) * pow( 1.0 - NdotL, 5.0 ); - float viewScatter = 1.0 + (fd90 - 1.0) * pow( 1.0 - NdotV, 5.0 ); - -@property( fresnel_separate_diffuse ) - @insertpiece( FresnelType ) fresnelD = @insertpiece( getDiffuseFresnel ); -@end @property( !fresnel_separate_diffuse ) - float fresnelD = 1.0f - @insertpiece( getMaxFresnelS );@end - - //We should divide Rd by PI, but it is already included in kD - float3 Rd = (lightScatter * viewScatter * energyFactor * fresnelD) * @insertpiece( kD ).xyz * lightDiffuse; - - return NdotL * (Rs + Rd); -} -@end -@end - -@property( hlms_enable_vpls ) -@piece( DeclareBRDF_InstantRadiosity ) -//Simplified cheap BRDF for Instant Radiosity. -float3 BRDF_IR( float3 lightDir, float3 lightDiffuse, - Material material, float3 nNormal @insertpiece( brdfExtraParamDefs ) ) -{ - float NdotL = clamp( dot( nNormal, lightDir ), 0.0, 1.0 ); - @insertpiece( FresnelType ) fresnelD = @insertpiece( getDiffuseFresnel ); - - //We should divide Rd by PI, but it is already included in kD - return NdotL * fresnelD * @insertpiece( kD ).xyz * lightDiffuse; -} -@end -@end - -/// Applying Fresnel term to prefiltered cubemap has a bad effect of always showing high specular -/// color at edge, even for rough surface. See https://seblagarde.wordpress.com/2011/08/17/hello-world/ -/// and see http://www.ogre3d.org/forums/viewtopic.php?f=25&p=523550#p523544 -/// "The same Fresnel term which is appropriate for unfiltered environment maps (i.e. perfectly smooth -/// mirror surfaces) is not appropriate for filtered environment maps since there you are averaging -/// incoming light colors from many directions, but using a single Fresnel value computed for the -/// reflection direction. The correct function has similar values as the regular Fresnel expression -/// at v=n, but at glancing angle it behaves differently. In particular, the lerp(from base specular -/// to white) does not go all the way to white at glancing angles in the case of rough surfaces." -/// So we use getSpecularFresnelWithRoughness instead. -@piece( BRDF_EnvMap ) - float NdotL = saturate( dot( nNormal, reflDir ) ); - float VdotH = saturate( dot( viewDir, normalize( reflDir + viewDir ) ) ); - @insertpiece( FresnelType ) fresnelS = @insertpiece( getSpecularFresnelWithRoughness ); - - @property( fresnel_separate_diffuse ) - @insertpiece( FresnelType ) fresnelD = @insertpiece( getDiffuseFresnelWithRoughness ); - @end @property( !fresnel_separate_diffuse ) - float fresnelD = 1.0f - @insertpiece( getMaxFresnelS );@end - - finalColour += envColourD * @insertpiece( kD ).xyz * fresnelD + - envColourS * @insertpiece( kS ).xyz * fresnelS; -@end - -@property( hlms_fine_light_mask ) - @piece( ObjLightMaskCmp )if( (inPs.objLightMask & as_type( passBuf.lights[@counter(fineMaskLightIdx)].position.w )) != 0u )@end - @piece( andObjLightMaskCmp )&& ((inPs.objLightMask & as_type( passBuf.lights[@counter(fineMaskLightIdx)].position.w )) != 0u)@end - @piece( andObjAreaApproxLightMaskCmp )&& ((inPs.objLightMask & as_type( passBuf.areaApproxLights[@counter(fineMaskAreaApproxLightIdx)].position.w )) != 0u)@end -@end diff --git a/ogre2/src/media/Hlms/Pbs/Metal/BlendModes_piece_ps.metal b/ogre2/src/media/Hlms/Pbs/Metal/BlendModes_piece_ps.metal deleted file mode 100644 index a933fc45f..000000000 --- a/ogre2/src/media/Hlms/Pbs/Metal/BlendModes_piece_ps.metal +++ /dev/null @@ -1,105 +0,0 @@ -//Reset t to 0 just in case (values are preserved from previous stages) -@pset( t, 0 ) - -@property( !hlms_shadowcaster ) -@piece( NormalNonPremul ) - //Normal Non Premultiplied @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, detailCol@value(t).xyz, detailCol@value(t).a ); - diffuseCol.w = mix( diffuseCol.w, 1.0, detailCol@value(t).w ); -@end - -@piece( NormalPremul ) - //Normal Premultiplied @value(t) - diffuseCol.xyz = (1.0 - detailCol@value(t).a) * diffuseCol.xyz + detailCol@value(t).xyz; - diffuseCol.w = mix( diffuseCol.w, 1.0, detailCol@value(t).w ); -@end - -@piece( Add ) - //Add @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - min( diffuseCol.xyz + detailCol@value(t).xyz, float3(1.0, 1.0, 1.0) ), - detailCol@value(t).a ); -@end - -@piece( Subtract ) - //Subtract @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - max( diffuseCol.xyz - detailCol@value(t).xyz, float3(0.0, 0.0, 0.0) ), - detailCol@value(t).a ); -@end - -@piece( Multiply ) - //Multiply @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - diffuseCol.xyz * detailCol@value(t).xyz, - detailCol@value(t).a ); -@end - -@piece( Multiply2x ) - //Multiply2x @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - min( diffuseCol.xyz * detailCol@value(t).xyz * 2.0, float3(1.0, 1.0, 1.0) ), - detailCol@value(t).a ); -@end - -@piece( Screen ) - //Screen @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - 1.0 - (1.0 - diffuseCol.xyz) * (1.0 - detailCol@value(t).xyz), - detailCol@value(t).a ); -@end - -@piece( Overlay ) - //Overlay @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - diffuseCol.xyz * ( diffuseCol.xyz + 2.0 * detailCol@value(t).xyz * (1.0 - diffuseCol.xyz) ), - detailCol@value(t).a ); -@end - -@piece( Lighten ) - //Lighten @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - max( diffuseCol.xyz, detailCol@value(t).xyz ), - detailCol@value(t).a ); -@end - -@piece( Darken ) - //Darken @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - min( diffuseCol.xyz, detailCol@value(t).xyz ), - detailCol@value(t).a ); -@end - -@piece( GrainExtract ) - //GrainExtract @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - (diffuseCol.xyz - detailCol@value(t).xyz) + 0.5f, - detailCol@value(t).a ); -@end - -@piece( GrainMerge ) - //GrainMerge @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - (diffuseCol.xyz + detailCol@value(t).xyz) - 0.5f, - detailCol@value(t).a ); -@end - -@piece( Difference ) - //Difference @value(t) - diffuseCol.xyz = mix( diffuseCol.xyz, - abs(diffuseCol.xyz - detailCol@value(t).xyz), - detailCol@value(t).a ); -@end -@end @property( hlms_shadowcaster ) - -@piece( NormalNonPremul ) - //Normal Non Premultiplied @value(t) - diffuseCol = mix( diffuseCol, 1.0, detailCol@value(t) ); -@end - -@piece( NormalPremul ) - //Normal Premultiplied @value(t) - diffuseCol = mix( diffuseCol, 1.0, detailCol@value(t) ); -@end - -@end diff --git a/ogre2/src/media/Hlms/Pbs/Metal/DetailMaps_piece_ps.metal b/ogre2/src/media/Hlms/Pbs/Metal/DetailMaps_piece_ps.metal deleted file mode 100644 index 4f6a1ab30..000000000 --- a/ogre2/src/media/Hlms/Pbs/Metal/DetailMaps_piece_ps.metal +++ /dev/null @@ -1,26 +0,0 @@ -// detail_maps_diffuse & detail_maps_normal are either 0 or 4 - -@pmax( NumDetailMaps, detail_maps_diffuse, detail_maps_normal ) -@foreach( NumDetailMaps, n ) - @property( detail_offsets@n ) - @piece( offsetDetail@n ) * material.detailOffsetScale[@n].zw + material.detailOffsetScale[@n].xy@end - @end -@end - -@piece( detail_swizzle0 )x@end; -@piece( detail_swizzle1 )y@end; -@piece( detail_swizzle2 )z@end; -@piece( detail_swizzle3 )w@end; - -/* -Down below we perform: - if( detail_maps_normal ) - second_valid_detail_map_nm = first_valid_detail_map_nm + 1; - else - second_valid_detail_map_nm = 0; -*/ -@property( detail_maps_normal ) - @add( second_valid_detail_map_nm, first_valid_detail_map_nm, 1 ) -@end @property( !detail_maps_normal ) - @set( second_valid_detail_map_nm, 0 ) -@end diff --git a/ogre2/src/media/Hlms/Pbs/Metal/IrradianceVolume_piece_ps.metal b/ogre2/src/media/Hlms/Pbs/Metal/IrradianceVolume_piece_ps.metal deleted file mode 100644 index 912f429c9..000000000 --- a/ogre2/src/media/Hlms/Pbs/Metal/IrradianceVolume_piece_ps.metal +++ /dev/null @@ -1,75 +0,0 @@ -@property( irradiance_volumes ) -@piece( applyIrradianceVolumes ) - float3 worldNormal = nNormal.xyz * toMat3x3( passBuf.invView ); - float3 worldPos = ( float4( inPs.pos.xyz, 1.0 ) * passBuf.invView ).xyz; - - float3 irradiancePos = worldPos.xyz * passBuf.irradianceSize.xyz - passBuf.irradianceOrigin.xyz; - //Floor irradiancePos.y and put the fractional part so we can mix. - irradiancePos.y -= 0.5f; //Texel centers are at center. Move it to origin. - float origYPos; - float fIrradianceYWeight = modf( irradiancePos.y, origYPos ); - origYPos *= 6.0; - origYPos += 0.5f; //Make sure we sample at center (so HW doesn't do linear - //filtering on the Y axis. We'll do that manually) - - float3 isNegative = (float3)( worldNormal.xyz < float3( 0, 0, 0 ) ); - - float3 tmpAmbientSample; - - //We need to make 3 samples (actually 6), one for each axis. - /* The code is basically doing: - float3 cAmbientCube[6]; - int3 isNegative = ( worldNormal < 0.0 ); - float3 linearColor; - linearColor = worldNormalSq.x * cAmbientCube[isNegative.x] + - worldNormalSq.y * cAmbientCube[isNegative.y+2] + - worldNormalSq.z * cAmbientCube[isNegative.z+4]; - - We have 6 colour values per voxel. But GPUs can only store 1 colour value per cell. - So we 6x the height to workaround that limitation. This also means we loose the ability - to do HW bilinear filtering around the Y axis; therefore we do it ourselves manually. - Because of this, instead of doing 3 samples, we end up doing 6 (in order to perform - filtering around the Y axis) - **/ - - float irradianceTexInvHeight = passBuf.irradianceSize.w; - - irradiancePos.y = (origYPos + isNegative.x) * irradianceTexInvHeight; - float3 xAmbientSample = irradianceVolume.sample( irradianceVolumeSampler, irradiancePos ).xyz; - irradiancePos.y += 6.0f * irradianceTexInvHeight; - tmpAmbientSample = irradianceVolume.sample( irradianceVolumeSampler, irradiancePos ).xyz; - - xAmbientSample = mix( xAmbientSample, tmpAmbientSample, fIrradianceYWeight ); - - irradiancePos.y = (origYPos + (2.0f + isNegative.y)) * irradianceTexInvHeight; - float3 yAmbientSample = irradianceVolume.sample( irradianceVolumeSampler, irradiancePos ).xyz; - irradiancePos.y += 6.0f * irradianceTexInvHeight; - tmpAmbientSample = irradianceVolume.sample( irradianceVolumeSampler, irradiancePos ).xyz; - - yAmbientSample = mix( yAmbientSample, tmpAmbientSample, fIrradianceYWeight ); - - irradiancePos.y = (origYPos + (4.0f + isNegative.z)) * irradianceTexInvHeight; - float3 zAmbientSample = irradianceVolume.sample( irradianceVolumeSampler, irradiancePos ).xyz; - irradiancePos.y += 6.0f * irradianceTexInvHeight; - tmpAmbientSample = irradianceVolume.sample( irradianceVolumeSampler, irradiancePos ).xyz; - - zAmbientSample = mix( zAmbientSample, tmpAmbientSample, fIrradianceYWeight ); - - - float3 worldNormalSq = worldNormal.xyz * worldNormal.xyz; - float3 ambientTerm = worldNormalSq.x * xAmbientSample.xyz + - worldNormalSq.y * yAmbientSample.xyz + - worldNormalSq.z * zAmbientSample.xyz; - ambientTerm *= passBuf.irradianceOrigin.w; //irradianceOrigin.w = irradianceMaxPower - - if( irradiancePos.x < 0 || irradiancePos.x > 1 || - irradiancePos.z < 0 || irradiancePos.z > 1 || - irradiancePos.y <= (6.0f * irradianceTexInvHeight) || irradiancePos.y >= 1 ) - { - //Metal does not support border colour addressing mode. - ambientTerm = float3( 0 ); - } - - finalColour.xyz += ambientTerm.xyz * @insertpiece( kD ).xyz; -@end -@end diff --git a/ogre2/src/media/Hlms/Pbs/Metal/Structs_piece_vs_piece_ps.metal b/ogre2/src/media/Hlms/Pbs/Metal/Structs_piece_vs_piece_ps.metal deleted file mode 100644 index 7131a6619..000000000 --- a/ogre2/src/media/Hlms/Pbs/Metal/Structs_piece_vs_piece_ps.metal +++ /dev/null @@ -1,252 +0,0 @@ -@piece( PassStructDecl ) -struct ShadowReceiverData -{ - float4x4 texViewProj; -@property( exponential_shadow_maps ) - float4 texViewZRow; -@end - float2 shadowDepthRange; - float2 padding; - float4 invShadowMapSize; -}; - -struct Light -{ - float4 position; //.w contains the objLightMask - float3 diffuse; - float3 specular; -@property( hlms_num_shadow_map_lights ) - float3 attenuation; - float3 spotDirection; - float3 spotParams; -@end -}; - -#define areaLightDiffuseMipmapStart areaApproxLights[0].diffuse.w -#define areaLightNumMipmapsSpecFactor areaApproxLights[0].specular.w - -struct AreaLight -{ - float4 position; //.w contains the objLightMask - float4 diffuse; //[0].w contains diffuse mipmap start - float4 specular; //[0].w contains mipmap scale - float4 attenuation; //.w contains texture array idx - //Custom 2D Shape: - // direction.xyz direction - // direction.w invHalfRectSize.x - // tangent.xyz tangent - // tangent.w invHalfRectSize.y - float4 direction; - float4 tangent; - float4 doubleSided; -}; - -@insertpiece( DeclCubemapProbeStruct ) - -//Uniforms that change per pass -struct PassData -{ - //Vertex shader (common to both receiver and casters) - float4x4 viewProj; - -@property( hlms_global_clip_planes ) - float4 clipPlane0; -@end - -@property( hlms_shadowcaster_point ) - float4 cameraPosWS; //Camera position in world space -@end - -@property( !hlms_shadowcaster ) - //Vertex shader - float4x4 view; - @property( hlms_num_shadow_map_lights )ShadowReceiverData shadowRcv[@value(hlms_num_shadow_map_lights)];@end - - //------------------------------------------------------------------------- - - //Pixel shader - float3x3 invViewMatCubemap; - -@property( hlms_use_prepass ) - float4 windowHeight; -@end - -@property( ambient_hemisphere || ambient_fixed || envmap_scale ) - float4 ambientUpperHemi; -@end -@property( ambient_hemisphere ) - float4 ambientLowerHemi; - float4 ambientHemisphereDir; -@end -@property( irradiance_volumes ) - float4 irradianceOrigin; //.w = maxPower - float4 irradianceSize; //.w = 1.0f / irradianceTexture->getHeight() - float4x4 invView; -@end -@property( hlms_pssm_splits )@psub( hlms_pssm_splits_minus_one, hlms_pssm_splits, 1 )@foreach( hlms_pssm_splits, n ) - float pssmSplitPoints@n;@end @end -@property( hlms_pssm_blend )@foreach( hlms_pssm_splits_minus_one, n ) - float pssmBlendPoints@n;@end @end -@property( hlms_pssm_fade ) - float pssmFadePoint;@end - @property( hlms_lights_spot )Light lights[@value(hlms_lights_spot)];@end - @property( hlms_lights_area_approx )AreaLight areaApproxLights[@value(hlms_lights_area_approx)];@end -@end @property( hlms_shadowcaster ) - //Vertex shader - @property( exponential_shadow_maps )float4 viewZRow;@end - float2 depthRange; -@end - -@property( hlms_forwardplus ) - //Forward3D - //f3dData.x = minDistance; - //f3dData.y = invMaxDistance; - //f3dData.z = f3dNumSlicesSub1; - //f3dData.w = uint cellsPerTableOnGrid0 (floatBitsToUint); - - //Clustered Forward: - //f3dData.x = minDistance; - //f3dData.y = invExponentK; - //f3dData.z = f3dNumSlicesSub1; - //f3dData.w = renderWindow->getHeight(); - float4 f3dData; - @property( hlms_forwardplus == forward3d ) - float4 f3dGridHWW[@value( forward3d_num_slices )]; - float4 f3dViewportOffset; - @end - @property( hlms_forwardplus != forward3d ) - float4 fwdScreenToGrid; - @end -@end - - @insertpiece( DeclPlanarReflUniforms ) - -@property( parallax_correct_cubemaps ) - CubemapProbe autoProbe; -@end - - @insertpiece( custom_passBuffer ) -};@end - -@piece( PassDecl ) -, constant PassData &passBuf [[buffer(CONST_SLOT_START+0)]] -@end - -@property( fresnel_scalar )@piece( FresnelType )float3@end @piece( FresnelSwizzle )xyz@end @end -@property( !fresnel_scalar )@piece( FresnelType )float@end @piece( FresnelSwizzle )x@end @end - -@piece( MaterialStructDecl ) -//Uniforms that change per Item/Entity, but change very infrequently -struct Material -{ - /* kD is already divided by PI to make it energy conserving. - (formula is finalDiffuse = NdotL * surfaceDiffuse / PI) - */ - float4 bgDiffuse; - float4 kD; //kD.w is alpha_test_threshold - float4 kS; //kS.w is roughness - //Fresnel coefficient, may be per colour component (float3) or scalar (float) - //F0.w is transparency - float4 F0; - float4 normalWeights; - float4 cDetailWeights; - float4 detailOffsetScale[4]; - float4 emissive; //emissive.w contains mNormalMapWeight. - float4 userValue[3]; - - //uint4 indices0_3; - ushort diffuseIdx; - ushort normalIdx; - ushort specularIdx; - ushort roughnessIdx; - ushort weightMapIdx; - ushort detailMapIdx0; - ushort detailMapIdx1; - ushort detailMapIdx2; - - //uint4 indices4_7; - ushort detailMapIdx3; - ushort detailNormMapIdx0; - ushort detailNormMapIdx1; - ushort detailNormMapIdx2; - ushort detailNormMapIdx3; - ushort emissiveMapIdx; - ushort envMapIdx; - - @insertpiece( custom_materialBuffer ) -};@end - -@piece( MaterialDecl ) -, constant Material *materialArray [[buffer(CONST_SLOT_START+1)]] -@end - - -@piece( InstanceDecl ) -//Uniforms that change per Item/Entity -//.x = -//The lower 9 bits contain the material's start index. -//The higher 23 bits contain the world matrix start index. -// -//.y = -//shadowConstantBias. Send the bias directly to avoid an -//unnecessary indirection during the shadow mapping pass. -//Must be loaded with uintBitsToFloat -, constant uint4 *worldMaterialIdx [[buffer(CONST_SLOT_START+2)]] -@end - -@property( envprobe_map && envprobe_map != target_envprobe_map && use_parallax_correct_cubemaps ) -@piece( PccManualProbeDecl ) -, constant CubemapProbe &manualProbe [[buffer(CONST_SLOT_START+3)]] -@end -@end - -//Reset texcoord to 0 for every shader stage (since values are preserved). -@pset( texcoord, 0 ) - -@piece( VStoPS_block ) - @property( !hlms_shadowcaster ) - @property( !lower_gpu_overhead ) - ushort materialId [[flat]]; - @end - @property( hlms_fine_light_mask || hlms_forwardplus_fine_light_mask ) - uint objLightMask [[flat]]; - @end - @property( use_planar_reflections ) - ushort planarReflectionIdx [[flat]]; - @end - @property( hlms_normal || hlms_qtangent ) - float3 pos; - float3 normal; - @property( normal_map )float3 tangent; - @property( hlms_qtangent )float biNormalReflection [[flat]];@end - @end - @end - @foreach( hlms_uv_count, n ) - float@value( hlms_uv_count@n ) uv@n;@end - - @foreach( hlms_num_shadow_map_lights, n ) - @property( !hlms_shadowmap@n_is_point_light ) - float4 posL@n;@end @end - - @property( hlms_pssm_splits )float depth;@end - @end - - @property( hlms_shadowcaster ) - @property( alpha_test ) - ushort drawId [[flat]]; - @foreach( hlms_uv_count, n ) - float@value( hlms_uv_count@n ) uv@n;@end - @end - @property( (!hlms_shadow_uses_depth_texture || exponential_shadow_maps) && !hlms_shadowcaster_point ) - float depth; - @end - @property( hlms_shadowcaster_point ) - float3 toCameraWS; - @property( !exponential_shadow_maps ) - float constBias [[flat]]; - @end - @end - @end - - @insertpiece( custom_VStoPS ) -@end