Page 1 of 1

PerPixelLighting tutorial

Posted: Sat Jan 27, 2007 3:54 pm
by Prott
Hello.
I have one simple and "noobish" question.
What code exactly turns on per-pixel lighting on the room in PerPixelLighting tutorial?

Posted: Sat Jan 27, 2007 5:54 pm
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.

Posted: Sat Jan 27, 2007 6:09 pm
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.

Posted: Sat Jan 27, 2007 6:16 pm
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.

Posted: Sat Jan 27, 2007 7:02 pm
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?

Posted: Sat Jan 27, 2007 7:06 pm
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:

Posted: Sat Jan 27, 2007 7:14 pm
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.

Posted: Sat Jan 27, 2007 7:46 pm
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.

Posted: Sat Jan 27, 2007 7:48 pm
by xtheagonyscenex

Posted: Sat Jan 27, 2007 8:28 pm
by Prott
Ok ... sorry :) , I am beginner to shaders and it seems that my teories were wrong.