Jump to content
  • Advertisement
Sign in to follow this  
glsensor

help me modify a lighting

This topic is 4314 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 wanna make a point lighting effect as follows: /*********** vertex shader ******/ OUT.WorldNormal = mul(IN.Normal, WorldIT).xyz; half4 Po = half4(IN.Position.xyz,1); half3 Pw = mul(Po, World).xyz; OUT.LightVec0 = normalize(light0_Position - Pw); OUT.TexCoord = IN.UV; OUT.WorldView = normalize(ViewI[3].xyz - Pw); OUT.HPosition = mul(Po, WorldViewProj); /********* pixel shader ********/ half3 Nn = normalize(IN.WorldNormal); Hn = normalize(IN.WorldView + IN.LightVec0); hdn = pow(max(0,dot(Hn,Nn)),specPower); ldn = dot(IN.LightVec0,Nn); diffuseColor = ldn * light0_Diffuse; specularColor = (ldn * hdn) * light0_Specular; half3 map = tex2D(ColorSampler,IN.TexCoord.xy).xyz; half3 result = (Ambient + diffuseColor) * map + specularColor; return half4(result,1); /********* shader eof ********/ This's a nice lighting, But the lighting has 2 problems. 1. When I moving it to close to object the lighting is attenuated. When I moving it to far away the lighting is intensified. It's seem not a real world lighting. 2. The lighting has not a radius, I want that when object out of lighting radius only to do ambient shader as a real world lighting. Anyone know where could find some real world lighting tutorials for HLSL? Thank!

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!