#archived-shaders

1 messages · Page 75 of 1

regal stag
sly delta
#

Im already acessing the .material.

Some some reason, my enemies need the GPU instancing no the material to have different properties, but the player doesnt. Even tho they have the exact same material and im getting all their materials in the same class

#

EDIT: The player (lighted object on the scene) actually had a different material, but yeah i need GPU instancing to actually get per instance variables. But how do i set them actually be affected by post-processing/light?

#

i think i've fixed it, ill just multiply the color at the end and should be fien

hollow harness
#

can anyone please provide me a simple unlit shader with 2 passes including the ForwardAdd lightmode, which does its lighting properly for lightsources other than directional light...just for learning purpose

vague imp
#

hello, i have a tree that i want to react to wind in unity, and i want to store a float value in the vertices of my model, that holds how much each vert gets affected so that i can use it later inside of my wind shader graph.

is it even possible to store this info in my verts and then use it in shader graph?

regal stag
vague imp
modest fjord
#

Would anyone happen to know why calling Graphics.Blit() on a RenderTexture with a Material generated from a ShaderGraph would always produce a red value? The ShaderGraph is set to only output black and 0 alpha, but the resulting RenderTexture has a red value. I made a thread that has a bit more context + images if that helps: https://forum.unity.com/threads/graphics-blit-always-outputting-1-on-red-and-alpha-channels.1576584/

regal stag
modest fjord
slender ore
#

I have tried this method but with no success, it was always a little bit off. I have also tried a number of different combinations of the method on the screen but I think what happens is, the seed value returns to 0 as quick as the sine value goes below 1. Do you know any way to turn this Branch from if (value == 1) {true} else {false} into a trigger? Something like if (value == 1) {true} but without this false return

regal stag
#

Here's a similar setup but with a triangle wave instead of sine

dark flare
#

So uhm can someone help me make

sinful vault
#

hey guys?
i try now a very long time to create a buitifull water shader with Foam, Waves and some more...
but nothing what i try wont work 😦 i tryed to follow youtube videos, i tryed to follow a KI Chat Bot...nothing work...

maybe anyone here have a nice waterShader for free?

mental bone
#

I'm trying to create a UI blur shader for a world space canvas in HDRP. Now sampling the hd scene color node with a higher lod works great, but I need to discard objects that are between the UI and the camera obviously. I cant figure out how to use the scene depth to do the check. Can someone point me in the right direction ?

amber saffron
# mental bone I'm trying to create a UI blur shader for a world space canvas in HDRP. Now samp...

I guess you can't really :

  • Obviously, when objects are between the camera and the UI, the UI pixels behind those objects are not visible, so that's not the issue ?
  • But because the scene color node LODs are a blurred version of the whole screen, it contains blur of objects that are in front of the UI. Including on pixels where the objects are not directly in front (because, blur)
  • The two only ways to get around this would be to :
  1. Have a dedicated color buffer with objects only behind the UI, and the blurred version in LODs
  2. Do a custom multi-tap blur (costly) in the UI shader on the scene color LOD0, and discard samples where the matching depth buffer value is in front of the UI
mental bone
amber saffron
mental bone
#

This is starting to go into not worth it category. I should have mentioned it is for VR and the UI is floating to follow the head of the player

#

But just for my own learning how would the discard of samples for option 2 work ?

amber saffron
amber saffron
mental bone
#

How do I get the current pixel depth ?

amber saffron
#

It's the view position Z value 🙂

mental bone
#

Right. And to sample the color buffer I need its texel dimensions no ?

#

To offset the screen pos uv’s

amber saffron
#

Yep

mental bone
#

In eye space maybe?

#

But how do I get the texel dimensions of the color buffer ?

amber saffron
mental bone
amber saffron
mental bone
#

1/screen.width for example is the texel.x of the color buffer yes ? My original idea was that adding +1 to that and then sampling would in fact sample the pixel on the right

amber saffron
vague imp
#

Hello, im making a tryig to make a wind shader that offsets the verts of my tree models and i was wondering. Is there a way to have unitys built in wind sones affect the models using this material?

Like, is there a way to get the amount of wind that should be applied to this object via windzones, inside of my shader graph?

mental bone
amber saffron
vague imp
mental bone
#

Like windMain pulseFrequency etc

tacit parcel
# sinful vault anyone? 😦

Not enough information.
What kind of style are you trying to create? (realistic? cartoon? anime?)
What is your current progress look like?

sinful vault
tight phoenix
#

How do I get Canvas to show up as a shadergraph type?

#

I am on unity 2023.3 and shadergraph in the package manager has no updates avaliable but as far as I can tell I should be on or above a version that supports this feature

#

ah its URP thats the problem. I am on URP 14.0, it needs 16.0

#

hrm actually im on latest LTS so I am a little confused where/why I don't have this 🤔

#

trying to figure out what I need to update when/where to get it

#

like 6 months old videos are showing Canvas shaders are in 2023.2 and I am in 2023.3

#

Oh Im dumb and blind I am in 2022

mental lake
#

Using render graph, is it expected that DrawRenderers() for objects on the AfterRendeirngTransparents render event will prevent any ztesting from occurring? My objects are rendering on top of all of my geometry!

regal stag
mental lake
#

Interesting, no I haven't - I've called builder.SetRenderAcctachment() for the activeColorTexture only

#

On 2023.3

#

Oh sorry I meant that I'm using DrawRendererList()

regal stag
#

Edited my above, sorry mentioned the wrong functions

mental lake
#

Thank you that fixed it!

twin wave
#

I'm trying to apply fog to a shell based shader in the URP and while I appear to have made some amount of progress it is still not working properly. I'm also getting really hard, pitch black shadows. Any idea what I might be doing wrong?

bleak patio
#

Not sure the right channel - feel free to redirect. If I have a large mesh, is there a way to apply different materials to different faces? Or should I break that into separate meshes? Is this what submeshes are really for?

grizzled bolt
bleak patio
#

to the googles.

#

I have some more submesh questions:

  • If I have a large mesh, does unity automatically make it into submeshes or do I need to do that manually? I am making meshes at runtime
  • Is the vertex limit of 2^16 vertices at the mesh or submesh level?
  • If I want to make a huge mesh with different rendering graphics, is it best to just make each different rendering target a submesh?
  • To be more clear: I'm making a golf game. I make a "bunker mesh" and am trying to stitch it together with a generic "rough mesh" and am having problems. It would be much easier to just make a huge mesh and put certain vertices in a submesh so they can render different (sand vs grass)
  • Can I have triangles between submeshes?
