#archived-shaders

1 messages · Page 26 of 1

grizzled bolt
#

But using vertex displacement instead would sidestep that issue

#

and possibly some more in the future

forest mason
hardy echo
#

I've a question: Everytime when I try to install shader graphs in any version of unity in my project, there comes this error (you can see it in the picture), I've already tried to create a new project but it stil doesn't work... Has any one an idea, how I can fix that? Even if I create a new project in URP or HDRP there is directly again this error of Shader graphs and URP without I've done any thing... I'm confused... : (

vague sinew
#

Given this struct

      struct OUT_Data_Vert
      {
          float3 texcoord :TEXCOORD0;
          float4 texcoord1 :TEXCOORD1;
          float3 texcoord2 :TEXCOORD2;
          float3 texcoord3 :TEXCOORD3;
          float4 vertex :SV_POSITION;
      };

how do I migrate this to a shader graph?

lime viper
vague sinew
#

that's correct

lime viper
#

ok then you will need to move them to custom interpolators, on the vertex stage block right click and "add block node"

#

then just push whatever you need to via custom interpolators and access them on the fragment side like you would any other data

shadow locust
vague sinew
#

thank you!

#

what would be the type for the SV_POSITION?

lime viper
#

if you are altering the position you can just do the position value at the top of the vertex block

vague sinew
#

I see, thank you!

grand jolt
#

Hello!, I'm currently using Mountain Environment – Dynamic Nature and I got no idea how to add shaders to make it look awesome.

lime viper
grand jolt
#

Oh yeah, by the way u got any idea how to make sure the shaders are compatible with my render pipeline?

lime viper
tame topaz
potent spire
#

Anyone know how to tile a procedural pattern? I'm trying to generate a variable size bar and tile it so it looks like a barcode. I have managed to get as far as creating the procedural bar itself, just cant figure out how to tile it properly.

eager vigil
#

Hey, so I'm trying to create a shader where an object gets soaked over time. The object will be dry at first but after touching water (changing a value) a darker/wet version of the texture will slowly cover the object from the bottom up. I have the textures for the object but I don't know how to change the colors from the bottom up from a value.

lime viper
lime viper
eager vigil
potent spire
#

Maybe just writing it here will help me understand it better, but Ive generated a linear gradient that maps 0 on uv.x = 0 and uv.x = 1 and 1 at uv.x = 0.5. then uses step function to make the gradient harsh. I'm getting stuck on making the bar repeat and thinking about it now I might be able to test using a sine wave

potent spire
#

The end I'm going for will look similar to that, but not like an actual barcode, just a solid repeating bar like scanlines on a crt or something. I'm checking out using a sinewave rq to see if it works, gimme a moment

lime viper
eager vigil
potent spire
#

Well I was sort of right... the sine wave does what I thought it might, now I just gotta fix the blur lol

potent spire
potent spire
# eager vigil Graph

Nice, the blendmap to blending the two textures, are you trying to replace the primary texture with the secondary entirely where the wetness is? or just overlay it?

eager vigil
#

Think abt like this

#

The one of the left is before touching it, and the one on the right is after. The dark part will slowly climb up the player.

potent spire
#

So using the method Cameron just posted you should be able to just mask the secondary texture and add it to the primary when you output it. Alternatively if you want to replace the texture where the value changes, you can multiply the primary texture by the mask after passing it through a one minus node, then multiply the secondary texture by the mask and add the result. Then all you have to do to control the height of the effect is change the remap nodes map values I think.

eager vigil
#

Damn alr

#

I'll try doing both methods

#

Thx alot

eager vigil
#

I dunno if im doing anything wrong lmk

#

Wait nvm Im dumb

potent spire
#

Oh, when I said mask I just meant the result of the remap, you should be able multiply it with the secondary texture to "mask" it.

subtle cove
#

Hey does anyone know a good tutorial on making a sort of sand tesselation blending with other objects and to move the sand away from objects the deeper the objects are in the sand (like with water)? (For URP)

subtle cove
subtle cove
#

And... Do you recommend Shader Graph or coding the shaders without visualization?

#

(general question)

lime viper
lime viper
subtle cove
lime viper
dim yoke
astral pecan
#

Still struggling after days :c

astral pecan
#

I still don't understand what went wrong here though. I thought my plan would work.

  1. Extract the rotation matrix to euler angles.
  2. Clamp it to min/max angle.
  3. Convert it back to rotation matrix.
  4. Apply it to the object.
amber saffron
potent spire
#

Is it possible that I can create my own globally accessible cginc file similar to UnityCG.cginc? Getting really tired of manually fixing every shader to specify it's path if I need to move the file or shaders that include it.

amber saffron
humble robin
#

i want to discard a pixel when i set alpha of it to 0, how can i do it?

#

i need it to not exist in the depth texture too

amber saffron
humble robin
#

wait, can i use if statements in shader?

amber saffron
humble robin
#

wow, thanks

quaint coyote
regal stag
# quaint coyote Hey guys, Need some help here: https://forum.unity.com/threads/code-included-que...

It's because all these drawing commands don't happen instantly - they queue up to be executed later (during ScriptableRenderContext.Submit(), probably called by the UniversalRenderer class).
But material.SetColor() does happen instantly, so you just end up with a material with the last specified colour. You should probably have the pass create it's own instance/copy of the settings.overrideMaterial

#

Or could switch to a global colour variable and use CommandBuffer.SetGlobalColor

astral pecan
#

Hmm, the conversion is from Unity's Unity.Mathematics source though

quaint coyote
#

Thank you @regal stag the context.submit did the work 🤩👍

astral pecan
#

Remy, did you know how to use Object Position node with objects marked as static?

#

Because when I mark it static, it does this on play mode.

quaint coyote
#

That’s the problem when you mark objects as static. There’s a tag that had to be add like batching off or something but I guess it’s similar to making this non-static 😦

astral pecan
#

Hundreds and hundreds of blocks.

humble robin
#

how can i get clip pos in shader graph?

quaint coyote
astral pecan
quaint coyote
regal stag
subtle cove
quaint coyote
wicked niche
#

please tell me how to add a small smoothness here, I need the shader itself to remain as simple as that. there is a Lambert lighting model and there is no Smoothness parameter

quaint coyote
wicked niche
#

and how hard it will make my shader

#

this is my legacy simple diffuse transparent shader

regal stag
# wicked niche please tell me how to add a small smoothness here, I need the shader itself to r...

Lambert does not include a specular model, so smoothness isn't required.
If you want that, you could switch to BlinnPhong model instead.

My knowledge of surface shaders is limited, but should be #pragma surface surf BlinnPhong alpha:fade. I think that requires SurfaceOutputStandard rather than SurfaceOutput. Then you have access to setting o.Smoothness =, probably using some _Smoothness Float property.

quaint coyote
# wicked niche this is my legacy simple diffuse transparent shader

That’s great! Here’s a document that I’ve followed for my shaders and it’s by unity:

https://docs.unity3d.com/Manual/SL-SurfaceShaderLighting.html

Cyan is right, lambertian model doesn’t give you smoothness control. So you might have to switch to other models.
But if you really want a simple control then it’s:
DiffuseCol+spec
Where
spec= pow(dot(normalsWS, lightDir),48)
Replace 48 with a slider.

Also this is specific to light. So you can calculate a halfway vector as well. Which is:
Normalize(lightDir+viewDir)
And do a dot normalsWS, halfway vector

#

But you don’t need all those calculations because smoothness can be easily added using what cyan said and do check the unity documents. It has the info

wicked niche
wicked niche
#

This is my shader

quaint coyote
#

so you just want a shine, specular? @wicked niche

harsh marsh
#

How can I avoid this issue where outlines have gaps in them at certain angles (changing thickness of lines does not fix this)

#
void Curvature(float2 uv,float depth,out float curvature,Varyings input)
{
    curvature = 0.0;
    float3 offset = float3(_SourceSize.zw, 0.0) * (CURVATURE_SCALE);
    float3 center = SampleNormal(uv);
    float3 normal_up = SampleNormal(uv+ddy(uv*CURVATURE_SCALE));
    float3 normal_down = SampleNormal(uv-ddy(uv*CURVATURE_SCALE));
    float3 normal_right = SampleNormal(uv+ddx(uv*CURVATURE_SCALE));
    float3 normal_left = SampleNormal(uv-ddx(uv*CURVATURE_SCALE));

    float normalEdgeBias = float3(1.f, 1.f, 1.f); 
    float normal_diff = dot(normal_up.g - normal_down.g, normalEdgeBias) + dot(normal_right.r - normal_left.r, normalEdgeBias);
    if (normal_diff >= 0)
    {
        curvature = 2 * CurvatureSoftClamp(normal_diff, CURVATURE_RIDGE);   
    }
    else
    {
        curvature = -2 * CurvatureSoftClamp(-normal_diff, CURVATURE_VALLEY);
    }    
    
}

