Operating System: Windows 10
Render System: Direct3D9 (but same thing happens on my Direct3D11 shader)
Hello!
I am almost complete in upgrading from Ogre 1.9 to Ogre 1.11.2, but I have yet again ran into a problem.
Shadow receiver materials are behaving strange when using hardware animation, when not using hardware animation, it works perfectly.
For some reason, when I use the exact same shader/material for hardware animation on Ogre 1.9, it works.
The shadow casting work either way, it is only the shadow receiver that does not work properly.
Below is a very simple shader/material that works on Ogre 1.9 but not in Ogre 1.11.2.
Material:
Code: Select all
material alien
{
technique
{
pass
{
vertex_program_ref TestSkinning_VS
{
}
fragment_program_ref TestSkinning_PS
{
}
texture_unit DiffuseMap
{
texture alien.png
}
texture_unit ShadowMap
{
content_type shadow
tex_address_mode border
tex_border_colour 1 1 1 1
}
}
}
}
Code: Select all
vertex_program TestSkinning_VS hlsl
{
source test.hlsl
entry_point main_vs
target vs_3_0
includes_skeletal_animation true
column_major_matrices false
default_params
{
param_named_auto worldMatrix world_matrix
param_named_auto texViewProj texture_viewproj_matrix
param_named_auto viewProjectionMatrix viewproj_matrix
param_named_auto inverseWorldMatrix inverse_world_matrix
param_named_auto worldMatrix3x4Array world_matrix_array_3x4
}
}
fragment_program TestSkinning_PS hlsl
{
source test.hlsl
entry_point main_ps
target ps_3_0
default_params
{
param_named_auto shadowColour shadow_colour
}
}
Code: Select all
float4x4 worldMatrix;
float4x4 texViewProj;
float4x4 viewProjectionMatrix;
float4x4 inverseWorldMatrix;
float3x4 worldMatrix3x4Array[23];
struct VS_OUTPUT
{
float4 oVertexPos : TEXCOORD0;
float2 oUV : TEXCOORD1;
float3 oShadowUV : TEXCOORD2;
};
VS_OUTPUT main_vs( float4 position : POSITION,
out float4 oPosition : POSITION,
float2 iUV : TEXCOORD0,
float4 blendIdx : BLENDINDICES,
float4 blendWgt : BLENDWEIGHT )
{
VS_OUTPUT Out;
oPosition = float4(0, 0, 0, 0);
for(int i = 0; i < 3; ++i)
{
oPosition += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
}
Out.oVertexPos = mul(inverseWorldMatrix, oPosition);
oPosition = mul(viewProjectionMatrix, oPosition);
Out.oUV = iUV;
float4 shadowUV = mul(texViewProj, mul(worldMatrix, Out.oVertexPos));
Out.oShadowUV = shadowUV.xyz / shadowUV.w;
return Out;
}
float4 shadowColour;
sampler DiffuseMap : register(s0);
sampler ShadowMap : register(s1);
float4 main_ps( float4 position : TEXCOORD0,
float2 uv : TEXCOORD1,
float3 shadowUV : TEXCOORD2 ) : COLOR0
{
float4 color = float4(1,1,1,1);
color.xyz = tex2D(DiffuseMap, uv).xyz;
const float shadowBias = 0.000005;
float shadowSample = tex2D(ShadowMap, shadowUV.xy).x;
if(shadowSample + shadowBias < shadowUV.z)
color.xyz *= shadowColour.xyz;
return color;
}
I have tried everything I could think of, but nothing fixed it. I tried changing "worldMatrix" to many other types of "param_named_auto", but nothing works correctly.
With some of my tests, I have seen that the shader actually receives the shadow correctly, but that it is for some reason in the wrong space or something, which is wierd because it worked in Ogre 1.9...
Anyone have any ideas on how to fix this?