1

i want to draw a particle system on Android, where the particles are continuously flowing from a specified point. without shaders i'm able to get that by checking for life of particle. if life is zero then reset the position to the center.

how to achieve the same with shaders?? i took a lifetime variable to keep track whether particle is alive. once particle is dead, i want reposition particle around the specified point. this lifetime will be random for each particle, is there any way i can achieve this with shaders??

to make my question easy to understand, for example i want to implement NeHe lesson 19 (Please see DrawGLScene of lesson 19)with Shader....

Full code of my work can be found below for reference

1)No Shaders

2)With Shaders

8
  • First explain why you need the previous position, it is not clear how it is relevant to the the rest of the info you provided Commented May 25, 2011 at 4:59
  • without using shaders, i updated position of each particle in for loop and i maintained a variable 'life', when life hits zero, i reset position to center(from where the particles are flowing). if you like to see the code, i'll post it Commented May 25, 2011 at 8:17
  • i used a thread to update the positions of particles, thread maintains the 30FPS update speed Commented May 25, 2011 at 8:40
  • if the center position is common for all particles, then can't you just push it as an uniform? posting some code always helps Commented May 25, 2011 at 9:30
  • i have updated question, added code part Commented May 25, 2011 at 10:11

2 Answers 2

2

Thanx everybody,

i found out a solution after struggle for total sat'day...

now i'm doing all the calculation in vertex shader based on time

i'm calculating the time at particle will die and mod with current time will give the modified time frame...

basically each particle will live its life time again n again

code can be found at google code directory

Thanq one all for trying to solve my problem

Sign up to request clarification or add additional context in comments.

Comments

0

You have to update LifeTime of particple in Draw function on every draw and then pass it to shader with GLES20.glVertexAttribPointer as "attribute float a_lifetime;" ,for example.

look at this source SOURCE

1 Comment

thanx, i took the same idea from the source you have mentioned, but my question was, once lifetime hit zero how to re-position the particle at the center (for continuous flow of particles), since lifetime will be random in my case. so each particle will die at different time, so need to spawn(position them to origin) them individually

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.