regal stag
# bleak patio I have some more submesh questions: * If I have a large mesh, does unity automa...
  • No, you handle it manually. For procedural meshes, SetTriangles
  • See the baseVertex param in the above function, I think it allows you to specify an offset so you can go over the overall 65535 vertex limit. Can also instead override the indexFormat to use 32-bit indices.
  • The point of submeshes is so you can apply different materials. So yes for your golf scene, you could assign sand to the bunker submeshes and grass elsewhere. Or could look into using a "terrain-like" shader that already allows you to paint multiple textures (via a splatmap or vertex colors)
  • Submeshes have their own separate triangle arrays. They can share vertices though (probably assuming you don't use that baseVertex offset)
bleak patio
#

Thanks Cyan. Given that each submesh would need a different Physics interaction as well (obviously rough is different than green or bunker)... how would you store an entire hole's geometry? Any advice? Thanks for your time.

#

For further context: I am auto-generating holes... so I will create unique bunkers/greens/fairways each time, e.g.

#

Current plan is a bit odd.... I would draw a generic mesh with noise of rough at some resolution per unity unit... then each feature (biome vegetation, fairway, green, etc.) - have a spline that defines that area. If I'm within a spline, I'll let that unit draw its own geometry... otherwise, I will connect a triangle to the nearest point to that spline. Then within a unit, I will use terrain shaders/splatmaps to do things like draw dirt on the walls of bunkers or something.

regal stag
bleak patio
#

I can't use a different collider then on a SubMesh?

regal stag
#

Afaik no, it's only on the whole mesh

bleak patio
#

Okay, so basically same plan and then just make them different GO/MeshFilters instead of SubMeshes... I'll just have to duplicate some triangles I suppose

#

And vertices

#

Unity forums seem to imply that meshes can be split automatically - would really simplify my mesh code

junior galleon
#

Guys, how do you use mask and thickness textures? I'm in the shader graph right now.

grizzled bolt
junior galleon
#

Any way to figure that out?

grizzled bolt
#

Where did you get it?

junior galleon
grizzled bolt
#

Thickness must be supported by the shader, it'd likely be used for translucent or subsurface scattering

junior galleon
grizzled bolt
grizzled bolt
junior galleon
#

I don't know what to show you

grizzled bolt
junior galleon
#

Its unitys terrain sample

#

it includes a bunch of grass

#

Is there a way to go in the shader and check?

grizzled bolt
# junior galleon Its unitys terrain sample

Then it's either URP mask map that has metallic map on the R channel and smoothness on the A channel
Or more likely it's HDRP mask map which also has AO on green channel and detail mask on blue channel

#

If it's for HDRP that means the thickness map could be used for HDRP's "translucent" or "transmission" material types

#

In a custom shader graph the support for those features must be enabled in the graph settings
I don't remember if HDRP lets you use all the special material types in shader graph though

junior galleon
#

I am in URP

grizzled bolt
#

To use the mask map correctly you'd use the Split node to split the color channels out, and connect them to the appropriate inputs

junior galleon
#

No idea what the asset was designed for, asset store it's compatable with all

grizzled bolt
junior galleon
#

Nope

junior galleon
grizzled bolt
#

Unity's mask maps don't conflict with each other but non-Unity mask maps could

junior galleon
#

I mean you said "if it's for URP..." with 2 outputs and then for HDRP with 2 different outputs, nothing that you said conflicts with itself

#

green looks to be AO, it looks right

#

I dunno about any others

junior galleon
#

It looks totally off, center grass is the normal one

#

Smoothness and metallic 0 looks like the normal model

#

I'll just leave it like that

grizzled bolt
#

This is not a problem that can be fixed by tweaking the values of mask maps because it's unrelated to them

#

0 smoothness can conceal only by removing all specularity which isn't how the material is meant to look

junior galleon
grizzled bolt
junior galleon
#

So what do you suggest?

grizzled bolt
royal bloom
#

can someone help me make a shader to make these image sprites white?

regal stag
steel notch
#

Why is it that in the intersection of these 2 meshes, I get a black band?

regal stag
steel notch
#

Is it related to ambient occlusion?

grizzled bolt
steel notch
#

Actually on a side note, normals are not altered by a mesh's scale factor, right?

#

Their direction I mean.

#

Like if you made an object's scale (0.1, 1, 1), would the normals adjust?

royal bloom
#

i'll take this

#

why do i get this error?

#

i dont think i modified Default UI Material

#

im pretty certain i didnt

regal stag
# royal bloom

Ah, I should've suggested using the UI Default shader as a basis instead of the sprites one actually. The sprite one doesn't have the stencil stuff.
Again probably changing the fragment to return fixed4(1,1,1,color.a);

royal bloom
#

and i still get the error

royal bloom
regal stag
royal bloom
regal stag
# royal bloom can you help me make it identical to what i had?

Copy the UI default shader, swap frag function out for something like this

fixed4 frag(v2f IN) : SV_Target {
  half4 sample = tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd;
  half4 color = IN.color * half4(1, 1, 1, sample.a);

  #ifdef UNITY_UI_CLIP_RECT
  color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
  #endif

  #ifdef UNITY_UI_ALPHACLIP
  clip (color.a - 0.001);
  #endif
  
  return color;
}
royal bloom
#

yeah it works man

#

thank you so much

#

but why am i still getting the error?

#

i only get it when i enable the dropdown template

regal stag
#

Not sure, might just have bugged out a bit. Maybe try reloading the editor

royal bloom
#

thanks so much man

#

i appreciate it

dapper heath
#

heya, is anyone aware of a better way to do this?

i'm trying to do worldspace uvs for this sample mountain made in probuilder, but i'm having a tough time getting it to look right
i use x & z for the top (flat, which is fine), x & y for one side, and y & z for another. problem with this is that i want to be able to just put one material on all vertical sides and have it tile correctly, so i've been trying to "assume" which to use based on the normal vector

#

as you can see though it produces weird stretching

#

atm i'm lerping between x and z based on the x component of the normal vector, i'm positive there's a better way though

strange moth
#

ok so I have a gas planet shader that I made in unity shadergraph, there is this seam that runs through the planet, how do I fix this?

#

open up images for full view*

hot cloak
#

Anyone know why my material is full and simply transparent instead of patchy like this?

#

maybe it takes the entire shader and averages the transparency?

tacit parcel
shell fable
hot cloak
hot cloak
karmic hatch
#

(so sampling (0,y) should give the same value as sampling (1,y))

karmic hatch
hot cloak
#

with alpha clipping on it has the same effect ^, until I set clipping to around above 0.5, then it just goes completely blank

karmic hatch
#

I assume this is a procedural mesh or something?

hot cloak
#

I'll look into the UVs

#

thanks

karmic hatch
#

If it's procedural, you just need to do mesh.uv alongside everything else

hot cloak
#

nah these aren't

alpine igloo
#

is it possible to rotate these things?

regal stag
regal stag
upper jetty
#

Anyone know how to resolve this lighting issue Im having with RenderBoth sides of a plane in shadergraph URP?

In the images I have shown a light on either side of the 'front' faces of a mesh. Light seems to only be calculated for the front face and duplicated/mirror onto the backfaces. I would ideally like the light to be calculated for both sides without having to add extra geometry explicitly

#

And yes I have tried that trick everyone shows online (see image for reference) where you use a 'is front facenode' and invert the normals, when I do this it just flips which faces are considered the 'front' faces so doesnt really heap much with what I want to do

grizzled bolt
#

It should fix the initially described problem so maybe you're observing a different one

upper jetty
#

It seems to just flip which face is considered the front face, instead of handling the normals seperatly

#

IM using the built in Lit shader in URP

#

Some of the examples I saw online where people used that fix they were using PBR, so maybe it has something to do with that

regal stag
upper jetty
regal stag
#

Okay. So you're using World space normals in a Tangent space port. You should change the normal output space under the Graph Settings

#

Unless you actually need tangent space for normal maps. In which case I think you should only be negating the Z axis

upper jetty
#

Yeah that was just me trying every combo of normal type 😂

#

When I change them both to world the backfaces receive no lighting at all

#

Im gonna try a different method anyway and just just the magnigtude of the main light source to light foliage

grizzled bolt
deep moth
#

I know this isn't what you're asking but often for foliage a hack I'll use is to use the normals of the surface underneath them. Usually that means just pointing them up.

neon harbor
#

Hi, i'm trying to figure out why my Tranpsarent Cube is still visible in the scene. It's hard to see but certainly visible 🤨 . Is this normal?

floral badger
#

Hi, I have a PNG image being rendered and I'd like to switch the shader from UI/Default to something else. How do I un-gray the shader options?

grizzled bolt
floral badger
#

Oh, the 3rd line in the photo? That makes sense thx

muted depot
#

anyone knows what might be the cause of these errors? this is URP2d unity 2023 project, almost new, barely touched shaders

grizzled bolt
muted depot
#

it doesn't seem to break anything but it's annoying

#

at least for now

strange moth
#

So basically I have a planet shader but there is a ugly seam on the planet sphere. Its a bit complex with a moving storm that passes around the planet, If you can help me that'd be great and it'd help me a ton. DM me please if you can help, You would need to watch my screenshare for myproblem to be clear.

raw willow
#

After scouring this channel history and the webs, it looks like SM 6.6 features like InterlockedAdd(float) are still not supported? Just double-checking.

alpine igloo
#

what would be the unity equivalent of vertex position in UE?

regal stag
#

Probably with space set to Object specifically

alpine igloo
#

yes i mean shader graph, ill try this out, but if i want emission based on my vertex position would this still be possible?

#

because the emission is in the fragment stage

#

im using hdrp btw

carmine crag
#

do made shaders for Built-in Render Pipeline work well in mobile devices ?

amber saffron
#

Unless you do something fancy, like deformation in the vertex shader but still want to use the original vertex position in the fragment, you just have to use the position node

craggy dune
#

Hi guys i have a Color in my shader and on the material when i change the color it stay on white color, i use 2022.3.0 version someone know something on this problem ?

sour gale
craggy dune
sour gale
craggy dune
sour gale
#

can you show the color panel

#

I mean show it all

craggy dune
#

like that ?

craggy dune
sour gale
#

are you using urp or hdrp?

craggy dune
#

hdrp

sour gale
#

in hdrp you must give the emmision very high value to be able to see it

craggy dune
#

i know that not the problem

#

the problem is when i change the color there is no change the color stay white

#

so i can't put it blue or red

sour gale
#

can you show the object too

craggy dune
sour gale
craggy dune
regal stag
craggy dune
regal stag
regal stag
craggy dune
regal stag
#

Probably a bug then. I'd try restarting unity

craggy dune
#

already try

sour gale
#

can you try multiplying the emmision color with a float and set the value to a high value like 20-30?

craggy dune
sour gale
#

does the color change on the inspector?

#

when you change it on the wheel

craggy dune
#

no that the problem

regal stag
#

If you create another color property, can you change that one?

craggy dune
#

When i select blue that do nothing so the color is white again

craggy dune
#

thx

tranquil wolf
#

having this weird bug where the shader outline for my slimes disappears behind my water shader. any ideas?

brisk spindle
#

I'm trying to make a simple outline for an object, taking the position of the vertices and scaling them out, rendering only the back to create a sort of outline, however it's position isn't working how I'd expect. With the scale and colour set, it just positions itself far away from the object itself

regal stag
dim yoke
tranquil wolf
#

Unless I did it wrong

tranquil wolf
# brisk spindle I'm trying to make a simple outline for an object, taking the position of the ve...

https://youtu.be/Bm6Bmcjd1Mw?si=qZ4ZuKV2yZe9uWBr

here is a tutorial for getting outlines in unity that I did - it does the same thing you're doing. took me a bit to do it correctly, is hard

Hey Guys! Welcome back to another CG Smoothie Video! In this video I'm bringing you guys a new Unity Game engine tutorial! This time, we're learning how to use the unity game engine to make 3d outlines around characters and objects in your game using the Unity Shader Graph! I think this is one of the BEST Outline tutorials out there! If you guys...

▶ Play video
brisk spindle
tranquil wolf
brisk spindle
#

and now when i run the game the outline material just vanishes...
yippee. head hurts :/

regal stag
tranquil wolf
#

yeah to get an outline I had to mess with the render pipeline. that is why I linked that video instead of giving a simple solution

sour gale
brisk spindle
#

yeah, lowering it brings it closer to world centre and reduces the size, raising does the inverse

#

but, when I just apply the material as normal it works fine

#

so it's the way i'm doing it dynamically that it doesn't like

sour gale
#

does it happen with all the object? can you try default untiy cube?

#

I can give you my outline shader if you want. you using URP or HDRP?

tranquil wolf
#

@regal stag love your website btw

regal stag
brisk spindle
#

just because i've ticked static?

dim yoke
#

good catch

regal stag
brisk spindle
#

gotcha, that'll come in handy

#

although I think I'm going to resort to your idea of having a separate object since even with that fixed, it's not switching materials properly

#

is that normally the approach you'd take for something like this? When highlighting objects for selection?

alpine igloo
#

should you make objects which have a custom shader but dont move like rocks static?

ebon basin
#

Dynamic batching for low end mobile devices though. Still, always profile and compare.

cerulean moat
#

Helloo Folks

#

How can I make a shader affects different sorting layers?

grizzled bolt
cerulean moat
#

Like the target

#

To iluminate

#

Like the lights

grizzled bolt
#

Hmm I don't quite understand what kind of effect you're describing

cerulean moat
#

The light can illuminate specific sorting layers

#

How can I make this in a shader?

#

This is the shader,I want the glow effect to affect layer behind it

alpine igloo
ebon basin
alpine igloo
#

yes i did that

ebon basin
#

Not entirely sure how static batching with groups work, but ive read stuff that it's still ideal to flag statically.

#

If anything, more to cache but mem is cheap

#

As for dynamic stuff. I find using urp that gpu instancing has been a frame increase beyond some situations

grizzled bolt
cerulean moat
#

Oh

#

I get it

hallow void
#

Is it very difficult to convert this shader from standard to urp?

Shader "Custom/Stencil Object" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200

    Stencil {
        Ref 1
        Comp equal
    }
    
    CGPROGRAM
    // Physically based Standard lighting model, and enable shadows on all light types
    #pragma surface surf Standard fullforwardshadows

    // Use shader model 3.0 target, to get nicer looking lighting
    #pragma target 3.0

    sampler2D _MainTex;

    struct Input {
        float2 uv_MainTex;
    };

    half _Glossiness;
    half _Metallic;
    fixed4 _Color;

    void surf (Input IN, inout SurfaceOutputStandard o) {
        // Albedo comes from a texture tinted by color
        fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
        o.Albedo = c.rgb;
        // Metallic and smoothness come from slider variables
        o.Metallic = _Metallic;
        o.Smoothness = _Glossiness;
        o.Alpha = c.a;
    }
    ENDCG
}
FallBack "Diffuse"

}

