Hello,
I am trying to have shadows in my application using RT Shader system and pssm3 shadows, I use a directional light to cast shadows, and additional have a spolight in my scene.
When I use only directional light in my scene the shadow works fine but the shadow is completely black in color.
- Black shadow with directional light
When I add an additional light I have bad flickering shadow.
- Shadow flickers when point light is added
When I generate the Shaders in cg, I have the following Fragment code:
//Fragment file
//-----------------------------------------------------------------------------
// Program Type: Fragment shader
// Language: cg
// Created by Ogre RT Shader Generator. All rights reserved.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// PROGRAM DEPENDENCIES
//-----------------------------------------------------------------------------
#include "FFPLib_Common.cg"
#include "SGXLib_PerPixelLighting.cg"
#include "FFPLib_Texturing.cg"
#include "SGXLib_IntegratedPSSM.cg"
//-----------------------------------------------------------------------------
// GLOBAL PARAMETERS
//-----------------------------------------------------------------------------
float4 derived_ambient_light_colour;
float4 surface_diffuse_colour;
float4 surface_specular_colour;
float4 surface_emissive_colour;
float4 derived_scene_colour;
float surface_shininess;
float4 light_position_view_space0;
float4 light_attenuation1;
float4 derived_light_diffuse2;
float4 light_direction_view_space3;
float4 derived_light_diffuse4;
sampler2D gTextureSampler0 : register(s0);
float4 pssm_split_points5;
sampler2D shadow_map1 : register(s1);
float4 inv_shadow_texture_size6;
sampler2D shadow_map2 : register(s2);
float4 inv_shadow_texture_size7;
sampler2D shadow_map3 : register(s3);
float4 inv_shadow_texture_size8;
//-----------------------------------------------------------------------------
// Function Name: main
// Function Desc: Pixel Program Entry point
//-----------------------------------------------------------------------------
void main
(
in float3 iTexcoord3_0 : TEXCOORD0,
in float3 iTexcoord3_1 : TEXCOORD1,
in float2 iTexcoord2_2 : TEXCOORD2,
in float iTexcoord1_3 : TEXCOORD3,
in float4 iTexcoord4_4 : TEXCOORD4,
in float4 iTexcoord4_5 : TEXCOORD5,
in float4 iTexcoord4_6 : TEXCOORD6,
out float4 oColor_0 : COLOR
)
{
float4 lLocalParam_0;
float4 lLocalParam_1;
float4 lPerPixelDiffuse;
float4 texel;
float4 source1;
float4 source2;
float lShadowFactor;
FFP_Construct(1.0, 1.0, 1.0, 1.0, lLocalParam_0);
FFP_Construct(0.0, 0.0, 0.0, 0.0, lLocalParam_1);
FFP_Assign(lLocalParam_0, oColor_0);
FFP_Assign(derived_scene_colour, lPerPixelDiffuse);
SGX_Light_Point_Diffuse(iTexcoord3_0, iTexcoord3_1, light_position_view_space0.xyz, light_attenuation1, derived_light_diffuse2.xyz, lPerPixelDiffuse.xyz, lPerPixelDiffuse.xyz);
SGX_Light_Directional_Diffuse(iTexcoord3_0, light_direction_view_space3.xyz, derived_light_diffuse4.xyz, lPerPixelDiffuse.xyz, lPerPixelDiffuse.xyz);
FFP_Assign(lPerPixelDiffuse, lLocalParam_0);
FFP_Assign(lLocalParam_0, oColor_0);
SGX_ComputeShadowFactor_PSSM3(iTexcoord1_3, pssm_split_points5, iTexcoord4_4, iTexcoord4_5, iTexcoord4_6, shadow_map1, shadow_map2, shadow_map3, inv_shadow_texture_size6, inv_shadow_texture_size7, inv_shadow_texture_size8, lShadowFactor);
SGX_ApplyShadowFactor_Diffuse(derived_scene_colour, lLocalParam_0, lShadowFactor, lLocalParam_0);
SGX_ModulateScalar(lShadowFactor, lLocalParam_1, lLocalParam_1);
FFP_Assign(lLocalParam_0, oColor_0);
FFP_SampleTexture(gTextureSampler0, iTexcoord2_2, texel);
FFP_Assign(texel, source1);
FFP_Assign(lLocalParam_0, source2);
FFP_Modulate(source1, source2, oColor_0);
FFP_Add(oColor_0.xyz, lLocalParam_1.xyz, oColor_0.xyz);
}
I notice that the point light's diffuse is being considered by SGX_ApplyShadowFactor_Diffuse step. According to my expectation, I thought the diffuse of the directional light alone would be considered for this step, but thats not the case here.
So here are my questions:
Why is my Shadow always Black?
When I add any light to my scene(One Directional light is already there), why is my shadow flickering??
thanks for your inputs,
Amritha