Jump to content
  • Advertisement
Sign in to follow this  
AdamWebb

OpenGL 2d sprites with 3d lighting

This topic is 4858 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

I have a top-down space shooter sprite that is composed of a single texture stretched across two OpenGL triangles. Currently I'm using fixed-function lighting which gives poor quality results at best so I was wondering how I would go about using Cg with OpenGL to achieve something a little more impressive. Using the Adobe Photoshop normal map plugin; I've created a normal map of my texture and the nVIDIA 3d preview isn't quite what I was expecting. The effect created shows the lighting giving the impression of an object embedded and then embossed depending on the light sources position. Is there a way to avoid this in my final implementation when I come to do it myself? Edit: I'm not to sure if my description is adequate so heres some pictures of what is happening when using the normal map. Heres what I want to achieve, the texture appears embossed as it should. Heres what is happening though when the light source is given chance to change position it's causing the texture to indent this does not look at all right when applied to my ship's texture. Thanks for the Help! [Edited by - AdamWebb on March 27, 2005 11:36:21 AM]

Share this post


Link to post
Share on other sites
Advertisement
I think it's behaving more or less correctly - the normals point as you expect so the sections are lit normally.

Perhaps putting a bit of parallax into things would help - if you've already got height maps, you could try parallax normal mapping. That would help to maintain the parts of the sprite that are 'nearer' the camera.

Share this post


Link to post
Share on other sites
The effect of it looking embossed with a top light source and indented from a bottom light source is an issue with our perceptual system. We commonly view objects being lit from above, and therefore tend to make the assumption of its shape given the shaded values. I'm not sure if you can do much to change it in a local area. Though if there are other parts of the ship that pick up lighting direction cues, your visual system might account for it. Just wanted to let you know that this is one of those 'eye tricks' you see in the psychology books.

Share this post


Link to post
Share on other sites
Quote:
Original post by AdamWebb
Heres what is happening though when the light source is given chance to change position it's causing the texture to indent this does not look at all right when applied to my ship's texture.


Actually you'll find that its correct. You THINK its indented because all computer gui's work as if a light is at the top left corner of the screen. This makes everyone think if its dark at the top left its indented. However if the light in your 3D world is at the bottom right of your screen then the shadow is exactly where it should be. Its actually impossible to tell if either of those pictures are indenteted or raised because both could be true - just looke at it and imagine it raised and it will be :P

EDIT: beaten

Share this post


Link to post
Share on other sites
Hmm okay I'll agree that the above example was kinda stupid because it looks perfectly normal. But in the case of a more detail texture having the normal map applied it still looks weird.

Are there any other ways I could achieve realistic lighting behaviours on a 2d texture?

Share this post


Link to post
Share on other sites
The viewer for Nvidias photoshop plugin is kinda strange. I am using it for creating some artwork for my game it works just fine.

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!