#archived-shaders

1 messages Β· Page 210 of 1

tired canyon
#

and buildings

#

so there's no wierd overlap

cinder forge
#

the road is not raised :

tired canyon
#

the triangles are on top of the terrain

cinder forge
#

problem with stencil buffers is the fact that I could see roads through mountains

cinder forge
tired canyon
#

I'm pretty sure that the road itself is like 0.01m above the terrain

#

and then there's a bump up via the dirt

#

which touches the terrain

cinder forge
tired canyon
#

and then forms the height difference for the sidewalks

cinder forge
#

You can see the triangles of the terrain under the building, but not under the road

tired canyon
#

don't know if I believe that statement

#

you can't even see the actual end of the triangles that form the terrain

#

under the road

#

I would expect to see the actual points

#

instead the linesegments cut off

#

without showing valid triangles

cinder forge
tired canyon
#

well something you could do

#

use that same texture you have right now

#

but make it a float2

grand jolt
#

Thank you Elliot, I tried with the depth only method but still get the background. Can you please be a bit more specific? again thank you so much

tired canyon
#

and use the second channel to store ints that reference to a compute buffer

#

which would have the definition for the bezier curve

#

that defines the road

#

and then you could grab the road that overlaps that fragment

#

and figure out if you're inside it

#

or next it to it

#

with whatever precision you need

cinder forge
#

hmmm ok then I'll have to learn about computeShader, I heard it's hard

tired canyon
#

you can do that all inside normal shader

cinder forge
#

@tired canyonAlso I noticed something, here : can you spot the difference ?

tired canyon
#

you mean the difference between the geometry and what's visible?

cinder forge
#

sometimes the pavement texture on the terrain covers more than just the sidewalk πŸ€”

cinder forge
tired canyon
#

Yea

#

I assume that's a single float texture

cinder forge
cinder forge
tired canyon
#

Oh you render it

#

There's a whole slew of different texture formats

cinder forge
#

@tired canyonSo which texture format you think I should use ?

tired canyon
#

It depends on what information you need to encode in it

cinder forge
#

@tired canyonyou said "use the second channel to store ints that reference to a compute buffer"

teal breach
light epoch
#

they have the same shader and render queue, literally just wanted a different color between them

#

ive tried every render queue combination and nothing gave me what i wanted

#

i just want them to be rendered normally

tired canyon
#

But I can't code the entire thing for ya

#

I don't even know how good of an option it is

tranquil bronze
#

Is there a way of solving the problem of 'Compiler timed out. This can happen with extremely complex shaders or when the processing resources are limited.'

https://pastebin.com/i8wY1E09

I tried implementing the fast voxel traversal algorithm. It works fine on the cpu but its not compiling on a gpu pixel shader in urp?

Is it better to use a compute shader?

light epoch
#

is there a way to make generated shaders shorter?

#

seeing this on my github repository is really frustrating

#

andi ts because of the shader graphs

regal stag
light epoch
regal stag
#

Oh right, didn't see the error was a ShaderGraph. Can connect a Sampler State node (equivalent to an inline sampler) to the Sample Texture 2D node.

#

Yea

#

If those techniques reduce the number of texture samples you need to do it might still be something to look into, would make the shader more performant

#

It would likely only depend if you needed a texture / group of textures to use a different wrap or filter mode. If they can be all the same, just use the same SS for all textures.

tired canyon
#

has anyone here used groupshared memory in a compute shader before

slender ruin
#

im only doing 1

vocal thistle
#

why is this not working

#

its just showing this on the plane

#

im trying to get it to make smoke by subtracting circles with voronoi noise

digital gust
#

You understand it wrong, the noise value is just one value at a specific point, its a vector1 and therefore it will show some random white to black value @vocal thistle

vocal thistle
#

right

#

so if i turn that into a texture and output the rgba into the alpha, will it work?

digital gust
#

the voronoi depends on UVs, so if you have some texture and UVs layed out, it should work.

cosmic quail
#

anyone know how i can write a transparent color to one texture, and the depth to a separate texture?

eager folio
#

@vocal thistleIt looks like alpha is grayed out on that master node. Do you have the shader set to 'opaque'?

vocal thistle
#

hwo do i do that

eager folio
#

No, you don't want it to be opaque, but that is the default.

#

Go into the settings and change it from opaque to transparent.

#

@digital gustthe default plane and quad have UVs, so that should work fine

vocal thistle
eager folio
#

In the same place where you set node settings, there's a tab for the shader settings

vocal thistle
#

well i still dont know where that is

#

is it in the graph or what

#

oh ok

#

foundi t

#

ok thanks

#

how do i change the position of an image? like if i had a seemless texture and i jus t wanted it to constantly go right and loop again and again

eager folio
vocal thistle
#

ty

patent yoke
#

i have a shader graph that has a color and a texture that holds a color palette, how do i check which color in the color palette is closest to the initial color?

full salmon
patent yoke
#

so i made a custom function to solve my problem, here's the hlsl code

float3 closestColor = (1, 1, 1);
float colorDistance = 1;

for (int i = 0; i < Steps; i++)
{
    float3 checkColor = Palette.Load((max(i * (256/Steps) - Steps, 0), 0));
    float newDistance = distance(Color, checkColor);
    if (newDistance <= colorDistance)
    {
        colorDistance = newDistance;
        closestColor = checkColor;
    }
}

