0
\$\begingroup\$

enter image description here

How to calculate this cpecular reflection?

HLSL

void calculateSpecular(
    in float4 Normal,
    in float4 SunLightDir,
    inout float4 Specular
){
        Specular = specularLevel * pow(saturate(dot(reflect(normalize(abs(eyePosition)), Normal), SunLightDir)), specularExponent);
}
/// in pixel shader
float4 Specular = float4(0.f,0.f,0.f,1.f);
calculateSpecular( input.normal, -sunLightDir, Specular );

///sunLightDir it's just camera position + vec3(0,10,0)
/// in vertex shader
output.normal = mul( float4( input.normal, 0.f ) , World );
\$\endgroup\$
  • 1
    \$\begingroup\$ ok, i understand my mistakes. i use shader for point lights, but i need for directional light. I answer to this question later, when fix my code. \$\endgroup\$ – Artem Basov May 5 '19 at 11:21
0
\$\begingroup\$

Do not forget about the different types of light sources.

This article helped me solve the problem.

https://www.3dgep.com/texturing-lighting-directx-11/

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ On top of adding a link to an external website, this answer would be better if it added enough details for future readers to understand what approach you used to solve your problem. \$\endgroup\$ – TomTsagk Oct 2 '19 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.