Add ambient occlusion to default pipeline
This commit is contained in:
parent
140263d611
commit
961219a091
5 changed files with 96 additions and 5 deletions
|
@ -31,6 +31,11 @@
|
|||
<type>buffer</type>
|
||||
<name>spec-emis</name>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>4</unit>
|
||||
<type>buffer</type>
|
||||
<name>ao-3</name>
|
||||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/ambient.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/ambient.frag</fragment-shader>
|
||||
|
@ -55,6 +60,11 @@
|
|||
<type>sampler-2d</type>
|
||||
<value type="int">3</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>ao_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">4</value>
|
||||
</uniform>
|
||||
<!-- The following uniforms are automatically defined and initialized :
|
||||
- fg_SunAmbientColor
|
||||
- fg_SunDiffuseColor
|
||||
|
|
|
@ -53,6 +53,36 @@
|
|||
<scale-factor>1.0</scale-factor>
|
||||
<wrap-mode>clamp-to-border</wrap-mode>
|
||||
</buffer>
|
||||
<buffer>
|
||||
<name>ao-1</name>
|
||||
<internal-format>rgba8</internal-format>
|
||||
<source-format>rgba</source-format>
|
||||
<source-type>unsigned-byte</source-type>
|
||||
<width>screen</width>
|
||||
<height>screen</height>
|
||||
<scale-factor>0.25</scale-factor>
|
||||
<wrap-mode>clamp-to-border</wrap-mode>
|
||||
</buffer>
|
||||
<buffer>
|
||||
<name>ao-2</name>
|
||||
<internal-format>rgba8</internal-format>
|
||||
<source-format>rgba</source-format>
|
||||
<source-type>unsigned-byte</source-type>
|
||||
<width>screen</width>
|
||||
<height>screen</height>
|
||||
<scale-factor>0.25</scale-factor>
|
||||
<wrap-mode>clamp-to-border</wrap-mode>
|
||||
</buffer>
|
||||
<buffer>
|
||||
<name>ao-3</name>
|
||||
<internal-format>rgba8</internal-format>
|
||||
<source-format>rgba</source-format>
|
||||
<source-type>unsigned-byte</source-type>
|
||||
<width>screen</width>
|
||||
<height>screen</height>
|
||||
<scale-factor>0.25</scale-factor>
|
||||
<wrap-mode>clamp-to-border</wrap-mode>
|
||||
</buffer>
|
||||
<buffer>
|
||||
<name>lighting</name>
|
||||
<internal-format>rgba8</internal-format>
|
||||
|
@ -67,6 +97,7 @@
|
|||
<!-- STAGES -->
|
||||
<stage>
|
||||
<name>geometry</name>
|
||||
<order-num>0</order-num>
|
||||
<attachment>
|
||||
<component>depth</component>
|
||||
<buffer>depth</buffer>
|
||||
|
@ -86,13 +117,49 @@
|
|||
</stage>
|
||||
<stage>
|
||||
<name>shadow</name>
|
||||
<order-num>1</order-num>
|
||||
<attachment>
|
||||
<component>depth</component>
|
||||
<buffer>shadow</buffer>
|
||||
</attachment>
|
||||
</stage>
|
||||
<stage>
|
||||
<name>ssao-1</name>
|
||||
<type>fullscreen</type>
|
||||
<order-num>2</order-num>
|
||||
<effect>Effects/ssao</effect>
|
||||
<needs-du-dv>true</needs-du-dv>
|
||||
<scale-factor>0.25</scale-factor>
|
||||
<attachment>
|
||||
<component>color0</component>
|
||||
<buffer>ao-1</buffer>
|
||||
</attachment>
|
||||
</stage>
|
||||
<stage>
|
||||
<name>ssao-2</name>
|
||||
<type>fullscreen</type>
|
||||
<order-num>3</order-num>
|
||||
<effect>Effects/ssao-blur-1</effect>
|
||||
<scale-factor>0.25</scale-factor>
|
||||
<attachment>
|
||||
<component>color0</component>
|
||||
<buffer>ao-2</buffer>
|
||||
</attachment>
|
||||
</stage>
|
||||
<stage>
|
||||
<name>ssao-3</name>
|
||||
<type>fullscreen</type>
|
||||
<order-num>4</order-num>
|
||||
<effect>Effects/ssao-blur-2</effect>
|
||||
<scale-factor>0.25</scale-factor>
|
||||
<attachment>
|
||||
<component>color0</component>
|
||||
<buffer>ao-3</buffer>
|
||||
</attachment>
|
||||
</stage>
|
||||
<stage>
|
||||
<name>lighting</name>
|
||||
<order-num>50</order-num>
|
||||
<attachment>
|
||||
<component>depth</component>
|
||||
<buffer>depth</buffer>
|
||||
|
@ -104,5 +171,7 @@
|
|||
</stage>
|
||||
<stage>
|
||||
<name>display</name>
|
||||
<order-num>99</order-num>
|
||||
<effect>Effects/display</effect>
|
||||
</stage>
|
||||
</PropertyList>
|
||||
|
|
|
@ -36,6 +36,11 @@
|
|||
<type>buffer</type>
|
||||
<name>lighting</name>
|
||||
</texture-unit>
|
||||
<texture-unit>
|
||||
<unit>5</unit>
|
||||
<type>buffer</type>
|
||||
<name>ao-3</name>
|
||||
</texture-unit>
|
||||
<program>
|
||||
<vertex-shader>Shaders/display.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/display.frag</fragment-shader>
|
||||
|
@ -65,6 +70,11 @@
|
|||
<type>sampler-2d</type>
|
||||
<value type="int">4</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>ao_tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">5</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>exposure</name>
|
||||
<type>float</type>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
uniform sampler2D color_tex;
|
||||
//uniform sampler2D ao_tex;
|
||||
uniform sampler2D ao_tex;
|
||||
uniform sampler2D normal_tex;
|
||||
uniform sampler2D spec_emis_tex;
|
||||
uniform vec4 fg_SunAmbientColor;
|
||||
|
@ -9,7 +9,7 @@ void main() {
|
|||
if ( initialized < 0.1 )
|
||||
discard;
|
||||
vec3 tcolor = texture2D( color_tex, coords ).rgb;
|
||||
// float ao = texture2D( ao_tex, coords ).r;
|
||||
// gl_FragColor = vec4(tcolor*fg_SunAmbientColor.rgb*ao, 1.0);
|
||||
gl_FragColor = vec4(tcolor*fg_SunAmbientColor.rgb, 1.0);
|
||||
float ao = texture2D( ao_tex, coords ).r;
|
||||
gl_FragColor = vec4(tcolor*fg_SunAmbientColor.rgb*ao, 1.0);
|
||||
// gl_FragColor = vec4(tcolor*fg_SunAmbientColor.rgb, 1.0);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ uniform sampler2D color_tex;
|
|||
uniform sampler2D specular_tex;
|
||||
uniform sampler2D lighting_tex;
|
||||
//uniform sampler2D bloom_tex;
|
||||
//uniform sampler2D ao_tex;
|
||||
uniform sampler2D ao_tex;
|
||||
uniform float exposure;
|
||||
uniform bool showBuffers;
|
||||
uniform bool fg_DepthInColor;
|
||||
|
@ -29,6 +29,8 @@ void main() {
|
|||
color = texture2D( color_tex, (coords - vec2( 0.8, 0.0 )) * 5.0 );
|
||||
} else if (coords.x < 0.2 && coords.y >= 0.8 && fg_DepthInColor) {
|
||||
color = texture2D( depth_tex, (coords - vec2( 0.0, 0.8 )) * 5.0 );
|
||||
} else if (coords.x < 0.2 && coords.y >= 0.8) {
|
||||
color = texture2D( ao_tex, (coords - vec2( 0.0, 0.8 )) * 5.0 );
|
||||
} else {
|
||||
color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */;
|
||||
//color = vec4( HDR( color.rgb ), 1.0 );
|
||||
|
|
Loading…
Reference in a new issue