Page 1 of 1

Shaders

Posted: Mon Nov 20, 2006 8:45 pm
by xtheagonyscenex
hi i have a modified shader from the code snippets (the specular bump, modified to just bump) the scene is the same as the code here
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=15915
but why is it the dynamic lights in the engine dont affect the shader and how do you make a shader that does? tutorials or someting woukld be nice.
thx :roll:

Posted: Mon Nov 20, 2006 9:21 pm
by Saturn
You have to set light position correctly. The sample code sets light position == camera position. Also ambient, diffuse, and spec are set to some constants here, instead to the actual params of your light.

Simply set these params to the values of your light that you want to use.

Posted: Mon Nov 20, 2006 9:56 pm
by xtheagonyscenex
can i have a little change snippet pls.

Posted: Mon Nov 20, 2006 10:02 pm
by Saturn
From vitek maybe, but not from me. :P
Seriously, what part of what I wrote do you have problems with? I believe it is easy to understand, provided, that you understand the concept of shader callbacks at all. If not, see the tutorials on the tutorial page. Namely tutorial 10.
Else just ask a specific question about what is unclear to you. But actually *think* about it.

Posted: Mon Nov 20, 2006 10:03 pm
by xtheagonyscenex
yes i have done them all when i change the shader constants do i have to change the hlsl file?

Posted: Mon Nov 20, 2006 10:13 pm
by Saturn
Hmm. Now that you're asking..
From looking at the shader, it seems to expect the light in view space, since it uses the inverse view matrix to bring it from eye into world space, but funnily the matrix is named inv_view_matrix, but it actually is the inverse world matrix. so it actually is correct, by accident(?) so that light is transformed into object space.

Either way: No, actually this should be the only thing you need to change. How did you change the part?

Posted: Tue Nov 21, 2006 8:47 pm
by xtheagonyscenex
change what? but how do tell it to use the lightnode data, i tried several ways and all i got was a couple errors... thx

Posted: Tue Nov 21, 2006 10:09 pm
by Saturn
xtheagonyscenex wrote:i tried several ways and all i got was a couple errors... thx
Please don't give me too much and detailed information. My brain is on overload. "Stuff happened" is more than enough to fuel my magic eightball. Btw, it says: "Maybe".

Posted: Tue Nov 21, 2006 10:10 pm
by Saturn
What exactly did you try? What exactly are the "couple of errors"?
And, master question, did you work through Tutorial 10?

Posted: Wed Nov 22, 2006 5:14 am
by TheC
You need to tell the shader where the light is, since it would never know. In OnSetConstants do:

Code: Select all


services->setVertexShaderConstant("LightPosition", reinterpret_cast<irr::f32*>(&lpos), 3);

Then in your shader at the top:

Code: Select all

float3 LightPosition;
Then just call it in the vertex shader wherever you need it.

Posted: Fri Dec 08, 2006 8:43 pm
by xtheagonyscenex
yes but when i put light position = ISceneNode* light; it says its undefined and i get the same thing in the ieventrecievers