finalDistance = colorDistance;
Output = closestColor;```
#

and here is the result

#

input and output

#

color palette

cinder forge
#

Is there a way to paint the Unity terrain more accurately than this? All the scripts I have tested give me this kind of results where the outlines make "waves" πŸ€”

tired canyon
#

and rendering

cinder forge
tired canyon
#

don't think you can add geometry like that

#

and at that point I think it would be easier to just be generating your own mesh

#

terrain meshes are pretty simple to generate if they are just heightmap based

cinder forge
tired canyon
#

ohhh that's not a mesh

#

being overlapped by terrain

#

that's you just painting the terrain

#

my bad I misunderstood

cinder forge
tired canyon
#

that looks like a square brush

#

not sure what you are expecting it to do

cinder forge
molten violet
#

How can I fade a shader? When something happens, slowly increase the opacity?

#

And is there any way to create a transition between 2 shaders?

tired canyon
#

Sounds like you want to expose a property on a material

#

And then change that property

#

Via script

molten violet
#

ok, and I was thinking if you can also put a shader on top of another.

tired canyon
#

With a transition value

#

Which you use to lerp between the 2 shaders

#

And then set that transition value in script

molten violet
#

I am doing a fade with a timer and an update which is probably not the best thing. Any other way to make that?

dull notch
#

Anyone know how to achieve this kind of sketchy shadow with an outline?

amber saffron
cinder forge
molten violet
#

How do you change the values from a shader only to one object? because it is changing the material values

amber saffron
tidal harness
#

hello people does anyone ever face this problem where the texture of the leafs its getting cut to a certain distance ?

rich nimbus
desert orbit
full salmon
# grand jolt Thanks!

shout if you've got any questions, it's not tidied up enough for me to use it for work yet.

grand jolt
toxic falcon
#

strange question, I overwrite a property in a renderer with a MaterialPropertyBlock: for example the color

#

is there a way i can reference that renderer and get that overwritten color? or get the property block to be able to expose the color inside it

slim skiff
shadow locust
#

the api for it is a little weird - you pass it a MaterialPropertyBlock and it populates the block for you.

#

It's clever though - allows you to reuse the MPB to avoid garbage collection

cursive jewel
#

hi guys.. i have a wierd issue.. i am using URP, there is a specif model on which area light seems to have no effect when its in "URP/Lit" shader.. But when the shader is changed to "URP/BakedLit" it seems to work better... why this occur?

molten violet
#

Is there a way to make a shader extend past the size of the original sprite? Because mine is getting cut off

amber saffron
molten violet
#

I tried doing it but in the inner side, and it works fine except for the top part

#

it has that weird thing going on

wary horizon
#

i have a subgraph with a propertty, but i cant access it in my main graph?

#

nvm, i didnt save the subgraph haha

twilit geyser
#

Hey guys πŸ™‚ Can someone tell me what I have to do to make this builtin shader work with URP?

Shader "Unlit With Shadows" {
    Properties{
        _Color("Main Color", Color) = (1,1,1,1)
        _MainTex("Base (RGB)", 2D) = "white" {}
    }
        SubShader{
            Tags {"Queue" = "Geometry" "RenderType" = "Opaque"}

            Pass {
                Tags {"LightMode" = "ForwardBase"}
                CGPROGRAM
                    #pragma vertex vert
                    #pragma fragment frag
                    #pragma multi_compile_fwdbase

                    #include "UnityCG.cginc"
                    #include "AutoLight.cginc"

                    struct v2f
                    {
                        float4    pos            : SV_POSITION;
                        float2    uv            : TEXCOORD0;
                        LIGHTING_COORDS(1,2)
                    };

                    float4 _MainTex_ST;

                    v2f vert(appdata_tan v)
                    {
                        v2f o;

                        o.pos = UnityObjectToClipPos(v.vertex);
                        o.uv = TRANSFORM_TEX(v.texcoord, _MainTex).xy;
                        TRANSFER_VERTEX_TO_FRAGMENT(o);
                        return o;
                    }

                    sampler2D _MainTex;
                    half4 _Color;

                    fixed4 frag(v2f i) : COLOR
                    {
                        fixed atten = LIGHT_ATTENUATION(i);    // Light attenuation + shadows.                        
                        return tex2D(_MainTex, i.uv) * atten * _Color;
                    }
                ENDCG
            }
    }
        FallBack "VertexLit"
}
keen minnow
#

Hi I'm new to unity and I tried putting a toon shader I've found but now my objects don't cast shadow on others, what is the cause of that?

#

is there somewhere Ishoud look to enable it

#

or is it something I needto edit in the unlit shader graph

mild frigate
#

hey, I've got a strange bug, some of my shaders in game are using the same texture but I havent assigned it anywhere, I'm not even using it in those materials
as you can see, this is the leaf material, and the base of it is not empty, but it's using a completely random material.

regal stag
regal stag
# twilit geyser Hey guys πŸ™‚ Can someone tell me what I have to do to make this builtin shader wo...

There's quite a few differences between the built-in and URP shader code. If you just want shadows with unlit you could do that in shader graph though, same as the message above ^
(If you really need to do it in code I have some templates/examples here : https://github.com/Cyanilux/URP_ShaderCodeTemplates, would need to merge the Unlit example with the attenuation values from GetMainLight(shadowCoord) in the DiffuseLit example)

keen minnow
regal stag
#

Hmm not sure why that error is happening. Maybe try opening the Main Light Shadows subgraph and resave it.

keen minnow
#

oh ok

#

thanks it worked

#

I'm trying to figure out where I should connect it but I can't x) it's my first time on a graph shader

regal stag
#

Multiplying it with the toon colour just before you put it into the master stack Base Color port should work.
If you want ambient lighting though that might need to be added with the shadow atten before the Multiply.

keen minnow
#

Idk if I understood it right, sorry ^^ I created a add node after the main light shadow and I linked it with the Shadow atten

#

like that?

regal stag
#

What's in the B input?

keen minnow
#

the shadow atten

regal stag
#

Oh right, you already have your own Main Light function too. The ShadowAtten from that is the same as the Atten produced by the Main Light Shadows subgraph, well, it's supposed to be. The problem is that your Shadow Atten likely doesn't work as the graph requires some keywords to be added to properly handle shadows, which I do in the SubGraph to make setup easier.

You can ignore the ShadowAtten port on your node, but wherever that other connection coming out of it is going, replace it with the Atten instead. Hopefully that makes sense

keen minnow
#

i'm lost ahahah

regal stag
#

Yeah that's what I was referring to, use the Atten output to replace the B input on that Multiply

keen minnow
#

im' getting this

regal stag
#

Hmm, oh if you have your own lighting custom function they might be using the same keyword to prevent the file being included multiple times

keen minnow
#

yea I have a lighting custom function I copied somewhere else

#

do I replace the one I did with the new?

regal stag
#

Yeah, at the top of mine it uses

#ifndef CUSTOM_LIGHTING_INCLUDED
#define CUSTOM_LIGHTING_INCLUDED

You could change those both (in mine, or your hlsl file) to prevent them conflicting

#

Or alternatively, replace your Main Light custom function with the Main Light subgraph I provide

keen minnow
#

I'll try

#

I replaced mine does the name need to be something specific?

regal stag
#

I meant replace the entire Custom Function node. I use subgraphs for them all to make it easier to use (can add them from the Add Node menu, it's named Main Light).
But otherwise I think it just needs to be float precision and remove the ShadowAtten output.

keen minnow
#

ok I think it worked

#

i'm checking

#

Yas I got shadows now thanks !

keen minnow
#

I've put your additional light to my shader but it's not toon how did you toon yours ?

regal stag
keen minnow
#

ok I renamed it to mach the toon version

keen minnow
#

it's not the rimlight I desactivated it it did nothing

#

I multiplied it with an ambiant node

#

not exactly it

remote wigeon
#

well it's not quite a shader, but it seems like the problem is in the shader. I was wondering if I was doing something wrong when applying a render texture. I'd like to project what one camera is seeing onto a plane

wraith inlet
remote wigeon
#

honestly probably not, I'll take a look in a second..

remote wigeon
#

this is what I see

wraith inlet
#

Base map

remote wigeon
#

ok! I've got something showing up now

#

it's a bit washed out, but I'm getting there

wraith inlet
#

Set the color in base map to white

#

It's tinting everything gray right now

remote wigeon
#

ok, I set that

#

and it looks like it's there! thank you so much!

violet sage
#

Any way i can have a custom black white texture as a gradient for vertex position in shader graph?

slate compass
#

can someone help me out with my URP project..

#

this is scene view.. and the Foam.. Depth thingy works fine in editor..

#

i cant get it to work in my scene view tho..

#

i checked the urp asset and depth textures are checked on.. so idk 😦

#

game view \/

copper thorn
#

hey there guys, as soon as i turn a parameter in shadergraph to non-exposed, it seems to have the value 0 instead its default which is 1.
I also cant seem to modify it in code. What am i doing wrong?

shadow locust
#

also make sure you're using the reference, not the name to access it in code.

mighty tendon
#

Hey guys, im trying to get the world position of a fragment in a shader but from what im reading im sure im doing something wrong, could someone point me to the right direction?

essentially this is the part im struggling with

            struct MeshData
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct Interpolators
            {
                float4 vertex : SV_POSITION;
                float3 worldPos : TEXCOORD0;
            };

            Interpolators vert(MeshData v)
            {
                Interpolators o;
                o.worldPos = mul(unity_ObjectToWorld, v.vertex);
                o.vertex = UnityObjectToClipPos(v.vertex);
                return o;
            }

this is the full code btw:
https://hatebin.com/brjurvzjzi

brittle owl
#

that affects depth

slate compass
#

@brittle owl i fixed it.. I had already checked 100 times that the depth texture was ticked in the URP Renderer Asset but it turned out the wrong one was plugged into the renderer list πŸ€¦β€β™‚οΈ .. thanks for the tip tho πŸ‘

brittle owl
#

lol no problem

compact wadi
#

is it not possible to do a 2d subtract shader in unity? Can't find anything online. Does it go by another term?

grand jolt
#

Hello2 All,

I' m currently modfying the Viking Asset pack to fit a bit with my game.
However I'm stuck at blending the materials like this;

#

I hope my explanation is clear enough..πŸ˜‹
Do how do i achieve this blending material in Unity (URP Renderer).. ?

#

If possible i wanna do it without importing any extra asset...

noble olive
#

Hello guys, I have a .. question? May I refer to #archived-hdrp because I’m not sure which channel to use. Maybe someone has an Idea! Essentially it’s about 2D β€žshadowsβ€œ and merging them from multiple sprites, then rendering them with an alpha value. It probably needs to be merged to prevent shadow stacking via alpha values.

proud wharf
#

I dont know if it has any thing to do with code but i opened my unity project and all of black materials look green ish
Any fixxes?

oak ingot
#

is there a way to get the vertexcolor as 4 bytes? I tried setting mesh.colors32 but the vertexcolor node still outputs 4 floats

meager pelican
#

In shaders it's going to be a float of some size.
But you can multiply that by 255 and then cast the result to a uint if you want to.

#

And if you're doing 3 or 4 channels, you can vectorize the operation. But it's going to be awkward to work with as an int.

#

One reason might be for performing bitwise operations.

#

And you can't do this in the vertex shader (pretty sure) for interpolaed output since you can't interpolate uints (they must be "flat"). So you'll probably end up doing the math in the frag(). Grain of salt on that.

oak ingot
#

I was planning on doing bitwise operations.
I saw an approach to texture blending where 1, 0, 0 is one texture 0, 1, 0 is another, etc
I wanted to use something like 4 or 8 bits for a color instead of 32, to allow for more possible materials

#

that seemed like one of the most viable ways to blend more materials by vertex color

thin girder
#

hi, quick beginner question. I know that PBR Master node was changed into something another but I cant find which node I should use instead of this?

thin girder
#

Lit Shader Graph?

shadow locust
#

yes

thin girder
#

Thank you

thin girder
#

okey next question, why whole material is moving towards camera?

grand jolt
#

Hey hi, I still have a problem with a shader I made a while ago. Its a wind shader that moves vertices with noise over time. I'm using it in a 2d project with moving parallax layers. I move the vertices with object position. The problem is that when using 2 objects with the same texture, the strength of the effect gets doubled when moving the objects around. Having them stationary, no problems, but when moving 2 or more objects with the same texture the effect seams to multiply between the different objects. why is this?

#

watch the mushrooms<
2 different textures (looking fine)

#

But using the same texture on both mushrooms multiplies the wind effect! Why?!

teal breach
lone stream
#

Is there a way to fetch TAA_jitter value in shadergraph?

lone stream
#

trying to create dithered temporal alpha

meager pelican
# oak ingot I was planning on doing bitwise operations. I saw an approach to texture blendin...

Yeah, OK, and assuming that all 3 verts have the same value for the polygon in question, you can pull it off in the vert(), pass a flat uint value to the frag, and save calcs inside the frag(). You just can't interpolate differing values of your bits, so sharing verts in the mesh would be a problem. If you need to interpolate, you'll end up doing the conversion in the frag. Or perhaps figure out the barycentrics (gasp, wink).
Again, I think. I know that you cannot interpolate uints from what I've read. And I know that some native texture values are uints, some even 16 bits per channel.
https://docs.unity3d.com/ScriptReference/TextureFormat.html
I guess the question for your use-case is how to best pull all that off with color lookups for bit-packed fields.
The article below indicates that in HLSL, using SM4.0/DX10, bit-fields are somehow directly accessed and binary operations are fully supported. I'm not sure, frankly, how to declare that in Unity such that you can get a uint directly out of the tex2D() without having to screw around with floating point crap but I haven't tried it....the old Nvidia article (also below) indicates that tex2D can return a uint. IIUC, in DX9, if you have to support that, you're still stuck with floating point and possibly work-arounds.
See about the middle of the page here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-common-core for DX10/SM 4.0.
and here https://developer.download.nvidia.com/cg/tex2D.html for tex2D return types.
So it all depends on your target platforms, and your vert color storage. From what I read.
(I was curious too. πŸ™‚ )

#

I suppose another thing you can do is just store an index as a float, hell, even half floats store a reasonable number of whole-numbers (See that last link above, "Medium precision floating point value; generally 16 bits (range of –60000 to +60000, with about 3 decimal digits of precision)". IDK how that works out for your blending when using 4 color channels, but maybe you can get some clever maths in there.

surreal coral
#

i am using a water shader that is a little wavy on a plane. When i try to connect 2 planes i can see the sea floor and if i put the 2 planes in each other the colour of the water darkens. Any ideas?

devout quarry
#

@surreal coral what do you mean you can see the floor? The waves don't line up?

surreal coral
#

no they dont connect if they are on a different object

devout quarry
#

If you do the waves and foam and stuff in world space instead of object space, it will line up nicely

surreal coral
#

how do i do that?

devout quarry
#

Look up 'world space UV' online, you'll get useful results

surreal coral
#

ok thx

#

i had another idea

#

i could just scal the whole plane except for the heit

#

scale

#

hey now im looking for an easy to use toon shader for free any suggestions

#

?

#

@devout quarry hey now im looking for an easy to use toon shader for free any suggestions?

#

cancel that

brittle owl
#

try disabling it and see if it fixes it

devout quarry
oak ingot
#

I'm thinking a simple approach would be to make a different version of the unity vertex color node

  • read data at each vertex (first 16 bits to an int corresponding to id)
  • output up to 3 ids (ids of the three verts at any given pixel) and their weights
    pass that data to a function that samples a texture2darray at index of the ids passed, and blends them according to weight
#

im not very familiar with shader coding or the pipeline so im not sure if this is a good way to deal with it

proud wharf
brittle owl
#

oh weird

#

oh wait nvm it makes sense sorta

wooden laurel
#

Hi guys, I have this outline shader on my characters.
For some reason it keeps rendering through everything. Im doing this in HDRP custom passes.
I tried changing the renderq but nothing happens. Any ideas on what to change?

#

Im kinda noobish to custom passes so any tips would be appreciated

wooden laurel
#

Tested all kind of z test values and renderq values, nothing seem to work. Made sure im sorting by renderq aswell.

#

Feels like im missing something simple

teal breach
#

Anyone encountered an error like ArgumentException: JSON parse error: The document root must not follow by other values. when opening shadergraphs in 2019 LTS?

teal breach
#

currently, it seems that is not possible

meager pelican
swift yoke
#

let's say I wanted to make a shader that fades something in, and then that something just chills there and does nothing...
Would I just make 2 shaders, one that fades it in and then swap to the second one that does nothing or would I keep it all as one shader?
My fear with the one shader thing being, that you would then need some bool or something called isDoneFading and once it's done you set it true, and then it no longer fades, but now it's running if(IsDoneFading) every time which seems wasteful

modest spoke
devout quarry
teal breach
#

You can use the frame debugger to see what is being drawn during your custom pass, and verify if that is the case

devout quarry
#

Yeah you need to add ZWrite On to the shader that you use on the objects that draw outlines

#

And then in your outline pass, use β€˜CompareFunction.LessEqual’ to test for depth (this is how I do it in URP, probably similar in HDRP)

wooden laurel
#

Tyty, will try all the things later today, will update u on how it goes

#

And I know the effect is desired but in a scene with many objects carrying outlines it will start to look weird

#

When they phase through each other

swift yoke
#

real quick question - Can you call a method that's inside a shader, from outside the shader (so calling a GPU method from the CPU basically)

wooden laurel
#

You can

swift yoke
#

do you know what it's called so I can google it?

wooden laurel
#

You cant call methods directly from gpu on cpu. You can dance arouns it by storing values that u can later manipulate on the other. I think material values can be found in "material.SetX". So the answer is really no but maybe if u really want to

#

Depends on what exactly u wanna do

swift yoke
#

yeah okay that's what I thought you had to do

#

so i'll just index the methods and have a methodIndex int or something

#

which I don't mind, just double checking there isn't some crazy easy way

vocal thistle
#

i have a problem. i have impact vfx that i want to be able to see but should also appear where the player punches. the player usually punches inside the enemy though so i made the enemy have a transparent shader. this makes the viewer able to see the vfx but they can also see for example the right arm if they are looking at the left arm from a side on view. does anyone know how to only apply the transparency for another gameobject so you can see through the gameobject to another but not see through that gameobject to itself?

teal breach
#

You probably want to keep the enemy using an opaque shader and instead change the impact vfx. You could try changing the draw order of the decal to after the characters are drawn, and disable depth testing for that vfx (for simple cases).

devout quarry
vocal thistle
vocal thistle
#

also i kept saying vfx but i meant particle system

teal breach
#

transparency and depth testing are different things

brisk chasm
#

Hi i have a grass shader that i am applying to a procedural terrain. i want the grass to only be rendered above a certain height. How would i go about this?

wooden laurel
#

Or heightmaps

#

As I understand u wanna assign different textures on different heights on the same object.

brisk chasm
#

Yes but I have 2 materials. One for the vertex colours and one for the grass

#

How do I lerp between those

lavish oasis
#

Any nice free shaders for water for URP out there?

tired bronze
#

I guess a baseline would be Unity's BoatAttack demo

wooden laurel
wooden laurel
#

(Not mine)

#

Its highly customizable

lavish oasis
lavish oasis
devout quarry
#

@lavish oasis yeah it's stylized but you can make it more realistic, like this

#

But realism definitely was not the goal

lavish oasis
#

Ah tbh i dont want HDRP realism; just "good enough"

#

If i can get it to something like warcraft's water it would be pretty nice- quite like that kind of water style

lavish oasis
#

kind of overwhelming

#

i love that it has buoyancy script

ornate skiff
#

how do i get URP shader graph shader to respect the clipping planes of the camera? it draws the objects using the custom shader outside the clipping planes by default

full salmon
#

Does anyone know why I might be getting this weird artifact in my skybox shader when the texture meets itself?

#

It stays there without changing at all, whatever I set the tiling X to. It's not there in the texture.

ornate skiff
#

try changing the wrap mode on your image in the inspector

full salmon
#

hmm, that didn't help. It was a 16000-pixel-wide texture so I knocked it down to 1600 but still no good. The lines move as you tilt the camera up and down.

#

Ok, I turned off "generate mip maps" for the texture and that seems to have fixed it!

full salmon
#

This isn't gonna work right? I need the R, G and B from my color but the A from somewhere else?

junior iris
full salmon
#

Yeah, just thought it might be nice but actually it would be weird behaviour

vocal thistle
#

how do i turn depth testing off?

wooden laurel
#

ZTest Always

#

Is what u write in the shader

#

@vocal thistle

vocal thistle
#

ok

#

but wher

#

i saw that in a unity doc

#

but i dont know where to put it cuz i think there are 2 sub shader{} and a bunch of pass{}

wooden laurel
#

Hard to tell, depends what u wanna do

#

Usually done before a pass or inside a pass

#

Try around

vocal thistle
#

-_-

#

i did

#

none of it works

vocal thistle
wooden laurel
#

What pipeline are u using

#

If the standard ones try setting it to always, and play around with renderqueue values

#

You want to make sure your shader is always rendered on top of any geometry

vocal thistle
#

urp

vocal thistle
#

i was looking at taht one

wooden laurel
#

Yeah, it might be that it works but renderq value is 2 low

#

Relative to other geometries

#

Try changing the q value

vocal thistle
#

how

wooden laurel
#

Tags {β€œQueue” = β€œGeometry”}

#

Write this

#

Somewhere

#

Geometry tag means renderq value of 2000

#

Then change it around like
Tags {β€œQueue” = β€œGeometry+100}

#

And see if something changes

#

Try different values

#

In the link i linked u can see different tags u can use instead of geometry

#

Gotta go now good luck

vocal thistle
#

ok thanks bye

grand jolt
#

hi, how can i make transition between two keys(colors) with a gradient in shader/vfx graph

devout quarry
#

@grand jolt what exactly do you mean? A lerp?

grand jolt
#

^no just the gradient node. i dont get it. if i create a new gradient, then the transitions are made, but if i take an existing one, theres no transition when i add a key(color)

devout quarry
#

I don't understand haha you can add a gradient and then you can click on it and in the little editor you can add/move up to 8 colors right?

grand jolt
#

for example:

grand jolt
devout quarry
#

@grand jolt click on the yellow color and lower the intensity

#

Then it will be more gradual

grand jolt
#

@devout quarry yeah that does it, thnks for the help!

trail geyser
#

does anyone here knows a way to convert "Amplify Shader Editor" shader to "shader graph" shader?

#

or any shader to "shader graph"..?

devout quarry
#

@trail geyser convert it node by node manually

oak ingot
#

as far as I understand the data of a fragment is the result, is there a way to define custom data at each vertex and custom interpolation?

#

like an int or a custom struct or smtng

#

or is there a way to access the data of each individual vertex that a fragments data is from and write a custom method to determine the dragments data based on those vertices?

trail geyser
#

well I already know we can manually do that and custom function nodes and the internet says such conversion cannot be done
but idk.. imo if anything can be encrypted it can also be decrypted right? I kinda want to prove them wrong πŸ˜…

wooden laurel
#

question, can u disable a custom pass effect through code

#

i cant find any documentation

#

how can i access the enabled box there

oak ingot
#

I had read a bit about encoding data into a float but once interpolated wouldnt the data just be garbage?

trail geyser
#

I used it as a metaphor.. when you use shader graph, it just creates a "regular" shader file so why can't we convert it back

shadow locust
mossy viper
#

unblend a smoothie

trail geyser
#

ayt

mossy viper
#

actually Grant Sanderson has a nice video about the fourier transform, where he makes this analogy.
In a way, that's what the algorithm does

trail geyser
#

well this is also how shader graph works itself whenever you open a compatible file
that could be a good idea for an asset πŸ™‚

mossy viper
#

Really? I mean, can you open a regular shader, and it will backwards engineer it to build the graph?

trail geyser
#

no

mossy viper
#

I mean, I've seen the shadergraph files, and those seem to just hold the concrete data for the graph

#

What'd you mean then? about how the shader graph works itself

trail geyser
#

just that it takes a file with some data and knows what to show in the editor lol
so why can't we take a shader and create this json like(?) block of data

mossy viper
#

oh lol, I just noticed that your conversation here was exactly about how that's not possible

trail geyser
#

it'll require a really fancy algorithm tho πŸ˜…

mossy viper
#

I guess... It's just that regular shaders aren't necessarily build in this functional style, where you just have a pipeline of operations that feed into each other

#

I imagine a lot of it is not directly translatable

trail geyser
#

yea I also think its too complicated.. but maybe with a very small and basic it can be done

mossy viper
#

Anyway, if I'm providing an instanced shader with uv data from a compute buffer, how would I do that for different sides of a cube?
would I just have 6 uvs per instance, and use the vertex position to map them in the shader?

#

Sorry if this is a stupid question, this is kinda new territory for me...

#

like what I'm doing now is just provide a uv offset, and add that to the uv in the shader. but this obviously draws the same texture on all 6 sides of the cube

trail geyser
#

lol it's kinda new to me too.. that's why I asked here πŸ™‚ because I don't know that much about shaders..
I have a "Amplify Shader Editor" shader file that I thought maybe there's a way to convert it from one "editor system" to another because I'm too lazy to do that manually πŸ˜…

meager pelican
#

Maybe research "unity procedural geometry" and "draw procedural" with the variants. There's tons of ways to generate geometry and associated data like UV's. But there's no one-way.

#

For a cube, you have 24 verts, each with data. Color, UV's, position, whatever.

#

@mossy viper

mossy viper
# meager pelican Maybe research "unity procedural geometry" and "draw procedural" with the varian...

Right. I have this voxel renderer, and what I did before was generate meshes procedurally, and I would just do the uvs for each quad based on face normal, and add them to the mesh.
I'm trying to achieve the same using indirect instancing, but I can't really wrap my head around how to map the uvs from the buffer. Like, i suppose I could pass it uv data for all 24 vertices, but I'm still not sure how I would map those.
I guess my problem is that data is retrieved per instance, but has to be applied per vertex.

What I'm trying now is passing 6 UV offsets per instance, and somehow use the vertex normals to figure out which of the 6 offsets each vertex should use

#

Like for any face with uvs (0,0) to (1,1) the actual uv should be offset+uv*tilesize

#

God I'm so terrible at explaining this...

#

I guess what I'm asking is, for any given vertex, how to i figure out which side it belongs to so I can map it to one of the 6 uv offsets?

meager pelican
# mossy viper I guess what I'm asking is, for any given vertex, how to i figure out which side...

There's an instance ID and a vertex ID that you can grab. Somehow. I haven't done it in a while but you can find examples on the net and IIRC in the unity docs.
Like SV_VertexID or something.
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics

#

I wouldn't do maths in the shader that you can pre-calc once in the mesh, so I'm not sure why you need to store offsets since if you can store that you can store the actual value? But IDK, whatever blows your hair back works for me. πŸ™‚

mossy viper
#

well it is the actual value. just only for the lower left corner of each quad. idk... just figured that it'd be better to pass 6 coordinates per instance rather than 24. But I don't know, it might be better to just pass it a huge-ass buffer and apply using the vertexId. Again, I'm not very experienced with shaders
And I'm not really doing anything "once in the mesh" since I'm sort of bound to a single mesh. I don't think I understand what you're suggesting the alternative is?

sudden mountain
#

is there a way for me to make my shader only render in the scene view without the use of an external script? similar to the source engine tool textures.

#

using the UNITY_EDITOR directive does not seem to work

meager pelican
#

It's a lot to work through in a discord chat.

#

But what you end up getting is an instanceID and for each instance, you get counts through the vertexID for your mesh. That's passed to you by the runtime.
What you do what that information, and how you crank it, is up to you.

meager pelican
sudden mountain
#

I intend to use it for stuff that only needs to be seen in the editor, such as triggers and things that need to obstruct light but not be visible in the game. While I know that UNITY_EDITOR is a C# directive, I gave it shot anyways. is there an equivalent or a method to know in the shader if the rendering is happening in the scene view or not?

meager pelican
#

Not that I know of, but why?
The shader is rendering the triangles/verts. So if you want something in the editor-side to look different, try something like OnGUI and call your own shader on the object to RE-render over top of it or something.

Like...I had some stuff that I render only in the edtior but it's with a game object and OnGUI type of thing. A place holder so I could see where a ray tracer would render a procedural item in pay mode.
https://docs.unity3d.com/Manual/GUIScriptingGuide.html

sour ivy
#

hello guys, I wanted to ask about something ... So I got an idea of making a player invisible by setting the transparent to zero and the rendering mode to Fade it's working but the problem is that the shadow is not showing anymore because he is invisible, So what if I wanted to make him invisible while his shadow is showing at the same time? How to do it?

lone stream
#

How can i get _screenParams in shadergraph?

#

ah nvm got it

vocal thistle
#

how do i turn depth testing off

keen minnow
#

Hello I can't figure out how to make secondary lights cast shadows in my toon shader, is there a way to do that?

#

currently my secondary light doesn't stop when object are in the way

#

idk how to solve that

digital gust
keen minnow
#

yep

digital gust
#

There are some tutorials, even old ones and not super good, but should get you get started on youtube about that sphere effect.

#

Let's learn how to make an awesome force field with Unity Shader Graph!

● Check out Skillshare! http://skl.sh/brackeys15

● Support us on Patreon: https://www.patreon.com/brackeys

● Project Files: https://github.com/Brackeys/Force-Field
● Water Shader shown in intro: https://youtu.be/jBmBb-je4Lg

● Setting up Lightweight: https://bit.ly/2W0AY...

β–Ά Play video
keen minnow
#

okay thanks

#

but wait I did this tutorial for the bubble in the middle, but the blue circle around it is the light area

#

it's a point light

digital gust
#

Oh, but its a volumetric point light, right?

keen minnow
#

I've put the point light in the bubble

#

volumetric?

digital gust
#

okay, no forget volumetric, I was guessing. So, can you show only the light without shader?

keen minnow
#

like that

#

I had to bump up the intensity otherwise it wasnt showing

digital gust
#

And if you set the light next to a wall, it goes through?

sour ivy
keen minnow
#

it looks good without my toon shader

digital gust
digital gust
keen minnow
#

Nope

digital gust
#

Then it will go through

keen minnow
#

like that

#

with the toon shadr

digital gust
#

you need your shader to recieve shadows and your light to cast one, otherwise it wont know where to have light and where not

keen minnow
#

I didn't found how to have my shader receive shadows from secondary light

#

and my light

digital gust
#

I guess you cant use point lights here to use shadows...

keen minnow
#

yea, so idk what to do

digital gust
#

Use a spotlight for example

#

It sucks unity does not support shadows for pointlight still... but thats what Unity gives us

keen minnow
#

not supported either

digital gust
#

oh boy...

#

So close to switch to Unreal sometimes πŸ˜„

keen minnow
#

x)

regal stag
keen minnow
#

oh okay

digital gust
keen minnow
#

is it easy change version for a project

sour ivy
# digital gust MeshRenderer->Cast Shadows->Shadows Only

thanks man, its working! but what if i wanted to be able to make him visible a bit like he is invisible and his shadows is showing but something whatever it is happened to him and caused him to be visible but not visible very much i mean little bit of visibility like he is fading you know what i am saying?

digital gust
regal stag
digital gust
sour ivy
digital gust
#

Yep

regal stag
# keen minnow is it easy change version for a project

Usually, though it depends if you're using other assets and stuff. It's always a good idea to have a backup just in case the update goes wrong. You just need to install the newer Unity version (e.g. from Unity Hub) and open the project using the newer one. Then can check the Package Manager to make sure URP is also updated (might do it automatically)

keen minnow
#

to backup I just have to copy & paste the whole folder somewhere right ?

digital gust
#

Or use something like github

keen minnow
#

I'm gonna try to update then πŸ™‚

keen minnow
#

So I did the update and launched the project, it put me in safe mode and these are the errors

#

are these important ?

digital gust
keen minnow
#

i'll try to search how to do that

#

it worked

#

noice

#

now I got shadows yey

#

now if i want the shader to have like differents intensity based on how far we are from the point light, is it done with a ramp texture?

crystal ocean
#

mostly, I'm looking to create a slight color offset and a semi-faded/dusty look to the imagery.

digital gust
#

I guess a simple shader that adds that affect might work or better use post processing maybe

crystal ocean
#

how would you create a shader that adds that effect, or post-processing for that matter?

#

sorry I should've prefaced that I'm still trying to wrap my head around how I'd translate this into shader graph from something like Blender

digital gust
#

Really depends, using a shader like this for every material might be a performance hit, you gotta test it. How to use postprocessing, you should look into some tutorials first and come back when you tried something πŸ™‚ at least I got no time to test it out for you, sorry. maybe someone else already tried that

crystal ocean
#

Cool, thanks! I'll try to go look at some post-processing tutorials... any good recommendations for getting started?

#

I was using a really cheap method of doing this using an overlaid plane with a rendered out orthographic image, that that would be really time consuming to recreate across all my models and might be really inconsistent since I have to place them entirely by hand.

simple rivet
#

if I wanted to make a shader that effected a heightmap, like say an erosion system that treats raindrops as particles that fall and change the height in my texture...
A. is that possible
B. where should i start exactly?
could it be done in a compute shader? or should i use a particle shader, I'm not too strong at shaders but just a point in the right direction and I can figure it out

covert dawn
#

@simple rivet I saw this done recently, here https://youtu.be/eaXk97ujbPQ

In this coding adventure I attempt to implement a simulation of hydraulic erosion to make a procedural terrain look more natural.

If you're enjoying these videos and would like to support me in creating more of them, I have a patreon page here: https://www.patreon.com/SebastianLague

Interactive demo: https://sebastian.itch.io/hydraulic-erosion...

β–Ά Play video
simple rivet
#

new question, in hlsl can you call a function inside of a struct?

grand jolt
#

Can anybody help me with shader striping?

#

Currently creating a build takes over an hour with all the shader variants included(which is not needed)

#

I have a shader variant file containing the required shader on a per scene basis (which is really small compared to what's ending up in the build)

#

Is there a way to strip all the other shaders?

crystal ocean
#

following up (in a way) with my above questions, does anyone have a good resource/tutorial for learning how to write custom HDRP post-processing?

low lichen
gray elm
#

Good idea to always check the documentation first!

crystal ocean
#

Thanks @gray elm I did check the documentation, but this doesn't walk through writing your own Custom Full Screen Passes, it just shows how to create an already existing effect...

#

Is the Shader Code the same here as it would be for HDRP?

gray elm
crystal ocean
#

ah ok, yeah this is helpful, thanks!

gray elm
#

no problem

#

When you search for the documentation on google, for some reason it always shows the HDRP 6.9.2 documentation. Make sure to change it to the latest version otherwise you'll miss stuff.

crystal ocean
#

Yeah thanks... however, when I'm trying to just walk through this initial tutorial, I'm getting an error that my property isn't being recognized

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

When using the High Definition Render Pipeline (HDRP) we can use a custom pass to change materials on scene geometry, change the draw order in which objects being are rendered, and read camera buffers to use in our shaders. In this video, we'll take a look at how we can build a Custom Pass in Unity and use it to manipulate our scene.

πŸ‘‡ Learn mo...

β–Ά Play video
brittle owl
#

there are some render features you can find online that make it really easy

#

search up blit render feature urp

crystal ocean
#

Blit doesn't work with HDRP... I was using that before, and I might go back to it since I'm getting an error trying to use HDRP, but the post-processing stack for HDRP isn't compatible or overrides the blit info... I think...?

brittle owl
#

oh whoops wasn’t aware you were using hdrp

devout quarry
brittle owl
#

oops i was too late

crystal ocean
#

oh thanks, this is helpful

#

thanks to both @devout quarry and @brittle owl

#

Though I'm seeing that I can maybe accomplish the effect that I'm going for using HDRP if I was able to get the basic scripting to respond the way it's written... feel like I'm missing something essential and not seeing it right away

nimble perch
#

does any one have an idea on how they made these clouds in sky ?

brittle owl
#

just looks like meshes and textures to me

nimble perch
#

yea but they look so soft... also there moving so i guess theyre using some sort of displacement

brittle owl
#

i think the softness is just the normal map, i don’t see any transparency

#

maybe subsurface scattering?

nimble perch
#

that could be the case but its running on switch and i doubt that the switch has the grafics power for sss

brittle owl
#

well it can be faked

nimble perch
#

maybe with custom normals

brittle owl
#

(also runs on mobile it’s very impressive)

#

Making a Subsurface Scattering Foliage Shader in Unity, without using Raytracing.

You can read a more detailed write-up of this approach here:
https://www.patreon.com/posts/subsurface-write-20905461

If you'd like access to the source files (shaders and Unity Project) that you can freely use in your own games, please consider supporting me on P...

β–Ά Play video
nimble perch
#

so this is a test with custom normals

#

not optimal but i think thats the way to go...

I will try sss at some point tho

brittle owl
#

not only a normal map, you should also try an albedo texture

#

but i think sss is the way to go

crystal ocean
#

Does the Custom Pass Volume not work with Custom Shaders? I don't understand why when I try to use the filter and designate specific layers it still renders the entirety of the camera view... (and no I'm not using a FullScreen Pass)

brittle owl
#

are the new urp 12 features exclusive to the unity beta version?

#

for some reason all my graphs are broken after updating to urp 12 and the newest unity beta

#

shadergraph is installed in package manager

#

wait what?

#

i cant create graphs

devout quarry
#

@brittle owl I had the same thing once :/ did not find a fix then

brittle owl
devout quarry
#

Oh haha that's good

keen minnow
#

Hello I have a toon Shader and I want to use the Paint texture tool on my terrain but nothing happen, it is possible ?

nimble perch
#

Its me again...

Which shader do I use for materials for the trail renderer in hdrp ? At the moment Im just using the unlit shader but it doesnt copy the colors I set in the trail renderer.

latent crypt
#

Using this image as an example. I am very new to shaders and am struggling to figure out how to do this. But, is there a way to make the overlapping transparent shaders not overlap like that and become darker? Instead its always the same shade?

My project is in Unity 2020, using the URP. Everytime I think I find the solution, its for a non urp object

meager pelican
#

You'll just set the stencil value where the squares are, and then in another pass (maybe post processing) you can do whatever you want where the stencil is set.

latent crypt
#

Thanks appreciated, will look this up!

crystal ocean
#

If there's anyone @here who might be able to sit down with me to chat about this issue I'm having trying to get HDRP to recognize my layers and prevent things from completely melting my CPU, I'd really appreciate it.

grand jolt
crystal ocean
#

So should I just try to return back to something more simple like the Blit method described above?

grand jolt
#

you can use the frame debugger, profiler and log files to find out whats wasting resources

crystal ocean
#

I think part of the problem is that I was trying to use custom shaders as the base and the override for the custom pass, which when I substituted out helped performance considerably.

However, now I'm getting this strange z-fighting issue when I'm using the Custom Pass Volume:

#

(I want the red to override the white texture)

brittle owl
#

it actually looks kinda cool lol

crystal ocean
#

Indeed, but not my desired visual design...

meager pelican
#

Are you overlaying materials?

#

Of course, ideally, you'd draw it once, red (or whatever color should be in a pixel) the first time. Once.

crystal ocean
#

But doesn't the Custom Pass Volume override existing materials? I'm following this example:
https://www.youtube.com/watch?v=vBqSSXjQvCo&ab_channel=Unity

When using the High Definition Render Pipeline (HDRP) we can use a custom pass to change materials on scene geometry, change the draw order in which objects being are rendered, and read camera buffers to use in our shaders. In this video, we'll take a look at how we can build a Custom Pass in Unity and use it to manipulate our scene.

πŸ‘‡ Learn mo...

β–Ά Play video
brittle owl
#

hey weird question, how would i fake normal maps in an unlit graph?

#

dont really wanna use lit

crystal ocean
#

"We can use a custom pass to change materials in our scene" is a direct quote from the above demo

vernal glen
#

Man, shaders are still pretty much beyond my capablities 😦 Spent a couple hours on trying to make a snow trail displacement effect for a snowboarding game...

#

Just not predictable at all on what's happening. Sometimes the camera doesn't pick it up at all, other times it does, but way off point of where the cube is, etc.

brittle owl
#

is there any way to get semi realistic reflections on urp for free? planar reflections, box projection, ssr, etc?

#

i’ve been looking at github repos but most are outdated

deep mason
#

What would be the best way to apply the same shader effect to all children in a UI image object?
Say I have a "burn up" shader, just applying that to all children makes them all dissintegrate differently since they are all different size. Any way to make them all match?

vocal thistle
#

how do i turn depth testing off

lime smelt
#

Hey folks, I'm encountering a very puzzling situation with Shader Graph.

#

I have a shader graph like this:

#

From every sources online that I can verify, this is what you have to set up to replicate a basic PBR pass.

#

(Pay no attention to the Dissolve, EdgeWidth and EdgeColor properties for the purpose of this question)

#

I first created a Universal Render Pipeline/Lit material without assigning ambient occlusion as a reference (because my shader doesn't take in an AO texture either), and the result looks like this:

#

Then I created a material using my shader above, assigned all the same Albedo, Normal and Metallic textures, then swapped into the same mesh, and this is how it looks:

#

What am I doing wrong here?

vocal narwhal
#

is your normal map input marked as a normal?

lime smelt
#

I'm using Unity 2019.4.28f, VFX Graph 7.6.0

vocal narwhal
lime smelt
#

it appears so.

vocal narwhal
#

the type on the sampler needs to be set appropriately

lime smelt
#

Oh, this fixed the issue with that model, but created an issue for another model.

#

This is what happens when my shader doesn't have a metallic texture.

#

The reference material looks like it can render to this without a metallic texture.

vocal narwhal
#

set the default to black instead of white.

lime smelt
#

Is it the Default or the Mode?

vocal narwhal
#

mode

lime smelt
#

Okay, looks good now.

#

Thank you very much.

solemn pivot
#

any good reference to port Cg language to shadergraph?

#

I try to port this shader:

#

but get this weird result:

amber saffron
#

There is not real reference here, take the code and redo the same logic with nodes.

solemn pivot
#

monakS I did, and it result like above

#

and I don't know what I did wrong

amber saffron
#

Obviously, if the result is not the same, it means that the calculation is different and something is wrong.
Now it's up to you to figure that out.

lime smelt
#

Hey, I have a question about Shader node's precision inheritance.

#

I have 2 nodes set up like this.

#

So the inheritance rule says the output of a node is the max precision of all input nodes, but when the input nodes are manual input like this, what precision will they have?

restive radish
#

I have a sprite sheet to run in a shader. Basically I'm doing this:
half spriteSize = 8.0; half vel = 80.0; half2 animTex = input.texcoord * 1.0 / half2(spriteSize, 1.0); animTex.x += floor(fmod(_Time.x * vel, spriteSize)) / spriteSize; vertData.uv = animTex;

#

in the vertex shader

#

however, it's cutting the two last sprites

#

can someone check if my maths is correct?

#

it's an image with 8 sprites

wooden laurel
restive radish
#

yes

#

to help understanding, vel 80 means one frame every 0.1s;

#

that's what the fmod goes for

#

fmod makes sure it cycles through the sprites and floor makes sure it goes one by one instead of just sliding

#

the shader is for the grass, just to make it clear

wooden laurel
restive radish
#

actually, just the normal texture

wooden laurel
#

i cant see what would be incorrect in your code

#

should work

#

i think

restive radish
#

can use this without shadergraph?

wooden laurel
#

nah

restive radish
#

I can't use shader graph, too complex

#

I'll see what I can do then

#

thanks for the tips

amber saffron
#

The math seems correct to me πŸ€”

restive radish
#

I seriously don't know why it's wrong

#

texture is this one

#

it's a proper texture

amber saffron
#

I'd recommand that you try debugging it on a simpler object (a quad), and try to output readable values

restive radish
#

hmm

#

I'm using the detail grass from urp

#

custom version, obviously

amber saffron
restive radish
#

because I'm editing the terrain detail from urp, so I'm just changing the color and uv, as well as removing waving and wind

amber saffron
#

Ok, makes sense

restive radish
#

but when I change the uv there, it's going wrong somehow

#

it's the same if I change the uv in fragment shader as well

#

tried that already

tired canyon
#

In object space

#

are normals supposed to be 0-1

#

or -0.5 to 0.5

amber saffron
#

Maybe (not sure here) the UVs are wrong from the begining ?

restive radish
#

maybe

#

I'll try something and see how it goes

amber saffron
tired canyon
#

hm

#

I'm trying to sample a normal map using the triplanar node

#

and I can't seem to get remotely functional normals out of it

amber saffron
#

Note that the triplanar node has a mode to swith to normal sampling.
It will only accept a tangent space normal map

#

And will output tangent space normals

tired canyon
#

ok, so I should be able to feed worldspace normal in

#

and use the output as tangent space

#

the normal map is in tangent

amber saffron
#

You could also use object space if you want the mapping to be independant of the object transform.

tired canyon
#

well I'm in an instanced shader

#

and in HDRP I can't rely on the Object space

#

because I can't override the UNITY_WORLD matrices

#

so I've gotta do those conversions myself

warm marsh
#

Does anybody know if there was ever a work around for render texture transparency on URP when using post processing? I'm on 2019.4.19f1
Currently it completely ignores the camera clearing and won't allow transparency unless PP is turned off repost from render pipelines

deep mason
#

Hey guys, any idea what could be causing these particle squares? my material seems to be attached correctly, so why am I getting these?

wooden laurel
#

All particles are squares by default. Attach a different shader/sprite

#

If u want the shape to change

keen minnow
#

Hello, is it possible to have my directionnal light shadow to be as good as the point light one, le point light is the one on the left, the dir is in front, ( idk where do I put this sorry )

wooden laurel
#

also depends on what pipeline you are using

keen minnow
#

URP I have a toon shader

brittle galleon
#

I have a small city with several buildings all using a single large texture. My question is if it is possible to setup different normal maps for each building, but have them share the same texture?

shadow locust
crystal ocean
#

So I've made some progress on my shader, but I'm wondering how I can get a bit of a Chromatic Abberation effect to "offset" the color slightly off the model:

#

Kinda like this:

#

but keep the RGB channels uniform

proper plover
#

In the pbr graph theres an option for opaque shaders to have alpha blending. How do I achieve that in URP lit shader graph?

reef hinge
#

Hello, its my first time using shader graph. I am trying to do pixel outline effect following a youtube tutorial. But I am getting an extra inline effect from opposite side. I cant figure out why, can anyone help?

deep mason
brittle galleon
tired canyon
#

oh nevermind

#

ignore me

#

you are using the uv0 channel

#

do you only want the white parts?

reef hinge
#

yea

amber saffron
#

I guess the extra "inline" is from the subtract operation returning negative values => the black pixels

#

Add a "saturate" node after subtract to fix it.

reef hinge
#

I actually found a fix but it feels like a trick more than a fix. I am multiplying the result of subtract operation with a A channel to remove them

reef hinge
crystal ocean
#

anyone @here have thoughts on my above question about a uniform chromatic aberration effect?

amber saffron
crystal ocean
amber saffron
#

I don't ... get the question ? You want to do a kind of distortion effect on a texture ?

crystal ocean
#

I'm trying to create a material override within the URP

amber saffron
reef hinge
#

Sorry I am total beginner at this, how can I make it so yellow pixels stay orange here?

crystal ocean
amber saffron
#

Can you show your current setup of nodes ?

amber saffron
crystal ocean
#

Right, I'm doing that with a layer

amber saffron
crystal ocean
#

So that the post-process is only effecting object(s) on that specific layer

#

Basically I've been able to implement the color/material override that I want, but can't understand how to execute the color shift within shader graph

amber saffron
#

Are you sure you're doing a post process ? A render feature is not a post process

#

(not forcefully)

reef hinge
amber saffron
#

No, here is the good place to learn about shaders πŸ™‚

crystal ocean
#

Well I guess I'm not doing a post-process since I'm using a Render Objects renderer feature

reef hinge
#

ah alright, normally I can find answers with google search so I am confused haha

crystal ocean
#

But I don't know how the URP handles material overrides using custom passes

#

either way wouldn't the material override in the Renderer Feature still be able to execute a color shift using a material override?

amber saffron
amber saffron
crystal ocean
#

OK, gotcha, so then how does the URP handle custom post-processes if not in the Renderer Features?

crystal ocean
#

Is there documentation for writing your own custom post-processing volumes or features?

amber saffron
#

You can also make your own scripted renderer feature if you want

proper plover
#

anyone knows how to let the shadow change with the dissolve of this sphere for example? I'm using URP, lit shader graph, with transparent surface and alpha blend. All the tutorials I've seen used PBR graphs with opaque surface and alpha blend which I cant seem to get with the lit shader graph.

crystal ocean
#

ugh... ok thanks I really appreciate it @amber saffron

crystal ocean
amber saffron
amber saffron
proper plover
#

thanks

#

is it the alpha clip thing?

#

ah i got it to work

#

thanks remy

amber saffron
#

I think you mismatched the different conversations πŸ™‚
But put simple, if you want to have a vector values that varies from pixel to pixel, you need to get it from somewhere, could it be UVs/Position/else.
You can then operate on it like you want.
So if you want to offset the texture, but offset goes from -1 to 1 in UV space, you need to take the UV (range 0 to 1), multiply by two, remove one, input as offset of the tiling/offset node.

crystal ocean
#

If I'm using the Post-Processing stack in URP, can I single out specific objects to apply the effect to? The reason why I was using the material override is so that I can set the effect to specific layers

amber saffron
crystal ocean
amber saffron
crystal ocean
#

What about using a camera overlay? too costly?

restive radish
#

Now I'm a bit puzzled. The shader works fine if I play it in the material, but in the grass itself, it's cutting some frames.

#

you can see it works well in the material by the preview in the bottom right

#

any idea what I'm doing wrong?

amber saffron
crystal ocean
amber saffron
#

You could give a try to my solution with draw object renderer feature and transparent material.

crystal ocean
#

How do I create a draw object renderer feature?

amber saffron
# restive radish any idea what I'm doing wrong?

Like I mentioned, maybe bad UVs on the grass meshes itself ?
An other thing I have in mind : maybe the sampler used in the terrain detail doesn't loop on the texture, and so you're seeing the empty pixels repeated outsive of the uv space ?
Try applying a uv.x = frac(uv.x) before sampling ?

reef hinge
#

I have 2 shadergraphs and a material for each. How can I show 2 effects at the same time on one object?

amber saffron
amber saffron
#

Hum, ok ... I really don't get what you issue what and what you're doing, but if you're happy with it ...

amber saffron
restive radish
#

half4 diffuseAlpha = SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_MainTex, sampler_MainTex));

#

this is the sampler, gonna try what you suggested

reef hinge
amber saffron
reef hinge
#

soo you end up with really huge shadergraph if you want multiple effects?

amber saffron
#

Sooo, you want to sample a texture with an offset going back and forth between -1 and 1 for example ?

reef hinge
#

just trying to understand if thats common πŸ˜„

reef hinge
#

thanks!

amber saffron
reef hinge
#

lemme take a look at them

grand jolt
#

Is there a way to access Shader Graph Master Node settings in script ?

restive radish
grand jolt
crystal ocean
grand jolt
#

Thanks for the help!

amber saffron
crystal ocean
#

So what you're saying is create a secondary transparent object that only get rendered in the ForwardRenderer Data?

amber saffron
crystal ocean
#

To transparent?

amber saffron
#

yes

amber saffron
restive radish
crystal ocean
amber saffron
#

I'm not 100% sure, but I think the material/shader needs to be transparent also.

crystal ocean
#

Yeah, it already was...

amber saffron
#

Was the material override just remove when you changed the queue mode ?

crystal ocean
#

again, it's doing all the things I want, just don't know how to get that "offset" look

#

no it remained there but became invisible

amber saffron
#

Oh, sorry, that's my fault, the queue here is for filtering, not when to render

crystal ocean
#

Right, yeah I was a bit perplexed by that...

amber saffron
#

So, maybe the easiest to do is to use a fresnel node to control a color shift ?

#

Or something like that.

crystal ocean
#

yeah but how do I get it to shift off the model?

amber saffron
#

"off" ?

crystal ocean
#

yes, like a chromatic aberration effect:

amber saffron
#

If you want it like this, you just have to offset the vertex position.
But you said you want something more smooth, like a "real" post process chromatic aberration. But this requires sampling the color buffer. It can be done in an object pixel shader, but to shift off the model, without also shifting the rest of the scene, you have to mask out the model ... and wo get to the same point, of masking it.
Note that you might be able to use the stencil buffer to make this mask πŸ€”

tired canyon
#

does anyone know how given an object space normal and a tangent space normal how I can calculate what the new object space normal should be after applying the tangent

crystal ocean
#

THATS ALL I WANTED TO DO!

just offset the vertex position, but didn't know what it was called or how I wanted to reference it.

crystal ocean
#

Thanks so much @amber saffron for talking this out with me, I really appreciate it!

amber saffron
crystal ocean
#

I know, I'm bad at explaining, so sorry! Using terminology from fine arts and not good at using vocab from Unity πŸ˜›

tired canyon
# amber saffron Like, if you overlay them ?

I'm having some weird issues with my normals if I assign via tangent space. They look right if in the fragment shader I don't assign anything to them at all, but when I sample the normal map and apply the tangent normal from it I'm getting weird behavior

amber saffron
tired canyon
#

tangent map when the normal is used to color each fragment

amber saffron
#

Can you show the nodes setup ?

tired canyon
#

that above screenshot was with tangent normal of 0 0 1

#

hardcoded

#

this is what it looks like when I do use the normal map as both the tangent normal and the color

#

I get those weird faces where the normals are incorrect

amber saffron
#

If you sample a normal map, set the sample type to "normal"

tired canyon
#

fucking hell

amber saffron
#

Also set the texture to normal map in the texture importer

tired canyon
#

@amber saffron ty!

#

I'm a little annoyed that it was such a simple thing lol

#

but also glad that I don't need to attempt to fix my other math

modest spoke
crystal ocean
digital vector
#

when writing a shader for UI Images, how do i do rect clipping? Right now my shader isnt working with masking

#

or do i just write with builtin?

hard matrix
#

Hello everyone, I'm very new to Shaders, I'm trying to work with stencils and I ran into a weird situation, I'm hoping that someone can point me to the right direction:

{
  Ref 0
  Comp Equal
  Pass Keep
}``` Passes, but 
```Stencil 
{
  Ref 1
  Comp Less
  Pass Keep
}``` Does not pass