regal stag
hallow void
#

thank you so much

polar relic
#

When doing custom function in HLSL, how do you control conversion/non-conversion casts?
I'm using one of Unity's batch API, and it only allow to transfer float - including for stuff that could fit in a byte, which has a sizeable effect on data transfer speed.
EDIT:
Nevermind, found it.
int MyInteger = asint(MyFakeFloat);

muted depot
#

is there a way to suppress warnings from default shaders that come with URP?

#

other than editing package files which isn't a solution because not only it will get overwritten it also only changes stuff on my end

#

I really hate pointless warnings on every build because that obscures warnings that might actually be relevant to me

lilac mist
#

I have a question about using shaders and time. (Using shadergraph)

Let's say I'm using a material with a shader that gradually brightens a sprite over time, or dissolves an object over time, or some similar effect. This works fine if I only have one object and only want the effect to occur once, but how do I re-trigger it or reset the timer for multiple objects?

#

For example if an enemy dies and I want their body to dissolve using the normal Brackeys dissolve shader, this only works for one object and only once

coarse pilot
#

👋 Hello there, I'm not sure if I'm on the right channel but I'm having issue with LWRP and transparency, I have a PNG but Unity refuse to render it correctly

lilac mist
#

I'd really prefer to not have one material instance per object with my material

desert orbit
coarse pilot
desert orbit
#

LWRP is URP

coarse pilot
#

Ok 👌😊

silent sluice
#

hello, i dont know if this channel is the right way, but i suppose it's shade related thing:
How is the feature called where a part of a object that is inside a completly invisible cube is hidden? I would like to hide parts of the objects inside a cube, but not behind or in front

#

short explaination, in this image i want the green drawn part to be hidden while the cube is hidden

#

i have found something similar, but it's when it's in front, not in area

silent sluice
#

i have found this picture, i need to do this

sour gale
#

My texture is colored but why the output is black and white?

#

it's a regular urp lit shader and I didn't change anything

sour gale
regal stag
sour gale
hexed sorrel
#

Hey, I have an issue with my unity foliage wind shader graph where I am trying to simulate "wind" based on a windspeed variable using UVs currently, it works perfectly when windspeed is a positive integer however, as-soon as it becomes negative (to blow the other direction) it starts vertically stretching as the image below shows (assuming I can send images haha). If anyone has any idea as to what would be causing this I would be extremely appreciative, thanks!

#

my suspicion is that the multiply is just darkening the UV therefore stretching it, as it looks a lot different with positive integers.

#

I had a bandaid fix for it, where I'd just flip the uv conditionally based on the sign of windspeed, however that flips the entire asset and looks really weird when the wind speed is rapidly dancing over and under 0 "windspeed". If anyone has any ideas as to how to prevent the stretching based on the darkening I am quite new to shader graphs and would be very appreciative of any insight that could help me out, thanks!

sour gale
#

add a 'Vector2' node

#

the out of multiply goes to x and the Y is 0

#

and out of the Vector2 to Add

#

such as this

#

it stops it from stretching in the Y

hexed sorrel
lament scarab
#

What am I missing here?

regal stag
stable nexus
#

Hi. i wanted to ask how to convert world space position to view space position.

dim yoke
stable nexus
#

shader code

#

also could you please tell me how to get object space position ?

#

is there any documentation that tells all of this basic stuff ?, because googling doesnt gets me any concrete resource

regal stag
regal stag
dim yoke
#

Also note that the transformation should preferably be done in vertex shader and then transformed into the fragment shader. The vertex position is no more in object space in the fragment shader

regal stag
#

Yeah, if you need object space in fragment you'd need to pass into your own interpolator (e.g. an unused TEXCOORD channel) - same for the other spaces too.

dim yoke
#

That would probably be preferred when you need the positions in multiple spaces, passing every position in their own interpolator most likely wouldn't be as fast as only passing the object space position and doing the transformation in the fragment shader. Not something you need to really worry about at this stage though

regal stag
#

Personally I'm also not a fan of the .vertex style naming, I prefer positionOS/positionCS etc like the SRP code uses as it's much clearer.
But iirc some Built-in RP macros might not like that.

dim yoke
#

Yeah, I don't think they do. At least some shadow handling macros don't want anything else than .vertex. But again, I wouldn't care about that at this point, rarely you need the macros when doing more basic shaders

lament scarab
#

After doing all of this, my outline is still not emissive, what am I missing?

grizzled bolt
lament scarab
grizzled bolt
lament scarab
#

now i'm confused what emission actually is

#

i guess it would be nice if the outline also affected the lightmap

#

i like how standard shader emission behaves and i guess i was trying to replicate that

#

but seems like it's less straight forward than i imagined

grizzled bolt
grizzled bolt
grizzled bolt
lament scarab
#

i thought that's what i was doing tbh haha

#

i think worst case just hdr on the color prolly gets me half of the way there

grizzled bolt
lament scarab
#

anything else could affect it?

grizzled bolt
lament scarab
#

here's an example exagerating the bloom

#

in purple is my outline which doesnt seem affected while the intensity is much higher (in white the standard shader emission)

#

tbh it seems like all the emission code i added does nothing at all

grizzled bolt
#

