summaryrefslogtreecommitdiff
path: root/drivers/gles3/shaders
diff options
context:
space:
mode:
authorDominique LaSalle <dominique@solidlake.com>2018-11-13 17:19:11 -0800
committerDominique LaSalle <dominique@solidlake.com>2018-11-13 17:19:11 -0800
commit6eae6247e4fc3bf1655f52be0c583573ec7700ea (patch)
treef6a1fdf868f2204122ac8fbb77f8ad96b50d0991 /drivers/gles3/shaders
parent72db3000a56a6f85d348c218437d1a1dfc0953bf (diff)
Add parameter for fog max depth and use alpha as density.
Diffstat (limited to 'drivers/gles3/shaders')
-rw-r--r--drivers/gles3/shaders/scene.glsl9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 91ab34f775..ef36978258 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;
@@ -2033,10 +2037,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);