#archived-shaders

1 messages ยท Page 71 of 1

viscid knoll
#

You can sample camera base color in URP, it is SceneColor Node to use with ScreenUV, then blur it (as written property, i don't remember the name, do you@amber saffron?)

#

the best approach is to pre - blur the cameracolortarget into RenderFeature, you can produce better blurred "cameracolor", set the blurred texture as Global Texture and hop into the shader

amber saffron
#

then blur it
URP doesn't implement mipmap for scene color like in HDRP, so it's not as easy to blur it. So indeed, you either need to pre-blur, or do a multi tap box blur directly in the shader.

Or just don't care if you only need to distord and not blur ๐Ÿ™‚

viscid knoll
#

the way I would have blur in the shader, it is by sampling it multiple time to offset the ScreeUV (old school)

#

you can sample just 4 time, mulpliying the result and dividing it by the number of textures, whith a little shift in the ScreenUV x or y of each sampled texture(if Lรฉa you need a fast solution it may be easier to do this way), it's less good than the RenderFeature solution however, because if you make a blur by UI element like my exemple: if you have multiple UI element you will have many time the same calculation for each UIelement (per materials), so it's better if all this materials use the same Blurred buffer like by using a renderfeature

mental bone
#

is the Object->Screen Transform node equivelent of doing UnityObjectToClipPos ?

pastel oracle
#

Hello,
is it possible to divide the texture by input colors via shadergraph? For example the texture will have only two colors red and blue and I would like to divide the texture into a part where there are only red pixels and then a part where there are only blue pixels. Next step will be applying adjustments to these parts separately and then merge them together. Thanks a lot! ๐Ÿ™‚

regal stag
pastel oracle
regal stag
# pastel oracle Ohh, thats true (facepalm ๐Ÿ˜„ ) and it is possible to somehow divide another spec...

Obviously there's the green and alpha channels too. But for other colours it would be a bit more complicated. There's a Color Mask node which can work. For many colours the distance checks that node does might get costly, another option is using various shades in one channel, as the x coordinate for sampling a gradient/palette texture.
This post has some related info - https://www.cyanilux.com/tutorials/color-swap/

pastel oracle
olive sorrel
#

Someone plz help me, while editing a shader graph the object turned into a default asset and can't be edited or reimported. Ive tried copying, reimporting & reinstalling shader graph idk what to do

#

I can open it but nothing can be edited to fix

mental bone
#

I am somehow utterly failing to recreate this simple vert shader in shadergraph ```v2f vert ( appdata v )
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);

            float4 unityObjectToClipPos = UnityObjectToClipPos( v.vertex.xyz );
            float4 vertTransform = (float4(v.texcoord1.xy, (unityObjectToClipPos).zw));
            
            float2 newUV = ( (unityObjectToClipPos).xy + float2( 0.5,0.5 ) );
            o.texcoord1.xy = newUV;
        
            //setting value to unused interpolator channels and avoid initialization warnings
            o.texcoord1.w = 0;
            float3 vertexValue = float3(0, 0, 0);
            
            vertexValue = ( (vertTransform * float4( 2,-2,1,0 ) ) + float4( -1,1,0,0 ) ).xyz;
            o.vertex = float4(vertexValue.xyz,1);


            return o;
        }```  This is my attempt to recreate UnityObjectToClipPos
spiral swallow
#

Hi guys, can someone help me with a shader thing ? I know nothing about shaders, and tech art in general, but I would like to give it a try...

So, I would like to create an animated texture in pixel art, frame by frame from a spritesheet, and here is my difficulty : I would like to make it so I could put the texture on any sprite, any shape, any size, without my texture being distorted or stretched, and I would like to try adding a zoom parameter so I can adjust my texture to the sprite too...

I already tried a few things, but nothing worked...

regal stag
# mental bone I am somehow utterly failing to recreate this simple vert shader in shadergraph ...

There should be a "ViewProjection" option on the Transformation Matrix node iirc. Just that connected to the A port on the Multiply should do. Model matrix is already taken into account as the Position node is set to World space.
Or could probably use a custom function node to call TransformWorldToHClip

But note that you'll also need to do the inverse after calculating the output position. o.vertex expects clipspace, while shadergraph's Position output in the vertex stage expects Object.

broken sinew
#

sorry, do you have a git repo for the project*

#

if so, check what changed

#

does the asset have the .shadergraph extension?
does asset file contain correct data? (is it perhaps truncated and is 0 bytes now?)

mental bone
mental bone
echo briar
#

What should be the proper way to implement spencil on my shader ?

#

I just want my UI images to have their own material but also work with UI masking

olive sorrel
#

I had to remake everything

broken sinew
#

but have you inspected the content?

#

are you using git?

broken sinew
#

if you don't use git you should start, because loosing your assets is never fun

broken sinew
#

funny thing I noticed:
shaderlab mentions Integer property type to be preferred over legacy Int, but Integer doesn't work when used for properties such as _Cull mode

#

For example in my material property block I have [Enum(UnityEngine.Rendering.CullMode)] _Cull("Cull", Integer) = 0 and later in subshader Cull [_Cull]. Changing value in material inspector doesn't change a thing, but when Int is used instead, it works properly

#

what's the deal with that?

low lichen
broken sinew
#

yeah, sadly it's not documented anywhere and it's pretty bad that Int is marked as legacy in the docs, while it is the only thing that works. I wonder how many people had problems with it and didn't even realize...

low lichen
#

Int is just another name for a float property.

tacit hearth
#

Anyone know a node i can feed that Step into to convert those dots to squares?

cursive jewel
#

Hai,
I made an image effect(full camera) shader in 2D URP, It's working fine with sprites. But it's not working with UI elements.. I want it to affect entire screen including UI.

tacit parcel
floral kayak
#

I think it's a shader thing-- why is this model glowing so hard? It's a .fbx converted in Blender from .gbl for the purpose of making a VRChat avatar, and the .gbl doesn't glow at all

#

oh. the fbx has a sun for some reason

#

nevermind. deleted the sun

amber saffron
junior copper
#

how would you make "speed lines" ?

#

particles ? line renderer ? material ?

#

the view is always from top if this can simplify (like on the right screen)

amber saffron
junior copper
amber saffron
junior copper
#

ok ty

steep spindle
#

is this possible with shader graph urp ? if so how could I do it
I want to make all canvas elements that overlap with my sprite(the box with black outline) to be grayscaled

edgy crane
boreal condor
#

Just curious, are there good free alternatives to VHS Pro? Like on github or Unity forums.

mental bone
#

At this point I think shadergraphis screwing with me... This is the vs code I'm trying to re-implement in it ``` v2f vert ( appdata v )
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);

            float4 unityObjectToClipPos = UnityObjectToClipPos( v.vertex.xyz );
            float4 vertTransform = (float4(v.texcoord1.xy, (unityObjectToClipPos).zw));
            
            float2 newUV = ( (unityObjectToClipPos).xy + float2( 0.5,0.5 ) );
            o.texcoord1.xy = newUV;

            float3 vertexValue = ( (vertTransform * float4( 2,-2,1,0 ) ) + float4( -1,1,0,0 ) ).xyz;
            o.vertex = float4(vertexValue.xyz,1);


            return o;
        }``` and this is the graph so far. For some reason they dont work the same
#

The decal is being rendered via a command buffer as such ``` public static void RenderDecal(Renderer r, Material projector, Vector3 position, Quaternion rotation, Vector2 size, float depth = 0.5f, string textureName = defaultTextureName) {
// Only can draw on skinned meshes.
if (!(r is SkinnedMeshRenderer) /&& !(r is MeshRenderer)/) {
return;
}

        if (!r.TryGetComponent(out MonoBehaviourHider.DecalableInfo info)) {
            info = r.gameObject.AddComponent<MonoBehaviourHider.DecalableInfo>();
            info.Initialize();
        }
        // Could use a Matrix4x4.Perspective instead! depends on use case.
        Matrix4x4 projection = Matrix4x4.Ortho(-size.x, size.x, -size.y, size.y, 0f, depth);
        Matrix4x4 view = Matrix4x4.Inverse(Matrix4x4.TRS(position, rotation, new Vector3(1, 1, -1)));
        
        // We just queue up the commands, paintdecal will send them all together when its ready.
        instance.commandBuffer.Clear();
        instance.commandBuffer.SetViewProjectionMatrices(view, projection);
        info.Render(instance.commandBuffer, projector, textureName,projection,view);
     
        Graphics.ExecuteCommandBuffer(instance.commandBuffer);
    }```
steep spindle
mental bone
amber saffron
mental bone
junior copper
#

how can i fix this ?

amber saffron
junior copper
#

i didnt add any keywords

#

how can I edit the keywords ?

amber saffron
#

You shouldn't have to care for this one.
Worst case, it's only a warning and you could ignore it ?

mental bone
pastel oracle
#

Hello,
I'm sorry, I probably have a stupid question, but I've started making shaders lately. When I have a fragment shader in code version where inside frag function is every pixel modified by the following steps:
-> if the alpha of a pixel is greater than the specified threshold, the alpha is set to the max. value
-> on the other hand, if the alpha of a pixel is less than the threshold the alpha is set to 0

            fixed4 frag(v2f i) : SV_Target {
                fixed4 pixelColor = tex2D(_MainTex, i.uv);
                float opacity = pixelColor.a;
                float3 color_withoutAlpha = (pixelColor.rgb - ((1.0-opacity) * background.rgb)) / opacity;

                if(opacity >=0.5){
                    pixelColor = fixed4(color_withoutAlpha.x, color_withoutAlpha.y, color_withoutAlpha.z, 1); 
                }
                else{
                    pixelColor = fixed4(color_withoutAlpha.x, color_withoutAlpha.y, color_withoutAlpha.z, 0);
                }
                return pixelColor;
            }

Is it possible to create this procedure in a shader graph? Thank you! ๐Ÿ™‚

amber saffron
exotic willow
amber saffron
# exotic willow

The output of "Sine Time" is in the -1;1 range, resulting in negative color values, this is what causing the effect.
Connect a remap node between the time and mutliply, set from to (-1;1) and to to (0,1)

#

You could also use an absolute node instead, but it will make the color animation different

junior copper
#

but i also got another issue with it, transparency.

I know that unity struggle to hide/show transparent objects when they are in front each other

#

the thing is, i only got one transparent material, that is applied to one mesh. And i have the issue.

it seems that my sprite renderer placed in BG in considered as a "transparent BG"

#

but its opaque

#

what should i change to make it "not transparent" ?

grizzled bolt
junior copper
#

3D

junior copper
#

when I disable the Image comp the issue is fixed

#

so i think the sprite is considered as a transparent object, conflicting with my plane

exotic willow
#

i forget if i have reply ping turned on, sorry if i didnt

amber saffron
rancid crystal
#

I set intensity with code:
GetComponent<Renderer>().materials[0].SetColor("_EmissionColor", randomColorHSV * Mathf.Pow(2, 2));
However, why am I unable to observe any alterations in the scene?

amber saffron
mental bone
#

Hmmmmm so the docs say this about setviewprojectionmatrices โ€œThis function is compatible with the Built-in Render Pipeline. It is not compatible with the Universal Render Pipeline (URP), the High Definition Render Pipeline (HDRP), or custom Scriptable Render Pipelines.โ€ Soโ€ฆ because the hand written shader is a old CG shader it worksโ€ฆ but not for a shader graph shader.

#

I suppose

mental bone
karmic hatch
# rancid crystal

Turn on bloom if you don't have it, otherwise high intensity just makes things white/higher saturation

lime spade
#

So I'm using a Compute Shader that implements Raymarching to simulate liquids with a bunch of physics spheres. It works fine, but it draws over everything in my scene. Is there a way to make things drawn by the ComputeShader render with depth in relation to the rest of the scene?

viscid knoll
#

did workaround reprojection too few days ago, I had to code my own Unlit, also don't forget GL.Pushmatrix (to push your matrix) and GL.Popmatrix (to restore default)

#

note in custom pass api now, its far more easy to handle that case (i work hdrp), we have renderfromcamera() and if custom matrix, no need for GL too

junior copper
#

the 100 sprite is a circle, but it doesnt look like it on the sprite renderer

#

the main goal is to avoid having the red circles cuted

#

since i didnt found a good way of doing this in the shader graph im trying to achieve this in the sprite renderer

grizzled bolt
junior copper
#

the goal is to have a circle outline

#

using Full rect would have the same issue

#

why is the outline correct when unity uses "Sprites-Default" but not others ?

crimson cape
#

Does anyone custom TextMeshPro shader? I want to custom the Text to has both outer and inner shadow but fail to twist the code cause the lack of shader understanding ๐Ÿ˜”

crimson cape
#

I can change use it now, but anyone know how to add new properties and show to editor? I add Properties in script but nothing happen in editor :<<

rancid crystal
#

I don't know why but It fixed with changing priority of material

mental bone
chilly robin
#

Shader newbie, trying to make a mesh to terrain blending shader. Would this be the correct way to get the textures from the Terrain layers?

#

Setup nodes like this, then pass TerrainData from script?

#

Just curious if there is better way to do it or not

cosmic prairie
#

draw it before transparents too so it stays inside the bottle

cosmic prairie
cosmic prairie
#

if you create a custom outline you can make your red outline fit inside the 3D model

cosmic prairie
#

it has writing to the depthbuffer part

waxen grove
#

Hi there, what's a good way to create "water fog"?

#

I was thinking of using the depth of the camera to create said fog, but I am unsure of how it would work

I'm trying to copy how Half Life 2 did it's water shading

viscid knoll
#

Note Uri : HDRP Custom Renderers Pass shader is a single Pass shader that won't draw in the sceneview if you draw to a buffer, so you will need to redraw it into your scene view too

#

you can use the ShaderTagId to draw only this shader's pass
var MyPass = new ShaderTagId("MyPassName"); ShaderTagId[] shaderPasses = new ShaderTagId[] { MyPass };

#

as CustomPassUtils.RenderFromCamera() and CoreUtils.DrawRendererList() can both specify a shaderPass to draw it's usefull, it avoid using layermask to render special stuff

crimson cape
junior copper
grizzled bolt
grizzled bolt
mental bone
#

Thing is I am doing a one off render to a RT, I dont have anything to render each frame with this system @viscid knoll

edgy crane
#

Hey there,

I have an animated pixel art character. I wish to pixelate the look of the character through a shader (to keep my pixels the correct size as I modify the scale to apply some squash and stretch) . I guess its due to a bad flooring logic (?) but any help would be much appreciated ^^

A: the shader
B: look with
C: Look without

edgy crane
grizzled bolt
# edgy crane

Perhaps you are flooring the exact interesections of the pixels rather than pixels themselves, resulting in ambiguity
Anyway, why pixelate a sprite that's already pixelated?

edgy crane
grizzled bolt
edgy crane
grizzled bolt
edgy crane
grizzled bolt
edgy crane
grizzled bolt
edgy crane
lucid perch
#

hi this might be the wrong channel but i dont know where to ask.
so im trying to make a game looking like a short hike with its 3d pixel look. i managed to get this flat colors but i have no idea how to get the pixel look. i saw this tutorial on yt: https://www.youtube.com/watch?v=1f76ajrdPYc
which is using rendertextures for this, but i have no idea where to add the texture

Wishlist on steam here: https://store.steampowered.com/app/1797850/Goodlands/

Here's how to get that 'A Short Hike' 3D pixel art look -- this is from GOODLANDS, my upcoming indie game where you play as a paleontologist prospecting for fossils in environments inspired by the Montana badlands. Explore a tightly curated open world while interactin...

โ–ถ Play video
edgy crane
grizzled bolt
edgy crane
grizzled bolt
edgy crane
edgy crane
lucid perch
#

but ty i try

chilly robin
#

Asking again, but is this the proper way to set up textures from the terrain layers? Just trying to get the first pass/first 4 textures, but wondering if this could be optimized more?

lucid perch
# edgy crane Taht's exactly it

ok i tried know but somehow my "Camera facing the TV to play from another room" (actual name of the gameobject) isnt rendering the tv like its see through

junior copper
#

how get I get the scale of the object of the parent ?

#

my shader is applied to Plane

grizzled bolt
junior copper
#

so there is no way to get the "real" scale of a object ?

#

because the "real" scale of the object is the scale multiplied by the parents scale

edgy crane
junior copper
#

yup thats what im doing rn

fallow scarab
#

why cant i use my slash shader?

grizzled bolt
fallow scarab
#

had to fix graph settings

lucid perch
remote mauve
#

I'm facing an issue that my shaders do not render (every pixel is just transparent) on very specific small portion of Android devices, they tend to be very old devices, especially reading tablets which presumably aren't made for games. Otherwise the shaders work fine for everyone else. Unfortunately I do not own such a device to be able to reproduce the problem and debug on my own.
One of the shader is as below which is extremely simple, anything obviously wrong?

Shader "Quad" {

    Properties {
        [NoScaleOffset] _MainTex ("Texture", 2D) = "white" {}
    }

    SubShader {
        Tags {
            "RenderType" = "Transparent"
            "Queue" = "Transparent"
        }

        Blend SrcAlpha OneMinusSrcAlpha
        ZWrite off
        Cull off

        Pass {
            CGPROGRAM

            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            sampler2D_float _MainTex;

            struct appdata {
                float4 pos : POSITION;
                float  a   : COLOR0;
                float3 uvq : TEXCOORD0;
            };

            struct v2f {
                float4 pos : SV_POSITION;
                float  a   : COLOR0;
                float3 uvq : TEXCOORD0;
            };

            v2f vert (appdata v) {
                v2f o;
                o.pos = UnityObjectToClipPos(v.pos);
                o.a = v.a;
                o.uvq = v.uvq;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target {
                fixed4 color = tex2Dlod(_MainTex, float4(i.uvq.xy / i.uvq.z, 0, 0));
                color.a *= i.a;
                return color;
            }

            ENDCG
        }
    }
}
sharp silo
#

What is industry standard? 3d modeling software?

solemn moss
sharp silo
#

Maya ?

solemn moss
# sharp silo Maya ?

Autodesk Maya
Blender
Autodesk 3ds Max
ZBrush
Cinema 4D
SketchUp
SolidWorks
Rhino
Autodesk Fusion 360
Modo
Houdini
Substance Designer
Marvelous Designer
Daz Studio
LightWave 3D

#

I think that's all

chilly robin
#

Working on a mesh to terrain blending shader, and I'm having trouble figuring out how to get the normals of the terrain

deep moth
#

From there the process is the same as getting a normal map from a height / bump map.

chilly robin
deep moth
#

no worries! good luck

fleet olive
#

are these two expressions equivalent in hdrp?

#

they should be

#

im trying to find the depth between the camera and the object being rendered

#

i read that either of these work, but the bottom one only works in perspective mode

#

ultimate goal is to create something like this, where the color gets darker with depth

#

but ALSO so that it doesnt change if you move the camera around (which it does with my current setup)

tardy crypt
#

but I wanted to have control over its color and alpha so I made some modifications.

#

However, whenever I try to implement the ability to control the color and alpha from vertex color it's disappearing and giving me issues.

peak mantle
#

Hey there - I fear this will be one of those questions you all see here a lot but I am looking for some quick suggestions on what I can do to fix this. I added URP to an existing project and I believe it's all installed correctly. I'm trying to make my first material for my main character and I have made an unlit sprite shader graph, attached the material to a NEW sprite renderer component and am now looking at the shader graph. I see in tutorials online that people can preview their sprites in the Main Preview window but just keep getting a white box. Additionally my character in the scene is now just a big gray blob with an orange outline.

This is what my shader graph looks like. Any ideas on what the heck is going wrong here?

vocal narwhal
#

So that's what you get

peak mantle
vocal narwhal
peak mantle
grizzled bolt
broken sinew
#

What's the mechanism in URP that is instancing in BRP?

#

batcher?

upbeat charm
#

Hi. I setup a gradient shader graph and it works fine. I now want to expose different gradients as an enum to drive multiple materials from the same shader. I'm kinda stuck on how to link up the enum to a branch to the defined gradients. Is it even possible?

grizzled bolt
junior copper
#

im kinda confused why in shader graphs, all manipulated numbers are between 0 and 1 but RGB colors are between 0 and 255

grizzled bolt
junior copper
#

so why showing 255

grizzled bolt
#

Colo32 is only there for compatibility reasons, I assume
There's no other reason to use it and I'm pretty sure the color picker in 0-255 mode produces a typical normalized Color

grizzled bolt
junior copper
#

ah you can change, never paid atention to this

#

ty, my confusion is cleared

grizzled bolt
#

The color picker cannot change the type of the variable regardless of its mode

#

Note also that the floating point Color is not restricted to normalized 0-1 range, it can go above it

#

But that's useful only in case of HDR colors that have brightnesses above 1

junior copper
#

okay ty

#

and by the way

#

i got this offsetting down using time

how could I make the same effect, but have some "columns" wit hdifferent speeds

#

i have those columns from this

junior copper
#

tiling each columns independtly

#

or having a pattern

#

like ABABABABAB

#

A offsets down and B up

#

for i.e

grizzled bolt
# junior copper A offsets down and B up

If you can find the math for making vertical stripes, you should be able to set their width the same as your horizontal tiling there, and add to vertical UV offset with some multiplier

junior copper
#

looks like the image has a portion only of the material

junior copper
#

how can I extract a specific area in a texture ?

#

for example, if I use a font texture, i select a AxB area to select a character

grizzled bolt
junior copper
grizzled bolt
junior copper
#

okay ill test

broken sinew
#

is there a way to write a hlsl function that takes vector of any dimension? basically I want a single function, for example sdfSphere(float3 p, float R) { return length(p) - R; } without creating a bunch of overloads for float1, float2, ... etc

junior copper
#

i quite dont see how changing colors will help

fossil cloak
#

@grizzled bolt - Do you know how materials behave when changing them at runtime?
When i change my material (not at runtime) every copy of my object changes its color. (so far so good)
When i change it via runtime, it creates an instance right?
But it seems, that when i change it at runtime via code, it changed all materials.

grizzled bolt
#

By always I mean at runtime
Creating material instances out of runtime doesn't make that much sense so I suppose it instead modifies the shared material when it otherwise would create an instance

fossil cloak
peak mantle
#

I'm trying to create a SubGraph and getting this error

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.ShaderGraph.GraphData+GraphConcretization.ConcretizeGraph (UnityEditor.ShaderGraph.GraphData graph) (at ./Library/PackageCache/com.unity.shadergraph@14.0.9/Editor/Data/Graphs/GraphConcretization.cs:33)

Has anyone seen this and have a fix?

#

FWIW I'm on URP and Shader Graph 14.0.9 and Unity 2022.3.13f1

strange berry
#

Hey guys, I need a little help, I've been messing with Shader Graph on my own, trying to get something to work, I didn't find any tutorial specific for what I need, I'll try to explain real quick.
Basically I'm trying to create a shader for a rock that the moss part always stays on top, regardless the rotation

#

I've done this, probably in the eyes of someone who knows what's doing, this is a real mess of nodes

#

I want for example this part to always be mossy

chilly robin
#

Let's learn how to make a cool Snow Shader in Shader Graph!

Check out XMLLayout! https://bit.ly/2VZocbu

โ— The shader is inspired by this amazing video: https://youtu.be/Q43XBychCEY

โ— Mayan Temple pack: http://devassets.com/assets/mayan-temple/

ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท

โ™ฅ Subscribe:...

โ–ถ Play video
strange berry
#

Oh

#

I'll try to follow it, thx

waxen grove
#

Hi... can someone help me add vertical fog to my water shader? This is the current shader code? I'm currently using HLSL, or shader code. However, I'm not sure how to get the scene depth and create a fade effect depending on the depth of the water...

#

Currently I have it all setup to fade, but I can't seem to like, replicate the vertical fog I need, even online

waxen grove
#

Can someone help convert this to what I need:

float fog = saturate((SceneDepth - ScreenPos.a) / 10);

#

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

I'm following this tutorial

In this video, we will learn how to make a depth fade sub-shader in unity.
Depth fade is needed in many water shaders. So knowing how to make one is essential.
You will also learn the basics of sub-shaders.

Download the Sub Shader: https://github.com/GhostStudiosGS/DepthFadeSubShader.git

Subscribe: https://www.youtube.com/c/GhostStudios?sub_c...

โ–ถ Play video
torn root
#

Any idea why does the Tiling And Offset is doing this?

vocal narwhal
torn root
#

now that makes sense, thanks

waxen grove
#

Hey Vertx, can you help me with my issue above?

waxen grove
#

Left: Scene (And what it's supposed to look like)
Right: In Play mode

Why is this happening

grand jolt
#

hi all, im very new here to shaders. are there people here still writing shader code? I have a really simple question. I want to know how mul4 works

grand jolt
#

I am also unsure if this is even hlsl

#

ok, nevermind... I think it is not hlsl

cursive jewel
#

Hi I am trying to create a small outline shader by offsetting same texture and adding color.. instead of getting pure green as outline, I am getting some yellow patches in between.. why is that ??

grand jolt
#

can i add lighting to an unlit shader so that it becomes more performant compared to the surface shader?

grizzled bolt
grand jolt
regal stag
grizzled bolt
grand jolt
cursive jewel
grizzled bolt
grand jolt
#

I see

edgy crane
#

Hi there
I currently have a Dynamic pixel art water script that simulate pos, velocities and acceleration of an array of virtual points. I then convert this array into a Texture2D (I change the red values of each pixel) per frame that I then pass to the shader in order to convert it back to floats. The shader then make the necessary calculations to draw a pixel art wave according to the resulting float arrays. So far so good my system is working. But as I will inevitably increase the number of water spots and their width, I fear the calculations (that are still handled in script so by the cpu) might take a toll on performance.
The simple solution I see with my limited knowledge is to have the shader to the necessary calculations (e.g. modifying acceleration when a collision occur and use euler integration to update velocities and positions). As I understand, I need to pass a buffer (not sure yet what it is exactly tbh) containing these data.

Is this possible ? Is my reasonnng flawed ? Where can I find helpful ressources on how to proceed ?

Cheers ^^

broken sinew
#

hlsl variables can be put in namespaces. For example:

namespace vars {
  float someVar;
}

//... later in shader
float tmp = vars::someVar*2;
  1. Would those variables work as uniforms?
  2. Can those variables be set with material.setFloat and others?
  3. Can those variables be controlled by shaderlab properties? If so, how, what's the syntax?
low lichen
broken sinew
#

namespaces for functions work quite well. Namespaces for variables however...

#

as static consts it seems to function

#

without those modifiers it does not. Glsl compilation fails.

#

shaderlab can't really parse the vars::someVar in the material property block

mental bone
#

How do I essentially sample noise like a clamped texture? Do I just remap the uvs to a 0-1 range ?

amber saffron
mental bone
upbeat charm
meager pelican
#

Put a "real" object in there, like a default cube with a standard shader. Do the stars appear over that?
I suspect, although you didn't specify, that your spheres are transparent and not setting the depth buffer. At any rate you'll have to tell us about the objects as well as the particles.

Particles, although they may not set the depth buffer, they should honor it and not write on something they are "behind".

#

The standard test is LEqual or Less.

#

But what are the depths of the stars?
I would expect that the stars appear over the two spheres...the purple one is "behind" the star sphere, and the red/pink one is contained within such that stars on the near side of the star-sphere are closer.

#

Oh, like a skybox?

#

The camera will draw using a skybox shader between the opaque and transparent passes. This is because transparents must draw over the background. So you should investigate a skybox starfield shader, perhaps rather than VFX. It will be faster.

steel notch
#

So I have a scene here involving realtime lights and 2D sprites. When the sprites are in front of a light source, the side facing away becomes dark. This makes sense. Is there any way though to make it so the sprite reacts to a light the same way regardless of direction?

wild elm
#

Okay so when I import textures for UI they are always brighter than supposed (also creating color banding on the alpha channel). I am using zero compression, and it only happens when I'm using the Linear color space, on gamma everything works as supposed. It seems a big oversight. Let me know if this is the right thread to talk about this!
I've been searching but I didn't find any solution :(
I'll leave here visual examples of what I'm talking about (linear and gamma respectively):

grizzled bolt
steel notch
grizzled bolt
steel notch
#

Right?

grizzled bolt
#

Could be worse

rain parrot
#

Is there a way to ignore partially transparent pixels in shadergraph? I'm trying to recolor this image and I want to ignore the yellow-ish pixels when doing so.

grizzled bolt
steel notch
rain parrot
# steel notch You can do a step node on the alpha and use that as a mask.

That seemed to work, although its now facing the same issue i'm having with my color adjustment shader.

The shader i'm writing is essentially supposed to replace my grass color with another color, and I do that by creating two patterns that I then add together at the end. The step node worked on preventing the edges from getting color added to them. However Its still darkening the edges which makes me think my color multiply node isn't working as intended.

tawny plume
#

im new to unity and im wondering why there isnt a option to add emission textures to terrain layer textures and is there a way around it because i know it has somthing to do with shaders? so could someone help me?

steel notch
#

@regal stag You this Cyan? Using Unity 2022.3.10f

steel notch
#

Crisis averted.

zealous thicket
#

hi all, I'm doing some surface water shader stuff and am using voronoi but it ends up making everything look tiled. Are there any obvious gotchas I'm running into for this sort of thing? I thought the noise would just loop seamlessly

amber hollow
#

what do you use as uv input

#

show nodes

zealous thicket
#

I am using this sub shader, and this is the part where it connects to the voronoi

#

tyvm for taking a look btw, I really appreciate it

#

this is my first time going off-tutorial as they say and I'm very lost ๐Ÿ˜ฆ

#

I can see the split in the preview itself which makes me think my texture movement shader is causing this

#

it looks like even a fresh Tiling And Offset node produces this behavior with the built in voronoi noise node. Switching to 3d Preview I am able to see a noticable split in the default settings.

#

is there some other voronoi node people are using that doesn't produce this behavior?

#

or am I just really misunderstanding what's going on

#

from googling around it turns out that the unity voronoi node is indeed not safe for tiling ๐Ÿ˜ฆ bummer

#

is there a way to invert the grayscale of an image nicely?

steel notch
zealous thicket
#

wow, googling it and the easiest way is actually to just use photoshop... crazy that shader graph is so powerful but not with everything

steel notch
#

And another 40% with noise.

zealous thicket
#

well this problem was actually caused by noise!

#

unity's voronoi generation is not tileable ๐Ÿ˜ฆ

steel notch
zealous thicket
# steel notch If a tileable voronoi exists, couldn't you make a custom node to do it?

Ya that's what I ended up doing, I found a big ol png online and used that. But it was in reverse grayscale from what I wanted hence my follow up questions about negating an image grayscale-wise. And that's when I learned its easier to open an image in gimp and press "invert" and save it out since unity apparently has some real troubles with grayscale inversion

#

So in summary problem solved and my water looks nice

steel notch
zealous thicket
steel notch
#

BIG

zealous thicket
#

Maybe - I tried a lot of different things. I'll try that too just in case it works

steel notch
#

ya one minus on just the RGB (not A) should flip a greyscale.

zealous thicket
#

I'm always happy to learn new stuff in this flow, shaders are so fun

steel notch
#

I think

zealous thicket
#

Let me try! The project is still open

#

well dang! I wonder why I wasn't able to find this by googling around. learn something new every day I suppose!

strange berry
#

Hi guys, I was using the shader graph for some uses and I noticed something. For some reason, if I have shader graph installed in my Unity Project, the standard shaders and others break when i choose cutout. Is there any fixes? Because I'm currently using the standard as well

cursive jewel
#

Hi, I have a sprite of a banner. It's showing different in sample2D.. in original sprite, the alpha is like shown in alpha channel (like shown in black and white)
Why is this causing?

cursive jewel
mental bone
#

Shadergraph nodes do not have alpha in their previews. Make sure to look at your sprite in the scene/game view

waxen grove
#

Right: What it's supposed to look like
Left: What happens at weird angles

Also attached is the shadergraph of the applicable areas. Can anyone help me debug this?

waxen grove
#

If I may add this only affects play mode, not scene view

grizzled bolt
steel notch
grizzled bolt
#

Additionally the Lit Graph for some reason doesn't support Lit shader's features parallax height mapping and detail mapping

steel notch
grizzled bolt
#

"Main light" is the brightest directional light

steel notch
grizzled bolt
steel notch
#

So these two nodes I assume?

grizzled bolt
steel notch
#

If you have multiple directional lights, I assume that gets bundled with Additional? Like you said, it's the "brightest" directional light?

steel notch
# grizzled bolt Combine as in "add separately" yes

So what's the normal behaviour here? Add the Color from the Main Light with the Diffuse of the Additional Lights? How does the Normal fit into this normally? Do I dot product the Main Light color with the normal, and then also feed the normal into the Additional Lights?

#

Sorry for the intensity of the questions here. Just want to get the basics.

grizzled bolt
#

You notice that there is no complete or officially supported workflow to tweak the Lit shader or to recreate it

steel notch
grizzled bolt
grizzled bolt
steel notch
#

wait forgot ambient

#

I think they're the same?

#

Left = Lit Shader
Right = Custom

#

Alright now for the big question. How do I get them to be lit the same regardless of the normal?

grizzled bolt
#

Instead use the attenuatedLightColor directly

steel notch
#

Where is this LightingLambert function defined anyway?

#

I can swap it out easy (or really just create a new function so I dont break these nodes), but I'd like to see what it does.

#

for learning

grizzled bolt
steel notch
#

ya I'm reading the code

grizzled bolt
#

Then you can ctrl + f to find it

steel notch
#

Doesnt seem to be defined in the file that came with the package. Maybe it's defined somewhere else?

steel notch
grizzled bolt
grand jolt
grizzled bolt
# grand jolt how do i get the cone and the position of the light?

You have the position and rotation in the Transform component
You can use a script to pass them into corresponding shader properties
You can get a cone from a direction by getting the dot product of the light transform's forward axis and of the fragment's position
It won't be the exact same as the light component's unless you also pass that data in and remap the result using those, but since you just have one you could define the cone in the shader anyway

#

As a bonus you can map the result to a curve or a gradient to get any kind of nonlinear light shape you want

elder crow
#

I have a HLSL question, is this the right place for it?

grand jolt
#

can you help me a bit with this?

elder crow
#

Right as I was typing it up I rubberducked myself, I have solved it now ๐Ÿ™‚

#

thankyou though

dusky lance
#

How to do this in the shader graph Editor In Unity HDRP ?

steel notch
amber saffron
ebon basin
#

https://i.imgur.com/CfdRikw.png
Trying to make some impossible geometry cubes (similar to the game Antichamber) using stencils and I'm running into a problem where if I were to line up cubes nearby, there are angles where my stencil masks overlap, resulting in the correct pixels not being rendered. I was thinking of some dividers between each cubes using some quads, but I'm not exactly sure of the idea behind setting that up.

#

Some ideas that do work is setting some opaque quads with the masks, but this kinda confines the space to the cube, but in Antichamber, the space itself expands way beyond the cubes sometimes.

#

I can think of other ways too, but this requires using a lot more stencil values / layers but those are greatly limited and I imagine running into other problems that way.

ebon basin
#

Ok, so it seems that doing the stencil testing after I render my opaques does help me limit how much stencil testing is done. Lining the cubes with a secondary opaque border does limit the range which I stencil test, but I would prefer to have this larger divider outside of the cube so I can expand the geometry beyond the cube itself. So, the problem now is that I'm not sure how I create this divider as creating something transparent and writing to depth seems to create a lot of interesting artifacts. Perhaps there's another way to go about this.

#

Or maybe there's another way I should be tackling this depth issue

#

Basically it's more of a rendering order issue, but since you can view the cubes from different angles (from and to different cubes) then doing it by absolute rendering order would be impossible, so it looks like I need some type of depth to limit what is being tested as I can't figure out how to do it with stencils alone.

ebon basin
#

Yeah, not sure. I think there's a lot more masks to be involved which are rendered at different times is my theory. For the most part, it's pretty easy to change what's confined in a space, but when it comes to expanding out that space does it become a problem.

tacit hearth
#

erm, in terms of shader graph:

I use the same effect in a few shaders, and I don't mind duplicating the nodes since it allows me to use shadergraphs without needing any sub-graphs bundled with it.

However, let's say a bunch of nodes generates...1000 lines of code. 2 shaders = 2000 lines, would a sub-graph limit that to 1000 lines? I guess i'm asking if under the hood its more performant to use sub-graphs where possible

tired skiff
#

Hello,
I would like to create a shader to simulate a projectile.
Problem: what if the projectile goes far from the camera view and with a different angle from comera? I need to see them always and don't want to use meshes or particles or trail renderers. I just need a texture that face the camera. i did it with a script but it does not work fine because it always face the camera .
could anyone help me to solve this?

waxen grove
#

Please, I have no idea what's going on

zealous thicket
#

hey fam what's a good way to blend two colors together into some sort of gradiant?

#

if I lerp between two colors and give it a ratio between a value and the y coords in world space I get a harsh line but I'm looking for something blend-y

#

I want this but, like, blendy

untold otter
#

you could split a uv node

#

oh i thinkn i understood wrong

cursive jewel
#

Hi friends, I am creating a drop shadow shader, the shadow part works fine.
(Offsetting uv and adding shadow color)
I need to add softness/spread to the shadow.
.
What would be the easiest way to do this?

feral granite
#

Hi, is there a LightMode in shader pass tag named "DepthNormals"? I have been reading the Docs but cant find anything about it

#

I know there is a "DepthNormalsOnly", but this one shader im reading has a Lightmode named "DepthNormals" might be a typo?

#

Oh wait there is one in the Lit.shader

#

WUT

civic lantern
#

Or InverseLerp, or Remap+Saturate

vital token
#

Hi, so I have a ShaderGraph that creates my water texture, it's ripples, etc. The thing is, idk why, but it doesn't export to mobile. I've built to my Samsung S23+ plus multiple times and I JUST realized the shader isn't showing up at all, although in the game view in Unity, the shader shows up and is correct.
Maybe it's because I'm using URP? I'm not sure. I have no experience with shaders and no clue where to start when it comes to troubleshooting

#

This is my water on my phone. It seems the shaders solid color is showing, with its alpha value. But the voronoi noise I'm using for the ripples isn't working/showing

grizzled bolt
jolly orbit
#

Guys I'm trying to achieve this effect (top face borders of voxels lit up)

Here is what I've got so far (2nd pic), I am passing vec2s through UV channel, but the blending is pretty bad rn. I am using shader graph, **do you guys have any tips how I could blend it better? ** I just want little part if the edge to be highlighted like in the first pic

#

Rn it's just UV -> split node to get x & y components -> vector2 -> length -> to lerp T

#

maybe just create img texture and use that instead?

fossil cloak
karmic hatch
karmic hatch
zenith canyon
#

Hi, Im trying to make a unlit shader that receives pitch black shadows from other objects. It currently only works with directional lights and I would like advice on how to get it to work with point lights. Thanks

tacit hearth
#

that should apply to the top face only

#

and you can use a Lerp node for the blending I believe

broken sinew
# ebon basin https://i.imgur.com/H4qsrJl.png Something like this but that wall being transpar...

Follow along as we develop this mind-bending illusion using Unity and Blender. Expect to learn about the stencil buffer, transparency, and shaders in Unity. Designed with beginners in mind, this tutorial will walk you through not just the how, but also the why.

Github: https://github.com/PerspiringDeveloper/AntichamberTutorial

00:00 Introducti...

โ–ถ Play video
jolly orbit
regal stag
tired skiff
#

how to make a bilboard effect in shader graph?
I would like a texture that always face to camera. any idea?

grizzled bolt
grand jolt
#

how can i use a vector as a direction in shader coding?? i understood that if i get the dot product between the lightdirection (using the _WorldSpaceLightPos0 variable) and the normals direction, i can get the lighting....now what if i want to use a custom direction without using the _WorldSpaceLightPos0 variable?

tired skiff
amber saffron
amber saffron
tired skiff
#

I'd prefer to avid it because it's just one bullet. so one emission.
and many bullets in the scene

#

In fact I'm looking for a kind of bilboard effect with shader graph

tired skiff
amber saffron
#

Let me draw that real quick.

karmic hatch
tired skiff
grizzled bolt
grand jolt
#

@amber saffron when i am using directional light's direction the shader gets this direction...but when i am using the vector using that same rotation values..it doesn't seem to work...
The vector has same value as the directional light's rotation has

#

this is when it doesn't work

tired skiff
#

and how it could improve performance

grizzled bolt
#

Assuming it's still efficient with graphs of just one particle

amber saffron
#

(it is applied to a quad, that's why Y is used for the Z position)

amber saffron
#

In the transform component, rotation are in "euler angles", that is converted internally to a "quaternion".
You can get the light direction by script using light.transform.forward

grand jolt
# amber saffron Rotation values are not direction

i want to use one single spot light in my unlit shader....someone told me, i have to get the position, its direction and use the dot product to implement the lighting in the lightest way...can i do something like that?

amber saffron
#

But if you want to add shadowing to it, that's an other story

#

Simply using only a single spotlight in the scene isn't enough ?

grand jolt
grand jolt
amber saffron
grand jolt
#

i still have very poor idea on shader and stuffs related to this

amber saffron
#

Ah, yes, sorry, double checking the doc indeed that's what it does, additiona lights are included in the base pass only in case of per vertex lighting

grand jolt
#

i got the idea how i can correspond the rotation of the spot light with the direction of custom light...now i have to know how can i implement the lighting only on the surface covered by the spot light's range

tacit parcel
amber saffron
# grand jolt can you help me more about it?

If you only need a single spotligh for you scene, you can use the Shader.SetGlobal.... apis to set global values shared between shaders, so you won't have to do it per material, and all the objects in the scene will be able to get the light data.
Look at the SpotLight component reference to find the fields you need to pass to the shader. Like I mentioned, you'll need the position, direction, range and cone angle. You can also add inner/outer cone angles for fading, as well as a range rad distance.

grand jolt
tacit parcel
amber saffron
amber saffron
amber saffron
tacit parcel
tired skiff
grizzled bolt
ebon basin
#

Yeah, I've seen those videos, but they solve the issue for one specific case, but the game specifically has quite a few other tricks it does with the cubes and the only thing I can think of is that they have a ref value per side per cube, and are positioning them in ways where they can specifically order the rendering.

ebon basin
#

Or, there is more to stencils you can do providing depth, but with testing it seems that only by rendering opaques (before rendering the masks) between the cubes can I prevent overlapping of masks. But, ideally I'd prefer some way to do it with blending so I don't have to use these giant opaque dividers, but it doesn't seem like writing depth with transparent quads work.

broken sinew
#

stencil buffer has 8 bits, that's 256 possible values. You could try working with data - something like an ID per face + depth buffer to ill stencil with correct values and then compare stencil value per face you want to draw? This certainly doesn't seem like a single-pass kind of thing

ebon basin
# broken sinew stencil buffer has 8 bits, that's 256 possible values. You could try working wit...

I'm doing this with a combination of SRP Render Objects (for more render ordering control and such that I don't need to have to edit shader code per stencil value), but the rendering order is less useful as you can view the cubes in different angles. It seems the best way to go about it is to tie a ref value to each mask (for each side for each cube), which does work, but for some reason the render objects can only use 15 ref values.

#

Actually it would be a combination of ref values and rendering ordering too in that case (basically just render one after another)

#

so both are pretty limited

#

I'd assume I could accomplish this with depth too, but testing a bunch of ways I've gotten a lot of unexpecting renderings artifacts.

#

https://www.ronja-tutorials.com/post/022-stencil-buffers/
Their stencil mask does not blend, nor does it write to depth, and this is similar to many other stencil tutorials.

broken sinew
ebon basin
waxen grove
#

I think I've boiled it down:

If I'm looking west/left of the camera, the effect happens, but NOT when looking right

steep spindle
#

I cant find a single canvas/UI blur shader that would work on URP , is it even possible ? i dont get it
none of them blur UI elements only the game screen that is behind the UI

grizzled bolt
#

URP has no "grab pass" equivalent which is required to create such effects

steep spindle
spark leaf
#

So, I am having some trouble with using a stencil shader in builds for the Quest 3. The intended effect is to reveal an underlying object using stencils. This works in play mode, play mode over Quest Link, and PC builds but does not work in headset android builds. The intended effect looks like the first picture, but in headset the Stencil check just always passes so it looks like the second picture. I have tried changes around settings the depth buffer to 24 bit, making sure depth is enabled in URP settings, changing the graphics API, adding my shader to preloaded shaders, and a bunch of other crap. Pictures of the shader code and the stencil render features are also attached, also most of the relevant settings, not sure what to even try next. Any ideas?

#

Oh, also this is on Unity 2023.2.3, downgrading to 2022.3.20 did not seem to help.

spark leaf
broken sinew
#

hmm, have you tried other android device? I recall that some just... don't support it

spark leaf
#

I could try on Quest 2

#

but yeah, have not tried another device yet

broken sinew
#

in manual GLES you have to explicitly set up GLconfig, enable stencil buffer and set it's size. I guess it shoud be abstracted and handled automatically in some way in Unity but I don't know, maybe it's not?

tight vault
#

Hey, i dont know if this the right channel for this but im having some trouble with some shaders i downloaded working in the editor but not in build. I have basically zero experience with this kind of stuff so even getting them to work in the editor was done through a lot of trial and error and i dont even know if i did it correctly. Any help?

broken sinew
#

Advanced OpenGL blending operations require GLES3.1 AEP+, GL_KHR_blend_equation_advanced, or GL_NV_blend_equation_advanced. They can only be used with standard RGBA blending; they are not compatible with separate RGB and alpha blending.

#

you don't really use BlendOp, but... who knows

heavy plover
#

How can I like smooth out a line with noise in shader?

#

Like I want that cut to be like curved out a bit and act as a mask

grizzled bolt
heavy plover
#

Somethin like this is what I am seeking

odd warren
#

hey! is there a way to put a second material on the same mesh? For example I have a sand material I'd like to put on the ground in this cave, but I can't figure out how it works

#

thank you ::)

vital token
#

The second to last image is my game view in Unity. And the last image is the game on mobile. Why is my shader not working on mobile? The color and transparency is working, but the Voronoi ripples aren't showing and I don't know why

heavy plover
odd warren
#

Where do I see those submeshes? Iโ€™ve imported it but it doesnโ€™t seem to have any? Unless Iโ€™m lost

heavy plover
odd warren
#

No I imported it

#

It might have none indeed

#

Is there a way to create submeshes myself?

broken sinew
heavy plover
odd warren
#

Do I have to cut it in 2 lol

heavy plover
# odd warren Do I have to cut it in 2 lol

Edit the mesh and assign a different material to the faces you want to have a different material in Unity; when importing it back should detect that you have different materials and ask you what material you want on in each material socket

odd warren
#

Ohhh I see, Iโ€™ll try that, thank you!!

heavy plover
heavy plover
broken sinew
#

assuming uv is the coordinate input, you want the output of smoothstep(v+sin(u), ...other params)

heavy plover
broken sinew
#

does it help? (my params: wave shift: 10, wave scale: 0.1, wave shift: -0.3)

vital token
heavy plover
vital token
#

Nope I give up lmao. I've changed all the settings I can, on PC and mobile, can't figure out why the voronoi noise isn't showing on mobile.
I guess my water is just gonna look like shit

heavy plover
vital token
#

I sadly have to learn by doing, I can't just import things and look at them and understand how they work. I have to build it myself to know how it works

prime shale
#

If itโ€™s for mobile that that part isnโ€™t showing up you could just generate a vornoi texture and use that as your vornoi noise in the mobile shader

dusky wedge
#

Hi guys, have a nice day.

I'd like to ask how to get all light source on an object?
I can get the directional light using GetMainLight(), but not Point Light and Spot Light.

rare wren
mental bone
#

Hey guys, It's me again with more questions regarding my gore system. This time I'm trying to wrap my head around the technique described here: https://download.nvidia.com/developer/SDK/Individual_Samples/DEMOS/Direct3D9/src/HLSL_BloodShader/docs/HLSL_BloodShader.pdf
Now I beleive I found the original code since the download link does not work anymore( found it on the unity forums of all places haha) Here it is: https://pastebin.com/XZAr0R7X
Now obviously this is structured as a multipass shader so I'm wondering how to properly implement it in HDRP. As far as I understand we need to write to a texture and then read from it in the second pass. It is not enterely clear how the "Gravity Pass" writes to a texture, but maybe the magic happens from the FX framework. Ideally I would want to do the gravity calcs in a compute shader and then sample the texture in a regular shadergraph shader. However the gravity pass seems to manipulate the vertex position with this line Out.Pos = float4(2*(In.Tex.x-.5) - pSize, -2*(In.Tex.y -.5) + pSize, 0, 1); I'm not sure what this does exacly except that it puts the vertex in uv space maybe but why do we need that in the first place. Also the paper talks about creating a gravity map, but all the code implementation does is transform a grav vector to tangent space and then add it to the normal map. Maybe it is not worth precomputing it. Anyways I'm looking for input on this from smarter people hah.

maiden sluice
#

Hi so I suck at shadergraph and right now for my outline shader it has to be added as a seperate material which it warns is inefficient and it's better to use multiple passes but how do I implement that

mental bone
#

are on URP or HDRP ?

maiden sluice
#

URP

#

and on unity version 2022.3.19f1

regal stag
maiden sluice
#

Ahh ok, I was doing it for items, so it'd only be rendered for a handful

#

and it's only for the targeted item, right now I was using a branch to toggle it but is there a more efficient way of doing it?

tired skiff
amber saffron
tired skiff
#

yes. this is how it looks now.

tired skiff
#

or maybe i tried with wrong ones. which angle would you suggest?

amber saffron
#

In my test scene, rotating the object makes the billboard rotate so that the billboard points toward the object Z

#

Like this.
Or maybe I didn't understand your issue ?

tired skiff
#

the direction of the projectile is ok just with some camera angle view
Now the rotation of projectile it depends on the view with this shader

amber saffron
#

I made this shader so the "forward" of the projectile is the up texture axis

#

So if you change your texture to have a vertical trail, it should be fine

late dust
#

So I converted my project to URP, all the textures were pink (missing), so I selected all my materials and changed them to "Universal Render Pipeline/Simple Lit", and well, they're not pink anymore but the diffuse maps are missing :/

tiny sphinx
#

Hey everyone, I need some advice about using a dissolve shader to make an object disappear - I have an object with a material that uses the "URP Lit" shader. It has base, normal, metallic, etc. textures.

I also have a Dissolve shader that I'm trying to use to make that object dissolve away. It looks a bit like this:

The issue here is that I want the black part of the object to be invisible, but I can't find any tutorials on achieving something like this.

late dust
#

I made a brand new HDRP project with the default preset for it, and it was all missing textures so everything was pink, so I clicked reimport all, and now the scene is just completely missing lol

warm moss
tiny sphinx
# warm moss You need to create a shader graph that has cutoff transparency enabled. Then you...

Thanks for the help. So this is what I have currently. The issue is that I'm very new to shadergraph so wrapping my head around this is... Slow going.

I know I currently have this noise generation which is determining the shape of the dissolve and it's calculated on the Y axis, it's calculating an offset for the edge glow, etc., but the difficulty I'm having now is, either:

Figuring out how I can apply a series of textures to the shader itself (ideally programmatically, taking them from the base material at runtime before swapping the material with this shader), OR

Applying this shader additively to an existing object so that it doesn't render portions of the material underneath.

Can you offer any advice just glancing briefly at my graph? Also I completely understand that at this point I probably don't know what I don't know, and so might not be asking the right questions - Any advice (and patience) you can offer would be really greatly appreciated.

warm moss
#

@tiny sphinx the only practical way is to make your dissolve a subgraph and add it to every shader graph that's used with dissolvable objects.

tiny sphinx
odd warren
#

Hey! I'm trying to apply a texture to a tree but nothing's going right. The tree is supposed to look like the first pic, but ends up like the second... The texture is the third pic, but it changes when put inside unity and screws up the tree. Is there anything i'm doing wrong? I've been stuck with this for days

#

thank you ๐Ÿ™‚

late dust
#

I don't see it under window > rendering

#

nvm it's under edit > render pipeline > universal render pipeline

#

all my textures are still pink though.....The base color is still selected properly on all the pink textures so they're configured properly, just not showing up :/

viscid knoll
# mental bone Hey guys, It's me again with more questions regarding my gore system. This time ...

You can draw custom stuff at the injection point you need using custom pass API, and HDRP custom Renderer Shader template(single pass shader pick the name/tag as you want ), then in the custom pass you will have handle the result filter of the DrawRenderers using shaderTagIds to call only your custom renderers shader pass to be drawn, so you can create ScreenSpace buffer by create RTAlloc for few RenderTexture from your Asset folder and Draw function using the shaderTagIds that is the tag of your HDRP Custom Renderers shader, in the end you can writte pretty much everything that you need but that is not directly draw this way, I guess Nvidia just store the screen space result of the FX, then the gravity like a fullscreen (i guess)

faint basin
#

how can I rotate normals after billboarding it in vertex shader? I grabbed some shader code for it and it works fine (but I need to somehow limit rotations only in Y axis, but its another problem), but my shadows is not rotating with object and by googling I found that I need to rotate normals too, but I not get a clue how to even do it

even basic stuff is by a miles away from understanding for me

viscid knoll
wary scaffold
#

Hello! Remy helped me out a few weeks ago making a custom function for Alpha Cutout while tracking objects. Its been working great but I just caught an issue I hadn't even considered.
When my object rotates the cutout square does not rotate. Obviously this isn't an issue with circles - but if I pass in the objects rotation how can I apply it to the square to replicate the object?

{
    float3 _UVPos = 0;
    float _radius = 0;
    bool _isSquare = 0;
    float2 uv = float2(0, 0);

    mask = 0;


    [unroll]
    for (int i = 0; i < 32; i++)
    {
        _UVPos = _Worldpositions[i].xyz;
        _radius = _Worldpositions[i].w;
        _isSquare = _isSquared[i] > 0.5;

        uv = (_UVPos - worldPos).xz;

        if (_isSquare)
        {
            float2 d = abs(uv) - float2(_radius, _radius);
            d = 1 - d / fwidth(d);
            mask = max(saturate(min(d.x, d.y)), mask);
        }
        else
        {
            float d = length(uv / float2(_radius, _radius));
            mask = max(saturate((1 - d) / fwidth(d)), mask);
        }
    }
}```
viscid knoll
#

you want to rotate the square? is it absolutelly usefull?

#

you square come from world UV space, I guess you can rotate the UV before float2 d = abs(uv) - float2(_radius, _radius);

#

you will have to tranform the WSpos to object/mask pos center (or inject object/mask pos too) , rotate the UV using a new Vector3 "rotation", then object to worldspace to reapply your modified worldspace UV, so rotation would stay centered to the object/mask

warm moss
steel notch
#

The linework here is seriously impressive. I looked into Sable recently so I'm aware this is likely achieved through some Sobel edge detection post processing shader.

#

The really impressive part, that I'm unsure as to how to replicate, is the linework WITHIN the models.

#

For detailing within models, Sable used these specialized textures that defined edges.

#

But I imagine drawing a non-contiguous line such as these...

#

would be quite hard with this technique

#

Would you happen to have any idea as to how this was achieved? Do you think those internal outlines are just regular textures? They sooort of seem to shrink as the camera moves back?

vocal narwhal
#

There are endless ways to achieve things. There could be mask maps that break up the edges, there could be extra meshes, there could be triplanar masking ๐Ÿคท

steel notch
vocal narwhal
#

I would try all sorts of techniques and apply whatever worked best for the workflows required to build each piece of the environment

steel notch
#

Cause Iโ€™m thinking maybe I could just make one big โ€œoutline maskโ€ from multiple sources.

#

Edges, depth and drawn lines.

#

And then just slap that over the whole image.

vocal narwhal
steel notch
#

Ok yes BUT this breaks down pretty quickly when you want to make it non-contiguous ๐Ÿ˜›

vocal narwhal
#
  • this as a mask.
steel notch
vocal narwhal
#

I don't understand the question. The lines are the transition between white and black, and the cuts in the lines are black in the mask texture

#

add another channel for line thickness if you wanna get wild

steel notch
#

This could be one weird ass pipeline though.

#

Lot of textures just to define edge boundaries.

vocal narwhal
#

That's what happens when you have a specific art style

vocal narwhal
#

Note that you would cram it into as few textures as you can

steel notch
vocal narwhal
#

Yes

steel notch
steel notch
# vocal narwhal Yes

So how would I feed in these "fake edges" into the edge detection post processing shader?

#

Have the material write them to a render texture or something?

vocal narwhal
tiny sphinx
#

@warm moss Hi! Thanks again for your help ๐Ÿซก So I didn't end up using a subgraph, instead I've opted to add texture properties to the shader material that it copies from whatever it replaces, so with a little switcheroo in code I get the best of both worlds. Figured you might like to see an update and I wanted to thank you again ๐Ÿ˜‡

steel notch
#

Defining surface IDs is a very cool way to handle this.

