[2.1] Shadows issues after Ogre update

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

[2.1] Shadows issues after Ogre update

Post by AshMcConnell »

Hi Folks,

I have recently updated to the latest version of ogre (the last one was quite a few commits ago (255 iirc)).

I did the following
- updated to the latest 2.1 branch on Ogre
- updated MyGUI to the latest 2.1 branch (and fixed an include)
- copied across the latest HLMS shaders
- updated the main compositor to be pretty much like the PbsMaterials.compositor (but with the addition of a MyGUI custom pass)
- Copied across the dependencies for the new shadow compositor_node

After the update the shadows don't show at all on DX11 and on GL3 it gives me a few errors: -

Code: Select all

16:00:37: Vertex Shader: 537133184VertexShader_vs
Fragment Shader: 537133184PixelShader_ps
 GLSL validation result : 
Validation failed! - Different sampler types for same sample texture unit in fragment shader.
16:00:37: OGRE EXCEPTION(5:ItemIdentityException): Parameter called texShadowMap0 does not exist.  in GpuProgramParameters::_findNamedConstantDefinition at C:\Dev\3rdParty\cmake\Ogre\OgreMain\src\OgreGpuProgramParams.cpp (line 2214)
I looked in 537133184PixelShader_ps and it doesn't have any mention of texShadowMap0. Is there an issue with the shader generation or have I missed a step somewhere?

(Here is it for completeness)

Code: Select all

#version 430 core

#define float2 vec2
#define float3 vec3
#define float4 vec4

#define int2 ivec2
#define int3 ivec3
#define int4 ivec4

#define uint2 uvec2
#define uint3 uvec3
#define uint4 uvec4

#define float3x3 mat3
#define float4x4 mat4

#define mul( x, y ) ((x) * (y))
#define INLINE

#define outVs_Position gl_Position




#extension GL_AMD_shader_trinary_minmax: require

layout(std140) uniform;
#define FRAG_COLOR		0

	
		
			layout(location = FRAG_COLOR, index = 0) out vec4 outColour;
		
	








// START UNIFORM DECLARATION

	
		
struct ShadowReceiverData
{
    mat4 texViewProj;
	vec2 shadowDepthRange;
	vec4 invShadowMapSize;
};

struct Light
{
	vec4 position; //.w contains the objLightMask
	vec3 diffuse;
	vec3 specular;
};



//Uniforms that change per pass
layout(binding = 0) uniform PassBuffer
{
	//Vertex shader (common to both receiver and casters)
	mat4 viewProj;



	//Vertex shader
	mat4 view;
	
	//-------------------------------------------------------------------------

	//Pixel shader
	mat3 invViewMatCubemap;




	vec4 ambientUpperHemi;


	


	
} passBuf;

	
	
//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 detailOffsetScaleD[4];
	vec4 detailOffsetScaleN[4];

	uvec4 indices0_3;
	//uintBitsToFloat( indices4_7.w ) contains mNormalMapWeight.
	uvec4 indices4_7;
};

layout(binding = 1) uniform MaterialBuf
{
	Material m[256];
} materialArray;

	
//Uniforms that change per Item/Entity
layout(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 UNIFORM DECLARATION
in block
{

    
		
			flat uint drawId;
				
			vec3 pos;
			vec3 normal;
							
			vec2 uv0;
									

} inPs;







#define ROUGHNESS material.kS.w
uniform sampler2DArray textureMaps[1];


	uint diffuseIdx;





	
	
	
	

	
	
	
	


vec4 diffuseCol;




Material material;
vec3 nNormal;











//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)

	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);


	//Formula:
	//	fresnelS = lerp( (1 - V*H)^5, 1, F0 )
	float fresnelS = material.F0.x + pow( 1.0 - VdotH, 5.0 ) * (1.0 - material.F0.x);

	//We should divide Rs by PI, but it was done inside G for performance
	vec3 Rs = ( fresnelS * (R * G) ) * material.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 );


	float fresnelD = 1.0f - fresnelS;

	//We should divide Rd by PI, but it is already included in kD
	vec3 Rd = (lightScatter * viewScatter * energyFactor * fresnelD) * diffuseCol.xyz * lightDiffuse;

	return NdotL * (Rs + Rd);
}










