Put encode_gbuffer in a separate shader to please ATI and/or Mac OSX that doesn't like to have gl_FragData and gl_FragColor in the same program, even if one is never called
This commit is contained in:
parent
5057b49ed9
commit
7e1ed19307
8 changed files with 30 additions and 16 deletions
|
@ -79,12 +79,14 @@
|
|||
</technique>
|
||||
|
||||
<!-- Rembrandt -->
|
||||
<!-- FredB: What is the purpose of that ? -->
|
||||
<technique n="10">
|
||||
<pass n="0">
|
||||
<program n="0">
|
||||
<vertex-shader n="0">Shaders/deferred-gbuffer.vert</vertex-shader>
|
||||
<fragment-shader n="0">Shaders/deferred-gbuffer.frag</fragment-shader>
|
||||
<fragment-shader n="1">Shaders/gbuffer-functions.frag</fragment-shader>
|
||||
<fragment-shader n="2">Shaders/gbuffer-encode.frag</fragment-shader>
|
||||
</program>
|
||||
</pass>
|
||||
</technique>
|
||||
|
|
|
@ -53,8 +53,7 @@ the objects that use it, and replaces it with the default shader.
|
|||
<vertex-shader>Shaders/ubershader.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/ubershader-gbuffer.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-functions.frag</fragment-shader>
|
||||
<!-- <vertex-shader n="1">Shaders/deferred-gbuffer.vert</vertex-shader>
|
||||
<fragment-shader n="1">Shaders/deferred-gbuffer.frag</fragment-shader>-->
|
||||
<fragment-shader>Shaders/gbuffer-encode.frag</fragment-shader>
|
||||
</program>
|
||||
</pass>
|
||||
</technique>
|
||||
|
|
|
@ -195,6 +195,7 @@
|
|||
<vertex-shader>Shaders/deferred-gbuffer.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/deferred-gbuffer.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-functions.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-encode.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>texture</name>
|
||||
|
|
|
@ -465,6 +465,7 @@
|
|||
<vertex-shader>Shaders/deferred-gbuffer.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/deferred-gbuffer.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-functions.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-encode.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>texture</name>
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<vertex-shader>Shaders/deferred-tree.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/deferred-tree.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-functions.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-encode.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>texture</name>
|
||||
|
|
|
@ -159,6 +159,7 @@
|
|||
<vertex-shader>Shaders/urban-gbuffer.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/urban-gbuffer.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-functions.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-encode.frag</fragment-shader>
|
||||
<attribute>
|
||||
<name>tangent</name>
|
||||
<index>6</index>
|
||||
|
@ -323,6 +324,7 @@
|
|||
<vertex-shader>Shaders/urban-gbuffer.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/urban-gbuffer.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-functions.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/gbuffer-encode.frag</fragment-shader>
|
||||
<attribute>
|
||||
<name>tangent</name>
|
||||
<index>6</index>
|
||||
|
|
22
Shaders/gbuffer-encode.frag
Normal file
22
Shaders/gbuffer-encode.frag
Normal file
|
@ -0,0 +1,22 @@
|
|||
// -*- mode: C; -*-
|
||||
// Licence: GPL v2
|
||||
// Author: Frederic Bouvier.
|
||||
|
||||
uniform bool fg_DepthInColor;
|
||||
|
||||
vec2 normal_encode(vec3 n);
|
||||
vec3 float_to_color(in float f);
|
||||
|
||||
// attachment 0: normal.x | normal.y | 0.0 | 1.0
|
||||
// attachment 1: diffuse.r | diffuse.g | diffuse.b | material Id
|
||||
// attachment 2: specular.l | shininess | emission.l | unused
|
||||
// attachment 3: ---------- depth ------------ | unused (optional)
|
||||
//
|
||||
void encode_gbuffer(vec3 normal, vec3 color, int mId, float specular, float shininess, float emission, float depth)
|
||||
{
|
||||
gl_FragData[0] = vec4( normal_encode(normal), 0.0, 1.0 );
|
||||
gl_FragData[1] = vec4( color, float( mId ) / 255.0 );
|
||||
gl_FragData[2] = vec4( specular, shininess / 128.0, emission, 1.0 );
|
||||
if (fg_DepthInColor)
|
||||
gl_FragData[3] = vec4(float_to_color(depth), 1.0);
|
||||
}
|
|
@ -67,17 +67,3 @@ vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex )
|
|||
depth = texture2D( depth_tex, coords ).r;
|
||||
return position( viewDir, depth );
|
||||
}
|
||||
|
||||
// attachment 0: normal.x | normal.y | 0.0 | 1.0
|
||||
// attachment 1: diffuse.r | diffuse.g | diffuse.b | material Id
|
||||
// attachment 2: specular.l | shininess | emission.l | unused
|
||||
// attachment 3: ---------- depth ------------ | unused (optional)
|
||||
//
|
||||
void encode_gbuffer(vec3 normal, vec3 color, int mId, float specular, float shininess, float emission, float depth)
|
||||
{
|
||||
gl_FragData[0] = vec4( normal_encode(normal), 0.0, 1.0 );
|
||||
gl_FragData[1] = vec4( color, float( mId ) / 255.0 );
|
||||
gl_FragData[2] = vec4( specular, shininess / 128.0, emission, 1.0 );
|
||||
if (fg_DepthInColor)
|
||||
gl_FragData[3] = vec4(float_to_color(depth), 1.0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue