#archived-shaders

1 messages · Page 55 of 1

low lichen
#

A mesh is just a cloud of points, vertices. There's no quick way to find the top or bottom most vertex without checking them all. Unity does this to calculate the local bounds.

tight phoenix
#

what if I just use the bounding box

#

its close enough for most shapes, I just need to hack this apart to get it done, perfect is obviously not going to happen

amber saffron
#

That what I suggested before, use the world bounds, but you were not happy with the result

tight phoenix
#

Yeah because I thought this would be easy

#

but since its not easy, I have to give up being happy and just get something done because something is better than me spending another 7 hours doing jack shit

tight phoenix
amber saffron
#

I've only seend the graph preview, not scene screenshot

#

I'm pretty certain that it works

tight phoenix
#

this right here is a value of "3"

#

it should be a value between 0 and 1

#

so its not usable as is

#

oh im a fucking idiot again as usual, im using the old bounds and not the ones from Object

#

pebcak can't do a single @#$@^ing thing without @#$@^ing it up

#

its so immensely frustrating to be stupid

#

but there is nothing I can do to become not stupid

#

yep works perfectly when I plug in the actual min max

amber saffron
#

Don't freak out for any error that you hit, stay calm and learn from it.

tight phoenix
#

Yeah that'd be the healthy reaction

#

okay unstuck its working moving on from this instead of losing my shit for the next 7 hours

hardy hinge
#

not sure if this is the right channel but does anyone know how to use projectors to display a decal

grizzled bolt
hardy hinge
#

im using the built in pipeline

tight phoenix
#

nothing in here relates to camera so I don't get why its doing this

grizzled bolt
tight phoenix
grave vortex
#

Not sure exactly what might be happening there, but it usually helps to isolate the problem as much as possible

reef mango
low lichen
tight phoenix
low lichen
#

Is this in URP?

tight phoenix
#

turns 'off' when bounds min / max are used, doesnt when they arent (pictured)

#

I can only guess there is something wtf about these two values?

grave vortex
#

I'm not sure though, that still doesn't explain why camera position changes anything

tight phoenix
#

moving the object also breaks it it seems

#

how can I figure out if the problem is world space negatives?

grave vortex
tight phoenix
#

still happens even when I absolute the values

#

ill try that

grave vortex
#

Are you using HDRP perchance?

tight phoenix
#

URP

#

still occurs even when everything is positive values

#

in +++ space

amber saffron
# tight phoenix

1 : What happens if you use "absolute world" in the position node ?
2 : and if the shader is set to opaque with alpha cutoff ?

tight phoenix
#

my only guess is somehow a divide by zero is occuring?

tight phoenix
tight phoenix
#

how does alpha clip work, no matter what values I pass in it never clips

grave vortex
amber saffron
# tight phoenix

Don't you have an alpha output connection when using alpha clip ???

tight phoenix
low lichen
grave vortex
#

or, actually come to think of it you could probably just move the object itself to y 0

#

That should make it visible

tight phoenix
#

😐 well it stopped happening, which isnt helpful because I didnt change a single thing and it stopped happening all on its own

amber saffron
#

@tight phoenix You should have alpha and alpha clipt threshold.
Connect the result of divide.Y to alpha, and set clip to 0.5, it should cut the shape in half

grave vortex
tight phoenix
amber saffron
tight phoenix
#

I did

#

I can no longer reproduce the bug

#

nothing I do is making it come back, not that I want it to come back

#

but I dont know why it stopped 😬

#

you'll hear from me again if/when it returns I guess???

#

oh its happening again

#

I moved it closer to world 0

#

and it resumed happening

#

its gotta be divide by 0 happening right?

amber saffron
tight phoenix
amber saffron
tight phoenix
#

I hit this checkmark

#

is there more to do than hitting this checkmark

#

that is what caused alpha clip to appear

#

no matter what I pump into alpha or alpha clip threshold, nothing masks if that checkmark is on

amber saffron
# tight phoenix

Ok, so that's good.
And this setup give no masking ? Could you again show the connections ?

tight phoenix
#

current graph, current output gif

#

notice preview is pink - which is why I keep saying I think divide by 0 is happening

amber saffron
#

Don't use the smoothstep in this setup, just the Y from the split node plz

tight phoenix
#

Sure

amber saffron
tight phoenix
#

no change from the above gif

amber saffron
tight phoenix
#

uh further wtf, moving a different object with the same shader on it is flickering different OTHER objects

#

okay no transparency now, opaque with alpha clip

amber saffron
#

Still bugish ?

tight phoenix
#

Flicker appears to have stopped

#

which is nice but also I kinda wanted it to be transparent

#

wait hold on

#

the flicker is still happening even with alpha clip, except its flickering the entire mesh

#

is the problem maybe that min max bounds are updating due to the masking?

#

and so like, the range im masking is constantly changing due to the min and max physically change as more of it becomes fully not opaque?

tight phoenix
#

oh okay

#

well then in that case I have no answers or thoughts, but the flicker is not happening visually to the fragment but IS happening to the orange unity selection box, when in alpha clip

amber saffron
#

I wouldn't be surprised that the selection outline doesn't like alpha clip fronm shadergraph

#

Do you still have the local bounds script active and setting values ? If yes, could you remove it ?

tight phoenix
#

the selection highlight is acting super bizarrely

amber saffron
#

I don't get why the flickering is happening, it's dead stable on my side whe I try

tight phoenix
#

I am on 2022.2.17 if that helps?

amber saffron
#

Am on .21

tight phoenix
#

even weirder still

#

these meshes, I cant even click on them when the 'flicker' is removing the outline

#

clickable now, but if I move the camera, I cant select click them

#

gif explination:

#

Im starting to think unity itself is doing something wtf and its not my shader 👀

amber saffron
#

🤷

#

Like I said, I would no be surprised if the scene picking pass has troubles with the alpha clip

tight phoenix
#

the flicker does not occur if the bounds min max are not used

#

so Im 100% sure those are somehow the cause

#

since removing them it stops happening

amber saffron
#

Try upgrading, like I said it worked on my side.

#

Else, maybe the property block is interfering in some way

tight phoenix
#

currently there is no property block happening, I removed all those scripts and parameters

#

Ill update unity version to 2022.3.5f1

#

and see if that helps

tight phoenix
#

so all their different bounds are somehow causing it to asplode?

amber saffron
#

It should not, but it can be :/

frank sparrow
#

what setting would I have to change so this material isnt so bold. there are no reflectioons even when a directional light is pointed at it, im changing all the rgba settings and the colour changes but the a value doesnt change anything. any help would be appreciated thanks

tight phoenix
amber saffron
tight phoenix
#

ah okay, good to know it works for you then

#

still openin project

frank sparrow
amber saffron
frank sparrow
uneven schooner
#

Would it be possible to simulate a Lit Shader in an Unlit Shader? Like, get shadow data and such. I'm wanting to modify shadows

atomic elm
#

I'm trying to use this Triplanar node in Shader Graph to have a texture appear on vertical surfaces and side surfaces, but I wanted them to clamp so that there is no blending between them (switching between textures at the 90 degree angle). Is there a way to do this?

slim steppe
grizzled bolt
#

With very high blend values (like 100 or 1000) the transition between textures is very sharp, though not absolutely

#

It uses a power function for the blend, so if you don't want that you'll have to implement your own triplanar mapping that doesn't use it

atomic elm
#

But is there a way to have three different textures feed into that texture node?

amber saffron
amber saffron
reef mango
#

@amber saffron i fixed the colors on the rendertexture going to grayscale during the blitting but i still have the original problem. i find the heighest point at different uvs. then if the result is more than .7 i output a red pixel. If its less i output a green pixel. So youd expect all the colors to be either red or green. But theyre red AND green.

amber saffron
reef mango
#

is there a special way to do it ?

amber saffron
#

