Shadow receiver material

Problems building or running the engine, queries about how to use features etc.
Post Reply
dragostej
Gnoblar
Posts: 19
Joined: Wed Mar 31, 2021 8:36 am
x 1

Shadow receiver material

Post by dragostej »

Ogre Version: 1.11.6
Operating System: Win10
Render System: DirectX11

Hello guys,

Recently I have ported my app from DX9 to DX11, and I have started replace FFP with own shaders in the materials. The next thing what i want to implement is the shadows. I have some surfaces with own shaders what i want to receive shadows using different Ogre techniques like (contour and texture based, modulative and additive as well). If I'm right to make shadows work I have to classify passes in these material in order to Ogre can make illumination passes. I have followed the tutorial about material pass classification and i got that material:

Code: Select all

material desert
{
    technique
    {
        pass ambient
        {
		diffuse 0 0 0 
        }
        pass perlight
        {
	    ambient 0 0 0 
            iteration once_per_light
            scene_blend add
			
		vertex_program_ref Ogre/BasicVertexPrograms/AmbientOneTexture
            	{
           	}

		fragment_program_ref Ogre/BasicFragmentPrograms/PassthroughFpHLSL
		{
		}

		// Vertex program reference
		shadow_receiver_vertex_program_ref Ogre/DepthShadowmap/ReceiverVP_HLSL
		{
		}

		// Fragment program
		shadow_receiver_fragment_program_ref Ogre/DepthShadowmap/ReceiverFP_HLSL
		{
		}
			
        }
        pass decal
        {
            lighting off
            scene_blend dest_colour zero
			
		vertex_program_ref ownVS
          	 {
           	 }
           	fragment_program_ref ownPS
          	 {
          	 }
           	 texture_unit
         	 {
           		 texture "Terrain/terrain-1.bmp"
			filtering linear linear linear
			scale 20 20
            	}
    	}
    }
}
Actually additive, and modulative shadows are working great, but i want to some adjustment in my shaders.
Before that I had the possibility to change some properties of these surface materials during runtime with these Ogre functions: Ogre::pass->setAmbient( ), Ogre::pass->setDiffuse( ); Ogre::pass->setSelfIllumination(), and I could also set the material to transparent.

My question is, in what pass i have to call these functions? or I have to implement these features in the shader? but how?

Guys, could you give me some instructions because I have no idea what is the right way?
Thanks!
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Shadow receiver material

Post by sercero »

Hello,

You have to implement those features yourself in the shaders.

Now, the question is why not use the RTSS so the transition from DX9 to DX11 is more smooth?

The RTSS generates the shaders you need automatically.

Here is the documentation: https://ogrecave.github.io/ogre/api/1.1 ... ation.html
dragostej
Gnoblar
Posts: 19
Joined: Wed Mar 31, 2021 8:36 am
x 1

Re: Shadow receiver material

Post by dragostej »

Thanks for your reply.

Yes, I know the RTSS system, but in case of these surface materials it is easier to use own shaders, because these materials can be edited during the runtime in my app, and in lot of places in the code these are manipulated. With RTSS I got lots of crashes for example when I copied a materials in runtime etc.
Thats why I think I can go with own shaders in these materials.

Could you suggest me tutorials about shaders which I needed?

I just wondering that I can use only one pass with 2 shaders (basic shader, and shadow receiver shader) and Ogre does the pass classification if I turn on the shadows, can it work somehow? Handling only one pass in these materials it can be easier for me? What do you think?
User avatar
sercero
Bronze Sponsor
Bronze Sponsor
Posts: 449
Joined: Sun Jan 18, 2015 4:20 pm
Location: Buenos Aires, Argentina
x 156

Re: Shadow receiver material

Post by sercero »

Sorry, my knowledge about shaders is limited...

The little I know comes from this site: https://learnopengl.com/, so it does not apply to your situation.

And in fact, I haven't even used any shadows other than stencil for now, texture shadows with shaders is a pending subject.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: Shadow receiver material

Post by paroj »

dragostej wrote: Fri Jul 02, 2021 3:13 pm If I'm right to make shadows work I have to classify passes in these material in order to Ogre can make illumination passes. I have followed the tutorial about material pass classification and i got that material:
you only need to classify the passes for additive shadowing. Note though, that additive shadowing is a relic from the FFP days, where one had to use multiple passes. Nowadays, using multiple passes is wasteful and you should try to do everything in a single pass in your shader.

See this for how to get the shadow texture:
https://ogrecave.github.io/ogre/api/lat ... re-Shadows

There is still an advantage of having a separate shadow pass in that it allows you to split all shadowing code and keep your general shaders simpler. If this is relevant to you, you can use custom shadow caster/ receiver materials:
https://ogrecave.github.io/ogre/api/lat ... totoc_md36

Still, you should start with modulative (single shadowing pass) shadows here.
dragostej
Gnoblar
Posts: 19
Joined: Wed Mar 31, 2021 8:36 am
x 1

Re: Shadow receiver material

Post by dragostej »

Thank you paroj!

With the integrated texture shadows and a little bit modified shaders it can work nicely.
I dont know why i didn't notice before.
Post Reply