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

View file

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

View file

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

View file

@ -3,6 +3,11 @@
<name>Effects/HDR/smaa-edge-detection</name> <name>Effects/HDR/smaa-edge-detection</name>
<technique n="1"> <technique n="1">
<pass> <pass>
<stencil>
<function>always</function>
<value>1</value>
<pass>replace</pass>
</stencil>
<program> <program>
<vertex-shader>Shaders/HDR/smaa-edge-detection.vert</vertex-shader> <vertex-shader>Shaders/HDR/smaa-edge-detection.vert</vertex-shader>
<fragment-shader>Shaders/HDR/smaa-edge-detection.frag</fragment-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> <near>1.0</near>
<far>0.0</far> <far>0.0</far>
</depth> </depth>
<stencil>
<function>always</function>
<value>8</value>
<pass>replace</pass>
</stencil>
<texture-unit> <texture-unit>
<unit>0</unit> <unit>0</unit>
<type><use>texture[0]/type</use></type> <type><use>texture[0]/type</use></type>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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