#archived-shaders

1 messages ยท Page 6 of 1

karmic hatch
#

You could perhaps do something where you figure out where you are in the basis of the flake (create two random vectors A and B; then create a matrix (A, normalize(cross(A, B)), normalize(cross(A, cross(A, B)))), then multiply view direction by that matrix, yielding vector V) and then you can multiply V by some large number, floor, and add a half, to get vector Q, and check where that is relative to V (so rather than dot(view direction, random vector), do dot(V, Q))

#

Should turn each individual flake into a disco ball

zinc elm
#

it was brackeys ๐Ÿ’€

#

but thx tho

#

it works now

#

how can i make it so u can see the hexagons better all aroudn the forcefield instead of j mainly at where it touches ground

#

cant see the hexagons at all on the side here^

tight phoenix
#

How would I change my voronoi code so that the cell center is not the center but more like each cell is a ramp in an arbitrary direction? ๐Ÿค”

#

can such a thing even be done?

#

I have random directions from that random node

#

x/y problem

#

im still working on this stupid POS

#

but every cell in my body is screaming that its wrong, its uncanny, its completely wrong wrong wrong, its no good

#

I cant figure out what I have to do to make it not shit

#

im physically revulsed by it

#

my graph just keeps getting bigger and bigger and messier and messier and I become more and more miserable because nothing I do works, it just looks like complete shit and I dont have reference for what looking good would look like, all I know is that its WRONG

#

its WRONG why caNT IT BE RIGHT

#

in crisis again time to go

honest obsidian
#

Hey, I don't really know anything about shader graphs for unity, but I've got this graph im making from a youtube tutorial and the video is out of date, but seems to still be somewhat transferable, and im getting the magenta shade of death on my preview, but idk where the textures arent being detected, or what's going wrong here.

#

If anybody has ideas on how to help, I'd appreciate it

#

I can make it in Blender just fine, but idk how to make it in Unity. Trying to get a gradient into a transparency, and the closest thing I tried was this dithering texture video:

#

Learn how to create a dithering transparency effect similar to the one used in Super Mario Odyssey using Unity Shader Graph! This tutorial is also available in text format here: https://danielilett.com/2020-04-19-tut5-5-urp-dither-transparency/

๐Ÿ’ป Get the source on GitHub:
https://github.com/daniel-ilett/dither-transparency-urp
โœจ ...

โ–ถ Play video
copper harness
#

Is it possible to reference a float from a monobehaviour to a script?

devout plaza
tight phoenix
devout plaza
#

I'll add more details, unless you know what could be happening right away, but my preview shows the sparkles, but my capsule model does not. I saved the asset.

#

It also does not show the sparkle effect in VR in Altspace.

#

I do have some properties, but I made sure they are set similarly to the one in the model.

#

Interestingly though, one of the properties in Shader Graph will only work if set to a value < 1. But for the model, it needs to be > 1.

#

I know this is all probably very vague without thorough explanation.

tight phoenix
devout plaza
tight phoenix
#

the only interesting thing im doing here is I am multiplying the round distance voronoi at the end so that the glitter is not solid chunks

devout plaza
#

Mine seems a bit different

tight phoenix
#

Ah yeah I followed that one as well

devout plaza
#

I do not use voronoi

#

cool

tight phoenix
#

not for the above, but when I was trying to do a glitter that one came up

devout plaza
#

I see

#

Maybe it has to do with my scene's lighting? I just don't know.

#

For instance, when I turn the camera around, the base color is extremely apparent

tight phoenix
#

I'm no expert, but in my experience the preview and scene view rarely match up
You can try rightclicking on the preview of the final model and switching it to the capsule there

#

in case its the mesh that is the difference

devout plaza
#

Ah good idea hold on

tight phoenix
devout plaza
#

Naw the capsule in the preview is fine

#

I just changed the ambient occlusion, which helped that nasty gray color

tight phoenix
#

Did you check the material properties to be sure they're the same as these ones?

devout plaza
#

But still the problem is, it does not display the sparkles in the scene's preview, or in VR

tight phoenix
#

when you make the material, if you make any changes to the graph, the material wont update

devout plaza
tight phoenix
#

Thats weird

#

I wish I could help more but debugging is not my forte, you could maybe try deleting the material and remaking it, just in case

#

it can be fixed, but it will be a struggle (in my experience)

#

perseverence, and trying others tutorials, and posting in this channel

devout plaza
#

Alright. Yeah it's all part of learning, and hopefully I'll know what's going wrong if it happens again

#

Actually it makes sense that it would not show up in the scene, so I do have to start with it being pink like that and figure out what's wrong

#

Finally I got it. One property was the texture. It listed the default,, but when I actually went and browsed for it, and select it, it fixed it.

zinc elm
dim yoke
copper harness
dim yoke
#

Ah, my bad, other way around, use SetFloat, direct reference is still not possible. You have to set every time the float changes

grizzled bolt
#

It could also mean no valid active target, but most likely you're trying to make an URP shader without URP configured

karmic hatch
#

Get a little bit of bloom on them so they look like they're flashing vs blinking on and off

#

You could take the dot product part, do acos, negate, multiply by your power float, exponentiate for brightness as well which should make it broader around the peak

#

Also you could try swapping to dot(reflect(view direction, random vector), sun direction), and multiply by saturate(dot(surface normal, sun direction))

#

And to make the sparkles more localised, in the reflect() you can swap random vector for normalize(lerp(random vector, normal, some float))

#

(btw every mention of view direction is normalized view direction)

karmic hatch
karmic hatch
terse whale
#

I have this grass shader, and I want a potentially endless list of objects(their positions) to push the grass away

#

Not sure how I could let the shader know what the positions are

mental bone
#

I would fill a pre-allocated structuresbuffer

#

Not endless but can be large enough

#

Better than doing a 2 copies and redeclare to have it expand

meager pelican
#

@terse whale^^ that, if you can build it per-frame, so you have less to trod through each frame. Or if it is small enough to encompass the world, with changes.

But if not any of those, you could try screen-space depth buffer calcs. It would be rough though. I mean, you'd know there was something in the area, but you wouldn't know how DEEP it is. It could be 2 pixels wide from the view direction, but 100 units deep in world space. But if it occludes the grass, you may not notice much, since you'd only offset sideways.

I suppose you could do a sort of occlusion map as you draw everything, kind of like how they handle snow/mud indentations when things get drawn. So all your objects could draw into a world-space map as if viewed from above...a splat map more or less...and you could check world-space occlusion as you draw the grass LAST. That has complications too, like for things that have "legs" and aren't covering the whole ground where they sit...so you could also have a texture map of its "footprint" from above to draw into the worldspace map.

That map would have to be redrawn whenever things move, or completely drawn per frame.

honest obsidian
honest obsidian
wind pilot
#

hi all, I am having this issue:

Maximum number (256) of shader global keywords exceeded, keyword VARIANT23 will be ignored. You will have to delete some shaders or make them use less keywords.

#

would this issue prevent shaders from working in the build? Because I have some shaders I did myself (in HDRP) that work in the editor but not in the build. Thanks a lot!

leaden zinc
#

hey hi, im making a masking shader that renders everything inside the bounds of a collider.
Question is, how can i keep things once they are already rendered?
Ideally the character has this collider and as he moves the dark areas stay rendered.
Right now it renders everything in the collider but as he moves away it goes back to black oc. How can i save this information?

regal stag
# leaden zinc hey hi, im making a masking shader that renders everything inside the bounds of ...

One common way is to use an orthographic camera, pointing down over the scene. Using a Render Texture target, that doesn't clear. Can render a sphere/particles/etc to it around the player.

Then sample that Render Texture in the shader and use it for masking - using world position XZ rather than model UVs, and with some remapping to get it synced up.

This kinda only works with flat scenes without any verticality though. It's the same sort of thing that is used to add interaction to water/grass shaders or trails to sand/snow.

leaden zinc
# regal stag One common way is to use an orthographic camera, pointing down over the scene. U...

Mmm i can see that, the target effect is for an autogenerated dungeon, so in the end what i'd want to do is have a collider per room, and render the room when the player walks in, mask out the rest that hasnt been visited already as well as surroundings.
(3D top down rooms)

I was considering making the approach you mentioned, predefining the room's bounds with colliders may have a cleaner final look for what i want.
Instead of having the character render around him.

regal stag
#

Am a little confused when you say colliders as the shader doesn't know anything about the physics system. I guess you're sending positions into the shader via properties?

leaden zinc
#

Yeah sorry, i use the collider bounds to calculate positions.

#

So i'd pass those to the shader

regal stag
#

What does the background around these rooms look like? Couldn't you add a "ceiling" (with that same colour/texture) to each room which starts completely opaque but fades as a player enters the room?

leaden zinc
# regal stag What does the background around these rooms look like? Couldn't you add a "ceili...

i've tried this placing black walls. Ceiling isnt really a problem.
Thing is, these "rooms" are open spaces in my dungeons, like forest open spaces sticked together, so you can kinda guess what comes next room visually even with a ceiling.
Camera is per room, and has confiners, yet because of the perspective you still can see some of the others contents.

Usung black walls imitate the depth of the fotest, but looks a bit wanky tbh.
I was looking to create a more natural boundary for the rooms so i thought on playing with shaders that might give me more control for transitions (like disolving rooms or just making an actual gradual darkness/depth effect.)

it was also for the sake of learning shaders.

regal stag
#

Hmm yeah, but in this case the rooms look completely separate. The whole screen goes black and transitions to the next room, likely teleporting the player in the process.

leaden zinc
blissful atlas
#

does anyone know if it's possible to force a shader to never support reflection probes/shadow casting/shadow receiving/etc?

#

basically doing this on a shader level instead of having to do this on a per-renderer basis

#

