PerPixelLighting tutorial

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
Prott
Posts: 104
Joined: Sun Jan 14, 2007 12:01 pm

PerPixelLighting tutorial

Post by Prott »

Hello.
I have one simple and "noobish" question.
What code exactly turns on per-pixel lighting on the room in PerPixelLighting tutorial?
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post by xtheagonyscenex »

when you swap the regular mesh and use the create tangent mesh and and select EMT_NORMAL_MAP_SOLID, it uses a per pixel bump shader built into the engine, whoch is only good if you dont move the object.
"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."
Prott
Posts: 104
Joined: Sun Jan 14, 2007 12:01 pm

Post by Prott »

But "normal" (EMT_SOLID) lighting has also per-pixel lighting effect (in this tutorial). And when I (in my app.) create mesh with the same (EMT_NORMAL_MAP_SOLID or EMT_PARALLAX_MAP_SOLID) mapping, I don`t have it shaded by per-pixel lighting - it`s strange.
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post by xtheagonyscenex »

no its gourad shading based on vertex normals and it shades the texture on a per triangle basis
do you have a light in the scene?
lets see some code.
"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."
Prott
Posts: 104
Joined: Sun Jan 14, 2007 12:01 pm

Post by Prott »

Well ... I made very BIG mistake. I think that I have only 2 verticles on the side of the box, but I had 40 :) (I forgot about it, because I made this model 2 months ago), so I made "fake per-pixel lighting" myself.

So, maybe I am absolutely wrong, but doesn`t per-pixel lighting mean similar effect to this? (when I increase vertex count, the vertex-based lighting looks more "detailed") If yes then why is now (when I created "right" model - only 2 verticles on every side- and then I run perpixeltutorial with this model) perpixel tutorial still shaded with vertex-lighting (no matter if I choose EMT_NORMAL_MAP_SOLID or EMT_SOLID).
Here is the picture:
Image
1 - This is perpixeltutorial with 2 verticles on every side of the box (and with per-pixel lighting)
2 - This is perpixeltutorial with 900 verticles on every side of the box

I think that per-pixel lighting have to simulate "detailed" lighting using shaders to count color for each pixel, which depends on it`s distance from the light source - If this is true, then why it looks same as vertex-based lighting?
Last edited by Prott on Sat Jan 27, 2007 7:09 pm, edited 1 time in total.
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post by xtheagonyscenex »

if there both set on parralax mapping they both are going to look the same, but the more verts you have the more realistic lighting will be acheived. :wink:
"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."
Prott
Posts: 104
Joined: Sun Jan 14, 2007 12:01 pm

Post by Prott »

xtheagonyscenex wrote:if there both set on parralax mapping they both are going to look the same, but the more verts you have the more realistic lighting will be acheived. :wink:
But isn`t "realistic lighting" a work for per-pixel lighting (shaders) to do ?
When each pixel is shaded on pixel-bases, the quality of the lighting doesn`t depends on vertex count.
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post by xtheagonyscenex »

yes it does cuz the light hit a vertex and with a "bump" shader it transforms the texture coords and vertex normal direction to appear to be bump out eg if you have a wall with 4 verts and a light on each side bothe sides would be equally bumped but the center wouldnt any vertnormals so it would have to bring the outside normals slightly in to make the center bumped yet if you have more verts the more normals you have to displace to acheive more realistic "shaders" but lower poly is better but you stil need enough normals to get look. if you have a specular shader on a cube the whole side facing the light would be shiny yet if was subdivided it make only sections of the cube "face" reflect based on the light direction.
"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."
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post by xtheagonyscenex »

"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."
Prott
Posts: 104
Joined: Sun Jan 14, 2007 12:01 pm

Post by Prott »

Ok ... sorry :) , I am beginner to shaders and it seems that my teories were wrong.
Post Reply