RT Shader System Component (RTSS)

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
al2950
OGRE Expert User
OGRE Expert User
Posts: 1193
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 74

Re: RT Shader System Component

Post by al2950 » Fri Oct 23, 2009 8:40 am

Regarding the target profiles - the default is to use all profiles from higher to lower.
Thats a bit wierd because my card supports up 224 'constant registers' PS 3.0 (as per the Ogre log) but the error states that it has exceeded the 32 constant register limit. (Actually that might be something to do with the old CG version i am using?)
What other ways do you suggest to handle this situation ?
To be honest i am not really sure!! Part of me says it should handle it gracefully and fallback to FFP, but then part of me says if that happens some people may just think you system does not work, in which case its better to throw an obvious exception!

***EDIT****
I am using CG version 1502, which i think is the Sep release of version 1.5. That version should support PS 3.0.
0 x

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RT Shader System Component

Post by Nir Hasson » Fri Oct 23, 2009 10:23 am

Thats a bit wierd because my card supports up 224 'constant registers' PS 3.0 (as per the Ogre log) but the error states that it has exceeded the 32 constant register limit. (Actually that might be something to do with the old CG version i am using?)
You caught me there – the reason was that I actually discarded the PS3.0 profile from the default fragment target profile. The reason for doing that was that it caused sopme differences in FPP lighting. Anyway I just restored it to include the PS3.0 back and the deferred sample works with that.
To be honest i am not really sure!! Part of me says it should handle it gracefully and fallback to FFP, but then part of me says if that happens some people may just think you system does not work, in which case its better to throw an obvious exception!
I’ll think about other options to handle this issue – but for current stage I agree that more informative exception should be used.
0 x

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel

Re: RT Shader System Component

Post by Assaf Raman » Fri Oct 23, 2009 3:38 pm

al2950 wrote: ...
I am using CG version 1502, which i think is the Sep release of version 1.5. That version should support PS 3.0.
Can you give the latest version of CG a try?
0 x
Watch out for my OGRE related tweets here.

al2950
OGRE Expert User
OGRE Expert User
Posts: 1193
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 74

Re: RT Shader System Component

Post by al2950 » Fri Oct 23, 2009 3:44 pm

I have done :D. There was no difference......

Nir's latest fix with the RT Shader to allow PS 3.0 solved the problem i was seeing.
0 x

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RT Shader System Component

Post by Nir Hasson » Fri Oct 23, 2009 4:25 pm

Hey – Just thought about the integration with the deferred shading sample and I got to conclusion that using the RT Shader System there is unnecessary. All lighting calculations that performed by it in this sample are actually discarded since they are done in the deferred way using the G-Buffer etc.. So actually the generated shaders has no effect beside extra overhead,,,
The other reason to disable it in this demo is the number of light states that keep changing and cause shader re-generation for each combination which in turn cause FPS drop. Check out the huge number of generated in this sample.
So bottom line is that I want to disable it in the deferred shading demo – If somebody thinks that I should keep it let me know :)
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: RT Shader System Component

Post by Wolfmanfx » Fri Oct 23, 2009 4:51 pm

@Nir
I am online late at night today. I already had an output today but i have problems with some uniform var also i have to stabilize the glsl output.
One major problem now is that the shader writer has to create a full functional shader unit (source code) :) So whats the problem?

