Jump to content
  • Advertisement
Sign in to follow this  
FoxHunter2

OpenGL per-pixel lighting without normal maps?

This topic is 5051 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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? :)

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!