Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

nParticles per-point attribute access in shader

3 REPLIES 3
Reply
Message 1 of 4
zenop
503 Views, 3 Replies

nParticles per-point attribute access in shader

Hi, I'm trying access particle data from within an OSL shader. For example, I would like to store some vector attribute per-point and query that at shading time.

Is this possible? Pretty new to working with particles in OSL and can't find much info about it.

I'm finding following info in blender's osl implementation, is there an equivalent in arnold's implementation?

particle:index
Particle instance number.
particle:age
Particle age in frames.
particle:lifetime
Total lifespan of particle in frames.
particle:location
Location of the particle.
particle:size
Size of the particle.
particle:velocity
Velocity of the particle.
particle:angular_velocity
Angular velocity of the particle.



Edit: it seems I can read some per-particle attributes using getattribute("worldPosition", ...). All I have to do is export them in the nParticle shape node under Export Attributes. I can't seem to get this to work for "worldBirthPosition" though. Any ideas?

Thanks, Zeno

Tags (2)
Labels (2)
3 REPLIES 3
Message 2 of 4
aaronfross
in reply to: zenop

Hey @Zeno Pelgrims -- sorry to hijack your question, but I couldn't find any other way to contact you. Is there any way to use the existing POTA lens shader in 3ds Max? I set the arnold plugin path and can access other custom shaders in that folder, but not POTA. Thanks

Message 3 of 4
zenop
in reply to: aaronfross

send me an email instead please: zenopelgrims at gmail dot com

Message 4 of 4
madsd
in reply to: zenop

in MAX:

getattribute


paID = int value you can shuffle around as you like, birth index. Can be used to populate vertex number in array or whatever.
paLife = Life of the particle
mtlID = material ID
uv_0 = mapping channel 0 ( a vector ) <- here we can generate all above ids and a ton more.

Position vector exit the particle event to a UVW channel and extract the channel to initiate controller for shader.
- Velocity the same, exit to an unused 3 component vector channel again and catch eg. uv_0 if that is where you store the vector.
- Magnitude velocity just take square root of a^2+b^2+c^2

- I guess size can go on a float too, but it all depends if you can exit a stream to a uv_x because that makes things super simple.

So, there are 2 main routes to go, direct attribute calls with getattribute, or signing data streams to mapping channels and catch with an osl shader.

Signing data streams is by far most flexible as you can totally set the rules up for what kind of radio stream you want to inject into the initial shader that catches the signal.

So I hope your particle generator, or something you can wrap around the particle generator, can generate data streams directly to Vertex channel data sets, or whatever its called in your app. Then things become super trivial to manage.

Here I put a particles on each vertex in the particle generator, extract paID int and feed to an OSL digital display number shader, I assign pr particle. So that the number display actually displays the vertex on the quad plane beneath it in correct sequence.
I add in +1 since index starts at 0 in line 12.

You will notice I set the Digit output to zero and that just enabled the counting of digits and feeds that to the display shader automaticly. its just a trigger.

3684-gg.png

And here is the pr. particle location ID in world space ported from the particle generator, to uv_0 channel which is caught by a shader chain and printed to the closure output -> back to particles to give them a solid color based on location, color is vector, so we can now process the vector data in OSL like normal 3 component vector handling.
I use Arnold data node, but the same apples for the OSL code used.

3685-ff.png

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report