The problem is that glsl do not have #include statement like cg (and i already ported all FFP cg shaders to glsl to make use of them) so i have two approaches to solve that
1. Include all shaders source i depend on it into the current shader source (this is what i am doing now to get something working)
2. Use Modular shaders ( so that we compile the library shaders and attach them --> http://www.ogre3d.org/docs/manual/manual_21.html)
i think it must be possible to generate the shader code and the gpu programs per language but i will try to make it working with option 1 and then it is not more than software design to overcome the issue.

also note that the shader generation is different to cg shader generation (because we have to use the built in parameters...for example the vertex shader has to write gl_Position) so i dont think we can reuse one class to generate shaders for the two or more languages (Abstract Factory is needed here).
0 x

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel

Re: RT Shader System Component

Post by Assaf Raman » Fri Oct 23, 2009 5:12 pm

The function glShaderSource takes a pointer to several strings, so you can submit all of your files for compilation. The second paramter is the count.
So - there is an option to add support for #include in GL render system (and also in GL ES 2.x) by finding all the #include in the source, loading the file and adding its content to the list of sources that glShaderSource uses, then delete the #include line from the source, we had some code that know to parse #include in the CG plug-in once. I guess that an stl "set" container should be used so you won't load the same file twice.
I think that this solution is the way the ppl that designed GL wanted it to be - they didn't want GL to open files on its on.
This type of support for #include in the GL RS can be nice also for other uses then the RT shader system.
0 x
Watch out for my OGRE related tweets here.

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RT Shader System Component

Post by Nir Hasson » Fri Oct 23, 2009 5:20 pm

I agree with Assaf regarding the #include issue, but as you said is the minor problem we have.
Regarding var names - I think I will modify the approach of using the Parameter class.
Instead of using directly thier names in the function invocations you'll have to pass the parameter pointer and some mask that says which part of the parameter to use (X|Y|Z|W).
Then the writer itself will have the option to replace it with its own internal name.
This approach will also enable compacting output vars - I.E instead of using 2 output texcoord slots for 2 floats it will automatically pack into one slot of 4 floats...
Anyway - I'll be busy in the rest of the weekend - I'll try to be availble ASAP but I guess only in sunday or monday...
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: RT Shader System Component

Post by Wolfmanfx » Fri Oct 23, 2009 5:29 pm

Correct me if iam wrong but ogre already support modular shaders in GLSLProgram

Code: Select all

		const GLhandleARB getGLHandle() const { return mGLHandle; }
		void attachToProgramObject( const GLhandleARB programObject );
		void detachFromProgramObject( const GLhandleARB programObject );
		String getAttachedShaderNames() const { return mAttachedShaderNames; }
only #include is missing but thats not standard glsl but it would make life easier.
[edit]
sunday is ok for me :)
0 x

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel

Re: RT Shader System Component

Post by Assaf Raman » Fri Oct 23, 2009 7:11 pm

Wolfmanfx wrote:Correct me if iam wrong but ogre already support modular shaders in GLSLProgram

Code: Select all

		const GLhandleARB getGLHandle() const { return mGLHandle; }
		void attachToProgramObject( const GLhandleARB programObject );
		void detachFromProgramObject( const GLhandleARB programObject );
		String getAttachedShaderNames() const { return mAttachedShaderNames; }
only #include is missing but thats not standard glsl but it would make life easier.
[edit]
sunday is ok for me :)
You mean using "GLSLProgram::attachChildShader", the reason I suggested using glShaderSource is that I think that this way will be much more transparent to the users and will not create a GL handle for each include file.

I may be wrong, current me if that is the case.
0 x
Watch out for my OGRE related tweets here.

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RT Shader System Component

Post by Nir Hasson » Sun Oct 25, 2009 2:08 am

Just added the custom masked reflection map effect to the Shader System sample.
It shows how to extend the system with your own custom shaders.
Attachments
screenshot_4687.jpg
Masked Reflection Map extension
screenshot_4687.jpg (122.67 KiB) Viewed 3086 times
screenshot_4339.jpg
Masked Reflection Map extension
screenshot_4339.jpg (124.49 KiB) Viewed 3086 times
0 x

User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy

Re: RT Shader System Component

Post by boyamer » Sun Oct 25, 2009 10:43 am

Wow looks nice!! :) Parallax mapping would be nice to be added to the Shader System...
0 x

User avatar
Wolfmanfx
OGRE Team Member
OGRE Team Member
Posts: 1525
Joined: Fri Feb 03, 2006 10:37 pm
Location: Austria - Leoben
x 1
Contact:

Re: RT Shader System Component

Post by Wolfmanfx » Sun Oct 25, 2009 3:56 pm

