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: 1131
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 51

Re: RT Shader System Component (RTSS)

Post by al2950 » Thu Jan 28, 2010 7:57 pm

I have just intergrated RTSS into my system and i am very happy. Thank you!!

HOWEVER.. I ran into a couple of minor problems

FIRSTLY
Some of the RTSS headers the following defines around them, which means they wont be included in your project unless you pre define them;

Code: Select all

#ifdef RTSHADER_SYSTEM_BUILD_CORE_SHADERS
and

Code: Select all

#ifdef RTSHADER_SYSTEM_BUILD_EXT_SHADERS
I understand why this was done but it seems unnecessary to have to include these pre defines in a client app, is there any way this could be changed? It might help noobies like me get the system up and running quicker!

SECONDLY
When i run the RTSS in standard mode (ie no per pixel or anything) with Hydrax it runs very very slowly (< 30). However when i enabled per pixel lighting to runs much faster (>60)!! Can anyone explain this!???
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 (RTSS)

Post by Nir Hasson » Fri Jan 29, 2010 1:00 pm

Regarding the defines -
I guess I can change the logic of it so it will work with User apps easely - I may add the defines to the buildsettings.h file and it will save all the messing around with pre-processor settings.
Regarding Hydrax - I didn't use the combination yet so I can only suggest you to use NVPerfHUD or check the log file to seek the differences between the cases...
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19261
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
Contact:

Re: RT Shader System Component (RTSS)

Post by sinbad » Fri Jan 29, 2010 6:31 pm

Nir Hasson wrote:Regarding the defines -
I guess I can change the logic of it so it will work with User apps easely - I may add the defines to the buildsettings.h file and it will save all the messing around with pre-processor settings.
Yes, please make sure any settings which need to be persistent to client builds are added to OgreBuildSettings.h.in in the CMake/Templates area.
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 (RTSS)

Post by Nir Hasson » Fri Jan 29, 2010 6:50 pm

Ok - Did it now in the 1.7 branch
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 (RTSS)

Post by Wolfmanfx » Sun Jan 31, 2010 11:13 am

Trunk build is broken the RTSS do not include OgreConfig.h anywhere.
0 x

User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
Contact:

Re: RT Shader System Component (RTSS)

Post by Noman » Sun Jan 31, 2010 5:42 pm

This is because of the change from a preprocessor flag to an OgreBuildSettings.h flag. If a file does not include OgreBuildSettings.h before checking for capabilities (for example : OgreShaderFFPLighting.h) it won't get build even if the flag is enabled. There are two ways to solve this. I think the best one would be to move these #ifdef guard somewhere lower (like after including the prerequisites header) but I'm not sure that its the intended way...
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 (RTSS)

Post by Nir Hasson » Sun Jan 31, 2010 6:21 pm

Hi - When tested it I didn't rebuilt the system so I didn't saw these errors.
Anyway - just commited a fix to 1.7 branch - It will be merged to trunk in the next hours/days...
0 x

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

Re: RT Shader System Component (RTSS)

Post by al2950 » Mon Feb 01, 2010 1:32 pm

@Wolfmanfx

A little while back you mentioned that you were working on several sub renderstates including spec maps and parrallax maps, I was just wondering if you got round to doing this or not!!??

@Nir Hasson
I have done some digging regarding hydrax and per vertex lighting, but i have not found anything concrete, just odd! When the system is loaded with RTSS on using Vertex Lighting it runs very slowly, GPU Idle time is basicly 0%, frame time increases dramaticly but is very erratic but averages out to a consistent 30 fps. The Shaders both pixel and vertex increase quite alot, but the most noticable thing is that the ROP's rise very dramaticly. Moreover i enabled the ablilty to be able to switch between the RTSS material scheme and the deafult scheme at runtime. If you load the system up with default scheme it runs fine. If you load it with the RTSS scheme it runs terrible, and if you switch back to the default scheme at runtime it still runs terrible! HOWEVER if i start up the system with the defualt material scheme and then after startup flip to the RTSS materail scheme it works fine! I shall do some more digging but it must be something do with Hydrax defining its materials at runtime.
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 (RTSS)