Currently, this is the edge detection algorithm I'm using (from a screen space cavity/curvature shader on github)

sage locust
#

is it possible to, in short, have a shader that's almost literally just the standard shader, but then I just plug in some extra texture inputs and an extra SubShader?

wicked niche
wicked niche
#

but with simple shader

lime viper
lime viper
wary horizon
#

has the keyword REQUIRE_DEPTH_TEXTURE been changed since 2020? I'm in 2021 and i have a shader not doing anything, and im assuming its to do with this

sage locust
wary horizon
#

or this? I'm not sure 😬

terse chasm
#

does anyone know how i can add a shadertoy shader as a skybox in unity

#

never mind i have figured it out

tacit parcel
scarlet crater
#

hey so i have a shader that makes a bunch of repeated tex2D calls to create a bunch of instances of the same texture at random UV points

#

so far it "works"

#

but i'm having an issue with the output seeming to "flicker"

#

it only happens sometimes and im not exactly sure how to recreate it

earnest furnace
#

How do I make a material have higher rendering precedence (as in, overlays) than the other? I already tried making the overlay material have a higher sorting order than the other

quaint coyote
quaint coyote
quaint coyote
scarlet crater
#

Oop I completely forgot about that

#

One sec

median wind
#

Hey, I'm trying to make a Ray Marching Shader for infinitely repeating patters and such.
I just followed a tutorial on making the Ray marcher but it it's only contained inside a the object I put the shader on (a cube).
Is there a way to project this into the unity scene so it it's visible from all angles and acts more like a normal object that you can clip through?

amber saffron
median wind
#

screen space shader?

meager pelican
# median wind screen space shader?

Throw up a full screen quad or triangle and compute it all in screen space.

FYI - this tut is using ray tracing, and compute shaders. That may not be what you want, IDK. But here, he even traces geometry (polygon lists and material lists, converted to compute buffers). It is an interesting approach, and might be overkill if you just need a full-screen triangle/quad to do your tracing with. But you should find it an interesting read even if you don't use this approach.
http://three-eyed-games.com/2018/05/03/gpu-ray-tracing-in-unity-part-1/

median wind
#

Aye, thank you!

astral pecan
#

Yes I am in URP

quaint coyote
#

the concept of GPU instancing is to use same mesh with multiple transformations. Static batching may combine all meshes together. So imagine a tree being rendered 1000 times (GPU instancing) VS 1000 trees being batched and rendered as one mesh (this is heavier as compute is done for 1000 trees multiplied by num vertices in 1 tree) etc.

#

But you can have some objects static batched (manuall) by checking the static batching checkbox in inspector window. And some objects GPU instanced.

astral pecan
#

I have disabled static batching for the project.

quaint coyote
astral pecan
#

But I read they're better than GPU instancing at most cases?

#

Even if it results in higher batches.

quaint coyote
#

so there are a lot permutation and combinations that go along to get a good FPS and low(really low draw calls). GPU instancing breaks most of the times. So you need to keep seeing the frame buffer to get the optimal results.

#

E.g. In one scene with SRP batcher on, Set Pass Calls were 20 but draw calls were 70. So when done manually, I batched some and used GPU instancing on some, lowering draw calls to 25ish

#

I would suggest reading Unity's documentation on it.

astral pecan
#

Okay, I'll give it a go!

quaint coyote
#

cools 🙂

#

also note, SetPassCalls are different than draw calls!

keen onyx
#

Hihi!
I am pretty new to shaders and I am trying to rework a existing shader of someone else
But after changing some stuff I get the error message

Surface lighting model 'vertex:vert' not found. Available models: BlinnPhong, Lambert, Standard, StandardSpecular at line 15

I do have the function called
void vert(inout appdata_full v)

astral pecan
#

Its there on the documentation

quaint coyote
#

@keen onyx you should write vertex:vert after the lighting model. Here SimpleSpecular is the lighting model.

keen onyx
#

aaahh I might removed something out of that line

#

got now #pragma surface surf StandardCustomLighting keepalpha noshadow vertex:vert

#

error is gone but got another one

quaint coyote
# astral pecan

yeah thats the SRP batcher. Also GPU instancing breaks with lightmaps. So be careful. If you want to see the option again, in the lightweight asset(inspector window). right click and make sure you are able to see the advanced options

quaint coyote
keen onyx
#
        void surf(inout StandardSurfaceOutput o) {
             
        }```
#

my shader knowledge is a possible 1 out of 10

quaint coyote
keen onyx
#

oki!

quaint coyote
keen onyx
#

thank you!

keen onyx
#

do you got by any chance a doc or tutorial for like
making a mesh (vert) move/bend towards like a location?

I know I need lerp & beziercurve
but kinda stuck on the how to shader run and what the best what the best way todo it is.

charred canopy
#

hey I would like to have a normal map in world space but can't seem to figure out how to do that

#

the overall "shape" of it looks correct but of course the direction of the normals are incorrect

#

as they give me undesired values back

#

I have looked around and well I would assume that I'd just make a vertex shader and multiply it with the inverse world matrix like this

       void vert (inout appdata_full v, out Input o) {
           UNITY_INITIALIZE_OUTPUT(Input,o);
           o.normal = mul(unity_ObjectToWorld,v.normal);
       }```
#

it is the built-in render pipeline btw

amber saffron
charred canopy
#

would a fragment shader be better?

#

I just want my normals to not move no matter what rotation my mesh has

#

which is just a plane

#

what I would want is for my tileable normal map to continue like how you could do it with an albedo

#

or do I understand you wrong?

amber saffron
#

Like I said :

  • Surface shaders expect tangent space normal value
  • You have to transform the world space normal value to tangent space
#

No need to transform the vertex normals

charred canopy
#

so how do I do that?

#

I am sorry, still a bit new to shaders

amber saffron
#

I can't find the world to tangent function (there must be one somewhere in the include files ...)
But once you have this, it's just the matter of doing
[pseudocode]

o.normal = mul( WorldToTangent, worldNormal);
charred canopy
#

so that's for the vertex shader

#

world Normal is the normal in world space I assume

amber saffron
charred canopy
#
            float3 t2w0 = WorldNormalVector(IN, float3(1,0,0));
            float3 t2w1 = WorldNormalVector(IN, float3(0,1,0));
            float3 t2w2 = WorldNormalVector(IN, float3(0,0,1));
            float3x3 t2w = float3x3(t2w0, t2w1, t2w2);
            return normalize(mul(t2w, normal));
        }
        
        void surf (Input IN, inout SurfaceOutput output)
        {
            output.Albedo = half3(1,1,1);
            //output.Normal = UnpackNormal(tex2D(_NormalTex, IN.worldPos.xz / _NormalTiling));
            output.Normal = WorldToTangentNormalVector(IN, UnpackNormal(tex2D(_NormalTex, IN.worldPos.xz / _NormalTiling)));
        }```
#

so like that?

amber saffron
#

IDK what the WorldNormalVector is doing, but probably this yes

charred canopy
#

it's a normal texture sample

#

in world space so that it's tileable, correct?

#

now it's all black if I do it like suggested above

#

so this is the result of the normal map put into the albedo

#

which to me looks alright

amber saffron
#

WorldNormalVector is a sampling function ?

charred canopy
#

oh no that is from the library

amber saffron
#

But indeed, the value look ok when displayed here

charred canopy
#

#define WorldNormalVector(data,normal) fixed3(dot(data.TtoW0,
dot(data.TtoW1,normal), dot(data.TtoW2,normal))

#

that's what I found

charred canopy
#

but unfortunately it just makes my entire thing black if I put it inside the normal map

#

which I find odd since I believe that blue means they're pointing upwards

wicked niche
quaint coyote
quaint coyote
# wicked niche

did you copy and paste the whole shader or just part of it?

quaint coyote
#

@wicked niche hey sorry, for some debug purposes I had made a change at line number 45. Can you change it to o.Albedo = c

#

The albedo should not be equal to IN.worldNormal 😄

bold horizon
#

left is without the pixelization right is with

#

nvm i figured it out

viral elm
#

good evening, guys )

#

help 🥲
I don't know how to fix it
I already went back to the very beginning of my shader, deleted and re-created all the sampler states with default settings

#

the warning remains
I'm using urp, if it makes any difference

keen onyx
#

just wondering if there is a way to get like the mesh origin world position from a single vertex?

dim yoke
keen onyx
#

I using like void vert(inout appdata_full data) {

but I want the vertices to follow a curve based on like a start & end position, and based on there position inbetween these 2 points it should curve more or less

#
                float orificeChannel = 0;
                float orificeType = 0;
                float3 FinalPosition = float3(0, 0, 100);
                float3 orificeNormalTracker = float3(0, 0, 99);

                GetBestLights(orificeChannel, orificeType, FinalPosition, orificeNormalTracker);

                float4 modifiedPos = data.vertex;

                float3 P = float3(0, 0, 0);

                float T = (1 - ((FinalPosition.z - modifiedPos.z) / FinalPosition.z));

                Bezier(T, modifiedPos, FinalPosition.xyz, P);

                modifiedPos.x = P[0];
                modifiedPos.y = P[1];
                modifiedPos.z = P[2];
                data.vertex = modifiedPos;
            }```
