#archived-shaders

1 messages ยท Page 18 of 1

karmic hatch
#

and then put that where the camera position used to go

leaden turret
#

like this?

karmic hatch
#

Put it through the same split-negate-step you have here before multiplying

leaden turret
#

ahh

#

@karmic hatch where does the output of the [view direction] > [normalize] > [negate] > [multiply] go into?

#

not sure how to connect the new stuff...

#

but it shouldn't have anything to do with camera position, no? regardless of camera position, the effect should only happen on pixels belonging to the area below world Y 100, whether camera is above or below or between that

karmic hatch
leaden turret
#

like this?

#

IT TWORKS! ๐Ÿคฉ

#

there's a thin separation for some reason, where the underwater does not quite reach/touch the water horizon line for some reason.. ๐Ÿค”

karmic hatch
leaden turret
#

it gets more pronounced depending on view angle

leaden turret
#

B component you mean split from the view direction?

karmic hatch
#

wait b component of view space view direction

#

so you will need a second view direction node

leaden turret
#

2 view directions? i thought i'm replacing the current one (divide instead of normalize & negate)

karmic hatch
#

you need the view space view direction (split to get the b component) and the world space view direction (which you then divide by the b component from the other one)

leaden turret
#

ahh ok lemme try

#

OK here's what i got, not sure i did it right

#

it seems to close in from above, rather than come up from below

karmic hatch
leaden turret
#

ok np lemme try

plush yarrow
#

guys how can i modify emission on a custom shader pls hepl?

leaden turret
karmic hatch
#

just negate

leaden turret
#

YESS it's deliciously seamless ๐Ÿคฉ

grand jolt
#

is there a way to set a shader to a single camera that ONLY AFFECTS the objects within that camera?

leaden turret
#

thanks tremendously @karmic hatch ๐Ÿ™Œ

karmic hatch
#

np :)

leaden turret
#

so my water surface is basically normal maps and scene depth gradient (as in the unity water shader tutorial)

then my underwater fog is URP Sample Buffer and more scene depth * camera far plane, with added view direction magics to cut off at a constant Y world coordinate

so just a few performance questions; any reason to believe this might be a bit "performance intensive" yet for mobile? or conversely - are all of these effects definitely extremely "lightweight" and no biggie at all even on medium-end mobile devices?

or i should shutup and profile ๐Ÿ˜†

#

should i be worried that having the underwater effect URP Renderer Feature enabled at all times is extra unnecessary computation, and i should have some script to enable/disable it based on necessity eg. a trigger for when approaching water level, so no need for it to operate when you're having extended playtime far away on land ?

leaden turret
#

underwater shader used as a Renderer Feature

humble robin
#

how can i make this 2d light textures size be the same with my textures resolution (its a pixel art and i am aiming for pixel art toon shading)

leaden turret
#

next on the underwater menu is - how do i make a bottom-upward water surface? currently the water shader looks nice when viewing top-downward, but from underwater if I look up it's just fog

#

@karmic hatch are we not limiting the underwater effect at Y sufficiently? only if the camera is viewing pixels "belonging" to beneath Y coordinate 100 then it should do fog, otherwise it should be transparent visible?.... something like that?

#

if we could throw in a bit of distortions (is that called refractions?) of stuff seen through the water surface that would be cool too

plush yarrow
#

ca n someone help me with somethinhg

karmic hatch
karmic hatch
leaden turret
#

is that what's happening, but the fog is blocking surface / skybox stuff? or you're describing what we need to adjust to make happen

karmic hatch
leaden turret
#

hm interesting, is that what i want? that fog should decrease as approaching surface?

karmic hatch
leaden turret
#

ahh i see

karmic hatch
#

You could do a test for whether the ray should refract or reflect off the surface using the refract node, and then output either blue or some blend of blue and sky depending on whether it does, but maybe that would get expensive if you want to sample normal maps for that

#

Would probably look a bit nicer though

leaden turret
#

are there other "cheaper" distortions/refractions effects to consider? Or it is what it is - if i want this water effect it just is a bit more of a fancier expensive effect. In which case I would probably try to find next best replacement effect to leave it at for lower-end mobile devices and perhaps try to implement the effect for higher end mobile devices which can handle it

leaden turret
leaden turret
karmic hatch
#

Or before the multiply actually

leaden turret
#

ah

#

between the clamp & multiply? which multiply

karmic hatch
#

In here, in that connection there put a min and in the other slot of the min put -({near plane position}.y - 100)/{world space view direction}.g

#

where this is what i mean by -{near plane position}.y

leaden turret
#

gotcha ๐Ÿ™ (thanks for saving me parsing/fumbling/re-asking time on that ๐Ÿ˜„ )

#

not sure i'm doing it right ๐Ÿค”

#

might not have done the - 100 part, am i supposed to use the Step Edge node too?

#

@karmic hatch i did a separate near plane Split & Negate, but maybe i'm supposed to use the one affected by view direction view etc?

haughty willow
#

Thanks for this!
Yes it's only for demonstration purposes, my real shader is much more complex.

I'm mainly interested which strategy is better performance-wise:

  • Calling material.setTexture every frame and using as few sampler2D variables in my HLSL shader as possible
  • Calling material.SetTexture only in the start method but having more sampler2D variables in my shader

Also do you think it can give me performance improvements when using a CommandBuffer instead of executing the shader passes with Graphics.Blit?

leaden turret
karmic hatch
leaden turret
#

ok, not sure if that means i want raw Near Plane > Split G > Negate, or if i should reuse the value that comes out of the existing Negate (or even Step?) node

#

sorry i'm still rather noob to shader concepts, i wouldn't know (would i?) how to translate the concept of "the position of that pixel where the ray hits the near plane" into shader graph nodes meaningfully... ๐Ÿ˜ฌ

#

i disappoint you again, master ๐Ÿซก๐Ÿ™

karmic hatch
leaden turret
#

gotcha

#

i dont need the negate part?

karmic hatch
#

Idk, see if it works and if it doesn't, then flip the sign

leaden turret
#

k

#

ok so now the underwater fog cuts off at the Y coordinate, but has no underwater fog whatsoever in the upward direction towards surface

#

need it to have at least a little, even if we're super close to surface, at least a little

karmic hatch
#

Subtract 100 from the g component you took from the bottom

#

Bc the plane is at 100 not 0

leaden turret
#

when i dive deeper underwater; where the water line should be vs. where it seems to currently be

karmic hatch
#

Also ig it does make sense somewhat since the distance should go negative on one side...

#

So when you take the min it should be negative (then you clamp so it just ends up very small)

leaden turret
#

ok so now it's this

#

no fog? ๐Ÿค” i prolly did something wrong

karmic hatch
leaden turret
#

ohhh the other split i see

karmic hatch
#

(also maybe just for safety normalize the view direction before passing it into the split)

leaden turret
#

this is great so far ๐Ÿคฉ

#

just some quirks to sort out;

karmic hatch
#

Now just need to set it up to discard it when it's negative (just check if the value going into the min is negative, and if so, replace it with something very large instead)

leaden turret
karmic hatch
#

Na sometimes the view direction isn't normalized and it leads to things acting up so usually I just normalize out of habit. Doesn't look like it's doing anything wrong here though

leaden turret
#

ok i'll add it in anyway (or just try keeping in mind if i forget)

leaden turret
karmic hatch
#

Just had an idea, clamp the view direction g component between 0.001 (something small but positive) and 1

#

actually that would still lead to issues when you're very very near the surface

#

just do a comparison and then branch ig

#

(clamp probably uses more comparisons anyway)

leaden turret
leaden turret
#

hm how do i do the part of replacing with something very big

#

i'm playing with Comparison and Branch nodes not sure how to achieve that effect

#

hm maybe this?

#

er i think i flipped true/false

#

i think i'm a happy customer ๐Ÿคฉ

tight phoenix
#

How can I make this look less like a white bowl cupping one side of the cube, and more like depth fog?
I know the answer is to somehow build up the value when the view direction is facing the interior part, but I don't know how to achieve that

tropic sluice
#

Anyone here have an example of using RWTexture2D? no matter what I try I can't seem to get my writes to work

leaden turret
tight phoenix
#

I think the answer is to somehow get rid of the harsh white lines that are giving it the appearance of being the inside of a bowl

#

But how do I do that?

#

this sooooorta works but Im assuming its only 'working' because its just blowing out the whole thing

karmic hatch
karmic hatch
leaden turret
#

hm maybe

#

this clear line though going into the fog ๐Ÿค”

karmic hatch
#

hmm

leaden turret
#

lemme change the underwater ground color to clarify things

#

again - i'm not even sure i hate it ๐Ÿ˜„ weird distortions like this is natural especially at water surface (like mirage effect etc) but just wanna be sure it isnt indicative of something else wrong, or how do i fix it if i decided i wanted that weirdness gone