#

I would assume though that you'd have issues where objects that overlap and have identical surface IDs would struggle to identify edges.

#

But you have normal detection AND depth detection to fall back on.

#

In that case I guess I can just use a similar strategy for textures and sprites.

#

Just have a texture with effectively random colors that defines where the line needs to be, and a mask texture to remove unwanted lines.

#

Very cool.

dusky wedge
dusky wedge
#

Beside, what is the structure of struct InputData? Where can I find more information about Unity's shader API like that?

devout pier
#

Hi all, I'm an absolute shader noob.

I've been using this asset to add outlines to my game.
https://assetstore.unity.com/packages/tools/particles-effects/quick-outline-115488#reviews

But, my game uses an ismoetric, orthographic camera - and the strength of the outline appears to be affected by where the subject is positioned in the orthographic viewport.

I'm guessing somewhere in the shader its setting the size of the outline relative to the camera position - OR my orthographic camera is not correctly configured.

Any ideas?

Use the Quick Outline tool for your next project. Find this and more particle & effect tools on the Unity Asset Store.

devout pier
#

I'm guessing i will need to write my own outline shader...

rare wren
dusky wedge
# rare wren Unity URP and shader graph files are visible and even on github Nothing is docum...

Thanks for replying!

I did have a little research by reading hlsl files in URP library but couldn't find the definition of InputData and SurfaceData. Plus, My VS and VScode doesn't have shader intellisense so I can't track them down.

