#archived-shaders

1 messages Β· Page 233 of 1

regal stag
#

I'm not going to fix it for you. I've explained what could be the problem and what node could potentially fix it.

grizzled bolt
#

It would help you to practice with some tutorials so that you do know what you're doing
There will be plenty more challenges ahead

regal stag
pine arch
#

How can i get the object bounds in shader graph ?
i need to offset something in my shader to adapt to any object pivot so i guess i need the bounds info

#

something similar to this node in UE : ObjectLocalBounds

dire flume
#

I am working on adding a desaturation shader in the project I am working on and am finding that other UI elements that are behind the plane with the desaturation material are not . Is there a simple way to apply the desat to the UI elements that I am missing? Currently i have tried sorting canvases, sorting render layers and can get the ui elements hidden but that is not the effect I am going for

grand jolt
#

im bad at reading shaders

#

which part of this unity shader accoutns for shadows?

clear vector
#

Hi! Does anyone know how Material.ComputeCRC() works?

tacit parcel
#

Looks like the blade is rendered twice and have z-fighting, do you have culling disabled?

dim yoke
wise willow
#

How do I write to the _ShadowMapTexture buffer??

lone bone
#

im working through the patreon instructions, but mine already looks nothing like theirs, even though we have the same blocks. Any idea why?

dim yoke
lone bone
#

oh hold on let me put the first node back

dim yoke
#

the result depends on sphere radius and sphere position. you should use exactly same default values as they do if you want the same results

lone bone
#

they dont list the default values, and the first node isnt affected by radius and it still looks different. Ive tried setting the vector3 to 0,0,0 , 1,1,1 , 40,40,40, but none of them worked

summer beacon
#

Im currently making a light beam effect for a movie projector and this is what i have so far with an unlit shader graph. Is there a good way of making the end bit fade out? so that its not as abrupt?

regal stag
# lone bone they dont list the default values, and the first node isnt affected by radius an...

Pretty sure they use (0,0,0) but the difference is due to the 3D/sphere vs 2D/quad previews. You should be able to override it to the 2D one for your Distance node in the Node Settings (tab on Graph Inspector window). Assuming you're in a version which has that option, can't remember when it was added (v11 maybe?)

Otherwise using a value of (0,0,-0.6) should move the dark point roughly to the front of that sphere in previews.

regal stag
dusty coyote
#

How could I make the line's caps (like the end and the beggining of the line) rounded? I'm using 2d unlit sprite URP. Help would really be appricated πŸ™‚

regal stag
# dusty coyote How could I make the line's caps (like the end and the beggining of the line) ro...

The "Segment" sdf from here should give what you want : https://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
It's written in glsl so you'll need to convert it to graph form or hlsl and use a Custom Function node. (Mainly just vec2 -> float2, could replace the clamp with saturate)
Can then subtract a value from the dsf result to make it thicker/rounded, as explained near the bottom of the article.

sharp delta
dusty coyote
devout granite
#

I have a displacement map that I exported from Substance Painter, but it seems like the shadergraph wants nothing to do with it. I'm using URP and it has to be OpenGL compatible because I'm making this sim for the quest. Here's what my mesh is looking like with & without the displacement currently. Not sure what's going on here

#

here's what I have now in the graph, not sure if I should be doing something differently - a lot of the youtube tutorials on displacement are either old or not OpenGL/URP compatible

amber saffron
#

Or maybe even do a "push" operation : add normal x displacement to the position

devout granite
#

the add worked pretty well! one of the pieces of the mesh doesn't want to move with the rest of it but I'm going to make sure my UVs are correct there first

amber saffron
devout granite
#

since it's in VR there's going to be some LODs, so we wanted actual vertex displacement when the player is looking super closely at the ground. There's some rocks, wheel treads and footprints in the dirt so we figured actual vertex displacement would be beneficial for LOD0

amber saffron
#

My point is : vertex displacement isn't adding more geometry anyway. If it is static and you have LODs anyway, I would recommend to just bake that displacement into the vertex positions of the mesh :

  • less shader computation as it's already displaced
  • you will profit of better lighting as the vertex/faces normals will take the displacement into account, that is not the case currently in your setup
steel notch
#

So I want to create an intersection shader similar to the one displayed in this video.

#

But from the looks of it, the intersection is drawn on the back faces of the mesh, which mean lighting and sorting (like objects inside the mesh) won't look correct.

#

Is there anyway to figure out the intersection between the plane and some given object, and then display some texture on the plane where there is an intersection.

supple thistle
#

my weapon does this when under heavy light, any idea why?

shadow locust
shadow locust
hearty obsidian
#

how do I get the texture width/height when passing a texture to a custom function in shadergraph?

supple thistle
hearty obsidian
#

I have to pass it from the graph? I meant is there a way from inside the function

steel notch
steel notch
#

and the position of the plane is used to alpha clip the mesh

shadow locust
steel notch
#

Alright because that was word vomit on my part πŸ˜›

regal stag
supple thistle
#

@shadow locust do you have any idea what could cause that?

hearty obsidian
#

@shadow locust @regal stag thank you both ❀️

shadow locust
steel notch
#

I can still use the UVs of the Plane though

shadow locust
#

if that's available to you then yeah that can work

steel notch
#

as long as the mesh and plane move together

#

should be good?

hearty obsidian
#

One last Q, if I want to iterate through the pixels of a texture, I came up with this mess but is there an intended way to iterate over a texture?

float2 uv = (float2(x,  y) + 0.5) * texelSize;
float4 data = SAMPLE_TEXTURE2D(Tex, SS, uv);
lone bone
# regal stag Pretty sure they use (0,0,0) but the difference is due to the 3D/sphere vs 2D/qu...

ok, ive implimented to effect, but its still not quite what im trying to achieve.
if the scene looks like this normally:

then it should look like this when the effect is on:
ive kind of found a similar effect online but i dont think it works anymore, as the shader merely shows up as pink: http://halisavakis.com/my-take-on-shaders-spherical-mask-dissolve/

#

this being in a 3d environment of course, not 2d

#

And this effect hides objects outside the sphere, weather the camera is inside OR outside the sphere, the effect remains the same

supple thistle
steel notch
#

If an object has 2 materials, is the order of operations...

  • Vertex Function 1
  • Fragment Function 1
  • Vertex Function 2
  • Fragment Function 2

or

  • Vertex Function 1
  • Vertex Function 2
  • Fragment Function 1
  • Fragment Function 2
digital vector
#

probably the former, although this should not matter, as the materials wont affect each other

steel notch
#

Or more that it's just two separate processes?

digital vector
#

the way materials work internally is:

  • Pass the mesh handle (pointing at the mesh data in the gpu) that the material belongs to to the gpu
  • Set the shader program of the material in the gpu
  • pass variables and buffer handles (like textures) to the gpu
  • render to the output image
lament scarab
#

How would one go about combining shaders? I want to use a disolve shader on an object that already has a complex shader, what's best and the easiest way to go about this? The object is made of multiple parts that have different shaders too.

digital vector
steel notch
#

Is there any way to access the Stencil Buffer from Shader Graph?

supple thistle
#

can someone please help me with my shader issue it's making me pissed

vocal narwhal
#

Provide some more context

supple thistle
#

Well when under certain light sources my shader seems to change colors

#

Like inverted almost, white to blue

vocal narwhal
#

and what is "my shader"

supple thistle
#

Another example

supple thistle
vocal narwhal
#

I don't see a shader

supple thistle
#

The shader is on the weapon/screenshots

#

I can’t really send a pic of my whole shader but I could try and send some

vocal narwhal
#

What is the shader made in

supple thistle
#

Unity shader graph

vocal narwhal
#

Well, the problem is probably some logic in there

supple thistle
#

any rough idea what i could be?

#

its a problem with the white parts turning blue, so i can assume its

#

something around here

vocal narwhal
#

put a Saturate node in a few places and that might just fix your issue

supple thistle
#

where do you think? it would be best

steel notch
#

So I'm trying to make a shader that writes all the backface pixels to the stencil buffer. I don't want it rendering anything.

#

This is the code