#

see more towards the left-wards

karmic hatch
leaden turret
#

ah interesting

#

makes sense i suppose

#

not sure how they usually do this effect in other games, if they have any kind of blending or fading to reduce the "line" being so visible. or maybe after we're done with surface refraction effects etc. this issue will be unnoticeable or gone

#

i def owe you a free copy of the game though ๐Ÿ˜†

karmic hatch
leaden turret
#

ah cool yes i havent tried twiddling around with the numbers yet, time to play

grand jolt
#

anyone know why there is a black background on my sprite after applying a material with a shader on it?

karmic hatch
karmic hatch
tropic sluice
#

well, no documentation on my problem, and no help.. i give in

#

Unity ๐Ÿคท

grand jolt
tight phoenix
#

im trying to find ways to imply interior volume without raymarching

karmic hatch
# grand jolt how would i do this?

On the texture import settings, there are settings for alpha, and if you're using a shader graph, you want to make sure the texture's alpha is being passed into the alpha node on the fragment shader

grand jolt
karmic hatch
# tight phoenix im trying to find ways to imply interior volume without raymarching

Since the density is relatively simple, you can just integrate to calculate the total density along a line, and then exponentiate that times some (absorption color + scattering color) and add (scattering color/absorption color). If you want it to ramp up like that, the integral is distance through cube * abs(1/dot(view direction, ramp direction)) * abs(value of ramp on exit^2 - value of ramp on enter^2); if the NaN values where the dot is 0 are annoying, you can branch and just multiply distance through cube and 2 * value of ramp on enter

karmic hatch
karmic hatch
grand jolt
#