I'm now quite confused about my own question. Maybe it is too dumb/simple or lacking information or something. And no one seem to care about my question posted on the forum (there are posts after my question 30 mins and they even reach 10k views). It'd be great if you could give me some feedback!

rare wren
errant kettle
#

Hello! I've made this wind shader using CodeMonkey's video and it shows live in the preview inside the shader graph editor, but in the scene view it only updates when hovering over it or (at least for me) just at random. (Ping with replies pls)

karmic hatch
#

Around the gizmos tab iirc?

pulsar temple
#

Hi. I had a misunderstanding: They say on the Internet that you need to check the box next to Enable GPU Instancing so that there is less Batching. For some reason, it works the other way around for me. What's wrong?

worn ferry
#

Hi there,

Im noob to shaders, I'd appreciate if you could guide me how to create a Canvas Shader that procedurally generate skelteon-text effect

Appreciate
https://mui.com/material-ui/react-skeleton/
https://ionicframework.com/docs/api/skeleton-text

Ionic Framework Docs

ion-skeleton-text: Skeleton Loading Placeholder for Text

vale shadow
#

Hello, I got a problem with a custom shader that I want to make that makes my player look like this. My custom shader graph currently looks like this and the sprite sheet is tiled correctly. Any help is appreciated.

regal stag
vale shadow
#