void main()
{
    

	
		uint materialId	= instance.worldMaterialIdx[inPs.drawId].x & 0x1FFu;
		material = materialArray.m[materialId];
	
	diffuseIdx			= material.indices0_3.x & 0x0000FFFFu;














	uint objLightMask = instance.worldMaterialIdx[inPs.drawId].z;

	



	/// Sample detail maps and weight them against the weight map in the next foreach loop.



		diffuseCol = texture( textureMaps[0], vec3( inPs.uv0.xy, diffuseIdx ) );


	/// 'insertpiece( SampleDiffuseMap )' must've written to diffuseCol. However if there are no
	/// diffuse maps, we must initialize it to some value. If there are no diffuse or detail maps,
	/// we must not access diffuseCol at all, but rather use material.kD directly (see piece( kD ) ).
	

	/// Blend the detail diffuse maps with the main diffuse.
	

		/// Apply the material's diffuse over the textures
		
			diffuseCol.xyz *= material.kD.xyz;
		

	



	
		// Geometric normal
		nNormal = normalize( inPs.normal ) ;
	

	/// If there is no normal map, the first iteration must
	/// initialize nNormal instead of try to merge with it.
	
		
		
	

		/// Blend the detail normal maps with the main normal.
	
	

	

	

	






	//Everything's in Camera space



	vec3 finalColour = passBuf.ambientUpperHemi.xyz * diffuseCol.xyz;


	









	//Point lights


	//Spot lights
	//spotParams[0].x = 1.0 / cos( InnerAngle ) - cos( OuterAngle )
	//spotParams[0].y = cos( OuterAngle / 2 )
	//spotParams[0].z = falloff






///!hlms_prepass


	
		
			//Linear to Gamma space
			outColour.xyz	= sqrt( finalColour );
		

		
			
				outColour.w		= material.F0.w * diffuseCol.w;
			
		

		

		
	


	
}



Thanks for your help!
Ash
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by dark_sylinc »

You may be missing the update on registering the Hlms.

Checkout the updated GraphicsSystem::registerHlms. You may be missing a library as we added a new folder in Samples/Media/Hlms/Pbs/Any; as you need to include the path to it while creating the HlmsPbs.

Hopefully that's the problem.

Edit: Also a few days ago I fixed a rare shadow mapping bug that could be related to this, so make sure to pull to latest, again :)
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

Thanks Matias.

I had indeed missed the extra "Any" lib when registering the Hlms. This has solved the crash on GL3, but still no shadows on either render system (even after updating to the latest commit)

Any ideas what else might have changed?

Thanks again!
Ash
zxz
Gremlin
Posts: 184
Joined: Sat Apr 16, 2016 9:25 pm
x 19

Re: [2.1] Shadows issues after Ogre update

Post by zxz »

Ash, did you get any shadows working since your last post?

After taking the plunge and updating to the latest code (post-shadow-rework), I no longer get any shadows as well. Even when using a shadow compositor node from the samples. I added all the Any libraries, and there are no shader compiler errors since then. The samples are working, so I suppose something small is missing to get things going as before. (OpenGL/Linux)
zxz
Gremlin
Posts: 184
Joined: Sat Apr 16, 2016 9:25 pm
x 19

Re: [2.1] Shadows issues after Ogre update

Post by zxz »

It turned out to be a simple issue as expected.

I had accidentally added "Hlms/Common/Any/GLSL" instead of "Hlms/Common/Any". This didn't result in any shader compiler errors, only no visible shadows.

I think that the setup of the internal Ogre paths for the Hlms needs to be provided by Ogre, instead of by the client application. Every time these paths change, the client applications break unexpectedly. The API just needs to provide some form of customization points as necessary for injecting custom paths.

Best regards
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

Hi zxz,

Sorry for not getting back to you sooner. I haven't got it working yet, but hopefully I'll get a bit more time to get it working after my holidays. Hopefully it's something simple. Glad you got yours up and running :)

Thanks!
Ash
zxz
Gremlin
Posts: 184
Joined: Sat Apr 16, 2016 9:25 pm
x 19

Re: [2.1] Shadows issues after Ogre update

Post by zxz »

No problem, Ash.

I found an actual bug that might be the source of your problems. I noticed that shadows were only working when the UV extents of the shadow textures were 100%.

The problem is that the shadow node script parser is not locale-independent, and thus can't parse floating point numbers with a decimal point '.' on locales using ',' as decimal separator. So partial UV extents would all collapse to 0. The 'getReal' function in the script parser has to be patched to ignore the system locale, or to force the locale used during parsing.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by dark_sylinc »

zxz wrote:I found an actual bug that might be the source of your problems. I noticed that shadows were only working when the UV extents of the shadow textures were 100%.

The problem is that the shadow node script parser is not locale-independent, and thus can't parse floating point numbers with a decimal point '.' on locales using ',' as decimal separator. So partial UV extents would all collapse to 0. The 'getReal' function in the script parser has to be patched to ignore the system locale, or to force the locale used during parsing.
Several functions in the script parser needs patching unfortunately, it's been a longstanding issue. A workaround is to call:

Code: Select all

setlocale( LC_NUMERIC, "C" );
Either at the beginning of the program or while initializing resources.

