Jump to content
  • Advertisement
Sign in to follow this  
PSS

HLSL Lighting moving the scene

This topic is 3813 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 in a bit of a confused state right now: In my vertex shader, I'm calculating the lighting on the scene. When I calculate all the directional lights, it works fine and when I calculate the point lights it works fine... but when I add both together, my scene doesn't display properly and moves with the position of the last point light.
//Directional lights
   for(int d = 0; d < gvDirLightCount; ++d )
   		tvTotalLightDiffuse += gvDirLights[d].Diffuse * max( 0, dot( tvNormalWorldSpace, (-gvDirLights[d].Direction) ) );

	//Point lights
	for( int p = 0; p < gvPointLightCount; ++p )
	{
		float3 tvVec = gvPointLights

.Position - Input.Position; float tvDistance = length( tvVec ); float tvAttenuation0 = 1.0/dot( gvPointLights

.Attenuation0, float4(1, tvDistance, tvDistance*tvDistance, 0) ); tvVec = normalize( tvVec ); tvTotalLightDiffuse += max( 0, dot( tvVec, tvNormalWorldSpace ) * gvPointLights

.Diffuse * tvAttenuation0 * gvPointLights

.Range * 2); } Output.Color.rgb = tvTotalLightDiffuse + gvAmbient;

Any help would be appreciated

Share this post


Link to post
Share on other sites
Advertisement
fixed!

My problem was with the gvPointLights and gvDirLights arrays.
Their size was set to 10 each, and when I reduced them to 8 each, it worked fine.

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!