#

thats my entire function ^

#

GetBestLights gives me a float4 back x,y,z,1
and the Bezier gives me the core responding location in between the 2 points giving P back as float3

#

currently I am calculating it from the vertex position towards the final position
but should be the origin of the mesh core responding with t he vertex offset

#

my shader knowledge is a 1 ish

quaint coyote
# keen onyx ```void vert(inout appdata_full data) { float orificeChannel = 0...

from what I can understand is you want to plot a vertex between two points. So what you require is the index of the vertex. I dont know how to get that in the surface shader.
So what you can do is get the vertexID (its of type uint) in the vertex shader. Once you access that, based on the id and max vertices, you can plot the point on that curve.
e.g. if you have 1000 vertices, and current vertex id is 400 then the current position is : (400/1000 )*100 of the beziere curve plotted, which you can plot based on the min and max points A and B

keen onyx
#

I am trying to move the mesh towards the light (making that Z is always facing forward)

#

but yeah its now the vertex going to the final position using a curve

#

what I want is like get the origin X+Y then calculate the offset with the vertex X+Y so it can curve from the origin center

haughty moat
#

Hello, does any one knows what happens to invalid shader variants from invalid multi_compile keyword combination ? Do they get stripped away ? If I define the same symbol to different values using different multi_compile keywords, do I only get the variant where the symbol is defined a single time (getting effectively a single variant per keyword if I define the symbol for each keyword)?
Related question, can I define a group of keyword to be mutually exclusive? enabling just one from C# is cumbersome because keyword enabling survives domain reloading (I'm using a compute shader, I know material shaders are handled this way by default by Unity)

viral elm
#

forgot to post an update

astral pecan
#

Anyone know if the math is right? trying to extract Euler rotation part from matrix4x4.

    float3 ToEulerXYZ(float4x4 m)
    {
       // Extract the rotation part of the matrix.
       float3 x = m[0].xyz;
       float3 y = m[1].xyz;
       float3 z = m[2].xyz;
     
       float yaw, pitch, roll;
     
       yaw = atan2(z.x, z.y);
       pitch = atan2(z.x, z.z);
       roll = atan2(y.z, x.z);
     
       return float3(yaw, pitch, roll);
    }
#

I am using clamp, but it always gives me the MinAngle value.

float4x4 ConstrainDirectionMatrix(float4x4 DirectionMatrix, float3 MinAngle, float3 MaxAngle)
{
    float3 eulerAngles = ToEulerXYZ(DirectionMatrix);
    
    // Clamp the euler angles to the defined min/max values
    eulerAngles.x = clamp(eulerAngles.x, MinAngle.x, MaxAngle.x);
    eulerAngles.y = clamp(eulerAngles.y, MinAngle.y, MaxAngle.y);
    eulerAngles.z = clamp(eulerAngles.z, MinAngle.z, MaxAngle.z);
    
    return ToMatrix4x4(eulerAngles);
}

