Shaders
-
- Posts: 131
- Joined: Fri Jun 03, 2005 7:26 pm
Shaders
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
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
"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."
"How quickly I forget that this is meaningless."
-
- Posts: 131
- Joined: Fri Jun 03, 2005 7:26 pm
From vitek maybe, but not from me.
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.
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.
-
- Posts: 131
- Joined: Fri Jun 03, 2005 7:26 pm
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?
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?
-
- Posts: 131
- Joined: Fri Jun 03, 2005 7:26 pm
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."
"How quickly I forget that this is meaningless."
You need to tell the shader where the light is, since it would never know. In OnSetConstants do:
Then in your shader at the top:
Then just call it in the vertex shader wherever you need it.
Code: Select all
services->setVertexShaderConstant("LightPosition", reinterpret_cast<irr::f32*>(&lpos), 3);
Code: Select all
float3 LightPosition;
-
- Posts: 131
- Joined: Fri Jun 03, 2005 7:26 pm
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."
"How quickly I forget that this is meaningless."