RT Shader System Component (RTSS)
- Wolfmanfx
- OGRE Team Member
- Posts: 1525
- Joined: Fri Feb 03, 2006 10:37 pm
- Location: Austria - Leoben
- x 99
- Contact:
Re: RT Shader System Component (RTSS)
If i do that i get weired texture effects for example the border of the thumbnails in the samplebrowser scrolling from top to bottom.
So this fix do not work but lets see if i can something
So this fix do not work but lets see if i can something
- Wolfmanfx
- OGRE Team Member
- Posts: 1525
- Joined: Fri Feb 03, 2006 10:37 pm
- Location: Austria - Leoben
- x 99
- Contact:
Re: RT Shader System Component (RTSS)
Ok i looked into it again and the logic told me that we need a branch and this one
Now everything works (on my side the shader sample demo and my material script).
So we overwrite the content only if a custom texture matrix is set makes more sense for me too
but plz some should check this if any side effects are introduced (from my side not but you never no (: )
Code: Select all
if(textureUnitParams->mTextureMatrix.get() != NULL)
texCoordContent = Parameter::Content(Parameter::SPC_TEXTURE_COORDINATE0 + textureUnitParams->mTextureUnitState->getTextureCoordSet());
So we overwrite the content only if a custom texture matrix is set makes more sense for me too
but plz some should check this if any side effects are introduced (from my side not but you never no (: )
- Nir Hasson
- OGRE Retired Team Member
- Posts: 363
- Joined: Wed Nov 05, 2008 4:40 pm
- Location: TLV - Israel
- x 2
- Contact:
Re: RT Shader System Component (RTSS)
Let me see if I understand your change - you simply flipped the condition ? form == NULL to != NULL ?
If this is the case I'm sure there will be some other side effects..
If this is the case I'm sure there will be some other side effects..
- Wolfmanfx
- OGRE Team Member
- Posts: 1525
- Joined: Fri Feb 03, 2006 10:37 pm
- Location: Austria - Leoben
- x 99
- Contact:
Re: RT Shader System Component (RTSS)
yep flipped it but did not encountered any side effects
-
- Gnoblar
- Posts: 4
- Joined: Fri Nov 12, 2010 10:55 am
shadow flickers when more than one light is used
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.
When I add an additional light I have bad flickering shadow. 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
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.
When I add an additional light I have bad flickering shadow. 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
- Nir Hasson
- OGRE Retired Team Member
- Posts: 363
- Joined: Wed Nov 05, 2008 4:40 pm
- Location: TLV - Israel
- x 2
- Contact:
Re: RT Shader System Component (RTSS)
Right now the PSSM3 sub render state doesn't handle multiple lights in the right manner since it apply the shadow factor to the sum of all lights diffuse colour. (see previous page for detailed explanation).
Assuming you use modulation based shadow technique, the function that actually apply the shadow factor (called SGX_ApplyShadowFactor_Diffuse) affects only the diffuse term of the lights.
My guess is that your ambient light of the scene is completely black and in your shadowed areas of your scene the diffuse term goes to zero and you get that result.
Regarding the flickering issue - I think it's related to higher level of the application such as shadow camera setup etc.
If you can attach some screen shots of the flickering I might be able to help.
Hope I helped...
Assuming you use modulation based shadow technique, the function that actually apply the shadow factor (called SGX_ApplyShadowFactor_Diffuse) affects only the diffuse term of the lights.
My guess is that your ambient light of the scene is completely black and in your shadowed areas of your scene the diffuse term goes to zero and you get that result.
Regarding the flickering issue - I think it's related to higher level of the application such as shadow camera setup etc.
If you can attach some screen shots of the flickering I might be able to help.
Hope I helped...
- trilobite
- Silver Sponsor
- Posts: 135
- Joined: Thu Jul 13, 2006 9:16 pm
- Location: San Juan Capistrano, CA, USA
- x 1
Re: RT Shader System Component (RTSS)
Just a quick note here about a crash problems with RTShader lib, OpenGL driver and use of coulour_op_ex in material scripts...
I thought this problem had been fixed. But I was having crash problems while using the OpenGl driver.
I traced the problem to a material script that included...
texture_unit
{
colour_op_ex source1 src_manual src_current 0.219608 0.439216 0.439216
}
Eliminating that script, or eliminating the RTShader lib implementation resolved the crash problem.
Otherwise, the RTShader lib is working fabulously.
I thought this problem had been fixed. But I was having crash problems while using the OpenGl driver.
I traced the problem to a material script that included...
texture_unit
{
colour_op_ex source1 src_manual src_current 0.219608 0.439216 0.439216
}
Eliminating that script, or eliminating the RTShader lib implementation resolved the crash problem.
Otherwise, the RTShader lib is working fabulously.
-
- Gnoblar
- Posts: 4
- Joined: Fri Nov 12, 2010 10:55 am
Re: RT Shader System Component (RTSS)
Thanks for the reply!
For the black shadow:
The ambient suggestion was right, the materials in my application had black ambient color. So I updated all the material files with proper ambient. Now the shadows with one light(directional light) works fine.
For the shadow diffuse computation:
Thanks for the information on shadows using multiple lights.
One doubt still remains: if I use one directional light casting shadow and one point light which does not cast shadow, is there any way for me to get only the directional light diffuse involved in the shadow computation?
Indeed my flickering effect comes from the fact that the point light is also shadowed. Theoretically,if I add the diffuse of the point light on top of the shadowed diffuse of the directional light, I will not get any flicker...
For the black shadow:
The ambient suggestion was right, the materials in my application had black ambient color. So I updated all the material files with proper ambient. Now the shadows with one light(directional light) works fine.
For the shadow diffuse computation:
Thanks for the information on shadows using multiple lights.
One doubt still remains: if I use one directional light casting shadow and one point light which does not cast shadow, is there any way for me to get only the directional light diffuse involved in the shadow computation?
Indeed my flickering effect comes from the fact that the point light is also shadowed. Theoretically,if I add the diffuse of the point light on top of the shadowed diffuse of the directional light, I will not get any flicker...
- Wolfmanfx
- OGRE Team Member
- Posts: 1525
- Joined: Fri Feb 03, 2006 10:37 pm
- Location: Austria - Leoben
- x 99
- Contact:
Re: RT Shader System Component (RTSS)
I have a question regarding tex_coord_set (http://www.ogre3d.org/docs/manual/manual_17.html#SEC86) does the rtss respect tex_coord_set (used in a material) when normal mapping is used? i mean when i have a mesh with two sets? (my artist is doing it now and i am curious if this is working)
Also what is with the compacting feature?
Also what is with the compacting feature?
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Re: RT Shader System Component (RTSS)
tex_coord_set works.
Watch out for my OGRE related tweets here.
-
- Goblin
- Posts: 231
- Joined: Sun Nov 01, 2009 4:23 pm
- x 2
Re: RT Shader System Component (RTSS)
This might sound like a dumb question but where can I get RTSS from?
All I can find is this article and this page http://www.ogre3d.org/tikiwiki/RT+Shade ... light=rtss
Also, can I use RTSS to generate shadows with static geometry? How would I do this?
Cheers
EDIT I included the OgreRTShaderSystem.h file and tried to compile this part of code (taken from the above link) as a first step:
Just getting these compile errors and a lot more related:
Error 1 error C2065: 'mShaderGenerator' : undeclared identifier c:\pSource\dev_qt_platform\code\VE2Modelviewer\VEXMLViewerWidget.cpp 310
Error 2 error C2065: 'shaderLibPath' : undeclared identifier c:\pSource\dev_qt_platform\code\VE2Modelviewer\VEXMLViewerWidget.cpp 313
shaderLibPath must be a path, so I'm not too worried about that. It's the first one that gets me.
Any help appreciated
All I can find is this article and this page http://www.ogre3d.org/tikiwiki/RT+Shade ... light=rtss
Also, can I use RTSS to generate shadows with static geometry? How would I do this?
Cheers
EDIT I included the OgreRTShaderSystem.h file and tried to compile this part of code (taken from the above link) as a first step:
Code: Select all
if (Ogre::RTShader::ShaderGenerator::initialize())
{
// Grab the shader generator pointer.
mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
// Add the shader libs resource location.
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(shaderLibPath, "FileSystem");
// Set shader cache path.
mShaderGenerator->setShaderCachePath(shaderCachePath);
// Set the scene manager.
mShaderGenerator->addSceneManager(sceneMgr);
return true;
}
Error 1 error C2065: 'mShaderGenerator' : undeclared identifier c:\pSource\dev_qt_platform\code\VE2Modelviewer\VEXMLViewerWidget.cpp 310
Error 2 error C2065: 'shaderLibPath' : undeclared identifier c:\pSource\dev_qt_platform\code\VE2Modelviewer\VEXMLViewerWidget.cpp 313
shaderLibPath must be a path, so I'm not too worried about that. It's the first one that gets me.
Any help appreciated
Last edited by JonnyJP on Mon May 23, 2011 2:55 pm, edited 1 time in total.
- boyamer
- Orc
- Posts: 459
- Joined: Sat Jan 24, 2009 11:16 am
- Location: Italy
- x 6
Re: RT Shader System Component (RTSS)
Hi,
I would like to know how would be possible to add alpha testing and clip plane's into RTSS ?
As both of them are FFP states.
Thanks,
Amer
I would like to know how would be possible to add alpha testing and clip plane's into RTSS ?
As both of them are FFP states.
Thanks,
Amer
-
- Goblin
- Posts: 231
- Joined: Sun Nov 01, 2009 4:23 pm
- x 2
Re: RT Shader System Component (RTSS)
I'll answer my own question.
RTSS is included in the Ogre SDK under Components.
I'm trying to use RTSS to generate shadows. The code I have at the moment, at the end of my CreateScene is:
The resource location is set at the beginning:
It compiles and crashes with this from the Ogre.log
13:53:49: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource FFPLib_Transform.glsl in resource group General or any other group. in ResourceGroupManager::openResource at .\src\OgreResourceGroupManager.cpp (line 753)
Obviously there's something missing and I can't find any tutorials at all apart from the link in my original post. Any other pointers towards getting shadows would be great.
I appreciate any help with this.
Cheers
RTSS is included in the Ogre SDK under Components.
I'm trying to use RTSS to generate shadows. The code I have at the moment, at the end of my CreateScene is:
Code: Select all
if (Ogre::RTShader::ShaderGenerator::initialize())
{
// Set shader cache path.
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->setShaderCachePath("c:\\shaders");
// Set the scene manager.
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->addSceneManager(mSceneManager);
// Create shader based technique from the default technique of the given material.
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->createShaderBasedTechnique(MATERIAL_SURFACE, Ogre::MaterialManager::DEFAULT_SCHEME_NAME, Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
// Apply the shader generated based techniques.
theViewport->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
}
Code: Select all
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("c:\\shaders", "FileSystem");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
13:53:49: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource FFPLib_Transform.glsl in resource group General or any other group. in ResourceGroupManager::openResource at .\src\OgreResourceGroupManager.cpp (line 753)
Obviously there's something missing and I can't find any tutorials at all apart from the link in my original post. Any other pointers towards getting shadows would be great.
I appreciate any help with this.
Cheers
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Re: RT Shader System Component (RTSS)
Seems that FFPLib_Transform.glsl can't be found.
Did you add the resource location: "Samples\Media\RTShaderLib" (the file is there...)
Did you add the resource location: "Samples\Media\RTShaderLib" (the file is there...)
Watch out for my OGRE related tweets here.
-
- Goblin
- Posts: 231
- Joined: Sun Nov 01, 2009 4:23 pm
- x 2
Re: RT Shader System Component (RTSS)
No I didn't, thanks a lot.
That doesn't crash now but nothing happens. What do I need to do to get shadows up and running (plus any other shader effects)?
That doesn't crash now but nothing happens. What do I need to do to get shadows up and running (plus any other shader effects)?
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Re: RT Shader System Component (RTSS)
Start by looking at the RTSS sample.
Watch out for my OGRE related tweets here.
-
- Goblin
- Posts: 231
- Joined: Sun Nov 01, 2009 4:23 pm
- x 2
Re: RT Shader System Component (RTSS)
Thanks, I found that so am going through it asap.
-
- Goblin
- Posts: 231
- Joined: Sun Nov 01, 2009 4:23 pm
- x 2
Re: RT Shader System Component (RTSS)
I've had to switch to a Windows 7 laptop now and am getting a crash.
Basically, our Ogre window is created as a .dll which is loaded dynamically in our code. If I take out all of the code related to the RTShaderSystem then it compiles and runs fine. If I just put the following line in, the code crashes when the .dll is being loaded.
It looks like some other .dll is missing but I've copied across all the relevent ones from Ogre as before. I can't work out what is missing?
Any ideas?
Basically, our Ogre window is created as a .dll which is loaded dynamically in our code. If I take out all of the code related to the RTShaderSystem then it compiles and runs fine. If I just put the following line in, the code crashes when the .dll is being loaded.
Code: Select all
if (!Ogre::RTShader::ShaderGenerator::initialize())
{
return;
}
Any ideas?
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
-
- Goblin
- Posts: 231
- Joined: Sun Nov 01, 2009 4:23 pm
- x 2
Re: RT Shader System Component (RTSS)
Looking at the Process Monitor it looks like OgreRTShaderSystem_d.dll is missing, so I guess I need to build it somehow?
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Re: RT Shader System Component (RTSS)
What are you running? Aren't you building from source?
Watch out for my OGRE related tweets here.
-
- Goblin
- Posts: 231
- Joined: Sun Nov 01, 2009 4:23 pm
- x 2
Re: RT Shader System Component (RTSS)
We built Ogre from source but it looks like RTShaderSystem wasn't built as I can't find the .dll anywhere.
-
- Goblin
- Posts: 231
- Joined: Sun Nov 01, 2009 4:23 pm
- x 2
Re: RT Shader System Component (RTSS)
I've rebuilt Ogre and my crash was due to the .dll being missing.
Now I'm getting another one! I've tried to copy the code from the RTShaderSystem samples, so I have a function which (tries to) sets up all the RTShaderSystem stuff so I can get shadows.
This is the code:
Looking at the Ogre.log, it looks like there are errors. I don't know if they are relevant but here they are:
Now I'm getting another one! I've tried to copy the code from the RTShaderSystem samples, so I have a function which (tries to) sets up all the RTShaderSystem stuff so I can get shadows.
This is the code:
Code: Select all
if (!Ogre::RTShader::ShaderGenerator::initialize())
{
return;
}
// Set shader cache path.
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->setShaderCachePath("c:\\shaders");
// Set the scene manager ***CRASH AT THIS LINE***
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->addSceneManager(mSceneManager);
// Create shader based technique from the default technique of the given material.
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->createShaderBasedTechnique(MATERIAL_SURFACE, Ogre::MaterialManager::DEFAULT_SCHEME_NAME, Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
// Apply the shader generated based techniques.
m_viewport->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
mSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED);
// 3 textures per directional light
mSceneManager->setShadowTextureCountPerLightType(Ogre::Light::LT_DIRECTIONAL, 3);
mSceneManager->setShadowTextureSettings(512, 3, Ogre::PF_FLOAT32_R);
mSceneManager->setShadowTextureSelfShadow(true);
// Set up caster material - this is just a standard depth/shadow map caster
mSceneManager->setShadowTextureCasterMaterial("PSSM/shadow_caster");
// Disable fog on the caster pass.
Ogre::MaterialPtr passCaterMaterial = Ogre::MaterialManager::getSingleton().getByName("PSSM/shadow_caster");
Ogre::Pass* pssmCasterPass = passCaterMaterial->getTechnique(0)->getPass(0);
pssmCasterPass->setFog(true);
// shadow camera setup
Ogre::PSSMShadowCameraSetup* pssmSetup = new Ogre::PSSMShadowCameraSetup();
pssmSetup->calculateSplitPoints(3, 5, 3000);
pssmSetup->setSplitPadding(10);
pssmSetup->setOptimalAdjustFactor(0, 2);
pssmSetup->setOptimalAdjustFactor(1, 1);
pssmSetup->setOptimalAdjustFactor(2, 0.5);
mSceneManager->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(pssmSetup));
Ogre::RTShader::SubRenderState* subRenderState = Ogre::RTShader::ShaderGenerator::getSingletonPtr()->createSubRenderState(Ogre::RTShader::IntegratedPSSM3::Type);
Ogre::RTShader::IntegratedPSSM3* pssm3SubRenderState = static_cast<Ogre::RTShader::IntegratedPSSM3*>(subRenderState);
const Ogre::PSSMShadowCameraSetup::SplitPointList& srcSplitPoints = pssmSetup->getSplitPoints();
Ogre::RTShader::IntegratedPSSM3::SplitPointList dstSplitPoints;
for (unsigned int i=0; i < srcSplitPoints.size(); ++i)
{
dstSplitPoints.push_back(srcSplitPoints[i]);
}
pssm3SubRenderState->setSplitPoints(dstSplitPoints);
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->getRenderState(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME)->addTemplateSubRenderState(subRenderState);
// Invalidate the scheme in order to re-generate all shaders based technique related to this scheme.
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->invalidateScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
Code: Select all
14:26:27: Compiler error: unknown error in materials/RTShaderSystem.material(23): token "rtshader_system" is not recognized
14:26:27: Compiler error: unknown error in materials/RTShaderSystem.material(52): token "rtshader_system" is not recognized
14:26:27: Compiler error: unknown error in materials/RTShaderSystem.material(81): token "rtshader_system" is not recognized
14:26:27: Compiler error: unknown error in materials/RTShaderSystem.material(110): token "rtshader_system" is not recognized
14:26:27: Compiler error: unknown error in materials/RTShaderSystem.material(146): token "rtshader_system" is not recognized
14:26:27: Compiler error: unknown error in materials/RTShaderSystem.material(81): token "rtshader_system" is not recognized
14:26:27: Compiler error: unknown error in materials/RTShaderSystem.material(162): token "rtshader_system" is not recognized
14:26:27: Compiler error: unknown error in materials/RTShaderSystem.material(81): token "rtshader_system" is not recognized
14:26:27: Compiler error: unknown error in materials/RTShaderSystem.material(110): token "rtshader_system" is not recognized
-
- Goblin
- Posts: 231
- Joined: Sun Nov 01, 2009 4:23 pm
- x 2
Re: RT Shader System Component (RTSS)
Right, forget that. It wasn't a problem with RTShaderSystem but with how I'd declared mSceneManager.
Now I'm getting a crash here:
mSceneManager->setShadowTextureCasterMaterial("PSSM/shadow_caster");
Ogre.log says this material doesn't exist. But I've added the resource location "\\Samples\\Media\\RTShaderLib" to the resource group manager (and initialised them).
Is this correct? Or should I add something else?
Now I'm getting a crash here:
mSceneManager->setShadowTextureCasterMaterial("PSSM/shadow_caster");
Ogre.log says this material doesn't exist. But I've added the resource location "\\Samples\\Media\\RTShaderLib" to the resource group manager (and initialised them).
Is this correct? Or should I add something else?
-
- Goblin
- Posts: 231
- Joined: Sun Nov 01, 2009 4:23 pm
- x 2
Re: RT Shader System Component (RTSS)
Found this online and I have something very very flakey but since there are shadows it's a step in the right direction.
I have a ground plane in my scene. If I set the first parameter of createShaderBasedTechnique to be the same material as the ground plane, I get what looks like ok shadows.
However, the surfaces aren't self shadowing or shadowing other surfaces.
I'm also confused that when I'm setting the materials to meshes, none of them are set to "PSSM/shadow_caster" but they still cast shadows?
Getting there, but slowly...
Code: Select all
// declare the vertex shader (CG for the language)
vertex_program PSSM/shadow_caster_vs cg
{
// source file
source pssm.cg
// will run on vertex shader 1.1+
profiles vs_1_1 arbvp1
// entry function
entry_point shadow_caster_vs
default_params
{
param_named_auto wvpMat worldviewproj_matrix
// this is the scene's depth range
//param_named_auto depthRange scene_depth_range
//param_named_auto optimalAdustFactor custom 0
}
}
// declare the fragment shader (CG for the language)
fragment_program PSSM/shadow_caster_ps cg
{
// source file
source pssm.cg
// will run on pixel shader 2.0+
profiles ps_2_0 arbfp1
// entry function
entry_point shadow_caster_ps
default_params
{
}
}
material PSSM/shadow_caster
{
technique
{
// all this will do is write depth and depth² to red and green
pass
{
vertex_program_ref PSSM/shadow_caster_vs
{
}
fragment_program_ref PSSM/shadow_caster_ps
{
}
}
}
}
vertex_program PSSM/shadow_receiver_vs cg
{
source pssm.cg
profiles vs_1_1 arbvp1
entry_point shadow_receiver_vs
default_params
{
param_named_auto lightPosition light_position_object_space 0
param_named_auto eyePosition camera_position_object_space
param_named_auto worldViewProjMatrix worldviewproj_matrix
param_named_auto texWorldViewProjMatrix0 texture_worldviewproj_matrix 0
param_named_auto texWorldViewProjMatrix1 texture_worldviewproj_matrix 1
param_named_auto texWorldViewProjMatrix2 texture_worldviewproj_matrix 2
//param_named_auto depthRange0 shadow_scene_depth_range 0
//param_named_auto depthRange1 shadow_scene_depth_range 1
//param_named_auto depthRange2 shadow_scene_depth_range 2
}
}
fragment_program PSSM/shadow_receiver_ps cg
{
source pssm.cg
profiles ps_2_x arbfp1
entry_point shadow_receiver_ps
default_params
{
param_named_auto lightDiffuse derived_light_diffuse_colour 0
param_named_auto lightSpecular derived_light_specular_colour 0
param_named_auto ambient derived_ambient_light_colour
param_named_auto invShadowMapSize0 inverse_texture_size 0
param_named_auto invShadowMapSize1 inverse_texture_size 1
param_named_auto invShadowMapSize2 inverse_texture_size 2
//param_named pssmSplitPoints MANUAL
}
}
abstract material PSSM/base_receiver
{
technique
{
pass
{
ambient 1 1 1 1
diffuse 1 1 1 1
vertex_program_ref PSSM/shadow_receiver_vs {}
fragment_program_ref PSSM/shadow_receiver_ps {}
texture_unit shadow_tex0
{
content_type shadow
tex_address_mode clamp
}
texture_unit shadow_tex1
{
content_type shadow
tex_address_mode clamp
}
texture_unit shadow_tex2
{
content_type shadow
tex_address_mode clamp
}
texture_unit diffuse_tex
{
texture $diffuse
}
}
}
}
material PSSM/Plane : PSSM/base_receiver
{
set $diffuse BumpyMetal.jpg
}
material PSSM/Knot : PSSM/base_receiver
{
set $diffuse MtlPlat2.jpg
}
However, the surfaces aren't self shadowing or shadowing other surfaces.
I'm also confused that when I'm setting the materials to meshes, none of them are set to "PSSM/shadow_caster" but they still cast shadows?
Getting there, but slowly...