alaslipknot
alaslipknot

Reputation: 561

How to mask a texture with Unity Shader Graph

So the final effect that am trying to achieve can be found in this tutorial video (unity shader lab) and my case i want to reach this result: enter image description here

So far i created these properties:

enter image description here

And the result is this (no idea why "tiling" has 4 fields even though its a Vector2):

enter image description here

After that, i added 2 new properties:

enter image description here

A tiline and Offset node which has its offset controlled by the Position property, plugged it to a Sample Texture, and multiplied the output with the Emission texture output, and plugged the result to the Emission inpute of the PBR node:

enter image description here

and the result is this: enter image description here

It's kinda giving me what i want but its far from finished, what i can't figure out is:

  1. How to resize the mask area? because for now if i change the Tiling then the result is just too wrong:

enter image description here

  1. Is my "positioning" logic correct ? eventually i want the Position property to be controlled with a C# script based on a game object position, as you saw in my main preview example, i basically want the grid to glow under specific object, so am i doing it right ?

Thanks a lot in advance! i really hope the Shader graph community start getting bigger cause its been super hard to find answers even for the the most basic things.

Have a nice day!

Upvotes: 2

Views: 28947

Answers (2)

Simon Lee
Simon Lee

Reputation: 41

@user40079 was't wrong, he/she just didn't tell you which texture needs to be clamped. I think mask texture need to be clamped to achieve what you want.

Here is my graph.

grid shader graph example for unity

Upvotes: 0

user40079
user40079

Reputation: 133

Try setting the texture's wrap mode to clamp instead of repeat at the import settings.

Upvotes: 0

Related Questions