(well, not mine, i found it on youtube, it's a chromatic abberation shader)

karmic hatch
#

Also it's set to render opaque

#

So unless you use alpha clipping i think it will just end up opaque

#

Actually perhaps not

#

But you never set the alpha so it won't be transparent in use

#

@grand jolt what effect do you want from your shader?

leaden zinc
#

hey! i wonder if its possible to convert URP shader graphs to built in?

dim yoke
leaden zinc
#

everything is done in shadergraph

#

but im not sure if same opertions will be available

dim yoke
#

I think birp shader graph should support (atleast almost) all the same features as urp sg

leaden zinc
#

yeah, maybe not all of them but most. I was worried about nodes naming conventions between them too.
I will just try and see what happens

karmic hatch
leaden zinc
#

okay, im gonna give it a try. thank you for the help

grand jolt
karmic hatch
grand jolt
#

(If that's what you mean)

karmic hatch
#

your texture

grand jolt
karmic hatch
#

Presumably you want the maximum alpha value?

karmic hatch
# grand jolt yes

So when you're sampling the texture, store the rgba values, then extract both the alpha and the color you want (to save a few texture reads)

redTex   = tex2D(_MainTex, red_uv).r;
greenTex = tex2D(_MainTex, green_uv).g;
blueTex  = tex2D(_MainTex, blue_uv).b;
col.r = redTex.r;
col.g = greenTex.g;
col.b = blueTex.b;
col.a = max(max(redTex.a, greenTex.a), blueTex.a);
grand jolt
karmic hatch
#

oh right they should be float4s

#

or fixed4s

grand jolt
karmic hatch
grand jolt
karmic hatch
#

In the image I mean

#

Is it a fully opaque image on a transparent background?

grand jolt
#

in unity

#

it has a black bg

#

(with the shader)

#

without the material attached it works fine

#

here's what it looks like

#

if it helps, the sprite is animated

karmic hatch
#

I think if you comment out the line about blending and put a line after the alpha stuff doing clip(alpha - {some number between 0 and 1}); then it should remove the bits with low alpha

grand jolt
#

i literally know nothing about shaders so sorry for all the questions

karmic hatch
#

just put a line after you calculate the alpha, that's clip(alpha - 0.5);

karmic hatch
karmic hatch
#

yes sorry

leaden turret
#

BTW @karmic hatch i'm sure you've noticed by now the use of this URP Sample Buffer which i took advice from @regal stag about, just wondering if you approve of that method ๐Ÿ˜œ or would there be a different (less computation expensive even?...) way to do that, or is that definitely the way to go here

grand jolt
#

do we know why it's making the black bg in the first place?

karmic hatch
brave kettle
#

any know what happens? when i put a material with a shader dont become invisible

grand jolt
#

but i have another question

#

is there a way to post process only for one camera

karmic hatch
#

I think so but idk

karmic hatch
grand jolt
karmic hatch
#

set it to Input Texture Alpha

#

if it's not

grand jolt
#

would you know if there is a way to apply a shader to a camera object?

karmic hatch
#

Are you sure some of the black parts of the image don't have zero alpha?

karmic hatch
grand jolt
#

so i decided i might have to individually apply the shader to each sprite

karmic hatch
grand jolt
karmic hatch
# grand jolt the black square should not be visible

Indeed but is that the only part of the image with zero alpha, because it seems that if the alpha is coming from the image alpha, and if all the black parts in the image get cut, then all the black parts in the image must have low alpha

grand jolt
autumn willow
#

Hey guys I was working on a material for blending multiple textures together and I'm trying to work around the texture # limitations of webgl1 and so I've packed all the properties of a texture into a single one and then split it up in the shader. The issue I'm facing is that now there are these lines at the seams of the texture and I'm not sure how to remove them. It's worth noting that if I don't generate mip maps for the texture the lines go away but it absolutely tanks performance. Any tips would be greatly appreciated ๐Ÿ™

leaden zinc
#

Isnt any way to use it on builtin?

karmic hatch
#

In a lit graph, do you not have an emission output in the fragment node?

#

Also in the standard shader even in built-in there is emission

leaden zinc
#

There is emission node

#

But adding emission property in fragment is grayed out

#

Also is an unlit shader

karmic hatch
#

Unlit is all emission so it doesn't have a dedicated emission part

leaden zinc
#

Hmm

#

That must have changed, the tutorial uses master node, fragment + vertex wasnt yet implemented

#

What would be the way to do that now?

karmic hatch
#

To do what?

leaden zinc
#

Connect an input to the emission channel of the fragment shader

karmic hatch
#

If you're using an unlit shader, the base color is already emission

leaden zinc
#

Ohhh

karmic hatch
#

You only need emission for lit shaders

leaden zinc
#

Why was it separate before?

karmic hatch
#

Idk

leaden zinc
#

Hmm

tight phoenix
#

remapping the distance between 3D noise plastered on the exterior/interior sooorta works to imply mass inside of it, but its very unstable and inconsistent between angles

#

is there any way to make something like this more stable?

#

exterior and interior noise im taking distance between on the above

#

hm projecting one noise in world space does sooorta stabilize it a bit, but only if the dice doesnt move, as soon as you move it the effect is lost

#

this sorta almost works ๐Ÿค” if only it was less warp-y
Yeah im stumped, nothing beyond this ive done has looked any better

grand jolt
#

does anyone know how to use a stencil buffer to not modify a specific sprite in a shader?

dim yoke
#

just for clarification, this is pp shader used by Graphics.Blit

tight phoenix
#

is there an easy way to convert this to map the UVs the same on each face?

#

as in all 6 interior faces have the same UV from 0 to 1

#

I got one side to be the correct UVs ๐Ÿค”

#

hm maybe I can just split it and add them together in some way

#

there's gotta be a less stupid way to do this

#

this will work but its going to take hundreds of nodes

grand jolt
tight phoenix
#

close enough to test what I wanted to test ๐Ÿ”ฅ

#

test didnt work

#

I was thinking you could project a texture from 3 angles and sorta subtract all the view directions it doesnt overlap

#

to create a volume

#

6 if you wanted it to be fully 3D?

#

but my attempt to do that did not work

#

I was thinking you could encode the 'shape' in the xyz of a texture ๐Ÿค”

#

like if you consider the RGB chanels to be XYZ directions, you can imagine an object infinitely tall in each of those directions from the RGB colors
And you subtract the black so the end result will only occupy a position where all three align

#

hm let me try it in 3d

#

is it possible in shader to draw a sphere by subtracting three projections like so

#

its not about spheres though, its about arbitary volumetric shapes

kind juniper
kind juniper
# grand jolt bump : )

Maybe try to explain the problem better. What are you trying to do? What do you mean by "not modify a sprite"? That doesn't make any sense in the context of shaders.

grand jolt
kind juniper
grand jolt
kind juniper
#

Then why not just put these sprites on a layer that the pp effect does not affect?

grand jolt
kind juniper
# grand jolt i'm using graphics.blit

In this case, yeah, using the stencil buffer sounds like an appropriate solution. You'd need a custom shader for these 2 sprite though(or render them again with this custom shader) to write to the stencil buffer. Then do the stencil test in the pp shader and it should work. Check the docs on how to write/test the stencil buffer in a shader:
https://docs.unity3d.com/Manual/SL-Stencil.html

grand jolt
kind juniper
#

There are probably many ways. The simplest to set up would probably be a separate camera setup that only renders these 2 sprites with a replacement shader(or duplicate objects with the new shader) and nothing else.๐Ÿค”

#

And rendering the object one more time in there.

grand jolt
kind juniper
grand jolt
grand jolt
kind juniper
#

To 0. And the one in the stencil write shader to any other value below 255.

grand jolt
kind juniper
grand jolt
#

oh, sorry i misread

grand jolt
grand jolt
#

yeah it's not working

#

my two sprites are now invisible

kind juniper
grand jolt
kind juniper
#

If they're invisible, you probably removed/replaced the normal version(with the regular shader/material)

grand jolt
kind juniper
#

Hmm

#

And it makes the sprites entirely invisible?

grand jolt
#

nvm it doesn't

#

it still has the shader, though

kind juniper
#

Wdym?

#

They're rendered by the pp effect?

grand jolt
kind juniper
#

Did you add the stencil test to the pp shader?

grand jolt
kind juniper
#

Okay. And how does your stencil write shader looks like?

grand jolt
kind juniper
#

"to any other value" means not 0

grand jolt
#

oh alright

#

still does not work

#

(I set it to one)

kind juniper
#

In this case something must be overwriting/resetting the stencil buffer I guess. Try increasing the render order of the stencil write shader.

#

In the material

grand jolt
kind juniper
#

Yes. And assign the stencil write materials to them.

grand jolt
#

also i just saw this

kind juniper
kind juniper
#

Is that your sprite?

grand jolt
#

and this is the new stencilshader

kind juniper
#

That's the copy of your pp shader๐Ÿ˜…

kind juniper
#

The stencil write shader needs to write into the pixels that your sprite does. That's the whole point.

grand jolt
#

'Oh, your stencil write shader probably needs to be a copy of the regular shader you're using + the stencil write part.'

#

i followed this

kind juniper
#

Yeah, by "regular shader" I meant the one you use to render the sprite.

grand jolt
#

oh

kind juniper
#

But thinking about it more, it's probably gonna be more complicated that that.

#

It would work if it was a 3d object.

grand jolt
#

is there a way to just post process just on one camera

kind juniper
#

But with a sprite you might end up with 2 quads missing from the pp

grand jolt
#

thats really all i need

kind juniper
grand jolt
kind juniper
#

Although I'm not sure of the exact way. You probably just need to Graphics blit in the right place (after 1 camera renders and before the 2nd camera renders)

tight phoenix
#

I managed to stabilize my effect against its distortions moostly

#

its pretty close to looking like it has a physical volume inside of itself ๐Ÿค”

#

one that is mostly consistent across different rotations

tight phoenix
#

from certain angles it almost looks like its actually the same thing from different perspectives

#

and almost looks like physical interior without raymarching ๐Ÿ‘€

hallow plover
#

does anyone have documentation on what some of the already incuuded shaders does? I have looked at a lit shader grahp and it seems to have a few included hlsl files which might be useful but I have no idea what they do

proven copper
kind juniper
hallow plover
kind juniper
#

I believe unreal doesn't have much docs on their shaders as well. I guess it's just a common issue with most complicated topics that the engine devs don't expect the average user to go too deep into, or if they do, that they have enough background knowledge to just figure it out.๐Ÿ˜…

hallow plover
#

yeah. I have been trying to learn how lighting works in unity shaders for a really long time. I might try to switch gears and try to make my own lighting models since unity does not describe anything at all

kind juniper
#

There are actually some materials on lighting and shaders. They just don't go through each and every shader available.

hallow plover
#

yeah but I still find it very confusing

neat lichen
#

Hi, I have a Shader i use on a plane to show an Aurora Borealis. I use vertex displacement to make it wavy, but the vertex displacement only works in scene view. What could be the reason?

amber saffron
neat lichen
leaden zinc
#

hi! i wonder if there is any equivalent to this on built-in?

kind juniper
#

What does it do?

leaden zinc
#

mmm i think its the same as setting lightning to skybox instead of color lol.

amber saffron
neat lichen
#

Yes one moment

neat lichen
amber saffron
kind juniper
neat lichen
#

I resolved it, I feel silly. The spline tool I used to generate the mesh created a static mesh. Thank you still aliceheart

hot scaffold
#

Thanks again for this example btw. I have been searching for a shadergraph that is pretty much "URP Lit" as a starting point to add this to. any suggestions?

bold horizon
#

i wanna make a shader or material to achieve this how do i start?

#

this is my first time using unity

#

how to start with shaders and materials?

#

any tutorial would be helpful

tranquil pier
#

Hey! Not sure if I ask in the right place but let me know if not. My question is the following: how can I tile an atlas material without shader modifications? So for example I create a mesh that has these verices (0,0 - 0,1 - 1,1 - 1,0) and another that has (0,0 - 0,1 - 2,1 - 2,0) and I'd like the 2nd one to have the material twice. I've tried so many things and I couldn't make it work. UVs are setup like this: uvsOne[0] = new Vector2(0.8750f, 0.1875f);

haughty musk
#

i want so that both eyes have proper "offset" basically.

hallow plover
#

is there any good syntax highliting for hlsl shaders? Any program works fine as long as it has syntax highliting (like how visial studio does it in C#) and is free.

haughty musk
#

slevesque.shader for vscode ig

kind juniper
stiff tapir
tight phoenix
# proven copper this looks really sick, if possible could you give a general overview of how you...

Sure thing, im loading it up to work on more now.
The short version is that I have two gradient noises, one is in screen space and always faces the camera, but doesnt change size/position as you pan the camera/object or zoom in/out.
The second noise is a 3d noise mapped onto UVW coordinates that are aligned to make the cube look like its inside out

Then with some remapping I take the distance between those two noises and what you see above is what you get.
90% of the look is based on the the UVW coordinates, the noise itself is just two gradient noises plugged into distance

tight phoenix
haughty musk
stiff tapir
#

Not technically, but it's absolutely the same idea.

#

I was overlaying this starry texture once on UV coordinates, and once in screen space coordinates to generate a sense of fake depth, like you were looking into space on this character's scales

#

It was for a VR Chat character with some surreal materials

hallow plover
flint adder
#

Anyone able to help with shader variants?

#

why does it have 459 variants ? when I am only using this on one object

#

current build platform is Android

#

Vulkan

grand jolt
#

I have a shader that has this effect on the surface of the object it's applied on. and I want it to be projected towards everything that is below it, to give a caustics effect (shader graph)

#

I already have the nodes that make this effect

#

I just need to project that already existing image onto everything below it

grand jolt
#

anyone

ocean geyser
#

I'm having issue writing a simple radial-alpha shader (where center is 1.0, outside is 0.0).

            float4 adjustByAlpha(float2 uv, float4 input)
            {
                float dist = distance(float2(0.5, 0.5), uv) * 2.0f;
                return float4(1.0f, 0.0f, 0.0f, 1.0f) * dist;
            }

The idea is simple:

  • distance from center to the uv, which should be 0..1 range. This should result in 0 at the center, 0.5 at the outside (radius).
  • Multiply by 2 to get range from 0..1

Even this as you can see just shows a fully shown circle. What am I missing?

wicked magnet
#

Is it now 1 at the center or 1 at the outside?

ocean geyser
#

it's reverse than what I want, yes.

#

but I'm just trying to start with some sort of radial effect

#

that is - the code should display 0 at the center, 1 at the outside.
But reversed or not - it shows the entire circle as the same value.

grand jolt
#

does everyone here need help

grand jolt
#

I wish more people talked

wicked magnet
#

bruh anyone know anything about why my build doesn't finish after I set a specific set of shaders to always be included?

ocean geyser
#

@grand joltI guess you can make a post-processing effect for that, possibly using stencil

wicked magnet
#

well actually

ocean geyser
#

@grand jolt .. google

grand jolt
wicked magnet
#

its more like the shader used does not work in the build

civic lantern
grand jolt
#

so I'm guessing there must be a way

wicked magnet
#

compared to the ditor

#

edtiro*

wicked magnet
#

damn it

grand jolt
#

and it has to be tiled all across the plane

civic lantern
#

The decal projection does not work on transparent surfaces. that might be an issue, but if you want to project caustics on the bottom ground, shouldnt matter

wicked magnet
#

uh

ocean geyser
#

๐Ÿ˜ฆ anyone about my issue then? it should be very simple, don't know what's going on

wicked magnet
ocean geyser
#

@wicked magnet equivalent to vector2/vector4 ๐Ÿ˜

wicked magnet
#

vector4? goofy aah 4 dimensional movenment? ๐Ÿ’€

grand jolt
#

the thing is it's a separate shader

#

and I need it to be on a single shader

#

and also the caustics texture is animated and only works from a shader graph

civic lantern
#

well if its anything like HDRP decal, you can just use a custom shader for it

#

HDRP shader graph has a decal shader option

grand jolt
#

idk a node in the shader graph

#

or something like that

#

that I can just plug in with the rest of the stuff

civic lantern
grand jolt
civic lantern
#

its a shader graph so maybe youre able to copypaste/frankenstein your caustic shader into it

grand jolt
#

since the caustic shader covers waves foam and the poorly faked caustics

civic lantern
#

its just a blank shader graph with a specific output

#

again, not sure how it goes in URP, so cant help further

grand jolt
#

this is all that's inside

grand jolt
civic lantern
#

its a component.. look at the manuals

#

again i havent used URP decals.

wicked magnet
#

what even is the difference between "RP" and "URP" ? ๐Ÿค”

#

well anyways

#

shader's not working in the buid

#

build*

grand jolt
wicked magnet
grand jolt
#

and adds shader graphs

wicked magnet
#

ight ight

grand jolt
#

and was also the death of the start of the project I'm working on

#

because everything broke

wicked magnet
#

damn :(

grand jolt
#

it was confusing

grand jolt
#

the decal projector didn't work

#

so idrk what to do now]

#

aaa

balmy lark
#

Does anyone think that they can help me out (long warning)?
I'm trying to create a screen door effect using shader graph. Basically far away you can only see a big grid, and when you get close you can see a small grid of "pixels" too. I want to be able to apply this to walls so that it appears that anything beyond the walls and skybox are "gridded". I have all of that working OK, this was just background
Here's a preview of how it looks

#

This is generated by the following subgraph, which makes a grid, and shader graph, which combines the color and alphas of the two grids based on the view distance

#

Now notice how they aren't in world space, e.g. the grids don't line up if you move them around?

#

This can be fixed by adding a position node set to world or absolute world (not sure what difference is)

#

But when I turn them (as one might when making walls that completely surround the player, the grid stretches out like this:

#

How can I avoid this stretching and have the grid position in world space but the rotation? normals? uv direction? in object space. This is where my knowledge breaks down, sorry.

#

Apparently there's a Triplanar node that can do this for you, which would be pretty cool, however, it only works on textures. I'm generating this using the rectangle node.

#

I have a feeling that I need to put in some special UV into the rectangle node in my subgraph, but what could it be?

grand jolt
#

Hello, I am having trouble sampling the main depth texture from a post processing shader in URP (not shader graph).

It appears in RenderDoc as a completely black texture; It's called "UnityBlack".

In my forward renderer settings I render all the objects with "Depth Write" enabled and my camera has depthTextureMode set to DepthTextureMode.Depth. In RenderDoc, I can see it being generated, but it isn't being passed into my shader for some reason... I'm sampling it like this in my shader:

float depth = tex2D(_CameraDepthTexture, i.uv).r;
depth = Linear01Depth(depth);

What might be going wrong?

kind juniper
grand jolt
#

Well that wasn't working either.

kind juniper
#

Hmm... Nvm. Was confusing with stencil buffer.

kind juniper
grand jolt
#

Yep. Then I return that as the fragment colour.

#

Like this: float4(depth, depth, depth, 1.0).

kind juniper
#

Wait, so the issue is not that the depth is not generated properly?

grand jolt
#

No, I can see the depth texture in RenderDoc and it looks correct.

#

I cannot sample it from my post processing shader - the result is always zero and the input to said shader according to RenderDoc is "UnityBlack".

kind juniper
#

Okay.

#

Is your pp shader a compute shader perhaps?

grand jolt
#

Nope. It's a vertex + fragment shader.

kind juniper
#

Okay

#

What does Linear01Depth does? Can you share the code?

grand jolt
#

It's a built-in function.

#

It converts the depth from the non-linear space that it's rendered in to a linear depth.

kind juniper
#

Try outputting the depth as color without it. Is there any change?

grand jolt
#

Nope.

#

@kind juniper I didn't have this checked in my render pipeline asset:

#

It works now... Thank-you for your help :)

kind juniper
#

Oh it was that simple.๐Ÿ˜…

craggy jay
#

hello! i'm trying to convert a world position to a view port position and I'm having no luck

#
screenWorld.x = (screenWorld.x / screenWorld.w + 1) * 0.5;
screenWorld.y = (screenWorld.y / screenWorld.w + 1) * 0.5;```
#

am i doing anything wrong?

#

also, i.world does return the actual world position, i've tested it a ton of times so that is not the problem

#

i have a feeling that it's something to do with opengl's inverse z axis but i don't really know where I'd apply that?

#

i've done this before in shadergraph, and i just did screenWorld.y = (screenWorld.y / screenWorld.w - 1) * -0.5; and that worked perfectly, but it doesnt work in this shader?

warm marsh
#

Have you tried screenWorld = ComputeScreenPos (screenWorld);?

craggy jay
#

I have, that requires an object postion, but for some reason still doesn't work?

#

i've also tested doing screenWorld = ComputeScreenPos(i.vertex) which works perfectly in the vert pass but doesn't work at all in the frag pass?

#

the input of frag() and the output of vert() should be the same right?

#
            {
                v2f o;

                float4 world_origin = mul(UNITY_MATRIX_M, float4(0, 0, 0, 1));
                float4 view_origin = float4(UnityObjectToViewPos(float3(0, 0, 0)), 1);

                float4 world_pos = mul(UNITY_MATRIX_M, v.vertex);
                float4 view_pos = world_pos - world_origin + view_origin;

                float4 clip_pos = mul(UNITY_MATRIX_P, view_pos);
                o.vertex = clip_pos;
                //o.vertex = UnityObjectToClipPos(v.vertex);

                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                o.color = v.color * _Color;
                o.screen = ComputeScreenPos(o.vertex);
                o.world = mul(unity_ObjectToWorld, mul(inverse(UNITY_MATRIX_V), view_pos));//mul(unity_ObjectToWorld, v.vertex);
                UNITY_TRANSFER_FOG(o, o.vertex);
                return o;
            }```
#

o.screen returns the screen coord that i need, but if i calcuate it in frag(), it doesn't give me the same result

#

also, ik it sounds redundant since i have the screen coord, but i'm trying to get it working in the frag pass so that I can invert it and get the world position from the screen coord. all i need to do is get the world > screen conversion working and then I can go from there

craggy jay
#

another weird thing I came across, if i do screen.xy /= screen.w in frag() then i get the first image, if i do it in vert(), then i get the second

craggy jay
#

okay, i figured it out

#
float2 screen = i.screen.xy / i.screen.w;

// Convert Screen Coords into World Space Coords
float4 world = float4((screen.x * 2 - 1) * i.screen.w, (screen.y * -2 + 1) * i.screen.w, i.screen.z, i.screen.w);
world = mul(inverse(UNITY_MATRIX_VP), world);```
#

that goes into frag() while i.screen is defined with o.screen = ComputeScreenPos(o.vertex); in vert()

#

hope this helps anyone in the future

astral pecan
#

Anyone know how to use UV with procedural texture?

kind juniper
astral pecan
#

For example I want to use this twirl on this procedural texture

#

Its an animated texture created procedurally

kind juniper
#

What do you man by "use on"?

astral pecan
#

I can input UV on Unity's procedural texture nodes

#

How do I apply it on my own procedural texture?

kind juniper
#

Supply the uvs into your procedural texture node.๐Ÿคทโ€โ™‚๏ธ

#

Is your "procedural texture" just that sine node?

astral pecan
#

Oh crap you're right

#

I created them from UV at the beginning

#

I can input them there

patent plinth
#

How to make lit shader does not affected by ambient light in shadergraph?

tranquil jackal
karmic hatch
cerulean agate
#

Is it possible to get customizable text into a shader graph material? I'm trying to make decals with custom text (text changeable at runtime).

amber saffron
# cerulean agate Is it possible to get customizable text into a shader graph material? I'm tryin...

Not easilly.
The closest you could do is use a glyph texture atlas and sample it in you shader based on an input "string".
But as shaders don't take strings as input, you'll have to convert it into an array of indices for the atlas or something similar.

My best advice would be to use a dedicated RenderTexture and a camera to render your text into it (using TextMeshPro) and provide this texture to the shader.

karmic hatch
#

Is there a way to blend a transparent shader with two colors (multiply the background by one color, then add a second color), or do I need to use the opaque texture for that

astral pecan
#

How to use this feature?

#

Its released, but there is no UV option for Vector2 default values

amber saffron
amber saffron
amber saffron
astral pecan
#

I see, my bad, I thought I can use the feature already since it says released on the roadmap

amber saffron
regal stag
digital helm
#

Hey guys, does Unity support UDIM?

amber saffron
tacit stream
#

What would be a way to combine instanced shader and normal (non-instanced) into one?

#

Instanced

Shader "Unlit/EntityIdShader"
{
    SubShader {
        Tags { "RenderType"="Transparent" }

        Pass {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_instancing
            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };
            
            struct v2f
            {
                float4 vertex : SV_POSITION;
                UNITY_VERTEX_INPUT_INSTANCE_ID // use this to access instanced properties in the fragment shader.
            };
            
            UNITY_INSTANCING_BUFFER_START(Props)
            UNITY_DEFINE_INSTANCED_PROP(fixed4, _SelectionColor)
            UNITY_INSTANCING_BUFFER_END(Props)


            
            v2f vert(appdata v)
            {
                v2f o;

                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_TRANSFER_INSTANCE_ID(v, o);
                o.vertex = UnityObjectToClipPos(v.vertex);
                return o;
            }

            fixed4 frag(v2f i) : SV_Target
            {
                UNITY_SETUP_INSTANCE_ID(i);
                return UNITY_ACCESS_INSTANCED_PROP(Props, _SelectionColor);
            }
            ENDCG
        }
    }
}
#

Non-Instanced

Shader "Unlit/EntityIdShader"
{
    Properties
    {    
        _Color ("Color", Color) = (1,1,1,1)
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            struct appdata
            {
                float4 vertex : POSITION;
            };

            struct v2f
            {
                float4 vertex : SV_POSITION;
            };
            
            fixed4 _Color;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                return _Color;
            }
            ENDCG
        }
    }
  
}
regal stag
amber saffron
#

Once again, I find that Unreal's way to handle this is easier :/

astral pecan
#

Is this a branch in compilation or nah?

#

Using dropdown on subgraph

#

If it creates a branch I better create a sub graph for each type

amber saffron
#

This is a keyword property ? Then yes, compilation branch

astral pecan
#

Hmm ok

#

Its a dropdown property, not a keyword property

#

Since keywords not exposed for sub graph as a node

amber saffron
#

Now, branches are not always your enemies :
Depending on the type of keyword, not all variants are compiled

#

But it looks like the dropdown property is generating a ...

#

How the hell could I name that ...

#

"constant dynamic branch" ?

#

The branch code is dynamic (not compilation dependant on keywords), but the predicate is constant, as you select it on the node, and can't connect a varying input.

#

So, at runtime, only one branch is ever evaluated for this node

astral pecan
#

Ooh, that's great

#

Thanks for the answer, it's safe to use then :)

amber saffron
#

In theory, the compiler will even optimize this to have no branch at all at the end, as the predicate is a hard coded constant.

frosty linden
#

Could somebody tell me how this is possible? I'm extracting the alpha of a JPG but it's not fully white?? There's no alpha channel in the JPG

#

It seems to average the 3 other channel into alpha? Isn't it a bug? Alpha channel should be 1 if there is no alpha channel in the texture, shouldn't it ?

#

(And I think I already asked about this a few months back lol... I love stumbling on the same issues and completely forgetting about them ๐Ÿ˜‚ )

amber saffron
frosty linden
#

Ah yeah! That the answer back then

#

Dammit I'm stupid

#

Thanks a bunch ahah ๐Ÿ˜‰

winter timber
#

wondering what name the default shader's colour arrays have? (I'm gonna set them via a script)

kind juniper
#

Color arrays..?๐Ÿค”

winter timber
kind juniper
#

Color property?

#

Probably white.

#

By default.

winter timber
#

not quite what i mean, hold one while i find a better way of describing it

#

like what should i replace NAME with in order to write to the shaders colour thingy, if this helps?```cs
MatBlock.SetVectorArray("NAME", ColourArray);

amber saffron
#

The default shader doesn't have any color array input

winter timber
#

then how can the particle system have different colours for different meshes, with them all having the same material? wha?

kind juniper
#

Sounds like a serious misunderstanding of how shaders work๐Ÿ˜›

winter timber
#

ye, very likely

amber saffron
winter timber
#

oh ok cool, so if i just set the vertex colours of the mesh then the default shader will automatically work out how to set the colours?

amber saffron
#

No

winter timber
#

oh

amber saffron
#

The default shader doesn't care about vertex color

knotty juniper
#

the paricle shader uses the vertex colors to color the particle and uses its alpha value

amber saffron
#

But the particles one does

winter timber
#

oh ok, thanks a ton!

#

guessing that means ill need a new mesh for each colour then?

amber saffron
knotty juniper
#

either generate a material per new color or use a MaterialPropertyBlock to override the values per renderer

winter timber
winter timber
knotty juniper
winter timber
amber saffron
winter timber
knotty juniper
#

using MaterialPropertyBlock only makes sense if you have sets of settings
like if you had 20 different colors
you would have to do one draw command per set

kind juniper
#

Or fill a buffer of colors and sample it in the shader!

winter timber
amber saffron
# winter timber ooh that sounds clever, then i could just pass an int along with it for it to wo...

Example of using an array of color, assigned per mesh : https://toqoz.fyi/thousands-of-meshes.html

winter timber
#

anyway, thanks so much yall!

low lichen
winter timber
#

dont see how to add a colour array in shadergraph, guessing i can just use a texture2d as a replacement?

regal stag
winter timber
haughty moat
#

I assume Unity must somehow Take Care Of It, but how do I release Textures from compute shaders the way I release structured buffer, I can't find anything in the documentation (which makes me think it's a non-issue)

kind juniper
#

I'd assume that the managed texture object takes care of that.

haughty moat
#

Can't think of anything else either. So should I set my texture references to null on the C# side to make the garbage collector unbind them ? (That seems weird, even for unity)

kind juniper
haughty moat
#

Mostly to be sure they don't linger in the GPU, I use a bunch of noise textures at startup to generate other data, and I don't need them past that point(I have a couple kernels in my compute shader I dispatch a single time). If they were a buffer I'd just release them then. (I'm almost certain this isn't a problem, I'm just curious of how unity handles it)

shadow locust
haughty moat
pallid prism
#

Is there a way to make vertex shaders have working colliders? When I was working on my water shader, there seemed to be no way that I could find, so I wanted to verify. If there isn't a way, is it because vertex shaders are simulated on the GPU?

kind juniper
#

Not just vertex, but shaders in general are run on the GPU. They have a completely different workflow to CPU side(different language, API and what not) and absolutely no access to unity API. Unity default physics simulation is run on the CPU side, and don't have any access or relation to what's going on on the GPU side.

pallid prism
#

Yeah, that's what I thought. It's a shame, would be awesome to be able to connect it to Unity API features. But I guess I'll have to make a script handle the vertex side of my water system if I really want it to have colliders.

clear vector
#

@regal stag https://www.cyanilux.com/tutorials/depth/#depth i'm reading depth guide, so what can be overrited to depth buffer? (like it described in Shader Depth Output section) Should it be always value between 0 and 1? And how then can i test pixels depending on overwriten depth or it will happen automatically?

A big post explaining everything about Depth : Depth Buffer, Depth Texture / Scene Depth node, SV_Depth, Reconstructing World Position from Depth, etc.

kind juniper
pallid prism
#

Yeah, I know. Thanks anyways.

mental bone
tacit stream
#

hmm. Even though indices are different, all I'm getting - red color

            int _Index;

            fixed4 frag(v2f i) : SV_Target
            {
                fixed r = (fixed)(_Index & 0xFF);
                fixed g = (fixed)((_Index >> 8) & 0xFF);
                fixed b = (fixed)((_Index >> 16) & 0xFF);
                fixed a = (fixed)(255 - (_Index >> 24));

                return fixed4(r, g, b, a);
            }
#

pure 1,0,0,1

#

any idea how to fix it?

#

so per unique integer I get unique color

verbal slate
#

Hey guys... Im working on a cel shader, and such problem occurs when shadercaster is applied...

#

I thought it is shadow acne, but changing normal and depth bias doesn't make any difference on this while they DOES reduce the acne on other objects

kind juniper
#

And how are you inputting is?

tacit stream
#
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _Index ("Index", int) = 0
    }
