1
0
Fork 0

HDR: Use stencil buffer for optimization purposes

This commit is contained in:
Fernando García Liñán 2021-08-23 12:44:26 +02:00
parent 8662ce0a86
commit eed433ce9f
11 changed files with 72 additions and 12 deletions

View file

@ -39,11 +39,11 @@
<format>rgba8</format>
</buffer>
<buffer>
<name>depth</name>
<name>depth-stencil</name>
<type>2d</type>
<width>screen</width>
<height>screen</height>
<format>depth32f</format>
<format>depth32f-stencil</format>
</buffer>
<!-- HDR lighting result -->
@ -612,7 +612,7 @@
<name>geometry</name>
<type>scene</type>
<effect-scheme>hdr-geometry</effect-scheme>
<clear-mask>depth</clear-mask>
<clear-mask>depth stencil</clear-mask>
<clear-depth>0.0</clear-depth>
<cull-mask>0xfffff7ff</cull-mask>
<attachment>
@ -629,7 +629,11 @@
</attachment>
<attachment>
<component>depth</component>
<buffer>depth</buffer>
<buffer>depth-stencil</buffer>
</attachment>
<attachment>
<component>stencil</component>
<buffer>depth-stencil</buffer>
</attachment>
</pass>
@ -686,7 +690,7 @@
<effect>Effects/HDR/ao</effect>
<binding>
<unit>0</unit>
<buffer>depth</buffer>
<buffer>depth-stencil</buffer>
</binding>
<binding>
<unit>1</unit>
@ -725,7 +729,7 @@
</binding>
<binding>
<unit>3</unit>
<buffer>depth</buffer>
<buffer>depth-stencil</buffer>
</binding>
<binding>
<unit>7</unit>
@ -751,6 +755,10 @@
<component>color0</component>
<buffer>hdr-result</buffer>
</attachment>
<attachment>
<component>stencil</component>
<buffer>depth-stencil</buffer>
</attachment>
</pass>
<!--
@ -794,7 +802,11 @@
</attachment>
<attachment>
<component>depth</component>
<buffer>depth</buffer>
<buffer>depth-stencil</buffer>
</attachment>
<attachment>
<component>stencil</component>
<buffer>depth-stencil</buffer>
</attachment>
</pass>
@ -1090,7 +1102,7 @@
<pass include="smaa-pass.xml">
<name>smaa-edge-detection</name>
<effect>Effects/HDR/smaa-edge-detection</effect>
<clear-mask>color</clear-mask>
<clear-mask>color stencil</clear-mask>
<clear-color type="vec4d">0.0 0.0 0.0 0.0</clear-color>
<binding>
<unit>0</unit>
@ -1100,6 +1112,10 @@
<component>color0</component>
<buffer>smaa-edges</buffer>
</attachment>
<attachment>
<component>stencil</component>
<buffer>depth-stencil</buffer>
</attachment>
</pass>
<pass include="smaa-pass.xml">
<name>smaa-blending-weight-calculation</name>
@ -1114,6 +1130,10 @@
<component>color0</component>
<buffer>smaa-blend</buffer>
</attachment>
<attachment>
<component>stencil</component>
<buffer>depth-stencil</buffer>
</attachment>
</pass>
<pass include="smaa-pass.xml">
<name>smaa-neighborhood-blending</name>
@ -1182,7 +1202,7 @@
</geometry>
<binding>
<unit>0</unit>
<buffer>depth</buffer>
<buffer>depth-stencil</buffer>
</binding>
</pass>
</PropertyList>

View file

@ -14,6 +14,10 @@
</parameters>
<technique n="1">
<pass>
<stencil>
<function>less-or-equal</function>
<value>8</value>
</stencil>
<texture-unit>
<unit>8</unit>
<image><use>texture[8]/image</use></image>

View file

@ -23,6 +23,10 @@
</parameters>
<technique n="1">
<pass>
<stencil>
<function>equal</function>
<value>1</value>
</stencil>
<texture-unit>
<unit>1</unit>
<image><use>texture[1]/image</use></image>

View file

@ -3,6 +3,11 @@
<name>Effects/HDR/smaa-edge-detection</name>
<technique n="1">
<pass>
<stencil>
<function>always</function>
<value>1</value>
<pass>replace</pass>
</stencil>
<program>
<vertex-shader>Shaders/HDR/smaa-edge-detection.vert</vertex-shader>
<fragment-shader>Shaders/HDR/smaa-edge-detection.frag</fragment-shader>

View file

@ -1303,6 +1303,11 @@ please see Docs/README.model-combined.eff for documentation
<near>1.0</near>
<far>0.0</far>
</depth>
<stencil>
<function>always</function>
<value>8</value>
<pass>replace</pass>
</stencil>
<texture-unit>
<unit>0</unit>
<type><use>texture[0]/type</use></type>

View file

@ -660,6 +660,11 @@
<near>1.0</near>
<far>0.0</far>
</depth>
<stencil>
<function>always</function>
<value>8</value>
<pass>replace</pass>
</stencil>
<texture-unit>
<unit>0</unit>
<type><use>texture[0]/type</use></type>

View file

@ -47,6 +47,11 @@
<near>1.0</near>
<far>0.0</far>
</depth>
<stencil>
<function>always</function>
<value>8</value>
<pass>replace</pass>
</stencil>
<texture-unit>
<unit>0</unit>
<type><use>texture[0]/type</use></type>

View file

@ -1690,6 +1690,11 @@
<near>1.0</near>
<far>0.0</far>
</depth>
<stencil>
<function>always</function>
<value>9</value>
<pass>replace</pass>
</stencil>
<texture-unit>
<unit>0</unit>
<type><use>texture[0]/type</use></type>

View file

@ -681,6 +681,11 @@
<near>1.0</near>
<far>0.0</far>
</depth>
<stencil>
<function>always</function>
<value>9</value>
<pass>replace</pass>
</stencil>
<blend><use>transparent</use></blend>
<alpha-test><use>transparent</use></alpha-test>

View file

@ -124,6 +124,11 @@
<near>1.0</near>
<far>0.0</far>
</depth>
<stencil>
<function>always</function>
<value>3</value>
<pass>replace</pass>
</stencil>
<blend><use>transparent</use></blend>
<alpha-test><use>transparent</use></alpha-test>

View file

@ -46,9 +46,6 @@ vec3 getSunIntensity();
void main()
{
float depth = texture(depth_tex, texCoord).r;
if (depth == 0.0) {
discard;
}
vec4 gbuffer0 = texture(gbuffer0_tex, texCoord);
vec2 gbuffer1 = texture(gbuffer1_tex, texCoord).rg;
vec4 gbuffer2 = texture(gbuffer2_tex, texCoord);