Am I missunderstanding how Stencils work?
desert roost
#

I'm trying to make a shader that will make shadows on the material dithered.

#

This is what I have so far:

#

This looks like hot garbage. I'm quite new to shaders, so if anyone has any tips, I would greatly appreciate it.

brittle owl
#

well i mean, it is dithered

#

i think its too small though right

#

oh yeah im having a problem with urp's ssao render feature
ive created an unlit graph and i wanted to have ssao so i used the _SSAO_OcclusionTexture3 to get the ssao texture, but in game it looks like this:

#

up close you can clearly see the faces of the object, and far away it looks like its dithered

#

using a normal lit shader, you can sorta see the faces, so i guess thats not a big problem

#

but from far you dont see the weird dithering effect as the unlit one

brittle owl
#

oh i think i fixed it

#

_SSAO_OcclusionTexture2 is nice and smoooooooth

glossy hull
#

i asked this in the lighting forum but maybe it wasnt the right place, i have some night lighting which looks good using spot lights and a stacklit shader, it also looks good with area lights and a lit shader, but both are very expensive for performance, and i'm not sure WHY it happens, do i'm not sure how to fake it. my camera is static

#

thats how it looks stacklit or area lights, pretty much the same for both

#

spotlights and lit

#

you cant see the 'wet patches'