verbal slate
kind juniper
tacit stream
#

hmm

#

looks like I should have just divided it by 255

#

seems to work now

#

just came up with it ๐Ÿ˜…

verbal slate
#

oh oops sry...

#

Sry no used to this...

spare badger
#

hello ,i got "unidentified error at line" error in customfunction how can solve it;

tacit mural
#

Hey, I wrote a shader for a skybox in URP but I've noticed that it's not outputting any color for environment lighting (everything is very dark when environment lighting source is set to skybox). I'd previously kinda just assumed it was an automatic thing but is there a way I can set it as an output in the shader?

craggy jay
#

does anyone know how to define an array of floats in a shader?

#

not as a property, just like the syntax of making one

#

all i've found is float arrayName[16]; when what I want to do is this (using c# for example) float[] arrayName = new float[16] { 1, 2, 3, 4..... };

regal stag
craggy jay
#

ah okay thanks! I'm just setting up a const bayer matrix for some dithering pass, not anything special

regal stag
tacit mural
#

I have baked the real time GI

tight phoenix
#

I have two randomness functions that rely on Voronoi.
The top one produces the ammount of random vectors that I need, but it doesn't work on Voronoi with smooth edged cells
The bottom one is the opposite - works on smooth celled voronoi, but doesn't produce random enough values

