userData in ShaderCallBack

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
kaliber
Posts: 117
Joined: Sat Jan 17, 2009 12:51 pm

userData in ShaderCallBack

Post by kaliber »

is there any example to use userData in :

Code: Select all

virtual void OnSetConstants(video::IMaterialRendererServices* services,s32 userData) { }
:D :) :o :? :wink:
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: userData in ShaderCallBack

Post by Mel »

userData can be used in many ways. This value is set from the shader compiling method. Its best utility is to diferenciate the behavior of the shader on set callbacks, for instance, to use the same callback with many diferent shaders.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
kaliber
Posts: 117
Joined: Sat Jan 17, 2009 12:51 pm

Re: userData in ShaderCallBack

Post by kaliber »

so its for distinguish shader used in the callbacks, not the material
thanks
Abraxas)
Posts: 227
Joined: Sun Oct 18, 2009 7:24 am

Re: userData in ShaderCallBack

Post by Abraxas) »

Mel I also found it really useful to control the branching in a shader. It's great for lighting when you need certain things to react and certain things to ignore certain lights, without writing a new shader.

If we had better control over materialparams, for example a parameter which is a pointer where we can control the pointer type, there would be a ton more flexibility with shader design.

(also, technique support, but that may be a XNA only thing)
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: userData in ShaderCallBack

Post by Mel »

when i need pointers, i put them as attributes in the shader callbacks, and set them as soon as posible, being the optimal moment on the callback creation time. I use the userData for instance to enable or disable the shadowmapping variable setting for shaders that behave the same, but one has shadowmapping and the other doesn't.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Post Reply