particle_oriented_animated_quad_vbuf_pixel_shader: implement particle reset
This commit is contained in:
parent
314267afe1
commit
3ebdfda196
@ -1158,15 +1158,17 @@ int _floatbuffer(const shaders& shaders,
|
||||
|
||||
// fragment constants
|
||||
//const vec3 velocity_scale = vec3(0.003f, 0.01f, 0.003f);
|
||||
const vec3 velocity_scale = vec3(0.09f, 0.50f, 0.09f);
|
||||
const float delta_age = 0.01f;
|
||||
const vec3 velocity_scale = vec3(0.9f, 5.0f, 0.9f);
|
||||
const float delta_age = -0.01f;
|
||||
const float velocity_attenuation = -0.6f; // multiplied by velocity.y after bounce
|
||||
const float gravity = -0.04f;
|
||||
const float max_age = 3.0f;
|
||||
const float reset_radius = 20.0f;
|
||||
const float fragment_consts[] = {
|
||||
// 0:
|
||||
velocity_scale.x, velocity_scale.y, velocity_scale.z, delta_age,
|
||||
// 1:
|
||||
velocity_attenuation, gravity, 0, 0,
|
||||
velocity_attenuation, gravity, max_age, reset_radius,
|
||||
};
|
||||
int fragment_consts_length = (sizeof (fragment_consts)) / (sizeof (fragment_consts[0]));
|
||||
ib_ga_consts(fragment_consts, fragment_consts_length, 0);
|
||||
@ -1307,8 +1309,8 @@ int main()
|
||||
int colorbuffer_ix = 0;
|
||||
float theta = PI * 0.5;
|
||||
|
||||
const int floatbuffer_width = 8;
|
||||
const int floatbuffer_height = 8;
|
||||
const int floatbuffer_width = 64;
|
||||
const int floatbuffer_height = 64;
|
||||
floatbuffer_state state = create_floatbuffers(fd, floatbuffer_width * floatbuffer_height);
|
||||
|
||||
vertexbuffer_handle = init_particles_vertexbuffer(fd, state.length, &vertexbuffer_ptr);
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
-- const[0] = { velocity_scale.rgb, delta_age }
|
||||
-- gravity = -0.05
|
||||
-- velocity_attenuation = -0.7
|
||||
-- const[1] = { velocity_attenuation, gravity, 0, 0 }
|
||||
-- const[1] = { velocity_attenuation, gravity, max_age, 0 }
|
||||
|
||||
-- out[0].rgb : position
|
||||
-- out[0].a : age
|
||||
@ -64,14 +64,48 @@ src2.rgb = temp[4] : -- position
|
||||
src0.rgb = temp[4] :
|
||||
temp[4].g = MAX |src0.0g0| |src0.0g0| ;
|
||||
|
||||
--
|
||||
-- reset
|
||||
--
|
||||
|
||||
-- normalize(vec3(velocity.x, 0, velocity.z))
|
||||
src0.rgb = temp[1] : -- velocity
|
||||
DP3 src0.r0b src0.r0b ,
|
||||
temp[2].a = DP ;
|
||||
src0.a = temp[2] :
|
||||
temp[2].a = RSQ |src0.a| ;
|
||||
src0.a = temp[2] ,
|
||||
src0.rgb = temp[1] : -- velocity
|
||||
temp[2].rgb = MAD src0.r0b src0.a0a src0.000 ;
|
||||
|
||||
-- age = age + max_age
|
||||
-- reset__position = reset__position * 20
|
||||
src0.a = temp[0] , -- age
|
||||
src1.rgb = const[1] , -- max_age
|
||||
src2.a = const[1] , -- reset_radius
|
||||
src0.rgb = temp[2] : -- reset__position
|
||||
temp[2].a = MAD src0.a src0.1 src1.b ,
|
||||
temp[2].rgb = MAD src0.rgb src2.aaa src2.000 ;
|
||||
|
||||
-- reset__velocity
|
||||
src0.a = temp[1] , -- delta
|
||||
src1.a = float(64) , -- 2.0
|
||||
src0.rgb = temp[1] : -- velocity
|
||||
temp[3].rgb = MAD src0.rab src1.1a1 src1.000 ;
|
||||
|
||||
OUT
|
||||
src0.a = temp[4] , -- update__age
|
||||
src0.rgb = temp[4] : -- update__position
|
||||
out[0].a = MAX src0.a src0.a ,
|
||||
out[0].rgb = MAX src0.rgb src0.rgb ;
|
||||
src1.a = temp[2] , -- reset__age
|
||||
src2.a = temp[0] , -- age
|
||||
src0.rgb = temp[4] , -- update__position
|
||||
src1.rgb = temp[2] : -- reset__position
|
||||
out[0].a = CMP src0.a src1.a src2.a ,
|
||||
out[0].rgb = CMP src0.rgb src1.rgb src2.aaa ;
|
||||
|
||||
OUT TEX_SEM_WAIT
|
||||
src0.a = temp[1] , -- delta
|
||||
src0.rgb = temp[5] : -- update__velocity
|
||||
out[1].a = MAX src0.a src0.a ,
|
||||
out[1].rgb = MAX src0.rgb src0.rgb ;
|
||||
src2.a = temp[0] , -- age
|
||||
src0.rgb = temp[5] , -- update__velocity
|
||||
src1.rgb = temp[3] : -- reset__velocity
|
||||
out[1].a = MAX src0.a src0.a , -- constant
|
||||
out[1].rgb = CMP src0.rgb src1.rgb src2.aaa ;
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user