#

I don't really understand the math behind either's function at all, how can I fix the bottom one to be like the top one?

#
inline float Randomize(float seed) // we expect seed is between 0 and 1 <precision purposes only>
{
    float r1 = seed * 985.34342;
    float r2 = seed * 645.56432;
    float r3 = seed * 853.67543;
    float r4 = seed * 234.76543;
    
    float q1 = frac(r1 * frac(r2));
    float q2 = frac(r3 * frac(r4));
    
    return frac(q1 + q1 + frac(r1) * frac(r3));
}

inline float3 RandomVec(float seed)
{
    return 2 * float3(Randomize(seed), Randomize(frac(seed + 0.12345)), Randomize(frac(seed - 0.75643))) - 1;
}```
This is the code for the randomness that is random enough but doesnt work for the smooth cells
#
inline float hash1( float n )
{
    return frac(sin(n)*43758.5453);
}

        float3 col = 0.5 + 0.5*sin( hash1(dot(n+g,float2(7.0,113.0)))*2.5 + 3.5 + float3(2.0,3.0,0.0));
#

and this I think??? is the code for the smooth one

#

theyre completely incompatable but I have to make them compatable

#

I tried manually welding in the other one but that one destroyed the smooth cell fall off

#

I think I found part of the problem

#

when you change angle offset in regular voronoi, it changes the cell value, this one doesnt do that

tropic sluice
#

Does anyone know if its possible to have stuff like:
ColorMask RGB
as a shader property? So I can just specify a colour mask in the material?

tight phoenix
# tight phoenix ```csharp inline float hash1( float n ) { return frac(sin(n)*43758.5453); } ...
        float3 col = 0.5 + 0.5*sin( hash1(dot(n+g,float2(7.0,113.0)))*2.5 + 3.5 + float3(2.0,3.0,0.0));
           
        float3 col2 = float3(0,0,0);
        col2.x = RandomRange(col.xy);
        col2.y = RandomRange(col.yz);
        col2.z = RandomRange(col.zx);

