Is there a way to sort polygons in glsl?

Started by
13 comments, last by tomek22 13 years, 5 months ago
each particle is assigned a random value which controls the particle life span. This parameter is then multiplied by particle velocity. I guess i could precompute life span expectancy of the longest living particle before sending it to the shader, but i would like to have a solution which will work for all the different particle effects i plan to make in the future

Now that i think about it, i can deal with this by modifying the emitter interface in the application to make sure all emitters can calculate this on their own. I guess that should work.

Thanks a lot for the tip, you've been very helpful!
Advertisement
hmmm

looks like there's another problem :)

here's the prototype for texture1d function:

vec4 texture1D( sampler1D, float [,float bias] )

it takes in float, not int, which suggests i would have to send in float values from 0 to 1 in my application. How can i be sure about the precision?
I think you want texelFetch(), not texture1D().

See the section here about "direct texel fetches"

Also you have to be really careful when sending integers as attributes, opengl sends it's attributes as floats, even if you specify the attribute type as int. (spent a week figuring out this nasty mistake before when I sent '1' as an attribute it came out as integer 1,080,000,000).

Make sure you use glVertexAttribIPointer instead of glVertexAttribPointer for integers.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
i'm not sure if this is supported in my version of glsl (at least i can't find it in the specs). again, i'm using opengl 2.0
It might not be, not integer samples anyway. I think you need shader4 extension for integer operations in glsl.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
ok, i'll just try to send floats instead and see if it works

thanks again for your help!

This topic is closed to new replies.

Advertisement