Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

willyx

Lights problem

This topic is 6012 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''ve a little problem with lights as u can see here: http://www.geocities.com/gnomorinco/Image1.jpg I think that the problem is the vector of textures... I''ve made this 2D engine in OpenGL,i use flat planes with the some Z and tiles are made with texture.Lights are at the Z of tiles + something. Thanks

Share this post


Link to post
Share on other sites
Advertisement
To my mind, 3 possibilities :
1- you don''t define the same normals in the upper and lower planes.
2- you don''t define the same material properties (ambient, diffuse, specular, etc) in the planes.
3- you don''t split your geometry identically, eg see figure below :
  
+--------+-------+--------+
^ | | | |
| | | | |
upper| | | |
plane| | | |
| | | | |
V | | | |
+--------+---+---+--------+
^ | | |
| | | |
lower| | |
plane| | |
| | | |
V | | |
+------------+------------+


There woul be other possibilities, but the 3 above are the most "probable" IMHO.

Share this post


Link to post
Share on other sites
I use different size for textures, some are 128*128, others 64*64 and i draw all texture in any x*y position...is that the problem?

Share this post


Link to post
Share on other sites
I don''t think so.
The problem clearly seems to be lighting.

The only way that textures could produce this effect would be if textures contained explicitly faked colors.

Share this post


Link to post
Share on other sites
Isn''t this just caused by the fact that gouraud shading (ie the shading most cards use for lighting) is per-vertex, not per-pixel?

So basically, the card calculates the brightness of the light at each vertex, then just interpolates. So even though there should be a bright spot, it doesn''t show up.

Share this post


Link to post
Share on other sites
Well, if it is a lighting problem, and I''m correct in assuming that your game world is flat, then the normals for each vertex would be identical (straight at the camera).
However, to me it looks like a texture tiling issue - though I may be mistaken, have you checked that the textures tile seamlessly (a little trickier when you have different texture sizes)?

Share this post


Link to post
Share on other sites
Lord Kranus : the probelm is not due to the texture. In fact, texture may have "seam" problems, but there would not "look" like that.

There is only one solution for per-vertex ligthing (assuming you don''t choose the solution to disable lighting ) : split your geometry so that polygons'' vertices match between upper and lower part.

Do you see the figure that I drew above ?
Well, that''s exactly the problem. You have to split the horizontal middle line, for both upper and lower part, like that :
  
+--------+---*---+--------+
^ | | * | |
| | | * | |
upper| | * | |
plane| | * | |
| | | * | |
V | | * | |
+--------+---+---+--------+
^ | * | * |
| | * | * |
lower| * | * |
plane| * | * |
| | * | * |
V | * | * |
+--------*---+---*--------+


asterisks (*) shows what have to be done. Imagine those asterisks represents lines.

Share this post


Link to post
Share on other sites
Textures are ok without lights, the problem is the light.
Now i draw tiles in this way:

glNormal3f( 0.0f, 0.0f, 1.0f);
glBegin(GL_QUADS);// Draw Our Quad
glTexCoord2f(0.0f, 0.0f); glVertex3f(-Dim, -Dim, LACOSTANTE);
glTexCoord2f(1.0f, 0.0f); glVertex3f(+Dim, -Dim, LACOSTANTE);
glTexCoord2f(1.0f, 1.0f); glVertex3f(+Dim, Dim, LACOSTANTE);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-Dim, Dim, LACOSTANTE);
glEnd();

Share this post


Link to post
Share on other sites
vincoof i''ve tryed to use the some tile and place like in your picture, now the problem doesn''t exist, but i cant use only texture with the some size and place in that order...is possible to use per-pixel light?

Share this post


Link to post
Share on other sites

  • 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!