From 267e7397c5683ca656fc64a6321af0f9b26355ef Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 2 Apr 2014 00:46:03 +0200 Subject: [PATCH] GL3: Support specular materials with missing textures --HG-- branch : opengl3 --- .../opengl3/driver_opengl_pixel_program.cpp | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_pixel_program.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_pixel_program.cpp index 3c58e1d95..b9bf44108 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_pixel_program.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_pixel_program.cpp @@ -321,9 +321,31 @@ void ppTexEnv(std::stringstream &ss, const CPPBuiltin &desc) void ppSpecular(std::stringstream &ss, const CPPBuiltin &desc) { - ss << "vec3 specop0 = texel0.rgb * fragColor.rgb;" << std::endl; - ss << "vec4 specop1 = vec4(texel1.rgb * texel0.a + specop0, fragColor.a);" << std::endl; - ss << "fragColor = specop1;" << std::endl; + if (useTex(desc, 0)) + { + ss << "vec3 specop0 = texel0.rgb * fragColor.rgb;" << std::endl; + if (useTex(desc, 1)) + { + ss << "vec4 specop1 = vec4(texel1.rgb * texel0.a + specop0, fragColor.a);" << std::endl; + } + else + { + nlwarning("Texture stage 1 (reflection) missing in Specular shader"); + ss << "vec4 specop1 = vec4(specop0, fragColor.a);" << std::endl; + } + ss << "fragColor = specop1;" << std::endl; + } + else if (useTex(desc, 1)) + { + nlwarning("Texture stage 0 (color) missing in Specular shader"); + ss << "vec4 specop1 = vec4(texel1.rgb + fragColor.rgb, 1.0);" << std::endl; + ss << "fragColor = specop1;" << std::endl; + } + else + { + nlwarning("No textures defined in Specular shader"); + // do nothing + } } void ppGenerate(std::string &result, const CPPBuiltin &desc)