diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-01-01 22:16:52 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-01-01 22:16:52 -0300 |
commit | c2a217c3501b8006a3d2cdf2c678e33def15f275 (patch) | |
tree | 9f0b2d128ef5c97d4632e387041079e59c193fd7 /drivers/gles3/shaders | |
parent | a62c99c4e4325ca0c015d731f2bcb9b07410bb65 (diff) |
WIP particle system
Ability to enable and change MSAA settings
Ability to change VCT quality
Ability to enable/disable HDR rendering
Diffstat (limited to 'drivers/gles3/shaders')
-rw-r--r-- | drivers/gles3/shaders/particles.glsl | 121 | ||||
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 6 | ||||
-rw-r--r-- | drivers/gles3/shaders/subsurf_scattering.glsl | 4 |
3 files changed, 92 insertions, 39 deletions
diff --git a/drivers/gles3/shaders/particles.glsl b/drivers/gles3/shaders/particles.glsl index fb6060957e..e72f12cc5e 100644 --- a/drivers/gles3/shaders/particles.glsl +++ b/drivers/gles3/shaders/particles.glsl @@ -2,10 +2,12 @@ -layout(location=0) in highp vec4 pos_lifetime; -layout(location=1) in highp vec4 color; -layout(location=2) in highp vec4 velocity_seed; -layout(location=3) in highp vec4 rot_active; +layout(location=0) in highp vec4 color; +layout(location=1) in highp vec4 velocity_active; +layout(location=2) in highp vec4 custom; +layout(location=3) in highp vec4 xform_1; +layout(location=4) in highp vec4 xform_2; +layout(location=5) in highp vec4 xform_3; struct Attractor { @@ -32,10 +34,24 @@ uniform int attractor_count; uniform Attractor attractors[MAX_ATTRACTORS]; -out highp vec4 out_pos_lifetime; //tfb: out highp vec4 out_color; //tfb: -out highp vec4 out_velocity_seed; //tfb: -out highp vec4 out_rot_active; //tfb: +out highp vec4 out_velocity_active; //tfb: +out highp vec4 out_custom; //tfb: +out highp vec4 out_xform_1; //tfb: +out highp vec4 out_xform_2; //tfb: +out highp vec4 out_xform_3; //tfb: + +VERTEX_SHADER_GLOBALS + +#if defined(USE_MATERIAL) + +layout(std140) uniform UniformData { //ubo:0 + +MATERIAL_UNIFORMS + +}; + +#endif void main() { @@ -47,6 +63,7 @@ void main() { float restart_phase = float(gl_InstanceID)/total_particles; restart_phase*= explosiveness; bool restart=false; + bool active = out_velocity_active.a > 0.5; if (system_phase > prev_system_phase) { restart = prev_system_phase < restart_phase && system_phase >= restart_phase; @@ -55,60 +72,96 @@ void main() { } if (restart) { - out_rot_active.a=1.0; + active=true; } - out_pos_lifetime=pos_lifetime; out_color=color; - out_velocity_seed=velocity_seed; + out_velocity_active=velocity_active; + out_custom=custom; + + mat4 xform = transpose(mat4(xform_1,xform_2,xform_3,vec4(vec3(0.0),1.0))); + + out_rot_active=rot_active; - if (out_rot_active.a) { + if (active) { //execute shader - } + { + VERTEX_SHADER_CODE + } +#if !defined(DISABLE_FORCE) - if (apply_forces) { + { - vec3 force = gravity; - for(int i=0;i<attractor_count;i++) { + vec3 force = gravity; + for(int i=0;i<attractor_count;i++) { - vec3 rel_vec = out_pos_lifetime.xyz - attractors[i].pos; - float dist = rel_vec.length(); - if (attractors[i].radius < dist) - continue; - if (attractors[i].eat_radius>0 && attractors[i].eat_radius > dist) { - rot_active.a=0.0; - } + vec3 rel_vec = out_pos_lifetime.xyz - attractors[i].pos; + float dist = rel_vec.length(); + if (attractors[i].radius < dist) + continue; + if (attractors[i].eat_radius>0 && attractors[i].eat_radius > dist) { + out_velocity_active.a=0.0; + } - rel_vec = normalize(rel_vec); + rel_vec = normalize(rel_vec); - float attenuation = pow(dist / attractors[i].radius,attractors[i].attenuation); + float attenuation = pow(dist / attractors[i].radius,attractors[i].attenuation); - if (attractors[i].dir==vec3(0.0)) { - //towards center - force+=attractors[i].strength * rel_vec * attenuation * mass; - } else { - force+=attractors[i].strength * attractors[i].dir * attenuation *mass; + if (attractors[i].dir==vec3(0.0)) { + //towards center + force+=attractors[i].strength * rel_vec * attenuation * mass; + } else { + force+=attractors[i].strength * attractors[i].dir * attenuation *mass; + } } + + out_velocity_seed.xyz += force * delta; } +#endif - out_velocity_seed.xyz += force * delta; - } +#if !defined(DISABLE_VELOCITY) - if (apply_velocity) { + { - out_pos_lifetime.xyz += out_velocity_seed.xyz * delta; + out_pos_lifetime.xyz += out_velocity_seed.xyz * delta; + } +#endif } + xform = transpose(xform); + + out_velocity_active.a = mix(0.0,1.0,active); + + out_xform_1 = xform[0]; + out_xform_2 = xform[1]; + out_xform_3 = xform[2]; + + } [fragment] +//any code here is never executed, stuff is filled just so it works -void main() { +FRAGMENT_SHADER_GLOBALS + +#if defined(USE_MATERIAL) +layout(std140) uniform UniformData { +MATERIAL_UNIFORMS + +}; + +#endif + +void main() { + + { + FRAGMENT_SHADER_CODE + } } diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index c18a356a54..c5af010c96 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -484,7 +484,7 @@ 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; +layout(location=3) out vec4 motion_ssr_buffer; #endif #else @@ -902,7 +902,7 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s float max_distance = length(bounds); //radiance -#ifndef VCT_QUALITY_HIGH +#ifdef VCT_QUALITY_HIGH #define MAX_CONE_DIRS 6 vec3 cone_dirs[MAX_CONE_DIRS] = vec3[] ( @@ -1407,7 +1407,7 @@ 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; + motion_ssr_buffer = vec4(vec3(0.0),sss_strength); #endif #else diff --git a/drivers/gles3/shaders/subsurf_scattering.glsl b/drivers/gles3/shaders/subsurf_scattering.glsl index 89e618b66c..eb329dbaed 100644 --- a/drivers/gles3/shaders/subsurf_scattering.glsl +++ b/drivers/gles3/shaders/subsurf_scattering.glsl @@ -107,14 +107,14 @@ uniform vec2 dir; in vec2 uv_interp; uniform sampler2D source_diffuse; //texunit:0 -uniform highp usampler2D source_motion_ss; //texunit:1 +uniform sampler2D source_motion_ss; //texunit:1 uniform sampler2D source_depth; //texunit:2 layout(location = 0) out vec4 frag_color; void main() { - float strength = float(texture(source_motion_ss,uv_interp).r>>24)*(1.0/255.0); + float strength = texture(source_motion_ss,uv_interp).a; strength*=strength; //stored as sqrt // Fetch color of current pixel: |