Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Suggestions for wrapping a sand texture around an arbitrary coast (within certain limits)

Discussion in 'Shader Graph' started by ben_and_his_beard, Jul 27, 2023.

  1. ben_and_his_beard

    ben_and_his_beard

    Joined:
    Nov 29, 2016
    Posts:
    6
    So here's the scenario:

    I've already built out my terrain shader in Shader Graph and begun the arduous process of choosing which features I don't actually need. We're running things in VR for Quest 2 with URP, so even using the built-in terrain system is too expensive. The use case is a set of small islands, a focus on rapidly adding new ones, and a complex opaque water that bypasses the expense of active depth passes on our hardware.

    The current feature set uses two primary textures blended automatically at a height based threshold (grass over sand), with height mask blending for pretty edges. Vertex Color R is being used to nudge the the threshold up or down so that I can manually curate patches of grass and paths with ease. We have a second height based blend adding wetness to the sand at the current water level, and a few other unrelated features.

    The problem is that our textures are applied in world space, rather than UV space, giving us no control over the direction of the sand. Our islands are small, so wrapping the UVs around the coastline would almost immediately lead to pinched texture placement at the center, and would demand an extra level of cleanup on the topology to keep edges flowing around the island (this gets in the way of prototyping and should be done with a retopo tool later on if at all).

    So to the actual problem, the grooves in the sand run in the same direction no matter which way the coast is facing. I would like to be able to rotate them relatively cheaply to follow the shoreline, but don't quite know if that's feasible. A static flow map comes to mind, but could add expensive math (for VR at least) to an already loaded shader (fog + wetness in the rain + tides). I would like to keep the sand ripples because they look good. Adding a third layer with a second sand facing a different direction would kind of work, but is a little more clumsy than it's currently worth. Radial UVs would create a pinch and would fall apart with less circular islands (likes a crescent).

    Any suggestions on what might solve this?

    terrainBlend_03b.PNG