#
Shader "Unlit/BackfaceStencil"
{
    Properties
    {
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100
        Cull Front
        ColorMask 0

        Stencil
        {
            Ref 1
            Comp Always
            Pass Replace      
        }

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
            };

            struct v2f
            {
                float4 vertex : SV_POSITION;
            };

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

            fixed4 frag (v2f i) : SV_Target
            {
                return fixed4(1, 1, 1, 1);
            }
            ENDCG
        }
    }
}```
#

Unfortunately it's producing this very strange and glitchy looking back area.

#

and when it I move the camera around it does strange things >_>

#

I was told that ColorMask 0 would just not call the frag function.

supple thistle
twilit slate
#

Hi do you know why this happens, i'm new to shaders ? I'm using the Unity custom lighting shader but it keeps saying this but it's working for others ppl

digital vector
analog karma
#

how do i use the tri-planar node?

#

with a generated texture

amber saffron
# analog karma with a generated texture

The triplanar node is based on texture samples, and as such, need a texture object to sample from.
If you're doing some kind of procedural (noise, sdf, you name it) texturing, you will have to implement the triplanar mapping yourself (do the mapping in the 3 world axes and blend together using normals)

dim yoke
amber oracle
#

i'm trying to blend two rendertextures respecting their depth buffers (i.e. things in front should be in front), they're rendered from identical cameras in the same position - could i do this in a shader or have i missed some more obvious way to render two cameras into the same texture with proper z-testing

low lichen
#

It's more complicated with deferred rendering though

amber oracle
#

yeah but it ignores the depth buffer / z value - i do have the clear flags set to depth only but the second camera draws on top like another layer even if on the same depth (camera setting, both at 0), like for example if a tall object is partially behind a short object, when drawn by the second camera it'll draw entirely on top of the short object which is on the first camera

#

unless there's something i'm missing?

low lichen
amber oracle
#

ahh yeah thanks i just didn't understand what those options actually meant

lost kernel
#

ok maybe someone has an idea, i have an "outline" shader, a object behind a wall has an outline and also the complete body has a color, for some reason i have to have 4 children that must be single objects (they move seperately) if i add the outline shader to all you can see the parts through the body, i need the shader to only draw the body if the GROUP of meshs is behind an object

#

anyone has an idea?

#

is that even possible ?

steel notch
#

I want to define some point and clip all pixels that fall below the x,y,z of the point.

#

I tried doing it like this.

#
Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            float4 _MyVector;

            struct appdata
            {
                float4 vertex : POSITION;
            };

            struct v2f
            {
                float4 vertex : SV_POSITION;
            };


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

            fixed4 frag (v2f i) : SV_Target
            {           
                if(i.vertex.x < _MyVector.x || i.vertex.y < _MyVector.y || i.vertex.z < _MyVector.z)
                {
                    clip(-1);
                }

                return fixed4(1, 1, 1, 1);
            }
            ENDCG
        }
#

But it's not working, so clearly I don't understand how to use Clip well.

#

still a regular cube.

#

or wait what

#

it changes as I move the camera

regal stag
# steel notch ```cs Pass { CGPROGRAM #pragma vertex vert ...

You're doing it on vertex which is in clip space (well, probably NDC at this point) due to the UnityObjectToClipPos function (and perspective divide that occurs between vert & frag).
I'd assume you want to pass the object or world space coordinates through and compare against that instead.

steel notch
#

oh wait I'm stupid

#

ya I'd like to do that

regal stag
#

Could also use discard; keyword instead of clip(-1); but they'd do the same thing afaik

steel notch
#

what's the method to convert to unity world space?

#

mul(unity_ObjectToWorld, input.vertex);

#

I think

regal stag
#

Yeah, though I'd probably use float4(input.vertex.xyz, 1); in the second param just to be safe

regal stag
lost kernel
#

Maybe that explains it better

steel notch
lost kernel
#

@regal stag i think that's the way to go, but somehow i can't get it to work

#

lessequal almost did what i want but the parts between the two got another color then :/

steel notch
#

But doesn't writing to/checking the Stencil Buffer occur between the vertex and fragment programs?

#

And I can only discard for alpha clipping in the fragment?

#

Basically looking to replicate this.

#

Write exposed backfaces to stencil, use that data to draw on a plane.

#

I don't want to draw on the backfaces themselves.

lost kernel
#

Did you see that it's on Github @steel notch

regal stag
steel notch
#

So ordering is a bit fucky.

regal stag
#

Yeah it draws to the back faces but with UV coordinates aligned to the clipping plane rather than the regular ones

steel notch
#

Ye. I want to be able to have other meshes INSIDE the one I am clipping into, so even if the clipping plane is infront of these inner meshes, they will always appear in front.

#

Since it draws to the back faces.

#

Back to just a general question though. If I discard a fragment, does it write to the Stencil buffer?

#

Or is the reading/writing to stencil purely something that happens between vertex/fragment.

regal stag
#

If you discard that pixel won't test/write to the stencil buffer

#

I think the stencil test/write might happen before the fragment shader only if it doesn't use clip/disard. Otherwise it runs after. The same thing happens with ztest/zwrite

steel notch
#

Alright so...

  • One shader that renders back faces, clips and then writes to stencil.
  • One shader that renders front faces, clips and then resets stencil.
  • Shader for the plane that uses info in Stencil to draw.
regal stag
#

Yeah. An alternative to using stencils might be to calculate the depth to the clipping plane and override it for back faces using the SV_Depth output. (Though I'm not entirely sure on how to calculate that right now. I guess it's kinda like ray-plane intersection)

steel notch
#

Boy do I wish URP had multi-pass.

#

Tossing it multiple materials with Tiny shaders is kind of annoying.

#

Oh well.

#

Is the default value in the Stencil 0 or 255?

regal stag
#

Should be 0 afaik

lost kernel
#

Why do i get the warning i should consider using multiple shader passes in URP if it's not even possible ?

steel notch
#

How do I make it so the shaders only job is writing to the stencil and not actually... producing a value for the pixel?

regal stag
steel notch
#

I tried that and the region became this odd black zone of DOOM that caused graphical insanity.

regal stag
#

Maybe also with ZWrite Off?

steel notch
#

wont that mess up ordering?

#

Actually I guess not since the plane will have the job of ordering itself

#

and the stencil literally just contains a number

steel notch
#

If I am trying to manipulate the shader properties by script, which name am I supposed to use?

regal stag
#

_MyVector

steel notch
#

so this?

#

doesn't seem to be working

regal stag
#

Might be the OnValidate method? I'm not that familiar with it so not sure when it gets called.

steel notch
#

Im just tossing the material assets into a list

#

nice

lost kernel
#

@regal stag

#

still some problems but almost

#

thx for the idea

eternal depot
#

(1st, not Playing) (2nd, Playing)
Why is it that when i play the game the lights go like this? I havent done anything to the lighting or anything

#

When i play the game, its starts on a title screen then changes to this

shadow locust
eternal depot
#

oh slick. tbh i never knew this, its just one day this started to happen. did u have to do this now after a specific Unity update?

swift basin
#

I have a very basic question, just trying to learn:

I have a shader I'm trying to put on a texture, and it comes out grey. I know im missing something very simple...

vocal narwhal
#

Make sure the UVs are set appropriately. Put the material on a primitive to see whether it's an issue with your material or your mesh

swift basin
#

its an issue with the shader I think? I think it's this part:

#

@vocal narwhal

vocal narwhal
#

Your shader has definitely been saved?

swift basin
lone bone
#

is there a way to keep the texture size the same regardless of the scale of the object?

vocal narwhal
lone bone
grand jolt
#

Hello a little question - what is on demand remap for materials is supposed to ? For me it's just erases all the materials in the prefab

#

Also, how comes that some embedded textures in .fbx change tome and color in unity?

rugged aspen
#

Hi, i have materials that remain pink, even after upgrading them to HDRP. The materials have autodesk shader. Has anyone had this problem too maybe?

fervent flare
#

Anyone know of good ressources on how to create skybox shaders with shadergraph ?

lone stream
#

in shadergraph is texture 3d sampling are not supported?

#

hmm it seems i can't sampled texture 3d in vertex pass, well this is sad. . .

regal stag
# fervent flare Anyone know of good ressources on how to create skybox shaders with shadergraph ...

This might be helpful : https://jannikboysen.de/reaching-for-the-stars/
It's mostly the same as any other shader, except the skybox mesh has 3D UVs stored - that are actually the same as the vertex positions (Position node (Object)). Since they are 3D you'll likely need to handle the UV input on most nodes or it'll stretch through an axis. (Some examples of different ways to map them : #archived-shaders message)
(I would however avoid using multiple 'Skybox UV' subgraphs like Jannik does as that will do the calculation multiple times afaik)

regal stag
lone stream
nimble solstice
#

Honestly, I'm still confounded at why materials on imported fbxs are r/o. What is the point of making a new material but then restricting modification to it. I'm very curious about what unity devs reasons are for this.

lone stream
#

Wait how can i use Tex3DLOD in custom function ?

float4 Tex3DSample =  SAMPLE_TEXTURE3D_LOD(Texture3D_input, Sampler, UV, LOD);
Out = Tex3DSample;

This giving me Intrisic Error

regal stag
regal stag
#

It looks like you're using both Tex3DSample and tex3dsample there

lone stream
#

oh . . . . . typo. . . . welp i'm dumb πŸ˜…

tender remnant
#

hmm.., I'm dumbfounded.., I'm trying to supply a matrix through a script using "Shader.SetGlobalMatrix" function. It works as intended on my custom skybox material but I also have a water plane in the scene and that one doesn't seem to use the matrix properly. I can see in the frame debugger that the values look correct but it starts flickering and doing random things on the water plane. Anyone else know what might cause this or have experienced similar issues with supplying matrices through scripts to a shader?

#

and to just clarify better what happens.., I'm constructing some uvs with the matrix (I'm using it to rotate a vector. Basically telling me where in the sky my sun texture should be applied)

This is what it looks like if I take the values from the frame debugger of the matrix and input them manually into the shader (This is what I want)

#

And this is what it looks like when I try to use "Shader.SetGlobalMatrix" in a script. As you can see the skybox is fine but not the water plane

regal stag
tender remnant
#

oh yeah.., shader graph!

#

I tried putting the skybox material on the water in case there was something different about them but nope.., the water surface still glitched

regal stag
# tender remnant oh yeah.., shader graph!

Under the Matrix4x4 property settings (in Node Settings tab of Graph Inspector if in v10+) there should be an Override Property Declaration. Enable that and select Global

tender remnant
#

Yesss! Thank you!

#

(it worked)

regal stag
#

You shouldn't need to do this for any other types, but matrices have a slight quirk that they can't be "exposed" but are still treated as per-material by default so can be set through material.SetMatrix. I think the glitchy is due to how the srp-batching works.

tender remnant
#

yeah.., the tricky thing it apparently behaves differently from any other property as you mentioned. Thanks for the explanation πŸ˜„

#

Big thanks again! Would've taken me forever to figure out myself

lone stream
#

This is interesting, why Tessellation Displacement have a separate input? normally we just apply the displacement on vertex position. So why tho?

#

and the weird thing if we apply any vertex modification directly into the vertex position input or vertex normal input it doesn't taking account the tessellated mesh

flint jay
#

How do I find this shader to remove it? I am not good at shader and don't know how to search for legacy. I have hundreds of shaders from stuff I downloaded.

#

Another view

tender remnant
#

hmm.., is there a way to reference the same node at different spots in shader graph?.., to avoid spaghetti looking webs or duplicates of nodes (imagine a disjointed connection acting like a portal for example)

#

not sure what to call it but it's quite common in other node based software.., is there a way to do this?

tender remnant
#

aw that's a pity. Really cool of you to have that available though πŸ™‚

#

ooh.., those colored groups is something that's been annoying me as well!

#

like.., you just zoom out a little bit and it's a nightmare trying to decipher what's going on

#

Unity should definitely buy your thing and implement it πŸ‘

tranquil jasper
#

Hi guys, I'm trying to "categoryze" my properties on a shader graph, and the Unity manual said I can, but I can't find the option. (Unity 2020.3).

regal stag
tranquil jasper
regal stag
clear vector
#

I use gpu instancing to render sprites, but i want to use sprite atlas, so i need to pass proper texture coords. To do that i pass float4 to compute buffer to reproduce _MainTexST. I calculate this property through

public static Vector4 GetTextureST(Sprite sprite)
        {
            var ratio = new Vector2(1f / sprite.texture.width, 1f / sprite.texture.height);
            var size = Vector2.Scale(sprite.rect.size, ratio);
            var offset = Vector2.Scale(sprite.textureRect.position, ratio);
            return new Vector4(size.x, size.y, offset.x, offset.y);
        }

and then use it in shader with TillingAndOffset to get proper texture UV in fragment shader

float2 TilingAndOffset(float2 UV, float2 Tiling, float2 Offset)
{
    return UV * Tiling + Offset;
}

varyings.uv = TilingAndOffset(attributes.uv, mainTexST.xy, mainTexST.zw);

to render sprites i use same quad mesh and stretch it to sprite size.
But i get weird result (screenshot): there is 4 sprites on screen:

  • two sprites on top (hair + body) rendered through custom render system + custom instancing sprite material (with passed _MainTexST property as StructuredBuffer<float4> mainTexSTBuffer)
  • two sprites on bottom (hair + body) rendered through default sprite renderer mono-component + URP default sprite material

Hair and body sprites in both examples have the same position, both use sprites packed to unity's sprite atlas, but somehow sprites rendered through custom system have wrong hair position.

Also on second screen i see that texture from sprite atlas have made hair sprite a little shorter then body sprite, while both of sprite source have 168x32 size

Please help! πŸ™

oak hazel
#

anyone know why its not transparent?

dim yoke
oak hazel
#

no 😦

dim yoke
grand jolt
oak hazel
dim yoke
oak hazel
#

yes

regal stag
#

You have "Allow Material Override" ticked, so make sure the material is set to Transparent too.

#

If you created the material when it was opaque it will still be opaque

small knoll
#

Hey, so I posted over in general code but they recommended I post here. I have this mesh that I made using MeshTopology.Line and I wanted the vertices to glow so it is kind of like a moving grid of connected lines, so I made a submesh with emission and used the MeshTopology.Point display for it and added my vertices. But now the vertices don't all glow and they're poorly lit, it's a very weird graphical thing that I don't quite understand, can anyone point me in a good direction?

