diff --git a/src/particle_oriented_animated_quad_vbuf_pixel_shader.cpp b/src/particle_oriented_animated_quad_vbuf_pixel_shader.cpp index f2d812f..cc3030e 100644 --- a/src/particle_oriented_animated_quad_vbuf_pixel_shader.cpp +++ b/src/particle_oriented_animated_quad_vbuf_pixel_shader.cpp @@ -49,7 +49,7 @@ const int vertex_shader_paths_length = (sizeof (vertex_shader_paths)) / (sizeof const char * fragment_shader_paths[] = { "clear.fs.bin", "particle_plane.fs.bin", - "particle_particle.fs.bin", + "particle_particle_colored.fs.bin", "texture_tile.fs.bin", "particle_physics.fs.bin", "vertex_buffer_copy.fs.bin", @@ -965,7 +965,7 @@ void init_particles2(void * position_ptr, float vx = xorshift32f(state) * 2.0f - 1.0f; float vz = xorshift32f(state) * 2.0f - 1.0f; - float new_age = max_age * sinf(fi * rl * 2) * 0.5f + 0.5f; + float new_age = max_age * sinf(fi * rl * 2.0f) * 0.5f + 0.5f; vec3 new_position = vec3(sx, sy, sz); vec3 new_velocity = normalize(vec3(vx * 0.5f, 0.0f, vz * 0.5f)); @@ -1304,6 +1304,7 @@ int main() // colorbuffer colorbuffer_handle[0] = create_buffer(fd, colorbuffer_size, &colorbuffer_ptr[0]); colorbuffer_handle[1] = create_buffer(fd, colorbuffer_size, &colorbuffer_ptr[1]); + zbuffer_handle = create_buffer(fd, colorbuffer_size, &zbuffer_ptr); //flush_handle = create_flush_buffer(fd); texturebuffer_handle = load_textures(fd, textures, textures_length); @@ -1315,7 +1316,7 @@ int main() int colorbuffer_ix = 0; float theta = PI * 0.5; - const int floatbuffer_width = 512; + const int floatbuffer_width = 256; const int floatbuffer_height = 256; floatbuffer_state state = create_floatbuffers(fd, floatbuffer_width * floatbuffer_height); @@ -1374,11 +1375,13 @@ int main() break; - struct timespec duration = { - .tv_sec = 0, - .tv_nsec = 18000000, - }; - nanosleep(&duration, NULL); + if (0) { + struct timespec duration = { + .tv_sec = 0, + .tv_nsec = 17000000, + }; + nanosleep(&duration, NULL); + } } primary_surface_address(rmmio, colorbuffer_ix); diff --git a/src/particle_particle_animated_quad_vbuf.vs.asm b/src/particle_particle_animated_quad_vbuf.vs.asm index 2c08251..26c6464 100644 --- a/src/particle_particle_animated_quad_vbuf.vs.asm +++ b/src/particle_particle_animated_quad_vbuf.vs.asm @@ -21,18 +21,18 @@ temp[2].xy = VE_MAD input[1].yx__ const[7].xx__ input[1].11__ ; temp[0].xyz = VE_ADD input[0].xyz_ input[0].000_ ; -- ppos = position.xxx * dx + ppos -temp[0].xyz = VE_MAD temp[2].xxx_ const[4].xyz_ temp[0].xyz_ ; +temp[0].xyz = VE_MAD temp[2].xxx_ const[4].xyz_ temp[0].xyz_ ; -- ppos = position.yyy * dy + ppos -temp[0].xyz = VE_MAD temp[2].yyy_ const[5].xyz_ temp[0].xyz_ ; +temp[0].xyz = VE_MAD temp[2].yyy_ const[5].xyz_ temp[0].xyz_ ; --- ppos *= scale -temp[0].xyzw = VE_MUL temp[0].xyz1 const[6].www1 ; +-- ppos = vec4(ppos.xyz * scale.xyz, age) +temp[0].xyzw = VE_MAD temp[0].xyz0 const[6].www0 input[0].000w ; -- ppos = transform_matrix * ppos -temp[1].x = VE_DOT const[0].xyzw temp[0].xyzw ; -temp[1].y = VE_DOT const[1].xyzw temp[0].xyzw ; -temp[1].z = VE_DOT const[2].xyzw temp[0].xyzw ; -temp[1].w = VE_DOT const[3].xyzw temp[0].xyzw ; +temp[1].x = VE_DOT const[0].xyzw temp[0].xyz1 ; +temp[1].y = VE_DOT const[1].xyzw temp[0].xyz1 ; +temp[1].z = VE_DOT const[2].xyzw temp[0].xyz1 ; +temp[1].w = VE_DOT const[3].xyzw temp[0].xyz1 ; -out[0].xyzw = VE_MAD temp[1].xyzw temp[1].1111 temp[1].0000 ; -out[1].xyzw = VE_MAX input[1].xy00 input[1].xy00 ; +out[0].xyzw = VE_ADD temp[1].xyzw temp[1].0000 ; +out[1].xyzw = VE_ADD input[1].xy00 temp[0].00zw ; -- age diff --git a/src/particle_particle_animated_quad_vbuf.vs.bin b/src/particle_particle_animated_quad_vbuf.vs.bin index 450568f..efef34e 100644 Binary files a/src/particle_particle_animated_quad_vbuf.vs.bin and b/src/particle_particle_animated_quad_vbuf.vs.bin differ diff --git a/src/particle_particle_colored.fs.asm b/src/particle_particle_colored.fs.asm new file mode 100644 index 0000000..92323ae --- /dev/null +++ b/src/particle_particle_colored.fs.asm @@ -0,0 +1,43 @@ +-- temp[0].xy: texture coordinate +-- temp[0].a : age + +TEX TEX_SEM_WAIT TEX_SEM_ACQUIRE + temp[2].rgb = LD tex[0].rgba temp[0].rgaa ; + +-- i = vec3(0.25, 0.40625, 0.5625); +src0.a = float(40) , -- 0.25 +src1.a = float(45) , -- 0.40625 +src2.rgb = float(49) : -- 0.5625 + temp[1].rgb = MAD src0.a10 src1.1a0 src2.00r ; + +-- t = i + vec3(td) +src0.a = temp[0] , +src0.rgb = temp[1] , +src1.rgb = temp[0] : + temp[1].rgb = MAD src1.bbb src0.aaa src0.rgb ; + +-- j = fract(t) +src0.rgb = temp[1] : + temp[1].rgb = FRC src0.rgb ; + +-- k = cos(j * 2π) +src0.rgb = temp[1] : + COS src0.r , + temp[1].r = SOP ; +src0.rgb = temp[1] : + COS src0.g , + temp[1].g = SOP ; +src0.rgb = temp[1] : + COS src0.b , + temp[1].b = SOP ; + +-- l = k * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5) +src0.rgb = temp[1] , +src1.rgb = float(48) : -- 0.5 + temp[1].rgb = MAD src0.rgb src1.rrr src1.rrr ; + +OUT TEX_SEM_WAIT +src0.rgb = temp[2] , +src1.rgb = temp[1] : + out[0].a = MAX src0.1 src0.1 , + out[0].rgb = MAD src0.rgb src1.rgb src0.000 ; diff --git a/src/particle_particle_colored.fs.bin b/src/particle_particle_colored.fs.bin new file mode 100644 index 0000000..3eb1524 Binary files /dev/null and b/src/particle_particle_colored.fs.bin differ diff --git a/src/particle_physics.fs.asm b/src/particle_physics.fs.asm index c570f3f..660098f 100644 --- a/src/particle_physics.fs.asm +++ b/src/particle_physics.fs.asm @@ -75,8 +75,9 @@ src0.rgb = temp[1] : -- velocity 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 ; +src0.rgb = temp[1] , -- velocity +src1.a = temp[1] : -- delta + temp[2].rgb = MAD src0.r0b src0.a0a src1.0a0 ; -- age = age + max_age -- reset__position = reset__position * 20 @@ -88,10 +89,19 @@ src0.rgb = temp[2] : -- reset__position 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 ; +-- (p.velocity.x * 0.5 + 0.5) +-- velocity.xz = velocity.xz +src0.rgb = temp[1] , -- velocity.x +src1.a = float(48) : -- 0.5 + temp[3].a = MAD src0.r src1.a src1.a , + temp[3].rgb = MAX src0.r0b src0.r0b ; + +-- reset__velocity +-- velocity.y = (temp[3].a * delta + 2.0) +src0.a = temp[1] , -- delta +src1.a = float(56) , -- 1.0 +src2.a = temp[3] : -- + temp[3].g = MAD src2.0a0 src0.0a0 src1.0a0 ; OUT src0.a = temp[4] , -- update__age diff --git a/src/particle_physics.fs.bin b/src/particle_physics.fs.bin index 279fc2b..f2565a9 100644 Binary files a/src/particle_physics.fs.bin and b/src/particle_physics.fs.bin differ diff --git a/src/vertex_buffer_copy.vs.asm b/src/vertex_buffer_copy.vs.asm index eadd23e..75b82cf 100644 --- a/src/vertex_buffer_copy.vs.asm +++ b/src/vertex_buffer_copy.vs.asm @@ -1,2 +1,2 @@ out[0].xyzw = VE_ADD input[0].xyzw input[0].0000 ; -out[1].xyzw = VE_ADD input[0].xy00 const[0].xy00 ; +out[1].xyzw = VE_ADD input[0].xy00 input[0].0000 ; diff --git a/src/vertex_buffer_copy.vs.bin b/src/vertex_buffer_copy.vs.bin index b140eb3..fc9a4c5 100644 Binary files a/src/vertex_buffer_copy.vs.bin and b/src/vertex_buffer_copy.vs.bin differ