HDR: Implement a logarithmic depth buffer
This commit is contained in:
parent
e2af9b603b
commit
73a55a71c5
58 changed files with 375 additions and 149 deletions
|
@ -15,7 +15,7 @@
|
||||||
: G-Buffer 1 (RGBA8) : Base Color : Metallic :
|
: G-Buffer 1 (RGBA8) : Base Color : Metallic :
|
||||||
: G-Buffer 2 (RGBA8) : Material specific params : Occlusion :
|
: G-Buffer 2 (RGBA8) : Material specific params : Occlusion :
|
||||||
: G-Buffer 3 (R11G11B10) : Emission : - :
|
: G-Buffer 3 (R11G11B10) : Emission : - :
|
||||||
: Depth/Stencil : DEPTH32F_STENCIL8 (Reversed depth) :
|
: Depth/Stencil : DEPTH24_STENCIL8 (Logarithmic depth) :
|
||||||
:........................:............:.........:...........:.............:
|
:........................:............:.........:...........:.............:
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
<type>2d</type>
|
<type>2d</type>
|
||||||
<width>screen</width>
|
<width>screen</width>
|
||||||
<height>screen</height>
|
<height>screen</height>
|
||||||
<format>depth32f-stencil8</format>
|
<format>depth24-stencil8</format>
|
||||||
</buffer>
|
</buffer>
|
||||||
|
|
||||||
<!-- HDR shading result -->
|
<!-- HDR shading result -->
|
||||||
|
@ -632,7 +632,7 @@
|
||||||
<type>scene</type>
|
<type>scene</type>
|
||||||
<effect-scheme>hdr-geometry</effect-scheme>
|
<effect-scheme>hdr-geometry</effect-scheme>
|
||||||
<clear-mask>depth stencil</clear-mask>
|
<clear-mask>depth stencil</clear-mask>
|
||||||
<clear-depth>0.0</clear-depth>
|
<clear-depth>1.0</clear-depth>
|
||||||
<cull-mask>0xfffff7ff</cull-mask>
|
<cull-mask>0xfffff7ff</cull-mask>
|
||||||
<clustered-shading>
|
<clustered-shading>
|
||||||
<tile-size>128</tile-size>
|
<tile-size>128</tile-size>
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<vertex-shader>Shaders/HDR/quad.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/quad.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/atmos_aerial_perspective.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/atmos_aerial_perspective.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/pos_from_depth.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/pos_from_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/atmos.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/atmos.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/atmos_spectral.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/atmos_spectral.glsl</fragment-shader>
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/quad_matrix.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/quad_matrix.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/debug_gbuffer_depth.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/debug_gbuffer_depth.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/pos_from_depth.glsl</fragment-shader>
|
|
||||||
</program>
|
</program>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>depth_tex</name>
|
<name>depth_tex</name>
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
<fragment-shader>Shaders/HDR/gtao.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/gtao.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/pos_from_depth.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/pos_from_depth.glsl</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
<uniform>
|
<uniform>
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
<fragment-shader>Shaders/HDR/shading_opaque.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/shading_opaque.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_unpack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_unpack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/pos_from_depth.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/pos_from_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/shading_opaque.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/shading_opaque.glsl</fragment-shader>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<fragment-shader>Shaders/HDR/water_shading.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/water_shading.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/pos_from_depth.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/pos_from_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/sun.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/sun.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
||||||
|
|
|
@ -68,11 +68,10 @@
|
||||||
<technique n="109">
|
<technique n="109">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
<write-mask>true</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
|
@ -84,7 +83,9 @@
|
||||||
<cull-face><use>cull-face</use></cull-face>
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/model_chrome.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/model_chrome.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/model_chrome.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/model_chrome.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
|
|
|
@ -288,11 +288,9 @@
|
||||||
<technique n="129">
|
<technique n="129">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
@ -307,11 +305,13 @@
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/cloud_static.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/cloud_static.vert</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/cloud_static_common.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/cloud_static_common.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/sun.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/sun.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/atmos_spectral.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/atmos_spectral.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/3dcloud.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/3dcloud.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/3dcloud_common.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/3dcloud_common.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/exposure.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/exposure.glsl</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
|
@ -350,6 +350,8 @@
|
||||||
<scheme>hdr-envmap</scheme>
|
<scheme>hdr-envmap</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<depth>
|
<depth>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<function>less</function>
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
|
|
@ -208,11 +208,9 @@
|
||||||
<technique n="129">
|
<technique n="129">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
@ -227,11 +225,13 @@
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/cloud_static.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/cloud_static.vert</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/cloud_static_common.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/cloud_static_common.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/sun.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/sun.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/atmos_spectral.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/atmos_spectral.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/3dcloud.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/3dcloud.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/3dcloud_common.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/3dcloud_common.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/exposure.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/exposure.glsl</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
|
@ -270,6 +270,8 @@
|
||||||
<scheme>hdr-envmap</scheme>
|
<scheme>hdr-envmap</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<depth>
|
<depth>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<function>less</function>
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
|
|
@ -416,11 +416,9 @@
|
||||||
<technique n="129">
|
<technique n="129">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
@ -435,11 +433,13 @@
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/cloud_static.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/cloud_static.vert</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/cloud_static_common.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/cloud_static_common.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/sun.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/sun.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/atmos_spectral.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/atmos_spectral.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/3dcloud.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/3dcloud.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/3dcloud_common.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/3dcloud_common.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/exposure.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/exposure.glsl</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
|
@ -478,6 +478,8 @@
|
||||||
<scheme>hdr-envmap</scheme>
|
<scheme>hdr-envmap</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<depth>
|
<depth>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<function>less</function>
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
|
|
@ -529,11 +529,9 @@
|
||||||
<technique n="129">
|
<technique n="129">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
@ -548,11 +546,13 @@
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/3dcloud.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/3dcloud.vert</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/3dcloud_common.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/3dcloud_common.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/sun.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/sun.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/atmos_spectral.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/atmos_spectral.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/3dcloud.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/3dcloud.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/3dcloud_common.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/3dcloud_common.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/aerial_perspective.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/exposure.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/exposure.glsl</fragment-shader>
|
||||||
<attribute>
|
<attribute>
|
||||||
|
@ -609,6 +609,8 @@
|
||||||
<scheme>hdr-envmap</scheme>
|
<scheme>hdr-envmap</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<depth>
|
<depth>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<function>less</function>
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
|
|
@ -97,11 +97,10 @@
|
||||||
<technique n="107">
|
<technique n="107">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
<write-mask>true</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
|
@ -121,7 +120,9 @@
|
||||||
<cull-face>back</cull-face>
|
<cull-face>back</cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/terrain_lfeat.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/terrain_lfeat.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/terrain_lfeat.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/terrain_lfeat.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||||
|
|
|
@ -52,11 +52,9 @@ It's kept for backwards compatibility and should not be used on new projects.
|
||||||
<technique n="127">
|
<technique n="127">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
@ -83,10 +81,12 @@ It's kept for backwards compatibility and should not be used on new projects.
|
||||||
<cull-face><use>cull-face</use></cull-face>
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/model_transparent.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/model_transparent.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/model_transparent.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/model_transparent.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/shading_transparent.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/shading_transparent.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/surface.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/surface.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/ibl.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/ibl.glsl</fragment-shader>
|
||||||
|
|
|
@ -1313,11 +1313,10 @@ please see Docs/README.model-combined.eff for documentation
|
||||||
<technique n="108">
|
<technique n="108">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
<write-mask>true</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
|
@ -1343,7 +1342,9 @@ please see Docs/README.model-combined.eff for documentation
|
||||||
<cull-face>back</cull-face>
|
<cull-face>back</cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/model_combined.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/model_combined.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/model_combined.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/model_combined.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
||||||
|
|
|
@ -646,11 +646,10 @@
|
||||||
<technique n="109">
|
<technique n="109">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
<write-mask>true</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
|
@ -670,7 +669,9 @@
|
||||||
<cull-face><use>cull-face</use></cull-face>
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/model_default.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/model_default.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/model_default.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/model_default.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||||
|
|
|
@ -54,11 +54,9 @@
|
||||||
<technique n="128">
|
<technique n="128">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
@ -112,11 +110,13 @@
|
||||||
<cull-face><use>cull-face</use></cull-face>
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/model_pbr_transparent.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/model_pbr_transparent.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/model_pbr_transparent.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/model_pbr_transparent.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/shading_transparent.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/shading_transparent.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/surface.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/surface.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/ibl.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/ibl.glsl</fragment-shader>
|
||||||
|
|
|
@ -33,11 +33,10 @@
|
||||||
<technique n="109">
|
<technique n="109">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
<write-mask>true</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
|
@ -85,7 +84,9 @@
|
||||||
<cull-face><use>cull-face</use></cull-face>
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/model_pbr.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/model_pbr.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/model_pbr.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/model_pbr.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
||||||
|
|
|
@ -48,11 +48,9 @@
|
||||||
<technique n="128">
|
<technique n="128">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
|
@ -79,10 +77,12 @@
|
||||||
<cull-face><use>cull-face</use></cull-face>
|
<cull-face><use>cull-face</use></cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/model_transparent.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/model_transparent.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/model_transparent.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/model_transparent.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/shading_transparent.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/shading_transparent.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/surface.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/surface.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/ibl.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/ibl.glsl</fragment-shader>
|
||||||
|
|
|
@ -1412,12 +1412,11 @@
|
||||||
<technique n="108">
|
<technique n="108">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
<depth>
|
||||||
<depth>
|
<enabled>true</enabled>
|
||||||
<function>gequal</function>
|
<function>less</function>
|
||||||
<near>1.0</near>
|
<write-mask>true</write-mask>
|
||||||
<far>0.0</far>
|
</depth>
|
||||||
</depth>
|
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
<value>8</value>
|
<value>8</value>
|
||||||
|
@ -1442,7 +1441,9 @@
|
||||||
<cull-face>back</cull-face>
|
<cull-face>back</cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/model_combined.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/model_combined.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/model_combined.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/model_combined.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
||||||
|
|
|
@ -890,11 +890,10 @@
|
||||||
<technique n="108">
|
<technique n="108">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
<write-mask>true</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
|
@ -926,7 +925,9 @@
|
||||||
<cull-face>back</cull-face>
|
<cull-face>back</cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/terrain_runway.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/terrain_runway.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/terrain_runway.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/terrain_runway.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
||||||
|
|
|
@ -307,11 +307,9 @@
|
||||||
<technique n="129">
|
<technique n="129">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>greater</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<cull-face>back</cull-face>
|
<cull-face>back</cull-face>
|
||||||
|
@ -354,6 +352,8 @@
|
||||||
<scheme>hdr-envmap</scheme>
|
<scheme>hdr-envmap</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<depth>
|
<depth>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<function>less</function>
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<cull-face>back</cull-face>
|
<cull-face>back</cull-face>
|
||||||
|
|
|
@ -1715,11 +1715,10 @@
|
||||||
<technique n="109">
|
<technique n="109">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
<write-mask>true</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
|
@ -1739,7 +1738,9 @@
|
||||||
<cull-face>back</cull-face>
|
<cull-face>back</cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/terrain_default.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/terrain_default.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/terrain_default.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/terrain_default.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||||
|
@ -1761,6 +1762,11 @@
|
||||||
<technique n="139">
|
<technique n="139">
|
||||||
<scheme>hdr-envmap</scheme>
|
<scheme>hdr-envmap</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
|
<depth>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
<function>less</function>
|
||||||
|
<write-mask>true</write-mask>
|
||||||
|
</depth>
|
||||||
<texture-unit>
|
<texture-unit>
|
||||||
<unit>0</unit>
|
<unit>0</unit>
|
||||||
<type><use>texture[0]/type</use></type>
|
<type><use>texture[0]/type</use></type>
|
||||||
|
|
|
@ -60,11 +60,9 @@
|
||||||
<technique n="129">
|
<technique n="129">
|
||||||
<scheme>hdr-forward</scheme>
|
<scheme>hdr-forward</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
|
||||||
<write-mask>false</write-mask>
|
<write-mask>false</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<blend>1</blend>
|
<blend>1</blend>
|
||||||
|
@ -72,10 +70,12 @@
|
||||||
<cull-face>back</cull-face>
|
<cull-face>back</cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/text.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/text.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/aerial_perspective.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/text.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/text.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/math.glsl</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/shading_transparent.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/shading_transparent.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/surface.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/surface.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/ibl.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/ibl.glsl</fragment-shader>
|
||||||
|
|
|
@ -1880,11 +1880,10 @@
|
||||||
<property>/sim/rendering/random-vegetation</property>
|
<property>/sim/rendering/random-vegetation</property>
|
||||||
</predicate>
|
</predicate>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
<write-mask>true</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
|
@ -1905,7 +1904,9 @@
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/tree.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/tree.vert</vertex-shader>
|
||||||
<vertex-shader>Shaders/HDR/noise.glsl</vertex-shader>
|
<vertex-shader>Shaders/HDR/noise.glsl</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/tree.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/tree.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||||
|
|
|
@ -1496,11 +1496,10 @@
|
||||||
<technique n="108">
|
<technique n="108">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
<write-mask>true</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
|
@ -1551,7 +1550,9 @@
|
||||||
</texture-unit>
|
</texture-unit>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/water.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/water.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/water.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/water.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normalmap.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||||
|
|
|
@ -1877,11 +1877,10 @@
|
||||||
<technique n="109">
|
<technique n="109">
|
||||||
<scheme>hdr-geometry</scheme>
|
<scheme>hdr-geometry</scheme>
|
||||||
<pass>
|
<pass>
|
||||||
<!-- Reverse floating point depth buffer -->
|
|
||||||
<depth>
|
<depth>
|
||||||
<function>gequal</function>
|
<enabled>true</enabled>
|
||||||
<near>1.0</near>
|
<function>less</function>
|
||||||
<far>0.0</far>
|
<write-mask>true</write-mask>
|
||||||
</depth>
|
</depth>
|
||||||
<stencil>
|
<stencil>
|
||||||
<function>always</function>
|
<function>always</function>
|
||||||
|
@ -1949,7 +1948,9 @@
|
||||||
<cull-face>back</cull-face>
|
<cull-face>back</cull-face>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/terrain_default.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/terrain_default.vert</vertex-shader>
|
||||||
|
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/ws30.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/ws30.frag</fragment-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer_pack.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/normal_encoding.glsl</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
<fragment-shader>Shaders/HDR/color.glsl</fragment-shader>
|
||||||
|
|
|
@ -2,10 +2,14 @@
|
||||||
|
|
||||||
layout(location = 0) out vec4 fragColor;
|
layout(location = 0) out vec4 fragColor;
|
||||||
|
|
||||||
|
in float flogz;
|
||||||
|
|
||||||
// 3dcloud_common.frag
|
// 3dcloud_common.frag
|
||||||
vec4 cloud_common_frag();
|
vec4 cloud_common_frag();
|
||||||
// exposure.glsl
|
// exposure.glsl
|
||||||
vec3 apply_exposure(vec3 color);
|
vec3 apply_exposure(vec3 color);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -16,4 +20,5 @@ void main()
|
||||||
color.rgb = apply_exposure(color.rgb);
|
color.rgb = apply_exposure(color.rgb);
|
||||||
|
|
||||||
fragColor = color;
|
fragColor = color;
|
||||||
|
gl_FragDepth = logdepth_encode(flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,22 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
|
out float flogz;
|
||||||
out vec4 ap_color;
|
out vec4 ap_color;
|
||||||
|
|
||||||
// 3dcloud_common.vert
|
// 3dcloud_common.vert
|
||||||
void cloud_common_vert(out vec4 vs_pos, out vec4 ws_pos);
|
void cloud_common_vert(out vec4 vs_pos, out vec4 ws_pos);
|
||||||
// aerial_perspective.glsl
|
// aerial_perspective.glsl
|
||||||
vec4 get_aerial_perspective(vec2 coord, float depth);
|
vec4 get_aerial_perspective(vec2 coord, float depth);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 vs_pos, ws_pos;
|
vec4 vs_pos, ws_pos;
|
||||||
cloud_common_vert(vs_pos, ws_pos);
|
cloud_common_vert(vs_pos, ws_pos);
|
||||||
|
|
||||||
|
flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
|
|
||||||
// Perspective division and scale to [0, 1] to get the screen position
|
// Perspective division and scale to [0, 1] to get the screen position
|
||||||
// of the vertex.
|
// of the vertex.
|
||||||
vec2 coord = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5;
|
vec2 coord = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5;
|
||||||
|
|
|
@ -1,17 +1,22 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
|
out float flogz;
|
||||||
out vec4 ap_color;
|
out vec4 ap_color;
|
||||||
|
|
||||||
// cloud_static_common.vert
|
// cloud_static_common.vert
|
||||||
void cloud_static_common_vert(out vec4 vs_pos, out vec4 ws_pos);
|
void cloud_static_common_vert(out vec4 vs_pos, out vec4 ws_pos);
|
||||||
// aerial_perspective.glsl
|
// aerial_perspective.glsl
|
||||||
vec4 get_aerial_perspective(vec2 coord, float depth);
|
vec4 get_aerial_perspective(vec2 coord, float depth);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 vs_pos, ws_pos;
|
vec4 vs_pos, ws_pos;
|
||||||
cloud_static_common_vert(vs_pos, ws_pos);
|
cloud_static_common_vert(vs_pos, ws_pos);
|
||||||
|
|
||||||
|
flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
|
|
||||||
// Perspective division and scale to [0, 1] to get the screen position
|
// Perspective division and scale to [0, 1] to get the screen position
|
||||||
// of the vertex.
|
// of the vertex.
|
||||||
vec2 coord = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5;
|
vec2 coord = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5;
|
||||||
|
|
|
@ -6,11 +6,9 @@ in vec2 texcoord;
|
||||||
|
|
||||||
uniform sampler2D depth_tex;
|
uniform sampler2D depth_tex;
|
||||||
|
|
||||||
// pos_from_depth.glsl
|
|
||||||
float linearize_depth(float depth);
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
float depth = texture(depth_tex, texcoord).r;
|
float depth = texture(depth_tex, texcoord).r;
|
||||||
fragColor = vec4(vec3(linearize_depth(depth)), 1.0);
|
// Display depth as is, no linearization
|
||||||
|
fragColor = vec4(vec3(depth), 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,9 @@ void main()
|
||||||
{
|
{
|
||||||
float depth = textureLod(depth_tex, texcoord, 0.0).r;
|
float depth = textureLod(depth_tex, texcoord, 0.0).r;
|
||||||
// Ignore the background
|
// Ignore the background
|
||||||
if (depth == 0.0) {
|
if (depth == 1.0) {
|
||||||
fragColor = 0.0;
|
fragColor = 1.0;
|
||||||
discard;
|
return;
|
||||||
}
|
}
|
||||||
// Slightly push the depth towards the camera to avoid imprecision artifacts
|
// Slightly push the depth towards the camera to avoid imprecision artifacts
|
||||||
depth = clamp(depth * 1.00001, 0.0, 1.0);
|
depth = clamp(depth * 1.00001, 0.0, 1.0);
|
||||||
|
@ -64,7 +64,7 @@ void main()
|
||||||
// 1 / tan(fovy / 2), so we can use that directly.
|
// 1 / tan(fovy / 2), so we can use that directly.
|
||||||
// z_distance is the distance from the camera to the fragment, which is
|
// z_distance is the distance from the camera to the fragment, which is
|
||||||
// just the positive z component of the view space fragment position.
|
// just the positive z component of the view space fragment position.
|
||||||
float radius_pixels = world_radius * (fg_ProjectionMatrix[1][1] / abs(P.z))
|
float radius_pixels = world_radius * (fg_ProjectionMatrix[1][1] / abs(P.z))
|
||||||
* fg_Viewport.w * 0.5;
|
* fg_Viewport.w * 0.5;
|
||||||
|
|
||||||
float visibility = 0.0;
|
float visibility = 0.0;
|
||||||
|
@ -95,7 +95,7 @@ void main()
|
||||||
|
|
||||||
vec2 s_texcoord1 = texcoord - s_offset;
|
vec2 s_texcoord1 = texcoord - s_offset;
|
||||||
float s_depth1 = textureLod(depth_tex, s_texcoord1, 0.0).r;
|
float s_depth1 = textureLod(depth_tex, s_texcoord1, 0.0).r;
|
||||||
if (s_depth1 == 0.0) {
|
if (s_depth1 == 1.0) {
|
||||||
// Skip background
|
// Skip background
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ void main()
|
||||||
|
|
||||||
vec2 s_texcoord2 = texcoord + s_offset;
|
vec2 s_texcoord2 = texcoord + s_offset;
|
||||||
float s_depth2 = textureLod(depth_tex, s_texcoord2, 0.0).r;
|
float s_depth2 = textureLod(depth_tex, s_texcoord2, 0.0).r;
|
||||||
if (s_depth2 == 0.0) {
|
if (s_depth2 == 1.0) {
|
||||||
// Skip background
|
// Skip background
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
83
Shaders/HDR/logarithmic_depth.glsl
Normal file
83
Shaders/HDR/logarithmic_depth.glsl
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Logarithmic depth buffer utility functions
|
||||||
|
*
|
||||||
|
* The HDR pipeline uses a logarithmic depth buffer to avoid Z-fighting and
|
||||||
|
* depth precision issues. This method is compatible with all OpenGL 3.3
|
||||||
|
* hardware since it does not require any fancy depth reversal tricks.
|
||||||
|
*
|
||||||
|
* The main disadvantage is that we lose the early depth test optimization. This
|
||||||
|
* is not a problem for us because we use deferred rendering, so the fragment
|
||||||
|
* shaders that run on the actual geometry are very lightweight.
|
||||||
|
*
|
||||||
|
* Sources:
|
||||||
|
* https://outerra.blogspot.com/2009/08/logarithmic-z-buffer.html
|
||||||
|
* https://outerra.blogspot.com/2012/11/maximizing-depth-buffer-range-and.html
|
||||||
|
* https://outerra.blogspot.com/2013/07/logarithmic-depth-buffer-optimizations.html
|
||||||
|
* https://io7m.github.io/r2/documentation/p2s24.xhtml
|
||||||
|
*/
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
uniform float fg_Fcoef;
|
||||||
|
uniform vec2 fg_NearFar;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Prepare a view space depth value for encoding. Normal usage involves calling
|
||||||
|
* this function in the vertex shader, after writing to gl_Position. The z value
|
||||||
|
* corresponds to gl_Position.w (if using perspective projection), or the
|
||||||
|
* negated view space depth.
|
||||||
|
* See logdepth_encode().
|
||||||
|
*/
|
||||||
|
float logdepth_prepare_vs_depth(float z)
|
||||||
|
{
|
||||||
|
return 1.0 + z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Encodes a given depth value obtained with logdepth_prepare_vs_depth() into
|
||||||
|
* logarithmic depth. The result is used in the fragment shader to write to
|
||||||
|
* gl_FragDepth.
|
||||||
|
*/
|
||||||
|
float logdepth_encode(float z)
|
||||||
|
{
|
||||||
|
float half_fcoef = fg_Fcoef * 0.5;
|
||||||
|
float clamped_z = max(1e-6, z);
|
||||||
|
return log2(clamped_z) * half_fcoef;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is an alternative way of encoding a depth value obtained with
|
||||||
|
* logdepth_prepare_vs_depth() into logarithmic depth in the vertex shader
|
||||||
|
* without writing to gl_FragDepth in the fragment shader. The result
|
||||||
|
* corresponds to gl_Position.z
|
||||||
|
*
|
||||||
|
* The disadvantage is that depth will not be interpolated in a
|
||||||
|
* perspectively-correct way, but it will work okay for very finely tessellated
|
||||||
|
* geometry.
|
||||||
|
*/
|
||||||
|
float logdepth_encode_no_perspective(float z)
|
||||||
|
{
|
||||||
|
float clamped_z = max(1e-6, z);
|
||||||
|
return log2(clamped_z) * fg_Fcoef - 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Decode a view space depth value that was encoded with the functions above.
|
||||||
|
* z corresponds to the [0,1] depth buffer value.
|
||||||
|
* NOTE: The resulting depth value is positive, so it must be negated to yield
|
||||||
|
* a conventional negative view space depth value.
|
||||||
|
*/
|
||||||
|
float logdepth_decode(float z)
|
||||||
|
{
|
||||||
|
float half_fcoef = fg_Fcoef * 0.5;
|
||||||
|
float exponent = z / half_fcoef;
|
||||||
|
return pow(2.0, exponent) - 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Same as logdepth_decode(), but returns the normalized view-space depth
|
||||||
|
* in the [0,1] range.
|
||||||
|
*/
|
||||||
|
float logdepth_decode_normalized(float z)
|
||||||
|
{
|
||||||
|
return logdepth_decode(z) / fg_NearFar.y;
|
||||||
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
in vec3 vertex_normal;
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
|
vec3 vertex_normal;
|
||||||
|
} fs_in;
|
||||||
|
|
||||||
const float CHROME_METALLIC = 1.0;
|
const float CHROME_METALLIC = 1.0;
|
||||||
const float CHROME_ROUGHNESS = 0.1;
|
const float CHROME_ROUGHNESS = 0.1;
|
||||||
|
@ -8,9 +11,12 @@ const float CHROME_ROUGHNESS = 0.1;
|
||||||
// gbuffer_pack.glsl
|
// gbuffer_pack.glsl
|
||||||
void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
||||||
float occlusion, vec3 emissive, uint mat_id);
|
float occlusion, vec3 emissive, uint mat_id);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec3 N = normalize(vertex_normal);
|
vec3 N = normalize(fs_in.vertex_normal);
|
||||||
gbuffer_pack(N, vec3(1.0), CHROME_METALLIC, CHROME_ROUGHNESS, 1.0, vec3(0.0), 3u);
|
gbuffer_pack(N, vec3(1.0), CHROME_METALLIC, CHROME_ROUGHNESS, 1.0, vec3(0.0), 3u);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,20 @@
|
||||||
layout(location = 0) in vec4 pos;
|
layout(location = 0) in vec4 pos;
|
||||||
layout(location = 1) in vec3 normal;
|
layout(location = 1) in vec3 normal;
|
||||||
|
|
||||||
out vec3 vertex_normal;
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
|
vec3 vertex_normal;
|
||||||
|
} vs_out;
|
||||||
|
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
uniform mat3 osg_NormalMatrix;
|
uniform mat3 osg_NormalMatrix;
|
||||||
|
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
vertex_normal = osg_NormalMatrix * normal;
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
|
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec3 view_vector;
|
vec3 view_vector;
|
||||||
|
@ -20,6 +21,8 @@ void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
||||||
vec3 eotf_inverse_sRGB(vec3 srgb);
|
vec3 eotf_inverse_sRGB(vec3 srgb);
|
||||||
// normalmap.glsl
|
// normalmap.glsl
|
||||||
vec3 perturb_normal(vec3 N, vec3 V, vec2 texcoord);
|
vec3 perturb_normal(vec3 N, vec3 V, vec2 texcoord);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -32,4 +35,5 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
gbuffer_pack(N, color, metallic, roughness, 1.0, vec3(0.0), 3u);
|
gbuffer_pack(N, color, metallic, roughness, 1.0, vec3(0.0), 3u);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ layout(location = 1) in vec3 normal;
|
||||||
layout(location = 3) in vec4 multitexcoord0;
|
layout(location = 3) in vec4 multitexcoord0;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec3 view_vector;
|
vec3 view_vector;
|
||||||
|
@ -17,9 +18,13 @@ uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
uniform mat3 osg_NormalMatrix;
|
uniform mat3 osg_NormalMatrix;
|
||||||
uniform mat4 fg_TextureMatrix;
|
uniform mat4 fg_TextureMatrix;
|
||||||
|
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
||||||
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
||||||
vs_out.view_vector = (osg_ModelViewMatrix * pos).xyz;
|
vs_out.view_vector = (osg_ModelViewMatrix * pos).xyz;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec4 material_color;
|
vec4 material_color;
|
||||||
|
@ -16,6 +17,8 @@ void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
||||||
float occlusion, vec3 emissive, uint mat_id);
|
float occlusion, vec3 emissive, uint mat_id);
|
||||||
// color.glsl
|
// color.glsl
|
||||||
vec3 eotf_inverse_sRGB(vec3 srgb);
|
vec3 eotf_inverse_sRGB(vec3 srgb);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -25,4 +28,5 @@ void main()
|
||||||
vec3 N = normalize(fs_in.vertex_normal);
|
vec3 N = normalize(fs_in.vertex_normal);
|
||||||
|
|
||||||
gbuffer_pack(N, color, DEFAULT_METALLIC, DEFAULT_ROUGHNESS, 1.0, vec3(0.0), 3u);
|
gbuffer_pack(N, color, DEFAULT_METALLIC, DEFAULT_ROUGHNESS, 1.0, vec3(0.0), 3u);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ layout(location = 2) in vec4 vertex_color;
|
||||||
layout(location = 3) in vec4 multitexcoord0;
|
layout(location = 3) in vec4 multitexcoord0;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec4 material_color;
|
vec4 material_color;
|
||||||
|
@ -22,9 +23,13 @@ uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
uniform mat3 osg_NormalMatrix;
|
uniform mat3 osg_NormalMatrix;
|
||||||
uniform mat4 fg_TextureMatrix;
|
uniform mat4 fg_TextureMatrix;
|
||||||
|
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
||||||
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec3 view_vector;
|
vec3 view_vector;
|
||||||
|
@ -22,6 +23,8 @@ void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
||||||
vec3 eotf_inverse_sRGB(vec3 srgb);
|
vec3 eotf_inverse_sRGB(vec3 srgb);
|
||||||
// normalmap.glsl
|
// normalmap.glsl
|
||||||
vec3 perturb_normal(vec3 N, vec3 V, vec2 texcoord);
|
vec3 perturb_normal(vec3 N, vec3 V, vec2 texcoord);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -38,4 +41,5 @@ void main()
|
||||||
N = perturb_normal(N, fs_in.view_vector, fs_in.texcoord);
|
N = perturb_normal(N, fs_in.view_vector, fs_in.texcoord);
|
||||||
|
|
||||||
gbuffer_pack(N, base_color, metallic, roughness, occlusion, emissive, 3u);
|
gbuffer_pack(N, base_color, metallic, roughness, occlusion, emissive, 3u);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ layout(location = 1) in vec3 normal;
|
||||||
layout(location = 3) in vec4 multitexcoord0;
|
layout(location = 3) in vec4 multitexcoord0;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec3 view_vector;
|
vec3 view_vector;
|
||||||
|
@ -17,9 +18,13 @@ uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
uniform mat3 osg_NormalMatrix;
|
uniform mat3 osg_NormalMatrix;
|
||||||
uniform mat4 fg_TextureMatrix;
|
uniform mat4 fg_TextureMatrix;
|
||||||
|
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
||||||
if (flip_vertically)
|
if (flip_vertically)
|
||||||
vs_out.texcoord.y = 1.0 - vs_out.texcoord.y;
|
vs_out.texcoord.y = 1.0 - vs_out.texcoord.y;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
layout(location = 0) out vec4 fragColor;
|
layout(location = 0) out vec4 fragColor;
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec3 view_vector;
|
vec3 view_vector;
|
||||||
|
@ -32,6 +33,8 @@ vec3 eval_lights_transparent(
|
||||||
mat4 view_matrix_inverse);
|
mat4 view_matrix_inverse);
|
||||||
// normalmap.glsl
|
// normalmap.glsl
|
||||||
vec3 perturb_normal(vec3 N, vec3 V, vec2 texcoord);
|
vec3 perturb_normal(vec3 N, vec3 V, vec2 texcoord);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -58,4 +61,5 @@ void main()
|
||||||
fs_in.view_vector, N, V, uv, fs_in.ap_color, osg_ViewMatrixInverse);
|
fs_in.view_vector, N, V, uv, fs_in.ap_color, osg_ViewMatrixInverse);
|
||||||
|
|
||||||
fragColor = vec4(color, base_color.a);
|
fragColor = vec4(color, base_color.a);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ layout(location = 1) in vec3 normal;
|
||||||
layout(location = 3) in vec4 multitexcoord0;
|
layout(location = 3) in vec4 multitexcoord0;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec3 view_vector;
|
vec3 view_vector;
|
||||||
|
@ -20,10 +21,13 @@ uniform mat4 fg_TextureMatrix;
|
||||||
|
|
||||||
// aerial_perspective.glsl
|
// aerial_perspective.glsl
|
||||||
vec4 get_aerial_perspective(vec2 coord, float depth);
|
vec4 get_aerial_perspective(vec2 coord, float depth);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
||||||
if (flip_vertically)
|
if (flip_vertically)
|
||||||
vs_out.texcoord.y = 1.0 - vs_out.texcoord.y;
|
vs_out.texcoord.y = 1.0 - vs_out.texcoord.y;
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
layout(location = 0) out vec4 fragColor;
|
layout(location = 0) out vec4 fragColor;
|
||||||
|
|
||||||
in vec3 vN;
|
in VS_OUT {
|
||||||
in vec3 vP;
|
float flogz;
|
||||||
in vec2 texcoord;
|
vec2 texcoord;
|
||||||
in vec4 material_color;
|
vec3 vertex_normal;
|
||||||
in vec4 ap_color;
|
vec3 view_vector;
|
||||||
|
vec4 material_color;
|
||||||
|
vec4 ap_color;
|
||||||
|
} fs_in;
|
||||||
|
|
||||||
uniform sampler2D color_tex;
|
uniform sampler2D color_tex;
|
||||||
|
|
||||||
|
@ -23,20 +26,23 @@ vec3 eval_lights_transparent(
|
||||||
vec3 base_color, float metallic, float roughness, float occlusion,
|
vec3 base_color, float metallic, float roughness, float occlusion,
|
||||||
vec3 emissive, vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
|
vec3 emissive, vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
|
||||||
mat4 view_matrix_inverse);
|
mat4 view_matrix_inverse);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 texel = texture(color_tex, texcoord);
|
vec4 texel = texture(color_tex, fs_in.texcoord);
|
||||||
vec3 base_color = eotf_inverse_sRGB(texel.rgb) * material_color.rgb;
|
vec3 base_color = eotf_inverse_sRGB(texel.rgb) * fs_in.material_color.rgb;
|
||||||
float alpha = material_color.a * texel.a;
|
float alpha = fs_in.material_color.a * texel.a;
|
||||||
|
|
||||||
vec3 N = normalize(vN);
|
vec3 N = normalize(fs_in.vertex_normal);
|
||||||
vec3 V = normalize(-vP);
|
vec3 V = normalize(-fs_in.view_vector);
|
||||||
vec2 uv = (gl_FragCoord.xy - fg_Viewport.xy) / fg_Viewport.zw;
|
vec2 uv = (gl_FragCoord.xy - fg_Viewport.xy) / fg_Viewport.zw;
|
||||||
|
|
||||||
vec3 color = eval_lights_transparent(
|
vec3 color = eval_lights_transparent(
|
||||||
base_color, TRANSPARENT_METALLIC, TRANSPARENT_ROUGHNESS, 1.0, vec3(0.0),
|
base_color, TRANSPARENT_METALLIC, TRANSPARENT_ROUGHNESS, 1.0, vec3(0.0),
|
||||||
vP, N, V, uv, ap_color, osg_ViewMatrixInverse);
|
fs_in.view_vector, N, V, uv, fs_in.ap_color, osg_ViewMatrixInverse);
|
||||||
|
|
||||||
fragColor = vec4(color, alpha);
|
fragColor = vec4(color, alpha);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,14 @@ layout(location = 1) in vec3 normal;
|
||||||
layout(location = 2) in vec4 vertex_color;
|
layout(location = 2) in vec4 vertex_color;
|
||||||
layout(location = 3) in vec4 multitexcoord0;
|
layout(location = 3) in vec4 multitexcoord0;
|
||||||
|
|
||||||
out vec3 vN;
|
out VS_OUT {
|
||||||
out vec3 vP;
|
float flogz;
|
||||||
out vec2 texcoord;
|
vec2 texcoord;
|
||||||
out vec4 material_color;
|
vec3 vertex_normal;
|
||||||
out vec4 ap_color;
|
vec3 view_vector;
|
||||||
|
vec4 material_color;
|
||||||
|
vec4 ap_color;
|
||||||
|
} vs_out;
|
||||||
|
|
||||||
uniform int color_mode;
|
uniform int color_mode;
|
||||||
uniform vec4 material_diffuse;
|
uniform vec4 material_diffuse;
|
||||||
|
@ -25,28 +28,31 @@ uniform mat4 fg_TextureMatrix;
|
||||||
|
|
||||||
// aerial_perspective.glsl
|
// aerial_perspective.glsl
|
||||||
vec4 get_aerial_perspective(vec2 coord, float depth);
|
vec4 get_aerial_perspective(vec2 coord, float depth);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
vN = osg_NormalMatrix * normal;
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
vP = (osg_ModelViewMatrix * pos).xyz;
|
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
||||||
texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
vs_out.view_vector = (osg_ModelViewMatrix * pos).xyz;
|
||||||
|
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
||||||
|
|
||||||
// Legacy material handling
|
// Legacy material handling
|
||||||
if (color_mode == MODE_DIFFUSE)
|
if (color_mode == MODE_DIFFUSE)
|
||||||
material_color = vertex_color;
|
vs_out.material_color = vertex_color;
|
||||||
else if (color_mode == MODE_AMBIENT_AND_DIFFUSE)
|
else if (color_mode == MODE_AMBIENT_AND_DIFFUSE)
|
||||||
material_color = vertex_color;
|
vs_out.material_color = vertex_color;
|
||||||
else
|
else
|
||||||
material_color = material_diffuse;
|
vs_out.material_color = material_diffuse;
|
||||||
// Super hack: if diffuse material alpha is less than 1, assume a
|
// Super hack: if diffuse material alpha is less than 1, assume a
|
||||||
// transparency animation is at work
|
// transparency animation is at work
|
||||||
if (material_diffuse.a < 1.0)
|
if (material_diffuse.a < 1.0)
|
||||||
material_color.a = material_diffuse.a;
|
vs_out.material_color.a = material_diffuse.a;
|
||||||
else
|
else
|
||||||
material_color.a = vertex_color.a;
|
vs_out.material_color.a = vertex_color.a;
|
||||||
|
|
||||||
vec2 coord = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5;
|
vec2 coord = (gl_Position.xy / gl_Position.w) * 0.5 + 0.5;
|
||||||
ap_color = get_aerial_perspective(coord, length(vP));
|
vs_out.ap_color = get_aerial_perspective(coord, length(vs_out.view_vector));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,11 @@ uniform vec2 fg_NearFar;
|
||||||
uniform mat4 fg_ViewMatrixInverse;
|
uniform mat4 fg_ViewMatrixInverse;
|
||||||
uniform mat4 fg_ProjectionMatrixInverse;
|
uniform mat4 fg_ProjectionMatrixInverse;
|
||||||
|
|
||||||
|
uniform vec2 fg_FOVScale;
|
||||||
|
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_decode(float z);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Reconstruct the view space position from the depth buffer. Mostly used by
|
* Reconstruct the view space position from the depth buffer. Mostly used by
|
||||||
* fullscreen post-processing shaders.
|
* fullscreen post-processing shaders.
|
||||||
|
@ -13,22 +18,12 @@ uniform mat4 fg_ProjectionMatrixInverse;
|
||||||
* Given a 2D screen UV in the range [0,1] and a depth value from the depth
|
* Given a 2D screen UV in the range [0,1] and a depth value from the depth
|
||||||
* buffer, also in the [0,1] range, return the view space position.
|
* buffer, also in the [0,1] range, return the view space position.
|
||||||
*/
|
*/
|
||||||
vec3 get_view_space_from_depth(vec2 uv, float depth, mat4 proj_matrix_inverse)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* We are using a reversed depth buffer. 1.0 corresponds to the near plane
|
|
||||||
* and 0.0 to the far plane. We convert this back to NDC space by doing
|
|
||||||
* 1.0 - depth to undo the depth reversal
|
|
||||||
* 2.0 * depth - 1.0 to transform it to NDC space [-1,1]
|
|
||||||
*/
|
|
||||||
vec4 ndc_p = vec4(uv * 2.0 - 1.0, 1.0 - depth * 2.0, 1.0);
|
|
||||||
vec4 vs_p = proj_matrix_inverse * ndc_p;
|
|
||||||
return vs_p.xyz / vs_p.w;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 get_view_space_from_depth(vec2 uv, float depth)
|
vec3 get_view_space_from_depth(vec2 uv, float depth)
|
||||||
{
|
{
|
||||||
return get_view_space_from_depth(uv, depth, fg_ProjectionMatrixInverse);
|
float vs_depth = logdepth_decode(depth);
|
||||||
|
vec2 half_ndc_pos = vec2(0.5) - uv;
|
||||||
|
vec3 vs_pos = vec3(half_ndc_pos * fg_FOVScale * (-vs_depth), -vs_depth);
|
||||||
|
return vs_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 get_view_space_from_depth(vec2 uv)
|
vec3 get_view_space_from_depth(vec2 uv)
|
||||||
|
@ -46,11 +41,3 @@ vec3 get_world_space_from_depth(vec2 uv)
|
||||||
{
|
{
|
||||||
return get_world_space_from_depth(uv, texture(depth_tex, uv).r);
|
return get_world_space_from_depth(uv, texture(depth_tex, uv).r);
|
||||||
}
|
}
|
||||||
|
|
||||||
float linearize_depth(float depth)
|
|
||||||
{
|
|
||||||
// Undo the depth reversal
|
|
||||||
float z = 1.0 - depth;
|
|
||||||
return 2.0 * fg_NearFar.x
|
|
||||||
/ (fg_NearFar.y + fg_NearFar.x - z * (fg_NearFar.y - fg_NearFar.x));
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ const vec2 UV_FACTOR = vec2(0.5, 0.5);
|
||||||
// math.glsl
|
// math.glsl
|
||||||
float saturate(float x);
|
float saturate(float x);
|
||||||
float interleaved_gradient_noise(vec2 uv);
|
float interleaved_gradient_noise(vec2 uv);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_decode_normalized(float z);
|
||||||
|
|
||||||
float sample_shadow_map(vec2 coord, vec2 offset, float depth)
|
float sample_shadow_map(vec2 coord, vec2 offset, float depth)
|
||||||
{
|
{
|
||||||
|
@ -164,8 +166,9 @@ float get_contact_shadow(vec3 P, vec3 L, mat4 projection_matrix)
|
||||||
float t = (float(i) + dither) * dt;
|
float t = (float(i) + dither) * dt;
|
||||||
vec3 x_t = ray_start + ray_dir * t;
|
vec3 x_t = ray_start + ray_dir * t;
|
||||||
|
|
||||||
// Sample the depth buffer. It's reversed, so invert it
|
// Sample the depth buffer
|
||||||
float z = 1.0 - texture(depth_tex, x_t.xy).r;
|
float z = texture(depth_tex, x_t.xy).r;
|
||||||
|
z = logdepth_decode_normalized(z);
|
||||||
// Depth difference between the current ray sample depth and the actual
|
// Depth difference between the current ray sample depth and the actual
|
||||||
// camera depth contained in the depth buffer.
|
// camera depth contained in the depth buffer.
|
||||||
float dz = x_t.z - z - sss_depth_bias;
|
float dz = x_t.z - z - sss_depth_bias;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec2 orthophoto_texcoord;
|
vec2 orthophoto_texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
|
@ -19,6 +20,8 @@ void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
||||||
float occlusion, vec3 emissive, uint mat_id);
|
float occlusion, vec3 emissive, uint mat_id);
|
||||||
// color.glsl
|
// color.glsl
|
||||||
vec3 eotf_inverse_sRGB(vec3 srgb);
|
vec3 eotf_inverse_sRGB(vec3 srgb);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -35,4 +38,5 @@ void main()
|
||||||
vec3 N = normalize(fs_in.vertex_normal);
|
vec3 N = normalize(fs_in.vertex_normal);
|
||||||
|
|
||||||
gbuffer_pack(N, color, TERRAIN_METALLIC, TERRAIN_ROUGHNESS, 1.0, vec3(0.0), 3u);
|
gbuffer_pack(N, color, TERRAIN_METALLIC, TERRAIN_ROUGHNESS, 1.0, vec3(0.0), 3u);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ layout(location = 3) in vec4 multitexcoord0;
|
||||||
layout(location = 5) in vec4 multitexcoord2;
|
layout(location = 5) in vec4 multitexcoord2;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec2 orthophoto_texcoord;
|
vec2 orthophoto_texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
|
@ -14,9 +15,13 @@ out VS_OUT {
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
uniform mat3 osg_NormalMatrix;
|
uniform mat3 osg_NormalMatrix;
|
||||||
|
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
vs_out.texcoord = multitexcoord0.st;
|
vs_out.texcoord = multitexcoord0.st;
|
||||||
vs_out.orthophoto_texcoord = multitexcoord2.st;
|
vs_out.orthophoto_texcoord = multitexcoord2.st;
|
||||||
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
} fs_in;
|
} fs_in;
|
||||||
|
@ -12,6 +13,8 @@ void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
||||||
float occlusion, vec3 emissive, uint mat_id);
|
float occlusion, vec3 emissive, uint mat_id);
|
||||||
// color.glsl
|
// color.glsl
|
||||||
vec3 eotf_inverse_sRGB(vec3 srgb);
|
vec3 eotf_inverse_sRGB(vec3 srgb);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -24,4 +27,5 @@ void main()
|
||||||
vec3 N = normalize(fs_in.vertex_normal);
|
vec3 N = normalize(fs_in.vertex_normal);
|
||||||
|
|
||||||
gbuffer_pack(N, color, 0.0, 0.9, 1.0, vec3(0.0), 3u);
|
gbuffer_pack(N, color, 0.0, 0.9, 1.0, vec3(0.0), 3u);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ layout(location = 1) in vec3 normal;
|
||||||
layout(location = 3) in vec4 multitexcoord0;
|
layout(location = 3) in vec4 multitexcoord0;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
} vs_out;
|
} vs_out;
|
||||||
|
@ -12,12 +13,16 @@ out VS_OUT {
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
uniform mat3 osg_NormalMatrix;
|
uniform mat3 osg_NormalMatrix;
|
||||||
|
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 raised_pos = pos;
|
vec4 raised_pos = pos;
|
||||||
raised_pos.z += 0.05;
|
raised_pos.z += 0.05;
|
||||||
|
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * raised_pos;
|
gl_Position = osg_ModelViewProjectionMatrix * raised_pos;
|
||||||
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
vs_out.texcoord = multitexcoord0.st;
|
vs_out.texcoord = multitexcoord0.st;
|
||||||
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec3 view_vector;
|
vec3 view_vector;
|
||||||
|
@ -19,6 +20,8 @@ void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
||||||
vec3 eotf_inverse_sRGB(vec3 srgb);
|
vec3 eotf_inverse_sRGB(vec3 srgb);
|
||||||
// normalmap.glsl
|
// normalmap.glsl
|
||||||
vec3 perturb_normal(vec3 N, vec3 V, vec2 texcoord);
|
vec3 perturb_normal(vec3 N, vec3 V, vec2 texcoord);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -39,4 +42,5 @@ void main()
|
||||||
float roughness = mix(0.94, 0.98, mix_factor);
|
float roughness = mix(0.94, 0.98, mix_factor);
|
||||||
|
|
||||||
gbuffer_pack(N, color, 0.0, roughness, 1.0, vec3(0.0), 3u);
|
gbuffer_pack(N, color, 0.0, roughness, 1.0, vec3(0.0), 3u);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ layout(location = 1) in vec3 normal;
|
||||||
layout(location = 3) in vec4 multitexcoord0;
|
layout(location = 3) in vec4 multitexcoord0;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec3 view_vector;
|
vec3 view_vector;
|
||||||
|
@ -15,9 +16,13 @@ uniform mat4 osg_ModelViewMatrix;
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
uniform mat3 osg_NormalMatrix;
|
uniform mat3 osg_NormalMatrix;
|
||||||
|
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
vs_out.texcoord = multitexcoord0.st;
|
vs_out.texcoord = multitexcoord0.st;
|
||||||
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
||||||
vs_out.view_vector = (osg_ModelViewMatrix * pos).xyz;
|
vs_out.view_vector = (osg_ModelViewMatrix * pos).xyz;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
layout(location = 0) out vec4 fragColor;
|
layout(location = 0) out vec4 fragColor;
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec3 view_vector;
|
vec3 view_vector;
|
||||||
|
@ -27,6 +28,8 @@ vec3 eval_lights_transparent(
|
||||||
vec3 base_color, float metallic, float roughness, float occlusion,
|
vec3 base_color, float metallic, float roughness, float occlusion,
|
||||||
vec3 emissive, vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
|
vec3 emissive, vec3 P, vec3 N, vec3 V, vec2 uv, vec4 ap,
|
||||||
mat4 view_matrix_inverse);
|
mat4 view_matrix_inverse);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -41,4 +44,5 @@ void main()
|
||||||
fs_in.view_vector, N, V, uv, fs_in.ap_color, osg_ViewMatrixInverse);
|
fs_in.view_vector, N, V, uv, fs_in.ap_color, osg_ViewMatrixInverse);
|
||||||
|
|
||||||
fragColor = vec4(color, alpha);
|
fragColor = vec4(color, alpha);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ layout(location = 1) in vec3 normal;
|
||||||
layout(location = 3) in vec4 multitexcoord0;
|
layout(location = 3) in vec4 multitexcoord0;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
vec3 view_vector;
|
vec3 view_vector;
|
||||||
|
@ -18,10 +19,13 @@ uniform mat4 fg_TextureMatrix;
|
||||||
|
|
||||||
// aerial_perspective.glsl
|
// aerial_perspective.glsl
|
||||||
vec4 get_aerial_perspective(vec2 coord, float depth);
|
vec4 get_aerial_perspective(vec2 coord, float depth);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
vs_out.texcoord = vec2(fg_TextureMatrix * multitexcoord0);
|
||||||
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
||||||
vs_out.view_vector = (osg_ModelViewMatrix * pos).xyz;
|
vs_out.view_vector = (osg_ModelViewMatrix * pos).xyz;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
float autumn_flag;
|
float autumn_flag;
|
||||||
|
@ -15,6 +16,8 @@ void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
||||||
float occlusion, vec3 emissive, uint mat_id);
|
float occlusion, vec3 emissive, uint mat_id);
|
||||||
// color.glsl
|
// color.glsl
|
||||||
vec3 eotf_inverse_sRGB(vec3 srgb);
|
vec3 eotf_inverse_sRGB(vec3 srgb);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -33,4 +36,5 @@ void main()
|
||||||
vec3 N = normalize(fs_in.vertex_normal);
|
vec3 N = normalize(fs_in.vertex_normal);
|
||||||
|
|
||||||
gbuffer_pack(N, color, 0.0, 1.0, 1.0, vec3(0.0), 3u);
|
gbuffer_pack(N, color, 0.0, 1.0, 1.0, vec3(0.0), 3u);
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ layout(location = 3) in vec4 multitexcoord0;
|
||||||
layout(location = 12) in float fogcoord;
|
layout(location = 12) in float fogcoord;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 texcoord;
|
vec2 texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
float autumn_flag;
|
float autumn_flag;
|
||||||
|
@ -25,6 +26,8 @@ uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
|
|
||||||
// noise.glsl
|
// noise.glsl
|
||||||
float voronoi_noise_2d(vec2 coord, float wavelength, float xrand, float yrand);
|
float voronoi_noise_2d(vec2 coord, float wavelength, float xrand, float yrand);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
@ -67,6 +70,7 @@ void main()
|
||||||
|
|
||||||
position = position + vertex_color.xyz;
|
position = position + vertex_color.xyz;
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * vec4(position, 1.0);
|
gl_Position = osg_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||||
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
|
|
||||||
vec3 view_vector = (osg_ModelViewMatrix * vec4(position, 1.0)).xyz;
|
vec3 view_vector = (osg_ModelViewMatrix * vec4(position, 1.0)).xyz;
|
||||||
vs_out.vertex_normal = normalize(-view_vector);
|
vs_out.vertex_normal = normalize(-view_vector);
|
||||||
|
|
|
@ -4,6 +4,7 @@ layout(location = 0) out vec4 out_gbuffer0;
|
||||||
layout(location = 1) out vec4 out_gbuffer1;
|
layout(location = 1) out vec4 out_gbuffer1;
|
||||||
|
|
||||||
in VS_OUT {
|
in VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 water_texcoord;
|
vec2 water_texcoord;
|
||||||
vec2 topo_texcoord;
|
vec2 topo_texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
|
@ -29,6 +30,8 @@ vec2 encode_normal(vec3 n);
|
||||||
vec3 eotf_inverse_sRGB(vec3 srgb);
|
vec3 eotf_inverse_sRGB(vec3 srgb);
|
||||||
// normalmap.glsl
|
// normalmap.glsl
|
||||||
mat3 cotangent_frame(vec3 N, vec3 p, vec2 uv);
|
mat3 cotangent_frame(vec3 N, vec3 p, vec2 uv);
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_encode(float z);
|
||||||
|
|
||||||
void get_rotation_matrix(float angle, out mat2 rotmat)
|
void get_rotation_matrix(float angle, out mat2 rotmat)
|
||||||
{
|
{
|
||||||
|
@ -63,4 +66,6 @@ void main()
|
||||||
|
|
||||||
out_gbuffer0.rg = encode_normal(N);
|
out_gbuffer0.rg = encode_normal(N);
|
||||||
out_gbuffer1.rgb = floor_color;
|
out_gbuffer1.rgb = floor_color;
|
||||||
|
|
||||||
|
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ layout(location = 0) in vec4 pos;
|
||||||
layout(location = 3) in vec4 multiTexCoord0;
|
layout(location = 3) in vec4 multiTexCoord0;
|
||||||
|
|
||||||
out VS_OUT {
|
out VS_OUT {
|
||||||
|
float flogz;
|
||||||
vec2 water_texcoord;
|
vec2 water_texcoord;
|
||||||
vec2 topo_texcoord;
|
vec2 topo_texcoord;
|
||||||
vec3 vertex_normal;
|
vec3 vertex_normal;
|
||||||
|
@ -22,6 +23,9 @@ const float squash = 0.9966471893352525192801545;
|
||||||
const float latAdjust = 0.9999074159800018; //geotiff source for the depth map
|
const float latAdjust = 0.9999074159800018; //geotiff source for the depth map
|
||||||
const float lonAdjust = 0.9999537058469516; //actual extents: +-180.008333333333326/+-90.008333333333340
|
const float lonAdjust = 0.9999537058469516; //actual extents: +-180.008333333333326/+-90.008333333333340
|
||||||
|
|
||||||
|
// logarithmic_depth.glsl
|
||||||
|
float logdepth_prepare_vs_depth(float z);
|
||||||
|
|
||||||
void get_rotation_matrix(float angle, out mat4 rotmat)
|
void get_rotation_matrix(float angle, out mat4 rotmat)
|
||||||
{
|
{
|
||||||
rotmat = mat4(cos(angle), -sin(angle), 0.0, 0.0,
|
rotmat = mat4(cos(angle), -sin(angle), 0.0, 0.0,
|
||||||
|
@ -71,6 +75,7 @@ vec2 get_topo_coords(vec3 rawPos)
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
|
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||||
vs_out.water_texcoord = multiTexCoord0.st;
|
vs_out.water_texcoord = multiTexCoord0.st;
|
||||||
vs_out.vertex_normal = osg_NormalMatrix * vec3(0.0, 0.0, 1.0);
|
vs_out.vertex_normal = osg_NormalMatrix * vec3(0.0, 0.0, 1.0);
|
||||||
vs_out.view_vector = (osg_ModelViewMatrix * pos).xyz;
|
vs_out.view_vector = (osg_ModelViewMatrix * pos).xyz;
|
||||||
|
|
Loading…
Reference in a new issue