From 707e1066435b3c3cc068228b39c7404f991f24f3 Mon Sep 17 00:00:00 2001 From: Florent Malartre Date: Wed, 1 Jul 2020 11:50:14 +0200 Subject: [PATCH] Multiple Directional PSSM shadows --- OgreMain/include/OgreHlms.h | 3 +- OgreMain/src/OgreHlms.cpp | 15 +++++- .../Hlms/Pbs/Any/ShadowMapping_piece_ps.any | 47 ++++++++++--------- .../Media/Hlms/Pbs/GLSL/PixelShader_ps.glsl | 8 +--- .../Media/Hlms/Pbs/GLSLES/PixelShader_ps.glsl | 8 +--- .../Media/Hlms/Pbs/HLSL/PixelShader_ps.hlsl | 8 +--- .../Media/Hlms/Pbs/Metal/PixelShader_ps.metal | 10 ++-- .../PbsTerraShadows_piece_vs_piece_ps.glsl | 1 - .../Media/Hlms/Terra/GLSL/PixelShader_ps.glsl | 9 ++-- .../PbsTerraShadows_piece_vs_piece_ps.glsl | 1 - .../Hlms/Terra/GLSLES/PixelShader_ps.glsl | 9 ++-- .../PbsTerraShadows_piece_vs_piece_ps.hlsl | 1 - .../Media/Hlms/Terra/HLSL/PixelShader_ps.hlsl | 9 ++-- 13 files changed, 58 insertions(+), 71 deletions(-) diff --git a/OgreMain/include/OgreHlms.h b/OgreMain/include/OgreHlms.h index e548f7671..65d5a9b81 100644 --- a/OgreMain/include/OgreHlms.h +++ b/OgreMain/include/OgreHlms.h @@ -795,7 +795,7 @@ namespace Ogre static const IdString UvCount5; static const IdString UvCount6; static const IdString UvCount7; - + //Change per frame (grouped together with scene pass) static const IdString LightsDirectional; static const IdString LightsDirNonCaster; @@ -814,6 +814,7 @@ namespace Ogre static const IdString DualParaboloidMapping; static const IdString NumShadowMapLights; static const IdString NumShadowMapTextures; + static const IdString NumPssmLights; static const IdString PssmSplits; static const IdString PssmBlend; static const IdString PssmFade; diff --git a/OgreMain/src/OgreHlms.cpp b/OgreMain/src/OgreHlms.cpp index 6748f66fc..d517675b1 100644 --- a/OgreMain/src/OgreHlms.cpp +++ b/OgreMain/src/OgreHlms.cpp @@ -127,6 +127,7 @@ namespace Ogre const IdString HlmsBaseProp::DualParaboloidMapping= IdString( "hlms_dual_paraboloid_mapping" ); const IdString HlmsBaseProp::NumShadowMapLights = IdString( "hlms_num_shadow_map_lights" ); const IdString HlmsBaseProp::NumShadowMapTextures= IdString("hlms_num_shadow_map_textures" ); + const IdString HlmsBaseProp::NumPssmLights = IdString( "hlms_num_pssm_lights" ); const IdString HlmsBaseProp::PssmSplits = IdString( "hlms_pssm_splits" ); const IdString HlmsBaseProp::PssmBlend = IdString( "hlms_pssm_blend" ); const IdString HlmsBaseProp::PssmFade = IdString( "hlms_pssm_fade" ); @@ -2560,10 +2561,21 @@ namespace Ogre const TextureVec &contiguousShadowMapTex = shadowNode->getContiguousShadowMapTex(); size_t numShadowMapLights = shadowNode->getNumActiveShadowCastingLights(); - if( numPssmSplits ) + + bool tryNextShadowMap = numPssmSplits != 0; + unsigned int next = 1; + unsigned int numPssmLights = 0; + while( tryNextShadowMap ) + { + ++numPssmLights; numShadowMapLights += numPssmSplits - 1; + // If next light exist and also use pssm : add split number to 'numShadowMapLights' + tryNextShadowMap = shadowNode->getPssmSplits( next++ * numPssmSplits ); + } + setProperty( HlmsBaseProp::NumShadowMapLights, numShadowMapLights ); setProperty( HlmsBaseProp::NumShadowMapTextures, contiguousShadowMapTex.size() ); + setProperty( HlmsBaseProp::NumPssmLights, numPssmLights ); { const Ogre::CompositorShadowNodeDef *shadowNodeDef = shadowNode->getDefinition(); @@ -2878,6 +2890,7 @@ namespace Ogre setProperty( HlmsBaseProp::Forward3D, 0 ); setProperty( HlmsBaseProp::NumShadowMapLights,0 ); setProperty( HlmsBaseProp::NumShadowMapTextures, 0 ); + setProperty( HlmsBaseProp::NumPssmLights, 0 ); setProperty( HlmsBaseProp::PssmSplits, 0 ); setProperty( HlmsBaseProp::LightsAttenuation, 0 ); setProperty( HlmsBaseProp::LightsSpotParams, 0 ); diff --git a/Samples/Media/Hlms/Pbs/Any/ShadowMapping_piece_ps.any b/Samples/Media/Hlms/Pbs/Any/ShadowMapping_piece_ps.any index 06ccd5cdc..2293adcb2 100644 --- a/Samples/Media/Hlms/Pbs/Any/ShadowMapping_piece_ps.any +++ b/Samples/Media/Hlms/Pbs/Any/ShadowMapping_piece_ps.any @@ -254,29 +254,34 @@ @end @piece( DoDirectionalShadowMaps ) -@property( hlms_pssm_splits ) @property( debug_pssm_splits ) float3 debugPssmSplit = float3( 0, 0, 0 ); @end - float fShadow = 1.0; + @foreach( hlms_lights_directional, dirIndex ) + float fShadow@dirIndex = 1.0; + @end @property( hlms_pssm_blend ) float fShadowBlend = 1.0; @end @property( receive_shadows ) - if( inPs.depth <= passBuf.pssmSplitPoints@value(CurrentShadowMap) ) + @foreach( hlms_num_pssm_lights, dirIndex ) + + @set( CurrentShadowMapBlend, 0 ) + @set( CurrentSplit, 0 ) + if( inPs.depth <= passBuf.pssmSplitPoints@counter(CurrentSplit) ) { - fShadow = getShadow( hlms_shadowmap@value(CurrentShadowMap), @insertpiece( UseSamplerShadow ) - inPs.posL0, + fShadow@dirIndex = getShadow( hlms_shadowmap@value(CurrentShadowMap), @insertpiece( UseSamplerShadow ) + inPs.posL@value(CurrentShadowMap), passBuf.shadowRcv[@value(CurrentShadowMap)].invShadowMapSize hlms_shadowmap@counter(CurrentShadowMap)_uv_param ); @property( hlms_pssm_blend ) if( inPs.depth > passBuf.pssmBlendPoints@value(CurrentShadowMapBlend) ) { fShadowBlend = getShadow( hlms_shadowmap@value(CurrentShadowMap), @insertpiece( UseSamplerShadow ) - inPs.posL1, + inPs.posL@value(CurrentShadowMap), passBuf.shadowRcv[@value(CurrentShadowMap)].invShadowMapSize hlms_shadowmap@value(CurrentShadowMap)_uv_param ); - fShadow = lerp( fShadow, fShadowBlend, + fShadow@dirIndex = lerp( fShadow@dirIndex, fShadowBlend, (inPs.depth - passBuf.pssmBlendPoints@value(CurrentShadowMapBlend)) / (passBuf.pssmSplitPoints@value(CurrentShadowMapBlend) - passBuf.pssmBlendPoints@counter(CurrentShadowMapBlend)) ); } @@ -286,10 +291,10 @@ @end } @foreach( hlms_pssm_splits, n, 1 ) - else if( inPs.depth <= passBuf.pssmSplitPoints@value(CurrentShadowMap) ) + else if( inPs.depth <= passBuf.pssmSplitPoints@counter(CurrentSplit) ) { - fShadow = getShadow( hlms_shadowmap@value(CurrentShadowMap), @insertpiece( UseSamplerShadow ) - inPs.posL@n, + fShadow@dirIndex = getShadow( hlms_shadowmap@value(CurrentShadowMap), @insertpiece( UseSamplerShadow ) + inPs.posL@value(CurrentShadowMap), passBuf.shadowRcv[@value(CurrentShadowMap)].invShadowMapSize hlms_shadowmap@counter(CurrentShadowMap)_uv_param ); @property( hlms_pssm_blend && @n < hlms_pssm_splits_minus_one ) @@ -299,14 +304,14 @@ inPs.posL@value(CurrentShadowMap), passBuf.shadowRcv[@value(CurrentShadowMap)].invShadowMapSize hlms_shadowmap@value(CurrentShadowMap)_uv_param ); - fShadow = lerp( fShadow, fShadowBlend, + fShadow@dirIndex = lerp( fShadow@dirIndex, fShadowBlend, (inPs.depth - passBuf.pssmBlendPoints@value(CurrentShadowMapBlend)) / (passBuf.pssmSplitPoints@value(CurrentShadowMapBlend) - passBuf.pssmBlendPoints@counter(CurrentShadowMapBlend)) ); } @end @property( hlms_pssm_fade && @n == hlms_pssm_splits_minus_one ) if( inPs.depth > passBuf.pssmFadePoint ) { - fShadow = lerp( fShadow, 1.0, + fShadow@dirIndex = lerp( fShadow@dirIndex, 1.0, (inPs.depth - passBuf.pssmFadePoint) / (passBuf.pssmSplitPoints@value(hlms_pssm_splits_minus_one) - passBuf.pssmFadePoint) ); } @@ -321,21 +326,17 @@ @end @end }@end + @end + @foreach( hlms_lights_directional, dirIndex, hlms_num_pssm_lights ) + fShadow@dirIndex = getShadow( hlms_shadowmap@value(CurrentShadowMap), @insertpiece( UseSamplerShadow ) + inPs.posL@value(CurrentShadowMap), + passBuf.shadowRcv[@value(CurrentShadowMap)].invShadowMapSize + hlms_shadowmap@counter(CurrentShadowMap)_uv_param ); + @end @end -@end @property( !hlms_pssm_splits && hlms_num_shadow_map_lights && hlms_lights_directional ) - @property( receive_shadows ) - float fShadow = getShadow( hlms_shadowmap@value(CurrentShadowMap), @insertpiece( UseSamplerShadow ) - inPs.posL0, - passBuf.shadowRcv[@value(CurrentShadowMap)].invShadowMapSize - hlms_shadowmap@counter(CurrentShadowMap)_uv_param ); - @end @property( !receive_shadows ) - float fShadow = 1.0; - @end -@end @end @property( receive_shadows ) - @piece( DarkenWithShadowFirstLight )* fShadow@end @piece( DarkenWithShadow ) * getShadow( hlms_shadowmap@value(CurrentShadowMap), @insertpiece( UseSamplerShadow ) inPs.posL@value(CurrentShadowMap), diff --git a/Samples/Media/Hlms/Pbs/GLSL/PixelShader_ps.glsl b/Samples/Media/Hlms/Pbs/GLSL/PixelShader_ps.glsl index 03ea33e7c..3ea6c1b82 100644 --- a/Samples/Media/Hlms/Pbs/GLSL/PixelShader_ps.glsl +++ b/Samples/Media/Hlms/Pbs/GLSL/PixelShader_ps.glsl @@ -373,13 +373,9 @@ void main() @insertpiece( custom_ps_preLights ) @property( !custom_disable_directional_lights ) -@property( hlms_lights_directional ) +@foreach( hlms_lights_directional, n, 0 ) @insertpiece( ObjLightMaskCmp ) - finalColour += BRDF( passBuf.lights[0].position.xyz, viewDir, NdotV, passBuf.lights[0].diffuse, passBuf.lights[0].specular ) @insertpiece(DarkenWithShadowFirstLight); -@end -@foreach( hlms_lights_directional, n, 1 ) - @insertpiece( ObjLightMaskCmp ) - finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular )@insertpiece( DarkenWithShadow );@end + finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular ) * fShadow@n;@end @foreach( hlms_lights_directional_non_caster, n, hlms_lights_directional ) @insertpiece( ObjLightMaskCmp ) finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular );@end diff --git a/Samples/Media/Hlms/Pbs/GLSLES/PixelShader_ps.glsl b/Samples/Media/Hlms/Pbs/GLSLES/PixelShader_ps.glsl index 33e412daa..a29b115d1 100644 --- a/Samples/Media/Hlms/Pbs/GLSLES/PixelShader_ps.glsl +++ b/Samples/Media/Hlms/Pbs/GLSLES/PixelShader_ps.glsl @@ -373,13 +373,9 @@ void main() @insertpiece( custom_ps_preLights ) @property( !custom_disable_directional_lights ) -@property( hlms_lights_directional ) +@foreach( hlms_lights_directional, n, 0 ) @insertpiece( ObjLightMaskCmp ) - finalColour += BRDF( passBuf.lights[0].position.xyz, viewDir, NdotV, passBuf.lights[0].diffuse, passBuf.lights[0].specular ) @insertpiece(DarkenWithShadowFirstLight); -@end -@foreach( hlms_lights_directional, n, 1 ) - @insertpiece( ObjLightMaskCmp ) - finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular )@insertpiece( DarkenWithShadow );@end + finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular ) * fShadow@n;@end @foreach( hlms_lights_directional_non_caster, n, hlms_lights_directional ) @insertpiece( ObjLightMaskCmp ) finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular );@end diff --git a/Samples/Media/Hlms/Pbs/HLSL/PixelShader_ps.hlsl b/Samples/Media/Hlms/Pbs/HLSL/PixelShader_ps.hlsl index b41e55a4c..cc2959ce4 100644 --- a/Samples/Media/Hlms/Pbs/HLSL/PixelShader_ps.hlsl +++ b/Samples/Media/Hlms/Pbs/HLSL/PixelShader_ps.hlsl @@ -354,13 +354,9 @@ float4 diffuseCol; @insertpiece( custom_ps_preLights ) @property( !custom_disable_directional_lights ) -@property( hlms_lights_directional ) +@foreach( hlms_lights_directional, n, 0 ) @insertpiece( ObjLightMaskCmp ) - finalColour += BRDF( passBuf.lights[0].position.xyz, viewDir, NdotV, passBuf.lights[0].diffuse, passBuf.lights[0].specular, material, nNormal @insertpiece( brdfExtraParams ) ) @insertpiece( DarkenWithShadowFirstLight ); -@end -@foreach( hlms_lights_directional, n, 1 ) - @insertpiece( ObjLightMaskCmp ) - finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular, material, nNormal @insertpiece( brdfExtraParams ) )@insertpiece( DarkenWithShadow );@end + finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular, material, nNormal @insertpiece( brdfExtraParams ) ) * fShadow@n;@end @foreach( hlms_lights_directional_non_caster, n, hlms_lights_directional ) @insertpiece( ObjLightMaskCmp ) finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular, material, nNormal @insertpiece( brdfExtraParams ) );@end diff --git a/Samples/Media/Hlms/Pbs/Metal/PixelShader_ps.metal b/Samples/Media/Hlms/Pbs/Metal/PixelShader_ps.metal index 5d8003c1a..a3e4e1347 100644 --- a/Samples/Media/Hlms/Pbs/Metal/PixelShader_ps.metal +++ b/Samples/Media/Hlms/Pbs/Metal/PixelShader_ps.metal @@ -294,7 +294,7 @@ float4 diffuseCol; @insertpiece( custom_ps_posSampleNormal ) @insertpiece( forwardPlusApplyDecalsNormal ) - + @property( normal_map ) nNormal = normalize( TBN * nNormal ); @end @@ -337,13 +337,9 @@ float4 diffuseCol; @insertpiece( custom_ps_preLights ) @property( !custom_disable_directional_lights ) -@property( hlms_lights_directional ) - @insertpiece( ObjLightMaskCmp ) - finalColour += BRDF( passBuf.lights[0].position.xyz, viewDir, NdotV, passBuf.lights[0].diffuse, passBuf.lights[0].specular, material, nNormal @insertpiece( brdfExtraParams ) ) @insertpiece( DarkenWithShadowFirstLight ); -@end -@foreach( hlms_lights_directional, n, 1 ) +@foreach( hlms_lights_directional, n, 0 ) @insertpiece( ObjLightMaskCmp ) - finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular, material, nNormal @insertpiece( brdfExtraParams ) )@insertpiece( DarkenWithShadow );@end + finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular, material, nNormal @insertpiece( brdfExtraParams ) ) * fShadow@n;@end @foreach( hlms_lights_directional_non_caster, n, hlms_lights_directional ) @insertpiece( ObjLightMaskCmp ) finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular, material, nNormal @insertpiece( brdfExtraParams ) );@end diff --git a/Samples/Media/Hlms/Terra/GLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl b/Samples/Media/Hlms/Terra/GLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl index f0436a884..a24406dfe 100644 --- a/Samples/Media/Hlms/Terra/GLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl +++ b/Samples/Media/Hlms/Terra/GLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl @@ -32,7 +32,6 @@ @piece( custom_ps_preLights )fShadow *= inPs.terrainShadow;@end @end @property( !hlms_num_shadow_map_lights ) @piece( custom_ps_preLights )float fShadow = inPs.terrainShadow;@end - @piece( DarkenWithShadowFirstLight )* fShadow@end @end @end diff --git a/Samples/Media/Hlms/Terra/GLSL/PixelShader_ps.glsl b/Samples/Media/Hlms/Terra/GLSL/PixelShader_ps.glsl index 4432ac479..1f29304ee 100644 --- a/Samples/Media/Hlms/Terra/GLSL/PixelShader_ps.glsl +++ b/Samples/Media/Hlms/Terra/GLSL/PixelShader_ps.glsl @@ -230,11 +230,8 @@ void main() @insertpiece( custom_ps_preLights ) @property( !custom_disable_directional_lights ) -@property( hlms_lights_directional ) - finalColour += BRDF( passBuf.lights[0].position.xyz, viewDir, NdotV, passBuf.lights[0].diffuse, passBuf.lights[0].specular ) @insertpiece(DarkenWithShadowFirstLight); -@end -@foreach( hlms_lights_directional, n, 1 ) - finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular )@insertpiece( DarkenWithShadow );@end +@foreach( hlms_lights_directional, n, 0 ) + finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular ) * fShadow@n;@end @foreach( hlms_lights_directional_non_caster, n, hlms_lights_directional ) finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular );@end @end @@ -328,7 +325,7 @@ void main() @property( debug_pssm_splits ) outColour.xyz = mix( outColour.xyz, debugPssmSplit.xyz, 0.2f ); @end - + @insertpiece( custom_ps_posExecution ) } @end diff --git a/Samples/Media/Hlms/Terra/GLSLES/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl b/Samples/Media/Hlms/Terra/GLSLES/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl index f0436a884..a24406dfe 100644 --- a/Samples/Media/Hlms/Terra/GLSLES/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl +++ b/Samples/Media/Hlms/Terra/GLSLES/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.glsl @@ -32,7 +32,6 @@ @piece( custom_ps_preLights )fShadow *= inPs.terrainShadow;@end @end @property( !hlms_num_shadow_map_lights ) @piece( custom_ps_preLights )float fShadow = inPs.terrainShadow;@end - @piece( DarkenWithShadowFirstLight )* fShadow@end @end @end diff --git a/Samples/Media/Hlms/Terra/GLSLES/PixelShader_ps.glsl b/Samples/Media/Hlms/Terra/GLSLES/PixelShader_ps.glsl index a30680158..74a8dfa59 100644 --- a/Samples/Media/Hlms/Terra/GLSLES/PixelShader_ps.glsl +++ b/Samples/Media/Hlms/Terra/GLSLES/PixelShader_ps.glsl @@ -230,11 +230,8 @@ void main() @insertpiece( custom_ps_preLights ) @property( !custom_disable_directional_lights ) -@property( hlms_lights_directional ) - finalColour += BRDF( passBuf.lights[0].position.xyz, viewDir, NdotV, passBuf.lights[0].diffuse, passBuf.lights[0].specular ) @insertpiece(DarkenWithShadowFirstLight); -@end -@foreach( hlms_lights_directional, n, 1 ) - finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular )@insertpiece( DarkenWithShadow );@end +@foreach( hlms_lights_directional, n, 0 ) + finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular ) * fShadow@n;@end @foreach( hlms_lights_directional_non_caster, n, hlms_lights_directional ) finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular );@end @end @@ -328,7 +325,7 @@ void main() @property( debug_pssm_splits ) outColour.xyz = mix( outColour.xyz, debugPssmSplit.xyz, 0.2f ); @end - + @insertpiece( custom_ps_posExecution ) } @end diff --git a/Samples/Media/Hlms/Terra/HLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.hlsl b/Samples/Media/Hlms/Terra/HLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.hlsl index 25d48fded..a76c5aad9 100644 --- a/Samples/Media/Hlms/Terra/HLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.hlsl +++ b/Samples/Media/Hlms/Terra/HLSL/PbsTerraShadows/PbsTerraShadows_piece_vs_piece_ps.hlsl @@ -33,7 +33,6 @@ @piece( custom_ps_preLights )fShadow *= inPs.terrainShadow;@end @end @property( !hlms_num_shadow_map_lights ) @piece( custom_ps_preLights )float fShadow = inPs.terrainShadow;@end - @piece( DarkenWithShadowFirstLight )* fShadow@end @end @end diff --git a/Samples/Media/Hlms/Terra/HLSL/PixelShader_ps.hlsl b/Samples/Media/Hlms/Terra/HLSL/PixelShader_ps.hlsl index e9176f76f..273d0662d 100644 --- a/Samples/Media/Hlms/Terra/HLSL/PixelShader_ps.hlsl +++ b/Samples/Media/Hlms/Terra/HLSL/PixelShader_ps.hlsl @@ -230,11 +230,8 @@ float3 qmul( float4 q, float3 v ) @insertpiece( custom_ps_preLights ) @property( !custom_disable_directional_lights ) -@property( hlms_lights_directional ) - finalColour += BRDF( passBuf.lights[0].position.xyz, viewDir, NdotV, passBuf.lights[0].diffuse, passBuf.lights[0].specular, material, nNormal @insertpiece( brdfExtraParams ) ) @insertpiece( DarkenWithShadowFirstLight ); -@end -@foreach( hlms_lights_directional, n, 1 ) - finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular, material, nNormal @insertpiece( brdfExtraParams ) )@insertpiece( DarkenWithShadow );@end +@foreach( hlms_lights_directional, n, 0 ) + finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular, material, nNormal @insertpiece( brdfExtraParams ) ) * fShadow@n;@end @foreach( hlms_lights_directional_non_caster, n, hlms_lights_directional ) finalColour += BRDF( passBuf.lights[@n].position.xyz, viewDir, NdotV, passBuf.lights[@n].diffuse, passBuf.lights[@n].specular, material, nNormal @insertpiece( brdfExtraParams ) );@end @end @@ -285,7 +282,7 @@ float3 qmul( float4 q, float3 v ) @property( envprobe_map || ambient_hemisphere ) float3 reflDir = 2.0 * dot( viewDir, nNormal ) * nNormal - viewDir; - + @property( envprobe_map ) float3 envColourS = texEnvProbeMap.SampleLevel( envMapSamplerState, mul( reflDir, passBuf.invViewMatCubemap ), ROUGHNESS * 12.0 ).xyz @insertpiece( ApplyEnvMapScale ); float3 envColourD = texEnvProbeMap.SampleLevel( envMapSamplerState, mul( nNormal, passBuf.invViewMatCubemap ), 11.0 ).xyz @insertpiece( ApplyEnvMapScale ); -- 2.17.1