void ConstrainedBillboard_float(float3 VertexPosition, float3 ObjectScale, float3 ObjectPosition, float3 MinAngle, float3 MaxAngle, out float3 Out)
{
    float4x4 cameraInverseView = UNITY_MATRIX_I_V;
    float3 scaledVertexPosition = VertexPosition * ObjectScale;

    float4x4 constrainedDir = ConstrainDirectionMatrix(cameraInverseView, MinAngle, MaxAngle);
    float4 rotatedVertex = mul(constrainedDir, float4(scaledVertexPosition.x, scaledVertexPosition.y, scaledVertexPosition.z, 0));
    float3 finalPosition = rotatedVertex + ObjectPosition;

    Out = TransformWorldToObject(finalPosition);
}```
#

UNITY_MATRIX_I_V is working properly though, gave me the camera inverse dir when I tested.

#

But I'm just not sure what kind of values ToEulerXYZ(DirectionMatrix); produces.

#

And why it kept producing me the MinValue

#

How to even debug shader values?

harsh marsh
#

Still trying to figure out how to do this

haughty moat
haughty moat
astral pecan
#

That would be really helpful

haughty moat
glad coral
#

I've constructed a UI in a canvas that is applied to an ingame screen as a rendertexture. As part of this UI, I want to have a audio waveform visualizer.
Would making this audio waveform visualizer using a shader applied on a 2D texture inside the canvas have any downsides? Would light from the scene still affect the shader part of the rendertexture normally? or would it look weird compared to if I for example, alternatively constructed the waveform via a 2d mesh (probably much slower)

haughty moat
glad coral
haughty moat
glad coral
#

I just want a simple audio waveform visualization taking data from an audio source to display on the screen, basically.

#

here's how it currently looks

harsh marsh
haughty moat
#

oh ok, so more of an equalizer look ? That should work no problem yes

haughty moat
glad coral
# haughty moat oh ok, so more of an equalizer look ? That should work no problem yes

exactly. Can you perchance point me in the correct way to do this in the HDRP pipeline, if you know? I'm not actually sure if the method changes depending on the render pipeline, since its not a global shader that I want to apply but more so just a shader applied to a single texture/material/quad

I'm currently watching some french guy showing how to do it in HDRP but it feels like a weird way of doing it: creating a custom layer, as well as a new custom volume game object. It seems to also remove the default HDRP shaders from the texture it is applied to, which will make it look sort of out of place compared to the rest of the UI in my current usecase

haughty moat
harsh marsh
haughty moat
glad coral
#

I found the docs for the .SetTexture method, but as in the steps between I am very much blank 🤷‍♂️

#

if that's even the way you're referring to

haughty moat
# glad coral I've only delved into shaders recently, when I had to modify HDRP's HDRI skybox ...

There are a LOT of caveats to do this but the example in https://docs.unity3d.com/Manual/class-ComputeShader.html is essentially it for the shader side. Be certain that the renderTexture has random write enabled. for the C# side you'll probably need https://docs.unity3d.com/ScriptReference/ComputeShader.SetTexture.html , https://docs.unity3d.com/ScriptReference/ComputeShader.Dispatch.html and SetFloat or SetInt.
Also, this is a pretty good primer, don't know if everything is up to date though : https://catlikecoding.com/unity/tutorials/basics/compute-shaders/

A Unity C# Basics tutorial about using a compute shader to make it possible to show a million moving cubes.

glad coral
#

Oh, might've spoken too soon

#

By the way, what are those caveats you mentioned?

haughty moat
# glad coral By the way, what are those caveats you mentioned?

Depends on what you are doing but I'd generally stir away from constant buffers in Unity, they are buggy before Unity 2022. The tutorial should steer you clear of common pitfall of threadgroup size but essentially for [numthread(x,y,z)] try to have x*y*z be a multiple of 64 (for hardware reasons).
Unity has barely any error checking on this API, so things can fail silently very often, be very methodical.

glad coral
#

I guess it won't even report if you overflow the buffer? uh oh

haughty moat
meager bramble
# astral pecan Anyone know if the math is right? trying to extract Euler rotation part from mat...

I don't know if your math is correct, but I have this method for converting from quaternion to eulerXYZ. Pretty sure it is correct. Maybe you can cross check with it if you can get a quaternion representation of your rotation:
/// <summary> /// Converts to extrinsic Euler XYZ in radians (or intrinsic ZYX). /// </summary> public static float3 ToEulerXYZ(this quaternion quaternion) { float w, x, y, z, w2, x2, y2, z2; UnpackAndSquareQuaternion(quaternion, out w, out x, out y, out z, out w2, out x2, out y2, out z2); return new float3( math.atan2(2*(y*z + w*x), w2 - x2 - y2 + z2), math.asin(-2*(x*z - w*y)), math.atan2(2*(x*y + w*z), w2 + x2 - y2 - z2) ); }

#

Not sure if you want extrinsic or intrinsic, but there is this one also:
/// <summary> /// Converts to extrinsic Euler ZYX in radians (or intrinsic XYZ). /// </summary> public static float3 ToEulerZYX(this quaternion quaternion) { float w, x, y, z, w2, x2, y2, z2; UnpackAndSquareQuaternion(quaternion, out w, out x, out y, out z, out w2, out x2, out y2, out z2); return new float3( math.atan2(-2*(y*z - w*x), w2 - x2 - y2 + z2), math.asin(2*(x*z + w*y)), math.atan2(-2*(x*y - w*z), w2 + x2 - y2 - z2) ); }

#

Anyone know why, when I make a cbuffer, it only works if the size is atleast 16 bytes (4 ints)? If I make a cbuffer with only one int inside it never receives any values from the cpu.

haughty moat
#

Yeah, Unity didn't follow Microsoft guidelines for data packing. They supposedly fixed it in 2022

#

You don't have to have 16 bytes worth of data but the buffer you declare on the C# side must have a size that's a multiple of 16 to work correctly

glad coral
#

hopefully 2022 gets an LTS version soon

haughty moat
#

Idk, current LTS version should receive this sort of fix. They just won't idk why

glad coral
#

you're not wrong, but who knows whats going on at HQ lol

meager bramble
zinc beacon
nocturne wyvern
#

How did among Trees get such thick volumetric fog?

simple violet
#

can you make shader graphs for ui?

#

i tried but it just comes out black when i apply material to ui

#

unlit

#

it sort of works if I turn on alpha clipping and render back face but transparency isn't working

knotty juniper
#

@simple violet

#

(correction you dont need the emission)

simple violet
#

so it has to be lit?

knotty juniper
#

no works fine with unlit

#

what is that color that you have there?

#

the ui takes it color from the vertex color usualy

simple violet
knotty juniper
#

on what component do you use the material?

#

i tested it with a UI image

#

i can send you a test shader if you want a reference

simple violet
#

ok

#

i am using ui image btw

knotty juniper
#

its just the shadergraph and a test material with the shader

simple violet
knotty juniper
#

so its working?

simple violet
#

no

#

look at game view

knotty juniper
#

mmm wired

#

seems to be a issue with the overlay mode of the canvas in screen space camera mode it does show

simple violet
#

yeah that does work, but i gotta make the plane really close to the camera

simple violet
#

apparently other people ran into it to

#

and theres a vote for the feature

knotty juniper
#

there is a mode called Sprite unlit

simple violet
#

ah i tried that it didn't work for me

#

the transparent parts were black

knotty juniper
#

ah i see

#

sorry^^

simple violet
#

i basically only need to do a transition

#

would it work as a blit?

#

or would that be overkill

lean lotus
#

how do I blit to only part of a texture?

astral pecan
# meager bramble I don't know if your math is correct, but I have this method for converting from...

Do you have float4x4 to quaternion?
EDIT: Nvm here it is!

float4x4 ToMatrix(float4 q)
{
    float4 q2 = q + q;

    uint3 npn = uint3(0x80000000, 0x00000000, 0x80000000);
    uint3 nnp = uint3(0x80000000, 0x80000000, 0x00000000);
    uint3 pnn = uint3(0x00000000, 0x80000000, 0x80000000);

    float3x3 rotMatrix;

    rotMatrix[0] = q2.y * asfloat(asuint(q.yxw) ^ npn) - q2.z * asfloat(asuint(q.zwx) ^ pnn) + float3(1, 0, 0);
    rotMatrix[1] = q2.z * asfloat(asuint(q.wzy) ^ nnp) - q2.x * asfloat(asuint(q.yxw) ^ npn) + float3(0, 1, 0);
    rotMatrix[2] = q2.x * asfloat(asuint(q.zwx) ^ pnn) - q2.y * asfloat(asuint(q.wzy) ^ nnp) + float3(0, 0, 1);

    return float4x4(
        rotMatrix[0][0], rotMatrix[0][1], rotMatrix[0][2], 0.0f,
        rotMatrix[1][0], rotMatrix[1][1], rotMatrix[1][2], 0.0f,
        rotMatrix[2][0], rotMatrix[2][1], rotMatrix[2][2], 0.0f,
        0.0f,            0.0f,            0.0f,            1.0f
    );
}
median wind
#

can someone help me get my SV_Depth working correctly?
not sure why the code isnt working

#

Im also confused on how to get the torus to not change scale and only change position when i scale up mesh

languid lagoon
#

Hi guys, how do i delete the x on the fraction graph?

potent spire
#

Is there a way to specify shader code that should run exclusively on VR devices?
For example, I made a glass shader using grab pass and normal map to make a nice distortion effect. However, when using VR, since the grab pass result is stereoscopic it breaks the shader entirely.
Anyone have an idea how I can have this same shader change its method of texture mapping based on what device the viewer is using?

languid lagoon
#

i want to show only bottom left

dim yoke
languid lagoon
#

i want it transparent

dim yoke
#

You can do the math yourself, just compare the x and y coordinates separately

quaint coyote
quaint coyote
potent spire
quaint coyote
potent spire
#

Alright, thanks for your help.

languid lagoon
quaint coyote
#

I am curious as to why you want to have 1/3rd of the texture mapped with uv's and rest all transparent...

languid lagoon
#

black is actually okay if transparent is difficult tho

quaint coyote
#

okay, so if I understand you correctly, you need to sample a texture from the atlas and show it on an object right? @languid lagoon

languid lagoon
#

yes

quaint coyote
#

then you just need to add a tiling and offset node and enter the right values usually it would be x/3 and y/3. Then you need to put proper offset values to as you are scaling the texture up 3 times.

quaint coyote
#

yeah, but your maps look really skewed!

languid lagoon
quaint coyote
languid lagoon
quaint coyote
#

with better tiling/offset values 🙂
Also, try with 4 textures first instead of 9. That will give you a better idea

#

and division by 3 will always cause issues

languid lagoon
fickle ferry
#

so i moved my project to another git
it gives suddenly the message
your project is a project what is made in a version before 5.0
when i click continue and if im in the game the shaders looks totaly different.

lilac mist
#

Hey, I'm trying to make a very simple flat water-ish texture shader, and was wondering if anyone had any tips. Currently I'm using URP and I'm trying to make it in the shader graph. All I want is for a flat tile to look like top-down water ish. I've done some work on the shader graph equivalent in unreal, but not much in Unity.

#

I looked for some guides but they mostly seem to have the end result of moving 3d water, and all I need is for the texture itself to move

quaint coyote
#

Secondly, use a good texture map for water and make sure that there is some foam. foam can be made to flow by using flow maps(a bit of a complex concept, but its like 4-way chaos in unreal)

lilac mist
#

Right, I'll give that a try. Do you have any advice for if the end result is unlit?

#

I'm still kinda undecided on what I'll do lighting wise for this

quaint coyote
#

Then its upto you if you want to render refraction or not. For that you might want to use the scene-color node and distort it a bit and then mix it up well with the diffuse color

#

research a bit on the flow map(4-way chaos node in unreal). If possible try to make something like that. Or simplify it to a 2-way chaos node so that water looks flowing. You wont need normal maps then.

lilac mist
#

I'll check out flow maps too, thanks

quaint coyote
#

Mostly water in games is reflections and refractions, some good waves(they use a concept called gerstener waves and if you really want to go deeper then can do some signal processing like FFTs)

quaint coyote
lilac mist
#

Yeah, a lot of the tutorials etc I've found are more like, realistic water up close

#

but I'm really more at a "far away ocean, top down" place

fossil cloak
#

Does someone know how the Material Variants in Unity 2022 are handled performance wise? Is it like using the same material or are they treated like a different material when it comes to the drawcalls?

quaint coyote
fossil cloak
quaint coyote
#

@fossil cloak I just made a shader with multiple variants and checked, it makes 2 draw calls

fossil cloak
#

Possibly one for the Mesh and one for the Shader/material

#

Sounds good 🙂

quaint coyote
#

in short, multiple variants means multiple draw calls because the gpu render state changes. Please correct me if I am wrogn

fossil cloak
quaint coyote
glad coral
#

In games with very good graphics, where your GPU is going to be the bottleneck rather than your CPU, does it still make sense to use compute shaders for performance?

#

(context is drawing a realtime waveform from an audiosource onto a texture)

low lichen
#

Or if the CPU implementation is slow enough to make the CPU the new bottleneck.

terse chasm
#

hello anyone

#

i am using shadertoy into my unity skybox and when i load into the scene my 3d objects cant be seen through the shader

glad coral
restive radish
#

I'm trying to use a sprite renderer to animate a sprite, but without a proper sprite. All animation is done in the shader. However, I'm not managing to make it show the sprite. What are the technical details to make a sprite renderer into an empty square that I can resize to match the sprites in the shader?

#

this is the part of the shader that prints the character

#

my other option is to change to a quad mesh

wicked niche
#

Is there some kind of high-quality Glow on objects for mobile phones? preferably without post-processing, the effect should be something like from lightsabers
mb someone used something of high quality

simple violet
#

Probably a transparent mesh aound the object would work

cosmic sphinx
#

I've noticed shadergraph shaders stopped working for UI images after updating Unity from version 2021.3.2f1 to 2022.2.0f1 - the images are invisible unless I use Fullscreen material (which is not my intent). I'm using HDRP 14.0.4. Any ideas on how to fix the problem?

grand jolt
eager cove
#

Simple question probably but cant really seem to find the answer on google, id like to box project this floor texture but i dont know where to ajust

terse chasm
#

when i use shadertoy shader for skybox the objects in the scene are still solid but they are transparent

#

nevermind

#

i have got it working

young fog
#

Can I use shader graph to get certain objects in a scene?

shadow locust
#

any data you want in the shader would need to either be passed in as a material property, or fetched from one of the existing graph nodes

young fog
#

I can get the material properties?

shadow locust
#

I'm not really sure what "this" is? Flat/toon shading?

terse chasm
#

i have a question, can i make a skybox using raymarching?

shadow locust
young fog
#

I know

shadow locust
#

If you want to do something like overriding certain materials to certain objects by layer or something you could use a scriptable render feature in URP/HDRP

young fog
#

I don't know where to start, all I know is I have to separate it by materials

shadow locust
#

I'm not really sure what you're trying to do tbh

molten hamlet
#

Hey, random VRChat users here, Does anyone know where I could get the shaders like the ones in the treehouse in the shade world? I don't know how to code at all btw, if anyone could show me where I could find them, that would be really useful

young fog
# shadow locust I'm not really sure what you're trying to do tbh

I just wanted to create a basic effect with the objects, I wanted to just get these objects by material and render them on top of everything, then use it with this shadergraph I have on the camera

I wanted to understand how graphical effects like the ones in the video/game are done

shadow locust
#

The video just seems to be describing which materials are applied to which objects in the scene to me

#

It doesn't seem like an effect that's overlaid on top or something

young fog
#

it works in passes or something, I don't know how because I don't know much about that type of stuff

regal stag
#

The video basically describes a custom deferred rendering path iirc. But that's not something you'd do in ShaderGraph.

young fog
#

I see

#

so how would I do what I'm describing?

#

I just want the objects with that material to render on top of everything

humble robin
#

how can i get position of a pixel drawn by object in shader graph

#

i just want to check if it is divideable by x

regal stag
young fog
#

Thanks

#

I have been fascinated by (whatever it's called where you have a lot of buffers and then you combine them together to make a final image)

regal stag
humble robin
#

thanks so much

#

i was wondering why it didn't work

#

its because its between 0-1 i guess

#

thanks it actually worked

regal stag
simple violet
#

am I not able to use shader.setglobalfloat() if the property is exposed?

young fog
#

I understand that now

#

you can only manipulate the image, not the object I'm presuming

regal stag
simple violet
#

ok thx

humble robin
#

i set alpha of some pixels to 0, how can i make those pixels get discarded, from depth map too? (in shader graph)

regal stag
young fog
#

Thanks for helping out btw

Not sure what else I could do with it so I'll leave it for now

molten hamlet
#

Hey, if there are any other vrchat users here, is there a chance anyone has used the poiyomi 8.0 shader and knows how to use this?

simple violet
#

doesn't vrchat have a discord

molten hamlet
#

I've asked there, barely anyone ever responds

young fog
regal stag
# young fog I just want to ask one more question regarding that, how would you do something ...

Deferred is usually quite advanced. When rendering objects to those G-buffers you use a shader that outputs to multiple targets (SV_Target0, SV_Target1, etc), rather than rendering the scene multiple times to each target separately. Can't do that in ShaderGraph so you'd need to code them.
But yeah, then there is usually a final screen space quad/blit that combines those buffers, calculating lighting/shading and outputs that to the camera target.
I'm certainly no expert but can look into these tutorials if you want to know more (for Built-in RP but the idea is the same)
https://catlikecoding.com/unity/tutorials/rendering/part-13/
https://www.patreon.com/posts/shaders-for-who-34008552

But also Unity does already have settings to switch rendering paths (Forward vs Deferred) and regular-PBR shaders (e.g. Standard or URP/Lit) that already support both. Might be easier to build on top of what already exists, rather than trying to write it all from scratch. Idk.

hexed portal
#

^ Don't try to write your own rendering pipeline unless you know exactly what you're doing.

#

It's pain enough in DX12, I don't want to imagine redoing it in Unity lmao

#

I don't know enough about Unity's rendering pipeline to really get into it, but I'll take a look into deferred rendering if you'd like

reef owl
#

using SRP with render graph isn't too terrible imo

#

that's what I've been doing for the past month, with not that much knowledge of render pipelines beforehand

#

along with the github repo itself (all the code is commented! but not in unity so you'd have to adapt it)

quaint coyote
#

@young fog I was reading your posts. Here's something that I'd like to share:

  1. if you've worked with 3d softwares like 3ds max etc, you will know that you can do multi-pass rendering (diffuse, lighting, material-id, object-id...)
  2. after rendering out those passes, the final render is taken to a compositing software and there you can mask out objects based on object id masks or material id masks.

Now come the gaming engines:

  1. With unity you can apply a trick, where you can actually texture objects with an RGB mask and get that mask as a texture
  2. (as a simple approach) Using shader graph, you can, use the RGBA channels to apply various colors to the same.

Assume you have a cube. You go to 3ds max and unwrap it. And apply 2 faces each one color. E.g. Front and Back : Red; Left and Right : Green; Top and Bottom : Blue.

Now you can render out this mask and get it as a texture in unity. Then use this as a mask

#

@young fog again, that was a simpler approach. If you know well about rendering into frame buffers (Render Targets). You can render out those masks at runtime by giving objects material id's and use that to apply different shaders and not only colors.

quaint coyote
hexed portal
#

granted I'm a graphics engineer so like

yeah, that's my job, but definitely wouldn't recommend trying to dismantle the Unity rendering pipeline to someone new to graphics

#

Honestly if anyone reading this wants to get into rendering, I'd say learn modern OpenGL first (DX12 is much harder to get started with), that'll give you some much-needed experience without the "interference" of an outside API. Same reason I never use Unity physics in games except for gameplay-agnostic stuff like debris/particles.

quaint coyote
#

Thank you so much @hexed portal ! That really helps 🙂
Also, being so much into graphics, I'd love to have your opinion on implementing BRDF's

hexed portal
#

if it's real time, are you familiar with spherical harmonics?

quaint coyote
#

any good resources you can recommend please?

#

I know the spherical coordinate system and how it works...

quaint coyote
#

thank you! I am going to read that document

hexed portal
#

on the same note, you can also decrease the precision by lowering the dimensionality of the information encoded at a given point

#

e.g. a game world might use 4D SH to bake lighting, but something lower res like a mirror or reflective puddle of water would use 3D SH because the baked reflection doesn't need to be that high res

#

i'm probably doing a poor job of explaining it lmao

quaint coyote
#

ahh! I understand. By more dimensions you might want to say what all external sources affect the point at the surface?

#

no no, I will read that paper! Thank you so much for the help.

hexed portal
#

aye, I have resources at least, I'm not an expert on the subject

quaint coyote
#

What I've implemented are just basic DGF models and done a summation of lights over it

hexed portal
#

I'm still learning tbh

#

yeah I had to do that for an assignment iirc

quaint coyote
hexed portal
#

lowkey don't know how I got this job but apparently I impressed the shit out of the right people

#

Anyway, yeah, SH is good for approximating realtime lighting, but it can also be used in baked lighting to reduce computation time

quaint coyote
hexed portal
#

yeah it's very concise and a good starting point if you're already familiar with the concepts SH is based in

#

To be honest math was never my strong suit but even I can understand what's going on lmao

quaint coyote
#

hahah! hi5 on that... I think maths gets easier to understand when its supported with visualizations

#

I never liked maths in my school

hexed portal
#

with subjects like math, having the right teacher makes a world of difference

#

on the same note my graphics professor in uni was fantastic

#

and actually the reason I got into the field in the first place

quaint coyote
#

woahh! yeah it does help to have the right person to teach you maths the way you understand. Else you end up just watching tutorials online 😛

hexed portal
#

don't underestimate the power of indian dudes on youtube

quaint coyote
fossil cloak
#

Hey guys, im looking for the Shaders Reference for the "Emission Checkbox"
I fugured out, that the Emission color is _EmissionColor and the Emission Map is _EmissionMap.
But i cant find the Reference for the Checkbox in the URP/Lit Shaders Code.

quaint coyote
#

_EMISSION

fossil cloak
quaint coyote
#

doesnt work?

fossil cloak
#

nope

#

i cant find something in the docs that explains how the references are named.. 😄

quaint coyote
fossil cloak
#

oh well, im on shadergraph 😄

#

And the _Emission does not work for any reason

quaint coyote
#

it has to be done via c# script

fossil cloak
#

But everything here works perfectly by typing in the reference here 😄 Just the Emission Checkbox does not ^^

#

i just want unity to copy the bool of the Emission Checkbox to my shader when i change it from Lit > Custom

quaint coyote
#

ohh okay, you have the code in the shader file:

#

Lit.Shader or SimpleLit.shader

#

okay you might want to ask someone else the same question, even I dont know how to enable or disable a keyword via shadergraph 😦

fossil cloak
quaint coyote
potent spire
#

So does anyone know what's going wrong here? I can't figure out why this object is occluding itself inconsistently..

#

I've tried messing with the blending modes, operations, culling to no avail

quaint coyote
#

Cull Off

potent spire
#

It's off :(

quaint coyote
#

also check the ZTest and ZWrite values

potent spire
regal gorge
#

What is custom interpolator? Can I use it as some kind output data from shader graph?

regal stag
dim yoke
regal gorge
#

I was hoping I can use it as output data in this case.

#

I need get back float current_height from shader after I feed it with player position.

dim yoke
dim yoke
regal gorge
#

That sounds like great idea.

dim yoke
#

I dont know how presicely the values calculated on CPU and GPU will match, we once had problem with that same thing but it could have been our own fault

regal gorge
#

I dont need huge precision in this case, I doing some testing for boat animation.

#

I can also use FastNoise Lite I think.

dim yoke
regal gorge
#

But its possible to use FastNoiseLite as custom node in ShaderGraph I did it before.

dim yoke
regal gorge
#

Thanks a lot for help.

dim yoke
#

Np

patent laurel
#

I created a glass shader and applied it to my objects. But I don't understand why on some it works perfectly (see right window), while on others it seems not (left window). How come?

silk dew
#

hi

#

someone use amplify ?

dim yoke
silk dew
#

i m actually have a foam like this

#

but idk how it s possible to have more "shoreline" foam

#

more like this

abstract quartz
#

Hey everyone, here is my first tutorial/article, it is a breakdown of the effect in the tweet. We will learn to do a custom render feature in Unity there 😄
https://twitter.com/KubiakErik/status/1603709184456896512?s=20&t=0Rf7Cq0J8vJBlgNDQHPCzA

Hey everyone 👋

Finally, here is the intro and the first part of the medieval post processing breakdown 😄
RT & ❤️ is really appreciated 😄
Don't forget to follow for the next parts 😉
https://t.co/3P32lwEN9g

#madewithunity #shaders #medieval

▶ Play video
quaint coyote
#

That’s cool!

wicked niche
#

When I Set my alpha to 0 i have black color, how can I fix this ?

#

when without a background the mesh is invisible

quaint coyote
wicked niche
#

how can I make the color fade around the edges in the shader, so that there is a kind of glow effect, a smooth transition from yellow to transparent?

karmic hatch
karmic hatch
karmic hatch
wicked niche
knotty juniper
silk dew
knotty juniper
wicked niche
# knotty juniper that is a spehre

what i want to do is i have an outline shader for my mesh, how it works : the mesh is duplicated, flattened, and scaled a bit. I want to make it fade smoothly in the place where this outline is visible to achieve the glow effect

#

withpout post processing

wicked niche
karmic hatch
knotty juniper
#

if post processing is not a option and your mesh is that simple of a shape you could just use a gradient to fade it out to each side

wicked niche
#

I want to draw my mesh like this fade

wicked niche
knotty juniper
wicked niche
knotty juniper
#

in most cases you would use UV cordinates to know what is the border of the mesh

wicked niche
#

I want to set alpha color in edges like this, this is my outline mesh for example

#

this might be too complicated example, but at least something simple on the subject,

as I understand it, I have to figure out the distance from the coordinates of the point to some center, and depending on the distance, set the alpha, the question is how can I just calculate this distance

wicked niche
knotty juniper
# wicked niche

will not work the way you want it to
this is a capsule scaled flat

#

you are after a distance field of a line or very thin box

wicked niche
tight vortex
#

Hey peeps,

I posted here a while ago wondering if there was a better way to make simple parallax shaders, and I've kept at it since! I think I found a pretty simple technique that holds up even at tight angles and can event be used for interior mapping... I posted a thread about it on Twitter:

https://twitter.com/OKatBest/status/1603540893742424064

Experimenting with Parallax #shaders👀

I got frustrated with how the most common approach for this effect seems to break down at narrow angles, so I came up with a new way to achieve the effect:

#shadergraph #madewithunity #gamedev

Likes

300

▶ Play video
wicked niche
grizzled bolt
broken tendon
#

So i've never used shadergraph before, and I wanted to make a texture w/ an animated normal map so i figured i'd give it a try.
I instaleld urp and shadergraph, but the material is only pink no matter what i do. This reddit thread (https://www.reddit.com/r/Unity3D/comments/mlymk0/problem_unity_shader_graph_made_shader_is_pink/) seemed to offer the solution, but i don't want the rest of my materials to turn pink. Is there any way I can use shadergraph without this?

wicked niche
silk dew
silk dew
# silk dew

someone can help me to have a result more like this

#

?

#

some parts look weird

karmic hatch
#

Could also divide the depth by abs(normalize(world space view direction).z) so it's the depth of the water, not the length of the line of sight through the water

mental bone
tulip carbon
#

Hi. Does anyone know why when using a shader in the particle system to create a heat distortion effect, those particles make any other particle behind that 100% transparent please?

karmic hatch
tulip carbon
#

and how can I fix that, if there's a way to do it please?

simple violet
#

change your heat distortion shader code

tulip carbon
#

it is just this, what do I have to change sorry

cosmic prairie
#

are those still a thing?

#

or just the opaque texture

#

found this, bazinga

#

seems cool

cosmic prairie
tulip carbon
#

okay thanks

cosmic prairie
static meteor
#

im trying to achieve an effect where a 2d circular sprite imitates a spinning sphere, i found relatively helpful resources but im not sure how to translate to a shader or shadergraph, https://gamedev.stackexchange.com/questions/147193/imitate-a-textured-sphere-in-2d, 30:31 in this gdc talk https://gdcvault.com/play/1021863/Classic-Game-Postmortem-Star, im using urp's lit sprite shader as a base, in the first case there is a warning about sprite renderers not supporting offset, and the second case the shader doesnt have a heightmap, it seems a sprite mask is the way to go and just sliding the texture, but the actual distortion of the texture and retaining the pixel art is the problem

tulip carbon
cosmic prairie
#

The shader needs to render after this "after transparents" tag

#

lemme check the docs for further detail

tulip carbon
#

okay thanks and sorry😅

cosmic prairie
#

can you check if this works?

#

what you need to do is:

#

it should add this

#

So, to sum it all up, for this to work you need to add a "LightMode" tag to the shader, that has the same value you provide on the render feature "Shader Light Modes" section

cosmic prairie
# cosmic prairie

this would be easy if it were a coded shader, but in shader graph this may be the correct way?

tulip carbon
cosmic prairie
#

no, you need to add LightMode instead of RenderType

tulip carbon
#

just like this?

cosmic prairie
#

and now change the default value to DistortionTexture

#

I guess you need to edit the entry

#

when you have that check if it works

cosmic prairie
#

yeah I guess

#

check if it works like this, don't forget to save the graph 🙂

#

if it still doesn't, please select your shader graph asset, and click View Generated Code

tulip carbon
#

still nothing, now all I get is some kind of grey stuff

cosmic prairie
#

grey stuff is better than nothing

tulip carbon
#

or which part is important?

cosmic prairie
#

I guess just an image of everything thats in the first part

#

just as it opens

tulip carbon
cosmic prairie
#

damn

#

okay, it did not add the tag

tulip carbon
#

that's not good

cosmic prairie
#

alright, new plan, delete the enum thing in shader graph, and create a blank shader in your assets, just a regular shader, not a graph

#

then, generate the graph code again, and copy it all, and paste it into the new file you just made

#

after that, you see that lightmode part?

#

instead of that comment, write "LightMode"="DistortionTexture"

#

should definitely work ™️ ©️

#

oh, and save the shader and assign it to your material ofc

#

the downside of this, is that every time you change the graph you will have to do this

#

the key part is the LightMode tag

#

I honestly have no idea why they did not make this a lot easier

#

adding custom tags should be easy to implement, and grabpasses should have been replaced by something

tulip carbon
#

well but do I have to copy everything like with the texture thing in the shader graph or like as it was before?

cosmic prairie
#

what do you mean as it was before?

#

no, only remove the enum part

tulip carbon
#

like, is this the thing I have to copy in code?

cosmic prairie
#

the new texture stuff is needed

#

yeah, keep that, it's still needed

tulip carbon
#

okay so this is how the new code should look like?

cosmic prairie
#

yep! nicely done 🙂

#

does it work now? 🤞

tulip carbon
#

now nothing seems to be showing :/

cosmic prairie
#

can you increase the material's render queue by idk, 200?

tulip carbon
#

so set it to 3200 or just 200?

cosmic prairie
#

3200

tulip carbon
#

still nothing :/

cosmic prairie
#

🤔

#

I'll download the demo real quick

#

check out what could be the issue

tulip carbon
#

I changed the shader light modes thing and now it's black, idk if that's good or bad progress

#

like, this thing

#

before was like this and that's when nothing was shown

#

and now grey again without changing anything...?

cosmic prairie
#

I'm opening the project

tulip carbon
#

okay

#

I might not even have time today to solve this, I thought it would be an easy fix but it isn't😅

cosmic prairie
#

yeahhh... it SHOULD be easy

#

it's just a missing piece of URP rn I guess

tulip carbon
#

yeah, but what can it be :/

cosmic prairie
#

okay wait

#

1 sec I'll add image

tulip carbon
#

okay😅

cosmic prairie
#

add underscore

#

:DDDD

tulip carbon
#

now it's black

cosmic prairie
tulip carbon
#

I don't know, where is it supposed to be?

cosmic prairie
#

the texture node of your shader

#

that you sample

tulip carbon
#

that?

cosmic prairie
#

ye

tulip carbon
#

it is like that

cosmic prairie
#

hmm okay

tulip carbon
#

well I have to disconnect now, tomorrow I'll try to search for a fix if one even exists😅

#

thanks for all the help tho, I didn't know any of the stuff you told me tbh

cosmic prairie
#

no problem, tomorrow if you send me the shader I can test it out

#

maybe I can get it working and drop you the solution

tulip carbon
#

which one, the one in code or the one in shadergraph?

cosmic prairie
#

or you can send it now if you have the time

#

the graph

#

I would like to help you in a way that you can replicate 😄

tulip carbon
#

well thank you so much

#

byee

cosmic prairie
#

bye bye!

cosmic prairie
#

made a fork

static meteor
#

I made good progress on my spherizing sprite shader, is there a way to have the shadergraph target sprite sorting layers? Or some equivalent of selective distortion, not just everything behind the material

cosmic prairie
#

if you need stuff behind your object preserved, you should use a secondary camera to render the planet

#

if a dynamic planet is your goal

cosmic prairie
#

will you have stuff happen on it's surface?

#

because if nothing will move on it, or simple stuff happen that can be achieved in a shader, I would just advise rendering the whole effect in a shader, and not distorting anything on screen

gritty turret
#

Oculus Quest 2, Android, URP: Any suggestion how to make this cone look cooler? It's the cameras' detection cone. Right now I just packed a transparent material with some emission on it.

low lichen
cosmic prairie
#

could be fully volumetric if you render an inverted (Cull Front) mesh with a depth-only shader before the effect

#

probably would have to be in the AlphaTest queue so the depth texture is updated beforehand

#

which means the skybox would not render properly behind it

#

but as I see it's inside

cosmic prairie
#

and then it would work without skybox issues

#

(and other possible transparency issues 😳)

cosmic prairie
gritty turret
#

Thanks!

cosmic prairie
#

may not be up to VR performance standards

cosmic prairie
# gritty turret Thanks!

Also, you could easily add some dust to it, particles that shine more as they are closer to the camera and inside the cone

#

if it's futuristic maybe it could be a bit hologram-like, some fancy scanlines added

gritty turret
#

I'm close to buying the volumetric lights asset as it includes this stuff ;D

cosmic prairie
#

😄 make sure it's VR optimized

gritty turret
#

at least that's what they're stating

cosmic prairie
#

evil dyno bot : (

gritty turret
#

but it's only 35€ and that's definitely cheaper than me relearning math

cosmic prairie
#

I imagine these could be way more sparse, and moving around, some independent of others

gritty turret
#

they look fantastic

cosmic prairie
#

for holograms

#

for the camera it should be more subtle

#

and randomness would make it interesting

gritty turret
#

I like it! will test it tomorrow in VR. Theres a component for dust particles, didnt check this out yet.

static meteor
static meteor
#

the problem i find with doing it in the effect itself is that the texture is a rectangle, so the visible uv needs to be square to be cut onto the circle properly, sprite renderer apparently doesnt like offset, so i need another way of panning/scrolling it

regal gorge
#

Someone knows how to include FastNoiseLite as custom node in Shadergraph? I remember I did it back then but it was C#, and not HLSL and Im little bit confused.

#

I have no idea how to do it.

#

I tried figure it out for some time but I still cannot do it.

cosmic prairie
#

you need to scroll inside the shader

cosmic prairie
indigo cave
#

Do shader graphs that apply an outline to a mesh not work with quads? I have a custom mesh that made of a number of quads (think of it as a puzzle piece), been searching for an entire day to apply an outline to it. I tried many solutions, some of them worked with a sample capsule mesh object, but never my quad.

dim yoke
shadow locust
indigo cave
#

Well basically i only needed to know if quads are exceptions when it comes to applying outlines. Now i know i just need to do more research on it. Thanks

humble robin
#

how can i make a pixel that has 0 transparency get deleted from depth map too

#

on shader graph

#

not just be transparent but get deleted

#

equivalent of discard

#

in shader graph

cosmic prairie
#

it's the same as clipping or discarding

humble robin
#

is it available in sprite custom lit

humble robin
#

i could find that setting in lit or unlit

#

but those dont have the 2d light texture afaik

gritty turret
mint yacht
#

Don’t know if this would go here, I’m doing the vr room tutorial, and everything is just a light blue. I don’t know why. It’s just blue. So I don’t know how to fix this. Could somebody help?

tame topaz
mint yacht
#

oh alright

#

thank you

mint yacht
#

it's been an hour, still no diffrence

mint yacht
#

It’s still just blue

indigo cave
#

So I have created this shader graph, and I am pretty happy with the result on the sphere, but it doesn't work with a quad. I think it is because fresnel effect uses directions to make the effect and a quad is only one-directional, but what other approach should I take then?

grand jolt
#

Hey, anyone who knows about shaders can give me some pointers on what I need to modify here to get rid of alpha blending?

#

As you can see, when the text overlaps, the alpha multiplies, instead of this i just want 1 constant color. is it possible. ty

kind juniper
grand jolt
#

How do i render all as 1

kind juniper
#

A custom text rendering system with a custom shader I guess. The simplest solution would be just to save that text as a texture and use it with an image component. Or avoid having them overlap.
I'm not sure if there's a better way. Maybe someone else has an idea. Try asking in #📲┃ui-ux as well.

grand jolt
#

This is so trivial on the web, yet so hard in Unity for some reason 💀

#

I managed to get it to work almost

#

how do i fix where its not renderng

#

Lol i did it

kind juniper
#

How??

grand jolt
#

To all use the same stencil, comp notequal and some other settings

#

It Works for my use case. I might publish a Gist of the shader since I’ve seen this same question asked in a few places and repeatedly left unanswered

#

It ruined anti aliasing though

tribal badger
#

Hi, still not sure how Discord works, and/or if this is the right place to ask, but I have a high level shader/ shader graph question:

In I use a "default" URP/Lit material, I get properties for a normal map, metallic map, occlusion, etc. If I create my own shader graph for some effect, is there an easy way to "layer" it with the default Lit shader properties? Other than adding new texture properties and reimplementing the other behaviours?

Basically what's the standard way to "compose" effect to avoid duplicating code/shaders?

wary horizon
#

I made this shader to directly negate fog. this works in editor, but in build its not working at all, Anyone know why?

grizzled bolt
wary horizon
#

Editor:

#

Build:

grizzled bolt
# wary horizon Mainly the boolean keywords, to negate fog. this works in editor, but not in a b...

https://danielilett.com/2021-05-20-every-shader-graph-node/

A Boolean keyword is either true or false, so using one will result in two shader variants. Depending on the Definition, the shader acts differently: Shader Feature will strip any unused shader variants at compile time, thus removing them; Multi Compile will always build all variants; and Predefined can be used when the current Render Pipeline has already defined the keyword, so it doesn’t get redefined in the generated shader code. That might otherwise cause a shader error.
Sounds like something related to shader variant stripping

wary horizon
#

I did set multicompile

grizzled bolt
#

Though I'm really not familiar with it

wary horizon
#

You and me both haha

regal stag
wary horizon
#

mmm, lets give it a shot!

wary horizon
regal stag
wary horizon
#

Gotcha, i'll try it out!

wary horizon
harsh marsh
#

With custom render textures, is there a way to sample _CameraDepthTexture/_CameradDepthNormalsTexture?

#

I tried seeing if

return tex2D(_CameraDepthNormalsTexture, IN.localTexcoord.xy);

would work, but I just get grey .

fierce creek
#

How do you bring up the "add node" interface via keyboard?

#

I've tried everything under the sun that I can think of and nothing works

#

Surely I'm not expected to right-click, "Add Node" every single time

#

That would be crazy! heh

#

oh looks like you can at least get it up by dragging off an existing node connector

stable agate
#

idk if this channel is the right for this question
but is there a way to tell unity that there isnt a uv overlap where unity says there is?

#

these 2 are the exact same from blender to unity, and as you can see in blender, there isnt any uv overlap

vocal narwhal
stable agate
#

idk what uv2 is

vocal narwhal
#

The 2nd UV channel

stable agate
#

?

#

what do u mean 2nd uv channel

stable agate
#

i have no idea what to do

vocal narwhal
#

What don't you understand about the linked documentation?

cosmic prairie
#

lighter grey parts

stable agate
#

i used the select overlay function in blender, didnt show me anything

cosmic prairie
#

I think the light gray is overlap tho

#

might be wrong

#

try pulling a corner of the light grey rectangle

#

does it have stuff under

stable agate
#

it does not

cosmic prairie
#

looks like overlap

stable agate
#

there isnt

cosmic prairie
#

there's another rectangle under?

stable agate
#

nope

#

thats just the borders

cosmic prairie
#

ah

#

can you select that grey face and delete now I'm curious

#

what does it show

#

the only time I had that was when something was overlapping

stable agate
#

cant delete any faces in uv unwrapping

cosmic prairie
#

well, de-select in edit mode

#

do you have to deselect multiple to make it go away

stable agate
#

deleted the face

cosmic prairie
#

🤔

stable agate
#

yeah

#

i have no idea why unity says there is overlap

#

and funny thing is

cosmic prairie
#

is this for lightmap btw?

#

where does it say

stable agate
#

after i fixed another uv overlap (made sure using unity uv overlap)
baked again and i got 1 more uv overlap now
11 before
12 now

#

anyway, im gonna head off now

cosmic prairie
#

aight

#

gl with it

#

may the christmas spirit guide you

harsh oracle
#

why is the depth buffer (_CameraDepthTexture) always blank (completely black) when I try to access it in my postprocess shader despite the fact that Depth of Field postprocessing is working?

#
    TEXTURE2D_SAMPLER2D(_CameraDepthTexture, sampler_CameraDepthTexture);```
