#archived-shaders

1 messages · Page 37 of 1

cosmic prairie
#

for example you could make differences visible by, idk the more red part of the object is the larger the difference?

#

but you can't access data from one shader in the other

#

shaders are just their own isolated mini program

#

you can barely do anything crazy

#

only way to read and write info in shaders is with buffers

#

but i'd recommend you just compare the shaders you have by eye and maybe paint

#

its what everyone does, it's the fastest way

#

graphics almost never has to be precise

#

if it looks good, it looks good

#

maybe if you describe why you need all this debugging crazyness, what kind of effect you want to achieve I can help

distant dirge
#

Then copy this?

neon lagoon
distant dirge
#

Does he show anything of how its done

#

Anyways what rp do you have

neon lagoon
#

Not sure what an RP is

neon lagoon
distant dirge
neon lagoon
#

The built-in unity one

distant dirge
#

Well i have clue how to actually write shaders sooo
Shader graph in URP makes life much easier for me

#

Hopefully someone else knows

neon lagoon
#

No problem and I hope someone does

cosmic prairie
#

there's shader graph for built-in now too

#

you can do outlines by rendering the mesh a second time inside-out, vertices offset by their own normals

#

and the color is just any color you define

neon lagoon
#

No clue how I'd do that

onyx cargo
#

are smoothness and roughness the same thing?

#

some threads i just read i'm led to believe if i'm packing a roughness map into the alpha of a metal map for the standard shader, i should invert it first because smoothness is the invert of roughness

regal stag
onyx cargo
#

@regal stag thanks! I'm using some materials from gametextures.com and I notice if i download their prepackaged version for unity PBR, the metal map has nothing in the alpha (it says RGBA in the inspector, but when i open in photoshop there is literally no alpha channel), and they don't provide the roughness/smoothness map when you choose that download option

#

that's straight up wrong, correct?

regal stag
# onyx cargo that's straight up wrong, correct?

Maybe? I know with Unity the smoothness can either be the alpha channel of the albedo map, or metallic map. That's why there's a "smoothness source" dropdown on the Standard shader. So maybe they put it in the albedo?

#

I don't work with PBR textures a lot so others might know more

tight phoenix
#

What are possible reasons why object space positions calculate correctly, but the same positions in world space do not 🤔

#

the only difference between these two is changing from object to world space

amber saffron
#

Object & world position only match if the transform of the object is (0,0,0)(0,0,0)(1,1,1)

tight phoenix
#

which is why the noise is the same shape as the left one, which is in object space

#

but you can see the normals are completely blown out, despite that being the only difference

#

also unrelated buy sometimes shadergraph wont let me connect nodes

#

and I don't know why this is the case

regal stag
#

If the chain is connected to the fragment stage it sometimes blocks you from connecting to vertex stage (and vice versa). It's best to keep them completely separate.

#

There are also nodes which can't be connected to the vertex stage (like DDX, DDY, Sample Texture 2D) but since you're using a Preview node to reroute that's not the issue here.

amber saffron
tight phoenix
tight phoenix
#

the left one is in object space

#

so its rotation is unrelated to the problem

#

though I dont understand why they dont match in that regard

#

somehow changing object space to world space did that

regal stag
# tight phoenix Ahh I see, yes I had to connected to fragment because I was trying to debug the ...

I don't know if this is related to the current issue, but for the record btw, if you want to debug the normal, use the Normal Vector node in the fragment stage, as that'll already be the normal you input into the vertex stage.
If you try to connect somewhere along that normal recalculating chain to the fragment stage, it'll be doing the calculations again, with that already adjusted normal, so what you'll see would be kinda wrong.

amber saffron
#

Sorry, I'm trying to understand what I see and what is the issue, but a lot of things you've said are confusing :

  • in the screenshot, what are the color showing ? Positions like you've said ? Looks like normals
  • You want to compare object space vs world space positions. Supposely, the world space object in the screenshot (right) is unscaled, unrotated, and placed a 0,0,0
    Then why did you rotate the one showing object space ? To have a better comparison, just translate it, it only makes it more difficult to compare if you add rotation
tight phoenix
#

but it seems to be working now

tight phoenix
#

left is in object space, its deformed and recalculated
right is in world space, same, its the same exact shader in every way, except for the space being changed

#

but in world space the normals are completely wrong

#

resulting in the blown out look there

regal stag
#

It might also be a good idea to make a thread, these conversations always get so long 😅

tight phoenix
#

yeah good point

#

I need this to be in world space, not object space

#

but the math to recalculate the deformation normals doesnt work in world space for some reason I dont understand

#

and I am trying to fix it but I have no comprehension of why its not working

amber saffron
tight phoenix
#

now its behaving completely differently

#

when all I did was flip it to object space and back to world space

#

which makes no @#$@^ing sense

#

suddenly the normals are correct

#

but when I move the mesh, it moves further than the mesh moves further than the game object

#

which also makes no sense

#

shaders are completely and utterly illogical and random

#

literally the only thing I did was turn it to object space and back to world space

amber saffron
#

No they aren't.
Shaders are math, and math are logical and predictible.

tight phoenix
#

that cannot change the shader that fundamentally

tight phoenix
#

if you just wanna be a dick to me why do you even bother replying, I need help not abuse

amber saffron
#

I'm trying to help, and I gave you some guidance, and apparently it worked ? Is that beeing a d**k for you ?
I'm just saying that there is no magic here, and no random value that changes when you look away from you screen, if something doesn't work at some point, and then seems to work after you do "the exact same thing", then you didn't do the same thing.

cosmic prairie
#

if you create a shader graph shader and add it to your new material

amber saffron
cosmic prairie
amber saffron
#

Have an other mesh object, or use custom passes (HDRP) / custum renderer features (URP)

cosmic prairie
#

and what benefit does it bring to have multiple gameObjects / meshrenderers over multiple materials?

#

and how much extra work are custom passes?

amber saffron
amber saffron
cosmic prairie
amber saffron
cosmic prairie
#

Assigning a new material just seems way more convenient

cosmic prairie
#

The way it would work with multiple submeshes (and I think worked a long time ago), is that after all submeshes are rendered with their material indexes, it would just loop around and all un-rendered materials render with the looped submeshes

#

with submesh 1 and 2: mat1 mesh1 mat2 mesh2 mat3 mesh1 mat4 mesh2

amber saffron
# cosmic prairie By the way, this is just a random decision that it isn't supported, there's no r...

Well, it is "supported" in the way that we mention it in the doc. But if you have a bit of complex object with more than one material, you're screwed and it won't work anymore : https://docs.unity3d.com/Manual/class-MeshRenderer.html#materials

Note: If there are more materials than there are sub-meshes, Unity renders the last sub-mesh with each of the remaining materials, one on top of the next. If the materials are not fully opaque, you can layer different materials and create interesting visual effects. However, fully opaque materials overwrite previous layers, so any additional opaque materials that Unity applies to the last sub-mesh negatively affect performance and produce no benefit.

cosmic prairie
amber saffron
#

Submeshes are supported, that's for sure, it's more the behaviour of "more material than submeshes" that is clunky.

cosmic prairie
#

And it would make sense

amber saffron
#

IDK why it was decided like this, and probably that the persons that took this decision had also valid arguments.
It is now to late to rollback I guess.

Imho, it should just be impossible to assign more materials than submeshes, and that's all.

cosmic prairie
#

Imho it should be easier to add custom passes in URP

#

Until then, i'll just use this when there's 1 submesh

#

Because what if I don't want to replace the materials? I do not want to replace anything and have any business with tags

#

just have an object drawn multiple times and to it's own thing

#

not going to add multiple objects, because that's a useless memory footprint, and if you go back to change something all other objects need to be changed

#

it just doesn't make sense

#

Either multiple materials should be supported, or multiple shader SubShaders or Passes that render without any previous setting up

#

That's the other thing

#

SubShader

#

????

#

what's that even

#

Why not add support for multiple?

#

All these old but useful features that have seen no love in URP

amber saffron
cosmic prairie
#

ah, so only a fallback

amber saffron
#

Or LOD, like I said. Raise the LOD shader level -> switch to simpler sub shader

cosmic prairie
amber saffron
#

Maybe I shouldn't have use fallback in that case.
We do have a fallback mechanic for when a shader can not render on a platform/api, it falls back to an other supposed compatible one

cosmic prairie
#

Yeah, I know that one, it's also usable for passes, right? Or when passes fail the subshader fails?

amber saffron
#

According to the doc, it is for the full shader

#

The command I mean.
But indeed, it states that

If no compatible SubShaders are found, use the named Shader object.
So subshader are used to do fallback within a shader itself

cosmic prairie
#

Ah, okay

old saffron
#

Thanks! I was able to get it to work

onyx cargo
#

I have a surface shader I cobble together that clips objects to a plane

#

but I need functionality that the standard shader adds

#

is there a way to write a shader that extends the standard shader instead of a surface shader, with cginc standardcore includes etc, but have it clip to a plane?

neon lagoon
sudden portal
#

Hey, I have a stupid question, is there a way to fixe the normal of a mesh when we apply him a World space texture.

Like :
I have a tilleable texture, I apply it in world space to a mesh, I duplicate the mesh and rotate it on the Y Axis (so the planes faces the same direction).
Actually normals will act like I have rotate the light source.

How to fixe this and make the normal moove only when the light source is mooved ?

azure loom
#

Wtf is this?