(basically it breaks batching when the shader doesn't even support these things, at least the reflection probes break it)

regal stag
blissful atlas
#

I'll try!

#

nope, same issue

#

im justngonna go cry in a corner then

#

working with invisible/ethereal renderers is, not super nice

#

really wish we could extend from Renderer

#

it's fine everything's fine

frank mantle
#

whats the best way to send an int array to a shader via c#, since there isnt a nice material.setintarray method?

#

are we supposed to just hack it together with a buffer?

#

or go even hackier still and send floats instead?

#

i realise that directx and opengl werent really meant to deal with ints until just a few years ago, but sending floats as indices is a little too rough around the edges for me

shadow locust
zinc elm
#

i used brackeys forcefield shader tutorial

thin crater
#

Hi! I'm trying to use Unity's cartoon shader v2 from there:

#

I'm using URP. Everything in the editor works pretty well, but in the build shadows doesn't work for object that has this shader. Lit shaders cast shadows. How can I fix that?

#

Shadow mode is on on the renderer, I tested that on multiple objects, and settings is on ultra. Also urp settings is set to very high.

regal stag
#

Is the graph defining _MAIN_LIGHT_SHADOWS keyword?

thin crater
#

Yrah

#

But it doesn't seems like he uses it somewhere...

regal stag
#

Shouldn't need to use it in the graph. It's used by the ShaderLibrary files.

thin crater
#

In the editor this shader works really well

#

Shadows are a problem just in the build

meager pelican
#

One way to check if it is using a fallback is to create a shader that fills everything with a single color other than hot-pink. Like, say, an orange color. And set that for the fallback shader even if you have to make a temp copy of the SG file output and do a search and replace for any fallback. IDK if there's an option to set the fallback directly or not.

#

I admit I'm guessing a bit.

polar vector
#

Hi, is it at all possible to change colorspaces at runtime? It's very needed in my game

thin crater
#

Default is ultra

#

Also cleared playerprefs, just in case quality had been different sometimes in the project

thin crater
#

I don't know what you would try to get with that, check if quality is a problem?

#

I'd think that this works anyway

#

since normal lit shaders works

#

(in the build, too)

meager pelican
#

It won't be using a fallback for you desktop windows build, so nm.

thin crater
#

Any other way to fix that? I'm really a noob with shaders and my guess is that this shader was not built for urp

#

but then, why would it work perfectly well in the editor?

meager pelican
#

IDK why it doesn't work....

#

You can try and post the shader and see if anyone can duplicate the problem.

thin crater
#

It should be the same as in the tutorial

#

The one I'm actually using is a bit modified, I merged it with a grass shader from brackey's. But both of them doesn't work, and I think that if I can make work the basic toon shader, I can make mine work

#

(I'm testing anyway with the basic toon shader, to be sure that I did nothing bad)

regal stag
#

Have you tried the one in the main branch? It might be more up-to-date
Though I don't really see any reason why this one shouldn't work too.

meager pelican
thin crater
#

Doesn't work

polar vector
thin crater
#

looked at the wrong comment sry ahah

polar vector
# meager pelican This looked interesting, but IDK your use-case. https://medium.com/@abdulla.ald...

Actually yeah, no looking it over thats not what I want but is cool! Basically I have an old game we worked on that I want to convert the textures and art over to unity to look the exact same - for older users they can convert their old work over, but for newer users we want to use linear rendering. When using linear rendering with the old stuff and converting the gamma colors to linear to look the same the blending of some colors looks off. Which we need it to look the exact same. So we can do that by just using gamma color space but we'd like to use linear.

#

Very niche case ahah.

meager pelican
polar vector
#

Yup I've seen those examples

meager pelican
#

I think some stuff gets converted on import into the asset database. So it's a workflow thing, not a runtime thing. (well, really some of both I guess).
So unless you do it mathematically in the shaders...like that first article talks about, maybe with shader variants, IDK what to tell you. It's all in the math, and also in the final conversion that Unity/GPU will apply to the hardware. As you've read in those articles. I don't know of any magic bullet here. From what I'm reading, that is.

meager pelican
polar vector
meager pelican
#

Sure you can. It's all math.

#

So you'd do the blending equation yourself.

#

But it's probably slower since you have to read the back buffer to know what you're blending on top of.

#

See the shader lab page for the blend command. That's all the math.

#

You can do that yourself and output an opaque result.

#

But yuck.

polar vector
#

So I'd just turn Blend to Off and use the grabpass to do the blending myself I guess?

meager pelican
# polar vector So I'd just turn Blend to Off and use the grabpass to do the blending myself I g...

In BiRP you'd use grabpass, or some form of it (there's an option to do it similar to URP's grab-at-end-of-opaque by naming the grab texture and doing it at the right time).
In URP, you'd use the opaque texture grab, and do your special blending in the transparent materials/queue. URP doesn't use grabpass in shaders that I know of.

So for a traditional blend, you'd do something like
resultRGB = sourceColorRGB * opacity + backgroundColorRGB * (1-opacity).
I think that's it.

#

You could have those colors mathematically in any color space I'd suppose.

#

This is all spit-balling, so grain of salt.

#

Don't ask me how to convert between color spaces but I'd look for existing macros.

polar vector
#

Hmm okay ill look into it, I tried to use the grab pass a bit before without blending and couldnt get it to blend right but I'll keep looking into it, thanks!

polar vector
#

Yup

loud wedge
#

Hello everyone, I'm new to shader programming and am using a stencil to see through walls that are obstructing the player like so: ```
Stencil
{
Ref 1
Comp Always
Pass Replace
}

The problem is I cannot see any of my image effects through this shader, is there something else I can add to make them show up?
meager pelican
# polar vector Yup

Yeah, there's a "named texture" option IIRC, that let's you grab and save a texture, like using a full-screen quad to grab the screen. MIGHT be better to use that if you have a lot of blending to do, similar to how URP does it. But if you need to, you could do an unnamed grabpass per object as it is shading. It's a 2-pass operation then...one to grab the background and the next to shade over it. It's more expensive that way, which is why URP switched to the newer method.

polar vector
kind juniper
#

One is a shader graph shader that you create via the shader graph.
The other is a regular shader shader that you write with your own hands.

thin crater
thin crater
#

I fixed it, finally!

thin crater
regal stag
thin crater
#

Maybe yes, I'm using 2022.1.3f1

#

Maybe they're already defined, by default

regal stag
#

Maybe, but defining them twice also shouldn't do anything

#

I'll try it out on Unity 2022 a bit later

tight phoenix
#

I would like to add a very bright star-shaped highlight to this overtop of only the highest value dots ๐Ÿค” I have a highlight texture, but I can't seem to figure out a way to map it to the center point of voronoi cells

#

Im -still- trying to get this glitter to not be shit but ๐Ÿคทโ€โ™‚๏ธ

#

its gotten a little better but its still not right, not good enough, not the look I want

tight phoenix
karmic hatch
#

(and normalize)

karmic hatch
terse whale
#

trying to make my grass receive shadows

#

but it applies like a mask

tight phoenix
karmic hatch
tight phoenix
#
    for( int j=-1; j<=1; j++ )
    for( int i=-1; i<=1; i++ )
    {
        int2 b = int2(i, j);
        //storeRand = voronoi_noise_randomVector(p+b, AngleOffset);
        //randRes =  voronoi_noise_randomVector(p+b, AngleOffset);
        //float2 r = float2(b) + storeRand-f;
        float2  r = float2(b) + voronoi_noise_randomVector(p+b, AngleOffset)-f;

        float d = dot(r,r);

        if( d < res.y )
        {
            res.y = d;
            mr = r;
            mb = b;
        }
    }
    Distance = res.y;```
#

this is the code that draws cell distance circles

#

if I wanted to map UV data in there, I know that it starts at 0 and increases/decreases linearly on the x/y

#

Out would be a vec2

karmic hatch
#

Create, say, float2 RadiusInCell outside the loop, then in the if statement, set RadiusInCell= r;

tight phoenix
karmic hatch
#

Nice!

tight phoenix
#

a test

#

This seems like it will be very useful

karmic hatch
#

Maybe also divide by ddxy of the out vector

#

Before the tiling and offset node

#

(should make it look flatter)

tight phoenix
#

Flatter?

karmic hatch
#

So the lens flares don't look stretched or squashed on the sides of the cube not facing directly towards you

tight phoenix
#

Like this?

karmic hatch
#

ye

tight phoenix
#

for some reason, nothing shows up

#

oh you're saying that it will correct this portion

#

to be still screenfacing?

karmic hatch
#

it should roughly do that

karmic hatch
tight phoenix
#

Ahh that worked, 0.01

karmic hatch
#

wonderful

tight phoenix
#

Neat, this is really cool, gif is fighting me 1 sec

karmic hatch
#

:)

tight phoenix
#

gunna check that 'every shadergraph node' video to see what DDXY even is

karmic hatch
#

It's the sum of the screen space derivatives of whatever the input is, so ddx + ddy

tight phoenix
#

Derivatives I see ๐Ÿค”

#

the difference in value between this pixel and the next

karmic hatch
#

precisely

tight phoenix
#

zooming in and out affects the UV Tiling resolution

#

without it works as expected

karmic hatch
tight phoenix
#

there are strange white lines around each cell ๐Ÿค” as far as I can tell they exist straight from the output

#

subtracted them out from the voronoi

#

not sure why they exist in the first place though

karmic hatch
#

Nice

#

Idk either, seems a bit weird. Might be an antialiasing thing?

tight phoenix
#

oh the border of each cell its doing some kind of blend and that causes the UV coordinates to get weird there?

regal stag
#

It relies on DDX and DDY to calculate the mipmap level for sampling. And since the UVs jump, it's trying to sample a quite blurred mipmap along those pixels

#

Could fix it by disabling mipmaps for that texture or using a Sample Texture 2D LOD node.
(Or whatever the equivalent of tex2Dgrad is (SAMPLE_TEXTURE2D_GRAD()?), which would allow you to specify the ddx/ddy values, which you could get straight from the regular UV)

tight phoenix
#

Feels like we're getting somewhere ๐Ÿ‘€

echo flare
#

I fractured a mesh in blender and need the pieces to break off individually, not all at once. The seams are noticeable when rendered in unity. Any tricks on how to hide them? Not worried about the normals, just the white speckles

tight phoenix
regal stag
#

I imagine the speckles are being caused by the normals.

#

Can maybe use a Data Transfer modifier to transfer the normals from a non-fractured version of the mesh. Not sure how that'll look for the interior faces though.

echo flare
echo flare
regal stag
regal stag
dim yoke
#

Maybe mesh deformation c# script would be the best choise but i dont really know how id do that exactly

tight phoenix
#

better ish, I rotated the star UVs to be more randomized, and make them spin as well

#

but I'm starting to have doubts ๐Ÿค” feels like its moving away from good back towards bad/uncanny

#

every setup I do its incredibly difficult to control the ammount, intensity, density of the glit

#

easier to see the rotation and random rotation offset

regal stag
#

The dots and sparkles might be a bit big. The sparkles especially keep getting cut off by the voronoi which isn't looking that great.

tight phoenix
#

yeah I was wondering if I could edit the voronoi code to not be cells

#

to fix the cut off

#

I dont think its possible to do that though

karmic hatch
#

have you added bloom?

tight phoenix
regal stag
#

Yeah, Bloom (and other post processing) can really help make stuff look good

tight phoenix
#

I dont know why but I feel adverse to postprocessing, it feels like trying to fix a nail with a sledgehammer. Bloom might have tons of other affects on stuff in the scene so I dont want to add it just to fix this one thing

karmic hatch
#

Unless other stuff has areas where the color goes >1 (in which case saturate the result), it should be ifne

tight phoenix
#

if I use a different size cell for the glitter I can remove most of the cut-off, before I was trying to use the same cell size for the glitter and the other glitter

#

its the weekend, im going to have lunch and keep thinking on it ๐Ÿค”
I have some resin glitter dice ive been studying carefully trying to figure out what it has and mine does not, iunno if its helping though

slender sonnet
#

Heya, was wondering how i could use shaders to create something akin to this (in this case just used a perspective camera with 45 degrees angled quad) but with an orthographic camera?

echo flare
slender sonnet
#

problem with that is it's an orthographic camera, hoped the shader would be the workaround to it

tight phoenix
#

๐Ÿค” I think I might finally be satisfied with that

#

the bright spike highlights were what was missing making it uncanny

#

without the spec highlight blocking it

dim yoke
karmic hatch
#

If I am not mistaken, each vertical line would be when x/y={an integer multiple of some value plus an offset}, and each horizontal line is when y=arctan(1/{some integer}), idk where the offset goes tjere

slender sonnet
karmic hatch
slender sonnet
polar ruin
#

is there a way, to place nodes on shadergraph from code?

say I have a shader graph
and i want to add a multiply node
but I want to add it from a c# script and not use the UI
is there a way to do that?

regal stag
regal stag
# polar ruin yes, exactly

I have a package which adds some Register/Get Variable functionality to SG
https://github.com/Cyanilux/ShaderGraphVariables

More importantly in it's "Extra Features" I also added keybindings for quickly placing nodes at the mouse position. By default bound to the alpha number keys.
Could see how I handled that in ExtraFeatures.cs (also first part of SGVariables.cs, to actually allow the editor to run the code) and maybe adapt that if required.

polar ruin
#

very nice, i will have a look
thank you

karmic hatch
swift flame
#

Is it posable it add ignore Tag to shader graph shader?

tight phoenix
#

shadergraph question ๐Ÿค” half my nodes turned grey, the nodes themselves not the output. Anyone know why?

#

did I hit some kind of hotkey or toggle some option?

#

trying to google it all I get results for is the shader itself doing stuff involving grey and transparent

regal stag
#

Where is that chain connected to? It usually means the master port is not used by the current Graph Settings / Target.

tight phoenix
#

and was using emission before ๐Ÿ‘€

regal stag
regal stag
tight phoenix
#

to the best of my eyeballs, the results are the same (first turn is arcosine, second is power mult)

tight phoenix
#

I can remove it by force but it looks kinda bad, and it stops working at steep angles

regal stag
#

Hmm odd

#

What does the graph look like before the distance node?

tight phoenix
#

the only place I can see that might be the cause is the custom node voronoi has a bug written in it by me?

regal stag
#

You're using DDXY, so that'll be why it's causing the lines

tight phoenix
#

oh should I not be?

#

or is that just an artifact of DDXY that cant be avoided?

regal stag
#

Eh idk, my knowledge on DDXY is quite limited

tight phoenix
#

Fair, same here. Panzer was the one who suggested it to me

regal stag
#

Should just be able to use the UV_Cells directly into the UV on the Tiling And Offset?

#

Or use the Spherical output on the Voronoi I guess

tight phoenix
#

Looking at that now. The purpose of the DDXY is that at a steep angle the sparkles are still spherical instead of getting thinner

regal stag
#

Hmm I see

tight phoenix
#

I wonder if I could get the same effect by somehow using a fresnel to stretch the circle ๐Ÿค” Ill experiment with that now

swift flame
swift flame
# regal stag What are you trying to do?

I followed this tutorial on how to add decals
https://youtu.be/f7iO9ernEmM
and I only want decals to show on the environment not the player, or enemies.
_ _

Decals have been available natively in HDRP for a while now, but not URP. Luckily, there are ways to add our own. In this tutorial, learn how to use some neat tricks involving space transformations and the depth buffer to make decals of our own which project a texture onto flat or curved surfaces!

โœจ Based on NiloCat's fantastic impl...

โ–ถ Play video
karmic hatch
#

But otherwise functionally the same

karmic hatch
meager pelican
karmic hatch
#

Cell UV

#

not the UV UV

regal stag
# swift flame I followed this tutorial on how to add decals https://youtu.be/f7iO9ernEmM and I...

Well I don't think the IgnoreProjector tag would help here as that tag only works in the Built-in RP afaik.

One way to make it not appear on players/enemies would be to use Stencils.
Shader Graph doesn't really have stencil support, but can still use two RenderObjects features on the Universal Renderer asset, instead of rendering those layers normally.

  1. Put player/enemies on "Player" and/or "Enemies" layers. Put decals on "Decals" layer.
  2. Remove those layers from the Opaque Layer Mask at the top of the Universal Renderer asset.
  3. Add RenderObjects feature, Event : Before Rendering Opaques (probably), Filter to Layers : Players/Enemies. Use the Overrides to add Stencil, Value : 1, Comparison : Always, Pass : Replace.
  4. Add another RenderObjects feature, Event : After Rendering Opaques, Filter to Layers : Decals. Use the Overrides to add Stencil, Value : 1, Comparison : NotEqual, Pass : Keep, Fail : Keep.

(Or as Carpe mentioned above, could use a separate camera to render the players/enemies ontop. Though I think that may be a little bit more expensive)

tight phoenix
#

ive definitely made a mistake ๐Ÿค”

karmic hatch
#

(length(cell UV) is the usual voronoi output)

tight phoenix
#

somehow I made cubes, and also its still backwards

karmic hatch
#

Hmmm

#

You'd actually only want to scale it in one axis

tight phoenix
karmic hatch
#

The axis would be cross(view direction, cross(normal, view direction)) in 3D space

tight phoenix
#

the top node there is view direction the name is just out of frame

karmic hatch
#

I think the ddxy method would be most reliable tbh

tight phoenix
#

It creates pixel lines that I cant eliminate

karmic hatch
#

Could you set it to just repaint black everything that's near the boundary of two cells?

tight phoenix
#

this is as good as I was able to get it

tight phoenix
karmic hatch
#

There's definitely a geometric way of doing it

#

But you also need a way to get the 3D vector directions the UV g and UV r change along

tight phoenix
#

interseting as heck way its not workin

tight phoenix
#

I have the cross cross product, and the UV R and G

#

incidentally do cross products care which node is top bottom ๐Ÿค”

karmic hatch
#

Yes, but only a sign difference

tight phoenix
#

length mult one minus gets me the circles

karmic hatch
#

saturate at the end bc we don't like negative colors

tight phoenix
#

Will do

#

You said divide but im not sure what/where gets divided

karmic hatch
#

you need to figure out the UV g and UV r directions in 3D space

#

It changes for each face though

tight phoenix
#

oh

#

my thing is a cube so I can just use world position for that I think?

#

object rather?

karmic hatch
#

That doesn't tell us about UVs though

tight phoenix
#

oh

#

That isnt UVs above there??

karmic hatch
#

UVs are the red/green

#

2D coordinates on the surface of your object

tight phoenix
#

I know what UVs are

#

Im saying any two vectors can be UVs

#

I can map textures onto that cube just from its object position values

#

this is starting to involve so much high level math just to make the steep angles shine in a way that probably no one will ever notice but us, it probably would be better to just not do this :C

karmic hatch
#

If you do 3D voronoi but otherwise all the same things, the CellUV would be a 3D vector and then if you do normalize(reflect(CellUV, surface normal)+CellUV) you would get a vector parallel to the surface in the direction of the minimum

tight phoenix
#

I do have 3d voronoi ๐Ÿค”

karmic hatch
#

You'd need to edit it to get the CellUV

#

It's the same as for 2D voronoi though, but with float3s instead of float2s

karmic hatch
tight phoenix
#

How do you know all these formulas off of the top of your head? ๐Ÿ‘€

karmic hatch
#

And then treat those 2D coordinates like you did before, with length(float2(r,g)) as your voronoi value

tight phoenix
#

in no universe do I see myself being able to be like 'yeah just do (massive formula)' to get some extremely obscure vector angle

karmic hatch
tight phoenix
#

dots and crosses, vector math

karmic hatch
#

Indeed

#

Also since we're dealing with lengths we don't care about signs which is very nice

karmic hatch
tight phoenix
#

okay final_final_glitter_v2_final, no more messing with it.
I decided to forgo all that complex maths and just add fresnel to the sparkles to make it seem more dense at low angles

#

and no complex operations involved, a single dot product and the voronoi itself, the rest is all just mutiplication mostly

swift flame
#

will rendering after transparents come back to haunt me?

regal stag
loud wedge
swift flame
regal stag
#

But the shader also requires the depth texture, so you'd need to make sure you are rendering after that has been generated. That's mainly why I suggested the stencil approach

regal stag
loud wedge
regal stag
regal stag
#

That should be using the ShadowCaster pass. So if you add the cutout to that pass too it should work.
Though it would also affect shadows which may not be ideal. Maybe there's a macro that can help there...

#

It might be #ifdef SHADOWS_DEPTH ๐Ÿค” (but apparently that's also for directional lights and spotlights... so probably won't help)

loud wedge
regal stag
#

You don't need it in the outline shader, only the cutout one. But not to the main pass, it should be a second separate one.

#

Is it a vert/frag shader or a surface shader?

loud wedge
#

The cutout is a vert/frag shader:

regal stag
#

Ohh, it's using Stencils too. So wait, is this a quad rendering a circle texture?
And then shaders in the scene are testing against this stencil?

loud wedge
#

It's a sphere, but yeah, I've attached it to the player prefab and raycast to check if something is blocking the player

swift flame
loud wedge
regal stag
regal stag
swift flame
regal stag
regal stag
# loud wedge Yes they are

If you add addshadow to the end of the #pragma surface surf lightModel line, I'm hoping that might use the same Stencil operations for the ShadowCaster pass...

loud wedge
#

@regal stag You're a hero! It worked like a charm. For anyone that might stumble upon this I added this to my surface shader: #pragma surface surfObject DustyroomStylized vertex:vertObject fullforwardshadows addshadow and this to my cutout shader: Pass { Tags { "LightMode" = "ShadowCaster" } }

regal stag
#

The cutout shader probably doesn't even need the Shadowcaster pass. I was just confused about the implementation. Just using addshadow in the surface shader should be enough.

loud wedge
#

Hmm, taking that shadow caster pass away doesn't seem to work.

regal stag
#

Hmm odd. I guess keep it then! ๐Ÿคท

regal stag
#

Can try the settings I mentioned in the original answer : #archived-shaders message
If that still doesn't work, then IDK though.

tight phoenix
# karmic hatch fair

Yeah I figured it was a good compromise because I want to have a lot of objects in the scene with this shader on it

grand jolt
#

guys i am reltively new to this, i wanted to ask smthn. i saw on the internet, that unity provides a premade Toonshader, but i am not able to use it i dont know why. has anyone here used it before?

#

i cant download it. its called toonshader 0.6.1

#

unity toon shader *

loud wedge
frosty linden
#

Why is my lerp result not red to transparency but rather red -> white -> transparent. It should be red to transparent

vocal narwhal
#

What does the alpha channel look like

#

presumably it's a gradient from white to black

frosty linden
#

No, it's white to transparent

vocal narwhal
#

Same deal

#

it's 1 -> 0

frosty linden
#

Ah?

#

Ok so how could I get a proper red to transparent by mixing those two then?

#

Blend node give me the same result. I don't understand why.

vocal narwhal
#

I think you might be confused as to what transparency is.
Everything's just numbers. The RGB channels and A for alpha.
If you want Red to Transparent what you want is RGB: 1, 0, 0 and A: 1 -> 0
So you'd create a RGBA vector out of your color node and the alpha channel from your texture

frosty linden
#

But doing that, I lose the details from the texture.

#

For the sake if learning, I used a simple white to transparency texture, but in the future, I'd like to use this shader to create clothing and stack layers of textures (not decals, full texture wrapping all around the cloth)

#

It's basically like the lit layered, except it would handle transparency properly

#

As for what I mean by the lit layered not working properly, I opened both a ticket and a post on the forum but no reply so far

vocal narwhal
#

I'm a little confused why you expect anything but what you have though.
You're blending between pure red, and that white and black, using a gradient. Why would the outcome suddenly not have white in it?

frosty linden
#

Because the alpha of the texture should feed the lerp. Meaning you get full red from the A which get applied on the pixels of the texture which is basically full white with a horizontal alpha decrementing

#

Even if you consider the black part of the texture which is fully transparent

#

Those two parts should merge properly, shouldn't they ? I mean, it red + white, why doesn't it result in red?

#

So obviously my understanding of lerp is wrong here but I don't know how to get what I want

vocal narwhal
#

Lerp is a linear blend using a 0->1 value as input.
If the alpha texture is a gradient (not what is shown in that preview) then there's a 50% blend between red and white at some point in the middle, getting pink, and then further down it seems to be a 100% blend to white, and then black

#

put a preview node between the alpha and the lerp

#

to show what that looks like

shadow locust
#

the alpha being used as T here is quite weird

frosty linden
vocal narwhal
#

yeah, it's as I say, a 0->1 blend between red and white at the top there

frosty linden
#

I'm using this PNG I created in GIMP

shadow locust
#

ok so yeah that makes sense. Anywhere in the image where the alpha is high it will trend towards being red. Anywhere the alpha is low will trend towards the texture itself

frosty linden
#

Ok I get it now, the alpha plays a role the blending of the lerp color, I thought it would only affect the alpha channel, not the color channel, that's my mistake

vocal narwhal
#

What you see is 0 as black (0, 0, 0), and 1 as white (1, 1, 1).
Lerp blends between A and B based on T.
When T is 0, you get A, and when T is 1 you get B

frosty linden
#

Got it, but what if I don't want the alpha to play a role in the calculation of the pixel color then?

shadow locust
#

what do you actually want?

vocal narwhal
#

Then don't use it as the blend factor of the lerp?

frosty linden
shadow locust
#

or Blend

#

oh - or just using a constant 0.5 as T in lerp

vocal narwhal
#

It's unclear what you want because you can get what you want via various ways, and we're just making assumptions

frosty linden
#

I don't know the name of the operation lol, I want my white -> transparent png to become red->transparent

shadow locust
#

sounds like multiply to me.

frosty linden
#

I tried multiply

#

It give the same result

vocal narwhal
#

Ignore the whole "white to transparent" concept. Re-think what you have in terms of the color channels

frosty linden
#

Oh nevermind

#

If I don't plug the opacity alpha, then I do get what I want

#

That's the step I was missing

#

Now it's working like I expect. I just need to replug the opacity later

#

Thanks a lot for your patience and explanation lol

#

Must be annoying to explain beginners with their flawed understanding. Thanks again ๐Ÿ˜‰

vocal narwhal
#

You've really got to break it down in terms of mathematical operations, because multiply is literally multiplication.

// Red: 1, 0, 0
// White: 1, 1, 1
// Black: 0, 0, 0
// At the top:
R: 1 * 1 = 1
G: 0 * 1 = 0
B: 0 * 1 = 0
// At the bottom:
R: 1 * 0 = 0
G: 0 * 0 = 0
B: 0 * 0 = 0
#

Once you start thinking in numbers or at the very least thinking as channels and not as an overall "transparent color" framing it starts to make sense

frosty linden
#

I do get the operation, the problem was the formula

#

I didn't know the 3rd input, opacity, affected the basic multiplication.

#

Like you explained, the lower the alpha was, the lower the 3rd factor in the multiplication was

#

So actually, it's not A.r * B.r

#

It's A.r * B.r * C.a

#

That is my mistake

#

I thought the C.a was simply added to the color result from A.r * B.r, which is huge difference ๐Ÿ˜‰

#

Now it's crystal clear. Thanks again ๐Ÿ˜‰

frosty linden
#

I'm afraid I'll have to bother you again, but how do I put back the alpha once I merged my colors?

#

I tried a multiply but still no alpha. Which node should I use to inject alpha in a texture?

vocal narwhal
#

Split and Combine

#

Annoyingly shader graph isn't very economical with the nodes. Ideally combine would be more flexible, but it's very verbose instead.

frosty linden
#

I must have mixed up the inputs

#

Strangely, the alpha doesn't get added in the combine?

#

I know I could plug the alpha from my gradient directly to the final alpha but I want to merge the combine with another texture layer to stack them ๐Ÿ˜‰

shadow locust
#

if you put the RGBA(4) into alpha it will use the first channel (red channel) as the alpha

frosty linden
#

Ah ok, I thought it was smart enough to get the alpha lol

shadow locust
#

no

frosty linden
#

Thanks for explaining

shadow locust
#

another option is to put another Split node in there

#

to pull teh alpha out

#

from the combine output

frosty linden
#

I must have missed something because the combine preview still has no alpha?

#

So even the split does nothing

#

I did miss something... Forgot to set the material as transparent, my bad :x

frosty linden
#

Ok, now another possible stupid question. How to reproduce the lit layered shader capabilities to handle smoothness differently between layers?

#

From what I see in shader graph, we only have one smoothness input.

vocal narwhal
#

Ah sorry about not elaborating on split and combine earlier. Shadergraph is icky when it comes to them as you just experienced. It really should be better at hooking that stuff up imo, there's rarely a circumstance where the first thing you hook up is what you would want

#

You need to blend the smoothness in a similar way you would the color. Depending on the intended output you might want to multiply the alpha by the smoothness to mask it, and then use max to combine those together. I'm not sure as to the actual correct blending for smoothness though, that may not work perfectly as intended. It's a similar logic to lerping things together with the alpha channel or using the blend node

frosty linden
#

Ok, so only use alpha channels to merge smoothness together then, that makes things easier already. Thanks! I'm not looking for AAA quality so even if it's a bit buggy, I won't mind.

grand jolt
#

Shader not rendering on the object ;-; what can I do

#

even tho it shows the preview on the shader graph

frosty linden
#

Is your material set to transparent on the gameobject too?

#

If you changed in the shader graph after, it won't update automatically on the gameobject

grand jolt
#

I had the material and the shader graph set to opaque, tried transparent too but both dont seem to do anything

vocal narwhal
#

you only have one material assigned to that object?

#

and the graph is saved?

grand jolt
#

didnt even know you had to save the graph

#

thx

#

its working

frosty linden
vocal narwhal
#

you blend those different smoothnesses together using the alpha

#

or using the masks you use for blending, whatever that is

frosty linden
#

Ok, I think I get the picture after thinking carefully. I'll give it a proper shot now, thanks!

frosty linden
#

The max number of sample texture we can add in a shader graph is 16, is that correct ?

odd frost
#

when i run my game in the editor, I see all the textures but when I build it, some of the textures don't appear. I see the purple "no texture" texture instead. How do i fix this?

dim yoke
frosty linden
#

Nodes

#

But isn't it linked anyway?

#

You can't use 2 different textures on the same nodes anyway, right?

dim yoke
frosty linden
#

OK, I'm confused about the meaning of sampler then. I thought it was a sample texture node but it's definitely not then.

#

I'll check some more doc, thanks

dim yoke
#

You dont need to worry about it, you will most definitely not hit the limit of 16

frosty linden
#

Well, the thing is I'm aiming to create a shader to stack texture togethers, it would work by the same amount amount of diffuse, normalmap, emissive and heightmap. meaning each layer needs 4 textures. You're saying I can put as many layers as I want like this?

#

Because the hdrp/lit layered is limited to 4 layers

#

I though it was because of the sampler limit but it's not?

frosty linden
#

What is the RGB value of a pixel in a normal map if we don't want this pixel to move?

#

0,0,1?

#

Ok, thanks Google ๐Ÿ˜„ 1, 0.5, 0.5, 0.5 ๐Ÿ˜‰

#

Seems 0.5, 0.5, 1.0, 1.0 also works? It's confusing...

dim yoke
frosty linden
#

lol

#

I'm trying to do the same as the HDRP/Lit layered

#

Let me show you

dim yoke
#

Could you use Texture 2D Array instead?

frosty linden
#

I do not know how texture 2d array work

#

There. I have only 1 material for this tank top

#

I want to stack texture on it

#

here is layer 1

#

Er.. Main layer i mean

#

Layer 1

#

With layer 2

#

and layer 3

#

This way, I just need to change the layers to create whatever I want from the same model with only 1 material. I can also change the smoothness or metallic value of each part individually

#

There, jsut by changing colors, smoothness and metallic, I get a totally different feeling for the same model

#

It's awesome!

#

Different textures, each layers is again fully customizable

dim yoke
#

Im bit confused by the way shader graph handles samplers. Have you tried making much enough texture properties and connect them some way to see if you hit some limit?

frosty linden
#

Well, I've been able to merge my diffuse so far.

#

Now I'm stuck with the normal maps layers, since each layer has its own normal map AND like the lit layered, I want the main layer to be able to influence the other layers normal maps

#

I have the general idea but I'm just stuck with the strength parameter of each normal map which should be a number going above 1. But lerp and multiply nodes only use 0-1 inputs and I can't figure out how to increase the strength of my normal maps as I don't see any input in my shader

#

Nothing about the normal map input there. I remember in the default RP, there was a field which allowed me to increase or decrease the power of the normal map, but nothing here

#

It's confusing again lol

#

And as to why I don't use lit layered if it's already working, it's because of this bug :

#

Which forces me to create my own shader but I'm a beginner so it's really slow and confusing ๐Ÿ˜ข

#

Ok, found out there is a normal map strength node now which is what I was missing, nice ๐Ÿ˜„

dim yoke
frosty linden
#

Ah, I see. Well, it should be ok for the limit anyway. The more the better but as long as I can get the same 4 minimum layers as lit layered, that should be enough for my ideas. (But more would be better because I also want to use this shader for the skin and apply several layers on the face, such as different layers of make up, face which already has the face texture + the eyebrows texture so only 2 layers left in lit layered lol. Yeah, my ideas are a bit strange but as long as it works ;))

dim yoke
#

If thats not possible, it may be that the layered lit is actually just custom editor which connects the textures into texture 2d arrays under the hood, that would decrease the amount of samplers (but also would ignore the wrap mode etc. per individual textures)

#

Maybe some other trick would be possible too

amber saffron
#

But, the samplers are shared between textures, and not individual.
You can also do this in shadergraph by creating a sample state node/property and connecting it to multiple sample textures nodes

frosty linden
#

But why doesn't the lit layered handle semi transparency then? It's something I still can't figure out because I can't think of a reason it shouldn't. So I'm thinking it might be a bug?

amber saffron
#

@frosty linden IF you don't care about individual layers tiling/offset, you can write some script/custom material UI, to pack the layers mask into the 4 channels of a single texture, to save samples

frosty linden
#

OK, though I do need individual tiling offset too unfortunately since some layers can have a simple 32x32 vertical white/transparent texture tiling 40 times on which I apply a bumpy 512x512 normal map to give volume tiling 6 times (which is another lack in lit layered, the exposed property changes both the diffuse and normal map tiling, another thing I hope to fix in my shader)

frosty linden
frosty linden
#

So when do the sampler come into action in shader graph?

#

Is it a specific node or it's outside of shader graph?

amber saffron
#

Yo sample a texture using a texture object and a sampler state.
This is what the "Sample Texture" node does.
And on it you can input the Texture Object and the Sampler State

frosty linden
#

So this is a sampler right?

#

Meaning I can have 16 of those nodes max?

amber saffron
frosty linden
#

Ah

amber saffron
frosty linden
#

Yes, but I don't use this node at all for my shader, does this mean I can add as many textures as I want? What I mean is, there is a limit of 16 sampler, when is 1 sampler used by shader graph?

#

@dim yoke suggested to just sample a lot until I get an erreor but isn't there a better way to figure out the limit?

amber saffron
#

You can have up to 16 sampler states in a shader (but some are reserved by unity for lightmapping, so it's something like 13 or 14), but can sample 64 textures by using only 1 sampler if you'd like

frosty linden
#

Ok but when is a sampler used then? That's the only part I don't understand.

amber saffron
#

If you don't explicitely declare and use a sampler node, unity will create one for each texture on the fly. This explains the "16 texture limits"

frosty linden
#

Ah! That's easier to understand now, thanks.

#

So it means if I don't want to bother with managing sampler state, as long as I limit myself to 16 (or 12 textures then due to unity getting some) I don't have to worry about getting over the limit?

amber saffron
#

Yep

frosty linden
#

Ok, thanks a lot again. And sorry for the stupid beginners question :X

amber saffron
#

No PB ๐Ÿ™‚

frosty linden
#

Hm, I'm reading the documentation for the Sampler node because now I'm greedy and might want to go over the limit, but from the documentation, it's talking about sampling the same texture? So don't get how using a sampler node would allow to sample two different textures to go over the limit?

#

Do I just need to create the sampler node and connect it to 64 textures and it's done??

amber saffron
#

Connect the sampler node to multiple sample textures

frosty linden
#

That seems easy... But what is the downside then? Is it less performant since textures will use the same sampler?

amber saffron
#

No, the main performance cost is the sampling operation itself

frosty linden
#

Ok, but if a sampler can handle 64 textures at once, why doesn't shader graph do this by default then instead of creating 1 sampler per texture if not explicitly used? It would seem better this way then, wouldn't it?

amber saffron
# frosty linden Ok, but if a sampler can handle 64 textures at once, why doesn't shader graph do...

Because the sampler defines the interpolation between pixels, and extrapolation (tile/clamp/mirror) of the texture.
And in Unity you can define this on the texture asset.
It was decided to bind one texture to one sampler automatically in order to allow for a material to support any texture setting you want, but limits to 16-ish textures, unless you write yourself sampler states that are shared between texture samples

frosty linden
#

Ah! I get it now. Makes sense. Thanks again for the explanation! I'll try to stop bothering you now ๐Ÿ˜…

amber saffron
#

@frosty linden Oh, and btw, layered lit can have transparency

frosty linden
#

Really? But I can't get it to work despite trying all options

frosty linden
#

Here is the link with my problem. Both transparent and opaque modes produce strange results when mixing layers containing transparency.

#

So I must be missing something here. I've checked the documentation and tutorials online but couldn't find any explanations about this behavior

amber saffron
# frosty linden Really? But I can't get it to work despite trying all options

It's not obvious to understand how the layered shader works.
Let me try to explain :

  • Main layer is applied EVERYWHERE first
  • Then layers 1 to 3 are put on top in order 1, 2, and 3, using the layer mask channels R G and B
  • Layer mask alpha will affect the main layer transparency, Other layers will still stack on top of it, and this might be you issue, it is ignoring the layer mask alpha.
loud wedge
frosty linden
# amber saffron It's not obvious to understand how the layered shader works. Let me try to expla...

Aaaaaahhhhh! I'm getting it now! That's why you have only 4 layers, because you use the four channels of the mask map individually, one for each layer. OK, it makes so much more sense now! Though it doesn't work for my case indeed because my layered textures are changing depending on player input, meaning I'd need to generate the mask map each time a layer texture changes at runtime, not really efficient.

#

But now I'm wondering about performance, because your solution uses only one texture as a mask for 4 layers, which is 4 times more performant than having 4 grayscale textures as masks...

ebon galleon
#

Hi, I have a leaves texture but I want to remove the brown background. I also have another texture that highlights the parts I want to remove in blue. Does anyone know how I can make it so that only the leaves can be seen without the brown background?

amber saffron
frosty linden
#

Ah yeah indeed!

amber saffron
silk bridge
#

Hi guys,

Do i need to do something special when i working with a shader for a canvas image?

I mean i have the same shader working with a SpriteRenderer without any problem, but when i apply that shader to a canvas image, it seems to work on editor but in an android build is fully transparent.

Image Nยบ1 is on Editor.
Image Nยบ2 is a mobile Build.

Do i need to do something special for a canvas shader?

My shader frag

fixed4 frag (v2f i) : SV_Target
            {
                fixed4 col = tex2D(_MainTex, i.uv);
                col.a = 0.5;
                return col;
            }
frosty linden
#

But how does Unity handles the number of layers dynamically? At the moment, if I have 4 layers of texture in my shader but only need two textures for a specific part of the outfit, I have to put a 4x4 fully transparent image in layers 3 and 4 so that mixing the texture works properly. Lit Layered has a slider to reduce the number of sample used. Can this feature be reproduce in shader graph too?

#

Because I'm not sure putting those 4x4 transparent png is very efficient. Even more if I want to add more layers later on

amber saffron
cunning plank
#

Hey guys, I was wondering if anyone has some tips or perhaps a link to some tutorial for getting transparent objects to look good in Unity? I'm using the URP and on version 2021.3.0f1. Whenever I set an object to be transparent it looks really flat.

Also, do you model an inside as well, with flipped normals?

Thanks!

frosty linden
# amber saffron Yes, you can use the enum keywords and branch nodes

Ok, I remember reading about branches which are kind of "if" statements. As for keywords, I read that each time I add more, it creates new shader variants which bump the number quite a lot when generating the shader. So if we want a compromise between simplicity and performances, taking into consideration I'm not looking for an AAA fully optimized game but not a potato either, average is OK, would it still be viable to keep this blank png at the moment which I'd fill at runtime when needed? Does one sample texture add a lot of heavy work in the end when we stack layers?

amber saffron
# frosty linden Ok, I remember reading about branches which are kind of "if" statements. As for ...

Is it really a single sample texture, since each layer has albedo / normal, or whatever ?

Indeed keywords generated shader variants, and shaders with different variants can't be batched together.

On the other side, I think it can be acceptable for you to expose a slider "number of layers" that would control branches in the shader. As supposely the value is constant for a whole object, the branching operations shouldn't be to heavy and still save you sampling operations.

frosty linden
#

Ok, I'll look into branches then, thanks thrice more for your help ๐Ÿ˜‰

amber saffron
cunning plank
#

I guess it has a lot to do with getting the reflections to look good.

#

My goal is to make them look more like real glass

amber saffron
#

Ah yes, having good looking concave glass object can be very tricky.
The first issue to handle in the drawing order of transparent faces. As the polygons are rendered "in the order that they ares stored in the mesh data", you never really know which one might end on top, unless you precisely split the object into multiple meshes and tweak the rendering order.
And also very important for glass is to handle refraction, to make it convincing.

cunning plank
amber saffron
cunning plank
silk bridge
amber saffron
#

I honestly have no idea why it would act different on android :/

silk bridge
#

๐Ÿ˜ฆ

Where can I find an example of an HLSL shader for canvas UI?

I have a suspicion that it may have to do with my vert

My current vert:

v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);

                o.worldSpacePos = mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1));
                return o;
            }

I guess my vert is working with world position.

amber saffron
#

You probably want to look at "DefaultResourcesExtra\UI\UI-Default.shader"

silk bridge
#

Yes, thank you!

My vert looks different,i will give a try updating my vert.

upbeat horizon
#

Quick question

#

I have a shader that gives me a texture, and another two that I want to use that texture for different effects

#

How can I make them share it?

#

Instead of recalculating it?

amber saffron
upbeat horizon
#

This is for some future shaders I wanna make for volumetric lighting and fog

#

So a script is the way?

#

Performance budget is tight, and idk much about shaders

amber saffron
ebon galleon
amber saffron
silk bridge
#

@amber saffron After trying each of the options one by one I found that adding this to my shader worked on canvas "ZTest [unity_GUIZTestMode]"

hollow cypress
#

so i'm running a third person camera. I'm thinking about dissolving characters when they cross between the camera and the main character. Anyone have a suggested approach for this?

I'm thinking:

  • feed world space position of target as a global to shader
  • get the screen position of the world space target and if a pixel is within a radius - drop it?
#

i think ideally what i'd want to do is like a spherecast from camera to target - dropping any pixels that would the spherecast would hit - but i'm not sure how to write that in a shader

lavish plaza
#

Hey I'm working on a dither shader graph and I am trying to line the dither up with the pixels of the texture. Can someone help me understand what I am doing wrong in this screenshot? I'm trying to make a checker pattern of pixels on that grass ball disappear rather than the big chunks I have now.

humble robin
#

how can i mix multiple (6) colors to 1 color while ignoring black ones

lavish plaza
#

I'm trying to make a custom function node for urp and this so far. Unity accepts this and the node doesn't throw an error, but my IDE doesn't know about UnitySamplerState. Is there something I can include to fix this? I'm having trouble finding documentation to describe what I can do with UnitySamplerState. I don't know where it is defined and so I can't do anything with it yet.

lavish plaza
#

Thanks. The definition is all I need. I was just thinking of all the ways I could find out what is available on that class.

#

Now that I read through that I realize I have no idea what I am doing.

lavish plaza
#

I'm having trouble getting my bearings here. I hate to ask for someone to write the function for me but uhhh, can someone help me write this one?

shadow locust
#

and a rough screen space radius

cobalt totem
#

I'm having an issue with a ray marching shader I'm working on. I'm transforming the camera world position to the object's local position and using that as the origin point to begin ray marching. This works great at a distance, however as the camera gets closer to the object it starts to turn transparent. I'm guessing that the transformation is placing the camera closer to the center of the ray traced volume?

#

Here is an example:

low lichen
# lavish plaza I'm having trouble getting my bearings here. I hate to ask for someone to write ...

You need to multiply the texture dimensions with the UV. According to UnityTexture2D's description in this documentation page:
https://docs.unity3d.com/Packages/com.unity.shadergraph@10.3/manual/Custom-Function-Node.html
it should have a float4 texelSize variable. And if it's anything like _MainTex_TexelSize, the components of that variable should translate to this:

x: 1.0 / width
y: 1.0 / height
z: width
w: height

So your code should look something like this:

float2 sampledPixelCoordinate = InTex.texelSize.zw * uv;
cobalt totem
#

I'm calculating the distance from the centre of the volume using:

float centreDist = distance(float2(0, 0), float2(rayOrigin.x, rayOrigin.z));

Where rayOrigin is the world camera position transformed to local space

#

I then check if centreDist is greater than a threshold value (finalDist) and then skip the current iteration of the loop if it is:

#
if (centreDist > finalDist) {
  continue;
}
#

If I don't perform this check, then the transparency issue no longer persists, however I also have no control over the shape of the raymarched volume

#

So the issue is either with the way I'm calculating the distance, the transformation to local space, or some mystery third option I haven't considered

rotund ingot
#

Can someone tell me what this effect is called? I'm trying to get rid of the faces in between multiple transparent cubes but I'm not sure what the terminology is.

For the record I'm not competent in shader editing, and would prefer terminology or existing shader recommendations.

#

This is what I'm trying to fix

cobalt totem
#

๐Ÿคฆโ€โ™‚๏ธ I've just spent hours on this, all I needed to do was normalize the light direction vector and it all started working

karmic hatch
#

so lerp(scene color, cube color, alpha)

rotund ingot
rotund ingot
grand jolt
tight phoenix
#

I'm having a math/geometry problem question ๐Ÿค”
A value of 0 at Glow Spread is no different than 'Distance' - it produces a sphere.
The higher that value is, it produces a cube with rounded fall off at all its corners - an SDF cube
My problem is I can't seem to figure out how to control the ammount of corner roundness separate to the size of the cube itself.
if the spread has the ammount of rounded cornerness that I want, its way too small, and if it has the size I want, its too cubic

#

I cant figure out at what step which math to do to decouple the size of the cube from the size of the roundness of its corners

#

here is a 2d version that sorta kinda is what I m trying to describe? except it hasnt worked in 3D and also its corners arent rounded, they're more diagonal

karmic hatch
#

Oh and then after the sum, do Power but to 1/the previous power

#

So whereas a normal length is (x^2 + y^2 + z^2)^(1/2), do (x^p + y^p + z^p)^(1/p)

tight phoenix
karmic hatch
#

Yep

tight phoenix
#

So I have two variables, power and size, but neither controls the corner roundness in the way I want

#

I want to introduce more roundness, but this only introduces more squareness

#

playing with the values only makes more squareness, I cant find any values that introduce more roundness

#

the only time it has any around is when its size is 0, which is a single point and is again, too small
the problem of size/roundness decoupling still is present

#

at very low power its actually doing the exact opposite

#

roundness out the wrong way that falls more towards square the more power goes down

#

enitre graph so you can see if I am doing anything weird

karmic hatch
tight phoenix
#

subtract after the final power?

#

this looks neat ๐Ÿค” its not what I was shooting for but an interesting accident Ill save as a branch
Ill keep trying to change the node order maybe I can make it happen

tight phoenix
#

Looking at yours now

#

I had to one-minus after the subtract for the power step and then one minus again after

meager pelican
#

That's not me BTW, just a link. But it does round the corners and keep the size of the box using an SDF set of functions.

tight phoenix
#

hmm I wonder if there is some way to remove this overshoot(?) its getting from somewhere

#

oh huh it has something to do with the specularity

#

its not there when I do unlit

#

Ah saturate removes it

#

๐Ÿค” now I can control the size, and roundness, but I can't control the range of the roundness

#

when I say range of the roundness im refering to this distance here never changes

#

unless it does and im misunderstanding what im seeing?

#

im very close to what im targeting

#

I want it to fully fill the space, which I can do by increasing its size, but increasing its size also makes the soft range get pushed out as well ๐Ÿค”

#

the divide value seems to control that

willow egret
#

Hey all! Quick question. Using Shadergraph, how would I be able to achieve a shader similar to this?

lavish plaza
#

Just letting you know you helped me figure out where the problem isn't. Now I need to figure out the next thing to try.

tight phoenix
#

its getting late so im going to leave it at this, its mostly working the only thing I want to do is try to eliminate how pronounced it comes to a square bit

#

soft and jelly-like

#

wow that gif is awful

#

still image

wicked niche
#

How Can I create smmmothly changed alpha chanel like on second image?

wicked niche
#

How can I render several circles???

vale topaz
#

Hey! ๐Ÿ‘‹ Is there a way to get ZTest comparison value from an editor script?
I could potentially read the lines of the shader file, but trying to see if there's any option to get it in a nicer way.

amber saffron
amber saffron
idle jacinth
#

maybe with a dithering pattern you can do a sort of fade ?

amber saffron
amber saffron
frosty linden
#

Why can't I see the sub graph node in my shader graph?

#

Using shader graph 12.1.7

#

OK nevermind, sub graphs are a type of asset, not a node. Found a youtube tutorial :x

#

Oh, there's even a convert to subgraph option, nice

misty yew
#

Afaiu, compute shaders work on the GPU and could access GPU memory resources. And Afaik, A RenderTexture lives on the GPU. Is there a way to access a rendertexture on the GPU and read from it? The question really is if i call SetTexture on the compute shader, does that actually copy it over from GPU -> CPU - GPU or does it just assign it from GPU -> GPU directly?

charred crystal
amber saffron
amber saffron
#

There is still some CPU work done to assign the texture, but the data is on GPU only

misty yew
amber saffron
misty yew
# amber saffron A RT is a pointer to GPU memory, so the CPU part is just pointer and data about ...

I was looking into trying to read an RT in a compute shader and return an array with every unique color I could find for the CPU to then work with, but I understand that the function will run in parallel and I've seen some posts just by searching on google that talk about creating a 3D array and flipping bits inside of it to represent the unique colors, however it does not seem to me that it is very efficient to have a 16 mil large array copied back to the CPU. Do you maybe know of a better way to solve this?

amber saffron
#

Oh boy, that's basically sorting optimisations, and IDK a lot about this ๐Ÿ˜„

amber saffron
misty yew
gray harness
#

How can i pass array of objects to compute shader when the object contains property that is array of n vectors, different for every object?

frosty linden
#

Is there a way to apply a mask map on a normal map to make the masked part neutral ?

kind juniper
kind juniper
frosty linden
#

but if the mask as some grey pixel, won't it create some problem ?

ivory schooner
#

So I saw that Amplify Shader Editor was on special and I heard some good things about it, should I get it or stick with the normal shader graph? Mainly looking to make vfx with it.

ASG seems to do the same thing as Unity's shader graph so I don't know if it has increased functionality or is easier to use, or is it just a better looking editor?

#

Or should I even instead go for the "All In 1 Vfx Toolkit"?

terse whale
#

is it possible to have two shadow passes? I want to add shadows to my standard geometry, then have a grass geometry pass, and finally add shadows to that grass

#

Basically combining these two shadow passes, although I want the grass geometry to be rendered above the ground shadow

frosty linden
# kind juniper Sure, just multiply the normal map by the mask

It doesn't work. I must do something wrong. I'm using the alpha channel of my main texture as a mask for the normal. If I multiply the alpha channel by the normal map, if the alpha is full opaque, it gives me a resulting black normal map which is incorrect (0,0,0), it should be a neutral (0,0,1)

#

I tried to used a clamp but then I'm losing some normal strength when I stack my sub graph

amber saffron
frosty linden
#

Ok, I'll give it shot

amber saffron
#

If in a graph, you could also simply use the "normal strength" node with the mask input as strength

frosty linden
#

Ah, good idea, it's easier

frosty linden
#

I don't understand here. I'm feeding a JPG with no alpha channel, shouldn't the oneminus node result in full black?

#

It's the same with the invert color nodes, alpha behaves strangely.

#

Or is it getting its alpha value from one of the other 3 channels? Or maybe an average of the 3?

chilly scroll
#

Hey all, why is my grass creating some sort of grid? It's visible only from certain angles/sides...

amber saffron
frosty linden
amber saffron
#

Although this might depend on the platform/api targeted

frosty linden
amber saffron
frosty linden
amber saffron
#

Ah, that's interesting, it's compressed as RGBA, so it does store an alpha channel (you can preview it in the A tab here)

frosty linden
#

But it's full white here?

#

Or is it just we can't see the difference, only when it's inverted?

amber saffron
frosty linden
#

Yeah indeed

amber saffron
#

Now, I don't get why the automatic chosen format is BC7 with alpha :/

frosty linden
#

Its seems to come from the Compression High Quality

#

If I change to none or Normal Quality, the A channel is removed

amber saffron
#

Yeah, I'm not expert there, but I think that BC7 gives better RGB quality than DXT, with the addition of an alpha channel, even if unused

#

So, here is your why ๐Ÿ™‚

frosty linden
#

Got it, thanks for your help again ๐Ÿ˜„

grizzled bolt
#

Seems a bit odd to get compression artifacts on a blank channel
If that's what's happening anyhow

amber saffron
frosty linden
#

Oh Indeed

amber saffron
frosty linden
#

Changing to another format triples the size of my texture. For my case, it doesn't matter because I'll load the texture at runtime from the StreamingAsset folder anyway (But needed the texture in the project to test) but for other projects who want optimization, this is indeed strange for the alpha channel to get filled by another channel, forcing to use another format which will increase the size of the texture in the end.

amber saffron
frosty linden
#

Ah, I thought those formats would also be compressed automatically. Nevermind my comment then ๐Ÿ˜„

amber saffron
#

Something like BC1 should be fine (BC7, but without alpha)

frosty linden
#

Ok thanks

#

How to handle the HDR emissive color? I need to apply a mask to the emissive so I was thinking of using multiply on mask * emissive strength * color

#

But the color node has no HDR options. Won't I lose the control over this with a custom property?

amber saffron
frosty linden
#

Ah yeah my bad! Need to enable it in the properties, sorry :x

frosty linden
#

How to use the Keyword node exactly? Is it a similar to a IF statement? To reproduce the lit layered feature, I was suggested to use an enum keyword and branch nodes but I'm not sure how to make it work and I can't find any proper tutorial about the keyword node online. So basically, my shader stacks textures together, based on the previous layer of texture, each layers having its own texture, color, smothneess and metallic. How does the keyword interact in all this to create variants? For each final properties of my global shader, I need a keyword node to feed the value from the relative sub graphs based on the keyword value? If so, I don't need branch then?

regal stag
# frosty linden How to use the Keyword node exactly? Is it a similar to a IF statement? To repro...

Yeah, you don't need a Branch node. The keyword already acts like that. Behind the scenes, it would probably be using #if .. #elseif .. #elseif .. (etc) .. #endif

Since you want multiple layers active you can't just input each layer into the keyword node though. That would mean only one layer is active but you can switch between them.

You'd want the "One" input to include the first layer. Then "Two" would be the first and second layers combined (I guess with Blend node?). "Three" being the result of three layers combined, etc.

frosty linden
#

Yes, that's how I did it. Two is the blending of the 2 first layers

#

It seems to work indeed

#

So if my shader uses 5 layers in total, does it mean I'll get 5 variants?

amber saffron
regal stag
#

Eh, it's more complicated as the shader will be generating variants for other things too.

frosty linden
#

Ahah ok ๐Ÿ˜„ I'll see how it goes. I remember some users reporting issues with variants generation times. Hope it won't be too slow.

amber saffron
#

Like I told before, you could also use a float property with comparison and branches to "select" the number of layers, and avoid the variants generation

frosty linden
#

And it will not process unused layers this way?

regal stag
#

That would be calculating all layers though right? As Branch nodes don't use true branches, but ternary statements.

#

I think you'd have to use a Custom Function with if instead

amber saffron
#

In latest version, branch nodes are If(...) .
Since the float property controlling the number of layers is supposed to be constant for the whole object, in theory the unused branches won't be evaluated

regal stag
#

Ah okay, didn't realise it had changed (again)

frosty linden
#

Latest version being 12.1.7 ?

amber saffron
#

15.0

frosty linden
#

The package manager doesn't offer me to update my shader grapg version

#

Is it because I didn't upgrade my unity version?

amber saffron
#

Ah, I was wrong, it's still ternary operators :

frosty linden
#

Ah

amber saffron
#

Now, IDK if this acts like a real IF or not

#

Worst case, you can just create your own custom branching with an easy to write custom node

regal stag
#

Afaik hlsl ternary doesn't branch. It's like [flatten] if()

#

Idk if the compiler unity uses changes that though ๐Ÿคท

frosty linden
#

Well, considering I knew 0 about shaders last week, I've only gone this far because shader graph makes things a bit easier (though still confusing). I do find some similarities with traditional coding but not sure how to code a custom branch function :x

regal stag
amber saffron
frosty linden
#

Seems easy enough lol. I'll try

#

But I'd need to create one custom function per property type then, correct?

#

Can I reuse a custom function written as a string?

#

Or do I need to put that in a file?

amber saffron
frosty linden
#

Oh, smart beginner way ahah ๐Ÿ˜„

amber saffron
regal stag
#

Might only need one custom function if you provide more inputs and use else if, like the keyword node approach

frosty linden
#

Got it, I'll see how that goes, thanks to the both of you ๐Ÿ™

frosty linden
#

Ok, I think I misunderstood where the if statement needs to be applied

#

Now that I think about the purpose of the if, I'm assuming the statements needs to be add BETWEEN the layers... Not after everything is computed which would defeat the purpose of branching.

#

Though my current shader does work as intended, it will always process all layers. Dammit I'm a dumbass lol. Gotta redo most of it.

#

I'll try again when it's not midnight... Stupid mistake lol

regal stag
#

Nah, this'll probably work. The compiler should remove parts that don't get used.

frosty linden
#

Ah?

#

This makes my night more peaceful, nice. I'll try it more tomorrow. Anyway, thanks to the both of you for your time ๐Ÿ˜‰

regal stag
#

Well it would do that with keywords / #if, I'm actually not too sure about if

#

Might be safer to move the if after each layer

frosty linden
#

Ok ๐Ÿ˜‰ This part should be easy, though it's tedious. But I'll get there. Thanks again ๐Ÿ˜‰

bitter lintel
#

So i installed a toon shader, works fantastic and all but using the Inverted hull outline method for the outline shader, some of my models didn't work, so i just made an outline that basically renders the object twice at another scale. Any problem i might run into? Is it worse for performance than the inverted hull outline?

#

I use shader graph btw

#

Nvm still looks weird on some models

real viper
#

is there a way to generate a baked lightmap for a single object

wicked niche
#
-------- GLSL link error: L0008 The fragment floating-point variable vs_TEXCOORD0 does not match the vertex variable vs_TEXCOORD0.
 The vector size does not match.
#

This error on Build

#

in editor it is works fine

#

and I have pink material

dim yoke
dusky arrow
#

does anyone know how I can remove the background of my grass?

#

using hdrp ^^

rocky quarry
#

how i make object visible through walls

icy crag
meager pelican
#

@frosty linden@amber saffron@regal stag
This was interesting:
There are certain cases where using the branch or flatten attributes may generate a compile error. The branch attribute may fail if either side of the if statement contains a gradient function, such as tex2D. The flatten attribute may fail if either side of the if statement contains a stream append statement or any other statement that has side-effects.
From https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-if
IDK if (pun!) I'm tracking your conversation well or not...

regal stag
# meager pelican <@389647385145507843><@532477925250039820><@357936113983291393> This was interes...

Oh right... Yeah, using if might still be flattening the branches (executing both sides) even with the current setup :
Specifying [branch] before the if can force it (well, assuming the target platform supports that), but if @frosty linden's Layer code is using Sample Texture 2D nodes they may need to swap those texture samples out for custom functions with SAMPLE_TEXTURE2D_GRAD(texture, sampler, uv, dx, dy).
And then use DDX and DDY on the UV node in the graph and pass it into the Layer subgraphs and into that custom function... I think.
It's also explained somewhat in this article : https://medium.com/@jasonbooth_86226/branching-on-a-gpu-18bfc83694f2

knotty juniper
meager pelican
#

The common wisdom of "don't use conditionals in shaders" is one of my biggest frustrations with how shaders are taught.

step(y, x) is a conditional! It compiles to identical code as:

float val = (x >= y ? 1.0 : 0.0)

or

float val = 0.0;
if (x >= y) val = 1.0;

Likes

882

Retweets

194

dusky arrow
frosty linden
#

@regal stag @amber saffron @meager pelican Well, this is indeed a bit confusing. I also read there http://xdpixel.com/how-to-avoid-branching-on-the-gpu/ about avoiding branching, though the tweet linked above would discredit this? This post https://exiin.com/blog/unity-shadergraph-how-to-properly-use-booleans-in-a-shader/ seems to lean toward lerp instead with a conversion of the boolean to float to "cache"? the formula. It's a bit out of my comprehension at the moment so I'll just go with a lerp in my custom function until advised otherwise.

Overview In this article, I want to teach you how to write GPU Shader friendly code that avoids the performance costs associated with branching. What Do You Mean By โ€œBranchingโ€? You are branching anytime you use an explicit if/then. When your compiler encounters a conditional, it has a decision to make. There are at least โ€ฆ Continue reading How ...

regal stag
# frosty linden <@357936113983291393> <@532477925250039820> <@573586703202254878> Well, this is ...

My knowledge on the performance side of branching is limited so can't really comment on the first one. The answer to anything related with performance is usually try both and profile. Tools like RenderDoc may help with that, if monitoring the FPS isn't enough.

In terms of that second link, it's just misleading. It's a bit funny as in older versions the Branch node actually used to use lerp! It then changed to a ternary statement (Predicate ? A : B). But either of these still always evaluates both sides (so I'm not sure you'd really call it a branch - but that's what the node is called). If they changed it from lerp to ternary - I'd assume ternary is already better for performance here.
In that article they seem to treat a ternary as a dynamic branch, which it's not. A ternary is also not necessarily equivalent to an if statement, unless you add [flatten] before it - which again, forces both sides to be evaluated.
I'm also really not sure why they need to use a Boolean in the first place if they're just going to convert it to a float. Why not just... use a float property instead? ๐Ÿคฆ

In your case though, the Branch node or Lerp isn't necessarily what you want. Afaik that's not really any different from always having all layers "active". I think the point of branching here was to help with performance as it might have been able to skip those layer calculations? Idk, like I said the performance side is where my knowledge ends. Personally I usually stick to the keyword approaches.

frosty linden
# regal stag My knowledge on the performance side of branching is limited so can't really com...

Got it, thanks for your insight. Being more of a programmer, I might also use different shaders instead of branches, one shader per stack of layers and change the shader at runtime, this way, I'd be sure it only uses what's needed? Since each layers is is using the same sub graph, it's easy to maintain if I need to update too. Not sure what would be the downside of this solution then?

frosty linden
#

If I want to use heightmap to move the vertex positions with my shader, do I just need to plug my heightmap there? How to I control the elevation?

shadow locust
frosty linden
#

If I want the heightmap to just stretch forward, I wouldn't need to combine with the normal, right?

#

Which node do I need to use to get the vertex position? I can't find anything related in the Geometry nodes

#

Also is it possible to store values temporarily to reuse them in the same graph? Like local variables in a function. The idea being to just not having so many stretching lines everywhere making things confusing, simply store the local variable and reuse it elsewhere.

shadow locust
frosty linden
#

Well... Forward... Relative to... the normal... Which answer my dumb question lol ๐Ÿ˜„

#

Redirect nodes are when you double click a line right? It does allow to organize the lines better but still quite stretchy when the shader is huge ๐Ÿ˜„

#

When you say combine, it's simply multiply the 3 vectors with each other? Would that work?

#

Hm, I can't connect the out(3) to the Position(3) after a multiply. Obviously I'm doing something wrong but not sure how to combine the heightmap, normal map and vertex position otherwise :x

#

OK, found a tutorial, nice

frosty linden
#

I can get the vertex to move but they only move up and down, not relative to the normal map

#

I must be missing something.

#

The heightmap should only affect the mole on the face. But it's only moving the whole face material up and down so far. Kinda scary lol

amber saffron
# frosty linden I must be missing something.

It's hard to see what nodes you are using since the names are blured, but I'm pretty sure it's wrong.
Are you using the position node as UVs for the texture sampling ? This is probably not what you want.
Also, you won't be able to displace the mole on the face like you said. Remember that your are connecting this to the VERTEX position. You are moving vertices, so unless you have a very high densely detailed mesh with vertices placed at the edge of the mole, it won't move.

#

To do regular vertex displacement, the formula is : vertex position = vertex position + vertex normal direction * height
The heightmap is generally sampled with UVs, and in the case of shadergraph, the vertex position and normal need to be in object space.

#

But even with this in mind, the level if detail you are wanting to displace is to high for simple vertex displacement

mental bone
#

The real question here is why do you need vertex displacment for a mole ?

frosty linden
frosty linden
#

Though I thought Unity would try to split the faces to create the displacement if needed

#

For the mistake about the UV on the texture, it's because of the unity tutorial:

#

They use Voronoi for displacement and connected the position to UV, so being a beginner, I assumed I could do the same with the sample UV.

#

Here is the higher res screen if needed

#

Also, what happens if the heightmap is 4k black with a single white 1x1 dot which would be thinner than the face it's overlapping? Is it ignored?

north wind
#

Hey guys, I'm pretty new to shaders and having an issue I can't figure out - I'm trying to make a hair shader that lerps between two colors using the object position - but has a weird thing where it makes the whole screen yellow when the base head hair section is visible, and flickers when an actual hairstyle is on top.

https://i.gyazo.com/66f2ba0f0bc188b670c1c3c902de2387.mp4

#

Problem probably pretty simple but it's something to do with the position node, object should be right but it glitches out like this

mental bone
frosty linden
#

Ah got it, thanks

mental bone
north wind
#

I'm using a global volume, but you're right, it's the bloom part

#

But it either does this at any intensity or doesn't at off, no in between

#

Haven't come across this before

#

Only seems to be happening with this specific shader/mat though

mental bone
#

Again, a material like that cant change the bloom or turn it on or off

#

Look for the problem elsewhere

#

Unless you somehow created a fullscreen effect shader

rose kiln
#

Hey, I'm using shader graph and trying to use dithering to have transparency on an opaque material. i'm randomising the screen position to animate the dither noise and make it look less obvious, but this results in really nasty shadows. Is there any way to fix this? It would be nice to have an "is shadow pass" node in the shader graph

#

In the video i'm just comparing animated dither pattern to the static pattern, you can see how it messes with the shadows

amber saffron
# rose kiln Hey, I'm using shader graph and trying to use dithering to have transparency on ...

IIRC the shadow passes have some specific keywords that you could use to do branching in your code (with some custom nodes).
I don't think the dithering is really necessary for the shadow pass, maybe a simple alpha clip is enought ?
But even with this, since the grass blades are moving, and looking at the low-ish resolution of the shadowmap, you might still end up with blocky looking things

rose kiln
#

Yeah I was thinking of just doing an alpha clip for the shadows. thanks heaps, I will look into shadow pass keywords

meager pelican
tall girder
#

is there a way to make a texture scroll over the uv by incremental values? if using a time node, it's super smooth, but I need it to move 0.05 units per second without smoothing

regal stag
frosty linden
frosty linden
amber saffron
frosty linden
#

Ah got it, it's a relative to the vertex itself then? Nice

#

As you warned about, the mole heightmap is too small in the end, too bad ๐Ÿ˜‰ Is there no other technique which could give some more height to such a small facial detail? Would a pixel displacement work?

#

From what I see, pixel displacement would "sink" the texture inside to give the illusion of depth, which wouldn't work on a protuberant detail, too bad.

karmic hatch
violet urchin
#

Not sure im correct here. Why does unity add this grey color (around the eyes) to transparent part ?

grizzled bolt
violet urchin
eternal jay
#

hello

#

how can i make a shader for 'gore'

#

let me get an example

#

like this one, where flesh becomes visible when you damage an entity

grand jolt
#

hi guys

#

i need help with a 2d shader for lava

#

i cant find any tutorials going over what i want to acheive

dull igloo
#

Hey guys, I'm working on a BeatSaber custom platform where I upload the beatsaber platform in unity trough the help of a plugin I guess, and add my own assets to it to make it into a custom map and then export it with the help of a mod to beat saber.

#

The problem I'm getting tho

#

is that my assets turn out white when I put them in, while I gave them the materials in blender and exported the materials in the same mesh

#

I read something about using the shaders that are compatible with beat saber but I thought that just throwing in assets with a material in it would also work

#

anyone an idea?

#

Like this:

serene creek
#

Hello, any idea why Im getting this error?

#
UnityEngine.Canvas:SendWillRenderCanvases ()```
#

Appreciate any help

dark forge
#

Hi, very new to shader graph here! I'm trying to get the alpha to match with how dark the mask is, but instead I get a full opacity or no opacity result as shown on the right. I can see that it's just coloring a section if the pixel is above the threshold (0.5) but how do I make it so that it fades like in the mask?

#

the mask is black and white, it has no opacity of its own

#

nevermind, I just had to switch the surface type to transparent, not opaque haha

#

I thought I did that already whoops

white pivot
#

hey guys are you know why my preview shader in shader graoh dont match with viewport?

amber saffron
white pivot
white pivot
regal stag
#

Blend mode is in the Graph Settings.

But could also be that the Alpha contains values outside the 0-1 range. Try a Saturate node before connecting to the Alpha port.

knotty musk
#

but I want something like the outline from Unity:

#

any suggestions? Thanks! ๐Ÿ˜Š

plucky hazel
#

Hi! I made a sdf shader for my UI elements, but it appears that this material won't work with world space UI elements, does anybody know why?

#

They should look circular

#

It is like they are not getting effected by materials at all.

frigid ether
pine lily
#

does anyone know shadergraph toon/cell/outline tutorials that work with the latest unity? Every single one I followed from 2 to 3 years ago resulted in broken shaders.

shadow locust
pine lily
#

all of them used urp from what I could see, just the lit/unlit nodes looked a bit different

#

it's not like they didn't work at all they just had bugs and didn't show the right results

#

the problem is I'm trying to learn to use shadergraph but if I can't recreate and fiddle around in examples I can't learn.

gray harness
#

lets say i have separate objects that are getting rasterized on gpu, so i keep them in separate lists

I want to be able to render the objects in some order but even if i sort the lists this hierarchy is gonna be true Circle > Triangle > Quad, my idea was to make 9 lists 3 for objects in bg 3 for mid and 3 for foreground to get atleast 3 layers,

is there some good solution to this?

white pivot
serene creek
#

Hello, any idea why Im getting this error?

UnityEngine.Canvas:SendWillRenderCanvases ()```
Appreciate any help
grand jolt
#

it's a dumb question, but how can I get the vertex ID from a Mesh? i mean the SV_VertexID I can refer in the vertex shader

shadow locust
#

shader graph? hand-written vertex shader?

#

Or you mean C# code looking at a Mesh?

grand jolt
shadow locust
grand jolt
#

so SV_VertexID goes from 0 to vertexCount? just like in the Mesh.vertices array?