Post by Wolfmanfx » Mon Feb 01, 2010 1:45 pm

Yep i did this a long time ago :) i wanted to integrate it in new RTSS (I have done it for an older version) but do not got time for it....
also i have to say i am not satisfied at all with the soultion because the normalmapsubrenderstate gets to a kind of a uebershader with #ifdefs but atm i am working on 2 projects a small game and an editor where i want to use rtss with toothroot to design effects but its alot of work...but as always its a matter of time...
Attachments
59715804.jpg
59715804.jpg (110.39 KiB) Viewed 2441 times
0 x

User avatar
Mattan Furst
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 260
Joined: Tue Jan 01, 2008 11:28 am
Location: Israel

Re: RT Shader System Component (RTSS)

Post by Mattan Furst » Tue Feb 02, 2010 2:19 pm

I submitted a small patch in regards to the RTShader Lighting render. The patch fixes the rendering of lighting when rendering in "camera relative rendering" mode. Patch number is 2944607.
0 x
it's turtles all the way down

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 (RTSS)

Post by Nir Hasson » Tue Feb 02, 2010 8:24 pm

@al2950

I hope you'll find it before I'll get to integrate Hydrax into my project :)
I think its a good point you mentioned - the Hydrax material creation at runtime.
Do you create shader based technique for all the materials in the scene ? if so it might be that. Try to limit the scope to only one material - you can do it via script materials extensions.

@Mattan

Thanks for that - I commited it to 1.7...
0 x

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

Re: RT Shader System Component (RTSS)

Post by al2950 » Thu Feb 04, 2010 6:41 pm

Do you create shader based technique for all the materials in the scene
Yes i do. I turned that off and it works fine. However i still cant quite understand why this makes such a difference with Hydrax. Oh well! For now i have my ways around it so i am not going try and get to the bottom of it. I am planning on making a few changes to hydrax when i have time so i will look at in more detail then, one of these changes will be so you can set what material schemes the hydrax reflection & refraction viewports use. At the moment with RTSS enabled the difference between above and below water is very noticable as the the various hydrax RTT's use the default material scheme! I will ofcourse post any changes i make to hydrax in the hydrax forum. I also plan to integrate it into the Ogre work queue system, one thing at a time though!!!!


**EDIT** Disabling the listener that converts any defualt material schemes into RTSS shader schemes should not make any difference. Shouldnt the createShaderBasedTechnique() method fail as the hydrax materials are not FFP?
0 x

User avatar
XenoPhoenix
Gnoblar
Posts: 14
Joined: Mon Feb 08, 2010 1:40 am

Re: RT Shader System Component (RTSS)

Post by XenoPhoenix » Wed Feb 10, 2010 7:30 pm

Hi there,

Just integrated RTSS into my project and I'm having a very wierd issue, currently my application works fine after the initalisation of the system, with one caveat.. it gets slower and slower the closer i look the the origin and it then crashes with the following message:

Code: Select all

18:41:14: OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program 3489964277_FS: CG ERROR : "The compile returned an error."
(0) : error C6007: Constant register limit exceeded; more than 32 constant registers needed to compiled program
 in CgProgram::loadFromSource at /shared/ogre-1.7/PlugIns/CgProgramManager/src/OgreCgProgramManagerDll.cpp (line 67)
18:41:14: High-level program 3489964277_FS encountered an error during loading and is thus not supported.
OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program 3489964277_FS: CG ERROR : "The compile returned an error."
(0) : error C6007: Constant register limit exceeded; more than 32 constant registers needed to compiled program
 in CgProgram::loadFromSource at /shared/ogre-1.7/PlugIns/CgProgramManager/src/OgreCgProgramManagerDll.cpp (line 67)