brittle owl
#

how is lighting from normal maps calculated? i need to recreate it in an unlit shadergraph

umbral glacier
#

Hi fellas, can I ask a quick question about execution order in shadergraph shaders?

#

I got a scene with 3 shaders I made in shader graph

#

one is a emmisive plane effect, distorts the mesh, looks nice

#

and the other 2 are transparent shades, 1 fro glass with refraction using opaque textures, and the other is a bubble effect that uses a reflection probe

#

if I move my glass and bubble objects in a normal scene where objects are using the normal URP shader, the transparent objects work correctly, they reflect and refract light as you would expect

#

if i use the transparent objects in a scene with my emmisive grid shader, they look as if nothing is there, no reflections, no refractions

#

my question is if there is a execution order for shaders that I can adjust so that my emissive grid shader renders first, so that the transparant effects can take it's output as an input???

heavy stirrup
#

how do i upload a struct in C# to a constant buffer in a shader?

#

I see in graphics / compute buffer that the data has to be in an array

slow bear
#

I'm working on a water shader, but I'm having some issues regarding caustics

wooden laurel
#

Or set that in code

slow bear
#

I'm trying to implement parallax movement (NOT parallax mapping) but there's a weird issue where the parallaxed plane zooms when I get closer

slow bear
#

Another question: _WorldSpaceLightPos0 holds the info about the direction of the directional light and the position of the other light sources yadda yadda etc...

