Jump to content
  • Advertisement
Sign in to follow this  
el capitan

OpenGL Lightmap woes

This topic is 4760 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'm trying to implement this: http://www.gamedev.net/reference/programming/features/raylighting/page3.asp on dynamic terrain and I am having problems. The shadows just don't seem to be in right place even though i have copied and pasted the code directly. The only thing different in my implementation is how the values are assigned to the array. Whereas in the article the values are assigned as two dimensional array, i have one dimensional array. The loop starts like this: for (z = 0; z < MapSize; z++) for ( MapX = 0; MapX < MapSize; MapX ++) In the original implementation array is accessed like this: HeightMap[MapX][z]; Whereas in my implementation array is accessed like this: HeightMap[z*MapSize + MapX] Is this correct? My heightmap is fractal terrain generated via frand, and my question is that can I load LightMap directly into the memory? I use opengl and do this via gluBuild2dMipMaps. I have tried reversing the LightMap but it yields even worse results. I am generating another texture via cutting four textures together and it seems to be in the right place according to the heights. The lightmap code is just randomly messed up.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by el capitan
In the original implementation array is accessed like this:
HeightMap[MapX][z];

Whereas in my implementation array is accessed like this:
HeightMap[z*MapSize + MapX]

HeightMap[MapX][z] is equivalent to HeightMap[MapX*MapSize + z]. Maybe that's the problem.

Share this post


Link to post
Share on other sites
I tried switching the array access to what you suggested, but it still doesn't seem to work. There are shadows all right, but they seem to be in random places.

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!