I just added this as a workaround.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by dark_sylinc »

zxz wrote:I had accidentally added "Hlms/Common/Any/GLSL" instead of "Hlms/Common/Any". This didn't result in any shader compiler errors, only no visible shadows.

I think that the setup of the internal Ogre paths for the Hlms needs to be provided by Ogre, instead of by the client application. Every time these paths change, the client applications break unexpectedly. The API just needs to provide some form of customization points as necessary for injecting custom paths.
You're kind of right.
The idea is that you set it up yourself in case you want to customize parts of the template (i.e. without touching source code); but we should at least provide a helper function that returns the ArchiveVec already set up for those users who don't need customization at all. Thanks for the idea!
zxz
Gremlin
Posts: 184
Joined: Sat Apr 16, 2016 9:25 pm
x 19

Re: [2.1] Shadows issues after Ogre update

Post by zxz »

dark_sylinc wrote:
zxz wrote:I found an actual bug that might be the source of your problems. I noticed that shadows were only working when the UV extents of the shadow textures were 100%.

The problem is that the shadow node script parser is not locale-independent, and thus can't parse floating point numbers with a decimal point '.' on locales using ',' as decimal separator. So partial UV extents would all collapse to 0. The 'getReal' function in the script parser has to be patched to ignore the system locale, or to force the locale used during parsing.
Several functions in the script parser needs patching unfortunately, it's been a longstanding issue. A workaround is to call:

Code: Select all

setlocale( LC_NUMERIC, "C" );
Either at the beginning of the program or while initializing resources.

I just added this as a workaround.
Thanks for the workaround. I think a more proper solution is to use a function like sscanf_l with a custom locale. It's not very nice to change the application locale settings, even if only during resource initialization (other threads might be around and affected by the change).
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by dark_sylinc »

zxz wrote:Thanks for the workaround. I think a more proper solution is to use a function like sscanf_l with a custom locale.
Yep.
zxz wrote:It's not very nice to change the application locale settings, even if only during resource initialization (other threads might be around and affected by the change).
Agreed. Btw I made a small change. It's now optional; exactly for the reasons you described (it's a real PITA if we decide for the user to do this)
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

I updated to the latest version of ogre (3872cd09ab7a704aab13a857d7d02769c5e7b503) and tried again. I found that it crashed in GLSL, but then added the Unlit/Any archive (as shown in GraphicsSystem.cpp).

I tried the locale workaround (both by setting initialiseResourceGroup flag to true and using setLocale explicitly), but no luck for me, still no shadows.

Looking at the log file, I'm getting quite a few errors like this: -

Code: Select all

Fragment Shader: 537461120PixelShader_ps
 GLSL validation result : 
Validation failed! - Different sampler types for same sample texture unit in fragment shader.
I'm wondering if these are relating to some of my meshes that are only used as data (e.g. grid / pit positions and racing lines), so it could be a red herring.

Thanks guys!
Ash
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

Hi Folks,

I was trying again to get this working today without luck. I updated to the latest version of Ogre and copied across the latest HLMS folder and dlls.

I am getting a lot of errors like this (49 of them): -

Code: Select all

Fragment Shader: 537329920PixelShader_ps
 GLSL validation result : 
Validation failed! - Different sampler types for same sample texture unit in fragment shader.
Here is how the shader looks: -

Code: Select all