inline float RandomRange(float2 Seed)
{
    float randomno =  frac(sin(dot(Seed, float2(12.9898, 78.233)))*43758.5453);
    return lerp(-1, 1, randomno);
}

I solved my above problem by brute force, how can I optimzize this to not need this stupid hack?

#

"working" but inefficient

regal stag
tropic sluice
#

thanks

regal stag
tropic sluice
#

@regal stag how would you set that in code?

#

Is it just 1-15 for various combos?

regal stag
#

via material.SetFloat/SetInt. Can use numbers but it's likely easier to use the UnityEngine.Rendering.ColorWriteMask enum

tropic sluice
#

Oh nice! Thanks a ton

tight phoenix
#
inline float hash1( float n )
{
    return frac(sin(n)*43758.5453);
}

inline float RandomRange(float2 Seed)
{
    float randomno =  frac(sin(dot(Seed, float2(12.9898, 78.233)))*43758.5453);
    return lerp(-1, 1, randomno);
}```
#

I need both of those to be a single function that gets called one time per loop instead of two functions that get called four times total

#
        float3 col = 0.5 + 0.5*sin( hash1(dot(n+g,float2(7.0,113.0)))*2.5 + 3.5 + float3(2.0,3.0,0.0));           
        float3 col2 = float3(0,0,0);
        col2.x = RandomRange(col.xy);
        col2.y = RandomRange(col.yz);
        col2.z = RandomRange(col.zx);```
#

the current completely worthless shit 4 calls

tropic sluice
regal stag
tropic sluice
#

oh i was using ||, doh ๐Ÿ˜„

karmic hatch
tight phoenix
tight phoenix
#

so instead of h being a float you're saying h should be a float3?

#

How does that help me not need to do four loops of randomization above?

#

hm, I was about to say the other method does it all at once, but I just realized the other method is also taking three functions to output its random values

karmic hatch
tight phoenix
#

It is but its an awful one that is barely random

#

completely unusuable

karmic hatch
#

ah

tight phoenix
#

which is what im trying to overcome/fix

#

let me reset it to default so you can see its output

tight phoenix
#

vs what I get when I run those barely random values through unity's randomize function on top of it

#

whatever 'col' is doing to get random values it looks like its only really doing random once and then trying to fudge it a bit for the other two channels

karmic hatch
tight phoenix
#

yeah im too stupid to get it

#

I tried to just replace the col method with the method that the other one uses

#

but it just doesnt work at all because I don't underfstand it

#

inline float SmoothRandomize(float seed) // we expect seed is between 0 and 1 <precision purposes only>
{
    float r1 = seed * 985.34342;
    float r2 = seed * 645.56432;
    float r3 = seed * 853.67543;
    float r4 = seed * 234.76543;
    
    float q1 = frac(r1 * frac(r2));
    float q2 = frac(r3 * frac(r4));
    
    return frac(q1 + q1 + frac(r1) * frac(r3));
}

inline float3 SmoothRandomVec(float seed)
{
    return 2 * float3(SmoothRandomize(seed), SmoothRandomize(frac(seed + 0.12345)), SmoothRandomize(frac(seed - 0.75643))) - 1;
}
#

this is what the other node uses to generate 3 random vectors

#

but when I run it, I only get one

karmic hatch
tight phoenix
#

a vector3 who's values are all random

#

and not a vector3 with two channels of black

#

doesnt work

#

