Jump to content

sorting geometry in the shader


carstenkolve

Recommended Posts

Hi,

I'm quite new to Mantra shading, so please forgive me if this is sort of obvious. I'd like to plug together a shader that renders geo based on a custom attribute rather than the actual order when tracing from the eye. Imagine having 3 planes on top of each other, each having an attribute that indicates the order, whatever has the highest order does get rendered.

I want to use this to correct minor penetrations of geo that I can't resolve on the sop level.

So my thought was to use a "gather loop" to trace from surface "P" along "I" until I hit the next surface, get the order attr on the hit point and then decide what to do with it, if its used, use all the parameters at that P to shade the initial P. Maybe even doing a nested gather loop to gather until there is nothing more to gather (stepping through the micro poly stack). All surfaces are fully opaque and I'm using raytracing.

Now in theory this sounds fine (at least to me) - but I'm having a but of a problem building it in a shading network. I don't get any information back at all. -

What am I missing? Is it something fundamentally wrong, or just some setting I forgot to make?

I've attached a demo scene to illustrate my shader... it is simplified and should just retrieve the color of the first underlying geo.

Cheers!

Carsten

sortingShader_001.hip

Link to comment
Share on other sites

Heya,

a bit of progress and a new problem :-)

Turns out the gather loop seemed to trace right through all of my geo and hence I'd always get the background image and not the last hit surface. So I modified the shader with a conditional part that checks if we are actually hitting geometry or not. This works fine, however I do get this nasty black line where the surfaces are close. Modifying the bias on the rayhit does have an effect on the problem, but it only changes the appearance of the artifact. Is there a better way of checking the if my rays do hit the surface?

Cheers,

Carsten

post-4995-125350226173_thumb.png

sortingShader_002.hip

Link to comment
Share on other sites

ok, just a small update with a few results...here a screenshot of the shader doing its thing, some static scales on a snake (well, tube) first rendered without the shader clearly showing all the penetrations, then the result with the shader applied - it brings the sample to the front based on an "order" attribute and makes the penetrations dissapear

you can light it with a custom illuminance loop - haven't looked into shadows, motionblur etc, yet

a thing I've learned is that hooking up loops with lots of variables is a pain, should have a look into writing the vex code instead

post-4995-125412209889_thumb.png

sortingShaderExample_001.hip

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...