#if 0
	***	[Hash 0x010d84dd]	2
	***	[Hash 0x0790ba12]	4
	***	[Hash 0x086bb3a6]	0
	***	[Hash 0x0b4678e4]	1
	***	[Hash 0x0c7e761b]	4
	***	[Hash 0x1185e86f]	0
	***	[Hash 0x123606a9]	0
	***	[Hash 0x15cb74a1]	0
	***	[Hash 0x1af900a2]	1
	***	[Hash 0x1b0c2b69]	0
	***	[Hash 0x1bab8cdd]	0
	***	[Hash 0x1bb5acac]	0
	***	[Hash 0x1c1faad4]	0
	***	[Hash 0x1e8b5671]	50000
	***	[Hash 0x1f2c6e82]	0
	***	[Hash 0x22caa76a]	0
	***	[Hash 0x25dc73c6]	635204550
	***	[Hash 0x26249384]	42857
	***	[Hash 0x2a892b58]	0
	***	[Hash 0x2cb6ab02]	0
	***	[Hash 0x2dd3a2cd]	0
	***	[Hash 0x354d66c0]	3
	***	[Hash 0x359e8062]	1
	***	[Hash 0x360c3db1]	0
	***	[Hash 0x367aa843]	0
	***	[Hash 0x39384d5a]	28571
	***	[Hash 0x3b038020]	0
	***	[Hash 0x3dde9817]	1
	***	[Hash 0x3f315fff]	0
	***	[Hash 0x3fcb60f1]	1070293233
	***	[Hash 0x415a738b]	0
	***	[Hash 0x4508a85c]	1
	***	[Hash 0x45d6475f]	0
	***	[Hash 0x46bba485]	0
	***	[Hash 0x4956ca9a]	1
	***	[Hash 0x4ec19020]	1
	***	[Hash 0x51de8f13]	42857
	***	[Hash 0x549bb006]	0
	***	[Hash 0x55683ca9]	1
	***	[Hash 0x57643473]	3
	***	[Hash 0x5a1459c4]	1
	***	[Hash 0x5a23f9f0]	0
	***	[Hash 0x5ca459ef]	0
	***	[Hash 0x5cb4719a]	1
	***	[Hash 0x61e63948]	1
	***	[Hash 0x66ac9d57]	0
	***	[Hash 0x675280f4]	0
	***	[Hash 0x6962e498]	1
	***	[Hash 0x6be92c72]	0
	***	[Hash 0x6bf5b20f]	1
	***	[Hash 0x6d28c426]	1
	***	[Hash 0x6f177a79]	0
	***	[Hash 0x717564b5]	0
	***	[Hash 0x74824502]	1
	***	[Hash 0x790cdbbe]	0
	***	[Hash 0x7a148ebc]	0
	***	[Hash 0x7ae862a6]	0
	***	[Hash 0x7e8dec1c]	0
	***	[Hash 0x7e934f0e]	0
	***	[Hash 0x8040ea88]	28571
	***	[Hash 0x8421366d]	256
	***	[Hash 0x86319b9f]	1
	***	[Hash 0x875516cf]	0
	***	[Hash 0x8857c26f]	0
	***	[Hash 0x91f755f3]	0
	***	[Hash 0x92baf270]	0
	***	[Hash 0x93f2327b]	635204550
	***	[Hash 0x94b1117a]	-1
	***	[Hash 0x962aeb1a]	1
	***	[Hash 0x96c12323]	1
	***	[Hash 0x9abd84b5]	-1698855755
	***	[Hash 0xa1b3cd70]	1
	***	[Hash 0xa461daa9]	1
	***	[Hash 0xa62cee23]	0
	***	[Hash 0xa6ac776b]	0
	***	[Hash 0xa7fb3663]	1
	***	[Hash 0xa90324bb]	0
	***	[Hash 0xafaf1bb3]	450
	***	[Hash 0xb0e4cb8e]	0
	***	[Hash 0xb22f037a]	0
	***	[Hash 0xb9201184]	0
	***	[Hash 0xb967bb7b]	0
	***	[Hash 0xbc128c23]	0
	***	[Hash 0xc377e795]	50000
	***	[Hash 0xc46d5eba]	1
	***	[Hash 0xc5ed03e2]	1
	***	[Hash 0xc7cccc57]	0
	***	[Hash 0xcb33bcfe]	0
	***	[Hash 0xd17f1d1c]	1
	***	[Hash 0xdc23368e]	0
	***	[Hash 0xe40b2520]	1
	***	[Hash 0xe7bd0fde]	0
	***	[Hash 0xe9b3b96d]	0
	***	[Hash 0xebfcdcac]	28571
	***	[Hash 0xec133132]	-334286542
	***	[Hash 0xec4e19ce]	0
	***	[Hash 0xf415f8ba]	1
	***	[Hash 0xf6eb512d]	0
	***	[Hash 0xf742ff75]	1
	***	[Hash 0xfcef2411]	1
	DONE DUMPING PROPERTIES
	DONE DUMPING PIECES
#endif

#version 430 core


    #extension GL_ARB_shading_language_420pack: require
    #define layout_constbuffer(x) layout( std140, x )

    #define bufferFetch texelFetch

#define float2 vec2
#define float3 vec3
#define float4 vec4

#define int2 ivec2
#define int3 ivec3
#define int4 ivec4

#define uint2 uvec2
#define uint3 uvec3
#define uint4 uvec4

#define float3x3 mat3
#define float4x4 mat4

#define mul( x, y ) ((x) * (y))
#define saturate(x) clamp( (x), 0.0, 1.0 )
#define lerp mix
#define INLINE

#define outVs_Position gl_Position
#define OGRE_SampleLevel( tex, sampler, uv, lod ) textureLod( tex, uv.xy, lod )




#extension GL_AMD_shader_trinary_minmax: require


layout(std140) uniform;
#define FRAG_COLOR		0

	
		
			layout(location = FRAG_COLOR, index = 0) out vec4 outColour;
		
	










// START UNIFORM DECLARATION

	
		