all my various failed attempts cannot subsitute out this

        float3 col2 = float3(0,0,0);
        col2.x = RandomRange(col.xy);
        col2.y = RandomRange(col.yz);
        col2.z = RandomRange(col.zx);```
#

every time I try to change any part of that, it fails to produce random numbers

karmic hatch
tight phoenix
#

because im too fucking stupid to have any idea what im doing

karmic hatch
#

Idk why the other two are black though

tight phoenix
#

me either

#

I dont know anything ive been slamming my face off of this to a bloody pulp for hours and gotten nowhere except shittier than when I started

#

why does this work but it doesnt work when I copy it into a different method

karmic hatch
#

Probably just multiplying a seed where 0<seed<1 by something large then fracting would give a 'random' number of sorts

tight phoenix
#

im starting to go into crisis now because you're trying to explain to me the answer and im too fucking stupid to solve it when you literally hand me the answers

#

you are endlessly kind and knowledgeable and im always too stupid

karmic hatch
tight phoenix
#

my various other failed attempts all commented out

#

plus like5x more deleted

#

if I just output col2 instead of col, the voronoi is a perfectly square grid of random colors with no blending

#

so I can assume that method is what creates the blending and voronoi cells

#

if I try to output H to see wtf it actually is its jst black though

tight phoenix
#

maybe this hideous as fuck shitty hack I did is fine and I should just move on??????????? because im too fucking stupid to know better how to not need to randomize four times per loop leading to massive ammounts of looping

#

even though the OTHER method does it without a single loop

#

AND all at once without needing four methods

#

PEBCAK is my issue

#

im the problem, as usual

karmic hatch
tame topaz
#

@tight phoenix Again, we don't need this monologue, this isn't the first time you've been told. If you need to take a break, take one.

tight phoenix
#

If you don't want me around you should just kick me from the server

#

I'm sorry I have awful mental heath but at least im trying desperately to reach out and grow and improve

#

I'm not going to be your or anyone else's pity victim

#

pick a side and stick with it, with me or against me there's no grey area

#

you're either the enemy of people with mental health issues or their ally

tight phoenix
#

If you want to personally erase a victim of all kinds of child abuse that I won't get into, say it with your own voice and name, don't hide behind the anonymous 'we'

tame topaz
#

I represent moderation of this server. As you've been told before, we're not one for mental health discussion, you should seek professional help in that regard.

Keep this channel on topic now and in the future.

tight phoenix
#

Same to you, if its not about shader code, I don't want to speak with you for anything

tame topaz
#

Great, keep this channel specifically to shader code and we won't have to. ๐Ÿ‘

sage locust
#

I was overthinking on creating a shader but before I decide to do it the hard way, can Unity grass follow a rigged mesh?

kind juniper
verbal slate
sick pulsar
#

is it possible to use shaders to get this

kind juniper
#

What's "this"?
A light emitting rectangle?๐Ÿค”

sick pulsar
#

basically

#

50% light 50% black

kind juniper
#

Anything that goes outside the mesh would require more than a shader, unless it's a post processing shader.

sick pulsar
#

so i should just split it up and make multiple materials

kind juniper
#

That's one option. It looks a lot like already existing post processing effect - bloom. Maybe use that?

boreal relic
#

I made a simple shader with gpu instancing and it is working well, the question is, there is a way to use animation clips and animator???

kind juniper
verbal slate
kind juniper
#

Aight. Then gotta look into your shader again.

verbal slate
#

Shader code above

#

Also, meshes with other materials correctly cast shadow on to meshes w/ this mat

#

And these meshes correctly cast shadows on other meshes

#

the problem only happens to themselves

#

It of course can be influenced by shadow resolution, but not influenced at all by depth/normal bias

vocal narwhal
#

What is h representing?

verbal slate
#

oh it's the avg of light dir and view dir, just a way to calculate specular

#

im pretty sure it's not the reason cuz I used it elsewhere but none of those shaders have such problem

vocal narwhal
#

I would output different things as the final color to see what they are, which should help you get to the origin of whatever's causing the pattern

verbal slate
#

good idea... let me try

#

oh wait I tried that before

#

and

#

it's becuz of the shadow

#

so if I return float4(shadow, shadow, shadow, 1);

#

it looks like this

#

Just a guess... this might because the vertices are not correctly recorded in the shadow map... can somebody teach me how to check shadowmap in urp?

vocal narwhal
kind juniper
#

In the shadow pass.

verbal slate
kind juniper
#

Yes

verbal slate
#

oh sry that was a temp change... I used to use sth like UsePass "Legacy/VertexLit?ShadowCaster"

kind juniper
#

Does the issue happen with shadow caster pass commented out?

verbal slate
#

I copied that cg code from others to test if different shadow caster influence the effect

verbal slate
kind juniper
verbal slate
#

I just copy & pasted it...

#

so I think it might be the problem of my pipeline setting or sth?

verbal slate
#

like this

#

And this

#

the resolution is a little low so it is jittering...? maybe?

#

but I think that's normal...

kind juniper
#

Are you still using CG code in your shader?

#

Can you select the shader asset and take a screenshot of it's inspector?@verbal slate

vocal narwhal
#

Both shaders similar output if I show shadow for a sphere but neither seems to be influenced by it ultimately

verbal slate
kind juniper
#

Hmm...

verbal slate
kind juniper
#

Is the warning relevant perhaps?

verbal slate
# kind juniper Hmm...

I'm actually just at beginner level... so plz dont laugh if there is a silly mistake...

verbal slate
#

just a space transformation warning... Unity wants me to use a buildin func instead of matrix multiplication

kind juniper
verbal slate
#

The shader I copy from github (mentioned above) also have the same problem even thought the author didn't mention such problem at all, so probably it's because of my pipeline setting that causes the problem that doesn't happen on other people's device?

verbal slate
verbal slate
kind juniper
#

Maybe there're some clues in the frame debugger.

verbal slate
#

yeah but I don't know what to check in the frame debugger...

verbal slate
kind juniper
verbal slate
#

k, let me check

#

Thx

grand jolt
#

Hey all!
I have a simulation room that is based off the Titanfall boomtown.

However, my current setup is reflecting the ground on the roof.

Is there a way to flip this or add some type of transparent setting to get it to show off the sky?

#

inspired by this^

kind juniper
kind juniper
grand jolt
ashen lance
#

Hi so I have this weird bug when importing a mesh from Blender to Unity.

#

I am using Shader Graph and when I set the shader to transparent some face are not drawn according to their location on the z axis. In other words some face that are further are drawn on top of those who are closer.

#

This is not related to normals orientation I think. I recalculated them outside already

amber saffron
ashen lance
#

Even when the alpha is set to 1?

amber saffron
#

Yes

ashen lance
#

Is there a way to reach to effect I want?

amber saffron
#

IDK what you want precisely, but a solution could be to split the meshes and change the render-queue value

ashen lance
#

This is larger topic than I anticipated

#

I'll read some materials about

#

Thanks anyway

regal stag
wary quarry
#

Hey. I am trying to make a a Lit shader with ShaderGraph and use my custom lightning. As far as I understand to make custom lightning I have to "disable" Unity lightning information by setting Base Color to black, Metallic and Smoothness to 0 and then just plug my lightning and additional calculations into Emission slot. So far so good, everything works well. Now if I want to use Metallic Map, how can I replicate metallic calculations via shadergraph/scripting. Could someone give me a good reference where to start?

mild kayak
#

Hi Friends, im in HDRP, trying to make a UI Shader. for "Source Image" on the canvas the property name is _MainTex and that works fine in the shader, but i cant get the color from the canvas to work, anyone know what the Property name needs to be?

knotty juniper
#

the image component does put the color into the generated UI mesh

white marsh
#
float3 finalCol = tex.xyz * light * _MainColor + specularLight + fresnel * _ColorRimLight * _ColorRimLight.a);
float4 output = float4(finalCol, 1);

if i calculate the final color in my shader like this. and i want to add my metallic, where/how do i do that?
the ways i tried it looks like the color is wrong or when i set metallic to 0 it becomes black

amber saffron
white marsh
#

I have a variable with the finished metallic calculated but how do i apply it to the final color correctly?

mild kayak
white marsh
#

so idk how i should add the metallic on the color to get it to have it look correct

#

or maybe im missing a step in my calculation

amber saffron
white marsh
#

oh so only doing this

float3 reflectionDir = reflect(-V, i.worldNormal);
float roughness = 1 - _GlossIntensity;
roughness *= 1.7 - 0.7 * roughness;
float4 envSample = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, reflectionDir, _MetallicRoughness * metallicMap * UNITY_SPECCUBE_LOD_STEPS);
float3 diffuseIBL = DecodeHDR(envSample, unity_SpecCube0_HDR) * _MetallicIntensity;

would only be part of the reflections i need to blend between then?

mild kayak
white marsh
#

so i want to blend between this diffuseIBL + fresnel + specular * albedo (black) and the diffuse?

amber saffron
knotty juniper
white marsh
#

i think i figured it out

#

though, the specular shouldnt be in with the reflections right? as something can still have specular and not be metallic if im remembering correctly

mild kayak
mild kayak
#

My UI shader is not appearing when the canvas is set to overlay mode, how fix? ๐Ÿ˜„

dim yoke
mild kayak
dim yoke
#

Queue and ZTest [unity_GUIZTestMode] are the ones I meant

plush yarrow
#

how do i add specular in my shader graph?

#

its grayed out

regal stag
#

You could provide a Vector3 property (or Float if you just need Y) to offset (subtract) the position from the Object node for each mesh. So say the hat is 1.5 units above the feet of the player, for it's material you'd set the property to (0, 1.5, 0) while the material for the rest of the player stays at (0,0,0).
Or could pass the worldspace player position in (perhaps to a global Vector3 property) and replace the Object node entirely. Though with that you'd need to update the position every frame while the offset would be set once.

white marsh
#

im trying to find the unity manual page where they explain every step of making a diffuse shader but i cant find it

astral yew
#

Ive written a simple shader to draw a 1px outline of a province map image to a custom render texture. I would like to use a second shader to then stamp an outline texture periodically along the white pixels (for example a dotted line). The problem is im not really sure if what i would like to do here is even possible using shaders, or if there is some unity feature that would do a better job.
See here for more detail: https://forum.unity.com/threads/stamp-texture-along-outline-textur.1347770/

cosmic prairie
#

Hi! I have a question regarding ComputeScreenPos and soft particles...
So, I want to display objects behind walls with a custom alpha value (like 0.5) to make them less visible. I checked out how soft particles are done, since it's basically the same effect, just the alpha curve changes differently. In soft particles, unity does this: sceneZ - i.projpos.z, where sceneZ is acquired from the depth texture, and projpos is from ComputeScreenPos(). Now, if I try to implement it the exact same way, using projpos.z, this value never changes. it's like projpos.z is constant 1. Using projpos.w on the other hand seems to result in the desired effect. My question is, why is this? Should I be worried that I used something incorrectly, and now my shader code won't be consistent on different devices? Please help

#

(using built-in rp btw, required for this project)

prisma fox
rough haven
#

why are the raw vertex positions are screen space by default

#

like when you do this

knotty bough
#

Hey, I'm sure this is very obvious, but how do you make this little connection node?

#

NVM

#

JUST FIGURED IT OUT

ebon basin
#

Using the shader graph, what nodes would I use utilize to create an effect such that a ring expands outward using the uvs. Something that kinda imitates a wave effect without distorting the vertex, and maybe an effect that expands outward like a nova.

meager pelican
# prisma fox Kinda curious, how would you replicate the Visual Effect Graph's Subpixel Anti A...

As a general discussion the vertex stage is resolution-independent. It's calculating in "space math" (generally object space and clip space) using just math for the verts. This is why the ddy/ddx values aren't available to a vert program and why you have to use things like tex2dlod if you want to read a texture in a vert program.

You can, of course, pass in your own values to your shader. What I would do if I were you is to generate a basic simple shader using that subpixelAntiAliasing node, and examine the code generated to see what it is doing.

meager pelican
prisma fox
#

Ah, thanks for the tip. Just checked out a generated VFX Graph shader. Surprisingly, it appears that they are modifying in the Vertex stage. A call to a method named SubpixelAA. I've copied the method here in case anyone has the same question later: https://gist.github.com/occasoftware/db75b9e908ba109c574cafa2d76eaf9f

Although this element of the approach reads in a straightforward way, it looks like they reconstruct a VFX Element matrix that they mul with the input vertex positions and then convert to clip space before passing to the frag stage.

Gist

A copy of the Subpixel AA method from the Visual Effect Graph shader. - SubpixelAA.hlsl

meager pelican
#

Cool, yeah, they're using passed-in values. Calcing in the vert is smart.

Your 2nd paragraph makes sense too. Sure, since vert() always outputs clip space. It's the reconstruction that is "hard". So they're changing the size of the particle and snapping it to some kind of grid by sizing it? And the more it is resized, the lower the alpha due to the ratio of localsize : resize. Pretty cool.

#

IDK how they set the passed-in values, more research!

#

I assume the alpha is interpolated...so I'd check the vert2frag interpolation to see what is passed.

prisma fox
#

Yeah, I was wondering whether they would run a compute shader on the background to modify the object matrix in some way, interesting to see that they do it directly on the vertex stage. It looks like the matrix reconstruction is fairly straightforward as well. In short, just the rotation matrix multiplied with the scale matrix in the float3x3 and then the position assigned to the 4th column. Copied into the gist as well for convenience.

#

I'm not that familiar with the contents of the projection matrix, so I'm finding it difficult to parse out the reality of what is happening in this line float minSize = clipPosW / (0.5f * min(abs(UNITY_MATRIX_P[0][0]) * _ScreenParams.x, abs(UNITY_MATRIX_P[1][1]) * _ScreenParams.y)); // max size in one pixel, presumably it does as the comment says.

#

I don't see any obvious re-interpolation of the alpha, although the actual usage is buried since they pass it through quite a few other methods. I assume they pass it to the frag and use it as-is for alpha blend otherwise they multiply with the color for additive.

meager pelican
#

Sounds like you've got it, you'll dig in. Sorry I don't have that either, off the top of my head. But it makes sense, because the projection matrix takes view space and splats it to 2d space.

Well, yeah, that's how they pass it to the frag, via interpolators. As I said, I'd assume.

dull bramble
#

Hey, is there any easy way to get the terrain color (maybe like runtime virtual textures in unreal) in Unity URP?

prisma fox
#

Yup, thanks for the chat and the tip! Helped a lot to get me on the way.

rough haven
meager pelican
#

It might, depending on the origin of the mesh, and the values in the verts. Many meshes have values in their verts that are within the range of clip space (which is what the vert() stage outputs). Try making a mesh that has it's orign at 0,0,0 but has all the verts over at, say, 5,5, 1. Like move the orign outside the mesh and see what that does.

Anyway, the point is that the vert() stage takes model/object space and converts it to something called clip-space....which is the end result of applying the model transform, moving it to world space, then transformed into view space and then splatting it into clip space. This is Model-View-Projection transformation (UNITY_MATRIX_MVP matrix all done at once, for example) but there's a macro for it that's more efficient UnityObjectToClipPos(float3 objectPos), that takes an object-space vert and gives you the homogenous clip space version.

This result will be clipped against the view frustum, rasterized in the next stage, and the pixel shader will be called for all pixels that are not clipped.

plush yarrow
#

hello

#

how can i make my vertex shader to shade sharp, and not faded?

dim yoke
#

You mean interpolation?

#

Or normals?

timid dune
#

Hello, I'm a newbie in shader.

#

I'm trying to combine two different shader

#

Can somebody help me?

plush yarrow
#

i want it to be cut

#

when i colorise faces with probuilder it colors only the faces with no interpolation

#

but these models are not probuilderized, they are skinned meshes so i can paint them only with polybrush

timid dune
amber saffron
amber saffron
plush yarrow
amber saffron
plush yarrow
#

what do you mean by hard edges?

amber saffron
#

When talking about lighting, it's when the shading is per face vs smooth.
For vertex colors it's basically the same, when you can color individually per face vs when the color of a vertex "bleeds" toward it's neighbours.

Technically, it's how the data is stored on a mesh : A vertex can only hold one information of each type (position, normal, color ...).
When you can distinguish this information from one face to the one beside it, in reality there is two vertices overlapping.

plush yarrow
#

i dont think i get it

#

this is a cube made with probuilder

#

left face is just applied color

#

right side, blue, is painted with polybrush

#

theres no double verticies

#

this is the shader im using

amber saffron
#

There is, you just don't see them.
Anyway, I don't think polybrush can actually paint faces individually

plush yarrow
#

well how can i achive the hard edge effect

#

probuilder cant color meshes that are not probuilderized

amber saffron
plush yarrow
#

and i cant probuilderize cus they are skinned meshes for animations

#

can you suggest one?

amber saffron
#

Oh wait, I'm wrong I think

#

Polybrush brush mode "Fill" is apparently what you want

plush yarrow
#

fill just fills the whole mesh?

amber saffron
amber saffron
plush yarrow
#

ohhhh

#

yes it fills faces

#

fantastic

#

thanks m8

sand vine
mild kayak
#

my UI shader isnt picking up the color of text, anyone know if UI text uses the same _Color parameter name as images? Images store that color as Vertex colors, does text?

#

my UI shader isnt picking up the color

sand vine
#

Is there a way with shader graph so that even though the mesh is transparent, you don't see the parts inside of it?

astral yew
#

Hi, I've written a simple shader to draw a 1px outline of a province map image to a custom render texture. I would like to use a second shader to then stamp an outline texture periodically along the white pixels (for example a dotted line). The problem is im not really sure if what i would like to do here is even possible using shaders, or if there is some unity feature that would do a better job. Ive attached an example of the outline map if that helps. Thanks
See here for more detail: https://forum.unity.com/threads/stamp-texture-along-outline-textur.1347770/

full zephyr
#

hello! is there a way to get the depth buffer after the (Render Objects) renderer feature? the SceneDepth node seems to just sample the camera depth texture, which doesn't have everything drawn to it in my usecase
i saw one forum post about rendering renderer's depth in the scene to a rendertexture after a render event, but that means rendering everything the second time which i would imagine to be quite slow
(crossposting from another channel, deleted the original message)

#

or not... i should try the second option first

full zephyr
#

oh nevermind, the way im setting up my Render Objects completely eliminates the camera's depthnormal pass making all the other postprocess effects that use it useless including ssao, im gonna need a better approach

rough haven
#

why does this return yellow i dont get it

#

shouldnt it be colored based on frag position

brazen locust
#

Does anyone know why I might be getting the opposite output from a sub graph ๐Ÿค”

#

Essentially if I do all this in the parent graph, I get the bottom left colored as I would expect. But if I convert it to a subgraph and then use that node I get the top right. Which I don't want

cosmic prairie
#

give it a smaller render queue than your current material

#

might work already, if not, fiddle with the ztest options

meager pelican
brazen locust
#

Ah I think you may be right @meager pelican

olive hinge
#

im following a tutorial for some custom lighting in shaders in URP and im getting this error: Shader error in 'Master': unrecognized identifier 'Light' at Assets/hlsl/CustomLighting.hlsl(13) (on d3d11)

#

custom function copied from an early step in the tutorial: ```float3 CustomLightHandling(CustomLightingData d, Light light)
{

float3 radiance = light.color;

float diffuse = saturate(dot(d.normalWS, light.direction));

float3 color = d.albedo * radiance * diffuse;

return color;

}```

olive hinge
#

do i need to include Lighting.hlsl? #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"?

kind juniper
white cypress
#

So I want to make a snow effect on the ground using a shader on the built in pipeline, something like this picture. I was thinking of using minionsart's snow shader as a base but I'm unsure how to get the snow into little chunks on a flat plane. Do I just use a heightmap? How do I generate something like that?

karmic hatch
white cypress
swift loom
#

i have a shader where i raycast through a 3D texture and grab colors on the way, but currently i am running into some issues because I'm saving them in an array, and accessing it causes the frame rate to halve.

is there some other way i could store and later iterate through the colors in the same draw call?

my current idea is to make a function that is basically a limited array, and just take an integer, and depending on the integer access a certain fixed4 variable from a list of fixed4's that i have pre-assigned, but I wanted to see if there's a better way.

amber saffron