diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-03-01 16:04:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-01 16:04:11 +0100 |
commit | 29215b229bab093bd083af4099234cbffe4febfb (patch) | |
tree | bdd2fc1a9a678422b37513a83f9bd842de532145 /drivers/gles2/shaders/canvas_shadow.glsl | |
parent | 7f3024d343aa1b14641ad5a7b56efaa1501550cf (diff) | |
parent | eac4c984dfe5eebb73b094aaf2ed5ab37b6e8fdf (diff) |
Merge pull request #16687 from karroffel/gles2-2d-pr
add GLES 2 renderer for 2D
Diffstat (limited to 'drivers/gles2/shaders/canvas_shadow.glsl')
-rw-r--r-- | drivers/gles2/shaders/canvas_shadow.glsl | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/gles2/shaders/canvas_shadow.glsl b/drivers/gles2/shaders/canvas_shadow.glsl new file mode 100644 index 0000000000..c757990de0 --- /dev/null +++ b/drivers/gles2/shaders/canvas_shadow.glsl @@ -0,0 +1,49 @@ +[vertex] + + + +uniform highp mat4 projection_matrix; +uniform highp mat4 light_matrix; +uniform highp mat4 world_matrix; +uniform highp float distance_norm; + +layout(location=0) in highp vec3 vertex; + +out highp vec4 position_interp; + +void main() { + + gl_Position = projection_matrix * (light_matrix * (world_matrix * vec4(vertex,1.0))); + position_interp=gl_Position; +} + +[fragment] + +in highp vec4 position_interp; + +#ifdef USE_RGBA_SHADOWS + +layout(location=0) out lowp vec4 distance_buf; + +#else + +layout(location=0) out highp float distance_buf; + +#endif + +void main() { + + highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0;//bias; + +#ifdef USE_RGBA_SHADOWS + + highp vec4 comp = fract(depth * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0)); + comp -= comp.xxyz * vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); + distance_buf=comp; +#else + + distance_buf=depth; + +#endif +} + |