summaryrefslogtreecommitdiff
path: root/drivers/gles3/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles3/shaders')
-rw-r--r--drivers/gles3/shaders/SCsub1
-rw-r--r--drivers/gles3/shaders/particles.glsl114
-rw-r--r--drivers/gles3/shaders/scene.glsl10
3 files changed, 122 insertions, 3 deletions
diff --git a/drivers/gles3/shaders/SCsub b/drivers/gles3/shaders/SCsub
index 272f9bb5e1..f9baeae97d 100644
--- a/drivers/gles3/shaders/SCsub
+++ b/drivers/gles3/shaders/SCsub
@@ -17,5 +17,6 @@ if env['BUILDERS'].has_key('GLES3_GLSL'):
env.GLES3_GLSL('ssao_blur.glsl');
env.GLES3_GLSL('exposure.glsl');
env.GLES3_GLSL('tonemap.glsl');
+ env.GLES3_GLSL('particles.glsl');
diff --git a/drivers/gles3/shaders/particles.glsl b/drivers/gles3/shaders/particles.glsl
new file mode 100644
index 0000000000..fb6060957e
--- /dev/null
+++ b/drivers/gles3/shaders/particles.glsl
@@ -0,0 +1,114 @@
+[vertex]
+
+
+
+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;
+
+
+struct Attractor {
+
+ vec3 pos;
+ vec3 dir;
+ float radius;
+ float eat_radius;
+ float strength;
+ float attenuation;
+};
+
+#define MAX_ATTRACTORS 64
+
+uniform mat4 origin;
+uniform float system_phase;
+uniform float prev_system_phase;
+uniform float total_particles;
+uniform float explosiveness;
+uniform vec4 time;
+uniform float delta;
+uniform vec3 gravity;
+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:
+
+void main() {
+
+ bool apply_forces=true;
+ bool apply_velocity=true;
+
+ float mass = 1.0;
+
+ float restart_phase = float(gl_InstanceID)/total_particles;
+ restart_phase*= explosiveness;
+ bool restart=false;
+
+ if (system_phase > prev_system_phase) {
+ restart = prev_system_phase < restart_phase && system_phase >= restart_phase;
+ } else {
+ restart = prev_system_phase < restart_phase || system_phase >= restart_phase;
+ }
+
+ if (restart) {
+ out_rot_active.a=1.0;
+ }
+
+ out_pos_lifetime=pos_lifetime;
+ out_color=color;
+ out_velocity_seed=velocity_seed;
+ out_rot_active=rot_active;
+
+ if (out_rot_active.a) {
+ //execute shader
+
+ }
+
+
+ if (apply_forces) {
+
+ 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;
+ }
+
+ rel_vec = normalize(rel_vec);
+
+ 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;
+
+ }
+ }
+
+ out_velocity_seed.xyz += force * delta;
+ }
+
+ if (apply_velocity) {
+
+ out_pos_lifetime.xyz += out_velocity_seed.xyz * delta;
+ }
+
+}
+
+[fragment]
+
+
+void main() {
+
+
+}
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index b0b2782307..90c501ea32 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -899,8 +899,10 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s
float blend = 1.001-max(blendv.x,max(blendv.y,blendv.z));
blend=1.0;
+ float max_distance = length(bounds);
+
//radiance
-#ifdef VCT_QUALITY_HIGH
+#ifndef VCT_QUALITY_HIGH
#define MAX_CONE_DIRS 6
vec3 cone_dirs[MAX_CONE_DIRS] = vec3[] (
@@ -914,6 +916,7 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s
float cone_weights[MAX_CONE_DIRS] = float[](0.25, 0.15, 0.15, 0.15, 0.15, 0.15);
float cone_angle_tan = 0.577;
+ float min_ref_tan = 0.0;
#else
#define MAX_CONE_DIRS 4
@@ -927,9 +930,10 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s
float cone_weights[MAX_CONE_DIRS] = float[](0.25, 0.25, 0.25, 0.25);
float cone_angle_tan = 0.98269;
+ max_distance*=0.5;
+ float min_ref_tan = 0.2;
#endif
- float max_distance = length(bounds);
vec3 light=vec3(0.0);
for(int i=0;i<MAX_CONE_DIRS;i++) {
@@ -944,7 +948,7 @@ void gi_probe_compute(sampler3D probe, mat4 probe_xform, vec3 bounds,vec3 cell_s
//irradiance
- vec3 irr_light = voxel_cone_trace(probe,cell_size,probe_pos,environment,blend_ambient,ref_vec,tan(roughness * 0.5 * M_PI) ,max_distance);
+ vec3 irr_light = voxel_cone_trace(probe,cell_size,probe_pos,environment,blend_ambient,ref_vec,max(min_ref_tan,tan(roughness * 0.5 * M_PI)) ,max_distance);
irr_light *= multiplier;
//irr_light=vec3(0.0);