Sign in to follow this  

ligthing problem

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

This topic is 4734 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this