Bloom has no knowledge about what the shaders are doing

regal stag
#

Is the outline meant to be magenta? That colour usually means the shader can't compile, there might be a syntax error

lament scarab
#

also emission is just white

#

but doesn't do much, seems like nothing

#

here's the full code here

#

hmm wait

#

basically i took some outline shader and tried modifying it to add emission to it

regal stag
lament scarab
#

oh it's like a chain?

#

so somthing like, return input.color?

#

that was all ._.

grizzled bolt
#

You could get emission intensity even simply by multiplying the color result by any number above 1
Emission for bloom doesn't require that much, but by default the bloom threshold cuts off values below 1 or 0.9 or so

lament scarab
#

thanks

regal stag
# lament scarab oh it's like a chain?

I guess. The fragment is responsible for outputting the colours of pixels/fragments. You can do calculations in vertex shader and it's interpolated across the triangle though.
It was like you're calculating & setting a variable but not actually using it.

silent sluice
misty knoll
#

Hi, Im trying to make a "selection outline" material, I am complelety new to shaders and dont know what I'm doing tbh im getting the desired outcome kinda but I just want to know if there is a way to invert this? I want where the object is white to be transparent and where the object is transparent to be white or whatever colour.

mental lake
#

In render graph, what's a simple way of storing a TextureHandle from a previous frame's render pass?
Setting texture handles as global is the only solution I know of, but I would prefer not to create any RenderTextures asset files.

Looks like you can add textures to a frame data to be accessed by other render passes, but I assume that it's cleared by the next frame?

tacit parcel
viscid knoll
sour gale
neon gale
#

I think i have a question that is too simple, and that is why i cannot find the info. In Shader Graph, i just want to change the Color/Hue of an albedo texture, with an exposed slider/color wheel. I can change the color by multiplying while in the shader graph, but i want that color changer to be exposed in the inspector

#

NM, just found it

#

Instead of a separate Property, like a Vector or a Float to control it, you Convert the Color node itself into a Property :/

tranquil wolf
#

Then you have to plug that property into the graph itself

ember grove
#

Hi all!

I'm struggling a bit with getting my reflection to show up without the surrounding white box -- might anyone happen to have any insight as to why this may be happening?

I'm attaching screenshots of my shader, the render texture, and how it looks like in a game view.

Any help is appreciated, thank you!

mental lake
#

Is it possible for an unlit shader to sample URP reflection probes? In render graph, there doesn't seem to be a way to pass in the reflection probe atlas to a material

ember grove
regal stag
mental lake
ember grove
ember grove
regal stag
mental lake
#

In the frame debugger, I noticed that the Reflection Probe Atlas was being passed in for lit shaders only, so I was hoping that passing it in manually would fix it?

tawdry shale
#

How do you do vertex lighting on URP?

steel notch
#

If I needed to render literally millions of points, each at a specific position, what would be the go-to strategy?
Is there a way to hook into something like the VFX graph and specify the position/color of each particle?

low lichen
steel notch
#

Second question.

#

Is there any way to click a particle?

#

Or some way to know that the mouse is close to some particle in particular, and pull unformation out?

#

Like imagine I am mapping the nearest 10,000 stars.

#

I click a star particle, and then I get to see data about the star.

low lichen
# steel notch Is there any way to click a particle?

There's nothing built-in to VFX Graph that makes that easier. Since you have the star data on the CPU, you can try putting them all in a spatial tree, like an octree or k-d tree, and raycast against that. There are a few libraries on GitHub that can do that.

steel notch
#

Or at least, pushing to see what I can do.

#

Associating the visual representation with the data is the tough part here.

wooden kite
#

Can someone please help me? I currently have a outline+shadow shader on my TextMeshPro fonts, it works but when i try to change the alpha the outline colors accumulate on overlapping areas, here's a picture of it:

#

Is there anything i can do so those overlapping areas alpha doesn't accumulate when changing the alpha of my text?

#

Another picture that's easier to see this overlapping

arctic snow
#

Hey I simply wanted to create a shader material which changes the color based on uv height of my procedual generated terrain. It works on a cube, however, it's not working on my terrain correctly. Does anyone has an idea why this is happening?

dim yoke
arctic snow
dim yoke
#

Now the gradient is showing between the y positions between 0 and 1

arctic snow
karmic hatch
#

roughly (min height, max height) -> (0, 1)

dim yoke
#

Yep, the remap node could be used

#

So could inverse lerp or simple multiplication in this case

#

Remap would be the most flexible of them for the future (I think inverse lerp should work just as well though)

arctic snow
dim yoke
arctic snow
dim yoke
dim yoke
arctic snow
strong tinsel
#
#pragma kernel CSMain

struct BoidData
{
    float3 pos;
    float3 rot;
    float3 flockPos;
    float speed;
    float nearbyDis;
    float avoidDis;
    float boidsCount;
};

RWStructuredBuffer<BoidData> boidBuffer;

float deltaTime;
float3 targetPosition;
float maxSpeed;

[numthreads(8, 8, 1)]
void CSMain(uint3 id : SV_DispatchThreadID)
{
    BoidData boid = boidBuffer[id.x];
    float3 targetDir = normalize(targetPosition - boid.pos);

    if (isnan(targetDir.x) || isnan(targetDir.y) || isnan(targetDir.z))
    {
        return;
    }

    float distanceToTarget = length(targetPosition - boid.pos);
    if (distanceToTarget <= boid.nearbyDis)
    {
        return;
    }

    float3 separationDir = float3(0, 0, 0);
    int count = 0;

    for (int i = 0; i < int(boid.boidsCount); i++)
    {
        if (i != id.x)
        {
            BoidData otherBoid = boidBuffer[i];
            float distance = length(boid.pos - otherBoid.pos);
            if (distance < boid.avoidDis && distance > 0.01)  // avoid division by very small values
            {
                float3 diff = boid.pos - otherBoid.pos;
                separationDir += normalize(diff) * (1.0f / max(distance, 0.1f)); // Scale influence inversely with distance
                count++;
            }
        }
    }

    if (count > 0)
    {
        separationDir /= float(count); // Average the separation vector
    }

    float3 velocity = (targetDir + separationDir) * boid.speed * deltaTime;

    if (length(velocity) > maxSpeed)
    {
        velocity = normalize(velocity) * maxSpeed;
    }

    boid.pos += velocity;
    boidBuffer[id.x] = boid;
}

I am trying to create the boid separation logic using a compute shader but the separation vector is turning out to be zero

strong tinsel
#

using a debug buffer

kind juniper
strong tinsel
kind juniper
#

So it's the pos?

strong tinsel
#

@kind juniper basically I am trying to implement the separation behavior of boids, while following a target

kind juniper
#

Huh... It's in the shader?

strong tinsel
#

yes the same struct is present both in the shader and inside a class

kind juniper
#

I don't see you writing anything to the debug buffer in the shared code..?

strong tinsel
kind juniper
#

Can you share the whole code including the debug logic properly?

#

!code

echo moatBOT
strong tinsel
strong tinsel
#

@kind juniper

kind juniper
strong tinsel
#

zero all the vectors distance are zero

kind juniper
strong tinsel
#

yes

kind juniper
#

Okay, then it's not just the separation vector that is the issue

strong tinsel
#

but I removed the separation code , the zombies follow the target that part of the code is working, but when I re-add the separation logic then everything is 0

kind juniper
#

Which part exactly do you remove?

#

Commenting out?

strong tinsel
#

the red part and instead of velcoity just add a constant speed like 0.05 to the position vector

kind juniper
strong tinsel
#

yup i checked those one by one

kind juniper
strong tinsel
#

have not tried that

#

let me see

#

nope does not work

kind juniper
strong tinsel
#