Copy paste the code here with code quotes ( this one : `)
3 quotes to start the block, 3 to end it, and you can add a langauge for highlighting

reef mango
#
                    bool brushTouchingOutputPixel = false;
                    float greatestHeightAtSpotLocations = -1;
                    for (int index = 0; index < 9; index++)
                    {
                        half2 diff = _ArrayCoordinatesOfSplats[index].xy - i.uv;
                        half2 scaledDiff = diff * half2(_SizeX, _SizeY);
                        if (abs(scaledDiff.x) < 0.5 && abs(scaledDiff.y) < 0.5)
                        {
                            float heightOfDisplacementMapAtSplatPosition = tex2D(_MainTex, _ArrayCoordinatesOfSplats[index].xy).r;
                            if (heightOfDisplacementMapAtSplatPosition > greatestHeightAtSpotLocations)
                            {
                                greatestHeightAtSpotLocations = heightOfDisplacementMapAtSplatPosition;
                            }
                            brushTouchingOutputPixel = true;
                        }
                    }
                  
                    if (brushTouchingOutputPixel)
                    {
                        if (greatestHeightAtSpotLocations < 0.7f)
                        {
                            return float4(0, 1, 0, 1);
                        }
                        else
                        {
                            return float4(1, 0, 0, 1);
                        }
                    }
                    else
                    {
                        return heightOfDisplacementMapAtOutputPixel;
                    }

amber saffron
#

Hum, yes, I'm lost, I don't see anything here that could explain having different values

tight phoenix
tight phoenix
amber saffron
#

I'm out of ideas

tight phoenix
#

same

#

Im going to just try to achieve what I want but without using the bounds calculations

#

fudge it some other way

desert orbit
#

@rough hawk Don't cross-post. Stick to one channel, please.

rough hawk
#

Sorry guys, I just joined. which channel would best fit my question.

desert orbit
reef mango
#

@amber saffron emy i wonder if i should use GPU instancing to pass the decal UV coords to the shader?

amber saffron
#

🤷

frank sparrow
#

can anyone help me here, i have no clue what this means or how to fix it

amber saffron
frank sparrow
amber saffron
#

Yes

reef mango
#

@amber saffron i think i found a solution. Im going to output the highest displacement value to a 1x1 texture and use that as input to another shader that will alter the entire 4096x4096 map.

gusty marten
#

Hey Folks! I have a question. What is the difference between #define and #pragma shader_feature KEYWORD. my understanding is they do same thing, define a keyword that can be used for if else and static branching

vale spruce
#

you can't turn off and on #define I think? #define is more like specific pass maybe, but shader_feature is more like if you want to use specific shader feature or not

#

there is also #multicompile thingy

steady lintel
#

Hey! I've been having some weird artifacts and bugs relating to this one ToonShader in my project. I was wondering if anyone would be able to maybe identify what sort of issue this is or what could be causing it? I don't really know how to explain it, so here's a video of it in motion.

#

As you can see, the geometry in this video stops receiving shadows and starts to weirdly display other objects in the area when viewed at a certain angle. I don't know what the reason for this is. If it helps at all, here's the shader file:

gusty marten
tight phoenix
#

UnityChanThink I noticed I am making a lot of derivatives of the same basic shader, each of these is like 90% identical, what is the best/most optimal workflow to reduce duplicate code / lower how much work it is to maintain branches?
a copious number of Subgraphs are the first thing that comes to mind, but is there anything better than / in additon to that?

#

most of the same pieces, the same inputs, is there some way to make like, a derivative shader that inhereits all this instead of remaking it over and over?

ocean bison
#

oh, sorry.. nm.. you got that already

tight phoenix
#

googling it looks like subgraphs is all there is really, inhereitance isnt really a thing

ocean bison
#

That's all I know of:( the backend HLSL, is c not c++, so yeah, would be hard for 'em to do (inheritance).

#

I'm just starting out with compute shaders- hope it's ok to post Q's on em here...

#

I want to use a compute shader to progressively alter a texture. Meaning each cycle, the change to the texture depends on the current state of the texture.
Do I need to have separate read and write version of the texture? (And if so, how do I copy the results back into the "read" texture at the end of each compute shader cycle? I want to use this texture in another shader (shader-graph for drawing).

I ask because I'm running into some odd issues: this version of my test shader graph code works fine, and changes both texture to red (as seen in the inspector)


// The two input textures that we want to adjust.
RWTexture2D<float4> _GroundTexture;
RWTexture2D<float4> _WaterTexture;


[numthreads(8, 8, 1)]
void RedTest(uint3 id : SV_DispatchThreadID)
{
    // Store the color red in a float4 variable.
    float4 redColor = float4(1, 0.0, 0.0, 1);

    // Write the red color to both input textures at the current pixel.
    _GroundTexture[id.xy] = redColor;
    _WaterTexture[id.xy] = redColor;

}```

But THIS code, sets both texture to black!
```#pragma kernel RedTest

// The two input textures that we want to adjust.
RWTexture2D<float4> _GroundTexture;
RWTexture2D<float4> _WaterTexture;


[numthreads(8, 8, 1)]
void RedTest(uint3 id : SV_DispatchThreadID)
{
    // Store the color red in a float4 variable.
    float4 redColor = float4(1, 0.0, 0.0, 1);

    // Write the red color to both input textures at the current pixel.
    _GroundTexture[id.xy] += redColor;
    _WaterTexture[id.xy] += redColor;

}```
#

and THIS code leaves _GroundTexture intact (with an image I copied in there at startup), WaterTexture starts and remains black:


// The two input textures that we want to adjust.
RWTexture2D<float4> _GroundTexture;
RWTexture2D<float4> _WaterTexture;


[numthreads(8, 8, 1)]
void RedTest(uint3 id : SV_DispatchThreadID)
{
    // Store the color red in a float4 variable.
    float4 redColor = float4(1, 0.0, 0.0, 1);

    // Write the red color to both input textures at the current pixel.
    ///_GroundTexture[id.xy] += redColor;
    _WaterTexture[id.xy] += redColor;

}```
uneven schooner
#

Made this scanline + RGB Effect shader, wanted some opinions

pale python
#

hey is it possible to get the return of float4x3 function float4x3 GetValue() stored on 4 seperated float4 without having to store the return of the function on a float4x3 first ?
i was thinking of float3 f1,f2,f3,f4 = GetValue();
where f1 = GetValue()[0]

shadow locust
#

one example from there:

// Given
float2x2 fMatrix = { 1.0f, 1.1f, // row 1
                     2.0f, 2.1f  // row 2
                   };
float2 temp;

temp = fMatrix._m00_m11 // valid
temp = fMatrix._m11_m00 // valid
temp = fMatrix._11_22   // valid
temp = fMatrix._22_11   // valid```
pale python
#

like this float3 f1,f2,f3,f4 = GetValue();

shadow locust
#

I don't think so

#

that would be very pythonic

pale python
#

ok thats all i wanted to know , thanks ❤️ ❤️

grave vortex
vale spruce
#

can I use the #if like this to remove a function?

#if defined(_OCCLUSION_MAP)
    float GetOcclusion (Interpolators i)
    {
        return lerp(1, tex2D(_OcclusionMap, i.uv.xy).g, _OcclusionStrength);
    }
#endif
#

or it need to be inside the function like this?

    float GetOcclusion (Interpolators i)
    {
#if defined(_OCCLUSION_MAP)
        return lerp(1, tex2D(_OcclusionMap, i.uv.xy).g, _OcclusionStrength);
#else
        return 1;
#endif
    }
hushed vigil
#

You can use the first one, but then of course you'll get an error if you try to call the non-existing function from somewhere else

vale spruce
#

better or cleaner way to write this?

float4 OutlineFragmentProgram(Interpolators i
#if defined(LOD_FADE_CROSSFADE)
    , UNITY_VPOS_TYPE vpos : VPOS
#endif
    ) : SV_Target
{
    // code
}
#

is there like inline #if defined()?

hushed vigil
#

nope

#

for clarity I'd do

#if defined(LOD_FADE_CROSSFADE)
float4 OutlineFragmentProgram(Interpolators i, UNITY_VPOS_TYPE vpos : VPOS) : SV_Target
#else
float4 OutlineFragmentProgram(Interpolators i) : SV_Target
#endif
{
vale spruce
#

oh! thanks Nitku!

vale spruce
#

can you like turn off and on double sided from custom GUI?

Pass
{
    Tags
    {
        "LightMode" = "ForwardBase"
    }

    Blend [_SrcBlend] [_DstBlend]
    ZWrite [_ZWrite]

    CGPROGRAM

    #pragma target 3.0
    #pragma shader_feature _DOUBLE_SIDED

    #if defined(_DOUBLE_SIDED)
    Cull Off
    #endif
        // code
}
#

but it say

regal stag
#
// in Properties :
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", Float) = 2 // "Back"
// in Pass :
Cull [_Cull]
vale spruce
#

it's 2 sided now, but it's only doing cutoff on one side, anyone know how to cutoff both side?

vale spruce
#

is there a away to flip a face in fragment shader?

#

not normal flip, but like the face itself

frigid jay
vale spruce
#

do you know how to make like cutoff shader that is double sided?

regal stag
#

It should already clip both sides

frigid jay
vale spruce
frigid jay
regal stag
#

Hard to say why without seeing the code, but check what calculations you're doing for the clipping. Unless you're using SV_IsFrontFace (or VFACE) I don't really see why it can be different per side.

#

Is the alpha based on normal vector perhaps?

vale spruce
vale spruce
regal stag
#

Then it shouldn't be different. Perhaps what you're seeing is a different pass/object?

vale spruce
#

ah... it's my other pass... kekwait

#

thanks guys I found the problem

vale spruce
#

so we have #shader_feature to remove and adding a code on compile time. Can we do something like adding and removing a pass?

frigid jay
vale spruce
#

I see... thanks

#

how expensive is an empty pass?

frigid jay
vale spruce
#

oh! thanks I will try to look into that

#

Material.SetShaderPassEnabled anyone have tried this?

vale spruce
solid geyser
#

So... I've built a voxel engine thats pretty robust and handles beveled edges but i'm looking for ways to distinguish the different block types.
Each block has its own material and I was wanting the materials to generate small geometry details like pebbles on the dirt blocks.
Would I want to use a vertex shader or something for that? I havent messed with shader programming but would like to learn

#

Right now I'm kind of wanting to work without generating UVs because the mesh was a lot more complex to generate than meets the eye,
especially with how the corners blend in all directions

#

My idea is to do something similar to grass and create a bunch of vertices in a range around the player as they move, placed on the appropriate block type.
So dirt might have pebbles on all sides while grass only places those vertices on top

frigid jay
solid geyser
#

Technically demanding as in implementing it?

#

Any resources on the topic?

ebon idol
#

I have a question. Does the Unity Toon Shader support Global Illumination backed lighting? Because everytime I try to back lighting the sceen goes completely black, but lightmaps are created so it seems to be working, but it isn't. But if I use a normal normal URP shader it works fine.

grizzled bolt
ebon idol
#

Oh ok. Problem with that is Unity only provided the HLSL for the shader and not a shader graph file. Unless I'm missing something.

shadow locust
#

basically you deform the normals at the fragment level based on a texture to create imaginary bumps

solid geyser
#

I see, i'd like to actually create vertices so may just do manual mesh generation stuff

frigid jay
frigid jay
oblique wind
#

I have question about Shader Graph.
I want Shader Material attached to object(2D)
So it looks same with material as it would if it was just sprite attached, currently getting weird lines around.

#

Here is what I have, and I wonder how to make that left blob look same as right one in-game but by applying shader

#

The reason why I want it this way is so t hat I can dynamically replace spritesheet via code which saves me from having different animations per character spritesheet

#

I am not too familar with shaders any help appreciated

regal stag
#

You may also want to use _MainTex as the property reference, that way it'll automatically use the sprite set under the SpriteRenderer

oblique wind
#

much appreciated

frank sparrow
#

What are these used for, I thought they were just helpful but when I add one my node goes from a float1 to a float4

regal stag
#

Can put through a Float node first to avoid that

frank sparrow
#

ah alright, thank you very much

frank sparrow
#

i have been following catlikecoding gerstner waves tutorial. ive converted it from a shader to shadergraph but i just cannot get it to work. ive done it twice from scratch so i dont think its small mistake rather a misunderstanding in the tutorial. ive attached in order a video of what my shader is, what is should be as an image, my shader and my subgraph that does most the work and here is the link of the tutorial i am following https://catlikecoding.com/unity/tutorials/flow/waves/. i understand it is a lot to look through but if anyone is familar and might just know what is wrong because they are familar with the tutorial, it would be very much appreciated

A Unity Flow tutorial about moving vertices to create waves.

karmic hatch
frank sparrow
#

ive tried changing the values too in the editor you can see in the video on the right, as well as in the shader editor

karmic hatch
oblique wind
#

without maintex I get desired effect but I get this warning.

frank sparrow
regal stag
oblique wind
#

ill try that approach tomorrow cheers

ebon moss
#

when I apply a shader graph to a 3d visual effect graph, is it making a 2d projection of the 3d object and then stretching the shader to fit that 2d projection?

#

My only experience with shaders is a 6 minute yt vid so i might be totally misunderstanding something

rare wren
slim steppe
#

I'd like to make a post processing shader for urp, I tried using the shadergraph stuff but I dont like it.
I'm trying to replicate what I did there in a regular shader but I cant even find a working template for one.
Does anyone know a simple one (for example like the color inversion example)

ebon moss
grizzled bolt
#

Or it's probably not useful to think of it that way

#

You could think of it more like that a shader runs for every pixel that's occupied by the mesh on screen

#

(Though it also runs on vertices, and not technically on pixels but fragments, but)

oblique wind
#

This is code grab of replacing main tex texture ThinkSpin

regal stag
oblique wind
#

changing this doesnt affect it

regal stag
#

Hmm, it's supposed to UnityChanThink

#

I guess if you have a animator or something that might be overriding it?

oblique wind
#

ye changing out materials and not having reference set to mainTex is only way it works

#

but that does give that little warning

oblique wind
#

but whole reason I used shader is to avoid duplicating animations

#

I am fine with warning but I wondered if there was alternative way to handle it

regal stag
#

I guess just use a different texture reference and ignore the warning then

#

As I mentioned before, adding an unused Texture2D property with the MainTex reference might also remove the warning

oblique wind
regal stag
#

In the shadergraph blackboard, you can add multiple Texture2D properties

#

Have one with _MainTex but sample the other texture instead in the graph

oblique wind
#

ye that removes the warning

#

silly to have extra variable though

mint berry
#

inside the shadergraph i can see emissive lights

#

in the scene i cant

#

W H Y

#

its HDRP

#

problem: emissive is not showing in scene

regal stag
# mint berry its HDRP

iirc HDRP uses different units for emission so I think you need to multiply by some large value to increase the intensity, or put it through an Emission node

mint berry
#

multiply + float ?

#

i ried both didn't work

#

ill try in new scene

#

Could that be a bug am using somewhat an old version

lavish sierra
frank sparrow
kind sierra
#

Hello, would this be the correct channel to ask questions about the SRP?

#

Specifically I have questions regarding programming render features and passes myself

marsh dust
#

How could I add a shader on top of my existing material?

#

I want something similar to a Minecraft enchant!
Is it just make a shader that applies the texture normally, and optionally return something else?

frank sparrow
#

how would i be able to update a shader from 2017, i copied a shader and need to update it to unity 2021

lavish sierra
# frank sparrow how could i check that, is that the wireframe?

Yeah. But also if you are making a fishing boat game just use this https://www.youtube.com/watch?v=PtI9LYfx1Dc.

Zii

50% off The Dev Days of Summer sale on the Asset Store, for a limited time: https://prf.hn/l/dlR3glw

  • Unity has a great water system in the boat attack project, and i'll show you how to import it to your URP project.

Boat Attack (Github) : https://github.com/Unity-Technologies/BoatAttack

Don't forget to like and subscribe for more videos lik...

▶ Play video
#

unless you are set on spending your time getting that shader working, this tutorial should take you like 10 minutes and your game will be better for it

frank sparrow
frank sparrow
mental bone
lavish sierra
#

basically, the game engine is trying to save your resources by not unnecessarily rendering the water in edit mode when you don't need to. It should be fine in play mode, and/or if you zoom in close to edit stuff.

#

you can try unchecking dynamic clipping here though

#

and/or changing the clipping planes

ebon moss
grizzled bolt
stoic heath
#

Hey can anyone help me finding where I can use a smoothness map? I only see a 1 vector value and nothing else

#

chatgpt tells me i find the setting on the material inspector tab but there is none

karmic hatch
karmic hatch
# mint berry I tried this setup

It could be that the intensity value set in your material is 0 and the one for your shader isn't?

Also put the emission intensity into the emission node, otherwise I think the node is pointless (plus, color output is exp(HDR intensity)*color, not intensity*color; you can pick the intensity so it's the same but the former makes it easier to access a wide range of brightness effects)

grizzled bolt
mint berry
vale spruce
#

anyone here know any tutorial that teach how to make light mode for built-in shader?

grizzled bolt
mint berry
#

the scene is no diffrent

#

the material preview changed

#

the preview in the asset folder

#

lol

#

it did work now

#

Thanksssss

mint berry
mint berry
#

@grizzled bolt you always come and save the day idk you are like magic xd

vale spruce
#

wait, I mean light mode like, foward, forwardadd, deferred, meta, showdowcaster

#

or is that the same?

meager pelican
#

For unlit, maybe this? https://www.youtube.com/watch?v=4XfXOEDzBx4
You want to make your own light mode? Like add one? Or you "just" want to know what those passes do?

Lets explore how to build diffuse lighting onto our meshes. This is intended as somewhat of an introduction to some of the magic behind shaders.

There are two types of shaders you will typically create a in Unity. The first is the Standard Surface Shader. These are very Unity specific ...

▶ Play video
vale spruce
#

I want to disable a pass on on shader, if I click something on my custom shader GUI
and Material.SetShaderPassEnabled only work based on light mode

meager pelican
vale spruce
meager pelican
#

IDK, never tried it. Something to attempt....

vale spruce
#

from what I know you can't exclude a pass using #pragma shader_feature

meager pelican
#

Yeah, IDK if you can you have #ifs at that level. But otherwise it could be something like

  Pass YesFoo
#else
  Pass NoFoo
#endif```
But IDK if that will work.

I suppose the other option is to use conditional compilation within the pass and return a non-result/unaltered-result/discard in some cases.
solar pelican
#

Is there a way with a fullscreen shader(s) to set the z buffer to filled only where the stencil buffer = 0, and clear the z buffer where the stencil buffer != 0?

stoic heath
#

Hey i have a pretty stupid beginner question: I get that the fragment decides for every pixel what the color should be. But how does it know which pixel i mean when the metallic input only uses one value?

#

Metallic can only be 0...1 float value as far as i know. How does it know that I only want the top right white part be 1?

regal stag
stoic heath
#

Ohhh the UV0 refers to the UV of the mesh where I use the shader on?

regal stag
# solar pelican Is there a way with a fullscreen shader(s) to set the z buffer to filled only wh...

You'd likely need to draw the fullscreen quad/triangle yourself rather than relying on cmd.Blit or similar functions as they don't set/use the depth target.
If by "z buffer to filled" you mean set to a specific value, you'd also need two passes as you can't read the stencil directly in the shader. Have one with Stencil Comp Equal, and another with NotEqual.
Have fragment output to SV_Depth to set the depth buffer value to 1 (or 0 in other pass). Should use #if UNITY_REVERSED_Z and 1-z to make sure it fills/clears on any platform.
If you mean left as it is, only need one pass with Comp NotEqual.

stoic heath
quartz wasp
#

is "snoise" a built in hlsl function in unity

regal stag
quartz wasp
#

ok. Im working on a new project with other people with an snoise function. I was just wondering whether i should be looking for it in unity or in the project itself

frank sparrow
# regal stag You'd likely need to draw the fullscreen quad/triangle yourself rather than rely...

sorry to ping you like this but i saw you mentioned that you used catlikecoding's gerstner wave and recreated it. ive tried to follow that guide twice and recreate it as well as copying the shader and pasting into my unity project and having no luck as both times i recreated it it didnt function as the webpage showed even with the same inputs and when i copied the shader it was pink and didnt work. i was wondering if anything similar happened to you and if you had a solution to it, thank you

quartz wasp
#

ty though

regal stag
frank sparrow
regal stag
#

A shadergraph will work yes. Well, assuming it's targetting the same pipeline in the Graph Settings.

frank sparrow
regal stag
#

The magenta previews might also be something different though. Possibly dividing by zero or using negative values in a Power node for example

frank sparrow
regal stag
frank sparrow
#

ah crap thank you, is the meshes scale just the scale in the inspector

#

plus is there a way i can convert the copied shader to urp?

regal stag
regal stag
solar pelican
frank sparrow
regal stag
solar pelican
regal stag
regal stag
# frank sparrow object space, is that bad?

Not really. I can't remember what the tutorial uses but I tend to apply the waves in world space then transform back to object (as that's the space the vertex stage output requires)
Either would work. Just depends if you want the waves to scale when you scale the plane or not.

lone crow
#

I am having trouble understanding this combo. I somewhat know what scene depth does but idk how subtracting the A value ( idk what A represents here ) of the scene position leads to the effect seen in water shader and stuff.

#

Literally every tutorial just go like 'put this into this and you acheive the effect' and none told how it works.

#

I tried asking gpt but the response was as of 2017 there is no screen position node in shader graph

karmic hatch
quartz wasp
#

is there an (easy) way to get the UV of a frame of an animation? Trying to apply a UV dependant shader to an animation

regal stag
regal stag
quartz wasp
#

yeah

#

sorry shouldve specified

stoic heath
#

Hey can anyone point me to a good guide about shaders that gives me a strong fundamental knowledge of what I need? I'm fine with just using the shader graph but I would want to actually understand what is happening so I can write more complex shaders

#

Or should I stay at the unity documentation?

pale apex
#

Anyone know a good shader for hair? I'm running into a issue using the standard shader for hair.

marsh dust
#

I have a dynamically created mesh which is simply an extruded triangle - it has 5 faces. 1 top, 3 sides, 1 bottom.

I assigned the top face one material, 3 sides another, and bottom another.

I would now like to add a shader that is visible on top of every face, kind of like an enchantment in Minecraft.

How could I do this?

#

My materials will change depending on circumstances. I want the shader to work on any mesh with any materials!

marsh dust
#

Huh it seems like just adding a material as a component should work for my purposes... (Dragging it from assets works so probably will from code also..!)

stoic heath
#

Hey can you manipulate the vertices position independently from the mesh's scale?

#

I scaled my mesh 100 units. But now when I move the vertices in the shader by 1 unit everything gets moved 100 units

lunar valley
marsh dust
stoic heath
stoic heath
marsh dust
#

Sorry I am not very familiar with Unity specifically so I am not 100% if this is available, but if there is a mesh edit mode (where you can move the points/lines/faces), then scaling the object by the points in this edit mode would keep the units consistent!

fathom crane
vale spruce
#

should I also include

Pass
{
    Tags
    { "LightMode" = "Meta" }
}

on gpu intancing shader?

vale spruce
#

is there vector3 for shader property?

vocal narwhal
vale spruce
#

I see... ok thx

vale spruce
#

difference between #ifdef and #if define()?

lone crow
# regal stag ThePinkPanzer basically covered it above, but I'll also link my depth post in ca...

Wow this explanation is very good. But I still have some questions about Screen Position Node. Like what do the RGBA values of the split node represent when screen position node is connected to it?

Lets assume that the R G B values represent the screen position of each vertex and A represent the depth of the vertex from the camera. That means A is the depth value. Alright. Now Scene Depth node utilizes the depth texture which is basically a black grey white texture where each pixel represent the depth of the vertex behind it. So the way it works is, for each and every vertex of the object, We are subtracting the depth of the scene behind this vertex ( which could be rock under water or anything under our transparent material ) from the depth of this vertex ( A value of the screen position node ). Which will give us the distance between the background and our object. Is this the how it works? Or I got it all wrogn?

vale spruce
#

do we have sign function in shader?

#

built-in shader only have floor? no ceil?

regal stag
vale spruce
#

or maybe anyone?

regal stag
#

They are equivalent if using a single keyword

#

With just #if, you can use && and || though so check multiple

vale spruce
#

I see thanks!

regal stag
# lone crow Wow this explanation is very good. But I still have some questions about Screen ...

Basically yes. Though as we are in the fragment stage it's not really dealing with vertices, but the fragments/pixels. But their positions are interpolated from the vertices.

what do the RGBA values of the split node represent
What the values represent depends on the mode on the Screen Position node. There is some explanations in the docs - https://docs.unity3d.com/Packages/com.unity.shadergraph@14.0/manual/Screen-Position-Node.html
In this case Raw mode gives access to the clip space position, which happens to include the depth as the W/A component based on how the projection matrix works.
You can get the same depth value a different way if you prefer, (also mentioned in my post) - using the Position node set to View space, Split, take Z/B axis and Negate.

pliant lodge
#

I have two realtime lights on my url lit shader in opposite direction, I'm generating the UVs from worldspace, all the normal maps are in tangent space in my shader. what am I messing up here?

regal stag
#

Oh if you're using worldspace UVs the tangent space conversion will be incorrect

#

If the texture is projected from only one axis should just need to Swizzle the normal map sample a bit iirc

pliant lodge
#

ah I think I got it, I had a unpack normals node before my normal input

#

yeah, I feel it's not yet correct

regal stag
#

If you set the Sample Texture 2D node to "Normal" mode it should do that automatically but either works

pliant lodge
#

in one direction the light looks fine, in the other direction it looks inverted

lone crow
regal stag
# pliant lodge

If the texture projection is worldspace XZ projection, I'd use a Swizzle node on the normal output with "xzy". Change the normal output space in Graph Settings to World and connect that swizzled normal to the master stack.

tight phoenix
#

I am having an issue with my wireframe shader - in theory the ddx ddy are supposed to make it so each wireframe edge is a uniform width on the screen but for some reason certain edges are thicker than others and I havent been able to determine or solve why this is the case

#

is there a known reason why this is occuring? an unsolved problem?

#

this is where I got the code for the fixed width

tight phoenix
#

studying it more carefully I see I made tons of mistakes in turning their code into nodes

#

working as expected after re-writing it all

grizzled meadow
#

u

onyx talon
#

How can I modify the tangent vector by using a normal map?

regal ivy
#

I'm a lil rusty. What was the way to isolate each uv tile? Or at least a group, like a column or a line

regal ivy
lunar valley
young marten
#

Are subgraph property implemented as uniform?

hollow wolf
#

#pragma exclude_renderers gles gles3 glcore, why did my shadergraph autogenerate this? and isnt this basically make opengls graphic api didnt render the shader?

regal stag
hollow wolf
#

hmm, i create shader but it didnt render in VR using opengsl and when MSAA is active, so i thought this was the problem

marsh dust
#
Material effectOverlayMaterial = Instantiate(GameAssets.effectsOverlay);
float randomHurtValue = Util.getRandomFloat();
effectOverlayMaterial.SetFloat("hurt", randomHurtValue);

Why does my SetFloat not get set in the shader? Am I doing it wrong? Here's how my URP Lit Shader Graph looks like!

marsh dust
regal stag
marsh dust
#

Ohhh! Right, thank you! I forgot about that!

regal ivy
#

I'm trying to make each square have a different color for the whole panning duration. Any ideas?

marsh dust
regal stag
regal ivy
regal stag
regal ivy
#

you are saying I feed in the fraction andthe pixelate effect node group the continuous UV?

#

This is what I got so far

regal stag
#

So that you have both

#

A little messy, but something like this

regal ivy
#

Altho the preview is the exact same result

regal stag
#

As the divide node in your screenshot?

regal ivy
regal stag
#

Might look similar but that one doesn't have the same offsets

regal ivy
#

ohhh

#

ok I see it

#

It worked

regal stag
#

Oh right, should be fine. The values are all above 1 so will display as fully yellow/red but they are different. When put through the Random Range you should get different coloured squares

regal ivy
tight phoenix
#

"Inline" shader question 🤔
Is there a way to do a local outline-within-the-bounds-of-the-mesh of a mesh without relying on a depth texture? I want to use it on a transparent material which doesn't write to depth.
It doesn't have to be outside the mesh like a real outline, but I am not finding many resources on google how to achieve 'inlines'

#

like what unity does when you select a mesh, except inside overlaping the polygons rather than relying on any kind of extrusion trickery

#

I assume surface normals will be involved in some way UnityChanThink

#

maybe if I google normal-space outline perhaps

lavish sierra
#

why don't you just use a camera with a rendertexture for those and use that as a "depth" texture to do your outlines?

#

bonus: the highlighted item can be the sole thing rendered there, making this super easy to do

tight phoenix
lavish sierra
#

you're not rendering the entire screen...

tight phoenix
#

k

lavish sierra
#

so was your intent to get help or be a snark?

tight phoenix
#

my intent was to get it done with the surface normals and not a render camera

#

render camera doesnt meet my use case

lavish sierra
#

so you want a toon shader or an inverted hull, it's not helpful to say "like what unity does" in that case, because that's not how you get object outlines that ignore internal geometry

#

so what do you actually want?

tight phoenix
#

I think my question as written was pretty clear

#

inline shader

#

opposite of an outline

#

Rendering overtop of the mesh itself an 'outline' that doesnt require any screenspace trickery

#

or cameras

#

Can't find the answer on google because inline just refers to functions and outline just refers to screenspace camera stuff which is 1000% not what I am trying to do

lavish sierra
#

that image has an outline of a certain kind

#

but what you are asking for looks like this

#

note that internal geometry is being outlined as well here

#

so you are asking for different things with your words vs your examples

lavish sierra
#

just trying to make sure you don't spend a ton of time on this just to end up with a look you don't want

lament scarab
#

Hi, I'm getting this error when trying to build, with a Unity shader that seemed fine in editor:

Shader error in 'Custom/Snow': 'mul': no matching 2 parameter intrinsic function

I provided the entire code, the mul with the issue is on hastebin line 140.
https://hastebin.com/share/aqoxocuyuj.csharp

regal stag
uneven schooner
lament scarab
regal ivy
#

Is Keywords Enum made for code use or there's a way to use it in the ShaderGraph itself?

regal stag
regal ivy
#

Seems like the enum value will influence which float it will pull from. I guess that's it. 🤦‍♂️

smoky widget
#

Hi

#

So, I have some small issues. I'm using a command buffer to schedule the call of diferent commands and dispatch diferent compute shaders

#

Some of those handle append buffers

#

The problem I'm having is scheduling the right amount of threads for the compute shaders that make use of the append buffers

#

My current solution is copy the counter value of the computebuffer into another compute buffer, get data and the counter, and use that, but I don't like that solution

#

Is there a better option to schedule append buffers, or should I dispatch according to the maximum length of the compute buffer always and make use of the counter value on the compute shader itself to skip the threads that pass the count amount

#

Aha! I can use a compute buffer with the arguments set there, perfecct

river lintel
#

is there any shader graph basic tutorials from youtube or udemy or some site?
I just wanted to learn basics of shader graph
Im new to shader graph.

vale spruce
#

why I can't disable shadow caster pass, but I can disable Always lightmode pass?

#

ok nvm, this scam function only work on Always light mode pass only notlikethis

tacit parcel
late dust
#

So I imported a gltf from blender into unity and it got it like 70% of the way there, but everything looks like it got covered in ashes (It's mirage from CSGO). Any Idea what might be doing that?

compact adder
#

Does anyone have/know a good sharpen shader

#

That sharpens the imagr

misty ginkgo
#

Howdy pardners! I'm just doing some fun little projects to learn, and one of them is making a 52 card deck of auto populating and numbering cards, but TextMeshPro is giving me grief. The TextMeshPro shader is set to Distance Field (which I understand to be the correct shader to make it behave like an object in the scene?) but it renders above the card back, which is a sprite renderer with a texture on it. I've tried setting the sorting layer, but this makes the text just vanish (I think it's being culled) when the card is viewed from a slight angle. The issue shows itself as all numbers showing through all cards, even when the cards are offset on the Z axis from each other...
How to I make the text behave in the scene like any other object?

hushed silo
#

Hi!

I am trying to see if I can get a portal-y effect within shadergraph only, without editing in a stencil tag so that I can use it with VFX graph.

Essentially what I want to know, is how can I set an alpha only when it's intersecting a plane or such... or maybe is within a cone eminating from a vector or something

fossil cloak
#

@regal stag
Hello! Im struggling with my shader for a while now 😄
I want to have a hover effect on my gameobjects. i get this to work now, but my problem is, that the hover effect looks always different based on the color of the albedo of the GO.
That means, that the hover color have less effect on dark colored GOs and more effect on bright GOs.
Do you have a smart idea how to solve this?
I already tried to overwrite the GOs albedo with a flat color, but that doesnt look great.

regal ivy
fossil cloak
vale spruce
#

how do you do vertex animation on built in unlit shader?

#

I just want a simple animation now of grass moving left and right

fossil cloak
regal ivy
#

Happens whenever you just apply an semi-transparent color over the albedo color of the texture

#

You can also use a “mask” to not pass the albedo color and pass only the hover color

#

But without seeing your node setup, it’s not easy to help

young marten
#

How do I read SpriteRenderer.color in shadergraph?

vocal narwhal
young marten
#

thanks

gloomy fractal
#

is this normal? first time messing with the shader graph. it seems like this appears after i add the "Transform node"

smoky widget
#

I need to add diferent append compute buffers

#

Im currently dispatching this shader

#
StructuredBuffer<uint> _Origin;
AppendStructuredBuffer<uint> _Target;
StructuredBuffer<uint> Count;
[numthreads(128,1,1)]
void CopyIndices(uint3 id: SV_DISPATCHTHREADID){
    if(id.x < Count[0]){
        uint index = _Origin[id.x];
        _Target.Append(index);
    }    
}
#

But this adds up

#

Any idea on how I could do this faster

severe crystal
#

How can i make my Textures on here?

lavish sierra
fossil cloak
waxen verge
#

Hello eveyone,

I'm actually trying to do a shader in URP but there is a problem with my preview in my scene. In my preview my fresnel effet is on the top of my cue but in my scene the effect is dependant of my camera and I d'ont know why :/ There is a screen of my shader and the view i got in my scene.

severe crystal
# fossil cloak ?

As you see the material is pink. then i changed it to lit from the urp shader. now its just gray, but the things like the base (rgb) normalmap and so on arent right and i want the textures on the material

fossil cloak
#

Then you grab the texture and drag it into the right place in the material

severe crystal
#

But where do i drag it in? I mean the textures cant be dragged anywhere with the lit shader in use

severe crystal
#

I can put them on the base map but thats not how it should be

fossil cloak
#

You can put the Base (RGB) Alpha (A) from your screenshot into the albedo of the urp shader

#

The other two are not compatible with the standard unity shader i think.
I dont know what Trans (RGB) could be.

fossil cloak
severe crystal
fossil cloak
severe crystal
#

I dont think that is the tree xD

waxen verge
#

@fossil cloak I need it for later because I want to do a dissolve shader for the center to the edge on the top of my cube, that's why I put position node

severe crystal
#

That should be tree base and leaves

#

But on it doesnt gets splitted ig

fossil cloak
fossil cloak
severe crystal
#

ah seen it

waxen verge
#

@fossil cloak something like this

severe crystal
#

Nice but there are these little planes

fossil cloak
severe crystal
#

They are a lil more away but not everything

#

Very blurry now flushedhide

#

And buggy asf

severe crystal
#

Turning out Specular Lightning

#

Now you can change the smoothness and metallic without changing the planes

karmic hatch
#

If you just want a radial pattern like that, you can just take the (x,y) components in object space (using a swizzle or split -> combine or split -> Vector2 node) and then take the length of that

#

(alternatively I think you can plug (0,0,1) into the view direction slot and it should give the same result)

waxen verge
#

@karmic hatch Thanks a lot ! 🙂

karmic hatch
#

np :)

gentle shale
#

Quick question!! Is there any way to turn off culling on the Standard Unity Shader?

smoky widget
#

I need to add diferent append compute buffers
Im currently dispatching this shader

StructuredBuffer<uint> _Origin;
AppendStructuredBuffer<uint> _Target;
StructuredBuffer<uint> Count;
[numthreads(128,1,1)]
void CopyIndices(uint3 id: SV_DISPATCHTHREADID){
    if(id.x < Count[0]){
        uint index = _Origin[id.x];
        _Target.Append(index);
    }    
}

But this adds up

#

Any idea on how I could do this faster

#

I just need to add append buffers

fossil cloak
#

Hello, i wrote a shadergraph shader, that uses dithering for some kind of transparency. If looks fine for me:
But for my collegue on his mac, its completly broken.
We already gave it to someone else, its fine for him too. Is there something weird with dither and macs?
Also the Material preview is damaged.. 😄
(first image is how it should look like)

fossil cloak
#

@grizzled bolt - What is this emoji? 😄

grizzled bolt
fossil cloak
grizzled bolt
tardy needle
#

just got started messing with shader graphs, and I'm wondering what would be the best way to get an input texture and change its hue, saturation, brightness and contrast values before outputting it into the final product. using URP.

tardy needle
#

right, I saw all of those minus brightness, but how can I combine them back into the final image?

#

to be honest I'm not even sure if I'm doing the first part right

regal stag
# tardy needle to be honest I'm not even sure if I'm doing the first part right

It may be helpful to assign a texture to the property ("Default" field in the Node Settings tab while property is selected). As well as play with the vector4 or swap out for Sliders temporarily to visualise what the nodes are doing.
You likely want to chain the Hue/Saturation/Contrast nodes together.
Though it might also be easier (and more performant) to swap it out for a Colorspace Conversion. Something like: Linear->HSV, Add or Subtract to offset values and convert back HSV->Linear.

tardy needle
#

by chaining them together do you mean getting the output from one into the input of the next?

#

alright, that seems to have worked. cheers.

#

one last question: I'm trying to apply the alpha values of my model's vertex paint to the final product. what kind of node would I need for something like that?

regal stag
#

Vertex Color -> Split -> A would give you the alpha component of the vertex paint

tardy needle
#

seems to have done it. perfect!

lapis grove
#

Hello all; I'm looking to do a full-screen effect for a transition where I basically take a screenshot of the current screen, overlay that over top of everything while I change the scene in the back, then I would like to split the overlay image into cubes of uniform size, and have each cube "do something" like turn while and fade to transparent in turn, sort of like a cascade effect.

Sorry if this is a dumb question, but is a shader on the overlaid texture a good way to achieve this? If so, are there any simple examples I can look at that could get me started learning what I'd need to know to build such a thing? Not looking for complete hand holding but I'm not even familiar enough with shadery-stuff to know the right terms to use when searching 😄

vocal narwhal
lavish sierra
lapis grove
#

Thank you; mostly what I needed was a guidance on "direction". I found a lot of scene transition stuff that was really basic, so doing an overlay isn't complicated and i'm not new to coding at all. If a shader isn't the right tool then I guess this isn't my excuse to start learning those 😄

ebon moss
rare wren
#

Maybe with the new fullscreen shader graph if it's a full screen effect

ebon moss
rare wren
#

Everything is possible. Might need some custom nodes, but it's probably possible.
No guarantees tho

ebon moss
#

any resources you reccomend where I could learn how to do this?

rare wren
#

There also are tutorials etc on how to get these lines in Unity, maybe just a different way

ebon moss
#

yeah, I actually have speed lines like these already, the issue is I want the shader specifically, like the wind like gradient pattern

rare wren
#

If you use particles or existing shaders you could change the color on those as well instead of rewriting everything.
But for shader graph look around google and youtube

ebon moss
#

ok, thanks!

ebon moss
rare wren
#

Yes

#

2022.3 has it for both

#

Use the full screen effect on your URP renderer and put the material there

ebon moss
#

ok, thanks

oblique gazelle
#

anyone knows why my shader from shader graph is white in build? in editor it works and displays fine, in build it's all white

#

here is the shader

severe crystal
restive cobalt
#

How do I add 2d shadow caster component to a tilemap and get it working? right now I think it just thinks the whole layer is one solid block, here are some screenshots:
first one is without it enabled, second one is with it enables

#

the tilemap has a tilemap collider 2d component so I'm thinking its something to do with that.

restive cobalt
#

nevermind, I found out that theres no such thing for tilemaps

civic onyx
#

Hi Guys,

#

to achieve this kind of wave lines, which nodes should i use in Unity Shader Graph?

#

this is wave pattern with distortion in Blender node setup

karmic hatch
grizzled bolt
#

There is no such node out of the box
Blender uses saw or sine wave math on object space position for the stripes, offset by a 3D noise for the distortion
Unity's default noises are all 2D

karmic hatch
#

It is fairly easy to install 3D simplex noise (or use 2D noise at a different angle to the wavevector so they align and dealign in different ways)

civic onyx
#

this is what i am able to do, but i want the strip thickness to be changeable with outer input factor.

civic onyx
#

this is how i achieved this, but is there any better way?

dim hemlock
#

Hey guys, does anyone know why my decal is casting this dark, square projection when normal blend is > 0?

karmic hatch
civic onyx
#

with this setup

#

i am able to obtain this result

#

but how can i fix the stretching? is it possible to use triplanar kind of thing here?

amber saffron
#

Best would be to use a 3D noise, but shadergraph don't have any, and you will have to grab it from somewhere or do it yourself

civic onyx
#

actually i am new in unity node system, so i am not familiar with what particular node will be useful here,, 3D noise? but We can make our own 3d noise in Shader graph by using Sample noise and applying position node to it, wouldnt it work?

amber saffron
civic onyx
#

thanks, let me take a look

#

did this guy wrote code to made these noises?

amber saffron
civic onyx
#

its difficult for me to understand the workflow here, i will try for triplanar projection, will update any progress, if happens from here...

#

looks like i have to split the axis and rejoin them and blend the lines back.

amber saffron
civic onyx
#

ok, I will study the above workflow system then, thanks.

civic onyx
#

with perlin 3d noise, the stretching has been removed, thanks alot remy, one last question is, is this subgraph mobile optimized? i have no experience of coding and its code is 220+ lines.

amber saffron
regal ivy
#

I'm having a problem where shader graph is all buggy and can't connect nodes that should be able to connect

regal stag
regal ivy
regal stag
regal ivy
regal stag
regal ivy
#

Like so

proper halo
#

whenever i try to put a material (with a custom shader) to a plane (or any other object), it does alot of errors like these, when it goes up to 285 it delays every time it makes a error

lone crow
#

I want to apply a fresnel outline to my model but Idk why its not showing up.

amber saffron
lone crow
#

What can be the approach to solve the issue though. Like am I supposed to create a outline texture then multiply with some color and put it into the emission?

lone crow
#

It kinda works now but there is another problem I am facing.

I have two parts of the shader, first part creates the outline using a texture I created.
Second part add intersections using scene depth node.

To show both of them at the same time, the output of both parts should be added and then plugged into the alpha.

But the individual parts work and when I add both of them, the final result doesn't.

karmic hatch
#

if it goes negative then it'll break everything

#

might be natural to take the maximum value too

#

yeah here you can see it's subtracting from the texture value until it reaches zero at which point it just becomes transparent

#

(probably best is to take the max value though, that way when the texture and edge detection parts are both lighting up it doesn't make it double-bright)

lone crow
#

So this means, as of now the output of OneMinus node may have negative values which when supplied directly into the alpha give acceptable results as any value less than 0 is basically 0. But when these negative values are added to the output of the texture node then they cause some of the positive values to drop down to zero and hence removing the effect of texture at some places?

karmic hatch
#

yes exactly

#

in general if you think your value might go outside the required range, it's good to saturate it and that way it doesn't do anything unwanted

lone crow
#

Makes sense. I clamped the output of OneMinus Node and it works perfectly as intended now.

#

Thanks

shadow locust
ebon moss
late dust
#

So how would I go about taking a model with a bunch of separate parts with separate textures on it, and baking them all into a single texture for the entire model?

royal widget
#

Shader Graph Transparency Issue

robust stone
#

I made this shader with the stencil buffer that can render objects like a portal, it works fine as i want, except the portal gets drawn over everything. Even at the back of the portal you can kinda see with the colors I provided. Also shared the settings I'm using in the URP render features I made but I tried and this is the best for me, only thing is that rendering on top. I know transparent objects have something with the depth buffer that is messed up, is there a way around this so that that green thing and the red ball will be drawn on top instead of behind?

Thanks in advance!

(Also I made two render features that load the objects normally and I switch between the correct ones with code and triggers inside the portal gameobject so don't worry about that)

EDIT: I fixed it already. I just changed the Render Overworld Objects Normal from a stencil overwrite to a depth overwrite, set to less.

charred cedar
#

Hello!
I have made this "Fog" Shader Graph, and for some reason it's obstructing light coming off other sprites in my scene.
As you can see, the "stars" each have a light attached to them, but when I use the Shader Material, it's obstructing them.

#

These are my Material and Shader Graphs:

#

I am new to these so I apologize if it's an obvious issue

#

I tried to set the Shader to "Lit" and "Unlit", no change was visible. I am also certain the sorting order of the stars is higher than that of the fog

#

Any idea what it could be?

#

Thanks in advance:) < 3

grizzled bolt
#

Are the lights 2D lights?

charred cedar
charred cedar
grizzled bolt
#

Otherwise it might not work with sprite sorting at all

charred cedar
#

Yeaah

#

I believe sprite sorting is working fine

#

I tested it

#

Only the light is getting obstructed

#

But I'll try to use a,Sprite Graph and see if it fixes it

#

Thanks!:D

blissful oak
#

I need some help with a build issue. I have a simple shader graph that contains a custom function that simply takes a colour (and world position) & finds the shadow attenuation for it. This works great in the Editor, but when I build the player it doesn't show the shadows (DX11 & DX12). I presume this is to do with the boolean keywords for main light shadows being stripped? But I have no idea how to confirm this or fix it.

rare wren
#

Does anyone know how to get the point/spot light position in shader graph (via custom hlsl)

waxen verge
#

Hello everyone, i'm trying to do a URP shader to change the skin of a cube but in a particular way.

Actually, i'm using Position > Polar coordinates > Split (R) > Step, to get a circle on the top of my cube that can shrink or grow but i'm actually stuck for the rest cause of the growing is not like I want. It's probably something about UV but I don't what I need to do 😅

Do someone have an idea to help me ? Thanks ! 🙂

regal stag
#

For the sides I'd probably Step the Y coordinate of the Position

#

Could use vertical axis of UVs instead but depends how it's unwrapped then

waxen verge
#

So I need to use 2 shader, one for the top and one for the edges ?
Or use particular UVs on my cube with what i have actually ?

regal stag
#

Whether you need specific UVs depends if you base calculations off the UV node or Position. In the above you're already using the Position, might be fine to stick with that.

waxen verge
#

@regal stag ok I tried the comparison node and it's look very usefull in my case, I understand more what you explain to me . Actually i'm trying to get the circle that can grow only on the top of my cube

waxen verge
#

@regal stag I actually do this, so the shader is only on the top of my cube, the top face is black if < 0, white between 0 and 1, and white on the side if > 0. how can i get back the circle pattern in this case ? Do i need to use a texture or something like that ?

regal ivy
waxen verge
#

@regal ivy the fact is i don't know how to manage a normal vector + my polar cordinates nodes to get a circle on the face 🥲

regal ivy
#

So, the key here is that Normal Vector of the Object shows us the face direction values, independant of the object's rotation, because it is in object space.

#

So, in this case, using Normal Vector (Object) I split into XYZW(RGBA) and isolated the Y(G). The face up is the only face that has a Y(G) value of 1. So, using the comparison, I compared the normal vectors' Y(G) values that are greater (redundant) or equals to 1.

#

I notice there's a weird behaviour when rotating the cube, where the circle disappears. Replace the comparison value from 1 to a number >= 0.5 and < 1. I don't know why this happens tho

waxen verge
#

I was doing this and i'm gonna ask you if it was the good way to get the effect x)
Thanks a lot for this and for your explanations

i'm going to try to do the second part of the shader now, thanks a lot 🙂

waxen verge
#

@regal ivy I do this for the second part ( sliding from to to bottom on the edges, and it's works, now I have to connect them. Does it's looks good ?

regal stag
waxen verge
#

@regal stag Done 🙂

waxen verge
#

@regal stag Here is what i've done, I restored the rotate because i can't get the white from top to down with a value from 0 to 1. I don't know if it's the good way to mix the effects but it works ^^' Now I gonna try to put some color on this

lavish sierra
#

This graph ^ doesn't make any sense to me

#

well, mostly the part where position is piped to a uv input and rotated

#

looks like a convoluted and somewhat unsupported way to get the y-coord out for comparison?

#

I would just use (object pos. + split node) to get y and then remap (using the object min/max y) to get 0 to 1

polar stone
#

Is here ayone with a advanced monke brain that can tell me how to make a procedural cristal shader for 2D work? Im kinda new to shaders and dont fully get the concept...

stark flare
#

Hi everyones, i would like to know if its possible to take the main hdrp lit shader and make a variation with a rotation in the triplanar options. Is it possible?

stark flare
# frigid jay Everything is possible 🙂

Yeah i know everythings is possible and sky and beyond is the limit ahah, but is it possible to start from the existent shader of hdrp lit, or I need to recreate the shadergraph? Im still new to the shadergraph.

frigid jay
stark flare
raw frigate
#

hey guys

#

i got a colour map texture

#

and the base map texture

#

and basically, id like to apply the colour maps colours

#

onto the base map texture

#

how can i do this

frigid jay
raw frigate
#

how do i first colour the colour map texture?

#

like for example, how do i change the green... to some other colour

frigid jay
raw frigate
#

and then apply the colour map to the base map to change the colour of hte object

#

so like imagine a character, wearing some clothing

#

id like to change the colour of his clothes

#

with the colour map

regal stag
# raw frigate

I'd probably put the colour map R output into the T of a Lerp node. Set A to white and B to primary colour.
Put result into the A port on another Lerp with colour map G in T port and secondary colour in B port.
Then Multiply with base map.

raw frigate
#

that worked lol

#

how you think of this stuff in ur head is quite amazing

long lotus
#

A question regarding shader speed:
I'm applying a gradient to the top and bottom of an image.
I was doing this with an if-else to check the y value in the frag() block

    // bottom gradient
    c = lerp(float4(0, 0, 0, c.a), c, (IN.vertexWorld.y - _GradBottomYMin) / (_GradBottomYMax - _GradBottomYMin));
}
else if (IN.vertexWorld.y > _GradTopYMin) {
    // top gradient
    c = lerp(float4(0, 0, 0, c.a), c, (_GradTopYMax - IN.vertexWorld.y) / (_GradTopYMax - _GradTopYMin));
}```
I replaced this with some step() shenanigans instead
```fixed top = step(_GradTopYMin, IN.vertexWorld.y);
fixed bottom = step(IN.vertexWorld.y, _GradBottomYMax);
fixed middle = step(IN.vertexWorld.y, _GradTopYMin) * step(_GradBottomYMax, IN.vertexWorld.y);

// carbuncle of steps
fixed4 col =
    (top * lerp(float4(0, 0, 0, c.a), c, (_GradTopYMax - IN.vertexWorld.y) / (_GradTopYMax - _GradTopYMin)))
    +
    (bottom * lerp(float4(0, 0, 0, c.a), c, (IN.vertexWorld.y - _GradBottomYMin) / (_GradBottomYMax - _GradBottomYMin)))
    +
    (middle * c);```
I'm not sure which is better.
Is branching bad enough to justify using step() and just executing everything in those branches?
reef mango
#

Is it possible to create custom passes in the builtin pipeline?

regal stag
# long lotus A question regarding shader speed: I'm applying a gradient to the top and bottom...

Afaik branching isn't really that bad, especially if nearby pixels take the same branch which they'd probably do here. But you could add [Flatten] before the if statement to hint to the compiler not to branch if that's what you want to avoid. (Though I think that only works on some platforms)
Turning everything to steps works, but is probably messier. There's also ternaries (bool ? a : b) which always flattens too but probably not that much different.
If you really want to know which performs better you'll likely need to try them and profile (with something like Renderdoc)

reef mango
frigid jay
cunning herald
#

Hey everyone. How can I open code of a shader made with shadergraph and save changes in it? As I see "view generated shader" doesn't allow to save changes

regal stag
long lotus
reef mango
#

in the unity documentation theres a page with lots of shader examples for the builtin pipeline. I cant find such a handy list of examples for URP

brave osprey
#

How can I acheive the desired effect in shadergraph? I want the alpha to ignore the semi-transparent areas. I was able to acheive this in a custom shader, but the sprite lit shader in shadergraph does not have an alpha thershold option, and I cant find any resources to help me with my issue. How can I just add alpha thershold to sprite lit in Shader Graph?

stoic heath
#

im currently learning about shaders and i go with the code approach since im already a professional programmer. It involves...soooo....much math. I didn't have this kind of math in school that i need except for basic stuff. Does anyone has good resources online where I learn 99% of the stuff that i need math related. Vector Mathematik, Trigonometry and Linear Algebra...smth else?

#

I heard Khan Academy is the way to go

#

Or maybe a more pratical approach would be to learn as you go?

brave osprey
#

Im very close to discovering my own solution. Ive created this custom node in shader graph, but why is it coming out as blurry/soft edges? Any idea?

frigid jay
regal stag
regal stag
brave osprey
#

Ah the legendary Cyan. Thank you. Now i can go back to my project ❤️ You were right ;D I had to set it to point

reef mango
reef mango
#

im using normal from height in URP shader graph and the normals are being lit by a light that is being occluded by the mesh

weary dawn
#
Shader "Custom/InvertColours"
{
        SubShader
    {
        Tags { "RenderPipeline" = "UniversalPipeline"}
        LOD 100
        ZWrite Off Cull Off
        Pass
        {
            Name "ColorBlitPass"

            HLSLPROGRAM
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"

            #pragma vertex Vert
            #pragma fragment frag
            
            TEXTURE2D_X(_CameraOpaqueTexture);
            SAMPLER(sampler_CameraOpaqueTexture);

            half4 frag (Varyings input) : SV_Target
            {
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
                half4 color = SAMPLE_TEXTURE2D_X(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, input.texcoord);
                return color;
            }
            ENDHLSL
        }
    }
}``` Why does this shader result in full grey in URP? The render pass seems to work fine if I leave the color as is.
#
        CommandBuffer cmd = CommandBufferPool.Get();
        
        Blitter.BlitCameraTexture(cmd, m_CameraColorTarget, m_CameraColorTarget, material, 0);
        
        
        // Execute the command buffer
        context.ExecuteCommandBuffer(cmd);
        cmd.Clear();
        CommandBufferPool.Release(cmd);```
#

I'm using this to call the Blit, and I'm doing the stage at the BeforePostProcessing RenderPass event

#

(Also if anyone knows any good docs for this stuff please let me know the unity docs suck for this)

regal stag
cyan abyss
#

I have a water shader. I want the screen to get bluer when the player submerges under the water. What is the best way to go about it? Should I just place some postprocessing volume under the water plane that turns the screen blue? Or are there more efficient ways?

lavish sierra
#

Depends on what else is going on in your game and how it is set up

#

perhaps you have a light and you can just change its hue

brazen nimbus
#

Hello ! I'm looking to modify the basic HDRP Lit shader (Unity 2023) in HLSL in order to modify the saturation of every materials that I used with this shader.

I'm very new to this so I used ChatGPT at first but it doesn't seems to work and looks like sometimes, it's erasing the code I'm writing when I'm saving. Any helps on that please ?

Here is what ChatGPT Suggested to me.
Here is what I've done in the shader.
Here is the result (nothing changed) in the properties.

Thanks in advance for your help !

weary dawn
stray rune
meager pelican
# cyan abyss I have a water shader. I want the screen to get bluer when the player submerges ...

Do you want to "split" the screen if they're 1/2 way under water...so only the bottom is blue? OR
Do you want the entire screen to simply have a blue tinge to it?

If the latter, you can apply a post processing effect as you mention...or the alternative is for ALL the shaders/materials for ALL the objects to add a blue tint, maybe from a shader global. That way you only draw things once, and that's your answer to efficiency. You could also possibly add a Y-height conditional to compute the "above/below" value of your water plane, but without more calcs you won't deal with the waves properly. Similar to "unity fog".

But you may find that a post-processing effect's impact is negligible.

stray rune
weary dawn
#

Also, is this true for the Blitter API as well?

When rendering we need to make sure we do not read and write to the same texture/target as this can cause “unintended behaviour” I see this being done A LOT in unity examples.

regal stag
weary dawn
#

With the camera colour thing, is it because the _BlitTexture uses texels etc that I can't read from it?

#

How should I be reading the camera colour?

regal stag
#

If you just want to apply affects to the screen there's also the Fullscreen Pass Renderer Feature that URP provides in 2022.2+. It's designed with the Fullscreen graph in mind but that kind of shader should still work with it

weary dawn
#
            half4 frag (Varyings input) : SV_Target {
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
                float4 color = SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_PointClamp, input.texcoord);
                return float4(1,0,0,1);
            }```
#

Changing it to that

#

Yields this, so the shader is running properly

#

(Original scene, for ref)

quartz wasp
#

how expensive is modifying a float in a shader material via script? Should I bother only doing it when it changes, or is it so trivial that its fine to do every frame?

quartz wasp
#

ok thanks

mental bone
quartz wasp
#

the game im working on is not the type to be super performance intensive, so my biggest priority is gonna be bigger performance bottlenecks.

weary dawn
#

Does anyone have any insight on accessing the colour or depth texture inside a Blitter.BlitCamera... Shader?

fleet olive
#

why cant i change the output nodes of a subgraph

#

its a vector4 but i need it to be a float

#

nvm

#

why, despite the lerp displaying a blue image the main preview is pink

#

hdrp

#

its not exactly a complex shader

regal stag
fleet olive
#

ok

#

no longer pink but my shader is a little off

#

its supposed to be having a a constant depth visibility

#

but moving camera position does not work with that

#

turning the camera acts as normal but moving up and down distorts the texture in a way i did not expect

weary dawn
#
            SAMPLER(sampler_BlitTexture);


            half4 frag (Varyings IN) : SV_Target {
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
                float depth = SampleSceneDepth(IN.texcoord);
                float4 color = SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_BlitTexture, IN.texcoord);
                return 1 - color;
            }```
#

An intermediary rthandle seems to help fix the invert shader in game view, but the scene viewer is still really strangely affected:

regal stag
weary dawn
#

Game view looks like this

regal stag
#

That I'm not sure about

#

Is HDR disabled on the URP asset maybe? That might cause game view to use LDR textures (already clamped between 0-1). While scene view might always be HDR

weary dawn
#

Saturate seemed to fix it, is it a HDR thing?

#

I'll take a look

weary dawn
#

Let me try remove saturate and disable

#

HDR Off: Scene view is fine

#

HDR ON: Scene view is broken unless saturate is used.

#

Some google searches doesn't seem to reveal much about why scene view would be like this, other than some other people complaining about bugs with HDR appearing only in scene or game view and not the other.

regal stag
#

Hm well, not sure why game view isn't affected as well without the saturate. Probably makes sense to keep using saturate to remove negative values here.

weary dawn
#

Maybe game view just clamps those values itself, but honestly who knows.

reef mango
#

@regal stag can you read a texture at a supplied UV (not a UV on a vertex or fragment) in shader graph?

regal stag
reef mango
#

@regal stag excellent. thank you

#

@regal stag if i sample a texture at a bunch of locations (10 or so) how do i get the smallest value sampled ?

reef mango
#

@regal stag is there a way to pass an array of floats to shader graph?

regal stag
regal stag
reef mango
#

cool. thanks

regal stag
#

Please also ask your questions to the whole channel and not @ me directly

reef mango
#

ok sorry

weary dawn
#

Is there any way to quickly decompile shader graph nodes to look at what it's doing under the hood?

low lichen
weary dawn
#

But thanks, that's a good tip

low lichen
#

I'm not finding a node that doesn't have the "Generated Code Example" section.

weary dawn
#

Also, quick question should I be using HLSLPROGRAM or CGPROGRAM

#

Good practice seems to be hlsl according to wiki, but most examples I see are CG

low lichen
#

For URP/HDRP, you should be using HLSLPROGRAM. Either way, it's all HLSL, but if you use CGPROGRAM, Unity will automatically include some functions and types that are found in CG, which you don't need for URP/HDRP.

low lichen
weary dawn
#

We can define our own output struct for the Vert shader right?

#

We don't need to use Varyings specifically?

low lichen
#

I don't think URP or HDRP has any built-in Varyings that you can use, it's always redefined per shader. So you can use any name, but might as well use Varyings to match all the other shaders.

weary dawn
#

I haven't defined it myself

weary dawn
low lichen
weary dawn
#

Though the compiled code just seems mostly assembly, impossible to read

low lichen
weary dawn
#

Apologies, and thanks

weary dawn
#

Is there any way to make my view direction work well in scene view? It's currently basically completely broken

#

Scene view

#

Game view

#

Colours clipping and wrapping again? I guess.

#

Saturate fixed it in any case

carmine spear
#

I have a material in shader graph and I want to make it render in multi-pass or it wont render in VR otherwise. Is there a way of changing the render mode of an individual object without affecting the entire project in project settings (to benifit from single-pass instanced performance)

cloud fog
#

Is there an easy way for shadows to be pixelated rather than having smooth edges?

young heron
#

I'm trying to add the option to replace a solid color with another in a standard shader code. However, all features eventually stop. Can anyone who knows shader help?

late dust
#

So how would I go about baking multiple textures into one? Like I have an object that uses a bunch of different textures, but I want to merge them all into one single texture so that when I export it, I only need to apply a single texture image to it

grizzled bolt
late dust
grizzled bolt
late dust
grizzled bolt
tight phoenix
#

I am having a problem getting direction in a shader.
I am trying to get the direction between the camera and the object, direction = destination - origin (right?)
But in my scene, every single mesh moves the same direction, even though every object should have different world space positions

#

is object position node not in world space? or am I doing something wrong elsewhere? Where is my mistake?

#

expected output is different direction vectors depending on thje direction btween the object and the camera

#

but the output im getting is the same direction for every single object, even though the camera position is clearly smack dab in the center of them

#

all of this is xy

#

what I really want to do is get the Orthographic camera's XYZ position, the object's XYZ position, and use that to move the vertexes in shader to give paralax based on the difference between the mesh's Z position in world space, and world 0

#

in a direction relative from the mesh to the camera, to get paralax depth

#

NOT from the vertexes individually but from the object as a whole

#

im adding the direction from cam to object to the verts but all objects move the same direction and that makes no sense

#

also they flip the fuck out based on my editor camera? Which makes no sense because editor camera is not sampled anywhere in the shader at any point

#

nor is view angle or literally any variable at all other than the vec3 being passed in

#

why would any of this cause random positional flickering

#

I dont understand and I cant debug it

uncut inlet
#

Why do my textures look like this when i sample them

grizzled bolt
uncut inlet
#

this is what the original looks like

grizzled bolt
#

I expect because there's no texture alpha plugged to Fragment Alpha input

civic onyx
#

Hi Guys, is it possible to design this kind of lines distorted in Unity Shade Graph complete procedurally or i should use some external textures as well?

cosmic prairie
#

an idea would be to draw lines along the UV of the mesh and distort the UV with a noise texture applied

#

a seamless noise texture is required or if you want the full procedural route you can use the gradient noise node or the other noises

civic onyx
#

I have 3d Perlin Noise Shader Graph, Should i just import a wave pattern texture and distort it?

cosmic prairie
#

by wave pattern you mean straight lines?

civic onyx
#

by the way, what are look up textures?

#

Yes, Straight black and white lines.

cosmic prairie
#

so in this case the data is the noise

civic onyx
#

oh ok.

cosmic prairie
#

noise, especially 3d perlin is expensive

civic onyx
#

3d perlin is expensive for mobile games?

cosmic prairie
cosmic prairie
civic onyx
#

it was a code of subgraph written by some developer, i didnt knew, this would be issue, because i already used it for a texture, let me share that here, but it hasnt been tested yet in the mobile device

cosmic prairie
#

testing it would be wise, but I have a feeling it's not a good idea

#

I mean the usage of it

civic onyx
#

got it.

reef mango
#

im struggling with the scene depth node. It seems to return a binary value. everything is either black or white.

civic onyx
#

this is 3d Perlin noise Based Texture.

reef mango
split oyster
#

How do I read texture values from a shader to my mono c# script

#

?

cosmic prairie
split oyster
#

I wanna read values from my inspector

cosmic prairie
#

You wanna split the scene into parts and you wanna debug that?

#

You gave me 3 seemingly unrelated things and I'm not sure what you want to tie together and how

#

because there's no simple way of just reading an output of a shader

split oyster
#

@cosmic prairie are you still there?

neat shore
#

Does anyone know how to read and map a gradient in HLSL? Trying to make a toon shader with the shading controlled by gradient. How can I plug a gradient and read from it in a custom HLSL function in shadergraph?

steady carbon
#

Hello, how can i make the shader graph material to fit the sprites shape ? Right now it looks like this

vocal narwhal
steady carbon
vocal narwhal
steady carbon
vocal narwhal
#

it should be using the one designed for sprites, there is a lit version of that

steady carbon
steady carbon
#

and animations also doesn't work when i apply the shader graph material

#

i can see the changing animation sprites in the sprite rendere but i can't see them in the scene

vocal narwhal
#

Are you animations doing sprite swapping via the sprite renderer? If so you're probably not using the correct name for your texture

steady carbon
vocal narwhal
#

It should be set as an exposed property and called MainTex