1
0
Fork 0

Hopefully fix the two-sided case for the Rembrandt renderer. Shadows are not fixed yet.

This commit is contained in:
Frederic Bouvier 2012-04-03 23:29:30 +02:00
parent 5753b2ce99
commit ddf0c576e9
3 changed files with 16 additions and 10 deletions

View file

@ -165,7 +165,7 @@
<blend>false</blend>
<alpha-test>true</alpha-test>
<shade-model>smooth</shade-model>
<cull-face>back</cull-face>
<cull-face><use>cull-face</use></cull-face>
<render-bin>
<bin-number>1</bin-number>
<bin-name>RenderBin</bin-name>
@ -183,6 +183,9 @@
<mode>modulate</mode>
</environment>
</texture-unit>
<vertex-program-two-side>
<use>vertex-program-two-side</use>
</vertex-program-two-side>
<program>
<vertex-shader>Shaders/deferred-gbuffer.vert</vertex-shader>
<fragment-shader>Shaders/deferred-gbuffer.frag</fragment-shader>

View file

@ -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 );
}

View file

@ -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;
}