@kind juniper ```
#pragma kernel CSMain

struct BoidData
{
float3 position;
float3 rotation;
float speed;
float stoppageDistance;
float avoidanceDistance;
float boidsCount;
};

struct DebugBoidData
{
float3 separation;
};

RWStructuredBuffer<BoidData> boidBuffer;
float deltaTime;
float3 targetPosition;

[numthreads(8, 8, 1)]
void CSMain(uint3 id : SV_DispatchThreadID)
{
BoidData boid = boidBuffer[id.x];
DebugBoidData debugBoid;
float3 targetDir = normalize(targetPosition - boid.position);

// Check if any of the components of targetDir are NaN
if (isnan(targetDir.x) || isnan(targetDir.y) || isnan(targetDir.z)) {
    // Ignore the boid if targetDir contains NaN values
    return;
}

float distanceToTarget = length(targetPosition - boid.position);
if (distanceToTarget <= boid.stoppageDistance)
{
    // Boid has reached the target, stop moving
    return;
}

// Separation among boids while following the target
float3 separation = float3(0, 0, 0);
for (uint i = 0; i < (int)boid.boidsCount; i++)
{
    if (i == id.x)
    {
        continue;
    }
    
    BoidData otherBoid = boidBuffer[i];
    float3 otherBoidDir = normalize(otherBoid.position - boid.position);
    float distanceToOtherBoid = length(otherBoid.position - boid.position);
    
    if (distanceToOtherBoid <= boid.avoidanceDistance)
    {
        separation -= otherBoidDir;
    }
}

// Add the separation to the debug buffer
debugBoid.separation = separation;
// Move the boid towards the target and apply separation
targetDir += separation;
boid.position += targetDir * boid.speed * deltaTime;
boidBuffer[id.x] = boid;

}

now the two parts the seeking is working which just follows  a target positoin, but the separation vector is 0 for some reason , nad i cant seem to find the reason
kind juniper
strong tinsel
#

@kind juniper found the reason, I was reading and writing the data properly from the shader, RW buffer for the debug has not been defind as you can see 🥲

kind juniper
strong tinsel
#

RWStructuredBuffer<BoidData> boidBuffer;
This should also be defind
RWStructuredBuffer<DebugData> debugBuffer;

kind juniper
#

But it is on that screenshot

tidal wind
#

How can i give my billboard shader a min/max size like in a particle system? I want the object to get smaller the further it is until a certain point after which it will stay the same size and vice versa with the max size

strong tinsel
strong wagon
#

Hi, i am trying to figure if i can create a shader for pixel grass 2d top down, and i am wondering how would i do that

dim yoke
strong wagon
tacit parcel
#

If its 2D, why not just drawing it manually?

strong wagon
#

It’s pixel art very large ,

strong wagon
#

It’s a tile set

#

The tile are made of pixels if that makes sense

zenith meteor
#

Hello people. A question about shader graph how can i combine two normal maps with a mask ? normal blend doesnt work

halcyon panther
#

Anyone got any resources on or now how to morph a texture into another texture and back again with hlsl? I'm trying to make the small plant texture morph into the bigger one over time. (not just fade in/out) Getting them to fade in/out of/to each other is simple enough but true morphing is a bit more difficult and I'm not sure how to do it or where to start. With a mesh it would be relatively easy I think with just displacing the vertices but I'm attempting to do it on the actual textures here instead, like an ordinary 128x128 pixel texture.

broken sinew
#

Any tips for investigating why shaders working in unity on opengl don't work on vulkan when unity is started with -force-vulkan -force-gfx-mt?

#

"don't work" as in "shit's transparent, yo"

slim skiff
#

heya, I'm trying to do a build and this compute shader throws this error, which is pretty vague:

#

the shader looks like this, just some defines...anyone have any pointers?

low lichen
slim skiff
daring wind
#

I'm on URP 2022.3.22f
Is it possible to extract surface data from what a decal is projecting on to so I can do something like height based blending?

#

I want to make some puddle decals, and it would be cool if I could have the water blend into the cracks of my floor material.

tacit parcel
daring wind
tacit parcel
#

if the decal is static, you can just capture it once

daring wind
#

And what if I have multiple puddles?

tacit parcel
#

you can capture the whole puddles using one camera with exchange of larger texture requirement, or you can only capture puddles that getting in range (became visible).
Or you capture it every frame for limited area (and layer) near the camera
There are many possibilities on how it can be done...

waxen grove
#

Could someone help me make an image project on the skybox correctly? I'm trying to make a sun for my procedural skybox shader but it doesn't seem to be working

#

Any solution Ive found doesn't seem to work the right way, like it won't follow offsets correctly and/or the scale is messed up

halcyon panther
scenic igloo
#

is it possible to change the color of a texture in unity?
in blender ive set it up to do so, how can i do the same in unity?

amber saffron
amber saffron
halcyon panther
scenic igloo
#

in my setup, the Green channel is used to change allat, but when i try to use the green channel here, it uses the whole texture and changes it to whatever color, not the mask

#

can anyone tell me how to change the color of certain masks only

amber saffron
#

Could you show a screenshot of the whole graph, and the one you had in blender so we can get a grasp of what you are doing ?

scenic igloo
#

ok

#

the ones i selected are how i change the colors: I take the green channel from masks texture, change it into my color, and then add it to the main diffuse

amber saffron
amber saffron
#

Yes ! (sorry, it was "time", not "t")

#

And match the gradient to the one you have in blender

scenic igloo
#

see it still changes the whole texture, instead of green channel

#

see this is the green channel

amber saffron
#

Because you are adding the output of the gradient to the base color, everything that is not black from the gradient node will be visible.
In blender the color ramp gradient starts with black, but in Unity it is red to white, that's why it is visible everywhere

scenic igloo
#

oh

#

so i should inverse the gradient?

amber saffron
#

Make it start with black, and end with the wanted color

scenic igloo
#

oh ok

amber saffron
#

Yes

scenic igloo
#

added to it but its still the same\

#

or should i multiply with it

amber saffron
# scenic igloo like this?

Strange, the preview clearly shows that the bottom right part stays black ...
That sample gradient node is directly connected to the add node, right ?

scenic igloo
#

yes directly

amber saffron
#

You could try to tweak the masking effect by moving the gradient keys to the right (to mask more of it)

scenic igloo
#

it just looks deep fried

#

wait

amber saffron
#

I was more suggesting to move these :

scenic igloo
#

oh

#

also btw

#

why whenever i click somewhere

#

it adds an adjustment slider

#

instead of doing nothing

amber saffron
#

That's how the gradient editor works

#

You can remove the key by "sliding them out" of the gradient

scenic igloo
#

like how

#

sliding them to their side?

amber saffron
#

More up/down

scenic igloo
#

ive got it like this

#

but there are holes

#

but if i do the inverse

#

one sec

#

there are still holes

#

which i dont want to change colors of

#

how to fix

scenic igloo
#

@amber saffron hey (sory for ping)
ive got the clothes masked out, but when i try to add red color using maths "add" it changes the whole thing

amber saffron
#

Could you maybe send your base color and mask texture so I can doodle out with nodes myself ?

#

@scenic igloo ^

scenic igloo
#

i cant send mask texutre

#

its "blocked"

amber saffron
#

Non compatible image format ? Try to zip it ?

scenic igloo
#

no

#

nvm

amber saffron
#

So, hum, isn't this what you'd want ?

scenic igloo
#

yes wow

#

oh

#

wow

#

wit

amber saffron
#

Did you maybe use the wrong texture as mask ? 😅

scenic igloo
#

yup lol

#

thank you so muych

#

wait

#

it always imports as this

#

not the transparent one

#

how did you get it like that

amber saffron
#

I just drag & dropped the mask texture in unity 🤷

#

Maybe you have bad import settings, can you show them ?

scenic igloo
amber saffron
#

It really doesn't look like the texture I have on my side :

scenic igloo
#

bruv how

#

yours is compressed

amber saffron
#

It's the same without compression

#

(doesn't change on my side if I disable)

scenic igloo
#

how

amber saffron
#

Hey, this one is named "...Met..."
Isn't it the metallic texture, and not he mask ?

scenic igloo
#

wha

#

its correct in preview

#

but not in unity

amber saffron
#

Ok, got it now, drag&drop from the browser "converted" it to bmp, if I do a right click / save as I get the same png ase you now

#

Here's the fix :

#

IDK why blender would act differently (maybe also a texture import setting on blender side, something like premultiplied alpha), but the issue here was that Unity doesn't "apply" the alpha value to the other channels when importing.

By multiplying the alpha and green channel you mask out alpha from green to match what I had previously

#

I've also changed the "sample gradient" to more lightweight nodes for better performances.
As an other benefit, you can controll the mask "sharpness" with the multiply B value, and you will be able to expose the color on the material with the color node (gradients are not exposed)

scenic igloo
#

thank you so much

#

this is amazing

#

thank you

#

one last question, do you know how to fix this?

#

its transparent and idk why

broken sinew
scenic igloo
#

checked

amber saffron
#

If enabling double sided on the shader "fixes" it, then it's backface culling, and you have inverted triangles

runic igloo
#

hey can someone explain to me why I can't edit this shader

#

Like I wan't to change the shader from standard

scenic igloo
#

in blender i enabled it

#

its fixed

slender ore
#

In shader graph, is there is a way to get local Position Y into percentage

slender ore
# dim yoke percentage of what?

height of object. For example, I have 5 mountains with different heights. I want to make it so each mountain will have a 15% painted from the top

dim yoke
slender ore
dim yoke
# slender ore Bounds refers to size?

Yes, kinda. Not the scale value you see in the inspector but rather the maximum and minimum values the object reaches on each separate axis. It's more like the actual dimensions in meters but it's good to note that if the object is rotated, the bounds may (and will actually except when the mesh is a cuboid) overextend outside of the mesh making it appear larger than it actually is (it expects the mesh to be a not rotated cuboid at (0, 0, 0) rotation)

slender ore
#

Tbh, no idea how to use it. When I feed it to the lerpT for 2 different colors i actually changes the output color??? I thought I could use positionY and some calculations but now I am confused

amber saffron
slender ore
lost socket
#

Hey, I'm not to sure where to ask this but does anyone know where to find the setting under graphics for a custom transparency sort axis for camera settings. I typed it in the search feature of unity version 2022.2.21f1 but it only pointed me towards the graphics settings. And the graphics settings are telling me >A scriptable render pipeline is in use and some settings are hidden " Should i disable the render pipeline and see if it appears?

#

I hope this won't mess w/ my renders if i do this. That's why i'm asking first.

regal stag
#

Wouldn't recommend removing the pipeline asset unless you actually intend to switch back to Built-in RP. Would require material/shader changes too.

ebon basin
#

built-in it's under graphics, but SRPs it's tied to the renderer asset

cosmic prairie
ancient karma
#

Hey all.
Having a strange issue with 2d sprite textures with a shadergraph.
I'm not sure why, but my sprites and their output have this 'smearing' where the transparent pixels should be-
I've tried connecting the alpha of the 2d sprite sampler to the fragment output with no luck in fixing it.

#

The alpha looks correct when it's just the alpha channel, but the output is still weirdly smeared, generally to the bounds Unity created on my imported sprites.

#

I've tried a handful of fixes I can find for this problem, but not having much luck.

regal stag
# ancient karma Hey all. Having a strange issue with 2d sprite textures with a shadergraph. I'm ...

Afaik the smearing in fully transparent areas is intentional. I think unity does it behind the scenes when importing textures to avoid artifacts at the alpha edge (& particularly in mipmaps). You just usually can't see it, since those areas are fully transparent - assuming you have the alpha set up correctly as you mention.

In this case (similar to an outline?), you probably want to take the Maximum of both texture A outputs for the Alpha port.
And for Base Color, take your current Subtract -> Saturate to remove the negative side -> use in T input of a Lerp, with A as the texture RGBA and B as the color property

ancient karma
#

I figured out that my issue was that I had the Material setting under 'Universal' set wrong, which was making it output the alpha when it shouldn't have.

lament scarab
#

Can anyone direct me towards a shader I can use to show range?
This is what I'm using right now, I've been looking online but haven't found anything too good.
Drawing a circle on the ground would be nice too

#

Any resource I could use (built-in)?

#

Found something decent in the meantime

warm glacier
#

I am trying to write up the Decal that will project correctly and image into the floor, On the Right is the Shader Decal, I can't figure out what wrong I am doing, Any Ideas ?

ebon moss
#

does anytone know why I cant connect these two things

dim yoke
ebon moss
#

so is there anyway I can make it possible to use a normal map?

dim yoke
ebon moss
#

ah nvm i had to change type

#

thank you

silk grotto
#

hard work

lament scarab
#

You sure it's not frozen?

silk grotto
#

No, I'm done, approximately 9 hours and 20 min, will variants be compiled, can the wait be improved or reduced?

kind juniper
scenic igloo
#

hi guys does anyone know how i can add the black part of the left side texture to the main right side texutre

#

like i want both the textures to be combined

#

so that i can use it for metallic texture

#

when i add the two textures this happens

kind juniper
scenic igloo
#

okk thank u

strong tinsel
#

Hey everyone I have a game basically 3d view but the game is 2d and only x and z plane are being used , I have a use case where if a resource ( anything ) is behind an object a tree for instance , that part of the resource would appear just a simple color with no texture, currently a shader is being used code here https://pastebin.com/kTGFxvQk , so how can i achieve this
here is the view

zenith meteor
#

hey people how can i blend two normal with alpha mask?

regal stag
zenith meteor
#

@regal stag normal blend doesnt have a mask it has two entry points for two maps to blend. Lerp can work imma use it see what is up

cursive spade
#

Hey everyone, does anyone here know how to enable the heat map in shader graph?

regal stag
slender ore
#

Any clue why there is this difference between a png I have and texture I get in the shader graph?

regal stag
slender ore
vague imp
slender ore
#

Yeah, that was the issue. Didn't think that disabled layers would go through when exporting

brazen nimbus
# strong tinsel Hey everyone I have a game basically 3d view but the game is 2d and only x and ...

https://www.youtube.com/watch?v=GAh225QNpm0 Is this what you're looking to achieve ?

In this Unity game development tutorial we're going to look at how we can use URP Renderer Features to create a silhouette of a character when they're hidden by an obstacle.

We'll start looking at how to remove the rendering of the character completely by assigning it to a layer and removing this layer from the renderer.

Then we'll add two ren...

▶ Play video
#

Btw, does anyone know what would be a great set up for distorted radial UVs ? I currently have this but it doesnt work as the center gets offset if I'm increasing my float Power 🤔

regal stag
brazen nimbus
regal stag
#

I didn't mean to change the Center port, leave that at (0.5, 0.5)

brazen nimbus
fair jackal
#

so the time node is the only way to have an incremental value in shaders right? However, I have an issue where if I'm using time to modify something(like a UV offset), if I modify the time value to be something like slower or faster it makes the offset jump rather than change relatively. Is there any way around this?

regal stag
fair jackal
#

if I'm using a material variant that means I only have to apply it to the parent material right?

regal stag
fair jackal
#

alright thanks, I'll give it a go!

regal stag
#

If it's something that you need across multiple materials/shaders there are global properties too though. Set through static methods in the Shader class.
In shadergraph you untick the Exposed option under the property to read the global ones.

fair jackal
#

yeah I'm currently using that for my wind properties

silk grotto
dull magnet
#

Hi, I want to be able to create cool visuals like what you see on shadertoy.com

I know programming and high school math. Im not good at computer graphics or linear algbera or physics.

Are there any tools that would help me create shaders easily without understanding the math really well?

#

I think something that would be cool, is if I could travel the frames one by one and for a very small res like 100x100, be able to see a value for each pixel that determines its color. Like the value for a function inside the shader

dawn cave
#

Hi did unity removed the shader graphs from Textmeshpro shaders? I can only see shader files.

regal stag
dawn cave
regal stag
dawn cave
#

oh, i see thanks

lament scarab
#

how would you guys go about having a sky box within a stencil "window" thats different than the one from the scene?

lament scarab
#

also there are things between the stencil and the farclippingplane (or whatever it's called) so it can't be used inside the stencil (afaik)

storm gorge
#

Using a stencil shader, is it possible to cull pixels ONLY where the cube and sphere intersect? Or should I find another solution

kind juniper
strong tinsel
meager pelican
# storm gorge Using a stencil shader, is it possible to cull pixels ONLY where the cube and sp...

Another solution. I think. Depending on your definition of "intersect". I mean, what you're showing is where the two intersect, you've discarded pixels. But I think you want to cut out the sphere where the shell of the sphere intersects with the cube, so you'd see a square-ish shape cut out of the sphere, not a cube silhouette.
Stencils will operate on a per-pixel basis for the shaders, but it won't be as programmable as you're looking for. As you've discovered. Stencil operations are settable, but not programmable.
You can probably do what you wish to do mathematically. I mean, look up an intersection test for a cube. And the intersection of the sphere is easy too, since it's a distance-to-center calc. You'd need a data buffer for the objects that you want to intersect, unless it's so special case that you can just directly pass the cube and sphere locations/sizes into the shader.

tacit parcel
#

Yeah, stencil only works on screenspace, not in 3D space...
That's my first mistake on understanding how stencil works

harsh spindle
#

wait dyk how to enable hsls intellesnse for visual studio?

storm gorge
kind juniper
harsh spindle
#

so i just p much gotta suck it up and code

kind juniper
#

Pretty much yeah.

harsh spindle
#

rip

#

thanks tho

kind juniper
#

Shader coding sucks. That's the reality.

harsh spindle
#

😭

kind juniper
#

I guess real shader programmers just accept that as reality and look down on anyone crying about lack of intellisense

viscid roost
#

I wrote a ShaderGraph to make a blur effect on a 2D sprite by resampling it a few times and offsetting the sample down the y-axis. But for some reason it's moving them around the sprite as if it was a sphere, effectively cutting off the resamples in-game before they've moved very far. It's probably something dumb I should know by now but does anyone know what I would do to get the offsetting to just go down the y-axis, and not around like a sphere?

#

This video demonstrates how it looks in game. And you can see on the bottom right how the sprite has been spherized

harsh spindle
#

but i get a pink plane for some reason

#

and no triangle

kind juniper
#

Do you get any errors during the shader compilation?

harsh spindle
#

i dont think so?

#

it doesnt show any errors

#

wait does this mean something

tacit parcel
#

seems like you've misplaced your vert function, it has to be inside cgprogram block

harsh spindle
#

wait i thought it was inside it

#

oh wait

harsh spindle
#

i put it in there and its still pink

tacit parcel
# harsh spindle

select your shader and see in the inspector if there's still any error

harsh spindle
tacit parcel
#

🤔 I copased your shader and it works out of the box

#

so it seems like your gpu doesnt support your shader

harsh spindle
#

huh 😭

#

is there no way to fix that

#

coz its a rtx 1060

tacit parcel
#

are you sure its rtx? I'm not gpu savvy but iirc rtx starts at 2060

harsh spindle
#

waiut

#

i meant 1660

tacit parcel
#

thats getting weirder since I'm on 1650 and 1660 technically should be able to do everything 1650 can
Are you using dual graphic card? Maybe unity run on integrated card

harsh spindle
tacit parcel
#

try to build and run the game, and see if the shader shows properly, if it does, maybe the problem is unity doesnt run properly on your gpu

tacit parcel
#

No, I mean build to standalone app/game and run the built app

harsh spindle
#

wait how do i do that

#

oh wait

#

it doesnt run

#

when i click build and run

harsh spindle
tacit parcel
#

it has nothing to do with urp, just hit Yes

harsh spindle
#

yeah i did

#

it does nothing

#

i got an error saying "cannot build when importing assets or scripts"

tacit parcel
#

I think that's not related to shader anymore, you can ask try to ask the question in #💻┃unity-talk

grizzled bolt
cedar jackal
#

this is probably a very simple question but im relatively new, especially to shaders
i made a shader network following a brackeys tutorial from 4 years ago, and apart from 1 little thing at the start there was no issue, i just had to download a package to get the right type of shader graph

after following the tutorial i got to the end and the shader previews fine in the shader network tab, but in the game scene its very slow and jenky, weird thing is it forces an update any time i do something in unity, so if i autoclick a dropdown menu it runs at a smooth 30fps or whatever my autoclicker is
does anyone know why this is happening or how to fix it
NOTE: i already looked up the issue and it said to make sure the "exposed" box is ticked for the color node cos that can sometimes cause the issue, but mine was already ticked, so thats not the issue
audio warning, bad audio on the video, mute
edit, i can get more screenshots of the shader network if you need to see close up, its no hassle
the rules say to include what render pipeline im using but i have no idea, as i said im new, so prolly whatever the default is

karmic hatch
#

when you actually press to run the game it should run as normal regardless

cedar jackal
#

okok thank you so much

runic minnow
#

Whenever i apply a shadergraph shader to a UI element it's transparent colour (alpha 0) turns into this weird red, any ideas why? The shader works perfectly fine with other ingame objects

coarse pilot
#

I'm trying to make a shader for the eyes which use 2 layers of texture but the eyes are self-illuminated 😬
I'm new to Shader Graph so I'm not even sure what I'm doing 😅

runic minnow
coarse pilot
runic minnow
#

This seems like your one is unlit, as in, it doesnt interract with lighting

runic minnow
#

Try changing it to lit

coarse pilot
#

Oh.. I was guessing was the contrary indeed 😅
Now I learn something more, thank you 🍻

runic minnow
#

NP

#

It does sound kinda counterintuitive tbh, but it does make sense

regal stag
runic minnow
#

Oh awesome, thanks for the tip

coarse pilot
#

to RFTM prolly would help a lot 😁

fair jackal
#

when doing custom lighting is it possible for the shading/selfshadows to be affected by the shadow strength?

#

it's a bit weird having really soft shadows but objects with pitch black shading

grizzled bolt
#

"Shadow strength" is a variable that interpolates the shadow/shade color to the light color itself, as if the shadow was partially not there at all
It's not realistic at all but useful in some situations

fair jackal
grizzled bolt
regal stag
#

Should be able to use the Baked GI node to handle that - even if the object isn't actually lightmapped / using GI, that node will also sample the ambient probe

fair jackal
#

hmm I'll have to take a look thanks

drifting thistle
#

hello, i have a problem with the toon shader not working with other lights other than the directional any ideas how to fix ?

#

i get the issue here how do i make my flashlight the main light ?

regal stag
upper wyvern
#

any easy way to ad a line to this red line I painted in to this yellow circle?

#

doesn't have to look like that I just want it to be the circle's radius and then I can rotate it to the players direction via code

polar mason
#

https://youtu.be/yE6wXG3UTIE?si=AnqN4MnOyyTSJk_I

Town in a cubicle using original shader, outside is custom lightning shader to get 2 different lighting environment in one scene.

Developing for Apple Vision Pro.
Real life fantasy world in your dining table.

A miniature fantasy world on a tabletop. Players take on the role of a deity, manipulating time and weather while observing NPCs living within this spatially projected cubicle. It's an immersive experience blending AR technology with god-game mechanics.

▶ Play video
harsh spindle
#

I think im having trouble with my shader graph for grasses

#

whenever i add the grass material

#

my game gets really laggy and my gpu memory usaage slowly increases over time

#

so i think i have a memory leak

#

but idk how ot fix it

#

heres the shader code

idle viper
#

Is there any way to get the local transform position in a sprite shader?

#

I know you can get the world position using the unity_ObjectToWorld matrix

#

But i specifically need the local pos

sour gale
upper wyvern
#

Yes. I'm pretty good with photoshop. I could make the image I want very very easily. I just know that I made the circle itself using shaders. Are you telling me this whole time I could have just made a transparent image and stuck it under there lmao

ripe imp
#

yuuup, and probably should. Leave shaders for specific effects you need to be/want to be dynamically applied, think some VFX outside particles, outline, water etc. Or if you think it's easier to dynamically render something based off some conditions rather than create all possible ways it could look. Not sure if I explained it neatly enough but you hopefully get the point

#

altough people often push boundaries on what they make using shaders and sample textures, it does take some time to use efficiently

meager pelican
upper wyvern
#

-5 hours unlucky lol

#

thanks though

sour gale
#

its good for practice

upper wyvern
#

followed the same vid 5x just to realize that it works if i dont make the color blue lol

sour gale
#

thats sad

upper wyvern
#

yup

#

im 5 days in on unity tho and i almost have a full game ready to go

#

just level design/ui/polish left really

#

obviously downplaying how much is left

#

but i have everything in my prefabs for a fully built experience

#

feeling pretty good

sour gale
#

day 5 and you're learning shader graph? nice

upper wyvern
#

uhhhhh moreso just copying videos yeah

#

but learned a bit yes

sour gale
#

I teach unity at university and I only teched the shaders after a few months of basics

upper wyvern
#

I've made this game in gamemaker twice

#

so converting it to 3d and unity both for the first time is weird but it's been pretty smooth

#

it's kinda annoying to say this but it's true. Last time I installed unity I quit 30s in to the first tutorial. This time chat gpt was a massssssive difference.

#

i would just tell it to code me something and then figure out why it works

#

kinda annoying but it's the truth of it

craggy dragon
#

Does anyone know of a water shader that could interact with a boat to cause wake or foaming as it moves through it?

upper wyvern
#

I would have thought using it as a tool would allow me to 'cheat' instead of learn but it's actually been wayy more helpful than not.

sour gale
#

it's really good for learning if you use it right actually

upper wyvern
#

yeah I was shocked

#

prefabs and parameters are kinda crazy strong too

#

might be the wrong place to ask but do you know the best way for me to add rocks to my game? like big boulders? They don't need to have a ton of variety. they're just going to stand in the way and if the player runs into them they die. simple for now

sour gale
# craggy dragon Does anyone know of a water shader that could interact with a boat to cause wake...

In this video, you will learn how to create a water surface ripple effect. This effect can be combined with the water surface shader we made previously to make the water look more realistic.

Links :
神奇的小阿飞 : https://space.bilibili.com/31839293/
GitHub : https://github.com/Parrot222/Unity-Water-Shaders
Previous Video : https://youtu.be/xJk8MKQDq...

▶ Play video
craggy dragon
sour gale
upper wyvern
#

Wasn't sure if there was a tool for it or I just need to find some models and import

#

right now my dilemma is trying to brighten my ice up but aside from bringing my occlusion all the way down I'm not seeing an answer.

craggy dragon
# sour gale what do you mean by the best way? what is the problem with adding rocks

Okay I watched it, I have a few questions/concerns, I'm not the best when it comes to shader graph but this one looks straight forward but I want implement this effect to a realistic water, the videos says you can combine this ripple effect with their other realistic water shader, I'm just not sure how they do it since they don't say how

sour gale
craggy dragon
sour gale
#

just do everything else but with other water shader graph and use that instead for the material

craggy dragon
sour gale
#

after you make the water right, watch the ripple effect

#

instead of creating new shader, add the thing in the ripple effect to the water shader that you made previously

craggy dragon
#

@sour gale I do a have a quick question I just thought of, once I'm done with it and have it the way I want it, how would I go about exporting it to another project?

sour gale
craggy dragon
#

Everything, Including any textures I have set with it

#

Kinda like other shader packages I have seen before, you know

sour gale
#

there you can select everything you wanna export

#

it saves it as a file. you can click and drag the file to the other project or right click to the project window and select "Import package"

craggy dragon
#

Oh alright, that's a lot easier than I thought, thank you!

young rampart
#

is there a way to enable shader debugging in shader graph?

mental bone
night steppe
#

Any idea why this code produces really dark and contrasted pictures? Left is the output file, right is the render texture

var prev = RenderTexture.active;
RenderTexture.active = _camera.targetTexture;

var dimensions = new Vector2Int(_camera.targetTexture.width, _camera.targetTexture.height);
var texture = new Texture2D(dimensions.x, dimensions.y);
texture.ReadPixels(new Rect(Vector2.zero, dimensions), 0, 0);
texture.Apply();
        
RenderTexture.active = prev;

var bytes = texture.EncodeToPNG();
var path = Path.Combine(Application.persistentDataPath, $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.png");
await File.WriteAllBytesAsync(path, bytes);
wide wren
#

How can I add this on my basecolor?

civic lantern
#

It won't look exactly like in the inspector of that standard shader though

karmic hatch
drifting thistle
#

about the lightning fix

#

i want the toon shader interact with my spot light not with my main directional lighting

ruby sonnet
#

how to get TexelSize from a Texture2D

regal stag
regal stag
grave hornet
#

Hi! Shader graph beginner here, I have a question. Why is my output only taking in the bottom texture? Isn't "Add" supposed to literally add two values together, like if white (or blue-ish white in my case) is 1, then it should go 1 + X.... which should never reach 0 (black), the output I'm getting on the edges, right?

sour gale
karmic hatch
grave hornet
#

tyty

grave hornet
sour gale
#

voronoi and step?

grave hornet
#

just a simple voronoi node with lerp

#

and animated it with a time node

#

but tbh I'm just experimenting and seeing what works haha

sour gale
#

that's cool

grave hornet
#

it's probably possible without two lerp nodes, but this works so I left it

sour gale
grave hornet
sour gale
#

chagning step in value changes dots scale

grave hornet
#

now it's like stars flickering lol

#

sweet

sour gale
mortal viper
#

hello, I am trying to create an outline/rim shader on a quad but Im not sure what's going wrong. I have used ones that work on 3D meshes but none for quads.

sour gale
#

for 2D?

pine beacon
#

Is there a way to make this the shadow and the edge of the table look smoother? It looks a bit wonky right now

mortal viper
#

I am generating a mesh that it's flat is what Im saying

regal stag
mortal viper
regal stag
#

Well still, if you want "outlines" you need to generate the mesh with appropriate UVs or vertex colours to tell the shader where the outer parts are

#

It's not something you can really do in the shader itself

mortal viper
#

yeah that's what Im trying as well

#
            {
                vertices.Add( cellCorners[ i ] );
                vertexColors.Add( i == 0 || i == 3 ? new Color( 1, 0, 0, 1 ) : new Color( 1, 1, 1, 1 ) );

                // Assign the UVs corresponding to each vertex
                uvs.Add( new Vector2( i % 2, i / 2 ) );
            }```
