1
0
Fork 0

Bloom effect for the Rembrandt renderer

This commit is contained in:
Frederic Bouvier 2012-05-12 13:06:45 +02:00
parent 2163651c43
commit be5a51ec5d
8 changed files with 165 additions and 5 deletions

10
Effects/bloom-blur-1.eff Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
<name>Effects/bloom-blur-1</name>
<inherits-from>Effects/blur</inherits-from>
<parameters>
<blurOffset_x>4.0</blurOffset_x>
<blurOffset_y>0.0</blurOffset_y>
<buffer-name>bloom-1</buffer-name>
</parameters>
</PropertyList>

10
Effects/bloom-blur-2.eff Normal file
View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
<name>Effects/bloom-blur-2</name>
<inherits-from>Effects/blur</inherits-from>
<parameters>
<blurOffset_x>0.0</blurOffset_x>
<blurOffset_y>4.0</blurOffset_y>
<buffer-name>bloom-2</buffer-name>
</parameters>
</PropertyList>

34
Effects/bloom-combine.eff Normal file
View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
<name>Effects/bloom-combine</name>
<parameters>
</parameters>
<technique n="11">
<pass>
<texture-unit>
<unit>0</unit>
<type>buffer</type>
<name>spec-emis</name>
</texture-unit>
<texture-unit>
<unit>1</unit>
<type>buffer</type>
<name>diffuse</name>
</texture-unit>
<program>
<vertex-shader>Shaders/fullscreen.vert</vertex-shader>
<fragment-shader>Shaders/bloom-combine.frag</fragment-shader>
</program>
<uniform>
<name>spec_emis_tex</name>
<type>sampler-2d</type>
<value type="int">0</value>
</uniform>
<uniform>
<name>color_tex</name>
<type>sampler-2d</type>
<value type="int">1</value>
</uniform>
</pass>
</technique>
</PropertyList>

View file

@ -124,6 +124,45 @@
<scale-factor>1.0</scale-factor>
<wrap-mode>clamp-to-border</wrap-mode>
</buffer>
<buffer>
<name>bloom-1</name>
<condition>
<property>/sim/rendering/rembrandt/bloom-buffers</property>
</condition>
<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>bloom-2</name>
<condition>
<property>/sim/rendering/rembrandt/bloom-buffers</property>
</condition>
<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>bloom-3</name>
<condition>
<property>/sim/rendering/rembrandt/bloom-buffers</property>
</condition>
<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>
<!-- STAGES -->
<stage>
@ -209,6 +248,50 @@
<buffer>lighting</buffer>
</attachment>
</stage>
<stage>
<name>bloom-1</name>
<type>fullscreen</type>
<condition>
<property>/sim/rendering/rembrandt/bloom-buffers</property>
</condition>
<order-num>60</order-num>
<effect>Effects/bloom-combine</effect>
<scale-factor>0.25</scale-factor>
<attachment>
<component>color0</component>
<buffer>bloom-1</buffer>
</attachment>
</stage>
<stage>
<name>bloom-2</name>
<type>fullscreen</type>
<condition>
<property>/sim/rendering/rembrandt/bloom-buffers</property>
</condition>
<order-num>61</order-num>
<effect>Effects/bloom-blur-1</effect>
<scale-factor>0.25</scale-factor>
<attachment>
<component>color0</component>
<buffer>bloom-2</buffer>
</attachment>
</stage>
<stage>
<name>bloom-3</name>
<type>fullscreen</type>
<condition>
<property>/sim/rendering/rembrandt/bloom-buffers</property>
</condition>
<order-num>62</order-num>
<effect>Effects/bloom-blur-2</effect>
<scale-factor>0.25</scale-factor>
<attachment>
<component>color0</component>
<buffer>bloom-3</buffer>
</attachment>
</stage>
<stage>
<name>display</name>
<order-num>99</order-num>

View file

@ -5,6 +5,7 @@
<exposure type="float"><use>/sim/rendering/rembrandt/exposure</use></exposure>
<show-buffers type="bool"><use>/sim/rendering/rembrandt/show-buffers</use></show-buffers>
<ambient-occlusion type="bool"><use>/sim/rendering/rembrandt/ambient-occlusion-buffers</use></ambient-occlusion>
<bloom type="bool"><use>/sim/rendering/rembrandt/bloom</use></bloom>
</parameters>
<technique n="11">
<pass>
@ -40,7 +41,7 @@
<texture-unit>
<unit>5</unit>
<type>buffer</type>
<name>ao-3</name>
<name>bloom-3</name>
</texture-unit>
<program>
<vertex-shader>Shaders/fullscreen.vert</vertex-shader>
@ -72,7 +73,7 @@
<value type="int">4</value>
</uniform>
<uniform>
<name>ao_tex</name>
<name>bloom_tex</name>
<type>sampler-2d</type>
<value type="int">5</value>
</uniform>
@ -91,6 +92,11 @@
<type>bool</type>
<value type="bool"><use>ambient-occlusion</use></value>
</uniform>
<uniform>
<name>bloomEnabled</name>
<type>bool</type>
<value type="bool"><use>bloom</use></value>
</uniform>
</pass>
</technique>
</PropertyList>

View file

@ -0,0 +1,10 @@
uniform sampler2D color_tex;
uniform sampler2D spec_emis_tex;
void main() {
vec2 coords = gl_TexCoord[0].xy;
vec4 spec_emis = texture2D( spec_emis_tex, coords );
if ( spec_emis.a < 0.1 )
spec_emis.z = 0.0;
vec3 tcolor = texture2D( color_tex, coords ).rgb;
gl_FragColor = vec4(tcolor * spec_emis.z, 1.0);
}

View file

@ -3,12 +3,13 @@ uniform sampler2D normal_tex;
uniform sampler2D color_tex;
uniform sampler2D specular_tex;
uniform sampler2D lighting_tex;
//uniform sampler2D bloom_tex;
uniform sampler2D bloom_tex;
uniform sampler2D ao_tex;
uniform float exposure;
uniform bool showBuffers;
uniform bool fg_DepthInColor;
uniform bool ambientOcclusion;
uniform bool bloomEnabled;
vec3 HDR(vec3 L) {
L = L * exposure;
@ -33,11 +34,15 @@ void main() {
} else if (coords.x < 0.2 && coords.y >= 0.8 && ambientOcclusion) {
color = texture2D( ao_tex, (coords - vec2( 0.0, 0.8 )) * 5.0 );
} else {
color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */;
color = texture2D( lighting_tex, coords );
if (bloomEnabled)
color = color + texture2D( bloom_tex, coords );
//color = vec4( HDR( color.rgb ), 1.0 );
}
} else {
color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */;
color = texture2D( lighting_tex, coords );
if (bloomEnabled)
color = color + texture2D( bloom_tex, coords );
//color = vec4( HDR( color.rgb ), 1.0 );
}
gl_FragColor = color;

View file

@ -70,6 +70,8 @@ Started September 2000 by David Megginson, david@megginson.com
<show-buffers type="bool" userarchive="y">false</show-buffers>
<ambient-occlusion type="bool" userarchive="y">false</ambient-occlusion>
<ambient-occlusion-buffers type="bool">true</ambient-occlusion-buffers>
<bloom type="bool" userarchive="y">true</bloom>
<bloom-buffers type="bool">true</bloom-buffers>
<exposure type="float" userarchive="y">1.0</exposure>
<use-color-for-depth type="bool">false</use-color-for-depth>
<no-16bit-buffer type="bool">false</no-16bit-buffer>