But what that does imply? Is the shader run multiple times for each light source in the scene?

wooden laurel
#

depends on what type of shader you are talking about

#

A shader doesnt actually know the position of the light, it just cares about the direction of light coming in. So the name of that is not intuitive.
A shader is in most cases either applied to either a vertex or a pixel.
A shader calculates from what direction light is hitting the pixel/vertex then does the calculations to show the results.
So yes, every light hitting the pixel/vertex will be taken into the consideration as it needs the information from the light vectors to display to you

#

this is done on the gpu ofc

#

@slow bear

slow bear
#

That's not the point I'm making

#

Going by the docs, _WorldSpaceLightPos0 is a vec4 structured as (WorldSpacePosition, 0) if it's handling a directional light and (WorldSpacePosition, 1) if it's handling a point light

#

of course, since the actual position of a directional light doesn't make sense, in the directional light case the World Position is exactly the light direction

#

What I was wondering about though was: if the Alpha/W channel of _WorldSpaceLightPos0 can be either 0 or 1, what happens if I have a scene with a single point light and a directional light? What does a simple custom lit shader do in that case, is it run twice?

wooden laurel
#

You can handle all light calculations in a single pass. Meaning that it's ran a single time

#

Just take in consideration the order in which you do the calculations

#

lemme write u a code example

