Jump to content
  • Advertisement
Sign in to follow this  
Dragon_Strike

help with horizonmapping

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

well i tried to write a function to calculate horizons based on angles... this is what i have...
#define PIUNDER180 57.2957795130823208767981548141052f
#define RAD_TO_DEG( radians ) ( ( radians )*PIUNDER180 )

float* CLIGHTING::CalculateHorizonMap(float* Mesh, float lightangle)
{

	float* Temp = new float [m_size*m_size];

	float angle;


	for ( int z = 0; z < m_size; z++)
	{
		for (int x = 0; x < m_size; x++)
		{
			angle = 0.0f;
            for (int x1 = x-1; x1 > 0; x1--)
			{

				float opp = Mesh[x1+(m_size*z)];
				float adj = (x-x1);
				float Newangle = RAD_TO_DEG(atan( opp / adj ));

				if ( Newangle > Angle)
				{
					angle = Newangle;
				}
			}

			Temp[x+(m_size*z)] = angle;
		}
	}

	return Temp;

}




but as u may guess it doesnt work... its pretty simple but i dont get where ive gone wrong.. any suggetions?

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!