Thanks @regal stag๐Ÿ˜Š . I wanted to make an outline to the character and didn't know why I didn't display correctly at first.

grizzled bolt
hollow wolf
#

disable static batching == there's no mesh combine

#

check via frame debugger

zealous thicket
#

hi all, I have a part of a shader that is creating a mask for waves of foam for a beach. I'd love to make this wave wiggle around based on the world position such that rather than a straight-ish line, the line makes a big sine wave kind of shape. Anyone have a good starting position for this kind of thing? I feel like it involves multiplying time and getting it on some sort of sine wave, right?

amber hollow
elder crow
#

Hi! Im writing an SRP and I want to do some compute. In SRP, all my textures are int TextureIds because thats what the API wants
like
cameraCmdBuffer.GetTemporaryRT(nativeScaledCameraColorTextureId, resolvedTextureDesc, FilterMode.Bilinear);
but all the compute commands want actual real textures like Texture2D and RenderTexture - how is this handled usually?

#

Oh, I just spotted SetTextureFromGlobal

#

okay, question retracted ๐Ÿ˜„

mortal mica
#

How do i make Alpha Clipping work

#

i just want to mask the bottom side of a sphere

late dust
#

https://www.youtube.com/watch?v=gRq-IdShxpU&t=96s&ab_channel=Unity

I'm following this tutorial, and I've done exactly what he's doing up until 2:32, but my plane doesn't have a gradient like his :/

In this video, we'll take a look at how we can use the Shader Graph feature in Universal Render Pipeline, or URP for short, with Unity to create a water shader! The water shader can be simple or complex, and include the features you desire. Let your imagination get wild in this tutorial, or simply follow step-by-step to get about the same result...

โ–ถ Play video
#

I'm running Unity 2019.4.39f1

#

ah wait nvm, didn't click save -_-

fallow scarab
#

why is my outline not working?

late dust
toxic flume
#

Hey, how to convert depthmap in object space from an object to world position?
Suppose we have a depthmap grayscale image for an object?

broken sinew
#

I am writing my own unity shader with fragment + vertex, and I don't know and can't find how to apply lights if the only thing I have in my shader is writing depth, normal and basic material properties like albedo, specular etc.

#

assuming the output color is color, I tried color.rgb += ShadeSH9(half4(myNormal, 1));, but it seems to be unaffected by the ambient light color

#

Built in pipeline btw, and I currently wrote only ForwardBase

#

do I have to use surafce shaders to make it work with default unity material system???

tacit parcel
amber saffron
# grand jolt after that?

Did you try a bit to search by yourself how light calculation work ? There's plenty of material for this, and there is plenty of ways to achieve lighting

grand jolt
amber saffron
grand jolt
broken sinew
#

2016 is when unity was on version 5.x

amber saffron
broken sinew
#

btw, with the upcoming Block shaders, will the reliance on macros be smaller?

#

for example in favor of functions and whatnot

amber saffron
#

I don't think so ๐Ÿ˜…

#

But I'm not sure, sadly I haven't spend a lot of time trying block shaders myself

broken sinew
#

