summaryrefslogtreecommitdiff
path: root/drivers/gles3/shaders/scene.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles3/shaders/scene.glsl')
-rw-r--r--drivers/gles3/shaders/scene.glsl42
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index 192042192e..230544c1c3 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -75,6 +75,7 @@ layout(std140) uniform SceneData { //ubo:0
vec2 directional_shadow_pixel_size;
float reflection_multiplier;
+ float subsurface_scatter_width;
};
@@ -385,6 +386,7 @@ layout(std140) uniform SceneData {
vec2 directional_shadow_pixel_size;
float reflection_multiplier;
+ float subsurface_scatter_width;
};
@@ -479,6 +481,9 @@ uniform int reflection_count;
layout(location=0) out vec4 diffuse_buffer;
layout(location=1) out vec4 specular_buffer;
layout(location=2) out vec4 normal_mr_buffer;
+#if defined (ENABLE_SSS_MOTION)
+layout(location=3) out uint motion_ssr_buffer;
+#endif
#else
@@ -621,6 +626,35 @@ in highp float dp_clip;
#endif
+#if 0
+//need to save texture depth for this
+
+vec3 light_transmittance(float translucency,vec3 light_vec, vec3 normal, vec3 pos, float distance) {
+
+ float scale = 8.25 * (1.0 - translucency) / subsurface_scatter_width;
+ float d = scale * distance;
+
+ /**
+ * Armed with the thickness, we can now calculate the color by means of the
+ * precalculated transmittance profile.
+ * (It can be precomputed into a texture, for maximum performance):
+ */
+ float dd = -d * d;
+ vec3 profile = vec3(0.233, 0.455, 0.649) * exp(dd / 0.0064) +
+ vec3(0.1, 0.336, 0.344) * exp(dd / 0.0484) +
+ vec3(0.118, 0.198, 0.0) * exp(dd / 0.187) +
+ vec3(0.113, 0.007, 0.007) * exp(dd / 0.567) +
+ vec3(0.358, 0.004, 0.0) * exp(dd / 1.99) +
+ vec3(0.078, 0.0, 0.0) * exp(dd / 7.41);
+
+ /**
+ * Using the profile, we finally approximate the transmitted lighting from
+ * the back of the object:
+ */
+ return profile * clamp(0.3 + dot(light_vec, normal),0.0,1.0);
+}
+#endif
+
void light_process_omni(int idx, vec3 vertex, vec3 eye_vec,vec3 normal,vec3 binormal, vec3 tangent, vec3 albedo, vec3 specular, float roughness, float rim, float rim_tint, float clearcoat, float clearcoat_gloss,float anisotropy,inout vec3 diffuse_light, inout vec3 specular_light) {
vec3 light_rel_vec = omni_lights[idx].light_pos_inv_radius.xyz-vertex;
@@ -870,6 +904,10 @@ void main() {
bool discard_=false;
#endif
+#if defined (ENABLE_SSS_MOTION)
+ float sss_strength=0.0;
+#endif
+
{
@@ -1194,6 +1232,10 @@ LIGHT_SHADER_CODE
normal_mr_buffer=vec4(normalize(normal)*0.5+0.5,roughness);
+#if defined (ENABLE_SSS_MOTION)
+ motion_ssr_buffer = uint(clamp(sqrt(sss_strength)*255.0,0.0,255))<<24;
+#endif
+
#else