struct ShadowReceiverData
{
    mat4 texViewProj;
	vec2 shadowDepthRange;
	vec4 invShadowMapSize;
};

struct Light
{
	vec4 position; //.w contains the objLightMask
	vec3 diffuse;
	vec3 specular;

	vec3 attenuation;
	vec3 spotDirection;
	vec3 spotParams;
};



//Uniforms that change per pass
layout_constbuffer(binding = 0) uniform PassBuffer
{
	//Vertex shader (common to both receiver and casters)
	mat4 viewProj;




	//Vertex shader
	mat4 view;
	ShadowReceiverData shadowRcv[3];
	//-------------------------------------------------------------------------

	//Pixel shader
	mat3 invViewMatCubemap;




	vec4 ambientUpperHemi;



	float pssmSplitPoints0;
	float pssmSplitPoints1;
	float pssmSplitPoints2;	Light lights[1];

	


	
} passBuf;

	
	
//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 detailOffsetScaleD[4];
	vec4 detailOffsetScaleN[4];

	uvec4 indices0_3;
	//uintBitsToFloat( indices4_7.w ) contains mNormalMapWeight.
	uvec4 indices4_7;
};

layout_constbuffer(binding = 1) uniform MaterialBuf
{
	Material m[256];
} materialArray;

	
//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 UNIFORM DECLARATION

in block
{

    
		
			flat uint drawId;
				
			vec3 pos;
			vec3 normal;
							
			vec2 uv0;
		
			
				vec4 posL0;
			
				vec4 posL1;
			
				vec4 posL2;		float depth;					

} inPs;







#define ROUGHNESS material.kS.w
uniform sampler2DArray textureMaps[1];


	uint diffuseIdx;





	
	
	
	

	
	
	
	


vec4 diffuseCol;




Material material;
vec3 nNormal;











