Shaders

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
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Shaders

Post 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:
"Held in Your arms but too far from my heart." "These thoughts will carry me through the darkest nights...while your eyes rest in mine."
"How quickly I forget that this is meaningless."
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post 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.
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post by xtheagonyscenex »

can i have a little change snippet pls.
"Held in Your arms but too far from my heart." "These thoughts will carry me through the darkest nights...while your eyes rest in mine."
"How quickly I forget that this is meaningless."
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post 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.
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post by xtheagonyscenex »

yes i have done them all when i change the shader constants do i have to change the hlsl file?
"Held in Your arms but too far from my heart." "These thoughts will carry me through the darkest nights...while your eyes rest in mine."
"How quickly I forget that this is meaningless."
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post 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?
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post 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
"Held in Your arms but too far from my heart." "These thoughts will carry me through the darkest nights...while your eyes rest in mine."
"How quickly I forget that this is meaningless."
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post 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".
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

What exactly did you try? What exactly are the "couple of errors"?
And, master question, did you work through Tutorial 10?
TheC
Posts: 93
Joined: Fri May 05, 2006 7:50 am

Post 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.
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post by xtheagonyscenex »

yes but when i put light position = ISceneNode* light; it says its undefined and i get the same thing in the ieventrecievers
"Held in Your arms but too far from my heart." "These thoughts will carry me through the darkest nights...while your eyes rest in mine."
"How quickly I forget that this is meaningless."
Post Reply