#Reveal/ rub shader for URP

1 messages · Page 1 of 1 (latest)

brave robin
#

I'm trying to find out how to make a shader that can be "rubbed" away to reveal what's on the other side.

It's going to be a mesh top layer, that looks like sand, and gets "brushed" away to reveal a bone (another mesh) underneath.
I'm struggling to find tutorials on google, but this could be because I'm not sure on the correct terms and searching for the wrong things.

woven nacelle
#

Hi, i found this one

#

searched for reveal shader. Pretty old but might be what you are looking for

#

unfortunately not in urp

brave robin
#

I saw that, but it's not a tutorial?

woven nacelle
#

do you want to write the shader or use shader graph?

brave robin
#

either is fine - would prefer shader graph

#

I know next to nothing about writing/ making shaders

woven nacelle
#

been using shader graph for a few simple things, like grass sway, objects outline etc

#

would be a nice experience tho to achieve this effect just for training purpouses.

brave robin
#

I'm not sure how to break it down into smaller parts to learn

#

need to know

  • how to do the brush
  • how to "paint" that brush shape on the mesh/ material?/ texture?
  • how to set the brush shape transparent
woven nacelle
#

yeah, i was also thinking about the brush part and how tricky it could be.

chrome bison
#

A fairly common/easy way for painting on a flat(ish) area, would be an additional camera, orthographic, RenderTexture target and using cullingMask to only render a specific layer, where you draw a transparent quad with the brush texture or particle system (that you then move/emit through a script, e.g. at mouse position)
I think Camera background can be Uninitialized so previous frames get stacked if you want the painting to be permanent.
example : https://80.lv/articles/recreating-the-drawing-mechanic-from-half-life-alyx-in-unity

Or can handle a similar setup all in code, using two RenderTextures, and Graphics.Blit with a custom shader that draws the brush at a particular point. Each frame swap between the two textures to avoid blit using same source/destination
.

#

With either method, can then use the resulting RenderTexture to displace vertices / alpha clip in the sand shader

brave robin
#

@chrome bison that first method may be ok, I'm gonna try it out later - thanks.

The project is in AR , and I was hoping to not have it flat (will if I have to though).

woven nacelle
#

Good news , i found a tutorial and i got it working

#

not easy but it works

#

had to use some image to text converter which gave me tons of typos, had to corrct a lot of things.

#

and there is a small typo in his code in the PaintWithMouse script,
currentMaterial.SetTexture("_SplatMap", splatMap); // this is correct with the underscore

brave robin
#

Ace, cheers - can it go transparent?

woven nacelle
#

it has a splashmap so it reveal the texture under, i think it should be possible to do that too

#

seems to be something you´d have to find out and implement

brave robin
woven nacelle
#

yeah this is looking promissing