Home Technical Talk

Ground Sand Shader - Need some help

interpolator
Offline / Send Message
Shrike interpolator
Hey
So I have this ground sand gradient shader, not a real intersection shader but a cheap solution that is good enough from a top down view

Now this works well for objects that have a pivot at the bottom, like a Building or a Lamppost or something that stands on the ground
For rocks however, that dosnt work at all, as they are rotated and moved a ton.

Using object position AKA the Pivot, you can see the downfalls here:



(The cube shows the problem, with a pivot on center, the sand effect is not working, or the stone on the right is rotated and floating but still shows it)

Now I could use world position instead of object position, the issue there is that the terrain is not flat, and at different heights that would not work.

Here is my simple setup:





Some ideas:
- Object intersection shader based on camera depth? No experience in that but might work? but then the stones also intersect each other?
- World position with a terrain height map for an offset? - Not the greatest workflow but could likely work
- ??

How do you go about this?

Replies

  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    Depth offset will probably work - I'm fairly sure that's how they did it in journey.

    I usually use mesh distance fields in unreal for this sort of thing - not sure if that's available in unity

    Or you can use the object's world space bounding volume to generate UVs 
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    poopipe said:
    Depth offset will probably work - I'm fairly sure that's how they did it in journey.  - This is fairly simple to implement and to use, and not expensive either. I would probable use this solution, although its a fake solution, and can cause objects to appear a little bit floating.

    I usually use mesh distance fields in unreal for this sort of thing - not sure if that's available in unity - Personally I don't really like this solution, because it requires storing and sampling mesh distance fields, so its kinda expensive and not very high res.

    Or you can use the object's world space bounding volume to generate UVs  - This is the cheapest way, but requires some parameter tweaking on some shapes. Its also kinda hard to get it working with instancing.

  • Shrike
    Options
    Offline / Send Message
    Shrike interpolator
    Thanks!
    That dosnt sound super amazing all in all, but ill give the first a try
    Otherwise I will just vertex paint it by hand I guess.
Sign In or Register to comment.