#

it's just always a completely black texture

vast sail
#

how do I get my hands on the source for the built in metallic shader

#

I would like to reference their math for supporting both a mask map and a functional slider for smoothness and metallic

simple violet
#

In the unity github

vast sail
# simple violet In the unity github

yeah thats what I found, theyre just written in an incredibly distinct way from the way everything else teaches you to write shaders, I only care because I'm in an older version of unity

#

I guess Ill ask my main question: I want to support both a metallic map texture and a smoothness/metallic slider but have the texture take precedence, such that if the texture is present the slider information is disregarded, similar to how the standard shader works

#

non branching way to do this in psudeocode seems like metallic = metallicSlider * hasmetallictexture + metallic texture * hasmetallictexture

#

no clue the exact way to do this though

#

and unity shader source is very unclear for my beginner eyes

simple violet
#

idk im a beginner too

#

but I'm guessing not having a metallic texture would just be a black color

#

and the black color would be replaced by a texture

#

if you do have a texture

#

i reccomend u follow catlikecoding tutorial

quaint coyote
quaint coyote
quaint coyote
tacit parcel
#
\\do something
#else
\\do other thing
#endif```
quaint coyote
tacit parcel
# quaint coyote that is counted in static branching

but unity does that too

{
    #if GLOSSMAP
        return saturate(s.smoothness + (1-s.oneMinusReflectivity));
    #else
        return i.eyeVec.w;
    #endif
}```

Source
https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/CGIncludes/UnityStandardCoreForwardSimple.cginc
GitHub

Unity Built in Shaders. Contribute to TwoTailsGames/Unity-Built-in-Shaders development by creating an account on GitHub.

quaint coyote
#

Yes unity does that. Just that he asked what’s a non-branching way of doing it 😅

tacit parcel
#

No, he asked the source for the built in metallic shader (which is actually integrated in the overly complex standard shader system), the non branching is most likely a guess or a suggestion.

quaint coyote
tacit parcel
#

actually, that's just my guess too 😅 I've might just misinterpreted it as well

quaint coyote
#

He has a lot to read when he's back at work though 😄

quaint coyote
#

While writing a custom renderer feature, how do I make sure to draw an object with a second shader pass index and not with first pass index? I am not overriding the material.

quaint coyote
#

I was able to render using light mode tag. But I guess there should be a way to set the current materials pass index. Or access the current material / shader that’s rendering the renderer

inner plover
quaint coyote
#

also there are 2 position nodes, I am assuming you are talking about the one that is in the bottom left of the screen right?

wicked niche
#

Can I create shader in shadergraphy like mobile simple shader?

quaint coyote
# inner plover Yes.

so 2 things. You need to remove the position node from the UV node of the Tiling and Offset node.

#

rather you should change the position from world to screen space. I am sure you want screen space uvs and not world space uvs if you want to put them into the UV channel of the Tiling and Offet

#

try that first.

inner plover
#

Using the Screen Position node?

quaint coyote
#

yeah

inner plover
#

I don't think that is what I am looking for. What I am trying to do it have the water tiled so I can have multiple water chunks. That is why I used the Position node.

quaint coyote
inner plover
#

It still has the same result.

#

It also seems when I put the position into the Tiling and offset node it changes to a Sphere.

regal stag
wicked niche
#

why my all nodes are black?

regal stag
# wicked niche

Looks a bit bugged. But at a guess it might be that the graph has no Target (under Graph Settings tab of Graph Inspector)

regal stag
#

The graph requires a target. Press the + icon under that list and add the render pipeline you are using

inner plover
wicked niche
regal stag
regal stag
regal stag
#

Which property are you editing?

inner plover
#

The scale of the gradient noise.

#

I got it to work, I messed around with the Gradient Noise scale.

wicked niche
#

how can I adjust the transparency in the vertex shader depending on the deviation of the normal, I calculate through the dot the value between the normal vector and the vector directed towards the camera

amber saffron
#

Further than this, the normal is not modified at all apparently.

wicked niche
#

to 0.6

amber saffron
#

You didn't also apply the vertex color in the fragment stage ?

But now, simply, you just have to assign this alpha value to the vertex color alpha channel, and it should be good.

wicked niche
amber saffron
amber saffron
#

Personally, I output values as readable unlit color

wicked niche
tranquil cipher
#

can anyone gimme an example that we can use view dir to make fun uv offset effect in shader graph ?

#

I wanna google for it but don't know the terms to search

tranquil cipher
#

I just wanna add some juice to her eyes bright dot, but don't know how to

#

if they're just static like a texture map then they're not so fun to look at

amber saffron
#

Is the "bright spot" already in the texture ?

tranquil cipher
#

no the bright dots are separated texture

#

they will be applied parallax

amber saffron
#

You probably want the view direction to be in tangent space btw

tranquil cipher
wicked niche
amber saffron
wicked niche
astral spade
#

Error building Player: Shader error in 'EasyRoads3D/Terrain/ER Terrain Mesh Tesselation': maximum ps_5_0 sampler register index (16) exceeded at line 149 (on d3d11)
Line 149:

            sampler2D _NormalMap, _greenNormalMap;
amber saffron
wicked niche
amber saffron
astral spade
amber saffron
astral spade
#

I know nothing about shaders.

#

So I have no idea what you're talking about.

wicked niche
# amber saffron I have no idea of what you are doing or trying to do. I was assuming you were ge...

I’ll tell you in more detail, I generate a cylindrical mesh along the spline through the so-called TubeGenerator component

I want to add a simple glow effect

The original cylinder will still be drawn, I just need to add a little blur around the edges along this cylinder as if it were a lightsaber

I refused post-processing, there was also an idea to generate a flat Line along the same points of the spline with a white texture that disappears at the edges, but I think all these methods will be very expensive for weak devices

astral spade
#

You don't know how to solve it?

grizzled bolt
grizzled bolt
#

That's an error, not a problem description

astral spade
#

So how can I describe an error more than that?

amber saffron
astral spade
#

This error came from a paid asset.

amber saffron
amber saffron
#

Well, hum, please delete this link

astral spade
#

Why?

amber saffron
#

Your are now sharing source code of a paid asset

astral spade
#

"Terrain Mesh Tessellation"

#

That doesn't seem important.

amber saffron
# astral spade That doesn't seem important.

That's not the debate. EasyRoads3D is a paid asset, they put time and effort to make it and write the shaders, you don't have the right to share their source code out publicly

astral spade
#

Do people create shaders visually or via code btw?

amber saffron
#

Please remove the link or I'll have to report your to moderators

amber saffron
amber saffron
astral spade
#

no

amber saffron
grizzled bolt
# astral spade This error came from a paid asset.

We can't generally know from just the error what it is you were you trying to do or what the expected result is
A lot of the times the error itself is not the root cause, or even related to the apparent issue
Nor is it anyone's responsibility here to fix assets you bought

astral spade
#

So