Sign in to follow this  

help me modify a lighting

Recommended Posts

I wanna make a point lighting effect as follows: /*********** vertex shader ******/ OUT.WorldNormal = mul(IN.Normal, WorldIT).xyz; half4 Po = half4(,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

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