per-pixel lighting without normal maps?

Started by
4 comments, last by FoxHunter2 19 years, 7 months ago
Hi currently I'm reading through several tutorials about per-pixel lighting written in shaders. But it seems as if almost all tutorials make use of normal maps. Well, I have a BSP loader class which loads and renders Quake3 BPS maps. Since a map consists of dozens of textures, isn't it tedious to create normal-maps for every single texture? There must be another way :I heard of interpolating the pixel normals from the vertex normals, but as being a total newbie with shaders I don't how this actually works, if at all. Do I really need normal maps or are there easier ways (no problem if they're not 100 percent precise). I read through this tutorial and it seems to do exactly what I'm looking for. But I'm programming with DirectX and have absolutely no clue about OpenGL-code. I'd be grateful for any suggestions or hints into the correct direction :) thanks in advance
Advertisement
That tutorial doesn't shows per-pixel lighting, but per pixel attenuation. Per pixel attenuation do not require normalmaps because there is no DOT3 against every pixel normal. We can say that this tutorial shows a flat lighting.

So, if you want per-pixel lighting and attenuation you will need normalmaps.
Quote:Original post by LukeSkyRunner
So, if you want per-pixel lighting and attenuation you will need normalmaps.

Simply: no. PPL does not imply normalmaps or anything like that. It just states that you calculate lighting equation per pixel. Where you get normal from is just a part of it. If you use normal mapping, then yes, you get normal form normalmap, but you can also just use interpolated normalized vertex normal.
You should never let your fears become the boundaries of your dreams.
I'm interested in using interpolated and normalized vertex normals on per-pixel basis.

Could someone elaborate on this topic or give me a link? :)
Quote:Original post by FoxHunter2
I'm interested in using interpolated and normalized vertex normals on per-pixel basis.

Could someone elaborate on this topic or give me a link? :)

Using interpolated vertex normals to evaluate the lighting equation per-pixel is known as phong shading, so a search for that might help. For a sample pshader implementation, try Wolfgang's Introduction to Shader Programming Part IV: Programming Pixel Shaders.
It's DX8 though, IIRC.

Anyway, it's nothing complicated. You just pass your normal as a texcoord to the pixel shader, so it gets interpolated automatically. And then you might normalize it first before using it to evaluate your lighting equation (whatever that may be).

Thanks a lot!

Seems like this is what i've been looking for :)

This topic is closed to new replies.

Advertisement