Jump to content

Point Instance Procedural - how to get attributes in shader


j00ey

Recommended Posts

Hi

 

Can anyone give me a pointer as to what I'm doing wrong here? I'm trying to learn my way around some of the procedural shaders, currently the point instance procedural.

 

Attached is a HIP but a quick explanation. I have some very simple geometry, a line with 11 points, onto which I'm instancing spheres. I've set the v attribute on the points to be in positive Y, increasing with point number.

Mantra is definitely reading it as motion blur works so I thought I could get the length of the velocity vector and use that to mix between colours in my shader but I cannot get it to work. I tried using getblurP instead and subtracting that to get a vector and for some reason that does work... Somewhat confusing!

 

What I was planning on doing eventually was making a bubbles shader that takes the dot product between normalised v and normalised N, remaps that to 0-1, then uses a ramp to displace the surface - using the dot as a lookup and length of v as a multiplier. The idea being to get a flatter front to the bubbles in the direction of travel, more like mushroom caps.

 

Thanks in advance. I'm sure I'm missing something simple.

instanceShadingProblem.hipnc

Link to comment
Share on other sites

ps you can see what I'm talking about if you render the scene with the mantra ROP in there, the instanced spheres' colour changes from red to green based on the greater magnitude of P-getblurP but if you go inside the shader and hook up the v param instead, nothing happens.

Link to comment
Share on other sites

Attached are a couple of screengrabs in case it makes the problem clearer.

 

I have a line with 11 points, their velocity in Y ranges from 0 to 2. On to these points I'm instancing spheres. The shader attached to the spheres should use the length of v to mix between red and green. If I render the line itself using the same shader and with 'render only points' I get exactly what I would expect [see 3rd attachment] but it seems on the instanced geometry I can't use the v attribute [see first 2].

 

Thanks for reading...

 

post-9168-0-63372300-1413539943_thumb.jp

post-9168-0-06182100-1413539966_thumb.jp

post-9168-0-99280000-1413540418_thumb.jp

Link to comment
Share on other sites

For some reasons (i guess performance reasons) , SideFx decided, that users don't need access to attributes defined on points. This is the biggest downside of point procedural. There are some hacks to get attributes, like sampling a point cloud from shader for example. There is also a trick to get random number for each copy. But no "clean" way of doing that.

Edited by Stalkerx777
Link to comment
Share on other sites

Hi Alexey

 

Thanks very much for the info, I was sure I was just missing something basic.

 

In that case, could you point me in the right direction for deforming a load of bubbles at rendertime based on velocity? Do I have to do the copying in SOPS and then the displacement in the shader? Or is there some other method of instancing that would give me the control I need?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...