prime shale
#

looks like a light leak

azure loom
shadow locust
steady reef
#

I have no idea about shaders, but I'm working on a project with my friend who's not available right now.
He wrote a shader that I have to edit right now.
His shader makes big splotches of paint over objects and I need to make that paint black, but when I set the paint to be black then nothing appears.
I guess that's because black is the alpha channel.

#

Can someone help me figure this out?

kind juniper
#

Although then it might make the non painted areas black 🤔

steady reef
#

BUT

#

I just had a thought out of the box

#

And I thought that instead of trying to color the texture black I colored the black the texture 😄

#

I don't know if I said it clearly. What I mean is that now the color is under the texture instead of the other way around

maiden leaf
#

Anyone know why this shader is showing black in the transparent areas in the game view, but it shows transparency properly in the scene view?

simple violet
#

If its a ui shader i dont think its gonna work unless you enable opaque with alpha clipping

vagrant bough
#

Hello! Excuse me if I may seem a bit clueless, I'm very new to unity.

This part of the model I'm working with only shows on one side. I've been told that by making a custom shader with Cull Off would allow it to appear on both sides, but can't find a a way to simultaneously have the material show on both sides and have the rendering mode set to Cutout (the black bg isn't supposed to be there). Is there a way for me to get rid of the black bg and have it be double-sided at the same time like it does in blender?
(First two images are in unity. Second two are in Blender, which I'm trying to replicate.)

wraith wing
#

hi, quick question.
is there's any way to "convert" this to black white?

sacred stratus
#

yes, you can for example add the green values to all 3 elements of a channel so
cpp BlendModeAdd(Color.black, new Color(othercolor.g,othercolor.g,othercolor.g,1);

sacred stratus
#

@wraith wing

wraith wing
astral pecan
#

How to calculate Light Attenuation for custom lighting?

amber saffron
fossil cloak
sacred stratus
#

Can someone help me graphically solve this bezier curve?

the points are the ponts of the aqua bezier curve, which is how it should be

amber saffron
#

What do you mean by "graphically solve" ?

sacred stratus
#

like I want to be able to graphically solve each point on the curve at a given interval

tropic field
#

Anyone have any resources on how I could go about making this sort of spiral texture procedurally
using shader graphs?

sacred stratus
#

my current method gives me this which does not seem correct or usefull at all

amber saffron
sacred stratus
#

what does factored mean?

amber saffron
#

Not cleaned and optimized 😅

sacred stratus
#

oh xdd

amber saffron
#

The logic is : lerp between point A and controll A, lerp between controll B and point B, and finally lerp between the two precedent point, all by the same factor

#

Ah no, it's even more complicated XD, forgot a lerp step

sacred stratus
#

The thing you explained gives me this

I don't think it's correct but it seems better already

amber saffron
#

The one I badly refered to was the "DeCasteljau" one

regal stag
tropic field
sacred stratus
amber saffron
tropic field
#

i wanted a single swirl

tropic field
#

how did you know that multiplying the abs and one minus nodes would remove the seam

regal stag
#

Doing it like this might also be a little more intuitive, but basically the same thing

#

Fraction output is 0-1 repeating, could just step this but has a harsh edge.
Subtracting 0.5 centers that (moves the range of values to (-0.5, 0.5))
Absolute brings negative range into positive, so values go from 0 to 0.5 in center of swirl, then back to 0.

tropic field
#

hmm

#

idk how to ask this but, how did you know what to do

#

like I want to be able to get to a point where I can also make these patterns out of understanding

#

i could follow this setup but then i wouldn't understand why it works the way it does

regal stag
#

Kinda just practice? Idk. I've done a bunch of experiments with polar coords before. e.g https://twitter.com/Cyanilux/status/1123950519133908995

Knowing the values the polar coordinates node produces is also probably important. In short, the red/x axis is the distance to center, and green/y is the angle going clockwise from the downwards direction. I've got a bit more info + images here, I should really update it with some of these swirl examples
https://www.cyanilux.com/tutorials/polar-coordinates/

I also made a few patterns/shapes using polar coords. The rotation is useful for repeating patterns around a circle, for procedural flower shapes... or maybe snowflakes or cogs? I probably won't use this but might inspire someone else I guess. 😄

amber saffron
#

The base idea is this : take X & Y UVs, if you add them together you get a slope.
If you multiply any of the X or Y values, you alter the steepness of that slope:

#

If instead of rectangular UVs you use polar coordinates, instead of a straight slope you have one that goes from the center of the coordinates and circles around -> a spiral

tropic field
#

ok i understand until the add node

#

I'm a bit confused by the fraction node

#

from what i read on the wiki, it returns the decimal part of any input

#

so if I enter 0.3, it will return 3?

regal stag
tropic field
#

okay, that makes a bit more sense, but how does the resulting pattern come to be?

regal stag
#

Can think of it like, a range of values from 0->3 would become 0->1, 0->1, 0->1

amber saffron
#

The preview can't display properly anything that is greater than 1 (as 1 is white, and nothing is brighter). But by using the fraction node you can see the fractional values of anything greater

tropic field
#

any place where 0.9 -> 1.1 turns into an "edge"

regal stag
#

Yep

tropic field
#

if i'm understanding it right

#

okayy... that makes so much more sense

tropic field
#

that would help visualize the patterns in numbers

#

is there any tool like that?

regal stag
#

Hmm.. that would be kinda neat

amber saffron
#

Technically, it might be possible, but I guess all the preview are rendered in unorm format (so, 0->1 range), and having a feature like that, while probably usefull, isn't trivial to implement I guess.

tropic field
#

makes sense

regal stag
#

Easiest way to visualise values under 0 or above 1 is to just use nodes like Absolute, Negate, Fraction, etc to bring them into the 0-1 range

tropic field
#

we subtract 0.5 to normalize it to -0.5 and 0.5?

amber saffron
#

I'd use the term "remap" instead of normalize, but yes 🙂

tropic field
#

remap yes my bad :P

#

and then we absolute it, so that negatives just get turned right back into positive..

#

hmm

amber saffron
#

Yes, this is done in order to have a symetrical shape

#

Because after absolue the value does 0.5 > 0 > 0.5

tropic field
#

ok!! that maeks sense

#

once you put it into words, the patterns just sort of "popped" into my eyes.. i don't know how else to explain it, but I see it now

amber saffron
#

And so, it is easier to trace the line based on a single thickness value : the step / smoothstep node

tropic field
#

okay while i understand how smoothstep is being used here

#

to sort of limit the range of values

#

would there be any repository / something of other applications of smoothstep

amber saffron
#

I prefer to consider smoothstep like ... well, a smoother version of step 🙂

tropic field
#

i'm unfamiliar with step also T_T

amber saffron
#

step : returns 0 if the input value is under a threshold, 1 if it is over

#

very simple

tropic field
#

okay, makes sense

amber saffron
#

smmothstep : uses two thresholds , if the input value is lower than the 1st one : 0. If it is over the 2nd : 1. If it is in between : interpolate smoothly

tropic field
#

ahhhhhhhh

#

ok

amber saffron
#

It is a very easy way to do anti aliasing :

chilly marsh
#

Forgive me if this is not the right channel, but I'm wondering if there's a shader or component which can do what I'm looking for. This dome has flipped normals. I'm trying to give it a background that looks like a "portal" almost. Like a skybox, but even more-so. If you're looking at the background of this object, it should show the clouds way far back, as if it's the real skybox.

#

I fear my request doesn't make sense, haha.

amber saffron
tropic field
tropic field
#

thank you Remy and Cyan for your answers and patience!

#

i think i'm understanding it now ^_^

amber saffron
#

@tropic field It is with shader code, but quitte accessible imho, a very good explanation of how you can draw shapes in shader with mathematical functions. From our god Inigo Quilez : https://www.youtube.com/watch?v=0ifChJ0nJfM

LIVE tutorial on the basics of Painting with Mathematics. Source code/math for the painting here: https://www.shadertoy.com/view/XssSRX
Support this channel: https://www.patreon.com/inigoquilez

More tutorials on maths , art, SDFs and computer graphics: https://iquilezles.org

Donate: http://paypal.me/inigoquilez
Subscribe: https://www.youtube.c...

▶ Play video
low shard
#

Does anyone know how to make my shader graph actually see transparency? I'm using a Lit shader graph and I'm using version 2019.4 (what it should be and what it is)

regal stag
chilly marsh
#

Possibly my UV mapping is off.

#

For the dome.

#

HEre's what it looks like in Blender

regal stag
chilly marsh
#

Alright, this is something I'll have to pick up after work. I'm a bit out of my element.

autumn sigil
#

@regal stag do you have any tutorials on your paint shader you made a while back? Someone just pointed it out to me

#

I've been working on a paint shader and beginning to think I need two different layers, one for "standing" liquid and one for flat/drying liquid

#

an easier and more general Shader question: if I have a Shader Graph that takes a Texture2D input, do I need to create 2+ Materials from it if I need each Material to have a unique texture input?

autumn sigil
#

so I can't just reuse the same Material sadly

#

has to be a different Material if it's supposed to have a different Texture

amber saffron
#

Yes.
Materials are basically a group of settings for shaders.
You exposed the shader settings as "properties", and materials overrides those.
So, if you have a shader with a texture property, that you want to change per object, you need multiple materials using this shader, overriding the texture property each time.

What was your intend initially to avoid having multiple materials ?

autumn sigil
#

Well it's nonessential but I just didn't want to redo it each time if I could avoid it

#

If that's the way it has to be done it has to be done that way

amber saffron
#

Jokes aside, if what bothers you is that if you want to a change you have to do it on multiple materials, "recent" versions of unity implement material variants : like for prefabs, materials can inherit properties , so you can have a few "root" materials with your base settings, and multiple "child" one that only override, let say the color texture.
If for some reason you want to change the smoothness for all of them, you can just change it on the root one and if will propagate to all the children

mystic sable
#

how can i recreate gamecube style reflections with shader graph? i know its not super complex but im not good enough with shaders

#

the reflections work by taking a texture and stretching it across the object, it also uses the cameras position to move the texture accordingly

#

this is the texture being used for reference

#

if anyone has any ideas i would really appreciate it

grizzled bolt
mystic sable
autumn sigil
#

I have a texture with pretty strong normals and am trying to reduce the "glint" from the smoothness

#

is there a clamp option for that?

grizzled bolt
autumn sigil
#

no way to keep the high normals? only way I'm getting the right shadows on the underside of my paint

grizzled bolt
#

Let alone even more extreme angles

autumn sigil
#

how about smoothing the normals of a normal map, in SG? any way to go about doing that?

#

given that it's a paint shader I do kind of need the high smoothness. If I could alter the normals I'd happily do that

grizzled bolt
#

High smoothness alone isn't a problem, but combined with very sharp angles, steep normal map or otherwise "noisy" surface you get very random reflections per-pixel

#

If you already have normal map textures, it's probably more practical to get a smoother one than trying to smooth them in shader

#

Reducing normal map strength already smooths them to be more even, but doesn't blur or smudge them
Blurs and smudges in shaders are more complicated than with premade textures

sinful magnet
#

Hello shader people, i need help figuring out how to make the vision mesh around the player look more like "light" and also to not have such hard edges. Right now im using a shader that basically plays with opacity and a Fresnel effect, but i don't really like how it looks, any suggestions? I'd also like it to serve as a saturation filter, although im not sure if that is possible, thanks in advance!

#

Sorry for the bad quality*

autumn sigil
#

I am thinking about trying to have two layers; one for the crisper texture and one for the smoother one

#

@grizzled bolt There's a way to just multiply the shadows or something, isn't there?

#

weak normals, but decreased RGB values or something for dark spots?

grizzled bolt
finite barn
#

hey, a couple questions...
-So I tried making a fire tornado, but for some reason I can't get it to glow, any ideas?
-second, the Color variable had an update, which kind of ruined it, and turned my bright orange effect into a mustardy-yellow (I fixed it by just using a copy of the old deprecated variable, but still) - is there any known fixes for this too, using the up to date variable?

I don't do a lot of work in VFX/Shaders, so I don't entirely know what to screenshot for relevance...

grizzled bolt
#

Which just multiplies the color by a float

autumn sigil
autumn sigil
grizzled bolt
grizzled bolt
autumn sigil
grizzled bolt
autumn sigil
#

I think I'm just turning off bloom for now '^_^

autumn sigil
#

there's got to be a way to get an object to not contribute to bloom though, isn't there?

#

I found a youtube video that purports to do just that

grizzled bolt
autumn sigil
#

how do I use one Float to plug into several different Material inputs? Some sort of Global variable and script?

#

like

if a material has "Tex3D" in the title, it gets that input?

regal stag
astral pecan
#

I've created cavity maps, plugged it in, nothing happened.

rotund apex
#

Hey all! I have been having a bit of trouble with URP/shaders. I figured out what my issue is after posting in
#archived-lighting , but can't really figure out a solution on google. I have a tree asset from the asset store, and I have it urp/nature/seedtree8, this is the only shader that will correctly display the material. However, it does not correctly display shadows, as you can see in my recent post in #archived-lighting . Any help appreciated!

#

update: it appears I fixed it.... I'm not exactly sure how but it may have been upgrading materials to URP in that broad menu

autumn sigil
#

does anyone have a collection of textures they use to sample noise?

autumn sigil
regal stag
# autumn sigil Do you have a tutorial handy for your Splatoon paint SG? I'm trying to do someth...

I haven't written one but I can share some info/links.
I did a few methods, one "2D" which was drawing to a render texture and projecting that over the scene (basically sampling it using XZ of fragment position in world space, but remapped).
Also did a "3D" paint effect (could paint on walls too) which used baked GI to generate lightmap UVs. I found this video useful : https://www.youtube.com/watch?v=c7HBxBfCsas (Bleeding-Edge Effects on Mobile)
Also since then this video has also been released, which uses the same techniques : https://www.youtube.com/watch?v=YUWfHX_ZNCw (Splatoon - Painting Effect in Unity)

vagrant bough
#

Apologies if this isn't what you meant- As I said, I'm really new to all this

compact drift
#

Do I need URP or HDRP to make my own shaders?

steel notch
#

Any suggestions on how to render many, many lines all at once?

#

Like hundreds, enough where using line renderers is probably not the best move.

slim skiff
slim skiff
steel notch
slim skiff
#

and it can't just be a mesh?

#

anyway probably vfx graph is the way to go for something like that if it's mostly visual and don't need mobile support

#

but it's going to depend a lot on how the lines are viewed and interacted with and what they need to do what the best solution is

steel notch
compact drift
#

I also have a doubt, why is my model transparent on one side. I modelled it in Blender

astral pecan
#

Or try select all faces in edit mode, and recalculate normals outside

hexed moon
steel notch
hexed moon
#

and do you need to render these lines in 2d or 3d

steel notch
#

3D

hexed moon
#

just make a mesh

#

youll save yourself a lot of time and hassle

#

you could probably get away with using line render

#

but making a mesh isn’t difficult and if you want to texture it or write shaders for your mesh you can

#

one of my favorite articles

#

they only go about how to generate a quad, but thats all you need to know

hexed moon
# astral pecan Check your normals

the transparency isnt a normals problem, normals only calculate how the light should bounce off of the surface.

Its actually a triangle winding order issue. Somethings probably wrong with your triangle indicies

pearl frigate
#

HELP! ^^
So currently i have this kind of ground in my game (see image). The issue is, that is a full 3d model currently, which is obviously causing ALOT of unnecessary vertices. I am thinking that it must be doable with a flat model with the texture and a displacement of some sort? How would i do that and keep the same effect?

I tried using a heightmap, but that looked... Groovy to say the least dogdance

#

I am on URP btw.

amber saffron
pearl frigate
quaint grotto
#

How do you read stencil buffer in urp frag shader? I want to read the value then set a colour based on what the value is ranging from 0 to 4

compact wadi
#

noob to shaders here, can someone tell me how to fix this? The gravel merging with grass (red with green) doesn't look right

low lichen
grizzled bolt
chilly marsh
#

Shouldn t need to UV map What Remy is

merry rose
#

something like this in one liner "c /= mask.r+mask.g+mask.b;"

steady reef
#

I've got this node and a Color parameter.

#

How can I combine them together to have the Color from the parameter fill the black spaces?

#

I thought Add is going to work, but with a grey color it makes the green brighter

shadow locust
# steady reef

Maybe plug the output of this into a "Not" node to get a white mask for the black parts.
Multiply that mask by your external color
THen add that result to the original?

steady reef
shadow locust
#

aren't booleans just 0 and 1 values?

#

I know it's logic but wouldn't it work here?

#

I assumed it would treat 0 as false and anything else as true

steady reef
#

What I mean is that I can't connect pink to purple

shadow locust
#

ok

#

you can use Step then probably

#

Trying to get ShaderGraph open in my project to try it lol

steady reef
#

Thanks

#

This is the whole thing rn

#

wait

#

why did I create that last one

#

I've got the same back there

#

lmao

#

Sorry, I might not fully know what I'm doing, because it's not my work. It's a group project and the person who made it is not available. I have to edit it.

#

Basically I've got two parameters - BrushColor and Starting Color. I have to "mix" them in a cow-like pattern.

shadow locust
#

like this?

steady reef
#

Looks like it. 😄 Let me try it out

shadow locust
#

here's a better screenshot of what I did

steady reef
#

Thanks 😄

#

It works great!

#

I've been thinking drawing parallels between this and photoshop. I looked for something that works like the Screen layer option in PS.

#

That solution was kinda out-of-the-box-thinking for me.

#

I got trapped in that box

shadow locust
#

For the record the Not node does work here the same way as Invert Colors, it just doesn't have a preview 😆

#

As does one minus!

steady reef
#

I tried connecting it

#

it didn't want to attach

shadow locust
#

really?

steady reef
#

oh

#

look

#

I tried attaching it to one with pink dots

#

You're attaching to blue

#

Step is binary

#

(i guess)

#

and pink is just values

shadow locust
#

I'm not sure if those colors mean anything

steady reef
#

you can't NOT a #FFFFFF

shadow locust
#

the colors just change as a gradient

#

as you go down the graph

steady reef
#

now get the pink one in the not

shadow locust
steady reef
#

can't

shadow locust
#

well whatever

steady reef
#

The pink dot just doesn't attach to purple

shadow locust
#

I'm plugging a float(1) in

#

I plugged the oputput of the step function in (which is still a float(1))

#

you're plugging in the output of your multiply with the color(whichis a float4)

steady reef
#

What is a float(1) and float(4)

#

what is the difference?

shadow locust
#

think about float vs Vector4 in C# for example

#

float is one number

#

float4 is four numbers (the four color channels rgba)

steady reef
shadow locust
#

well the output of the step is just 0s and 1s (in each channel)

#

but since the input is only one number

#

it's only outputting one number

#

If you plug it like Noise -> Step -> Not it will work

#

it's not until you multiply by the Color node that you expand to 3-4 channels

hallow plover
#

how can I loop over each element in a StructuredBuffer (ComputeBuffer) using a for loop in a compute shader?

sacred stratus
#

you set a variable for the length of the buffer

steady reef
#

I'm wondering though why when the same is done with a texture then the texture turns out brighter

#

The last two steps next to eachother

shadow locust
#

I don't think it's brighter - optical illusion possibly

#

lemme pull out my color picker

#

yeah color picker is showing the same colors

steady reef
#

lmao you're right

shadow locust
#

e.g. the brown is 4d170d on both sides

steady reef
#

I do have a brightening issue though too

#

greying out actually

shadow locust
#

compared to?

steady reef
#

The texture itself

shadow locust
#

well i mean what if you used a normal shader with that texture

#

do you not get the "greying"?

#

is that just lighting?

steady reef
#

nope

#

I can't set the underlying color to black

#

it's grey

#

I mean I can but it turns grey

#

Nevermind, I managed to make it right. 😄

#

I don't know how. I just started kind of from scratch. Thanks for the help, Praetor. 🙂

lavish plaza
#

Sorry if this is the wrong channel, I don't know what channel is a better fit for this.

I'm learning about projection matricies so I can commit some funny business in the game's camera. So far my matrix gets an accurate near and far clip plane with adjustable orthographic size, but I can't figure out how to add perspective. Code: https://pastebin.com/wDKbxyGb

I have a couple separate attempts to apply perspective commented out. Dividing by the tangent of the field of view is what tutorials are telling me to do, but this only seems to make my orthographic camera smaller when I try it.

sacred stratus
#

I once made a perspective camera in open gl, you basically multiply some matrices from a math library in the correct order

lyric vortex
#

Hello I'm trying to make a procedural skybox using shader graph. Here is my current result:
It works but I'm looking for a way to get a more shiny sun. Do you have any idea on how to do that ?

hallow plover
regal stag
regal stag
native elk
#

Heyyy, is there a free asset for a water shader? (HDRP), if not can anyone help me make one since tutorials are to big for my small brain... joobisweat

tame topaz
#
  1. Look on the asset store

  2. Nobody is going to provide you with free tech art. Respect people's time.

  3. The latest version of Unity comes with a built in Ocean system for HDRP you can look at

native elk
tame topaz
#

Then you're out of luck, outside of making your own.

native elk
#

Thanks.

#

found one. and its open source lol

tame topaz
#

Hopefully it still works 🤷‍♂️

native elk
#

it does

#

i got it to work

#

i initially had an issue where it wouldnt render but i fixed it when i found out it didnt import the subshadergraph

quaint grotto
#

how do you read the stencil buffer in a frag shader so you can output based on its value ?

#

eg :

if value == 1 : green ? value == 2 ? blue : red

#

all the examples i see seem to just compare to one value then either clip or draw which is kinda basic and not useful for my needs

distant dirge
#

I'm trying to make a shader for my terrain to not tile so bad, as you can see from the picture, the tiling is really bad. I was told you can make a shader to make the terrain tile nicely. Does anyone know how I can do this? The tiling really bothers me when looking in the game, and it would be nice to be able to turn the tiling scaling down for nicer looking details and normals

#

btw if I have to make my own shader id like to use shader graph if that is possible

distant dirge
#

https://www.youtube.com/watch?v=aLCgoI0oYUo, ok so following this tutorial, I tried to make his fancy rotation node, since he makes a terrain tiling fix shader, but when i try to scale, my texture gets warped? Any ideas to fix this?

In this shader tutorial, I show how to move, rotate, and scale UV texture coordinates in Unreal and Unity. It sounds simple, but it can be tricky because of the order in which the operations are done.

Here's last week's video on UV rotation:
https://youtu.be/q62CdbKNdJQ

Here's the playlist for the whole series:
https://www.youtube.com/playlis...

▶ Play video
#

In his video it just tiles

#

As you can see from the thumbnail, but unless i missed a step there isnt some magical tiling node that he has?

mental bone
meager pelican
quaint grotto
#

For many effects

meager pelican
#

There IS a way, just not with stencils.

#

Don't use a stencil if that's not what you want. Accumulate the data you want in a texture instead of in the stencil buffer.

quaint grotto
#

Is it not just a buffer of memory with values you'd think they could expose the value in frag

#

How do I do it in a texture

meager pelican
#

Depends on the platform you want.
Maybe research Multiple Render Targets.

quaint grotto
#

Well how many would I need

meager pelican
#

So as you're outputting "regular" stuff, you can be writing to a 2nd texture.

quaint grotto
#

Not sure what you mean by platform

meager pelican
#

Some mobile might not support MRT

quaint grotto
#

I need obstacles write a 1 and characters write a 2. So I need only an 8 bit r channel

#

Mrt??

meager pelican
#

GTG, work pays the bills. Good luck.

quaint grotto
#

@meager pelican when you get time to reply, is it possible to write to depth buffer's blue channel for these ids since I'm generating the depth buffer

#

Since it only uses the r channel for height values

distant dirge
#

My texture was clamp im assuming

mental bone
#

well sure but what I gave is a compactly different solution that works probably better

#

if you end goal is to remedy the repetition of the terrain texture that is

tender tusk
#

Hi, I am doing a water shader (using shader graph) and while the foam looks right when the mesh has a uniform scale of 1, it looks too stretched when the mesh has a x size of 200 and 1 along the other axis.. do you know any fix?

#

This is the shader (there are some subgraphs, don't know if you need also those)

regal stag
# tender tusk This is the shader (there are some subgraphs, don't know if you need also those)

This happens as the noise is based on the UV coords stored in the mesh (UV0 channel is automatically used, can see in Tiling and Offset node)
A common way to keep the tiling consistent on planes like this is to use a projected / planar mapping instead. https://www.cyanilux.com/faq/#sg-planar-mapping
Would be the Position node, Swizzle to obtain XZ and connect to the UV port on that Tiling And Offset node.

tender tusk
#

Now it's like the water mesh collides with everything

#

This is the depth fade

regal stag
#

Is the graph type set to Transparent?

tender tusk
#

Ok I've made it work, thanks!

distant dirge
#

he is also making hex tiling

#

anyways quick question (not specifically for the guy i replied to lol)
im passing my sampled texture with UV modifications to the fragment shader, but it won't apply to the main preview. why is this is happening?

wooden ermine
#

Are unreal shader graph videos relevant for unity shader graph?

eager folio
wooden ermine
#

I saw someone above link a series on unreal’s shader graph and the series looks awesome, but it is unreal specific. Are there any decent series like that for unity? Something that is more than just “let’s build some stuff” but more teaching the system as a whole as well. I’ve written a handful of shaders and shader graphs but could certainly benefit from something a little more educational

regal stag
wooden ermine
#

Correct. And that’s interesting. I’ll give it a look through and see how well I can follow it

ancient drift
#

Is there a way to make a shader that not only colors a specific part of the sprite but also allows that color to be a gradient?

barren fox
#

hey, im making a 2d pixel art water shader, and i need help. I have been following this video that showcases how it works and i would need something similiar to this except that i dont know how shaders work because im very new to this, i have most of the nodes copied exactly like he has in the video just dont know how to continue. Or I could just start over but I need help with:

  • making the water transparent
  • making the outline of the water
  • making a wave system using the spring system thing

https://www.youtube.com/watch?v=xXYBMTnTems&t=763s

Heya Pals!

Today I just wanted to show off a little effect that I created for one of the obstacles in Insignia over the last couple of weeks. I was pretty happy with the result after trying a few different approaches, so here's a vlog covering the process.

Enjoy!

Chapters:
0:00 - Introduction
0:30 - Concept
1:32 - Function
2:19 - Colour Consi...

▶ Play video
distant dirge
#

oh cyan mentioned that

wooden ermine
#

Oh I thought it was in unreal. The few parts I looked at were in unreal

distant dirge
distant dirge
wooden ermine
#

Ah awesome

slow pilot
#

SDoes anyone know how I could recreate my own shader that can take a directional light (the sun) and create an actual 2d sun I can adjust like the built in Procedural Skybox shader? I have a custom shader graph I made that I like. But I'd want to add that feature.

distant dirge
#

How would I go about converting my shader graph into a shader that can be applied to a terrain? What special features does a terrain material need?

regal stag
# distant dirge How would I go about converting my shader graph into a shader that can be applie...

It should be possible with the Lit Graph, but probably not recommended. You'll usually get a warning in the terrain settings, saying the shader doesn't have a "TerrainCompatible" tag, that's not possible to fix in SG afaik but it could just be ignored.
If you need the splatmap / terrain layers, it's only possible to support 4 layers, but would use the same texture references (e.g. _Control, _Splat0 to _Splat3 etc).
(It's only possible for 4 layers, because normally a Terrain shader specifies multiple shader passes via Dependency shaderlab keyword but this isn't possible with SG)
Looking at the terrain shader code URP provides might also be helpful. https://github.com/Unity-Technologies/Graphics/tree/master/Packages/com.unity.render-pipelines.universal/Shaders/Terrain

distant dirge
regal stag
#

I mostly mean by the engine, like this is the warning you get.
But even so, I still use SG for terrain sometimes.

distant dirge
#

all i want

#

is normal and diffuse texture

regal stag
# distant dirge btw what is the splatmap

The terrain system allows you to paint different textures (for example like grass, dirt, sand, stone, whatever). The shader could support up to 4 of those layers, but not necessary if you just want the whole terrain to use a single texture.

distant dirge
#

how does the splatmap work?

regal stag
#

Can also blend between textures based on normals, which is useful to make cliffs appear as stone. Looking up "triplanar mapping" might gives some examples to that too.

regal stag
distant dirge
#

can you read normals and textures from the splatmaps?

#

and like blending levels or whatever

#

idk exactly how the terrain texture layering works

#

because im def going to need multiple terraiun layers

#

ill read it later lol sorry im busy rn

regal stag
#

That tutorial should give the general idea. The splatmap is masking where each layer/texture should appear.
And each terrain layer usually has multiple textures, like albedo, normal and a mask texture (containing metallic, ambient occlusion, heightmap and smoothness).
https://docs.unity3d.com/Manual/class-TerrainLayer.html

distant dirge
#

so my problem rn, is i have no idea how to get a reference to the terrain layer data, i understand the splatmaps now
Also i AM correct in assuming that as the terrain shader, its my job to process the splatmap, textures, normals, etc. right?

regal stag
# distant dirge so my problem rn, is i have no idea how to get a reference to the terrain layer ...

Like I mentioned earlier would be texture references, _Control, _Splat0 to _Splat3, _Normal0 to _Normal3, etc. Can look at the TerrainLit.shader as an example. https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLit.shader
There's also functions in TerrainLitPasses.hlsl which may be useful to look at, to see how those textures are sampled & mixed together. https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl

Technically, you don't have to process these textures unless you actually need the terrain painting.

distant dirge
#

but it is MY job if i want the painting?

#

i was looking at terrainlit earlier

regal stag
#

Yes, the shader is always responsible for calculating the pixel colour from it's materials inputs.

distant dirge
#

and i am not a shader expert so it looks bananas to me

meager pelican
quaint grotto
#

im trying to draw vision cones based on depth and stencil buffers

meager pelican
#

Well, sounds like you have the 2 types defined, can you not "just' do two passes, one for each type?

quaint grotto
#

im not an expert with shaders so i have no idea. was just curious if i could read a stencil value in a single pass but apparently i cannot

meager pelican
#

Yeah, it doesn't work that way unfortunately.

quaint grotto
#

if it was in a different channel of the depth buffer like the blue channel so i had depth , stencilID

#

it would be all one pass

meager pelican
#

Oh, I get that much. Do all your platforms support multiple render targets?

quaint grotto
#

uh ?

#

i have no idea what platforms support it lol

distant dirge
#

@regal stag Also, how would I go about making the blending between hex tiles smoother? even with really low focus, there is still really sharp edges... ofc if you dont know its fine
first image is the weights for my tiling, and second is one of my hex channel outputs. Im assuming i want to blur the latter as well for better blending between textures. ALSO this entire question is based on the assumption that you understand the hex tiling method that was shown in the tutorial ive been following

regal stag
#

I'm not that familiar with the method, someone else will have to help here

distant dirge
#

hmmm idk if thats what i want to do actually

#

nvm

#

but yeah very clear hexagon tearing

meager pelican
#

Some mobile won't support it. If your platforms support deferred shading, they'd support MRT since that uses MRT. According to this:

Model 3.0 (or later) and support for Depth render textures
. Most PC graphics cards made after 2006 support deferred shading, starting with GeForce 8xxx, Radeon X2400, Intel G45.

On mobile, deferred shading is supported on all devices running at least OpenGL ES 3.0.```

But you may not need it at all!  I mean there might be other ways, I still can't really tell exactly what you want, but you could maybe use layers for each "type"?  And draw each layer with another camera with different shader globals?  Or something?  IDK, maybe ask the group 
```How do I support multiple colors for 'vision cones', for each object type``` or something.  I fell like I/we may be over complicating this, but I'm unsure of the exact nature of the beast.
#

@quaint grotto

distant dirge
split flicker
#

Hello,
I tried to switch my unity to hdrp and then back to urp but I can't get it back to my original state.
This is what my scene looks like right now, thanks for your help.

distant dirge
#

OHHH ok i fixed the issue i was having, apparently you cant mess up the order of the output hex grid channels

#

i didnt know that lol, now it works, and damn it looks clean
unfortunately (unrelated) turning on my flashlight reduces fps by 40

quaint grotto
#

@meager pelicanlike this

#

i think they use stencil ids to determine what obstacle it is

indigo ginkgo
#

If I use custom vert attributes can I pack uints into the mesh to read in the shader?

meager pelican
# quaint grotto <@573586703202254878>like this

OK, but that's On or Off. You can do that with a stencil, since the "off" is filtered out and the only thing you need is the "on".

But if you want TWO of them on the same screen, one red and one blue, you'll have to do two passes to do stencils...one pass for red and one for blue.

quaint grotto
meager pelican
#

OK, "solid green" is one, and "textured" is two, sure.

quaint grotto
#

Okay so two passes is the best I can get out of this then

#

Unless you know a smarter way

meager pelican
#

Sounds like it. But the good news is that it's pretty fast filtering...happens at rasterization, the frag() is only called for the pixels that pass, and that's USUALLY where all the time is spent in a shader.

quaint grotto
#

Do you think I should skip using depth buffer to clip on obstacles and just use stencil

#

For both green, texture and clipped

#

That's 3 passes but no need to use depth buffer would that be more performant

meager pelican
#

Hmm....you have a separate pass for depth?

quaint grotto
#

Each npc has a camera that renders depth to target texture atm

#

And I pass that depth to the material

meager pelican
#

OK, so not scene depth from main camera, but sight-depth from custom camera.

quaint grotto
#

Yeah then I do mesh wp and depth to wp to determine if occluded

meager pelican
#

Sounds like a form of shadow casting, but in reverse.

quaint grotto
#

I dunno what that is don't do shaders much

meager pelican
meager pelican
#

@quaint grottoThere might be a "cheat" or optimization you can do for those NPCs.
If you add layers for "occluders" of any type, you could have a layer that has super-simple geometry for those objects with a lot of polygons....if you have them. IDK your scene.
So when you draw that depth-buffer, you'd use the super-simple geometry and NOT the complex geometry. For the visible cameras, they'd exclude that layer.

quaint grotto
#

I was planning to use simpler planes of geometry to represent the visual

indigo ginkgo
quaint grotto
#

But can that be done if they aren't visually rendered

indigo ginkgo
#

Ive only been able to make streams of existing data types eg vector3

#

And I can't seem to have multiple streams, I can put everything into stream 1 so I'm sure I'm setting it correctly but it won't let me split it up over 2 streams

meager pelican
indigo ginkgo
#

Not quite

meager pelican
#

Each vertex on the mesh has a bunch of UV values that come across in the shader as UV0, UV1, etc. That's custom vertex attributes.

indigo ginkgo
#

Oh

#

Why are they custom if they are built in

#

I thought custom would be new and anything I like

meager pelican
#

IDK, they're just not "stock" I guess. And the # of them has changed over time.
It's new and anything that you can pack into a float4

#

😉

indigo ginkgo
#

Having said that if I could make UV into a uint that would be great

meager pelican
#

Are you sure you really need to do that? What range do you need your uints in?

indigo ginkgo
#

I'm trying to bit pack data and the uvs as float32 is causing issues

meager pelican
#

OK

#

There's a way.

#

Second....

indigo ginkgo
#

Thanks 🙏

split flicker
indigo ginkgo
#

Did you put your project on version control?

meager pelican
#

So the UV data is in a float4. That can make packing a 32 bit uint really easy. You could just put 8 or 16 bits of data into each float and put them together later using bitwise operations in the shader.

So you'd do

    uint packedG = uint(color.g * 255) << 8; // shift bits over 8 places
    uint packedB = uint(color.b * 255) << 16; // shift bits over 16 places
    uint packedA = uint(color.a * 255) << 24; // shift bits over 24 places
    uint packedColor = packedR + packedG + packedB + packedA;

(I shamelessly stole this from Ben Golus from this post: https://forum.unity.com/threads/encode-float4-rgba-to-uint.695176/)
That's storing 8 bits in each color channel. You can probably get away with 16 bits and only two operations rather than 4.

#

I think the post was about the other way around, but you get the general idea.

#

@indigo ginkgoYou're sure you need this per vertex?

indigo ginkgo
#

I can get the packing working but the data type is still fp32 isn't it?

split flicker
indigo ginkgo
#

It's for baking material properties into the mesh so I can merge the meshs into one material and save drawcalls

#

I've got the texture combining part working ok

#

Maybe I should be doing some texture based lut...

meager pelican
indigo ginkgo
#

UV by default is vector2 of 2 fp32 values

#

I know I can make it vector4 but it breaks some stuff in the pipeline

meager pelican
#

Yeah, OK. Still 64 bits then.
But if you can use a texture, I'd do that. IMO.

indigo ginkgo
#

I suppose I'd like a quick fix for now

meager pelican
#

It depends on what you need. "Splat maps" and other such techniques are common.

indigo ginkgo
#

Which is making the fp32 a uint

meager pelican
#

Bust it up into two, and use bitwise operations.

indigo ginkgo
#

What does bust it up mean?

#

Sorry if this is a stupid question

#

I might be missing something simple

meager pelican
#

In C#, you want to encode a bit value, so you have some uint, yes?

indigo ginkgo
#

If I bit pack 8bit white or black into fp32 it ends up all 0000 or 1111 and that causes issues with sending the mesh data to the gpu

#

I think it counts as nan or infinity so the number gets lost

#

Yeah it's uint in c# but then it gets set back to fp32 when it's applied as uvs

meager pelican
#

And you need it per vertex

#

Not per material

indigo ginkgo
#

Yeah

meager pelican
#

How many bits did you say?

indigo ginkgo
#

128 lol

#

I'm using multiple UV channela

#

Float4 means 4 bytes?

meager pelican
indigo ginkgo
#

So that's 128bits?

meager pelican
#

so 1 float4 is 128 bits total, 32x4 = 128

#

yeah

indigo ginkgo
#

Ah yeah

#

I assume you already know but posting anyway

meager pelican
#

Yeah, that's a problem.

indigo ginkgo
#

Need to put baby to sleep

#

Will be back in a bit!

#

Thanks for the help

meager pelican
#

What I was suggesting is storing whole numbers in 4 floats 16 bits worth of precision, but that still only gets you to 64 bits in one float4.

#

That way you don't get a binary representation in the floats, the floats are just floats. The binary comes back OUT OF the conversion to the uint. Then you don't worry about NaNs and stuff.

indigo ginkgo
#

Oh I see

#

I think

meager pelican
#

Like reading a hex dump that is two bytes wide

#

So you'd have a float (maybe the .a part of a float4) that represents values 0 to 65535

#

And you'd have a float that represents the multiples of 65536 to whatever, etc.

indigo ginkgo
#

Will the whole numbers not fall foul of fp errors?

meager pelican
#

you're only storing 16 bits per float as a whole number. It can do that.

#

Because they're not binary, they're floating point whole numbers.

indigo ginkgo
#

Ahh

#

Was the code above doing that

#

Haha ok really gtg

#

Thanks again

meager pelican
#

If you wanted to store the value 0x00000000 00000000 00000001 00001111
in the float4, you'd store it as (0, 0, 1, 15) and in the shader you'd do
uint myInt = uint(uv5.a) + (uint(uv5.b) << 8) + (uint(uv5.g) << 16) + (uint(uv5.r) << 24);
But that's only for 32 bits, not 128 of the damn things.

#

But that's for storing 8 bit whole numbers.
Now if you put 16 bits worth of values into each float, you can double that to 64 bits encoded in a float4 and still I don't think you'll hit your Nan issue since you're only storing whole numbers and they range from 0 - 65535, which is easily represented in a float32. The trouble comes in when you try to store too much in one float32. It's signed and also has those special values.

#

You'll never stuff 32 bits of data into a float32 without hitting those values, as you've observed.

#

So it's probably easiest to use 16 bits of resolution.
and to do what you're asking you'd need TWO float4's....16 bits per channel x 4 channels x 2 floats = 128 bits.

indigo ginkgo
#

Ok she's asleep on my lap 😅

#

Yeah I see. I think I'll implement that then look at the splats

#

Splats is just a texture storing information?

#

Im baking materials to arrays so have the slice index saved in the mesh

#

I assume I can use that as a value to sample the splat

meager pelican
meager pelican
indigo ginkgo
#

Yeah!

#

That's working fine as fp32

barren fox
#

hey, so I have been following brackey's tutorial on how to make an outline shader, but i cant really figure out why but the outline doesnt work like it just doesnt show itself in the subtract preview and when i apply the shader material to the object (this is a 2d project) its not even the color its supposed to be. Could anyone help me with this? (im a noob at shaders)

https://www.youtube.com/watch?v=MqpyXhBIRSw

Thanks to NVIDIA for sponsoring!
Learn more about NVIDIA Studio► https://nvda.ws/38AaA8K
Razer Blade Studio laptops► https://www.razer.com/studio

In this video we create outline effect using 2D Shader Graph!

● Learn more about 2D Shader Graph: https://youtu.be/5dzGj9k8Qy8
● 2D Glow Tutorial: https://youtu.be/WiDVoj5VQ4c

● Get Gothicvania Ch...

▶ Play video
indigo ginkgo
#

Thank you for all the help

#

Sorry it took me a while to understand 😅

meager pelican
#

It took me time to understand too, I mean it's hard to communicate that level of detail back and forth.
If you find a better method let me know.

meager pelican
indigo ginkgo
#

At pc now & testing it out

#

I'm still very interested in knowing how the custom vertex attributes work too

#

but I guess that can wait

covert bluff
#

this is the model in unity

#

and this is how it should look like

#

what Im doing wrong why unity is polishing my model?

grizzled bolt
covert bluff
#

is there any way to fix it? @grizzled bolt

lyric copper
#

Hey does anyone know of a shader that would work for VR hands that doesn't have the depth issue when making a fist. I just need to be able to fade it i and out

meager pelican
covert bluff
#

thanks for advice

frigid vine
#

Any idea how to achieve this look? At first glance I thought its simply unlit shader but the more I look at it the more little shadows I see, some how this picture seems lit and unlit at the same time lol

teal breach
#

I think unlit with AO might get you most of the way there - most of the 'shadows' occur near crevices on 3d objects (e.g. the tree blossoms)

#

Is there an easy way to rename a shader? If I change the name of a shader in the .shader file, but keep the files metadata the same, will Unity be clever enough to carry on using the renamed shader? (in particular, for assets in different projects)

frigid vine
grand jolt
#

Does anyone happen to know why Parallax Occlusion Mapping doesn't seem to displace the material at all in scene view?

i can see the displacement happening in the preview but nothing happens in the actual scene, using the standard Parallax node works absolutely fine and shows the displacement in scene...

sinful canopy
#

Hey there, does anyone know how I could change the colour of only the white parts of the image on the top? Basically, I want the plant and dirt part to stay the same but I want the hand to be set to the colour that they player choses. As you can see in the image I tried doing a mask but it did nothing except cause a lot of weird glitches like the top of the leaves changing colour.

grizzled bolt
sinful canopy
#

I figured out a really weird work around using a node called replace colour. It doesn't completely get rid of the white but from the way I'm using it it makes dark colours have white outlines which is nice. Thanks for the info though!

regal stag
#

The graph you posted would also work if you removed the hand from the first texture (leaving black pixels)

tender tusk
#

How could I make a 3D "dark fog" effect? I have some cars that exit from a tunnel that the player can't access (which is like a simple quad with a black png for the tunnel) and I would like to make the parts of the car that are still in the tunnel really dark.. something like a black fog inside the tunnel (I am using URP)

simple violet
#

you'd probably have to look into depth textures for that

#

or just use environment fog

pine arch
#

Hi ! I have basic (i think) shader graph question, given a grayscale texture (a Mask with one Channel basically) how can i remove values under x and over y ? For example a perfect black to white gradient and i only want what's between 0.4 ans 0.6, outside this range i need values to be replaced by 0

#

it sounds simple but i cant figure out what nodes combinaison to use

#

i tried playing around with step, smoothstep, clamp, lerp but at best i remove one side of my min/max but not both

meager pelican
thorn tapir
#

how do I change the intensity of an HDR color via code?

sly tapir
#

for this on my draw distance influence where can I change the draw distance

grizzled bolt
thorn tapir
dusky mulch
#

Hey, maybe somebody knows how to solve shaders errors? These errors comes after I trying to built the project

grizzled bolt
#

@tender tusk Please do not crosspost

tender tusk
#

Ok deleting it

calm mortar
#

I know that lit shaders are affected by light and unlit shaders are not, but what is the difference between sprite shaders and the normal ones?

grizzled bolt
calm mortar
#

ty! So If I would want a 2D sprite to be affected by a 3D spot light, I would need the lit shader graph?

#

Or is that not possible? since it's not working

#

And would it be possible to have light affect a raw image attached to a canvas?

#

I've been stuck on this for a while now

grizzled bolt
reef owl
#

I'm having an issue setting global shader values: It seems like CommandBuffer.SetGlobalInteger doesn't work (or at least, it's value isn't being passed to the compute shader I'm targeting)

chilly frost
regal stag
chilly frost
regal stag
# chilly frost thanks ❤️ I made the change, is that right? <@357936113983291393>

I'd put the noise into the A port on the subtract node. But yeah looks okay. It's not doing the "scaling" anymore at least.
Though the result looks like it's shifting diagonally a bit, that might be because 0.5 isn't the average value of the noise, so may need to try some other values / alter texture ranges / import as non sRGB. Not sure.
Could also try a noise normal map / flow map instead. Or use Normal From Texture node.

#

May also want to scale down the original texture to give some padding to distort into, since if the texture goes outside the quad/mesh it won't be rendered. Can either do that by editing the texture, or do something like (UV - 0.5) * 0.9 + 0.5 + distortion as the UV.
Also if you don't want it to repeat, change Wrap mode on texture to Clamp (or attach a Sampler State node to Sampler port on sample)

chilly frost
#

I managed to get a result but I have to cheat with the values, I don't have much control. thank you! ❤️
I would be interested if you have links explaining how noise normal map, flow map, normal from texture node, staging these nodes / technique work. Maybe you talk about it on your website ? thanks @regal stag

regal stag
#

Though Normal From Texture samples the noise texture 3 times so is more expensive. But that could be swapped out for a proper normal map instead and then it's only one sample again.

#

I thought it might make the distortion look a bit better, as when you're adding with just the float/R output it's adding to both axis so only really distorting diagonally. While with a normal map it's distorting in all directions. But with strengths this small it's not noticeable anyway.

chilly frost
#

nice that gives me other variants thanks @regal stag ! I could even make the normal map myself to reduce costs (I guess)
And the flow map is this a technique that is done with a node scripter?

regal stag
# chilly frost nice that gives me other variants thanks <@357936113983291393> ! I could even ma...

Yeah flow map isn't built in, but would be something like this : https://catlikecoding.com/unity/tutorials/flow/texture-distortion/
Also example graph below.
But might not apply that well in this scenario, idk.
I mostly mentioned it because a flowmap texture is similar to a normal map but with just RG channels (which is all we need for texture distortion)

A Unity Flow tutorial about distorting a texture to simulate flowing surfaces.

hasty depot
#

I have a shader that does a kind of liquid possibility with particles but I need it rewritten is there a place to put up job offers like this

glossy palm
#

i have 0 experience in creating shading effects and dont even know what to research/look up for this sort of effect

#

its like gritty, grainy, but looks almost hand drawn/ink

hushed wing
#

Maybe some kind of thresholding effect, some noise, and some color quantization?

slate heron
#

Hello, I have an issue which I assume is shader related.
I have a single mesh as an fbx (it has animation), this fbx has several planes to form a 2D asset in 3D space.
I "baked" the alpha channel within the image texture I'm using for the model, a single atlas for the whole model.
Problem: I don't know why every time the meshes, all belonging to the same object (all the model is one single mesh), when overlapping one another, some parts of the topology disappear, like the hair for example.
What gives?
I send some images regarding my texture and my material settings.
Thanks

jovial bough
#

I'd like to prevent the time sine from going to zero or 1...any nodes that can help me with that?

atomic jolt
#

Trying to do the shader tutorial thing where you make the flag wave

#

And I’m pretty sure the tutorial is out dated because it just not work how they say it will work

digital gust
regal stag
regal stag
#

Depends what you are doing. Might be better to ask in #archived-urp though, this isn't really related to shaders.

regal stag
# atomic jolt This is what I have down

Looks fine from what I can see. But make sure the mesh you apply it to has enough vertices to displace, the correct orientation (since y axis is the one being displaced), vertices have an appropriate scaling, and UVs set up.
The default unity Plane mesh is probably a good one to test it on.
Make sure you also save the graph (button in top left).

hollow wolf
#

hi, i am working on VR dev as junior tech artist, i already learn shadergraph, and want to learn about compute shader, is it worth it? and what make it different? isnt it basically just make you have the ability to use GPU in almost everything?

low lichen
hollow wolf
#

i mean sure, it's very helpful but learning compute shader is definitely not easy

grizzled bolt
# hollow wolf i see, is there any other benefit?

It's also useful in realtime and offline simulations
Any computational task that the GPU architecture is a good fit for (a huge number of small, repetitive calculations in parallel) so the possibilities of "what it's good for" are pretty much endless
I'd go googling for examples of what people usually do with it to get a better picture

hollow wolf
grizzled bolt
#

Compute Shaders are further ahead from those both

gilded patrol
#

hi

#

I installed a map to test, and here is the result nothing at all for the textures
the dev says that

Note: When importing the package I noticed
All the shader materials show up pink in
the project editor, Im still working on why
this would be. Though they all work fine in
scene as is and if you want to fix the pink
colour just reapply the shader to the
material.

before exporting it to FBX I would like to have the textures but I don't know how to do it

grizzled bolt
grizzled bolt
# gilded patrol that the problem ?

It could be a problem but you haven't really stated what you're trying to do or how
If the render pipeline is incompatible with the assets you'll need to change the assets or change your project
But is your goal to make a project work with a specific RP or the assets work with a specific RP

gilded patrol
shy fiber
#

what is simple noise on shader? is it perlin?

regal stag
shy fiber
#

Can i do it on CPU with unity mathematics?

#

i have it on my game. It has 2 colors and noise blends both for ground texture

#

Now i want to do the same for grass meshes

#

Set the grass mesh color based on same noise (for same world position)

#

Like this but i don`t use terrain

limpid moss
#

I'm trying to transfer Shader code from shadertoy.com to Unity, but when I transfer it to Unity I just get a black screen. I tried changing almost all variables in the functions to static, but that didn't work either.

#

I'm getting no errors in Unity either

wooden ermine
#

needed a fairly lightweight gore shader, pretty happy so far

#

any optimizations, please feel free to suggest, fairly new to shader graph

limpid moss
#

Not sure where I should paste my code

wooden ermine
limpid moss
autumn sigil
#

Does anyone have any idea how much more processing intensive it is to render both sides in a shader? Do I need one-sided and two-sided variants?

merry oak
#

Is there anyway to make a shader in urp only replace the value on the stencil buffer if nothing is in front of it?

distant dirge
#

like the C compiler does

white cypress
unique oar
#

Is it possible to edit another texture in an image effect shader? I tried to compile the following code in an image effect shader, but it gave me this error message Shader error in 'Hidden/TestShader': maximum UAV register index exceeded, target has 0 slots, manual bind to slot u1 failed at line 42 (on d3d11)

            uniform RWTexture2D<float4> _Tex2 : register(u1);

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 col = tex2D(_MainTex, i.uv);

                _Tex2[int2(i.uv * 1024.)] = col;

                return col;
            }```
#

At the moment, I'm just trying to set pixels in _Tex2 to pixels in _MainTex, just to see if I can edit a second texture using an image effect.

#

Trying the code without the : register(u1) part yields this error message: Shader error in 'Hidden/TestShader': maximum ps_4_0 UAV register index (0) exceeded - note that the target doesn't support UAVs at line 42 (on d3d11)

astral pecan
#

Is there a way to convert flat image to distance?
Like this:

onyx talon
#

This may help you

astral pecan
astral pecan
#

Did the link change?

#

Cannot find that paper on Filter:LeymarieF

daring nebula
#

Hi all, I would like to create a fade effect on the edge of a sprite mask, after some research I saw that it could be possible with Unlit Shader Graph but I am completely lost... If you have a solution to create a fade effect I'm interested!

astral pecan
#

Plug this in to your Alpha

#

Swap noise with your texture

#

Swap time with your float fadeTime (0 to 1)

grizzled bolt
daring nebula
# astral pecan Plug this in to your Alpha

Thanks for your answer I tried to implement it but unfortunately my level on shader is close to negative 🥲 I finally found an asset on the asset store that does what I wanted.

astral pecan
#

I am thinking of expanding the shape, then use shader graph's distance(original, expanded)

#

But expanding it is a challenge too while keeping sharpness

#

Or maybe adding distance to edge

grizzled bolt
#

Distance is just the difference of two values

#

Fragment shaders don't really have knowledge of adjacent pixels so it's not a trivial problem at all

astral pecan
#

Ah, so its like blur

#

How do I pass down array in HLSL?
I am getting syntax error.

float SomeMethod(float2 UV, float2[] vertices) // syntax error: unexpected token '['
{
}
grizzled bolt
thin crater
#

Hi guys, does anyone know what I have to do in order to make my shaders work with deferred setting in URP?

#

I found basically nothing online 😦

grizzled bolt
thin crater
#

uh already done that, I've got all my shaders done in shader graph (with few lines of code for custom functions in hlsl). But this doesn't seems to change anything

#

for example: if I have a plane with my shader, and I place 10 lights above that, the lights shown will be maximum the number set in the URP setting asset, as if the rendering was NOT set to deferred (it is). But if in the same scene, with the same lights, I place a URP lit shader into a plane (or that same plane), then the plane will take all the ten lights, ignoring the lights limit, as it should with deferred.

#

So I guess it must be a problem with my shaders, still linked to the lights limit.

grizzled bolt
#

Is it?

thin crater
#

but not the terrain (the plane where I tested)

#

it's... unlit, also

#

thye're all unlit - maybe that's the problem?

#

I also use custom lighting to apply additional lights, from a script taken from a video online and slightly modified:

#

however I can't find any reference to a forward renderer or a light limit... so...

grizzled bolt
#

Deferred rendering also doesn't support transparent materials at all

thin crater
#

but... it behaves in the same way with opaque objects, like the terrain

#

and that's a huge problem

thin crater
#

No videos, no recent forum posts...

grizzled bolt
thin crater
#

okay ty

#

didn't see it mentioned deferred sorry

grizzled bolt
indigo ginkgo
#

can unity surface shaders find out the dimensions of a texture?

amber saffron
indigo ginkgo
#

thank you!

#

I'd tried before but not declared it so it wasnt working

indigo ginkgo
#

I think thats the same 🤔

#

do you know which one would be best?

#

I've got another question, I'm baking some textures to use as LUTs

amber saffron
#

@thin crater @grizzled bolt Custom lighting can't be done in deferred, as the shading/lighting is done in a specific pass after GBuffers. All you can do is alter how the GBuffers are filled.

Unless you want to dig into the URP code and add some branching in the deferred rendering funcion

indigo ginkgo
#

but I'm not sure what to do with regards to them be power of 2 textures

#

for example a LUT texture might be 12 x 72

amber saffron
indigo ginkgo
#

will do that then, thank you!

amber saffron
indigo ginkgo
#

🤔

#

the result depends on what data I feed to the c# code

amber saffron
#

I'm just trying to understand the LUT format here ^^

indigo ginkgo
#

oh its not the colour grading luts

#

Im just storing data in rgb values

#

to use in the shader

amber saffron
#

But worst case, you can just use it as uncompressed not power of 2 textures.
It is small enought to not have a big memory footprint, and you probably want uncompressed anyway to avoid loosing data

indigo ginkgo
#

yeah def uncompressed

#

I'm not 100% sure what happens to uncompressed non power if 2 textures, do they still get sent to the video card?

#

or do uncompressed textures not need to be power of 2

amber saffron
#

Yes, they still get to the video card 🙂
IIRC, it's more about memory optimisation, as a non PoT texture won't allow to fill the video memory as efficiently as only PoT ones

thin crater
amber saffron
#

Technically, yes, but not without modifying URP source code
Or if you only want to alter the GBuffers (understand PBR surface properties), it should be fairly straightforward

indigo ginkgo
#

thank you Remy you've been a big help

thin crater
#

My problem is just the light limit per-object, having a huge terrain chunk limits the number of lights that can be placed above it, to 8

#

And that's a big problem, some mobs will have lights on them, and the player might want to build more than 8 light sources in a single chunk..

astral pecan
#

Anyone know how to get colors like this?

#

Why my results looking so bad

#

😭

grizzled bolt
thin crater
grizzled bolt
amber saffron
thin crater
#

is that a beta? I can't find any 2022 beta, only 2023 beta

amber saffron
#

2022.2 is out of beta

thin crater
#

so it has not URP 14 with forward+, right?

grizzled bolt
amber saffron
#

As you can see on the doc page, there is still light limit, per camera

thin crater
#

Now the problem is upgrading, last time I tried that I had many, many errors and I had no clue on how to fix them 😅 but that's another topic

#

thanks a lot @grizzled bolt @amber saffron

thin crater
lunar valley
#

Experimenting with some post prossesing god ray shader, but for some reason these black dots start to appear and I don't know why. ```cs
fixed4 col = tex2D(_MainTex, i.uv);
float2 texCoord = i.uv;
float2 deltaTexCoord = (texCoord - ComputeScreenPos(float4(SunPos.xyz, 0)).xz);
deltaTexCoord *= 1.0f / NUM_SAMPLES * Density;

            float3 color = tex2D(_MainTex, texCoord);
            float illuminationDecay = 1.0f;

            for (int i = 0; i < NUM_SAMPLES; i++) 
            {
                texCoord -= deltaTexCoord;
                fixed4 s = tex2D(_MainTex, texCoord);
                s *= illuminationDecay * Weight;
                color += s;
                illuminationDecay *= Decay;
            }
            return float4(color * Exposure, 1);```
unique oar
unique oar
#

I did this by taking each pixel's distance to a point and setting its brightness based on a function that looks like this.

#

In order to make it separate into bands of red, green, and blue, I just multiplied the input of the function above by a number between 0 and 1 for each color channel, with the number being less for green and even less for blue, like so:

#

hope that all makes sense 😄

#

here's the function I'm using btw, it doesn't have to be exactly this, this is just what I decided on in the moment lol

thin crater
astral pecan
grizzled bolt
thin crater
#

but not everyone is having it 😦

#

so maybe there's a workaround

#

also, it only does it with my custom shaders, not with lit/unlit URP shaders

low lichen
#

Custom shaders made with Shader Graph?

thin crater
#

yes

#

and a bit of hlsl code

#

that's where I calculate additional lights

grizzled bolt
thin crater
#

I have no clue how to file a bug report 😦 I'll look for it

grizzled bolt
#

Maybe it's intended to work with the hlsl lighting functions, maybe not
But it's worth doing anyhow

thin crater
#

but I need a solution.... if there's one, maybe I'm still getting something wrong

thin crater
grizzled bolt
#

Also, sometimes stuff just breaks when you upgrade a lot
It's best to make a repro project just showing the issue for the bug report, and by doing that you'll also confirm if the problem carries over to a freshly created project

low lichen
#

Did the Shader Graph package update automatically when you updated Unity/URP?

grizzled bolt
#

If it doesn't carry over and you can't reproduce the problem, that means you have the means to work around the bug yourself

drifting hollow
#

Why is there no "Create > Shader > Empty HLSL"... or similar?
How are we supposed to create HLSL shaders from within the Unity interface?

low lichen
drifting hollow
low lichen
drifting hollow
#

I'd rather do it in Unity & double click to open up - that's what I do for everything else

#

don't wanna have to browse for the correct file path of my project in the "save as" menu

#

maybe Unity editor scripts can help me out with that
edit: ye, I'll just do it with editor scripts, seems very doable

low lichen
drifting hollow
#

yep, thanks

split flicker
#

Hello :),
i am facing some weird behavior with my shader, when i put it on plane i am getting some whole midle , as you can see on second pic wireframed one edge is disolved, Any idea to solve it plz?

hushed dune
#

Can somebody tell me why im getting this error?

Im using a lit shader graph as part of the URP

im using a custom function with the following code https://pastebin.pl/view/829a15ef

I dont understand why its not working, I tried following the tutorial and then just copy pasting from the patreon directly and both dont work

brittle latch
#

how can i use a image on gameobject which is invisible so I see only the image in the game (its a bullet impact)

dim yoke
brittle latch
#

sorry i'm a beginner whats this?

#

I want that if i shoot with my weapon, the image of the bullet impact is shown in the game

grizzled bolt
brittle latch
#

how to use them i cant put the image on an empty gameobject

grizzled bolt
civic lantern
#

Not sure how decal works if there's no renderer to project it on

#

Having a fully transparent renderer and enabling Affects Transparent in the decal projector settings would work, In HDRP at least

#

They mentioned that the other gameobject is invisible, in case you missed that

grizzled bolt
#

Could also be looking for sprite masking
Hard to say

civic lantern
#

Right, I didnt even consider 2D

hushed dune
slim steppe
lean lotus
#

Does #pragma multi_compile not allow global variables in compute shaders?

#

trying to use it to define a texture as a float2 vs it being a float4array(built in motion vector vs hdrp motion vector texture)

hushed dune
#

it takes me to the unity code manager or smth like that

slim steppe
hushed dune
#

i downloaded the file from thje patrion

slim steppe
hushed dune
#

and the shader graphh

hushed dune
grand jolt
#

hello, im new to hlsl. Im trying to make a shader that takes height map information and uses it as a mask for a texture. Any help on this or if you can point me in the right direction . Thanks

hushed dune
#

i spent 3 hours trying to figure that out

slim steppe
thin crater
#

Hi! As I said in some previous messages, I upgraded to Unity 2022.2.10f1 and URP 14. My goal was to use Forward+ in the settings so my custom shaders could use an (almost) unlimited light count on them.

#

But the problem is that when I enable Forward+, the lights starts to flicker.

#

Digging into the problem I created a fresh new project (so if it's a bug I can report it), and I imported all my shaders. I managed to create a minimal shader with just the bare minimum to be shown and reproduced the bug.

#

So, this is my current shader.

#

The problem seems to be in the CalculateLightingRamp subgraph.

#

This is the subgraph.

#

(if it's not clear, it's the second node in the main shader)

#

I've noticed that if I link the main light diffuse to this CalculateLightingRamp node, the cube flickers like in my main project. But if I set a constant value - like light intensity, or just a float static value - then the cube with the shader will not flicker anymore (but will have only one light everywhere in the cube, as if the light came from every side of the block).

#

This is the calculateMainLight subgraph, if you want to see how I calculate the diffuse value

#

And that's the custom function

#

I have absolutely no clue if that's a bug, or if it's intended to be, because docs for Forward+ is very scarce and very few posts have been created for it 😦

grizzled bolt
#

Make sure to include that info in the bug report summary
I doubt many here can help with that
The number of people who've tried to use custom lighting with URP's forward+ renderer so far might very well be in the single digits globally

thin crater
#

that makes me feel somewhat special ahahah

#

I'll report that now, hoping to get some help

grand jolt
#

Im using a height map, and "catching" certain ranges of 0 - 1 values. Im trying to blend in and out from that range. my goal is the second image or atleast something similiar

#

The first image is what i have so far. Looking for hlsl solution . im using URP

regal stag
thin crater
#

any advice on how to do it? I'm not good at all with hlsl 😦

#

I also thought the problem could be on diffuse, but I was not sure....

grand jolt
#

https://www.youtube.com/watch?v=E4PHFnvMzFc&list=RDCMUC7M-Wz4zK8oikt6ATcoTwBA&index=6 @thin crater good information on hlsl , if this video doesnt have it one of her other ones will most likely contain what you need

In this final lecture we dive into normal maps, tangent space, height maps and image-based lighting

If you are enjoying this series, please consider supporting me on Patreon!
🧡 https://www.patreon.com/acegikmo

00:00:00 - Intro
00:01:17 - Recap
00:10:34 - Multi-light support (assignment 2)
00:14:48 - .cginc include files
00:21:18 - Multiple pas...

▶ Play video
#

covers some lighting/shader stuff in depth

merry oak
#

Is there anyway to make a shader in urp that only replaces the value on the stencil buffer if nothing is in front of it?

regal stag
regal stag