calm idol
#

https://youtu.be/mnxs6CR6Zrk?t=192
Does anybody think they know a way to recreate this effect that uses the nearest lightsource for cel shading?

Let's figure out how The Legend of Zelda: The Wind Waker was able to pull off cel shading at a time when nobody else was able to.

🐦 https://twitter.com/JasperRLZ
πŸ’° https://patreon.com/JasperRLZ
🀼 https://discord.gg/bkJmKKv
🌎 https://noclip.website

🎡 Jasper - Epoch ( https://www.youtube.com/watch?v=DDmzbYV0d9M )
🎡 Allister Brimble - Fluidity - ...

β–Ά Play video
#

I'm not super experienced with shaders but I've noticed that not a single shader I've seen has actually correctly mimics this effect or at all really

grand jolt
regal stag
# calm idol https://youtu.be/mnxs6CR6Zrk?t=192 Does anybody think they know a way to recreat...

The shader itself would basically be the same as any other cel/toon shader (should already be tutorials out there). But rather than using _WorldSpaceLightPos0 you'd provide it with a custom Vector property and set it from a C# script via material.SetVector("_Example", direction);, where the direction is calculated based on the nearest light, or main directional if not near to any. (Can probably ask in a coding channel for help with that part if required)

calm idol
calm idol
#

I could probably attach a trigger to the lights to do something like that, hmm

#

The other way I can think of is by doing constant distance checks which would be horribly inefficient

robust wharf
#

Quick question: say I'm making a 2D game and I want objects to affect the color of the background shader.

We'll say the color extends out in a circle with a diameter of n units.

What I really want is that when the color fields overlap they transition smoothly between the object's color values rather than just overlapping to produce the average color.

Do I reference the objects in the shader, or create some kind of manager object, or something else entirely?

lean lotus
#

hey whats the fastest/best way to get textures such as world space position and normal textures from a main camera and into a compute shader every frame? I remember the last time I tried to do this I couldnt get it to work

small knoll
hearty stump
dim yoke
#

Depends on the amount of objects to be checked. I wouldnt call Vector3.Distance horrible on modern pc. Using sqrMagnitude when comparing saves barely anything because sqrt is veery fast nowadays

novel thicket
#

I have been running into the issue of shadergraph shader not showing when in a standalone build. They do however show in editor. The meshes do show in standalone when a standard URP lit material is applied.

Things i have tested but did not fix the issue:

  • Enabled GPU instancing on the materials.
  • In project settings i added the shader to always included shaders.
  • change the project settings shader stripping to keep all variations

It seems like something in the shadergraph shader is not compatible with instancing.
Would be great to know if anyone managed to fix or found a solution to this issue.

dusty barn
#

Is it possible to achieve something similar to UEs Runtime Virtual Texturing to blend objects in with the landscape?

dusty barn
#

^^ Got this covered with microsplat actually

grand jolt
#

Any idea why after being exported from blender all my textures become waaay darker?

#

blender is the upper one

analog karma
#

anyone know why this is happening? im trying to implement refraction

nimble solstice
# grand jolt blender is the upper one

You need to change a setting in blender for proper color. I'm not on the computer right now but will take a screenshot of the setting in a couple of hours (assuming I remember 😜) off the top of my head it's in the rendering section of properties, the color space section

formal canyon
#

I'm trying to define a sampler state that repeats the texture. I've tried pretty much all combinations I could think of...
Texture2D _MainTex;
SamplerState sampler_repeat_MainTex;
....
_MainTex.Sample(sampler_repeat_MainTex, uv)
---> Unrecognized sampler 'sampler_repeat_maintex' - does not match any texture and is not a recognized inline name (should contain filter and wrap modes)

regal stag
formal canyon
#

aaaaa thank you so much!

tender remnant
#

Just noticed that whenever I double click create one of those "funnel dots" in shader graph it converts the value to a float4 (if it was a regular float for example)

This seems like a huge bug.., or am I missing something?

#

I'm talking about these things

regal stag
tender remnant
#

oh.., so it's whenever it's after an multiply node?

regal stag
#

Yeah

tender remnant
#

ah yeaaah.., just tested it out

#

sooo weird though πŸ˜„

#

I can't say the word that comes to mind when using shader graph is "polished"

Soo many small annoyances

#

I mean I like it for what it is.., but sometimes...

mint wave
#

hello there
want to translate this
v.vertex.y += sin(v.vertex.x +_Time.y) * 0.3...

#

but as you can see how i can do v.vertex.y = v.vertex.x in visual !!

regal stag
# mint wave

Put the output of your Multiply into the Y port of a Vector3 node before the Add.

mint wave
#

@regal stag ok i try

#

@regal stag i took time to figure how that's perfectly fine thks ..

grand jolt
#

is there a way to save the effects of a shader ( such as transparency & material color ) to a GLTF? I am trying to save these procedurally generated crystals.

tame topaz
#

@grand jolt Either use #πŸ’»β”ƒcode-beginner (as you claimed this was a "coding issue"), or use this. You know not to crosspost by now.

left fjord
#

Does anyone know shader tutorials that would help to understand how to make creep like zerg in Starcraft 2?

dusty coyote
#

Hey I have an idea for a shader but don't know where to start :d Can someone give me some tips how to accomplish this?

#

The electricity would be moving and inside the ball

#

Should i create a texture and distort it with noise or how would be best?

shadow locust
#

tweak your noise function and your threshold it until it looks like that

#

cull the fragment if noise is not over that threshold

fresh moss
#

I'm making an instanced shader, is it possible to get instance id in the frag command?

#

because when i try it seems to be returning 0

#

or null actualy

#
fixed4 frag(v2f i, uint instanceID: SV_InstanceID) : SV_Target{
    fixed4 OUT;
    OUT = tex2D(_MainTex, i.texcoord);
                
    #ifdef UNITY_INSTANCING_ENABLED
        OUT *= _Colors[instanceID];
    #endif


    return OUT;
}```
dusty coyote
regal stag
fresh moss
#

ok

#

i think i did just find somthing that works though

#

thanks anyway

storm steppe
#

hi, is it possible to make shader that can blend the normals when object comes in contact with other and also recieve shadow at the same time?

#

unity 2018

shadow locust
storm steppe
#

@shadow locust it is ok if the shader is opaque i just want to blend diffuse and normal values on points of contact or intersection

cosmic prairie
#

should be doable, use deferred rendering to get screen normals, or calculate them from converting depth into world space and that into normals using multiple samples

#

but it will only blend on one material

#

if its fine

red fjord
#

Iam sorry if this is the wrong Category but i have a problem with my Sprite Mask in a 2D Topdown Game when iam using a sorting Group cause it just wont apply.

nimble solstice
# grand jolt Thanks!

I'm sorry. I tried to repro this issue (I've had it before) but my previous solution seems to not be working. I did see a bug reported about it to blender fwiw

grand jolt
grand jolt
calm idol
grand jolt
tight phoenix
#

I'm having an issue in Build that doesn't occur in Editor.
I have a RenderTexture, but its either black, or completely invisible in build, but normal in Editor

#

I've tried changing its Color Format field, I dont really know what most of them mean, but trying them at random, my render texture is sometimes black, sometimes not visible at all

#

I am using the URP which may or may not be affecting it

tight phoenix
#

Does anyone know why a Render Texture might be black, or totally transparent in Build, but not Editor?

vocal narwhal
#

Please don't cross-post. If a render texture is black then perhaps .Create has not been called

tight phoenix
vocal narwhal
tight phoenix
vocal narwhal
#

It should serialize just fine, though Create should be unnecessary if it's an asset in the project. Is it being used in conjunction with a camera or something?

tight phoenix
tight phoenix
tight phoenix
vocal narwhal
#

It should serialize, that's how it's visible on the camera, but that's besides the point. The issue is likely URP-specific

tight phoenix
#

How it looks in Build and in Editor. Editor is the expected appearance

tight phoenix
#

The most recent things I added are a Canvas for UI, and a second Overlay camera in the scene

#

neither of those things in any way interact with this render texture though

#

--
Going back through my builds, I was wrong, it was never working

#

I just mis-remembered it as working once

#

Which is helpful to know that it was not a recent change that broke it, it was never working at any point

#

"working" being in this case, rendering anything in Build. 100% transparent

#

showing up as a huge black square didnt happen until I started to mess with the camera and render texture trying to get it to show anything

vocal narwhal
#

Sorry, I don't know what could be wrong. Perhaps try posting your setup in #archived-urp and someone might know

tidal wraith
#

How would you go about designing a shader like kylo rens lightsaber? I've tried do a vertex deformation shader, and it just looks like a mess. Any ideas?

dim yoke
lean lotus
#

Is there any performance difference between dispatch and indirect dispatch?

median lava
#

Does anyone one know what this is called ? It's mostly used for fur shaders, I've been looking everywhere for an array like shader resembling something like this .

vocal narwhal
#

I've heard it called shells, and I can't think of another name off the top of my head

regal stag
mental bone
#

Can confirm on the naming Ive been trying to bang out a hdrp geometry fur shader for some time now

median lava
#

@vocal narwhal @regal stag @mental bone thanks for pointing me towards the right direction guys

charred inlet
#

hello, I'm new to the shader graph and I have a problem with understand why the main color switch from white into red can anyone explain me that a bit please?

dim yoke
regal stag
#

So the other channels on the split are returning 0

#

You don't really need to convert a float to Vector3 with Split/Combine unless you need to alter the channels. Just connecting the float to the Vector3 port will automatically promote it to (float, float, float)

charred inlet
#

hmm ok, thanks for help

grizzled bolt
# grand jolt what does that means ? ^^

There are many ways to represent colors on screen
Blender by default uses linear color space with "filmic" tonemapping
Unity by default uses gamma color space with no tonemapping

#

Blender's default settings make colors look washed out under most lights, so switching view transform to sRGB (or gamma color space) can give you a more informed look of how the asset will look in other programs

#

Switching to linear color space un Unity and enabling HDR tonemapping will give you a bigger color space to work with, but will also alter the visual color and contrast of assets

#

(I don't know if blender's filmic view transform is technically "tonemapping" but it seems to function the same way. Someone can correct me on that)

vocal narwhal
#

I'm not sure if gamma is the default in URP or HDRP any more because it's been a mistake of a default for a while and I was glad when they changed it

grizzled bolt
distant sonnet
#

My two-sided transparent shader is not working correctly; why?

low lichen
distant sonnet
#

But that messes with the render order?

elfin kraken
#

Hi, I'm working on a simple water shader.
I was trying to do the foam around the edges of objects, which works okayish, but it's not exactly how I want it to be.
Basically I am calculating the distance from a camera to the object below the water line and applying a gradient to it based on that distance.
I see that a lot of shaders that I found online also use the same technique for the foam so I tried that as well, but the obvious issue with that is that the water follows the same gradient, so it doesn't really appear around the vertical objects. On slopes such as beaches it works well enough.

Does anyone know of a different approach to creating the foam effect around the objects that actually follows the surface?

#

I found this example online, this is exactly the effect I would like to achieve

nimble solstice
#

The vertical issue is just part of the way it works. If you want to avoid it you need to use a second camera generally

#

There's one link that outlines it

elfin kraken
#

Thanks, I saw this article before and they seem to have the same issue with the foam.

elfin kraken
nimble solstice
#

Because the edge you point to isn't near to anything behind it

#

So it doesn't detect anything near by

#

The second camera points downward at the water and uses a render texture to find where objects are rather then relying on screendepth

#

Then uses the render texture to calculate the foam

elfin kraken
#

Oh okay, I see. Thank you!

tidal wraith
#

@dim yoke I'm actually trying to understand more the noisy vertex displacement kind of look on the saber. You see how its kind of wild not just a solid beam?

dim yoke
regal stag
# elfin kraken Hi, I'm working on a simple water shader. I was trying to do the foam around the...

To add to what Phosphene mentioned,
Using depth (captured from second camera looking down) can work in some cases (e.g. sloping terrain) and wont change with camera angle like screen depth techniques, but that still won't work for harsh edges like those spheres/pillars in your scene. What you essentially need for that (and I think what the example image is using) is to generate a distance field texture. Might find this useful : #archived-shaders message

elfin kraken
lean lotus
#

How can I get the textures out of a camera such as the motion vectors, normals, and diffuse texturing? I need to feed it into a compute shader and would rather not have to recompute all of it if possible

still shoal
#

what is the best psx shader for unity? (that its free and easy to use) (should i ask this here or should i ask this in other channel?)

knotty juniper
#

you need it all the time?

#

enable that and unity will refresh the scene view all the time and your shader will run

lean lotus
#

Is there a way for me to get things like the diffuse texture a camera may generate in a compute shader?

shadow locust
#

And pass the texture to the shader

lean lotus
#

hmmmm
ok i could do that
but how does that work with shader scheduling?(currently I have the compute shaders being called every OnRenderImage)

unique oar
#

hey sorry, I know this is a noob question, but how do I expose an integer in my shader???

#

I thought this would work _iterations("Iterations", int) = 100; but it just throws an error

#

i also tried Int but that doesn't work either

#

and google hasn't been helpful

#

and the error says, "Parse error: syntax error, unexpected $undefined, expecting TVAL_ID or TVAL_VARREF" which is very useless

#

omg im an idiot lol

#

sorry i keep writing semicolons after my property declarations

#

thats what was wrong hahahaha

dusty coyote
#

why doesn't the upper rectangle get distorted?

grizzled bolt
# dusty coyote

The distortion happens symmetrically in diagonal direction

regal stag
# dusty coyote

Your distortion is using the same value for both the X and Y axis (because it's a float), and that can only shift the coordinates diagonally towards the top right. Using two sets of noise (with different offsets) into a Vector2 node would fix it (but be more expensive).
Normal From Height node also works (but bit pixelated as it uses ddx/ddy which act in 2x2 pixel blocks)
Sampling a distortion/flow map (texture) may be better.

dusty coyote
#

Thanks to you both!

steel notch
#

So for shaders, are you able to give them a Color32, but they will only work on a 0 to 1 scale for color?

meager pelican
# steel notch So for shaders, are you able to give them a Color32, but they will only work on ...

You can pass Color32 ints (int32/int) to shaders. And do bit operations if you wish.
https://forum.unity.com/threads/cant-pass-an-integer-to-a-shader.950419/
https://docs.unity3d.com/Manual/SL-DataTypesAndPrecision.html
But in the end, you (convert back to and) return a float4, AFAIK. Or a fixed4/half4. Maybe if your GPU texture is an int-type, you can return an int-type, but I don't see it done much.

GPU's are optimized for floating point. On desktops all the half and fixed get run as floats, but on modern-mobile, they end up being half for example (saves power and maybe some memory bandwidth). I'd save the ints for use as array indices. Some GPU's don't even really support ints at all (see 2nd link above).

But bitwise math in shaders needs to have ints declared even if they're emulated. So it depends on if you want to use bitwise math.

steel notch
#

I know how to do the transparency and all that jazz, it's just getting that data into the shader to do comparisons that I'm struggling with.

sinful ermine
#

with compute shaders and setting AppendStructuredBuffers, do i NEEEEED to know what the result size of the buffer will be when setting it before dispatching?

#

im trying to construct a mesh using the marching cubes algorithm and im not quite certain how to handle not knowing how many resulting triangles im going to have

meager pelican
steel notch
#

Im worried about floating point comparison nonsense as well as interpolation between the verts messing things up.

#

I'm also not sure how to tell it to show multiple regions.

meager pelican
#

Use int values in the float.
You shouldn't have any major comparison problems then, for reasonable ranges. AFAIK.
OK, so now you have interpolation problems...yes...that will happen IF you're sharing verts and IF a polygon has different tags on its verts. If they're all the same it won't matter. So don't share verts.

As far as how to show multiple regions, IDK what to tell you. You can convert the tag to a binary int (maybe that's what you were thinking about in your original question) and then use bits to flag/mask the areas. And pass in a bit mask to decide if this area is active, and AND it with the polygon tag and decide if it is non-zero or not. I think. IDK off top of head how expensive converting to int is.

#

You'd have to check the mantissa bit sizes and figure out your number of tags. Something lower than 24 bits if I read correctly.

#

That's for IEEE 754

meager pelican
sinful ermine
#

2048 bytes or 2048 x the size of the stride

fickle jay
#

I'd like to color faces of a mesh like so: if a point is closer than N to an edge, color it black, otherwise color it white. What's the best way to approach this? If I use a texture and an uv-map to simulate this, I expectedly get blurry edges and high-quality textures weight a lot.

meager pelican
#

Also check out various wire-mesh techniques, but many involve barycentrics.

fickle jay
#

Thanks.

meager pelican
sinful ermine
#

interesting, valuable intel

meager pelican
#

I edited @sinful ermine

#

@sinful ermineI'm also now unsure as to the count variable during construction. I'm researching.

sinful ermine
#

i'll take it for a spin

meager pelican
#

Cool. It looks like they construct it with max-count, stride, type. Then set the counter to zero in the code and then append.
The buffer for the counter (index) is separate from the data stack, as you see.

That's my best guess when reading it, it's been quite a while since I messed with append buffers. Good luck @sinful ermine

shadow osprey
#

does anyone know why my hands disappeared here and why my body is still pink even though i tried upgrading all textures to urp and re-importing all assets?

meager pelican
#

Check your graphic settings and be sure it is set up for URP with the right asset showing.
When you're editing the shader, make sure you hit "save".
Otherwise, it's an error in the shader, look for an error message.
That hot-pink is the error color.

violet rock
#

So I have a voxel-based world, and the grass is having a real tough time with the dynamic directional lighting. It flickers a ton with the sun’s angle changing. In the realtime shadows settings, I set the depth to 8, the normal bias to 0, and the near plane to 0.5; this helped somewhat, but not nearly enough.

#

Is there anything I can do other than lengthen the day-night cycle?

#

Oh also reducing shadow strength to below 0.5 makes the flickering negligible, but then the shadows are too soft and it looks bad

#

I’m using the azure sky package if that is relevant

little glen
#

if i wanted to create a shader that replace alpha with some colour
what would be the best? need standard pipeline, have image with transparency & colour property
i dont think i need fade, just straight cutout (need to be affect by other lighting effect just like non transparency texture do)
not sure if i need to write my own shader though (havent done it for a while)

*anyone have answer just tag me
**not urp / hdrp, so no shadergraph

willow remnant
#

uh, can anyone tell me why it is not transparent?

Shader "FieldOfView" {
    Properties{  
        // Properties of the material
        _MainTex("Base (RGB)", 2D) = "white" {}
        _FOVColor("Field Of View Color", Color) = (1, 1, 1)
        _MainColor("MainColor", Color) = (1, 1, 1)
        _Position("Position",  Vector) = (0,0,0)
        _Direction("Direction",  Vector) = (0,0,0)
    }
        SubShader{
        Tags{ "RenderType" = "Diffuse" }
        // https://docs.unity3d.com/Manual/SL-SurfaceShaders.html
        CGPROGRAM
#pragma surface surf Lambert

    sampler2D _MainTex;
    //https://docs.unity3d.com/Manual/SL-DataTypesAndPrecision.html
    fixed3 _FOVColor; //Precision
    fixed3 _MainColor;
    float3 _Position;
    float3 _Direction;

    // Values that interpolated from vertex data.
    struct Input {
        float2 uv_MainTex;
        float3 worldPos;
    };

    
    void surf(Input IN, inout SurfaceOutput o) {

        // Albedo comes from a texture tinted by color
        
        
        float3 Norm = normalize(IN.worldPos - _Position);


        float angle = acos(dot(Norm, _Direction));

        bool InCone = distance(_Position, IN.worldPos) < 3 && angle < .7071;

        if (InCone)
        {
            o.Albedo = _FOVColor;
        }
        else
        {
            o.Alpha = 0;
        }
    }
    ENDCG
    }
        FallBack "Diffuse" //If we cannot use the subshader on specific hardware we will fallback to Diffuse shader
}
#

only the red section is supposed to be visible, I'm sure I've missed something obvious

steel notch
#

How do you control whether you're working with the vertex program or the fragment program in shader graph?

mental bone
#

Afik it depends to what stage in the master node you hook up nodes. Thats why for examole you can hook up a sampletexture node to the vertex position

steel notch
#

Is there anyway to make it so certain values dont interpolate between the vertex and frag?

lone stream
#

how can i get _CameraDepthTexture_TexelSize in shadergraph HDRP?

#

custom function?

dim yoke
# steel notch Is there anyway to make it so certain values dont interpolate between the vertex...

If all the corner vertices of triangle had same values, it would make sense to just put one of those values to all fragments on that triangle, otherwise that doesn't make much sense (so no, not possible). Can you elaborate what you're trying to do? Are you trying to gain performance by skipping the interpolation or is there some specific effect that would benefit from that (again, I don't see how it would make sense to skip interpolation)?

steel notch
#
I know how to do the transparency and all that jazz, it's just getting that data into the shader to do comparisons that I'm struggling with. ```
[#archived-shaders message](/guild/489222168727519232/channel/497874081329184799/)
From here basically ^
#

I stored the tag value (int) into the Alpha channel of the vertex color.

#

I then tried to make a shader that would only display the fragment if the current color's alpha exactly matched some "tagValue" shader property.

#

It sorta worked but I got some intense flickering.

dim yoke
#

and the point of skipping interpolation in this case would be?

steel notch
#

Well at the boundaries of regions those tag values would interpolate. For example at the boundary between region 10 and 0, there could be some fragment where the alpha interpolated to 5, and if I tell the shader to show region 5, I'll get that 1 pixel lit up.

dim yoke
steel notch
#

ya 1 moment

#

I can only assume this is due to float comparison stuff.

dim yoke
#

could you just round the value?

#

or compare with some error margin

steel notch
#

I tried rounding and it didn't work.

#

I tried with a margin of error, and that worked.

#

I made my margin super small, like 1x10^-7 small

#

and it all worked

#

so ya, likely float nonsense

#

wish I knew the exact reason though

#

as I continued the reduce the margin, those stray pixels at the border of regions also disappeared

#

likely because they just weren't an exact enough value

#

point is it all feels very cobbled together

dim yoke
vocal narwhal
#

It's based on barycentric coordinates afaik

dim yoke
#

@steel notch if the values are either 0 or 10, it would probably be 10, because there's two 10s on the corner vertices but only one 0. that would still be weird in any generalized situation. what if the corner vertices have values 0, 5 and 10?

steel notch
#

I imagine this.

#

find the center of the 3 points and then define borders by drawing a line from the middle of each segment to the center

#

though there's probably some GPU based reason why this is a bad idea, or very expensive, or hard to compute because the regions aren't triangles

#

Are we trading Microsft Paint images? πŸ˜›

dim yoke
steel notch
#

I am unfamiliar with Voronoi but after a quick google search I would say "sort of I guess"

#

but ya I imagine the final color of the frag is defined by which region it covers the most.

#

Which I believe is already done for verts.

#

wow my typing is trash tonight

vocal narwhal
#

Try adding nointerpolation before your type in the struct you use between vertex and fragment. If this is shadergraph, you will not have access to that

steel notch
#

How DOES that resolve then?

#

For color as an example between 3 points.

vocal narwhal
#

give it a try 🀷

steel notch
#

LOL fair fair

#

separate fast question though

#

So I noticed Unity has some built in masks, but the UI one only seems to be able to make images appear IN the region. Not be CUTOUT by the region.

#

Any uuuuh... way to do that?

#

That doesn't involve Stencil buffer tomfoolery?

dim yoke
# steel notch

wouldn't that give zigzag like result which would not look too good either? rounding to nearest value would give better results anyways

vocal narwhal
#

No, I lied??

dim yoke
#

everyday learning something new

steel notch
#

WAT

#

Oh sarcasm

#

listen man it is 3:30am I am functioning at 20%

#

my typing skills are falling apart

#

"Does Unity have a built in CutOut shader for UI stuff?", is basically my question.

#

I did a quick google about an hour ago. Seems the answer is no.

#

Just want to make sure though.

vocal narwhal
steel notch
#

Fancy

#

ty I'll give them a look

#

That SoftMask one looks really promising

#

I've recently been taking the deep dive into shaders. Gave up on relying on ShaderGraph for everything and started biting into it all.

#

My god are these things wild.

meager pelican
# steel notch Fancy

This is all why, when we discussed it before, we discussed not sharing verts. Using @dim yoke's example pics, if all 3 verts had a 10 or all three verts had a 0, for any given polygon your interpolation issue becomes irrelevant. You'd get your "tag" of 10 or 0.

This requires a modeling change, though, to not share verts. Each triangle would have its own 3 verts, with it's own tag/type on it. It would allow you to use shader graph if you wish also.

south sinew
#

Hi , i am very new to using shaders , NEED HELP , i am trying to go for the solution provided here for unity 2d lights

Where instead of looking black in case of light not falling on obect , it would disapear as shown , when i try to implelent same solution, it is not working , it is behaving weirdly especially with location of light source , problem in game scene only , request to please help me with this
https://stackoverflow.com/questions/65696260/is-there-a-way-to-hide-a-player-who-is-in-the-shadow-in-unity-2d-light-system

Here is what i am getting if i use sprite-lit default i get black for rest of object
but with Code given , it is working in scene , but in game scene as you can see it is not even visible, PLEASE HELP

tacit stream
#

what's the difference with custom template?

tacit stream
#

Any tip on how to create color mask shader?
Basically I want to have sprite of white color and color it however I want except for parts that are covered by mask texture

#

Kinda like this, everything except eyes and mouth supposed to be colored

dim yoke
#

@steel notch So it did this small experiment and it seems like nointerpolation kinda works but it seems to pick the color to use quite randomly between the possible vertices. id imgine it just picks the value from the first vertex of the 3. If you use that, you lose control of the borders. I think the carpe's way of dublicating the vertices would be the default way to do that.

amber saffron
tacit stream
#

Apply a lerp to white?

#

Sorry, I'm really far from shaders

#

what is white in this context?

amber saffron
#

just the white color.

#

And "lerp" is a very common operation in shading. synonims are "blend" or "mix".

tacit stream
#

yeah, I know lerp

#

So, let me show

#

so, I have this

#

All white part

#

is supposed to be untouched by color multiply

#

aaaand, I'm uncertain how it can be done without if statement

regal stag
#

Put the tint colour in the A input of that Lerp

tacit stream
#

yeah, i tried that previously

#

but I couldn't figure out

#

what to do with it

#

if I simply multiply my original texture

#

all that untouched part just gets colored black

#

meanwhile I want to remain untouched from original texture

regal stag
#

Wait why is the eyes/beak black now?

tacit stream
#

huh

regal stag
#

Did you change the T input, I'm confused

tacit stream
#

ok

#

I fixed it

#

it's white now

#

let's see

#

yyyyep

#

thank you, sir

#

ok, now I have this question

#

How do I access Color

#

that is assigned through Sprite Renderer?

regal stag
#

It passes it through the Vertex Color node

tacit stream
#

ahem

#

it's 3D

#

is that fine?

amber saffron
#

Sprite renderer is sprite renderer, should you be in 2D or 3D, so, still through the vertex color node πŸ™‚

tacit stream
#

what about texture

#

is there some sort of Input node

#

for texture that comes from Sprite Renderer?

hearty obsidian
#

name it _MainTex

tacit stream
#

like this or

#

I need _ in name as well?

hearty obsidian
#

This is fine

slim steppe
#

Its supposed to look like this one

#
http://blog.hvidtfeldts.net/index.php/2011/09/distance-estimated-3d-fractals-v-the-mandelbulb-different-de-approximations/          
 float DE(float3 pos) 
            {
                 float3 z = pos;
                float dr = 1.0;
                float r = 0.0;

                for (int i = 0; i < _Accuracy ; i++) 
                {
                    r = length(z);
                    //if (r > _Bailout) break;
        
                    // convert to polar coordinates
                    float theta = acos(z.z / r);
                    float phi = atan(z.y / z.x);
                    dr = pow(r, _Power - 1.0) * _Power * dr + 1.0;
        
                       // scale and rotate the point
                       float zr = pow(r, _Power);
                     theta = theta * _Power;
                     phi = phi * _Power;
        
                      // convert back to cartesian coordinates
                      z = zr * float3(sin(theta) * cos(phi), sin(phi) * sin(theta), cos(theta));
                    z += pos;
                   }
                
                return 0.5 * log(r) * r / dr;
            }

            float GetDist(float3 samplePoint)
            {
                float dist = DE(samplePoint / _Scale) * _Scale;

                return dist;
            }

            float Raymarch(float3 rayOrigin, float3 rayDirection)
            {
                float stepSize;
                float3 position = rayOrigin;

                for(int i = 0; i < MAX_STEPS; i++)
                {
                    stepSize = GetDist(position);

                    position += rayDirection * stepSize;

                    if(stepSize < _SurfDist) return distance(rayOrigin, position);;
                }

                return 0;
            }
regal stag
slim steppe
#

thanks but that didnt solve it

gloomy tendon
#

Anyone have source for generating ambient occlusion maps from height or normal maps?

astral adder
#

is the switch from cg to hlsl possible
do i have to relearn the entire thing ?

south sinew
royal vale
#

Shader error in 'Compute': if statement conditional expressions must evaluate to a scalar at kernel CSMain

#

anyone have any idea what this means?

#

if(newPosition.x < 1 || newPosition.x >= WIDTH-1 || newPosition.y < 1 || newPosition >= HEIGHT-1){}

#

This is what its getting mad at

regal stag
royal vale
#

lmao yeah that's it thanks

#
  • does GLSL support modulus?
#

%

regal stag
# astral adder is the switch from cg to hlsl possible do i have to relearn the entire thing ?

"cg" isn't really a thing - it's all hlsl these days even though it's named "CGPROGRAM" (which just automatically includes some built-in RP stuff like macros/variables)
But I assume you're referring to writing shaders for different pipelines. The problem is less the language/syntax and more all the functions are named differently which makes it difficult, and surface shaders aren't supported in URP & HDRP. It's usually easier to use Shader Graph for those pipelines. For URP I've got an article which might help though, https://www.cyanilux.com/tutorials/urp-shader-code/

broken bobcat
#

why do I not have the "graph inspector" option in my shader graph?

regal stag
# royal vale + does GLSL support modulus?

Do you actually mean GLSL or HLSL? Both should support it afaik (or at least glsl has mod(x,y), and hlsl has fmod(x,y). I think I've used the % operator before which does the same).
Though note the actual implementation varies, as glsl basically uses x - y * floor(x/y), while hlsl's fmod uses x - y * truncate(x/y).

regal stag
broken bobcat
regal stag
broken bobcat
#

oh ok thanks πŸ‘

south sinew
olive inlet
#

How can i make object only visible through a transparent material

meager pelican
# olive inlet How can i make object only visible through a transparent material

You can't, directly. Transparents are drawn AFTER opaque materials. But maybe that's not quite what you're trying to say.

So maybe research STENCILS. Draw your magic looking-glass or whatever it is with a stencil even if you don't draw the colors. You could use a separate camera for it, the first camera for example. Now you have a stencil mask for whatever parts you drew.

Next, ALL YOUR OTHER SHADERS on objects only visible via that transparent material that you haven't even drawn for real yet, would have to honor that mask and NOT draw outside the stencil area. Draw your scene, and then as a last step draw your transparent thing on top of it all.

One guess as to a way.

broken bobcat
#

I have the color of this graph on black but this is the color thats showing up anyone know what the problem is?

quaint pike
potent jetty
#

why does it not flip when I do the scale of the object to -1?

sinful ermine
#

i cant find any info on it and it's driving me up the wall

regal stag
glad warren
#

This is an outline shader with a big width parameter in so the outline appears thick. What would I need if I want to do the inverse ? Like the outline grows inwards to the mesh. Maybe it's a different type of shader and I can't recall the naming of it.

pastel tapir
solar needle
#

Hello, quick question
Is it possible to have a variable list List<2D> (like in pure c# script) in the shader ?

#

i'd like to have an array of 2Dtextures as variable but directly in my shader

amber saffron
solar needle
#

yeah i saw that, but i'm not sure if it will fit
I'll see that, but i don't understand really this i think

amber saffron
#

How be ?

solar needle
#

like, in my mind, 2DArray was like this in the inspector but not at all

amber saffron
#

Nope indeed, the texture array is an objects by itself, that you need to edit/create by script.
It is the most close solution to what you're trying to do.
In shader you can have float arrays like float myFloatArray[] and other base types, but not for textures.

solar needle
#

oh, nice tips for the floats

regal stag
amber saffron
#

So you'll have to do something like this :

  • In your script declare a List<Texture2D> ....
  • Build a texture array object from it
  • pass the texture array to the material
solar needle
#

okay, that was what i had in head

solar needle
amber saffron
#

Adding up to Cyan awesome tool, Unity now also supports importing a "packed textures" to a texture array object

solar needle
#

okay !

#

and btw, do you know if unity support Udim, because i searched everywhere and i found nothing

#

so i am trying to create a tool to have a shader wich support udim, i already did a little shader wich can show the good base color according to the good udim part

pastel tapir
#

Hi!
I am trying to create VFX shader
i have made this

#

then

#

i tried improving the looking using contrast node, which worked in the shade graph preview

#

but it didn't work properly in game, and it gives this weird inner glow

#

i searched a lot about contrast node, but i still cant understand why is this happening

regal stag
# pastel tapir

The contrast node might be leaving negative values in black areas. Maybe a Saturate node will help here? (it clamps between 0 and 1)

pastel tapir
amber saffron
#

i thought there is only 0 - 1 options in shader graphic colors
This is a totally wrong assumption πŸ˜„

#

"simple" texture (RGBA 8 bits per channel) are usually considered this, but shaders are math, and with math you can do whatever you want

regal stag
pastel tapir
#

this is a whole new world of creativity i didn't see
now it makes sense how contrast effect looks so beautiful

#

Thanks :D

nimble solstice
#

Along with dividing by 0 warnings which appear to be related to the shadowCoord stuff as well

#

(Also sorry for lack of formatting, editing after the fact appears no bueno)

marble thunder
#

Hi, I can't seem to find good documentation that talks about the usage of UNITY_SAMPLE_TEX2ARRAY or UNITY_SAMPLE_TEX2DARRAY_LOD. I'm trying to access the array of all of the textures and cycle through them all.

tacit stream
#

Is there some sort of name for global variable for wind strength?

#

Like some name convention for that

nimble solstice
#

Looks like a Vector 4 labeled _WaveAndDistance @tacit stream

#

(Looking at WavingGrass.shader)

#

Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrass.shader

tacit stream
#

huh, good to know

#

I assume pre-made assets will use that variable as well

#

at least hope kek

nimble solstice
#

If you're using the terrain stuff waving I assume so as well πŸ˜„

regal stag
# nimble solstice Along with dividing by 0 warnings which appear to be related to the shadowCoord ...

I assume there was meant to be another message with this but the discord bot removed it due to incorrect code formatting. You might still see it on your end but it didn't send, hence why you can't edit it.

But since you mention shadowCoord error, I assume it might be related to using custom lighting functions in an Unlit Shader Graph? The error occurs due to the Varyings struct that the graph generates not including the shadowCoord interpolator to pass data between vertex/fragment stages. It can kinda be avoided if you set shadow cascades on your URP Asset to 2 or higher (as that avoids using an interpolator / always calculates the shadowCoord in fragment stage).
But I also have some functions / SubGraphs here which avoid the error. https://github.com/Cyanilux/URP_ShaderGraphCustomLighting
Specifically because of #undef REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR

nimble solstice
#

Thank you for the answer! Yeah, I'm using this:

    #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
    #if (SHADERPASS != SHADERPASS_FORWARD)
        #undef REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR
    #endif
#endif```
#

But it still seems to be an issue. I'm also attempting to use as few of cascades as I can as this is for mobile

#

and I'm really really unsure how the whole thing will run anyway πŸ˜›

#
    output.shadowCoord = GetShadowCoord(vertexInput);
#endif```
#

That's the problem varying.hlsl section of course

#

I'll check your repo out!

regal stag
nimble solstice
#

Weird indeed. I'm currently using 2020.3.23f1

#

Is this mostly due to the shadergraph preview then?

#

(Again, the shadows show up fine...ish πŸ˜› )

#

That is as fine as can be expected with 1 cascade πŸ˜‰

regal stag
#

As long as it works in scene/game I guess the error could be ignored. Maybe it's a weird cached thing, resaving the graph might make it update.

nimble solstice
#

Do you mean remove cache/library for recreation? I haven't tried that but the graph has been saved often πŸ™‚

regal stag
regal stag
supple leaf
#

Hey, how do i handle a vertex shader which behaves differently on different scaled models? for example i have a simple "wobble" shader but it behaves differently on bigger models. looking for a shadergraph solution.

flint jay
#

Hello, may someone help? I'm 4000 hours into a project and now my unity frazzing. I spent 20+ hours on this so far. error:A Hybrid Renderer V2 batch is using a pass from the shader "Legacy Shaders/Particles/Additive" https://forum.unity.com/threads/error-a-hybrid-renderer-v2-batch-is-using-a-pass-from-the-shader-legacy-shaders-particles-additive.1244176/

nimble solstice
#

kk, thanks @regal stag ! Error shows in the console (as does the two division by zero warnings)

atomic elm
#

Is there a way in Shader Graph to transition between two different models?

tacit stream
#

Do geometery shaders need lighting pass in URP?

#

or that part is covered by template?

marble thunder
grizzled bolt
atomic elm
regal stag
grizzled bolt
atomic elm
#

No need to actually warp between them though

grizzled bolt
atomic elm
grizzled bolt
#

I guess the geometries could be in one mesh if you give the shader some kind of indicator which one to invert, such as with vertex color or UV map data

#

But I can't think of a situation where it'd be preferable over using two separate objects

atomic elm
#

Gotcha, thanks!

grizzled bolt
#

What kinda use case is it?

atomic elm
# grizzled bolt What kinda use case is it?

There's a weapon that the player has that's supposed to "transform" into different shapes. I wanted to make it so that when he switches to the different weapon types, the model would wipe into the new model

grizzled bolt
#

Interesting!

lime star
#

stupid little question:
this isn't a scalar, its bool2, how do i check if all values of the boolx are true though?

if (id.xy == uint2(mousePos.x, mousePos.y)) {
    Result[id.xy] = float4(1, 1, 1, 0);
}```
this is in HLSL
steel notch
#

I'm not too sure how I can do this calculation in shader graph.

#

I want to have a boolean, and in the case it's true do a Greater or Equal comparison between two floats, and if it's false do a Less or Equal comparison between those same floats.

leaden radish
#

btw u can compile shader graph or something?

#

i was just wondering if i make some shader graph to go with my 2D art assets

atomic scroll
#

Opacity doesn't fix it.
Is there something I need to plug in to sort this out?

regal stag
#

Oh wait you want all(), I misread

regal stag
steel notch
#

I figured it out using a XOR gate

#

which I'm sad isn't built in

#

you'd think all the regular gates would be

meager pelican
sinful ermine
#

bruh

meager pelican
#

I gave ya a link to the unity doc pages that said it.

lost kernel
#

i use a shader with a stencil test that only renders pixels behind walls, problem is, if something of the same mesh is in front, it also renders, what should i do? an extra pass to write to the stencil buffer before the renderpass ? or is there any other chance to ignore the other parts of my mesh?

meager pelican
#

You could check the depth of the current pixel, and the depth at the screen (aka wall) and if the pixel depth is closer to the camera than the wall, don't render it (discard).

#

But opaque items are rendered front to back.

#

It sounds like the object center would be behind the wall though?

lost kernel
#

but i want it just for this object, can i write and read at the same time?

#

if i could write to the stencil buffer before the test

#

it would work i guess

meager pelican
#

Yeah, you'd have to render it twice, I think.

#

The stencil value should happen before the pixel shader logic though.

atomic scroll
#

Nah just making shaders for VRChat.
It's alright. Changing the shader to Phong lighting model has fixed it.

meager pelican
#

@lost kernel ^^

#

IIUC, stencil happens during rasterization-ish between the vert and frag, and if it fails, frag isn't even called. @lost kernel

lost kernel
#

thought about it again, i'm wondering why it happens i have 2 materials on it , first is a lit shader that just writes 4 to the stencil buffer, second does this:

Stencil {
Ref 4
Comp NotEqual
Pass Zero
}

but i renders parts from the same mesh

#

hard to explain, maybe this helps

#

right: behind wall, left: visible

meager pelican
#

IDK, my head is starting to hurt.
You're writing a 4 on the first draw, you said.
Then, on the 2nd material (a 2nd draw), the code you showed zeros out the stencil buffer where it isn't a 4.

lost kernel
#

the first (actual the real material for the mesh)

Stencil {
Ref 4
Comp Always
Pass Replace
}```
so after it got rendered i should have a 4 in the stencil buffer 

The second checks if it's not 4 (the plan was to ignore the other players) and then discards the pixel
#

fo the walls it works, if im behind a wall it renders on top of everything like it should, but it looks like it also renders things that are behind on the same mesh

#

with simple cubes it worked perfect, but if there are points behind from the same mesh this happens

meager pelican
#

I don't think the 2nd one is doing what you just said it is. Maybe I'm wrong though.

#

I'm thinking it isn't "The second checks if it's not 4 (the plan was to ignore the other players) and then discards the pixel"
If it's not a 4, it writes a zero to the stencil buffer. But IDK if the pixel gets discarded.

lost kernel
#

it's working now

meager pelican
#

What did you change?

lost kernel
#

i added the stencil write on all passes, somehow it looks like the pass im adding it is not always the last

#

i have to figure out what happens there, i have no idea

#

but when i do it on all passes it seems to work

#

but maybe im wrong and it could work better, i thought comp not equal: pass zero (together with ZTest greater) discards the pixel?

#

is that wrong?

#

yeah there must be something wrong, because i got bugs, sometimes it seems to get discard behind walls :/

steel notch
#

Any easy way to make an object always render on top of everything else?

lost kernel
#

i used "Queue" = "Overlay"

steel notch
#

damn not available from shader graph

#

oh well code time

steel notch
lost kernel
#

yes, maybe together with ZTest always

steel notch
#

Ah, that did it.

#

Thanks friend.

#

I'm using an Unlit transparent shader for this, I assume I can just modify some alpha value to get it to fade away?

steel notch
#
Shader "Unlit/InspectHighlight"
{
    Properties
    {
        _Color("Color", Color) = (1, 1, 1, 1)
        _Alpha ("Alpha", Float) = 1
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue" = "Overlay" }
        LOD 100
        ZTest Always

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
            };

            struct v2f
            {
                float4 vertex : SV_POSITION;
            };

            float4 _Color;
            float _Alpha;

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

            fixed4 frag (v2f i) : SV_Target
            {
                return float4(_Color.xyz, _Alpha);
            }
            ENDCG
        }
    }
}```
regal stag
regal stag
steel notch
south temple
#

I was seeing everywhere that atan2 in hlsl has its arguments in the opposite order than the glsl version

marble thunder
#

I still can't believe it's so hard to find documentation about unity's macros within the shader. I still have no idea what UNITY_SAMPLE_TEX2DARRAY produce. Is it similar to tex2D() (As float4 rgba output?)

south temple
#

glsl: atan(y, x)
hlsl: atan2(x, y)
Like this

And i've been debugging my code forever just to find out that it is not the case

#

Someone has an explanation ?

regal stag
regal stag
south temple
#

I know it's 4 years old, but still

royal vale
#

HLSL atan2 is the same as everywhere else right?

#

(y,x)

meager pelican
#

@lost kernelThis is for URP, but some of the things he talks about might be of interest to you. Or someone else. πŸ˜‰
It's an "x-ray" effect for parts of an object that are BEHIND other things, like walls.
https://www.youtube.com/watch?v=WmnYhIwWYfU

Today we have X-Ray Vision in this Unity Tutorial! Now you can implement a see through walls mechanic in your game! We use Shader Graph for a custom shader, a render feature to render above everything and apply a material to an entire layer and how to enable and disable it via code!

Hope you guys like it!

Inspired by Daniel Ilett: https://www....

β–Ά Play video
#

He's using render features, which are conceptually similar to multiple passes in a built-in pipeline shader.

dawn lion
#

I made this shader (yes it's horrendous, I never use shader graph) and it worked fine in the editor/playmode, but when I made a build the materials using the shader didn't render at all. Anyone have any clue why?

lost kernel
#

thanks @meager pelican the problem is, i used a renderfeature but: 1 layer / player if i want different colors for the x-ray. That sucked, so i tried with a shader, works also and its much easier to handle, 1 material per player and all is good, problem here: a player behind a player get's x-rayed also ... also the player is made of different meshes, im trying to understand shaders better, hopefully i find a solution

#

I use a shader that has an extra pass for the hidden pixels (ZTest Greater), writes a value to the stencil bufer for this areas.
The X-Ray Material (Renders on Top of Everything, ZTest Always, for debug, could be Greater if i got it working) checks for Stencil Equal the value.
The strange thing is it works, i was already starting a party but ... when i move the camera sometimes the x-ray is gone and im trying to figure out why now.
The Shader is pretty complex with a lot of passes, something breaks my plan sometimes and i don't know what :/

royal vale
#

HLSL uses a call stack still right? Like I shouldn't have to worry about concurrency issues with different thread sizes and stuff when dispatching different kernals that use/manipulate the same buffer

shadow locust
#

I don't think you can simultaneously dispatch multiple kernels

royal vale
#

hm alright

#

but are there any like common problems with concurrency when it comes to compute shaders for example? new to them and they're doing some wierd stuff just want to be sure

shadow locust
#

Oh yeah absolutely. Compute shaders are extremely parallel by definition. If you have more than one thread touching the same part of a buffer at the same time you can run into problems for sure.

royal vale
#

Oh damn okay, I assume that's down to not setting the numthreads correctly?

lost kernel
#

Can someone confirm that the passes in a subshader run in different orders depending on the camera / distance ? why is that

#

and how can i force an order

shadow locust
lost kernel
#

ahaha i can't believe @meager pelican .. the problem was , because of the use of renderfeature before i had disabled the layermask "player" in the forwardrenderer for the transparent layer mask ... and object was still in this layer , everytime i got it right it didn't show, just found out by creating a new project and trying there ... 2 F..... DAYS for this shit

idle copper
#

Hi, is there a way to make it so the backface of a mesh (which usually isn't rendered) render a color/texture different that the mesh's color/texture? For example, if the camera moved inside the mesh, or the mesh had a whole in it, you could see the special color.

grand jolt
#

Is there some sort of mapping procedure to convert CGProgram compute shaders to HLSL? I've got a custom surface shader I want to port over to URP, surface to vertex or fragment.

pastel rover
#

Hi, I've been learning shader graphs and I'm trying to make make an glowing emission texture on my object that glows from the centre outwards like a shockwave, I might of missed it but I can't find any tutorials like that on youtube aside from one that was the emission light filling up but I think the code was outdated since I had no errors in the script but it refused to work. Here's what my model looks like for reference

dim yoke
grand jolt
#

i am unable of applying a wave effect only on the top surface of the liquid

regal stag
# idle copper Hi, is there a way to make it so the backface of a mesh (which usually isn't ren...

You can disable backface culling in a shader by using Cull Off in the shaderlab Pass. If you want the backface to use a different colour look into VFACE or SV_IsFrontFace as a fragment shader input (returns 0 or 1 depending on back or front face)
(For Shader Graph there's an option to change the culling in the graph settings to Two Sided / Both faces and use the Is Front Face node into a Branch)

regal stag
# pastel rover Hi, I've been learning shader graphs and I'm trying to make make an glowing emis...

The Sphere Mask node should help here (with object space Position & center of (0,0,0) assuming the origin of the model is at it's center). Can multiply it with your current emission input.
If you want the effect to be playing constantly can use something like SineTime (from Time node) into a Remap. But otherwise have the radius based on a float property that you can then control from C# with material.SetFloat, or via an animation clip.

low lichen
unique raven
#

Hi, I'm using shadergraph to make half of a mesh disappear (any point above a certain local height), and it works when the model is static.
However when I animate the model, it seems my reference point of zero changes, resulting in my mesh that should always have half of it's points hidden, sometimes show a bit more, sometimes less, resulting in a rising tide wave like effect, which I don't want. Any ideas on how I can keep it only ever showing half (or any arbitrary unchanging amount) of the mesh regardless of the animation?
Attached is my simple shadergraph showing how I'm currently doing it.

low lichen
grand jolt
#

i tried to use unity convertor but it still doesnt work

grizzled bolt
vernal island
#

hello. i have to convert writen code into shader to make it faster. i think compute shader would be ideal for that, but i have searched much scripts/websites about it but not much info what i need to. do you know anything what helped you to understand it and would help me :/?

nimble solstice
#

@vernal island What type of code are you talking about?

vernal island
nimble solstice
#

Ahk, I've yet to find an "overmyhead" emoticon, but this is the perfect situation for its use πŸ˜‰

mortal basin
#

Hello i wanted to share a gold mine this video explains every shader node and even the basics of shader graph so for anyone wanting to start shader graph this is a great tutorial https://www.youtube.com/watch?v=84A1FcQt9v4

Shader Graph ships with over 200 nodes in the base package. With such a vast array of features at your disposal, it's easy to get lost when you're searching for the perfect way to make the shader you have in mind. This video shows every single node in action, complete with examples, explanations of what every input and output does and a few best...

β–Ά Play video
nimble solstice
#

Still wrestling with the shadowCoord error. I did find this solution but its for pure hlsl & replacing the _MAIN_LIGHT_SHADOWS keyword with REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR doesn't seem to work in shadergraphs. https://github.com/unity3d-jp/UnityChanToonShaderVer2_Project/issues/44#issuecomment-618936772

GitHub

2020-05-12 β˜‘ QA if the shader error is fixed. Now, the shader is compatible with SRP 7.1.7, 7.3.1, 8.0.1, 9.0.0preview.

#

Is there anyway to edit the varyings.hlsl file included with urp? Of course changing it directly makes unity get mad and revert the file

covert pilot
unique raven
low lichen
#

Also, object position will change if you scale it, because skinned mesh scale is applied directly to the mesh vertices, affecting object space.

#

I've reported that as a bug a month or two ago and haven't gotten a response

unique raven
low lichen
# unique raven ah dang. Is there any work arounds currently for this?

For the scale thing, you can pass the actual scale to the shader from script and divide your vertex positions with it. To fix the pivot point, assuming it's changing to the root bone position, you can pass in the root bone local position relative to the true pivot point and use that to correct the object position in the shader.

unique raven
low lichen
unique raven
tight phoenix
#

I'm working on a 2D black hole shader and its coming along well but there is a minor upset I'd like to factor out of the effect
Right now the camera's zoom/depth/position/something is affecting the end result of the shader, and I'd like it not to but I haven't been able to figure out how to remove it's influence

#

I have like four different graphs im prototyping that all do the blackhole effect slightly differently and they all suffer from it

#

Is this a known issue with shaders? Is there a way to eliminate camera <whatever>'s effect on the appearance?

#

I can post any of the nodegraphs but they're a little messy an undoccumented

low lichen
tight phoenix
#

I did try messing around with these outputs but I wasnt able to correct the distortion with them

dawn lion
#

Does anyone know why Shader Graph lit shaders break with URP decals? I've been trying to figure this out for 2 days and I'm slowly losing my sanity

low lichen
grizzled bolt
#

You can right click any node and open documentation directly, I use it all the time

tight phoenix
tight phoenix
low lichen
#

@tight phoenix If you can, you could also try to distort based on world position rather than screen position. I'd be more specific than that but I'm having trouble imagining exactly what that would look like.

tight phoenix
#

Ugh. I read the docs. I did not get understanding from them. Posting the docs at me and telling me they are clear, when I just said I read them and was not able to get understanding from them doesn't make it wow magic I understand it now. You're just being condescending

#

If you give me a hammer and tell me it hits nails, and I ask you how, and you reply 'it hits nails' again, doesn't make it any clearer

dawn lion
#

what? I was just wondering what those were, if not size. I didn't mean to be condescending

tight phoenix
#

Okay well maybe I was being too sensitive then, I ask a lot of questions and I feel like 9/10 someone just tells me its obvious, but doesnt actually answer my question, making me feel looked down upon

dawn lion
#

ah sorry about that

tight phoenix
#

Shaders arent easy πŸ”₯

dawn lion
#

nope

#

my sanity is hanging from a thin thread rn

tight phoenix
#

I feel you

dawn lion
#

I have no clue why decals would just completely break shader graph lit shaders

#

it makes no sense

dawn lion
#

Like, completely stops them from rendering

#

Whenever I add the "Decals" feature to the URP renderer, those shaders just cease to function completely

#

That's as far as I've been able to narrow it down

#

(This only happens in builds btw)

low lichen
dawn lion
#

Indeed

low lichen
#

That could be shader stripping

#

But that would be a URP bug rather than you doing something wrong.

dawn lion
#

Yeah... That's even worse if I can't fix it then

tight phoenix
#

I had a recent 'only happens in builds' with shaders/materials that in Build, the material was becoming a clone of itself and so changes to the material/shader in code werent propagating to the objects with those materials

#

Iunno if that helps if you are doing something similar to your decals

dawn lion
#

well with me it's more like... everything breaks

#

if I remove the decals again, lights stop being rendered

#

and sometimes ambient light dissappears

tight phoenix
#

realzied I could use a texture to help me debug what each one is actually doing

low lichen
dawn lion
#

yeah... my braincells are leaving my brain at an increasing rate

tight phoenix
#

I think this one is the closest to working but there are just a few things I can't seem to solve

#

Im trying to use camera height but I must be using it in the wrong places or the wrong way, because its not producing the look I want

#

I'm starting to get anxious that i've bitten off more than I can chew and its going to end up a huge steaming failure

#

Problems I keep facing that I can't seem to solve:

  • The look changes based on how close the camera is
  • The effect keeps like, it doesnt "pinch" it does some kind of inverse balooning out on the other side
#

which is sometimes good but at this exact moment its not what I am trying to do

#

clearly not working

#

They're all very cool but none of them are the look im trying to create

#

and ive done extensive googling on black hole shader tutorials, which is what got me this far

#

I hate that the very first one is the least shit, and its the one that is the most directly from a tutorial, every attempt i've made to bring it closer to the effect I want has just made it shittier and shittier :/

#

getting demoralized now

#

time to take a break as a stupid failure for now I guess

dawn lion
#

Alright so I've almost got it working. The materials render now, except their order is wrong.

#

The only way I was able to get them to render was by enabling "allow material override"

#

also still getting the issue of not having any environment/ambient light in the build

#

I'm so confused as to why this only happens in builds, though...

#

Getting somewhere...

tight phoenix
#

what is the correct way to pinch the screen position coordinates to look like that texture?

#

How do you make any kind of change at all to screen space positions?
If you add, divide, multiply, do anything, it seems like it just offsets it

#

I can't seem to make changes to it \

summer plinth
#

I'm converting an old shader to graph, and mostly have it (I think) but I'm stuck on this bit:

IN.uv_MainTex.y - 0.4*tex2D (_MainTex, (0.4*IN.worldPos.xz  ...

What node/channel corresponds to the uv.MainTex.y ?
I can add the whole context if requested but it's pretty much just that bit that has me stuck.

nimble solstice
#

Uv into split so you can extract the y maybe?

#

(uv node)

summer plinth
#

Yeah I think that's working now. Thanks!!!

#

I was trying to figure out how to get the UV output from a SampleTexture2D node. Didn't realize there was just a "UV" node.

dreamy garden
#

does the lightweight rp come built in? i couldnt find anything onit

lone bone
# tight phoenix

that still looks cool though, would you be down to share the graph file?

tight phoenix
atomic elm
#

I'm trying to modify Brackeys' dissolve shader but have it so that instead of dissolving to a transparent, it dissolves to a color. Can someone point me in the direction to do this?

lone bone
#

Nice! thank you. You said the problems with it were camera distance and a wierd pinching effect? i could try to screw around with it later and see if i can fix those

tight phoenix
#

I use a quad mesh and some URP renderpipeline draw object settings to draw the world, then draw the lensing where the quad is

#

I do like the first one, but I was going for more of a pinch + twist look, #1 does great lensing, and #2 does sort of a pinch, none of them do twist

tight phoenix
nimble solstice
dreamy garden
#

only problem is

#

everything is purple now

#

even after upgrading all project files

nimble solstice
#

Ah, there's a function to update materials

#

AH, KK

#

only updates built in stuff

#

So if you're using custom...

dreamy garden
#

probuilder and stanard cubes all did that

nimble solstice
#

Yeah, probuilders done upgrade iirc

#

Not sure about the standard cubes

dreamy garden
#

im working with old mats

#

will take awhile but it will work

#

thanks πŸ˜„

knotty yarrow
#

I was trying to compile my shader but this error message appears and im clueless

#

can someone please help me?

#

thanks

pastel rover
#

Hi, I got my emission to animate how I wanted it (ty Cyan) though another issue I'm having is my emission mask has a grey colour to it on the model while plugged into the shader's Alpha channel which I thought would make the material transparent, I also set it to transparent in the graph settings too. I was assuming that by doing that the main material would be visible under the emission glow. Here's what the emission map looks like on the model for reference

mystic sequoia
#

is there any way to apply shaders to 2d games?

dim yoke
mystic sequoia
#

Well, I would prefer hdrp or srp but honestly I can easily switch to the most convenient one

dim yoke
#

urp is definitely the best render pipeline for 2d games

#

On urp you can make 2d shaders using shader graph (theres unlit and lit options for sprite shaders)

#

On built in render pipeline youd have to code the shaders yourself and theres no official documentation for that afaik

mystic sequoia
#

Oh ok

#

Thanks dude 😊

twilit jackal
#

My first shader graph and I don't understand where I went wrong. I have a tree sprite that I sample and it's stretched out unlike the tutorial video that shows the sprite correctly. Any idea where I went wrong?

#

If I look at the normal of the image, it looks right and isn't stretched.

dim yoke
#

like this

vocal narwhal
#

The texture2D preview does not show the alpha channel

#

what you see there is the real RGB pixels behind the image

#

it's bled out like that to prevent alpha fringing artifacts

twilit jackal
#

I get it now. Thank you so much!

unique raven
#

Hi, how can I get shadergraph to mask out a target mesh when given another mesh? essentially I only want to render vertices of the target mesh that are inside a given masking mesh.

vagrant snow
#

I made a shader with 2D Textures but in the sea regular squares appear and I need a way to fix it. What could I do? πŸ˜…

slim steppe
#

Hi I'm using a planar reflection script but it also "reflects" sides of the terrain which obviously shouldnt be visible.

#

How could I fix this? I think the script works fine but thats just how ite works

vagrant snow
slim steppe
#

lerp between them using some noise

gloomy tendon
#

can you control the bump level in a surface shader? You only seem to be able to output the normal so you can just manipulate it directly, but no 'scalar'

lament karma
#

I'm following this tutorial as I'm new to shaders, and my material looks a bit different in the end: https://www.youtube.com/watch?v=taMp1g1pBeE
My material is not only one alpha, but a noise. What confuses me is how the tutorial texture doesn't look like mine, seeing as they also change the alpha channel.

Let’s learn how to create one of my favourite effects: Dissolve!

Check out Skillshare: http://skl.sh/brackeys6

● Download the project: https://github.com/Brackeys/Shader-Graph-Tutorials

β™₯ Support Brackeys on Patreon: http://patreon.com/brackeys/

Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·

β™₯ Subscribe...

β–Ά Play video
#

my guess is that this is due to the version of the shadergraph that I'm using.

#

I'm now pretty sure it has to do with the different "Surface" types.
In the tutorial he's using Opaque, and I'm using Transparent, as I cannot see the preview unless I do. Any ideas?

#

FIXED KIND OF
Now I just need to know how to actually see the preview of my shader even when using opaque instead of alpha...

wraith vapor
#

I'm actually having trouble with applying a shader, Crystal Shader, to some things on one of my models... In Unity Hub, it all looks correct, but after exporting it, it all just has the default material textures... I've tried everything that I can think of, I've even installed the package, and I've even tried placing the shader file into the files of the accessories directly, but no change... Does anyone have any ideas?

round linden
#

Why do I have this problem? The character does not have this problem in the blender. I use the default buil-in render of unity.

wraith vapor
wraith vapor
# round linden The render

I'm not sure if I see the issue here... I'm assuming that the top picture is how it is supposed to look, right? Could you explain the issue in more detail please?

round linden
#

The elements are superimposed as if they were semi 2d

#

From this angle you can better see what I mean

wraith vapor
#

I think I understand now... So, did you try to bring these elements in as objects, or create objects to place the materials onto...?

#

Also, please keep in mind that I only started using Unity yesterday

tight phoenix
#

I am making progress on a blackhole shader - the bellow nodes create a pinch effect that does not change the closer/further away the viewing Camera is, however it introduces a new distortion I'd like to correct - the object's physical rotation affects the distortion

#

Without the camera correction group, the "zoom" strength is a static value so the object can be rotated freely without affecting the depth of the zoom
With camera correction however, when the object is rotated, the zoom value changes

#

I need to account for the object's rotation in some way and then use math to remove its effect from the camera correction group, but I am not sure how

#

gif example of the rotation-distortion im trying to remove - pictured there I am rotating the gameobject plane which causes the zoom value to fluctuate

#

People discuss in length getting object rotation in shadergraph here but I don't know enough about matrix math to use these nodes to get the result I desire

wraith vapor
#

I see what you are saying, yes... From my (little) experience, something is triggering the zoom values here, so my best guess would be to investigate what all is pointing towards the zoom values, and see if you can make a new instance of whatever is causing this, to replace the current cause/effect actions... if that makes any sense...

swift loom
#

I'm trying to save some data into an array for each pixel to use for calculating. I have a [loop] for loop and inside I'm just using a normal array that I try to add the data to and then I iterate which index I'm writing to, but this causes the loop to not work. Is there some better solution I can use to store some color data for later use instead of an array, or do I need to do something special with the array? I've seen some cbuffer stuff but I don't really know what that is.

swift loom
#

setting the array to static seemed to let it run but i don't know exactly what that does so not sure it's the solution

lime star
#

so i have a texture, that i manipulate using a compute shader each Update, so i dispatch the shader, and have the result in a local variable...
my question is: how come this Rendertexture is always fine to use in the same Update, but in the next one (before it is reassigned) it always is equal to null?

#

for example

public void Start()
    {
        _result = new RenderTexture(1920, 1080, 24);
        result.enableRandomWrite = true;
        result.Create();
    }

public void Update()
    {
        Render(_shader)
    }

public RenderTexture Render(ComputeShader shader)
    {
        shader.SetTexture(slime.FindKernel("Render"), "Result", _result);
        shader.Dispatch(slime.FindKernel("Render"), result.width / 8, result.height / 8, 1);
        return _result;
    }

void OnRenderImage(RenderTexture src, RenderTexture dest)
    {
        Graphics.Blit(_result, null);
    }
``` where shader is just the default compute shader
on the first cycle it works fine, as i manually set _result, but after that i get an argumentNullException
#

you wouldnt think that should happen as _result is a valid texture (from the last cycle), it is also not externally changed or anything

#

mightve worked it out πŸ€¦β€β™‚οΈ

lean lotus
#

is there a faster way of uploading very very large buffers to the gpu than SetBuffer?(1.7million entries at largest so far) For a buffer that large, setbuffer takes like 30-40ms according to profiler

marble thunder
#

I am having the weirdest trust issue with runtime created Texture2DArray, and accessing individual textures in the shader. Whenever I tried to Graphics.Blits the result, it would generate a grey-ish image like. How can I properly get the texture2D data out of Texture2DArray? At Editor time, it works fine when I actually have the texture2DArray created, but not at runtime.

#

I've debug my code to a point where the issue is somewhere between setting Texture2DArray data into material slot, and simply... using Texture2DArray.

shadow locust
lean lotus
#

erm, cant unfortunately, its needed every frame

#

as it feeds the rendering

marble thunder
#

That sounds horribly optimized... Is there any other ways you could reduce the amount of buffer before shoveling into GPU?

lean lotus
#

erm not really
it feeds in an updated bounding volume hierarchy for a compute shader raytracer

wide thicket
#

hello, my custom rendering file doesn't show up when trying to add it to the forward renderer "add renderer feature" section, how can i fix this?

marble thunder
#

are all rgba value 0..1 or 0..255?

#

e.g. tex2D( _sampleTex, uv ).rgba

wide thicket
#

currently getting this error:
Assets\Scripts\Rendering\RenderingFeatures\ScreenSpaceOutlines.cs(129,13): error CS0246: The type or namespace name 'ViewSpaceNormalsTexturePass' could not be found (are you missing a using directive or an assembly reference?)

#

not sure why, it's right there

#

but it's this part that won't recognize it

#

I've checked the spelling and capitalization, don't think that's the problem

#

that and this error:
Assets\Scripts\Rendering\RenderingFeatures\ScreenSpaceOutlines.cs(16,30): error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?)

vocal narwhal
#

Your IDE does not look configured. If you're not getting errors underlined and autocomplete you should fix it using the instructions in #854851968446365696

#

You're also not using the namespace for list, which having a configured IDE should make easy to import.

regal stag
regal stag
wide thicket
vocal narwhal
#

If the error about the list is now underlined in red you can click it, click the lightbulb, and import the correct namespace

wide thicket
#

ah wait, switched to the correct version of VS

#

seeing the errors now

wraith coral
#

my shader is pink

#

idk why

tame topaz
#

What pipeline are you using?

fervent tinsel
knotty yarrow
#

do android support shader graph?

#

everytime i build my game something that made using the shader graph are pink

#

i already tried some of fixes but those are not helpful at all

#

please anyone help me

nimble solstice
#

It doez

knotty yarrow
#

can u help me with the problem

#

the shader just pink on mobile builds

#

im in a dead end rn \πŸ’€

nimble solstice
#

Errors? Using urp?

hazy sage
#

Hey everyone, I had a problem about a shader I use. On the right, the texture is applied on the object, nothing else (and it looks like what I want)