From 456816f707c36b482edb7385033bc5d4e282b412 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 17 Feb 2016 03:07:18 +0100 Subject: [PATCH] Use diffuse.a / vertex.a, use material emission --- components/shader/shadervisitor.cpp | 2 +- files/shaders/objects_fragment.glsl | 4 ++-- files/shaders/objects_vertex.glsl | 29 +++++++++++++++++++---------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index 02ece3296..96357ea9d 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -120,7 +120,7 @@ namespace Shader case GL_AMBIENT_AND_DIFFUSE: defineMap["colorMode"] = "2"; break; - case GL_AMBIENT: + case GL_EMISSION: defineMap["colorMode"] = "1"; break; } diff --git a/files/shaders/objects_fragment.glsl b/files/shaders/objects_fragment.glsl index c3f004e02..016cae13f 100644 --- a/files/shaders/objects_fragment.glsl +++ b/files/shaders/objects_fragment.glsl @@ -22,7 +22,7 @@ varying vec2 emissiveMapUV; varying float depth; -varying vec3 lighting; +varying vec4 lighting; void main() { @@ -40,7 +40,7 @@ void main() gl_FragData[0].xyz *= texture2D(darkMap, darkMapUV).xyz; #endif - gl_FragData[0].xyz *= lighting; + gl_FragData[0] *= lighting; #if @emissiveMap gl_FragData[0].xyz += texture2D(emissiveMap, emissiveMapUV).xyz; diff --git a/files/shaders/objects_vertex.glsl b/files/shaders/objects_vertex.glsl index 50d6eb490..1805f31de 100644 --- a/files/shaders/objects_vertex.glsl +++ b/files/shaders/objects_vertex.glsl @@ -18,24 +18,24 @@ varying vec2 emissiveMapUV; varying float depth; -varying vec3 lighting; +varying vec4 lighting; #define MAX_LIGHTS 8 -vec3 doLighting(vec3 viewPos, vec3 viewNormal, vec3 vertexColor) +vec4 doLighting(vec3 viewPos, vec3 viewNormal, vec4 vertexColor) { vec3 lightDir; float d; #if @colorMode == 2 - vec3 diffuse = vertexColor; - vec3 ambient = vertexColor; + vec4 diffuse = vertexColor; + vec3 ambient = vertexColor.xyz; #else - vec3 diffuse = gl_FrontMaterial.diffuse.xyz; + vec4 diffuse = gl_FrontMaterial.diffuse; vec3 ambient = gl_FrontMaterial.ambient.xyz; #endif + vec4 lightResult = vec4(0.0, 0.0, 0.0, diffuse.a); - vec3 lightResult = vec3(0.0, 0.0, 0.0); for (int i=0; i