You are too fast with new features :)
here a screen from the wip of the GLSL (#version 120) writer for teh RTShader system ( here a vertex shader http://nopaste.info/7dd928e531.html)
Attachments
GLSLShaderWriter.jpg
GLSLShaderWriter.jpg (108.49 KiB) Viewed 3054 times
0 x

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RT Shader System Component

Post by Nir Hasson » Sun Oct 25, 2009 4:06 pm

Great job - wolfman !!! :D
0 x

User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany

Re: RT Shader System Component

Post by xadhoom » Sun Oct 25, 2009 11:48 pm

Hi Nir!

The env map of the skybox is very distorted if RTS is activated in the sample (although the reflection is fine).

Why is the specular light colour on the sphere always vertex accurate only?

I got a crash when I quitted the sample browser one time in OgreUserObjectBindings: ~Attributes(). I only executed the RTS sample. Unfortunately I couldn´t reproduce the crash :-(

xad

EDIT: rev 9219

EDIT: Ok, I got the crash again. Here is the stack trace:

Code: Select all

>	OgreMain_d.dll!Ogre::Any::~Any()  Line 78 + 0x1b bytes	C++
 	OgreMain_d.dll!std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>::~pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>()  + 0x40 bytes	C++
 	OgreMain_d.dll!std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::_Node::~_Node()  + 0x19 bytes	C++
 	OgreMain_d.dll!std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::_Node::`scalar deleting destructor'()  + 0x16 bytes	C++
 	OgreMain_d.dll!Ogre::STLAllocator<std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::_Node,Ogre::CategorisedAllocPolicy<0> >::destroy(std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::_Node * p=0x01882970)  Line 153	C++
 	OgreMain_d.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::_Erase(std::_Tree_nod<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::_Node * _Rootnode=0x01882970)  Line 1078	C++
 	OgreMain_d.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::clear()  Line 955	C++
 	OgreMain_d.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::erase(std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::iterator _First=("SGX_ReflectionMapTextureName",{mContent=0x01a6c3f8 }), std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::iterator _Last=(",þÿÿ‹VjhÄ{ iRè|~&",{mContent=0x00000000 }))  Line 921	C++
 	OgreMain_d.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::_Tidy()  Line 1327 + 0x48 bytes	C++
 	OgreMain_d.dll!std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >::~_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> >,0> >()  Line 527	C++
 	OgreMain_d.dll!std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> > >::~map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> > >()  + 0x16 bytes	C++
 	OgreMain_d.dll!std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,Ogre::Any,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,Ogre::STLAllocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,Ogre::Any>,Ogre::CategorisedAllocPolicy<0> > >::`scalar deleting destructor'()  + 0x16 bytes	C++
 	OgreMain_d.dll!Ogre::UserObjectBindings::Attributes::~Attributes()  Line 120 + 0x1f bytes	C++
 	OgreMain_d.dll!Ogre::UserObjectBindings::Attributes::`scalar deleting destructor'()  + 0x16 bytes	C++
 	OgreMain_d.dll!Ogre::UserObjectBindings::clear()  Line 124 + 0x1f bytes	C++
 	OgreMain_d.dll!Ogre::UserObjectBindings::~UserObjectBindings()  Line 45	C++
 	OgreMain_d.dll!Ogre::Pass::~Pass()  Line 232 + 0x12 bytes	C++
 	OgreMain_d.dll!Ogre::Pass::`vector deleting destructor'()  + 0x57 bytes	C++
 	OgreMain_d.dll!Ogre::Pass::processPendingPassUpdates()  Line 1583 + 0x3b bytes	C++
 	OgreMain_d.dll!Ogre::Root::~Root()  Line 335	C++
 	SampleBrowser.exe!Ogre::Root::`scalar deleting destructor'()  + 0x1a bytes	C++
 	SampleBrowser.exe!OgreBites::SampleContext::go(OgreBites::Sample * initialSample=0x00000000)  Line 211 + 0x28 bytes	C++
 	SampleBrowser.exe!WinMain(HINSTANCE__ * __formal=0x00400000, HINSTANCE__ * __formal=0x00400000, HINSTANCE__ * __formal=0x00400000, HINSTANCE__ * __formal=0x00400000)  Line 53	C++
 	SampleBrowser.exe!__tmainCRTStartup()  Line 589 + 0x35 bytes	C
 	SampleBrowser.exe!WinMainCRTStartup()  Line 414	C
 	kernel32.dll!7c817077() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	user32.dll!7e37b7d0() 	
Hope it helps...
0 x

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RT Shader System Component

Post by Nir Hasson » Mon Oct 26, 2009 12:40 am

Parallax mapping would be nice to be added to the Shader System...
boyamer - The sample show how to write an extension to the RTSS, however since it is a common effect I guess I'll add it to the core extensions.

Hi - xad :)
The env map of the skybox is very distorted if RTS is activated in the sample (although the reflection is fine).
I guess its just the quality of that texture - when its on top of the Sky box its looks bad regardless of the RTSS.
I toggled the system and saw no difference... I simply used it cause it is the most intersting cube texture I found there.
I got a crash when I quitted the sample browser one time in OgreUserObjectBindings: ~Attributes(). I only executed the RTS sample. Unfortunately I couldn´t reproduce the crash
Saw it too and I thought I already solve it - the issue is that some memory allocated within the sample in the DLL context and it should be freed there, otherwise when the exe unloads and it tries to free this memory it crashes. This memory is allocated by some components of the shader system and I saw during debuging that it got freed..
However it was randomly occuring for me too - so maybe a threading issues ? what's the thread mode you work in ?
I'll dig in that in the next days...
0 x

User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany

Re: RT Shader System Component

Post by xadhoom » Mon Oct 26, 2009 12:51 am

Hi Nir!

Ah, ok!

Regarding the skybox: The skybox texture coordinates are definitely srewed up when using the Shader System. It looks a bit like a 90 degree rotation...
Usually my graphic driver don´t make problems and the ffp version looks ok...

Do you plan to integrate per pixel specularity?

xad

BTW: There is a typo in your code: mSpeuclarEnable
0 x

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RT Shader System Component

Post by Nir Hasson » Mon Oct 26, 2009 8:49 am

Regarding the skybox: The skybox texture coordinates are definitely srewed up when using the Shader System. It looks a bit like a 90 degree rotation...
Usually my graphic driver don´t make problems and the ffp version looks ok...
That's weird - I don't see anything wrong on my machines (NVIDIA 8800 and 8600) - what RS and graphic card do you use ?
Try to delete the cached shaders - I'm doing lots of changes lately so if you got some oldies there they might not work with the latest code... Sorry for the inconvenience.

Regarding the specular - it is depends on the lighting model you choose - the default is per vertex but when you switch to other lighting models it will change as well....
BTW: There is a typo in your code: mSpeuclarEnable
I guess my egnlish mixed up sometimes :wink: - will fix that - thanks
0 x

User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany

Re: RT Shader System Component

Post by xadhoom » Mon Oct 26, 2009 10:40 am

Nir Hasson wrote:Regarding the specular - it is depends on the lighting model you choose - the default is per vertex but when you switch to other lighting models it will change as well....
Thats obviously not the case. I´m not sure if its visible on the picture but the specular colour is only shaded per vertex although I use per pixel lighting.
You can see the screwed up skybox in the background. It only happens when activating RTSS. My cars is QuadroFX 1500M (see window).
I use the latest revision and deleted the cache beforehand.

VS:

Code: Select all

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
//                         PROGRAM DEPENDENCIES
//-----------------------------------------------------------------------------
#include "FFPLib_Transform.cg"
#include "FFPLib_Common.cg"
#include "FFPLib_Lighting.cg"
#include "FFPLib_Texturing.cg"

//-----------------------------------------------------------------------------
//                         GLOBAL PARAMETES
//-----------------------------------------------------------------------------

float4x4	worldviewproj_matrix;
float4x4	inverse_transpose_worldview_matrix;
float4	derived_ambient_light_colour;
float4	surface_diffuse_colour;
float4	surface_specular_colour;
float4	surface_emissive_colour;
float4	derived_scene_colour;
float	surface_shininess;
float4x4	worldview_matrix;
float4	light_position_view_space0;
float4	light_attenuation1;
float4	derived_light_diffuse2;
float4	derived_light_specular3;
float4	light_position_view_space4;
float4	derived_light_diffuse5;
float4	derived_light_specular6;
float4x4	world_matrix;
float4x4	inverse_transpose_world_matrix;
float4x4	view_matrix;

//-----------------------------------------------------------------------------
// Function Name: main
// Function Desc: Program Entry point
//-----------------------------------------------------------------------------
void main
	(
	 in float4	iPos_0 : POSITION, 
	 in float3	iNormal_0 : NORMAL0, 
	 in float2	iTexcoord2_0 : TEXCOORD0, 
	 out float4	oPos_0 : POSITION, 
	 out float4	oColor_0 : COLOR0, 
	 out float4	oColor_1 : COLOR1, 
	 out float2	oTexcoord2_0 : TEXCOORD0, 
	 out float3	oTexcoord3_1 : TEXCOORD1
	)
{
	float4	lLocalParam_0;
	float4	lLocalParam_1;

	FFP_Transform(worldviewproj_matrix, iPos_0, oPos_0);

	FFP_Construct(1.0, 1.0, 1.0, 1.0, lLocalParam_0);

	FFP_Assign(lLocalParam_0, oColor_0);

	FFP_Construct(0.0, 0.0, 0.0, 0.0, lLocalParam_1);

	FFP_Assign(lLocalParam_1, oColor_1);

	FFP_Assign(derived_scene_colour, oColor_0);

	FFP_Light_Point_DiffuseSpecular(worldview_matrix, iPos_0, inverse_transpose_worldview_matrix, iNormal_0, light_position_view_space0.xyz, light_attenuation1, derived_light_diffuse2.xyz, derived_light_specular3.xyz, surface_shininess, oColor_0.xyz, oColor_1.xyz, oColor_0.xyz, oColor_1.xyz);

	FFP_Light_Directional_DiffuseSpecular(worldview_matrix, iPos_0, inverse_transpose_worldview_matrix, iNormal_0, light_position_view_space4.xyz, derived_light_diffuse5.xyz, derived_light_specular6.xyz, surface_shininess, oColor_0.xyz, oColor_1.xyz, oColor_0.xyz, oColor_1.xyz);

	FFP_Assign(iTexcoord2_0, oTexcoord2_0);

	FFP_Assign(iTexcoord2_0, oTexcoord2_0);

	FFP_GenerateTexCoord_EnvMap_Reflect(world_matrix, inverse_transpose_world_matrix, view_matrix, iNormal_0, iPos_0, oTexcoord3_1);
}
PS:

Code: Select all

//-----------------------------------------------------------------------------
//                         PROGRAM DEPENDENCIES
//-----------------------------------------------------------------------------
#include "FFPLib_Common.cg"
#include "FFPLib_Texturing.cg"
#include "SampleLib_ReflectionMap.cg"

//-----------------------------------------------------------------------------
//                         GLOBAL PARAMETES
//-----------------------------------------------------------------------------

sampler2D	gTextureSampler0 : register(s0);
sampler2D	mask_sampler1 : register(s1);
samplerCUBE	reflection_texture2 : register(s2);

//-----------------------------------------------------------------------------
// Function Name: main
// Function Desc: Program Entry point
//-----------------------------------------------------------------------------
void main
	(
	 in float4	iColor_0 : COLOR0, 
	 in float4	iColor_1 : COLOR1, 
	 in float2	iTexcoord2_0 : TEXCOORD0, 
	 in float3	iTexcoord3_1 : TEXCOORD1, 
	 out float4	oColor_0 : COLOR0
	)
{
	float4	texel;
	float4	source1;
	float4	source2;

	FFP_Assign(iColor_0, oColor_0);

	FFP_SampleTexture(gTextureSampler0, iTexcoord2_0, texel);

	FFP_Assign(texel, source1);

	FFP_Assign(iColor_0, source2);

	FFP_Modulate(source1, source2, oColor_0);

	SGX_ApplyReflectionMap(mask_sampler1, iTexcoord2_0, reflection_texture2, iTexcoord3_1, oColor_0.xyz, oColor_0.xyz);

	FFP_Add(oColor_0.xyz, iColor_1.xyz, oColor_0.xyz);
}
Attachments
RTSS.jpg
RTSS.jpg (58.74 KiB) Viewed 2964 times
0 x

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RT Shader System Component

Post by Nir Hasson » Mon Oct 26, 2009 11:05 am

The skybox thing - I'll try to reproduce here, are you working on GL RS ?

Regarding the specular - the lighting model of the target object is controlled via its own custom RenderState so you have to change it using the menu on the bottom. From the generated code you attach you can see that it uses the FFP lighting functions...
When i'll finish all the stuff I want to make for the version i'll write detailed docs so everything will be clear.
0 x

User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany

Re: RT Shader System Component

Post by xadhoom » Mon Oct 26, 2009 11:22 am

I use DirectX.
Regarding the specular - the lighting model of the target object is controlled via its own custom RenderState so you have to change it using the menu on the bottom. From the generated code you attach you can see that it uses the FFP lighting functions...
When i'll finish all the stuff I want to make for the version i'll write detailed docs so everything will be clear.
Ah sorry! I was blind ;-)
0 x

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RT Shader System Component

Post by Nir Hasson » Mon Oct 26, 2009 12:43 pm

Xad - can you do me a favor and check the Sky box issue?
The generated shaders the skybox in the sample uses are 3677509718_*.
Try to tweak them and see what works. As long as they are on disk the RTSS will use them.
I believe this issue is somehow related to the cubic texture sampling - maybe wrong coordinates generation in the FFP_GenerateTexCoord_EnvMap_Reflect function.
0 x

User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany

Re: RT Shader System Component

Post by xadhoom » Mon Oct 26, 2009 11:41 pm

Hm, I get the exact skybox result like with the FFP when using this method:

Code: Select all

//-----------------------------------------------------------------------------
void FFP_GenerateTexCoord_EnvMap_Reflect(in float4x4 mWorld, 
							in float4x4 mWorldIT, 
						   in float4x4 mView,						  
						   in float3 vNormal,
						   in float4 vPos,						  
						   out float3 vOut)
{		
	vOut = float3(vPos.x, vPos.y, -vPos.z) - float3(mView[0][2], mView[1][2], mView[2][2]);
}
Ofcourse this method does not calculate the reflection on the sphere properly. Why do you use FFP_GenerateTexCoord_EnvMap_Reflect for both calculations?

xad
0 x

User avatar
Nir Hasson
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 363
Joined: Wed Nov 05, 2008 4:40 pm
Location: TLV - Israel
Contact:

Re: RT Shader System Component

Post by Nir Hasson » Mon Oct 26, 2009 11:56 pm

Why do you use FFP_GenerateTexCoord_EnvMap_Reflect for both calculations?
For the skybox I use it cause thats the way the materil defines it - reflection env map, thats go to the FFP.
For the custom reflection on the sphere - well... I guess a generated reflection texcoord was the most natural choice to do the Cube map sampling....
Anyway - i'll try to get it on ATI machine and check it out.
0 x

User avatar
xadhoom
Minaton
Posts: 973
Joined: Fri Dec 28, 2007 4:35 pm
Location: Germany

Re: RT Shader System Component

Post by xadhoom » Tue Oct 27, 2009 8:20 am

Nir Hasson wrote:Anyway - i'll try to get it on ATI machine and check it out.
But at least in my case its an NVidia card (Nvidia Quadro FX 1500M).

xad
0 x

Post Reply