Jump to content
  • Advertisement
Sign in to follow this  
Dragon_Strike

ligthing problem

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

ive been working on a algortitm or how u call it for terrain lighting... im not to advanced on eithermath, physics nor programming but ive come up with this code... bool dark; int x, z, p; // x pos on height map, z pos on height map, x pos from x to sunx float pHeight, mHeight; // height of ray, heightmap int sunX = m_iSize*2, sunY = m_iSize; // sun pos varibles //loop through all vertices for( z=0; z < m_iSize; z++ ) // m_iSize is the size of the heighmap { for( x = -m_iSize; x < sunX; x++ ) { dark = false; for (p = m_iSize ;0 < p; p--){ mHeight = GetScaledHeightAtPoint(p, z); pHeight = float( tan(((sunY-mHeight) / (sunX - x)) * (p - x)) ); if (pHeight < mHeight){ dark = true; } if (dark == true && mHeight < pHeight){ SetBrightnessAtPoint( p, z, (unsigned char)(pHeight-mHeight) ); } } } } the results get rly wierd and i cant seem to find why... anyone have any suggestions or should i give up?

Share this post


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