restive radish
#

is there any difference to cut alpha from texture2d arrays?

#

` half4 diffuseAlpha = SAMPLE_TEXTURE2D_ARRAY(_MainTex, sampler_MainTex, input.uv, _Index);
half3 diffuse = diffuseAlpha.rgb * input.color.rgb;

half alpha = diffuseAlpha.a;
AlphaDiscard(alpha, _Cutoff);
alpha *= input.color.a;`

Trying this, but it's just showing the color without cutting alpha. The texture is set to have alpha

wooden laurel
#
   SubShader
    {
        Pass
        {
            Tags {"LightMode"="ForwardBase"}
       
            struct v2f
            {
                float2 uv : TEXCOORD0;
                fixed4 diff : COLOR0;
                float4 vertex : SV_POSITION;
            };

            v2f vert (appdata_base v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.texcoord;
                half3 worldNormal = UnityObjectToWorldNormal(v.normal);

                //standard diffuse light here
                half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
                o.diff = nl * _LightColor0;

                //ambient light calculations here 
                o.diff.rgb += ShadeSH9(half4(worldNormal,1));

                return o;
            }
```@slow bear
#

I commented when in the places where light is calculated

#

But they are included in a single pass

#

meaning the code doesn't need to be running twice

#

ofc you could also seperate it into different passes

#

it's up 2 u really

slow bear
#

You still don't get what I'm saying, but maybe you got to the point

slow bear
wooden laurel
#

the point im trying to make is, you can decide how many times u run the shader depending on how u set it up with light

slow bear
#

sorry if I came out as rude, it's just that I know already how to make custom lighting, NdotL, NdotV, that kind of thing you know?

#

I know how to handle Blinn-Phong, but the shader reacts only to the main light in the scene; I want to make it so that it also reacts to point lights

wooden laurel
slow bear
wooden laurel
#

I gotta get back to work now doe, hopefully u figure it out. If u dont i can maybe help u after work

worn lion
#

Trying to displace the vertices by the value of the green on this texture. Have tried some approaches but it never really does what it is supposed to do. Any references or help is appreciated love

slow bear
pale ravine
#

Hi, I am working with veins right now. I am creating a normal map from a height map and I receive this effect. My texture is 512x512. What's the best I could do with this?

tired canyon
#

Then you have to make sure that you set the stride and that the buffer is large enough

#

And then you can bind it to your material or shader

#

That class has some examples of wrapper functions that do those things for you

#

It's MIT licensed as well so you could just use it

fair sleet
#

Hi everyone, I've a question about performance: a shader with a lot of nodes that they dont be used into my material (i.e. i have a complete PBR shader but i use only 1 texture slot) has worst performace of a shader with only the nodes of the texture that i effectively use?
And keeping in mind this, i have better performance with 1 complex shader or with more simply and specific shaders? (i'm working on Oculus Quest1)

amber saffron
# fair sleet Hi everyone, I've a question about performance: a shader with a lot of nodes tha...

There is no definitive answer to this.
So, in the case of the PBR shader where you only use one texture slot : This doesn't change anything, as you may have noticed, a texture input has a default value : black/white/grey/bump. Those are small (4x4 or 8x8 px) textures that are assigned to the slot if nothing else is there. So even if you don't use the slot, the shader operations are still doing something.

#

Unless you add some keyword based branching that would really remove the code of the unused slots.
But this is similar as making different shaders

#

Second question : is it more performant to have multiple "more specific but smaller" shader or a single "generic but bigger" one ?
Once again, it depends. A single one can more easilly batch objects together, but will have more operations per pixels. Smaller one have less operations per pixels but don't batch together ...

#

It's not great, but my best answer is : try and profile.

grand jolt
#

Can somone send me a double sided shader?

#

Dm it to me or @ me with it here please

tame topaz
#

That question doesn't really make any sense. What kind of shader, based on the standard lit, or what?

visual moth
#

Odd, I can't seem to find the download for the Transparent-Diffuse shader for Unity 2020.3.12

#

Is it because it's a legacy shader maybe?

fair sleet
#

Thanks @amber saffron !

tepid agate
#

Hey, someone can help me? In Shader Graph, I want to go from a gradient noise (represented by the circle) and adjust it so it's like a trail. How can I achieve this effect using nodes?

onyx jungle
#

Hey can anyone tell me why my transparency slider is not working

#

My materials alpha stays the same transparency

amber saffron
onyx jungle
brittle owl
#

question, how would i recreate normal mapping in an unlit shader graph?

#

i thought this would work but it doesnt :/

#

mine on the left, urp's lit shader on the right

keen minnow
#

Hello, is it possible to have a bump map in a toon shader ? (unlit shader graph)

#

?

brittle owl
#

by bump map do you mean normal map

#

(cause thats exactly what im trying to do lmao)

keen minnow
#

lol I think so

brittle owl
#

oh wait, i think i managed to actually do it!

#

its mostly correct

#

only problem is the darker parts

keen minnow
#

ooh nice

#

congratz

keen minnow
#

Oh I made it work

visual moth
#

I figured out my shader issue. I just had to manually assign the render order of my objects when creating the materials, and make sure I passed it con when updating the material

#

Not a great fix for everything, but it works for my case

#

No custom shaders required, haha

amber saffron
# brittle owl oh wait, i think i managed to actually do it!

Yep, you're almost there.
The main light direction vector is in world space, so you need to set the normal transform output to world space also.
And you don't need to remap the result of the dot product, eventually you can pass it through a saturate node.

#

And for the dark areas, well, this is kind of expected, at you're only applying a single main light, so the faces that are in the opposite directions are fully black.

#

You can multiply the result with the light color to ... well, use the light color πŸ˜„
If you want to include some ambiant lighting, there is an "ambiant" node if I'm not wrong, where you input the normal value and it output the ambiant light color. Add it to the previous result to have main+ambient.
Multiply this with your surface color, and you have a basic lamber shading πŸ™‚

brittle owl
#

i’m making a black and white toon shader so i don’t think i’ll need ambient lighting

tired canyon
#

Does anyone know if I can assign compute buffers to vfx graphs

#

And where any of this stuff might be documented

tired canyon
#

looks like I have to use textures

rare charm
#

I know almost nothing about shaders, so bear with me a minute. I have a standard surface shader. All I did was create the shader and adjust the color. But when I adjust the alpha of that color in the inspector it doesn't change in the game window.

Is there a different shader I should be using or something I should change? I want to be able to adjust the opacity of this at runtime and its more difficult than I thought it might be.

white cypress
balmy lark
#

So I am trying to modify an outline shader (https://github.com/chrisnolet/QuickOutline). Right now, for some reason, the shader only outlines objects that have nothing (the skybox) behind them. I would like the outline shader to outline every object that has it (on every face). Maybe the screenshot will help you understand my goal. Is this even possible? Here are the two shaders that it uses: https://github.com/chrisnolet/QuickOutline/blob/master/QuickOutline/Resources/Shaders/OutlineFill.shader
https://github.com/chrisnolet/QuickOutline/blob/master/QuickOutline/Resources/Shaders/OutlineMask.shader
I am using Unity 2020.3 and URP.

brittle owl
#

@amber saffron not sure if you'd be able to help, but now im trying to get specular working with the normal map, i found this blinn-phong specular subgraph a while back but it only has an input for smoothness, nothing for a normal map

rare charm
#

Yet the alpha change does nothing

white cypress
#

and when I said rendertype I mean in the tags of your shader code

rare charm
#

@white cypress The alpha:fade seems to have done it. Thanks!

rare charm
#

@white cypress well maybe not. What might be causing this behavior? The flag pole and flag both have the standard shader with alpha:fade and rendertype transparent, no other changes.

elfin hatch
#

Hey everyone, sorry for the noob question. I'm using URP but when I extract materials from my models they all have a blueish tint, it also happens when I try to create them using images from sites like Poliigon.

What shader to use when creating materials from texture images with normal maps and displacements etc. Can someone link me to a resource on how to creating high fidelity materials on URP?

vocal thistle
#

how do i change the draw order of a particle system so that it renders on top of other gameobjects?

native sphinx
#

Hi team - when I have a collision, or have a raycast, to know when I hit a part of the object where the Shader Mask is on or off? Basically making a shield with holes using noise, and want projectiles to pass through where the noise mask is not on the object

oak dagger
#

Hello can someone help me with shader issue?

#

I imported some assets on the marketplace to my project; URP pipeline, but material still pink.

native sphinx
#
  1. Check if there is a URP package in the asset. If so, unpack it
#
  1. Edit -> Render PipeLine -> URP -> Upgrade all project materials to URP
#

That should fix it

oak dagger
#

I did the upgrade but the material still pink

native sphinx
#

did you try #2?

#

or rather

#

#1?

#

if not, you have to contact the asset producer

#

too many variables, they likely have a readme or faq or something.

#

that covers specific instructions

#

or they didn't pack the right materials

#

when you imported, you imported all the materials, etc?

#

make sure nothing is missed

oak dagger
#

Foliage material have the problem, other does not.

native sphinx
#

and try their demo scenes. if they work there but not in your regular project, that can help you trouble shoot