HDR: Fix logarithmic depth in WS 3.0
This commit is contained in:
parent
a0db21db7f
commit
b00a1f2767
3 changed files with 33 additions and 1 deletions
|
@ -1929,7 +1929,7 @@
|
|||
|
||||
<cull-face>back</cull-face>
|
||||
<program>
|
||||
<vertex-shader>Shaders/HDR/terrain_default.vert</vertex-shader>
|
||||
<vertex-shader>Shaders/HDR/ws30.vert</vertex-shader>
|
||||
<vertex-shader>Shaders/HDR/logarithmic_depth.glsl</vertex-shader>
|
||||
<fragment-shader>Shaders/HDR/ws30.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/logarithmic_depth.glsl</fragment-shader>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#version 330 core
|
||||
|
||||
in VS_OUT {
|
||||
float flogz;
|
||||
vec2 texcoord;
|
||||
vec2 orthophoto_texcoord;
|
||||
vec3 vertex_normal;
|
||||
|
@ -31,6 +32,8 @@ void gbuffer_pack(vec3 normal, vec3 base_color, float metallic, float roughness,
|
|||
float occlusion, vec3 emissive, uint mat_id);
|
||||
// color.glsl
|
||||
vec3 eotf_inverse_sRGB(vec3 srgb);
|
||||
// logarithmic_depth.glsl
|
||||
float logdepth_encode(float z);
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@ -71,4 +74,5 @@ void main()
|
|||
vec3 N = normalize(fs_in.vertex_normal);
|
||||
|
||||
gbuffer_pack(N, color, TERRAIN_METALLIC, TERRAIN_ROUGHNESS, 1.0, vec3(0.0), 3u);
|
||||
gl_FragDepth = logdepth_encode(fs_in.flogz);
|
||||
}
|
||||
|
|
28
Shaders/HDR/ws30.vert
Normal file
28
Shaders/HDR/ws30.vert
Normal file
|
@ -0,0 +1,28 @@
|
|||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec4 pos;
|
||||
layout(location = 1) in vec3 normal;
|
||||
layout(location = 3) in vec4 multitexcoord0;
|
||||
layout(location = 5) in vec4 multitexcoord2;
|
||||
|
||||
out VS_OUT {
|
||||
float flogz;
|
||||
vec2 texcoord;
|
||||
vec2 orthophoto_texcoord;
|
||||
vec3 vertex_normal;
|
||||
} vs_out;
|
||||
|
||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
||||
uniform mat3 osg_NormalMatrix;
|
||||
|
||||
// logarithmic_depth.glsl
|
||||
float logdepth_prepare_vs_depth(float z);
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||
vs_out.flogz = logdepth_prepare_vs_depth(gl_Position.w);
|
||||
vs_out.texcoord = multitexcoord0.st;
|
||||
vs_out.orthophoto_texcoord = multitexcoord2.st;
|
||||
vs_out.vertex_normal = osg_NormalMatrix * normal;
|
||||
}
|
Loading…
Add table
Reference in a new issue