From 5fd84074c59e967c45f06c45f0ccf4d21b455c17 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 17 Feb 2016 02:52:44 +0100 Subject: [PATCH] Reimplement detailMap, darkMap and emissiveMap --- files/shaders/objects_fragment.glsl | 27 +++++++++++++++++++++++++++ files/shaders/objects_vertex.glsl | 24 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/files/shaders/objects_fragment.glsl b/files/shaders/objects_fragment.glsl index 07a524ba1..c3f004e02 100644 --- a/files/shaders/objects_fragment.glsl +++ b/files/shaders/objects_fragment.glsl @@ -5,6 +5,21 @@ uniform sampler2D diffuseMap; varying vec2 diffuseMapUV; #endif +#if @darkMap +uniform sampler2D darkMap; +varying vec2 darkMapUV; +#endif + +#if @detailMap +uniform sampler2D detailMap; +varying vec2 detailMapUV; +#endif + +#if @emissiveMap +uniform sampler2D emissiveMap; +varying vec2 emissiveMapUV; +#endif + varying float depth; varying vec3 lighting; @@ -17,8 +32,20 @@ void main() gl_FragData[0] = vec4(1.0, 1.0, 1.0, 1.0); #endif +#if @detailMap + gl_FragData[0].xyz *= texture2D(detailMap, detailMapUV).xyz * 2.0; +#endif + +#if @darkMap + gl_FragData[0].xyz *= texture2D(darkMap, darkMapUV).xyz; +#endif + gl_FragData[0].xyz *= lighting; +#if @emissiveMap + gl_FragData[0].xyz += texture2D(emissiveMap, emissiveMapUV).xyz; +#endif + float fogValue = clamp((depth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0); gl_FragData[0].xyz = mix(gl_FragData[0].xyz, gl_Fog.color.xyz, fogValue); } diff --git a/files/shaders/objects_vertex.glsl b/files/shaders/objects_vertex.glsl index 7ef2f6aa3..50d6eb490 100644 --- a/files/shaders/objects_vertex.glsl +++ b/files/shaders/objects_vertex.glsl @@ -4,6 +4,18 @@ varying vec2 diffuseMapUV; #endif +#if @darkMap +varying vec2 darkMapUV; +#endif + +#if @detailMap +varying vec2 detailMapUV; +#endif + +#if @emissiveMap +varying vec2 emissiveMapUV; +#endif + varying float depth; varying vec3 lighting; @@ -54,6 +66,18 @@ void main(void) diffuseMapUV = (gl_TextureMatrix[@diffuseMapUV] * gl_MultiTexCoord@diffuseMapUV).xy; #endif +#if @darkMap + darkMapUV = (gl_TextureMatrix[@darkMapUV] * gl_MultiTexCoord@darkMapUV).xy; +#endif + +#if @detailMap + detailMapUV = (gl_TextureMatrix[@detailMap] * gl_MultiTexCoord@detailMap).xy; +#endif + +#if @emissiveMap + emissiveMapUV = (gl_TextureMatrix[@emissiveMapUV] * gl_MultiTexCoord@emissiveMapUV).xy; +#endif + lighting = doLighting(viewPos.xyz, viewNormal, gl_Color.xyz); lighting = clamp(lighting, vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0)); }