[not requested anymore] Pass to Rtt

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 50

[not requested anymore] Pass to Rtt

Post by madmarx »

Hello,

Let's say we have a material with 1 technique and 2 passes.

I want the result from the first pass to be send to the 2nd pass as a texture. I don't need the first pass to be drawn in the backbuffer.

So the first 'pass' is not a real pass, but let's call it a "passToTexture", and the second one is a real traditionnal ogre pass.


Ogre material's passes are like painting directly on top of what was previously drawn, directly in backbuffer.
The passToTexture I describe uses some vertex shaders to create fullscreenquad (unfolding uvw), and the result is blit into a dynamic texture, that feeds another pass, or another passToTexture.

Maybe this feature already exists. But I just read the shoggoth(CVS HEAD) manual and did not found anything on this subject.

This is not exactly Compositor, because in compositor there is no access to the mesh, and I need in the second pass to apply vertex shader+ fragment shader. What is more, Compositor is used to do post-processing, and affects directly the final image. (If I am wrong please tell me).

I use these feature in render monkey to do advanced shaders and it works great. I also read some papers about GI in shaders, and it uses the same system, (but in that case the texture is not temporary, but is reused at each full rendering).

Now I would like to use my shaders with ogre ;-).

So the feature would be something like :

Code: Select all

material myMat
{
    technique
         {
              pass  myFirstFakePassAlias
              { 
                   ambient 0.7 0.7 0.7
                   diffuse 0.5 0.8 0.5
                    specular 1.0 1.0 1.0 1.5

                   vertex_program_ref GLSL/TransluscentUnfoldedVp
                   {
                    }

                    fragment_program_ref GLSL/TransluscentUnfoldedFp
                    { 
                    } 

                     texture_unit
                     {
                        texture flesh.tga
                        tex_coord_set 0
                      }
                }toTexture myDynamicTexture1  not_transient

                pass  mySecondFakePassAlias
                { 
                   ambient 0.7 0.7 0.7
                   diffuse 0.5 0.8 0.5
                    specular 1.0 1.0 1.0 1.5

                   vertex_program_ref GLSL/IrradianceUnfoldedVp
                   {
                    }

                    fragment_program_ref GLSL/IrradianceUnfoldedFp
                    { 
                    } 

                     texture_unit
                     {
                        texture myDynamicTexture1
                        tex_coord_set 0
                      }

                }toTexture myDynamicTexture2 not_transient

               pass  theOnlyRealOgrePass
                { 
                   ambient 0.7 0.7 0.7
                   diffuse 0.5 0.8 0.5
                    specular 1.0 1.0 1.0 1.5

                     texture_unit
                     {
                        texture myDynamicTexture1
                        tex_coord_set 0
                      }
                     texture_unit
                     {
                        texture myDynamicTexture2
                        tex_coord_set 0
                      }
                 }
           }
}

the " }toTexture myDynamicTexture1 not_transient"
is where I say "this is not a normal pass, but a passToTexture".
I also wrote 'not_transient' to say that the texture is not reused anywhere else, rendersystem does what it wants with the texture when this material is finished rendering.



What do you think?

-------------------------------------------------------------------------------

EDIT after a few hours of fun (well I am paid to do this...) :

I just manage to do the same effect, using the following dirty trick :

I put a copy of the objects using the material in a separate SceneManager.
I also use a copy of the current camera/lights in the separate SceneManager.

For each passToTexture
I create a material, with the vertex/fragment shaders I want.
I also use 1 dynamic texture per passToTexture.

Then in the frameStarted, I have a
'for each object'
keep this only object visible

'for all passToTexture of my special effect used by the object'
{
setMaterialName(),followed by
RenderTarget::update()
}
}

I think I will use in my prog special names for my passes alias (pass __totexture_myTextureOut) to recreate

the behaviour I described before (with automatic discard of passes & rtt creation etc...).
-------------

So it is not impossible to do right now :-).
But the way I do it right now is not very clean (with the copy / hide & so on). And I think it is something everyone using shader within Ogre would be happy to use to make cool showcase. ;-)

That is why I still request the feature.

-------------------------------------------------------------------------------

EDIT N°2 after 2 days of fun

I got it working very well, Object oriented, without a specific scenemanager, and without copying the objects. I have even learned about the RenderableListener.

I use only names of passes to now which rtt to create and which name to give to them.

Anyway, I think now maybe the feature was to much specific. (for example why not selecting a group of pass to do a rtt, or a complete material result to do it?).

What is more, I do not consider it quite mature, because of the trick with the names, and another one for the custom parameters that are different for each passtotexture.

I will suggest something else for useful prototyping/advanced developement/use of material (pragma in material/ pass/ texture_unit).


(sorry for my evil english).
Post Reply