//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)

	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);


	//Formula:
	//	fresnelS = lerp( (1 - V*H)^5, 1, F0 )
	float fresnelS = material.F0.x + pow( 1.0 - VdotH, 5.0 ) * (1.0 - material.F0.x);

	//We should divide Rs by PI, but it was done inside G for performance
	vec3 Rs = ( fresnelS * (R * G) ) * material.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 );


	float fresnelD = 1.0f - fresnelS;

	//We should divide Rd by PI, but it is already included in kD
	vec3 Rd = (lightScatter * viewScatter * energyFactor * fresnelD) * diffuseCol.xyz * lightDiffuse;

	return NdotL * (Rs + Rd);
}








	#define hlms_shadowmap0 texShadowMap0
	#define hlms_shadowmap0_uv_min SH_HALF2( 0.0, 0.0 )
	#define hlms_shadowmap0_uv_max SH_HALF2( 1.0, 0.28571 )
	
		
			#define hlms_shadowmap0_uv_param , hlms_shadowmap0_uv_min, hlms_shadowmap0_uv_max
			
	#define hlms_shadowmap1 texShadowMap0
	#define hlms_shadowmap1_uv_min SH_HALF2( 0.0, 0.28571 )
	#define hlms_shadowmap1_uv_max SH_HALF2( 0.50000, 0.42857 )
	
		
			#define hlms_shadowmap1_uv_param , hlms_shadowmap1_uv_min, hlms_shadowmap1_uv_max
			
	#define hlms_shadowmap2 texShadowMap0
	#define hlms_shadowmap2_uv_min SH_HALF2( 0.50000, 0.28571 )
	#define hlms_shadowmap2_uv_max SH_HALF2( 1.0, 0.42857 )
	
		
			#define hlms_shadowmap2_uv_param , hlms_shadowmap2_uv_min, hlms_shadowmap2_uv_max
			

	#define SH_HALF2 vec2
	#define SH_HALF float
	#define OGRE_SAMPLE_SHADOW( tex, sampler, uv, depth ) texture( tex, vec3( uv, fDepth ) )
	#define OGRE_SAMPLE_SHADOW_ESM( tex, sampler, uv ) textureLod( tex, uv, 0 ).x
	#define PASSBUF_ARG_DECL
	#define PASSBUF_ARG




		
			uniform sampler2DShadow texShadowMap0;	


	
		INLINE float getShadow( sampler2DShadow shadowMap, 
								float4 psPosLN, float4 invShadowMapSize )
		{
	
		//Spot and directional lights
		float fDepth = psPosLN.z;
		SH_HALF2 uv = SH_HALF2( psPosLN.xy / psPosLN.w );
	
	
		float retVal = 0;

		
			SH_HALF2 offsets[4] =
            
                SH_HALF2[4](
                        			
				SH_HALF2( 0, 0 ),	//0, 0
				SH_HALF2( 1, 0 ),	//1, 0
				SH_HALF2( 0, 1 ),	//1, 1
				SH_HALF2( 0, 0 ) 	//1, 1
						            
            );
                        		
		
		
			
				uv += offsets[0] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[1] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[2] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[3] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );		
		
			retVal *= 0.25;
			///! exponential_shadow_maps
	   ///! exponential_shadow_maps

	
	
		return retVal;
	}

	
		INLINE float getShadow( sampler2DShadow shadowMap, 
								float4 psPosLN, float4 invShadowMapSize, SH_HALF2 minUV, SH_HALF2 maxUV )
		{
	
		//Spot and directional lights
		float fDepth = psPosLN.z;
		SH_HALF2 uv = SH_HALF2( psPosLN.xy / psPosLN.w );
	
	
		float retVal = 0;

		
			SH_HALF2 offsets[4] =
            
                SH_HALF2[4](
                        			
				SH_HALF2( 0, 0 ),	//0, 0
				SH_HALF2( 1, 0 ),	//1, 0
				SH_HALF2( 0, 1 ),	//1, 1
				SH_HALF2( 0, 0 ) 	//1, 1
						            
            );
                        		
		
		
			
				uv += offsets[0] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[1] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[2] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[3] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );		
		
			retVal *= 0.25;
			///! exponential_shadow_maps
	   ///! exponential_shadow_maps

	
	
		retVal = (uv.x <= minUV.x || uv.x >= maxUV.x ||
				  uv.y <= minUV.y || uv.y >= maxUV.y) ? 1.0 : retVal;
	
		return retVal;
	}

	
		INLINE float getShadowPoint( sampler2DShadow shadowMap, 
									 float3 posVS, float3 lightPos, float4 invShadowMapSize, float2 invDepthRange
									 PASSBUF_ARG_DECL )
		{
	
		//Point lights
		float3 cubemapDir = posVS.xyz - lightPos.xyz;
		float fDepth = length( cubemapDir );
		cubemapDir *= 1.0 / fDepth;
		cubemapDir = mul( cubemapDir.xyz, passBuf.invViewMatCubemap );
		fDepth = (fDepth - invDepthRange.x) * invDepthRange.y;

		SH_HALF2 uv;
		uv.x = (cubemapDir.x / (1.0 + abs( cubemapDir.z ))) * 0.25 +
				(cubemapDir.z < 0.0 ? SH_HALF( 0.75 ) : SH_HALF( 0.25 ));
		uv.y = (cubemapDir.y / (1.0 + abs( cubemapDir.z ))) * 0.5 + 0.5;

			
	
		float retVal = 0;

		
			SH_HALF2 offsets[4] =
            
                SH_HALF2[4](
                        			
				SH_HALF2( 0, 0 ),	//0, 0
				SH_HALF2( 1, 0 ),	//1, 0
				SH_HALF2( 0, 1 ),	//1, 1
				SH_HALF2( 0, 0 ) 	//1, 1
						            
            );
                        		
		
		
			
				uv += offsets[0] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[1] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[2] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[3] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );		
		
			retVal *= 0.25;
			///! exponential_shadow_maps
	   ///! exponential_shadow_maps

	
	
		return retVal;
	}

	
		INLINE float getShadowPoint( sampler2DShadow shadowMap, 
									 float3 posVS, float3 lightPos, float4 invShadowMapSize, float2 invDepthRange,
									 SH_HALF2 minUV, SH_HALF2 maxUV, SH_HALF2 lengthUV
									 PASSBUF_ARG_DECL )
		{
	
		//Point lights
		float3 cubemapDir = posVS.xyz - lightPos.xyz;
		float fDepth = length( cubemapDir );
		cubemapDir *= 1.0 / fDepth;
		cubemapDir = mul( cubemapDir.xyz, passBuf.invViewMatCubemap );
		fDepth = (fDepth - invDepthRange.x) * invDepthRange.y;

		SH_HALF2 uv;
		uv.x = (cubemapDir.x / (1.0 + abs( cubemapDir.z ))) * 0.25 +
				(cubemapDir.z < 0.0 ? SH_HALF( 0.75 ) : SH_HALF( 0.25 ));
		uv.y = (cubemapDir.y / (1.0 + abs( cubemapDir.z ))) * 0.5 + 0.5;

		uv.xy = uv.xy * lengthUV.xy + minUV.xy;	
	
		float retVal = 0;

		
			SH_HALF2 offsets[4] =
            
                SH_HALF2[4](
                        			
				SH_HALF2( 0, 0 ),	//0, 0
				SH_HALF2( 1, 0 ),	//1, 0
				SH_HALF2( 0, 1 ),	//1, 1
				SH_HALF2( 0, 0 ) 	//1, 1
						            
            );
                        		
		
		
			
				uv += offsets[0] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[1] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[2] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );
				uv += offsets[3] * SH_HALF2( invShadowMapSize.xy );				retVal += OGRE_SAMPLE_SHADOW( shadowMap, shadowSampler, uv, fDepth );		
		
			retVal *= 0.25;
			///! exponential_shadow_maps
	   ///! exponential_shadow_maps

	
	
		retVal = (uv.x <= minUV.x || uv.x >= maxUV.x ||
				  uv.y <= minUV.y || uv.y >= maxUV.y) ? 1.0 : retVal;
	
		return retVal;
	}