damn :(

tired skiff
#

Hi guys,
I need to make a shield with local distortion shock wave shader in the point where a bullet hits it. is it possible? any idea?

#

the shield it should be a sphere. when the projectile hits that, it should make a wave distortion effect in that local point, the shock wave should be spread through the whole sphere gradually..

#

should i use a vertex shader, a fragment and vertex mixed or should I use a vfx graph?

grizzled bolt
winter arch
#

what went wrong with my shader that made the preview pink?

tired skiff
#

maybe with a shader graph i could have more control of that

#

this is the shockwave

grizzled bolt
winter arch
#

what is this weird black color when I apply it to my sprite and not when I apply it to a 3d shape?

#

im a shader graph noob plz help

#

heres the shader if it helps

#

nvm the issue is suddenly gone

#

why do these errors keep come and go

tired skiff
# grizzled bolt "Apply it" to a shader? Does not look "good"? It's somewhat unclear what the is...

Sorry I try to be more clear: this is my effect.
Now the wave start from z axis and it spread in this direction.
I would like this wave effect came from a bullet impact so in this case the z axis should be always faced toward the bullet. The problem is that bullets come from all directions.
That's why I've talked about "local" point. Because now the point where the wave start is fixed.
It would be cool to make a fragment/vertex or both shader that has this wave starting from the impact of a bullet.
Now is looped but I would like to see the wave after the collision. Should i turn the sphere every time? is there a way to make it "understand" where the collision comes and use that point as starting point of the wave?

barren hull
#

Heya all, I'm a little confused on how to implement more obscure maps into my shader. For example I'm trying to implement a detail map but I'm quite confused as to how. From what I can see, each channel represents a set of information.

Please correct me if I'm wrong but I belive these to be:
R: Detail albedo
G: Detail normal
B: Detail smoothness
A: ???

I assume I take these channels and blend them with the other relavent nodes?

meager pelican
#

This is a bit old, but https://www.youtube.com/watch?v=DGGZFLSHYUw
Here's one using a texture array with a map as an index into the detail array. https://www.youtube.com/watch?v=avZ26yW2KBw

โœ”๏ธ Works in 2020.1 โž• 2020.2 โž• 2020.3 ๐Ÿฉน Fixes for 2020.2 and .3:
โ–บ When you create a shader graph, set the material setting in the graph inspector to "Lit"
โ–บ The "albedo" field of the master node has been changed to "base color"
โ–บ Editing properties must be done in the graph inspector instead of the blackboard

If you have terrain or a large buil...

โ–ถ Play video

In this shader tutorial, I show a more advanced detail mapping technique that allows you to apply multiple detail textures (even 16 or more!) to your mesh using only one texture sample. This method can be used when you're applying detail to a character with multiple types of materials that each need need their own detail.

Here's last week's vid...

โ–ถ Play video
severe imp
#

What is the best way to make textures in unity?

#

Also is there a way to import the textures from blender to unity when importing the fbx?

tacit parcel
tacit parcel
tired skiff
viscid knoll
neon gale
#

is this normal or did i screw something up?

#

or is that compiling Every shader in the project, even though i only selected to compile one?

zenith aspen
#

I made this shader for something in my game but i need it to not stretch/compress the image i want it to just show a smaller portion

cosmic sphinx
worldly wasp
#

how can i change the material of a pre-made shader i didnt make?

sacred stratus
#

Hello math fellas, I want to create a sphere that uses angle calculation, so like longitude and latitude, but the best I could do yet is an iterative process, which makes it kinda bad for a mapping does someone have a better idea?
I wrote this mapping and it's awesome, but sadly it's iterative so I can't really use it, does someone know a mapping that can achieve a simmilar effect of reducing the latitude change close to the poles?


void main()
{
    uint px = vertexID % resolution;
    uint py = vertexID / resolution;

    float x = float(px) / float(resolution - 1);
    float y = float(py) / float(resolution - 1);
  
    float longitude = x * 2.0 * 3.1415926535897932384626433832795;

    float radius = 1000.0;
   
    float pi_interval = 3.141592/float(resolution-1);

    float latitude = 1;

    for(int i = 0;i<py;i++){
        latitude -= asin(sin(latitude)*6.28/float(resolution-1));
    }


    float px_world = radius * sin(latitude) * cos(longitude);
    float py_world = radius * sin(latitude) * sin(longitude);
    float pz_world = radius * cos(latitude);
   
hollow wolf
modest orbit
#

hi does anyone know why my shader has gaps from some angles, but is ok from others?

rugged relic
#

not sure if this would be possible with a shader, but i have a 3d model that uses two materials: one for the rock walls and one for the ground, and I just assign the materials in unity after exporting from blender. This is what it looks like, and I was curious if there would be a way to smooth out this material change between faces, or have the face fade to black when its connected to a material that is not the same.
Using URP

rugged relic
tacit parcel
tacit parcel
#

you might need to do the blits every frame with increasing scale and decreasing alpha to make the 'rippling' effect

#

๐Ÿค” you also might need to handle if the ripple is on the edge of the render texture

somber chasm
#

Whats the best way of returning "results" from a compute shader?

#

I basically do a bunch of computation off a texture, and get some number of results way smaller than the texture size, think "points of interest" in the texture

#

I don't really want to pass back and forth a buffer thats 1:1 size of the texture but I don't see any other option?

#

I see theres an AppendBuffer but i'm not sure how that works

somber chasm
#

And I get that theres "GetData" but the problem I have is how can I conditionally set this so I only have results I need/want

#

Or am I always going to have some redundant results in this case

mental bone
spark leaf
#

Unity 2023.3.20

Trying to pass in the _CarmeraDepthTexture to a custom function in shader graph. Get this error:
redefinition of '_CameraDepthTexture'

Did not have the same issue for the _CameraOpaqueTexture.

Depth texture and Opaque texture are both enabled in settings.

I am not sure how to fix this, I need access to the depth texture in the Custom Function. Any others ways to get it in there or fixes for this problem? I am very new to HLSL.

#

Also, I need to sample multiple pixels so just using the built in depth node on Shader Graph doesn't work as I can't get a section of texture all at once.

amber saffron
spark leaf
#

Seems to work, I love "reasons". How bad the documentation is for shader stuff compared to everything else in Unity is making me pull my hair out.

#

Thanks for the pointer.

kind juniper
#

To be fair any documentation for shaders is bad.๐Ÿ˜ฌ

#

Or rather, unclear and hard to understand

amber saffron
spark leaf
#

I accidentally made an edge highlight shader, this is not what I wanted.

old copper
#

hey! how do get the edges of these cells

grizzled bolt
old copper
#

aw man

#

I have to use hlsh for this one yes?

#

or can I write a custom vornoi in the shader graph?

#

(Im new to shadergraph)

civic lantern
#

You can use Step to get the white areas only, though. If that's what you need

#

Actually it might not be consistent

regal stag
spark leaf
timid jolt
worthy grail
#

I have a problem with the texture on the modelhttps://cdn.discordapp.com/attachments/900380950083534888/1211681472382107648/image.png?ex=65ef154e&is=65dca04e&hm=7215439e8127362f825528bcb4b14a04c97bdaf9786cc7014dc6a3e87a9de07a&

amber saffron
#

Probably not a shader issue

grand jolt
#

Helloo

barren hull
#

Heya so I wanted to use a temperature map in my shader to change the color of grass, pretty simple yeah. Only problem is I want the same value to be accessible from scripts. Now I could pass the values into the shader but that could take up a lot of bandwidth per chunk so it's not really that feasible, plus I'm not even sure if passing the values per vertex in would even make it look good seeing as the fragment shader would be determining the color. Anyone got any ideas? I'm almost considering yoinking the noise code from the shader and just re-creating it in my script

chilly robin
#

Quick shader graph question, but if I have an RGB mask where all 3 channels require different UV offsets, that means I have to sample it 3 different times, correct?

rain parrot
#

Is there a way to select only transparent pixels in my texture, or ignore opaque pixels (via shadergraph). I've got transparent colors that are acting as shadows and need to be affected differently from my opaque colors.

I've done the opposite by using a step node to ignore the transparent colors, but now i need to select only them.

grizzled bolt
light hearth
#

I have 3 tower prefabs. I am trying to make a simple shader graph for transparency for these. Am I going to need 3 seperate shaders as each tower prefab has a different base material?

#

Or can I create a single shader and somehow apply it to 3 different materials?

#

Messing around with it now but confused

grizzled bolt
#

!collab

echo moatBOT
grizzled bolt
light hearth
grizzled bolt
#

If you need to swap the shader used by a mesh at runtime, you would swap the material

light hearth
#

Got it, thanks

rain parrot
#

Hello, I've got this shader up and running that works like a jigsaw puzzle between 2 colors using a clamped noise pattern and a 1-minus version.
My next attempt at upgrading this shader is to see if i can provide a more natural border between the two colors. Preferably something like this:

#

I can provide the sprite pattern that would be required for the edge but i'm not sure how to implement it such that the two colors would intertwine.

lament granite
#

Hi, how can I change the material that is set on the full screen shadergraph by code? I mean the "blit" material that is set on the URP.

cerulean fjord
#

anyone got a gouraud shader

tacit parcel
cerulean fjord
#

ok

chilly robin
#

Do I need to include URP's Lighting.hlsl in my custom function to use the method TransformWorldToShadowCoord()?

Having some difficulty with this

#

If I don't include it, I get the error
undeclared identifier 'TransformWorldToShadowCoord' at line 10

But if I do include it, I get this error
_AdditionalLightsPosition: implicit arry missing initial value at line 151

vapid olive
#

Yo does anyone know how to make a simple custom text shader using shader graphs? Since normal text shaders just donโ€™t work on quest 3

#

Iโ€™m using unity 2020.3.44 btw

patent pebble
#

wasn't sure where else to put this but anyone know why when i export fbx into unity it turns out like this?

desert crater
#

what is this?

sturdy canopy
desert crater
#

can i find it in unity? This image was from a video.

sturdy canopy
#

just double click on a node in the graph and it should spawn one

grizzled bolt
#

Double click on a line that connects nodes

radiant inlet
#

Hello everyone, is there such a thing as a grayscale shader? Like if the shader is over anything it turns that into black and white?

radiant inlet
#

or maybe that's a global volume?

jaunty elm
scenic meadow
#

This is the shader I'm using

severe imp
#

How do I make my emmision so it glows

#

Because just checking the emmision box under a standard shader does not make it glow

clear veldt
#

How would I make a script where the UV of any white colored vertex color gets controlled by the movement of a bone

kind juniper
main totem
#

Does anyone happen to have a version of the standard shader with two detail maps?

#

I tried editing it myself, and while I have no errors, the added texture slots don't appear in the inspector. I have no clue what I'm doing

mental bone
#

Show your code

grizzled bolt
modest prairie
#

Hi everyone!
I'm trying to create a sort of a force-field like material that glows when in contact with other objects in the game sort of like this?

#

I've seen a lot of tutorials on how to do this, but it seems they all use URP, and my project is using the built-in render pipeline

#

I thought it was impossible to do in the buit-in, but then i found this water asset that runs in the built-in pipeline and achieves this effect

#

I'm a noob at all this shader stuff. Can anyone help me figure out how this works? I have the water's shader code but I don't understand how any of it works

tacit parcel
#

you'll need to get depth buffer first, maybe from camera depth buffer, then pass it to the shader.
https://docs.unity3d.com/Manual/SL-CameraDepthTexture.html
In the shader, you'll need to subtract the depth buffer with current texel z depth, that will give the rough information for where the effect should appear.

haughty mesa
modest prairie
#

Hey I figured it out! Thanks @haughty mesa and @tacit parcel

plucky siren
#

So I am quite new to shaders but i'm trying to figure out how to make this mechanic happen. The idea is that i have 1 long model but i use a 'viewing box' to clip away all the parts of the model that isn't inside of the viewing box. This part works wonderfully. The only issue with it is that the cutoff is quite abrupt (not visually pleasing) and when cutting of the model it shows off the insides of the model. I wanted to try and use an intersection shader to try and cover up those sides. Another option would be that the clipping is more a fade than a hard cutoff, but either way i don't know why the shader doesn't fully work nor why these two shaders have a weird interaction together. Does anyone know how to help me here?

ebon basin
#

Are there any wave/nodes I'm not aware of to get pingpong time in shader graph? Sine and remap work ok but it seems like it hangs near the extremes of 1 and -1 for while instead of smoothly interpolating back and forth.

ebon basin
#

oh huh I thought I tried that one but yeah works great ty

barren hull
#

Heya, trying to remove tiling here but despite my efforts it is not getting any better. Anyone know why?

#

It's overlaying fine but even with primes its just not great at all

grizzled bolt
grizzled bolt
# barren hull yea mb

There is no any one calculation that can beat repetition that works for every texture and every viewing angle equally, rather there are many varieties
It'd be better to show the issue itself
And usually the best thing you can do is change the texture itself to have less distinctive patterns

tacit parcel
grizzled bolt
#

Unity has an old procedural stochastic texturing node on git
But that method is also situational as it doesn't work for textures that aren't stochastic themselves

fair sleet
#

Hi everyone! I've seen a shader made in UE5 that use a "DistanceToNearestSurface" node to create a mask around the intersection area of 2 meshs in order to blen 2 different materials using this mask. There's a way to recreate this in Unity with the shader graph?

grizzled bolt
fair sleet
bleak patio
#

Sorry for a dumb question... but if I generate a mesh with hlsl, can it be a collider?

fringe furnace
#

hello guys, I am using a render texture to display my UI with post processing effects, what I am doing is to use a black mask in the background to discard/make transparent that pixels only leaving the UI. The thing is that I am getting a weird outiline and I cant use the black color xd. Idk what other solution I could make.

#

this is the result

#

How I can Isolate the UI in this render texture?

main totem
# mental bone Show your code

I simply copied the standard shader code from the github and copied the 3 detail related parameters, pasted them and renamed the variables. I couldn't see any other references to them in the shader code, but again, I have very minimal understanding of shader code.

mental bone
#

Well if you are not seeing the parameters at all its either the shader is not compiling or it is still using its custom inspector that is not showing your custom variables

restive radish
#

how to access color from sprite renderer in a shader graph?

deep moth
#

it looks like its pulling from a combination of the two.

restive radish
#

I tried both and it didn't work

deep moth
#

agh

restive radish
#

also tried _BaseColor

deep moth
#

What about _RendererColor

restive radish
#

using urp, by the way

#

hmm... going to try it here

#

thanks for the tip

deep moth
#

did that work ?

restive radish
#

no, it keeps the local color instead of referencing from the renderer

deep moth
#

dang : (

#

gonna need to poke around some more w/ urp specific code brb

#

interestingly in URP its the same setup

#

I was expecting to find some material property block here, instancing something or other

#

vertex color * _Color * _RendererColor

#

one of those is it -- it's possible its not getting set for some reason though?

#

do you have those variables publicly exposed ?

restive radish
#

they are exposed

#

I tried with all the three

#

I did a simple experiment here, just linking the color to the output, nothing else in the shader

#

like this

#

neither of them output the color in the renderer

#

using 2023.1.9f1

deep moth
#

oh! I was sending notes from 2022.3.7f1

#

that could be part of it

#

I dont know the answer to this one! But I think looking at the shader source for materials that do work is the way to go.

#

Unless it just won't bind with shadergraph.

#

In which case you could try copying one of the built in shaders

#

and tinkering with that instead.

restive radish
#

thanks anyway.

#

I will check the urp folder and find the default shader

#

` Properties
{
_MainTex("Diffuse", 2D) = "white" {}
_MaskTex("Mask", 2D) = "white" {}
_NormalMap("Normal Map", 2D) = "bump" {}

    // Legacy properties. They're here so that materials using this shader can gracefully fallback to the legacy sprite shader.
    [HideInInspector] _Color("Tint", Color) = (1,1,1,1)
    [HideInInspector] _RendererColor("RendererColor", Color) = (1,1,1,1)
    [HideInInspector] _AlphaTex("External Alpha", 2D) = "white" {}
    [HideInInspector] _EnableExternalAlpha("Enable External Alpha", Float) = 0
}`
#

Apparently, those properties are legacy, they don't serve a purpose at the moment

#

even using the sprite-lit-default, it doesn't get color from sprite renderer

#

same for sprite-unlit-default

#

I assume they changed something, and it is not used anymore

tacit parcel
#

Not sure is this should go to UI/UX or shader
Is there a way to overlay an image on top of 9-slice image on UI?
Using mask usually result with jagged edge, so I tried overlaying with shader
Using texcoord wont work because it's 9 sliced, so I try using worldPos instead and try to offset it with object position, but it seems that I cant even get the image transform position properly (using mul(unity_ObjectToWorldPos, float4(0,0,0,1);), seems like it returns the canvas position instead of the image position (and that's the easy part, I still have to get the image size or bounds)

#

So is there something I can use to properly map the image overlay?

main totem
#

I'm having issues with Shader Graph. I have two detail maps, but if I leave either one as none for the texture it makes the shader come out almost black

#

I have the two detail maps going into a multiply node, then that node going into a multiply with the base texture. Would adding a white base color to the detail maps solve this?

tacit parcel
ebon moss
#

is it possible to parametrize these?

tacit parcel
#

that said, I think alpha blending might offer more flexibility in the future

ebon moss
#

specifically, I want to be able to change "render face" option per instance of shader. I could always create a duplicate but this would be cleaner

main totem
#

What did you mean by alpha blending?

#

I'm new to shader graph

ebon basin
#

much like how Unity's lit/unlit shader exposes them

main totem
#

Did I do something wrong here? With the way this is, if I leave either detail texture as none, the material turns black? Any fix?

main totem
#

All I want to do is basically recreate the standard shader but with a second detail map, and the ability to scale the detail normals seperately. I still want it to use the alpha of the albedo for glossiness and everything else be the same. But I also can't figure out how to use the alpha as a specular mask in shader graph either

cursive jewel
#

Hi I am facing a weird issue,
I am making a 2D shader using shader graph for my ui components. It works fine in edit mode.
But when I enter to playmode, it's giving me a square.

#

In edit mode

#

In play mode

#

How can I fix this?

umbral panther
#

@cursive jewel my guesses would be one or more of:

  • somehow material is not applied
    you can probably test this by writing say RGBA(1,0,0,1) to the fragment output - if its a red square the material is working
  • something weird may be happening with zwriting on transparent pixels
    I'm not familiar enough with shader graph to have any good suggestions here, but perhaps moving some other objects around to test
  • something specific to using shaders with UI elements
    I've seen some pretty wierd behaviors, it might be worth outputting the UV coords as float4(uv, 0, 1) to make sure your getting sane inputs, but I'm not great with unity UI stuff
steel notch
#

why do I see some Shader graph examples where the nodes have these colored bars at the top?

#

How do I get the cool colored bars?

#

And what do they mean?

steel notch
#

On another note, I've got a question. I have a scene here with 2D sprite characters moving in a 3D world. Been working on solving some of the visual problems that came with that.

#

Currently I'm trying to figure out a good solution for shadows.

#

As the characters become perpendicular to to light source, the shadows shrink down to nothing.

#

This makes sense given that they are flat planes, but obviously it looks a bit... odd.

#

I'm not sure how best to solve this.

#

Even if I could somehow rotate the shadow along the light direction vector, I still think that would look odd.

#

Maybe I should just have a single directional light as the only shadow source?

ebon basin
#

Like, even if you were to get back the shadow map data of all the sprites pointed towards each light source, the proportions wouldn't look that great. No clue how a lot of these games do it but I'd expect there's a lot more math involved.

#

and I guess another problem is that you'd have a different sprite depending on where the light source hits the characters which you'd have to take into account, but there are games that just will just use the sprite in use.

ebon basin
steel notch
#

So the odd rotation gets obscured.

#

@ebon basin

#

Here's an example.

#

It's a cool solution, but would kind of only work with very "thin" characters.

ebon basin
#

smudge is good to fix the peter panning issues

steel notch
#

the what

ebon basin
#

that's what they call it lol

steel notch
#

who calls it that >_>

ebon basin
#

oh hey, my mate posted that question

#

lmao

steel notch
ebon basin
#

yeah, that's how I've had it.

steel notch
#

It's a shame but I might just need to let go of shadows for the entities.

#

They need a proper drop shadow anyway.

#

Since the player needs to gauge where they are when in the air.

ebon basin
#

recently I just been watching a lot of 3D to 2D videos and it got me more interested in doing this workflow backwards

steel notch
#

what do you mean by 3D to 2D?

#

Stuff like Little Big Planet?

ebon basin
#

3D models but with the illusion of 2D

#

deadcells is an example

#

easier to animate, easier to do the shadows, easier to work with unity's 3D engine

lilac mist
#

Hey, I'm making my own custom sprite shader in shader graph with some extra effects but would like to keep the normalmap functionality as it exists in the default sprite-lit material

steel notch
lilac mist
#

How do I get the normals to be correct based on the _NormalMap secondary texture?

ebon basin
#

the depth idea I had above is legit though even if you were to stick to 2D sprites, but that's something that requires more assets to do

lilac mist
#

I can access the normalmap through _NormalMap, right? But just sampling that and sending it to the tangent space doesn't appear to work.

steel notch
lilac mist
ebon basin
#

oh wait you found it

lilac mist
#

It's not producing the same as the normal sprite shader though, more jagged

ebon basin
#

I should consider using the shader graph for sprite stuff more. HLSL is a pain with srp and sprites

lilac mist
#

Apparently I should not be using the "Normal from texture". This makes a normal map based on a texture and is not suitable when I already have a normal map I want to use

#

Still, just applying the normal map to "Normal (tangent space)" does not produce a good effect

#

Light only applies from the bottom-left angle

#

Essentially implying everything is heavily facing down-left

tacit parcel
lilac mist
#

Ah, unpacking it appears to help

lilac mist
#

The reason normal from texture wasn't working was that instead of a heightmap I was feeding it my already made normal map

#

So it was trying to recreate a normal map based on a normal map

main totem
#

How does one set a texture to use the albedo alpha as Gloss in shader graph, like in the standard shader?

ebon basin
#

and I think you'd have to do that in a shader yourself

steel notch
#

From 1994

ebon basin
#

noice

#

gotta make it blend with the real time shadows too (for extra points)

steel notch
#

I imagine there must be someway to write to the shadowmap

#

or whatever is powering shadows

ebon basin
#

honestly looks fine. I'd deal with shadows later anyway if it's a problem

steel notch
#

Want to make sure I can actually... do this >_>

#

@ebon basin Actually, be real with me for a second? Does this style look good? I've been staring at it too long.

#

My sense of objectivity is shot.

ebon basin
#

considering the majority of 2.5D games uses blob shadows it's kind of natural to see it like this

steel notch
#

No no like.

#

The whole thing.

ebon basin
#

Yeah, looks good. Keep going

#

The lighting seems like a good idea too and easy enough so you've got that to play around with

steel notch
#

Post Processing is a fucking blessing btw.

#

Game looks like this without it.

#

How expensive are decals anyway?

#

Cause I'm aiming for like... 100 goobers.

#

Each with a drop shadow.

#

Plus a whole ton throughout the scene.

#

@grizzled bolt how dare you

rare wren
amber saffron
#

@steel notch
you can use a second sprite renderer set to "shadow only" and orient it to face the light.

In case of multiple light sources, this can get tricky, the other solution would be to to the camera facin in the vertex shader, and branch on shadowmap pass to face the light and not the camera.

steel notch
#

And it gets especially strange when the sprite is larger/wider.

#

You think it looks alright?

amber saffron
#

It does the job ๐Ÿ™‚

steel notch
burnt hinge
#

Hi ! Is there a way to replace the color of missing texture ? The magenta triggers epilectic episode for someone in my team

amber saffron
grizzled bolt
# steel notch My worry is that even with changing the shadow direction, the shadow won't reall...

Sprites are 2D so the shadow can never match perfectly, without revealing the cardboad cutout shape
The shadow can't really match the character "perfectly" without being casted by a 3D mesh of the character
To avoid making 3D meshes of all your characters you could have an approximate side view sprite of the character rotated 90 degrees casting shadows addition to the sprite itself
But neither strategy works well if the sprites are receiving shadows as well

burnt hinge
ebon moss
#

Using shader graph, is the only way to make a directional shader effect (for example a thing of fire running upwards through a person's body) to ensure that the UV's are mapped well enough, or is there a way to have the shader apply based on posiiton?