diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-06-05 22:33:01 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-06-05 22:34:32 -0300 |
commit | 0fb99306ff747072dfabceeeba27ca4432b9aa49 (patch) | |
tree | 72d991ed7962b550d4ef0d52a8c2d4702ff46e41 /drivers/gles3/shaders | |
parent | b21e68c8bc0168120ded326259d021d394a9d7bf (diff) |
-working SCREEN_TEXTURE, SCREEN_UV shader variables
-Added refraction support for default material
-Enabled BCS adjustments, as well as color correction.
Diffstat (limited to 'drivers/gles3/shaders')
-rw-r--r-- | drivers/gles3/shaders/copy.glsl | 31 | ||||
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 35 | ||||
-rw-r--r-- | drivers/gles3/shaders/tonemap.glsl | 27 |
3 files changed, 85 insertions, 8 deletions
diff --git a/drivers/gles3/shaders/copy.glsl b/drivers/gles3/shaders/copy.glsl index c8985e6902..621ae83162 100644 --- a/drivers/gles3/shaders/copy.glsl +++ b/drivers/gles3/shaders/copy.glsl @@ -84,8 +84,24 @@ uniform vec2 pixel_size; in vec2 uv2_interp; + +#ifdef USE_BCS + +uniform vec3 bcs; + +#endif + +#ifdef USE_COLOR_CORRECTION + +uniform sampler2D color_correction; //texunit:1 + +#endif + layout(location = 0) out vec4 frag_color; + + + void main() { //vec4 color = color_interp; @@ -135,6 +151,21 @@ void main() { color+=texture( source, uv_interp+vec2( 0.0,-2.0)*pixel_size )*0.06136; #endif +#ifdef USE_BCS + + color.rgb = mix(vec3(0.0),color.rgb,bcs.x); + color.rgb = mix(vec3(0.5),color.rgb,bcs.y); + color.rgb = mix(vec3(dot(vec3(1.0),color.rgb)*0.33333),color.rgb,bcs.z); + +#endif + +#ifdef USE_COLOR_CORRECTION + + color.r = texture(color_correction,vec2(color.r,0.0)).r; + color.g = texture(color_correction,vec2(color.g,0.0)).g; + color.b = texture(color_correction,vec2(color.b,0.0)).b; +#endif + #ifdef USE_MULTIPLIER color.rgb*=multiplier; #endif diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 29a7135eed..f498eae9f5 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -153,7 +153,7 @@ out highp float dp_clip; #define SKELETON_TEXTURE_WIDTH 256 #ifdef USE_SKELETON -uniform highp sampler2D skeleton_texture; //texunit:-6 +uniform highp sampler2D skeleton_texture; //texunit:-1 #endif out highp vec4 position_interp; @@ -338,7 +338,20 @@ VERTEX_SHADER_CODE [fragment] +/* texture unit usage, N is max_texture_unity-N +1-skeleton +2-radiance +3-reflection_atlas +4-directional_shadow +5-shadow_atlas +6-decal_atlas +7-screen +8-depth +9-probe1 +10-probe2 + +*/ #define M_PI 3.14159265359 @@ -370,7 +383,6 @@ in vec3 normal_interp; //used on forward mainly uniform bool no_ambient_light; -uniform sampler2D brdf_texture; //texunit:-1 #ifdef USE_RADIANCE_MAP @@ -482,7 +494,7 @@ layout(std140) uniform SpotLightData { //ubo:5 }; -uniform highp sampler2DShadow shadow_atlas; //texunit:-3 +uniform highp sampler2DShadow shadow_atlas; //texunit:-5 struct ReflectionData { @@ -500,7 +512,7 @@ layout(std140) uniform ReflectionProbeData { //ubo:6 ReflectionData reflections[MAX_REFLECTION_DATA_STRUCTS]; }; -uniform mediump sampler2D reflection_atlas; //texunit:-5 +uniform mediump sampler2D reflection_atlas; //texunit:-3 #ifdef USE_FORWARD_LIGHTING @@ -517,6 +529,11 @@ uniform int reflection_count; #endif +#if defined(SCREEN_TEXTURE_USED) + +uniform highp sampler2D screen_texture; //texunit:-7 + +#endif #ifdef USE_MULTIPLE_RENDER_TARGETS @@ -534,7 +551,7 @@ layout(location=0) out vec4 frag_color; #endif in highp vec4 position_interp; -uniform highp sampler2D depth_buffer; //texunit:-9 +uniform highp sampler2D depth_buffer; //texunit:-8 float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) { @@ -1020,7 +1037,7 @@ void reflection_process(int idx, vec3 vertex, vec3 normal,vec3 binormal, vec3 ta #ifdef USE_GI_PROBES -uniform mediump sampler3D gi_probe1; //texunit:-10 +uniform mediump sampler3D gi_probe1; //texunit:-9 uniform highp mat4 gi_probe_xform1; uniform highp vec3 gi_probe_bounds1; uniform highp vec3 gi_probe_cell_size1; @@ -1028,7 +1045,7 @@ uniform highp float gi_probe_multiplier1; uniform highp float gi_probe_bias1; uniform bool gi_probe_blend_ambient1; -uniform mediump sampler3D gi_probe2; //texunit:-11 +uniform mediump sampler3D gi_probe2; //texunit:-10 uniform highp mat4 gi_probe_xform2; uniform highp vec3 gi_probe_bounds2; uniform highp vec3 gi_probe_cell_size2; @@ -1265,7 +1282,9 @@ void main() { float normaldepth=1.0; - +#if defined(SCREEN_UV_USED) + vec2 screen_uv = gl_FragCoord.xy*screen_pixel_size; +#endif #if defined(ENABLE_DISCARD) bool discard_=false; diff --git a/drivers/gles3/shaders/tonemap.glsl b/drivers/gles3/shaders/tonemap.glsl index 8f7e0c7be3..b2615fa29c 100644 --- a/drivers/gles3/shaders/tonemap.glsl +++ b/drivers/gles3/shaders/tonemap.glsl @@ -39,6 +39,19 @@ uniform highp float glow_intensity; #endif +#ifdef USE_BCS + +uniform vec3 bcs; + +#endif + +#ifdef USE_COLOR_CORRECTION + +uniform sampler2D color_correction; //texunit:3 + +#endif + + layout(location = 0) out vec4 frag_color; #ifdef USE_GLOW_FILTER_BICUBIC @@ -255,6 +268,20 @@ void main() { color.rgb = mix( (vec3(1.0)+a)*pow(color.rgb,vec3(1.0/2.4))-a , 12.92*color.rgb , lessThan(color.rgb,vec3(0.0031308))); +#ifdef USE_BCS + + color.rgb = mix(vec3(0.0),color.rgb,bcs.x); + color.rgb = mix(vec3(0.5),color.rgb,bcs.y); + color.rgb = mix(vec3(dot(vec3(1.0),color.rgb)*0.33333),color.rgb,bcs.z); + +#endif + +#ifdef USE_COLOR_CORRECTION + + color.r = texture(color_correction,vec2(color.r,0.0)).r; + color.g = texture(color_correction,vec2(color.g,0.0)).g; + color.b = texture(color_correction,vec2(color.b,0.0)).b; +#endif frag_color=vec4(color.rgb,1.0); |