18:41:14: OGRE EXCEPTION(2:InvalidParametersException): Could not create gpu programs from render state  in ProgramManager::acquireGpuPrograms at /shared/ogre-1.7/Components/RTShaderSystem/src/OgreShaderProgramManager.cpp (line 102)
Currently running on the latest revision (9720) in the 1.7 branch. Any suggestions as to how to solve this?

I saw ealier in the thread that there was an issue with this and you recommend chaning the shader model? I attempted to change this with:

Code: Select all

shaderGenerator_->setFragmentShaderProfiles("ps_3_0");
But no joy!, I've looked through the samples several times and I can't see where I'm going wrong, any help would be appreciated.
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 (RTSS)

Post by Nir Hasson » Wed Feb 10, 2010 7:52 pm

The answer lay in these lines

Code: Select all

OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program 3489964277_FS: CG ERROR : "The compile returned an error."
(0) : error C6007: Constant register limit exceeded; more than 32 constant registers needed to compiled program
The RTSS generates a shader that can't compile due to over use of constant registers.
Try to trace the source material that generates this shader - 3489964277_FS - as the log write.
I can only guess that your scene is has many lights and this material compose of some complex sub render state (Normal map, PSSM etc.)
The best way to handle it is to set the shader cache path to some valid path on your machine. After the crash you can examine the generated shader - it will be in that folder
under the specified name, and from there you can understand the root of the problem.

Hope it helped...
0 x

User avatar
XenoPhoenix
Gnoblar
Posts: 14
Joined: Mon Feb 08, 2010 1:40 am

Re: RT Shader System Component (RTSS)

Post by XenoPhoenix » Thu Feb 11, 2010 12:42 pm

Yes I was attempting normal maps as per the samples, I removed some of the lights and it now works, however ultimate I would like more than 2 lights in my scene!

I'll try and have a look through the generated shaders but shader languages are not my forte hence why I was looking at using the RTSS :)
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 (RTSS)

Post by Nir Hasson » Thu Feb 11, 2010 12:44 pm

Ok - you can have multiple lights simply by changing your materials to multipass lighting techinque.
Take a look at the normal map sample - there are two additional RTSS based materials - one for single pass and the second is doing multi-pass.
0 x

User avatar
XenoPhoenix
Gnoblar
Posts: 14
Joined: Mon Feb 08, 2010 1:40 am

Re: RT Shader System Component (RTSS)

Post by XenoPhoenix » Fri Feb 12, 2010 12:33 pm

Ah thanks for that Nir Hasson, I have normal mapping working now with 9 lights, Forgive my nievity in this matter, but I ultimate what more lights than that in a given room of my game. Now obviously I would doubt that at anytime I would have more than abouyt 5 lights acting on a give pixel at one time for per pixel lighting. How to I writing this into the shader material so that I can potentially support as many lights as I want?

It's nice to have solid answers back from the person developing something, makes a pleasant change to a lot of projects :)
0 x

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

Re: RT Shader System Component (RTSS)

Post by al2950 » Fri Feb 12, 2010 6:15 pm

I beleive that you can have as many lights as you want and Ogre will pick the 5 closest lights to your object. (if your shaders is set up to pass lightPosition 0 - 4)

However if you are planning on using many lights you might want to look at Deffered shading instead.
0 x

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

Re: RT Shader System Component (RTSS)

Post by xadhoom » Fri Feb 12, 2010 7:35 pm

But keep in mind that the decision of lights is based on the mesh position. If you have a rather large static mesh of some rooms you might end up just seeing these lights lighting the walls which are nearest to the meshs position. If exactly these lights are all located in one room the other rooms are unlit (if you have some shadows enabled and/or the light range is too small).

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 (RTSS)

Post by Nir Hasson » Sat Feb 13, 2010 7:14 pm

You can have as many lights as you want by simply using addative multi-pass approach.

