#what's the best way to go about render sorting per prefab?

1 messages · Page 1 of 1 (latest)

round trellis
#

say, I have a character prefab, and I want all the face meshes to render overtop of the hair and head for that specific prefab, but I don't want to remove all the depth rendering of those parts since I want them to still render behind and in front of the environment and other character prefabs

summer terrace
round trellis
#

I'm going for a stylized look lol, kinda like windwaker, faces are 2d, while the hair and the head are modelled, just lookin to render the planes on top of the respective head/hair per character

#

ig in general what's the method I should use for this, not super familiar with this sort of thing in unity, or what I'd even really search to find what I'm after

#

this kind of thing

summer terrace
# round trellis I'm going for a stylized look lol, kinda like windwaker, faces are 2d, while the...

If the parts are transparent there's a bunch of stuff you can do to manipulate render order
https://www.cyanilux.com/faq/#transparent-sorting
Most relevantly "pre-sorting mesh triangle order" if they're one mesh, as transparent meshes are sorted internally by that order
Or if they're separate objects they would be sorted by object distance to camera, so you can have a script offset them a tiny bit relative to camera to ensure a specific order with a tiny change in their real depth (which could be fixed if needed)
But if you don't have a reason to set a material transparent, it's usually better not to and stick to opaque but that means you can't use those two methods

#

You probably could create a feature just like the one described by the video with URP's renderer features, but no idea if there's many instructions for it

round trellis
#

yeah they'd be transparent textures on the planes, and they'd be separate objects, and hmmm

summer terrace
#

The video's method could be simpler than I assume

#

Maybe could be done using this method

#

The eye mask would be the "window" with the stencil shader
And the eye that overlaps with the eye mask would be rendered through everything if the eye mask is drawn on screen at that pixel

round trellis
#

oh interesting, that sounds like it'd work well, thank you

cerulean saffron
#

why dont you just offset the face mesh viewspace z toward the camera?

round trellis
#

wasn't really sure if there was a better method than just moving it, also honestly wasn't sure if that was the method I wanted to use tbh

#

how would I go about that in a script btw? I don't really want to move the bones for the different parts, since I have a target translation setup, but I'm not opposed to just visually offsetting the meshes

round trellis
#

I also didn't want the mesh to clip through objects you get close to, when it's supposed to be on the head of the character

junior dust
#

actually a hard issue because what you're really looking for is internal sorting between opaques while still respecting depth of everything else in the scene

#

You can try messing around with render objects, but I think even if you try to force opaques to render at a specific part of the pipeline you still end up with the same outcome

#

stencil idea can work, but if you have multiple characters with similar setups then it'll conflict between everyone

#

I think the most optimal and correct way to go about this is pipeline script a custom sorting rule for these objects

#

oh, that video actually gives you the answer by just have some clipping mask

round trellis
#

yeah the clipping mask idea seems like a solid solution, just not sure how to translate that to unity, still pretty new to all the rendering features URP has

cerulean saffron
#

it need to be inside vertex function ofc, and after the object to clip pos transformation

summer terrace
#

Moving in clip space z / scaling relative to camera can be very useful but in this case it doesn't guarantee the geometry showing through as intended, and makes it possible to clip through something that's would occlude the eyes

#

Worst case scenario it doesn't fully show trough the head or hair, but also clipping through something in front of the eyes

#

Depends on how much you can control those situations

junior dust
#

pretty good idea and probably the easiest to get working, but yeah you'll have to eye it a bit to get the values you want, and wouldn't be consistent between characters with similar requirements.

#

still, not hard to modify it for each character. It may be a bit more difficult to prevent it from clipping through geometry if say the character does have quite a head of hair... but I guess at that point the hair would be clipping through the geometry too ;p

round trellis
#

Well luckily it’s for characters you can make with the character creator, so they’ll all be relatively the same, though I am thinking it’d be better to have more of a single solution that covers every issue