void main()
{
    

	
		uint materialId	= instance.worldMaterialIdx[inPs.drawId].x & 0x1FFu;
		material = materialArray.m[materialId];
	
	diffuseIdx			= material.indices0_3.x & 0x0000FFFFu;














	

	



	/// Sample detail maps and weight them against the weight map in the next foreach loop.



		diffuseCol = texture( textureMaps[0], vec3( inPs.uv0.xy, diffuseIdx ) );


	/// 'insertpiece( SampleDiffuseMap )' must've written to diffuseCol. However if there are no
	/// diffuse maps, we must initialize it to some value. If there are no diffuse or detail maps,
	/// we must not access diffuseCol at all, but rather use material.kD directly (see piece( kD ) ).
	

	/// Blend the detail diffuse maps with the main diffuse.
	

		/// Apply the material's diffuse over the textures
		
			diffuseCol.xyz *= material.kD.xyz;
		

	



	
		// Geometric normal
		nNormal = normalize( inPs.normal ) ;
	

	/// If there is no normal map, the first iteration must
	/// initialize nNormal instead of try to merge with it.
	
		
		
	

		/// Blend the detail normal maps with the main normal.
	
	

	

	

		float fShadow = 1.0;
	
		if( inPs.depth <= passBuf.pssmSplitPoints0 )
		{
			fShadow = getShadow( hlms_shadowmap0, 
								 inPs.posL0,
								 passBuf.shadowRcv[0].invShadowMapSize
								 hlms_shadowmap0_uv_param );
					}
		
		else if( inPs.depth <= passBuf.pssmSplitPoints1 )
		{
			fShadow = getShadow( hlms_shadowmap1, 
								 inPs.posL1,
								 passBuf.shadowRcv[1].invShadowMapSize
								 hlms_shadowmap1_uv_param );
					}
		else if( inPs.depth <= passBuf.pssmSplitPoints2 )
		{
			fShadow = getShadow( hlms_shadowmap2, 
								 inPs.posL2,
								 passBuf.shadowRcv[2].invShadowMapSize
								 hlms_shadowmap2_uv_param );
					}	

	






	//Everything's in Camera space

	vec3 viewDir	= normalize( -inPs.pos );
	float NdotV		= clamp( dot( nNormal, viewDir ), 0.0, 1.0 );



	vec3 finalColour = passBuf.ambientUpperHemi.xyz * diffuseCol.xyz;


	



	
		finalColour += BRDF( passBuf.lights[0].position.xyz, viewDir, NdotV, passBuf.lights[0].diffuse, passBuf.lights[0].specular ) * fShadow;





	vec3 lightDir;
	float fDistance;
	vec3 tmpColour;
	float spotCosAngle;

	//Point lights


	//Spot lights
	//spotParams[0].x = 1.0 / cos( InnerAngle ) - cos( OuterAngle )
	//spotParams[0].y = cos( OuterAngle / 2 )
	//spotParams[0].z = falloff






///!hlms_prepass


	
		
			outColour.xyz	= finalColour;
		

		
			outColour.w		= 1.0;

		

		
	


	
}
I wonder if this is perhaps what is causing the lack of shadows?

Thanks!
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by dark_sylinc »

Could you run it in Debug mode? Seeing "[Hash 0x010d84dd]" means you're using a non-debug version of Ogre, and you could be missing useful validation warnings (also it would print the actual parameters instead of hash numbers).

Also upload a RenderDoc capture (7z it first!) to Google Drive of Dropbox so I can take a look.

Btw the warning you're getting is normal, happens all the time (unfortunately) and can be ignored.
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

Will do: -
Image

I'll also get renderdoc and try a capture. It's something I've been meaning to look at for a while
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

Bah, even renderdoc is against me today :lol:

I tried to capture on dx11 and the game crashes when I capture: -

Image

I tried on GL3+ and the game crashes when I try to load the track / car (in OgreGL3PlusVaoManager.cpp)

Image

Stack trace: -

Image

Any ideas what could be the issue?

I will compile in debug mode after I get the kids to bed

Thanks!
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

