2d sprites with 3d lighting

Started by
4 comments, last by Hardguy 19 years ago
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]
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.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

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.
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
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?
The viewer for Nvidias photoshop plugin is kinda strange. I am using it for creating some artwork for my game it works just fine.

This topic is closed to new replies.

Advertisement