diff --git a/Effects/model-default.eff b/Effects/model-default.eff index 2439562f4..d5185e98f 100644 --- a/Effects/model-default.eff +++ b/Effects/model-default.eff @@ -165,7 +165,7 @@ false true smooth - back + cull-face 1 RenderBin @@ -183,6 +183,9 @@ modulate + + vertex-program-two-side + Shaders/deferred-gbuffer.vert Shaders/deferred-gbuffer.frag diff --git a/Shaders/deferred-gbuffer.frag b/Shaders/deferred-gbuffer.frag index a392efab2..929743349 100644 --- a/Shaders/deferred-gbuffer.frag +++ b/Shaders/deferred-gbuffer.frag @@ -5,17 +5,18 @@ // attachment 2: specular.l | shininess | emission.l | unused // varying vec3 ecNormal; -varying vec4 color; +varying float alpha; uniform int materialID; uniform sampler2D texture; void main() { - float specular = dot( gl_FrontMaterial.specular.rgb, vec3( 0.3, 0.59, 0.11 ) ); - float shininess = gl_FrontMaterial.shininess; - float emission = dot( gl_FrontLightModelProduct.sceneColor.rgb, vec3( 0.3, 0.59, 0.11 ) ); vec4 texel = texture2D(texture, gl_TexCoord[0].st); - if (texel.a * color.a < 0.1) - discard; + if (texel.a * alpha < 0.1) + discard; + float specular = dot( gl_FrontMaterial.specular.rgb, vec3( 0.3, 0.59, 0.11 ) ); + float shininess = gl_FrontMaterial.shininess; + float emission = dot( gl_FrontLightModelProduct.sceneColor.rgb, vec3( 0.3, 0.59, 0.11 ) ); + ecNormal = (2.0 * gl_Color.a - 1.0) * ecNormal; gl_FragData[0] = vec4( (ecNormal.xy + vec2(1.0,1.0)) * 0.5, 0.0, 1.0 ); - gl_FragData[1] = vec4( color.rgb * texel.rgb, float( materialID ) / 255.0 ); + gl_FragData[1] = vec4( gl_Color.rgb * texel.rgb, float( materialID ) / 255.0 ); gl_FragData[2] = vec4( specular, shininess / 255.0, emission, 1.0 ); } diff --git a/Shaders/deferred-gbuffer.vert b/Shaders/deferred-gbuffer.vert index b517ab146..4ab618936 100644 --- a/Shaders/deferred-gbuffer.vert +++ b/Shaders/deferred-gbuffer.vert @@ -4,10 +4,12 @@ // attachment 2: specular.l | shininess | emission.l | unused // varying vec3 ecNormal; -varying vec4 color; +varying float alpha; void main() { ecNormal = gl_NormalMatrix * gl_Normal; gl_Position = ftransform(); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; - color = gl_Color; + gl_FrontColor.rgb = gl_Color.rgb; gl_FrontColor.a = 1.0; + gl_BackColor.rgb = gl_Color.rgb; gl_BackColor.a = 0.0; + alpha = gl_Color.a; }