From fce0db09e8227ef04f9e03d28d69fcdc3517c7a2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 11 Oct 2017 00:07:57 +0200 Subject: [PATCH] Add support for reflection in PhongLighting shader --- .../Graphics/Resources/Shaders/PhongLighting/core.frag | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag index e37df3fa3..560ca4c29 100644 --- a/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag +++ b/src/Nazara/Graphics/Resources/Shaders/PhongLighting/core.frag @@ -63,6 +63,7 @@ uniform float ParallaxBias = -0.03; uniform float ParallaxScale = 0.02; uniform vec2 InvTargetSize; uniform vec3 EyePosition; +uniform samplerCube ReflectionMap; uniform vec4 SceneAmbient; uniform sampler2D TextureOverlay; @@ -451,6 +452,14 @@ void main() #endif vec3 lightColor = (lightAmbient + lightDiffuse + lightSpecular); + + #if REFLECTION_MAPPING + vec3 eyeVec = normalize(vWorldPos - EyePosition); + + vec3 reflected = normalize(reflect(eyeVec, normal)); + lightColor *= texture(ReflectionMap, reflected).rgb; + #endif + vec4 fragmentColor = vec4(lightColor, 1.0) * diffuseColor; #if EMISSIVE_MAPPING