diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-11-14 10:24:55 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-14 10:24:55 -0300 |
commit | 55f5f4757e03f019454fca06929ba028890b3b0f (patch) | |
tree | 569f26142a221e8925cb27af8563d747b25f4e85 /drivers/gles3/shaders/scene.glsl | |
parent | 43b9ed64c872f777a4e75f832fbc5352f7721848 (diff) | |
parent | 6eae6247e4fc3bf1655f52be0c583573ec7700ea (diff) |
Merge pull request #23248 from dlasalle/fog
Add parameters for fog end depth and use alpha as density.
Diffstat (limited to 'drivers/gles3/shaders/scene.glsl')
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 66c0631cef..2288c17334 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -98,6 +98,8 @@ layout(std140) uniform SceneData { // ubo:0 bool fog_depth_enabled; highp float fog_depth_begin; + highp float fog_depth_end; + mediump float fog_density; highp float fog_depth_curve; bool fog_transmit_enabled; highp float fog_transmit_curve; @@ -675,6 +677,8 @@ layout(std140) uniform SceneData { bool fog_depth_enabled; highp float fog_depth_begin; + highp float fog_depth_end; + mediump float fog_density; highp float fog_depth_curve; bool fog_transmit_enabled; highp float fog_transmit_curve; @@ -2026,10 +2030,11 @@ FRAGMENT_SHADER_CODE //apply fog if (fog_depth_enabled) { + float fog_far = fog_depth_end > 0 ? fog_depth_end : z_far; - float fog_z = smoothstep(fog_depth_begin, z_far, length(vertex)); + float fog_z = smoothstep(fog_depth_begin, fog_far, length(vertex)); - fog_amount = pow(fog_z, fog_depth_curve); + fog_amount = pow(fog_z, fog_depth_curve) * fog_density; if (fog_transmit_enabled) { vec3 total_light = emission + ambient_light + specular_light + diffuse_light; float transmit = pow(fog_z, fog_transmit_curve); |