#

but Im not sure what Im doing wrong 😭

#
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                o.color = v.color;
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                // Check if the vertex color is at full intensity, meaning it's an edge
                float edgeIntensity = i.color.r;
                fixed4 color = lerp(_FillColor, _EdgeColor, saturate(edgeIntensity - (1 - _OutlineWidth)));
                color.a = lerp(_FillColor.a, 1, saturate(edgeIntensity - (1 - _OutlineWidth))); // Adjust alpha for fill and edge
                return color;
            }```
#

basically this

regal stag
#

If you're using color.r to determine the outline I'd expect the C# code to set the vertex colors red to 0 or 1. Both seem to be using 1 in the ternary though (new Color( 1, ... ) : new Color( 1, ... ))

mortal viper
#

hmm you're right but it still doesnt work

regal stag
#

Well yeah, it seems you're just setting the corners of each tile. You'd need to detect which tiles are actually at the edges of the mesh and use that to set the vertex color, not just i == 0 || i ==3

#

May be able to ask in a coding channel if you need help with that, it's somewhat outside the area of shaders

regal stag
# mortal viper

Also since this one (and yours) seems to follow more of a grid stucture, it could also be based on a tilemap texture (probably similar to "wang tiles" or the "blob tileset"). For each quad you could calculate UV coords to select which tile of the texture should used, by comparing neighbouring tiles. Again more of a coding thing.

mortal viper
#

but Im not that good with shaders to set it up. Calculating edges can be C# but setting the uvs properly to show the part of the texture is harder for me 🙂

#

maybe Im better off just doing a line renderer 😭

broken sinew
#

In terms of cycles, how fast is matrix multiplication?

#

on GPU

#

The thing is currently in my shader I have a function I am calling in a loop, and each invocation calculates some point p * matrix

#

to be more precise I sometimes have a dozen or so function like that, each doing a matrix multiplication

#

so for example 20 matrix muls per iteration per pixel, max iterations cap around 200

broken sinew
#

probably also depends on the type of GPU, nvidia with tensor cores can do m4x4*m4x4 in 1 cycle iirc

kindred forge
#

The above shows the situation.

We are using UV Projection onto 3D objects, so 2D Isometric Sprites behave like 3d objects.

Lighting is Good!

EXCEPT...

...when lit from behind.

#

What I'd like is a shader that can add a directional rimlight, like this example here.

#

Our shader knowledge is however lacking, being a team of artists and 3 engineers. The help of a Tech Artist is on our near term hiring wishlist, but in the meantime a quick solution would be helpful, if anyone knows one to exist for this problem.

lone crow
#

How do you get the scene depth node like functionality in lit shaders
Trying to recreate the water shader but not using shadergraphs

regal stag
lone crow
regal stag
#

Should do

regal stag
lone crow
#

Ahh Thanks, I will try this out

sour gale
#

is there a better way to add outline to low poly models? I tried 2 type of outlines

#

usualy the best one for me was offsetting the normals

#

left one has empty lines between each face because it's low poly

#

right one looks okay with this one but because it's based on scaling, it looks bad when the pivot point is not on center or the object doesn't have a circular shape

halcyon briar
#

Hi. I want to fade my enemy after death. I am using a Toon shader and try to use SetFloat on the material. Why is material.SetInt("_TransparentEnabled", 1); not working but when I open the dropdown of the material in the shader then it suddenly works. What could be the problem?

regal stag
regal stag
halcyon briar
dim yoke
#

@sour gale two other solutions I would consider are to (in terms of performance what Cyan suggested might be the best):

  1. use two different meshes to begin with (one for the outline, one for the object itself. this would be the easiest solution I'd guess)
  2. use only the smooth shaded mesh and reconstruct the flat shading in the fragment shader of the main material (possible with partial derivatives. there may be few artifacts of using that approach though)
regal stag
# halcyon briar Ah, I thought about that too. So maybe I should output all the parameter values ...

Maybe. But it could be easier to just have a separate transparent material set up and swap it (i.e. renderer.sharedMaterial = transparentMat;) rather than trying to set keywords, renderQueue etc.
And can still generate an instance of that transparentMat if required, using new Material(transparentMat);. Ideally cache it and destroy later when no longer needed. Or use some kind of material pooling to reuse them between enemies.

sour gale
#

Thank you both

halcyon briar
regal stag
#

It's likely changing some blend properties and renderQueue to 3000. Possibly more though.

last latch
#

Is there any shader setup that colors based on intersection with gameobjects?

#

Looking to create an emissive glow around the edges that connect into that plane, so I can move it up and down and tthe shader will do an emission base on the intersection

last latch
#

Yes yes

#

Like so

sour gale
#

this is the interaction part

last latch
#

Thank you I appreciate it

sour gale
last latch
#

I am

sour gale
last latch
# sour gale

🤔 When applying that to a material nothing seems to happen, I have offset, multi, and color. But nothing exactly happens at the edges / intersections

sour gale
#

try with this values

last latch
#

Just acts as a solid color

sour gale
#

make it transparent

last latch
#

Ahh gotcha there we go

#

Wonderful

grand jolt
#

I'm using toon shader by unity technologies, and i wanna make an object to change a color through a script.. is that possible with toon shader?

night steppe
night steppe
#

How do I get my world canvas to react to lighting? I'm using URP

rare wren
night steppe
rare wren
#

Thats it is bright in 1 spot?

#

Unity up to date? In case it's a known issue.
Maybe try the simple lit shader?
Worst case use quads to do the backgrounds?

#

Didn't Unity 2022 have UI shader graphs?

tacit parcel
muted depot
#

is it possible to get size of uniform array from shader or do I have to hardcode size in both shader and code that uses shader?

#

I tried material.GetFloatArray(propertyId) but it returns null

#

or alternatively setting it for shader but that doesn't seem to be an option since size should be compile time constant

ruby sonnet
#

how to get access to CBUFFERs (UnityPerDraw for example) in shaderlab

muted depot
#

you mean this?

CBUFFER_START(UnityPerMaterial)
  float4 property;
CBUFFER_END
#

just put that in hlsl code in shaderlab