Check out these -
http://www.ogre3d.org/docs/manual/manual_74.html#SEC340
http://www.ogre3d.org/docs/manual/manual_16.html#SEC71

But keep in mind that your "paying" with extra geometry submission per light.
This technique is out of scope here - but a short explanation is that a addative multi-pass material splits the rendering into 3 phases.
The first is to draw ambient light - it executes once.
The second pass is executed many times - 1 for each light (or less for n lights).
The third is doing the diffuse colour blend over the prevous lighting results.

As I said before - the RTSS support this kind of per light iteration materials - check the source material script of the bump sample.
0 x

Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
Contact:

Re: RT Shader System Component (RTSS)

Post by Vectrex » Sun Feb 14, 2010 3:40 am

Will rtss ever support automatic generation of single pass multi light shaders? It'd be nice if it could add as many lights as the shader profile would allow. Obviously this would probably make making shader segments quite different
0 x

User avatar
XenoPhoenix
Gnoblar
Posts: 14
Joined: Mon Feb 08, 2010 1:40 am

Re: RT Shader System Component (RTSS)

Post by XenoPhoenix » Sun Feb 14, 2010 3:07 pm

Thanks very much for your help, I've got multi-pass from the example working fine now, I will look at the addative approach on monday as my geometry is not too bad.

al2950, I was looking at deferred shading, however the performance hit from it in the demos was staggeringly high. - also, I recognise A Bristol uni username if ever I saw one ;)
0 x

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

Re: RT Shader System Component (RTSS)

Post by al2950 » Sun Feb 14, 2010 3:52 pm

al2950, I was looking at deferred shading, however the performance hit from it in the demos was staggeringly high. - also, I recognise A Bristol uni username if ever I saw one ;)
ah crap, sussed!! Used Ogre at uni so the username kind of stuck!
0 x

User avatar
XenoPhoenix
Gnoblar
Posts: 14
Joined: Mon Feb 08, 2010 1:40 am

Re: RT Shader System Component (RTSS)

Post by XenoPhoenix » Mon Feb 15, 2010 4:30 pm

Forgive me if I am being a complete idiot with this, I have looked through the example that you have linked me too and I am currently using basically your normal mapped example ftrom RTShaders.material(i presume this is the one you are refering to?) . This appears to be the same as the one you linked me to (indeed it appears to be based off it). Mine is below:

Code: Select all

material Locker/phong2SG
{
	technique
	{
		pass ambient
		{

			ambient 1 1 1
			diffuse 1 1 1
			specular 0 0 0 0
			
			rtshader_system
 			{	
				light_count 0 0 0
			}
		}
		
		pass lighting
		{
			specular 0.2 0.2 0.2 32
			ambient 0 0 0
			scene_blend add
			iteration once_per_light point
			
 			rtshader_system
 			{	 	
 				lighting_stage normal_map NormalTest.png tangent_space 1
 			}
		}	
		
		pass decal
		{
			
			lighting off
			scene_blend dest_colour zero
			texture_unit decalmap
			{
				texture LockerDiffuse.png
			}			
		}
	}
}
However this is still crashing if I add more that 8 Lights?

The examples showed how you could pass parameters into the shaders, however these seemed to be for pre-created shader scripts of which the source was obvious, if this is the method I should be using then what is the format for passing in the parameter to base on light position? On the point of using a large mesh fro a room like I am doing, is there a way of doing the nearest lights based on pixel rather than the mesh as a whole?... probably straying in deferred shading again here...

I appologise if I am doing something really stupid or have missed something obvious...
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 (RTSS)

Post by Nir Hasson » Mon Feb 15, 2010 7:55 pm

The source material looks fine -
It should execute the first pass with diffuse lighting only, the second pass per point light, and the last only once with the diffuse texture.
Note that the second pass will execute only for point lights..
Anyway - if you have nvidia card you can use PerfHUD and see exactlly how the frame executes...
You can still dump the shaders to files and track the shader that cause the crash.
0 x

Post Reply