j00ey Posted October 16, 2014 Share Posted October 16, 2014 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 Quote Link to comment Share on other sites More sharing options...
j00ey Posted October 16, 2014 Author Share Posted October 16, 2014 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. Quote Link to comment Share on other sites More sharing options...
j00ey Posted October 17, 2014 Author Share Posted October 17, 2014 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... Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted October 17, 2014 Share Posted October 17, 2014 (edited) 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 October 18, 2014 by Stalkerx777 Quote Link to comment Share on other sites More sharing options...
j00ey Posted October 17, 2014 Author Share Posted October 17, 2014 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? Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted October 18, 2014 Share Posted October 18, 2014 I recommend you to try Packed Primitives instead. Here is a simple scene. You can get any attributes from packed primitive in your shader, using inline code. prim_attribs.hip 3 Quote Link to comment Share on other sites More sharing options...
j00ey Posted October 18, 2014 Author Share Posted October 18, 2014 That's great, thanks very much! I must get to grips with inline code, this is exactly what I was looking for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.