I compiled in debug mode (OGRE_DEBUG_MODE=1) and got a few more errors in the log file, but I don't think there is anything that might be the problem. There does seem to be quite a few meshes with "corrupted chunks" though. I'll have a look in the source to see what might be causing that.

I uploaded it as it's a little large

I also uploaded a generated shader (although as you say the error can be ignored)

Thanks again for your help, I'm not sure what it peculiar with my scene that causes shadows to not work :(
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by dark_sylinc »

OK:

1. RenderDoc crashes because it ran out of memory. This is common for non-small-sized projects running in 32 bit bits. Only solution is to build in 64-bit.

2. The shader you've uploaded in Debug mode differs greatly from the one from Release (note: what you've rendered is 100% deterministic, it is possible for Ogre to assign the same filename to two different shaders if they're from different runs).
The shader you've uploaded... does not perform shadowing (which would totally explain why you don't have shadows).
This could happen because the node doing the rendering does not actually have a shadow node, or all of your directional lights have done light->setCastShadow( false ).
In fact the generated shader has set hlms_lights_directional_non_caster = 1 and hlms_lights_directional = 0; which means your directional shadow has explicitly called light->setCastShadow( false ) (or the value that holds this data has been corrupted).

PS: about the "Corrupted chunk detected! Stream name", just ignore them. That's a bug in Ogre.
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

Thanks dark_sylinc.

I think conversion to 64 bit might take a bit of time, and with my limited dev time at the moment I'll have to add it on my list of todos :)

Ah, sorry I thought I picked the last error like I did for the Release mode, but I must not have.

Here is another one that has shadows. I don't think I've turned any casters off. They have worked in a previous Ogre 2.1 commit, but perhaps another problem was making them work somehow.

I'll take a good look through the code now :)

Thanks again
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by dark_sylinc »

Mmm... I don't see anything wrong with the shader.

Unless your ambient lighting is so strong that you don't really get to see the shadows even if they're there.
AshMcConnell wrote:I think conversion to 64 bit might take a bit of time, and with my limited dev time at the moment I'll have to add it on my list of todos :)
It's ok. We have two possible solutions:
  • Setup shadowmap visualization like in ShadowMapDebugging. I want to see the splits.
  • RenderDoc is running out of memory. Aside from going 64-bit, you can workaround this problem by making the scene simpler. Get rid of postprocessing effects, and get rid of cubemaps (dynamic and static). Cubemaps tend to consume a lot of RAM. If possible, get rid of as many textures as possible. Do this until RenderDoc doesn't crash anymore. Even if everything is grey and texture-less, that's enough.
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

Thanks, I'll try to skinny things down a bit.

Just to clarify one thing, it's not RenderDoc that crashes it's my game while being executed by RenderDoc
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by dark_sylinc »

Yes, but it's crashing with null pointers after requesting memory from the API (i.e. a buffer, or to map a memory region to upload something to the GPU). This strongly indicates RenderDoc ran out of memory and returned a null pointer.
These crashes are very common with 32-bit captures.
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

Thanks, that makes sense, but even if I remove all the meshes I can't do a capture (I tried both DX and GL3+).

This is with a AMD R390 on Windows 10. I'll try updating the drivers to see if that helps any.
User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 16
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by AshMcConnell »

Ok, I managed to bend RenderDoc to my will :)

Had to have very very minimal graphics, I uploaded it here(it's ~42 meg)

If the capture doesn't give you enough info I'll try shadowmap visualization tomorrow.

Thanks again for helping to debug, I know you are busy!
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [2.1] Shadows issues after Ogre update

Post by dark_sylinc »

Well, RenderDoc quickly said what was wrong (or at least what appears to be wrong). Your pssmSplitPoints are completely off. All bad.
If you wanna know how I got there: I do not know why it is busted, but I do can tell you where to look. You should place breakpoints in OgreMain/src/Compositor/OgreCompositorShadowNode.cpp

Code: Select all

if( pssmSetup->getSplitPoints()[0] != camera->getNearClipDistance() ||
    pssmSetup->getSplitPoints()[itor->numSplits-1] != light->getShadowFarDistance() )
{
    pssmSetup->calculateSplitPoints( itor->numSplits, camera->getNearClipDistance(),
                                light->getShadowFarDistance(), itor->pssmLambda );
}
A healthy PSSM split point list would look like this:

Code: Select all

pssmSetup->mSplitPoints = { 0.2, 10.91, 51.66, 500 }
Where 500 at the end is the value passed to mSceneManager->setShadowFarDistance( 500 ) or light->setShadowFarDistance( 500 ). Yours may be different.

Find out why your split points are {0.00367, 0.00183, 0.0} (they're in descending order!!!) and you'll find out why your shadows don't work. Also tell us why. I want to know too :)

Cheers and good luck
Post Reply