#archived-shaders

1 messages · Page 87 of 1

fast shore
#

Neither does it involve passing an adjacency texture

#

Which makes the matters even more enigmatic

frigid jay
#

There is no difference between one sample of 4x4 and 4Kx4K texture. But for pixel shader that covers multiple pixels there is a difference, because in case of 4x4 texture each pixel shader invocation (each pixel) will read almost the same memory location (4x4 pixel texture easily fits in texture sample cache). In case 4K texture there is a lot more memory to read and will be slower in general.

chilly robin
#

I was mostly confused on the sampling process as I was unsure if a 4k texture would be more expensive to sample over a smaller texture. Memory differences aside of course.

karmic hatch
#

Is there a way to get the main camera's up vector in shader graph?

#

Actually I can just convert Vector3(0,1,0) from view space to world space right?

regal stag
#

I think it's the second column... so UNITY_MATRIX_I_V._m01_m11_m21?

snow forge
#

Hi all, I'm having a bit of a brain fart moment (for a change :-P)

I'm building up a shader graph.......

I'm trying to 'overlay' the orange colour by using the noise as a mask, but for the life of me I can't remember how to get it so that the black doesn't affect the underlying texture.

Could anyone point me in the right direction please?

#

Result

#

What the 'rock' should look like.

regal stag
snow forge
royal bloom
#

@dim yoke

#

i got this

#

my lighting is buggin tho

#

when i blend it

#

also thats now how a skybox should work lmao

dim yoke
# royal bloom

Looks really cool to me. You could obviously add other siybox textures in it but if you only need to blend between two skyboxes at any given time, I’d just change the textures in a C# script to support more skyboxes. When it comes to the clouds, maybe the easiest solution would be to add completely separate mesh on top of everything else and add the clouds there so you wouldn’t need to add those to the same skybox shader

dim yoke
royal bloom
#

it works now

dim yoke
#

Cool

royal bloom
#

idk why but i feel like my game is laggin more

#

can you take a look at it

dim yoke
# royal bloom

That shader you linked is so cheap it definitely won’t make a difference. I think the laggy feeling might be due to the same effect you showed here which has something to do with the envirnoment reflection probe and how it updates to keep it up to date with the skybox. I don’t really know how that goes so I’m not able to help you more on that regard. It will likely depend on the render pipeline in use too. People on #archived-lighting might know more about that

royal bloom
#

alright

#

i had enviroment lighting source on skybox

#

so the color of the skybox was updating color of shadows

#

alright looks good to me for now

#

i'll try to figure something out with clouds

#

and find actual good skyboxes

dim yoke
# royal bloom so the color of the skybox was updating color of shadows

If you dont, the skybox doesn’t change the shadows so it wouldn’t get dark enough at nights for example. You could maybe use gradient for example and lerp between different gradient profiles according to the skybox in C# but haven’t done that myself. There might be some way to update the environment probe fast enough but I’m not aware of that

cerulean nexus
#

i am truly at a loss on what to do... i have no idea whats causing my builds to take so long and this happens on every one of my projects

#

its always my shaders that take tons of time to compute and ive tried creating an asset variant but that didnt help at all

tacit parcel
cerulean nexus
cerulean nexus
#

and i cant see what shaders are used during runtime because i cant even get a build to start running

tacit parcel
#

Well... I think it's the price of being 'Universal' 😅

stiff epoch
#

Hello I had a question, I don't use shaders but I know VERY light knowledge and I've made a couple, can someone please help me or guide me on how to make a triplaner TERRAIN shader for URP? (I've been looking for this FOREVER)

kind juniper
kind juniper
stiff epoch
cerulean nexus
kind juniper
cerulean nexus
kind juniper
kind juniper
stiff epoch
cerulean nexus
kind juniper
uncut gyro
#

Hey, I have a 2D top down game on a grid based system. It is divided into chunks of 32x32 tiles.
Depending on the chunks type (pure, impure), if it is "impure" I want to render a basic, half transparent texture on which I later want to apply a shader. If it is "pure" then just make it transparent.
I was wondering how to do this optimally? Cuz my map is really huge and I'm not sure if making a huge texture and applying some shader on it wont be laggy

tacit parcel
brazen nimbus
#

Hey ! Its me again ! I asked yesterday about how to use lightmaps infos in the shader and it works pretty nice (thanks again eheh) !
Now I'm wondering if there's a way in shader graph to modify the lightmap ? I could do that through code but I wanted to have the option to do a transition (could be a simple fade or a complex distorted weirdo transition, who knows !) through SG as it's easier for me ngl. If it's not possible, is there a way to combine some simple HLSL code to have a custom node that act kinda like a lerp but that actually can update the lightmap ?
Would be awesome if someone has infos about that ! Thanks in advance as always ! 🌺

warm moss
civic lantern
# stiff epoch Hello I had a question, I don't use shaders but I know VERY light knowledge and ...

I tried that for HDRP a couple of years ago, I was only able to get the first splatmap to work. So I had only 3 or 4 terrain layers to work with. Later realized that it should probably use multiple passes, one for each splatmap. But yeah this seems hard to find info about, you'd probably need to be pretty decent at shaders, and also examine the existing terrain shader and its material properties.
I ended up just rolling out my own terrain system completely...

#

If you dont need terrain layers then you can use any regular or custom shader

stiff epoch
#

Got it to work with all 4 layers too 👍

civic lantern
#

So your question is just about how to make it triplanar?

stiff epoch
#

Well i know how to do that in shader graph but not traditional code shaders

civic lantern
stiff epoch
#

Do terrains have more than 4 layers?

#

If so than that is news to me...

civic lantern
#

Might depend on the render pipeline

stiff epoch
#

Yeah I looked it up and hdrp has 8 while the rest have 4

stiff epoch
#

Yeah while searching I found that website, because of my very limited knowledge on shaders I dont know how to apply this to a terrain shader

#

I just dont know the code language

civic lantern
#

So you are not asking how to make a triplanar shader, but how to learn HLSL instead

#

Worth pointing out, that tutorial has some fluff in it since it predates URP. Section 1.5 onwards should be what you need for triplanar

stiff epoch
#

As stated earlier

civic lantern
civic lantern
#

Glad you figured it out

keen ore
#

Is there any reason why this seam is appearing? what you are seeing is the material attached to an image that's stretched across the screen, with 1 camera in the scene that's rendering with a solid color background

regal stag
keen ore
#

It only changed at all because I accidentally left an unwanted pp Volume in the scene, which I deleted

keen ore
# keen ore

I seriously can't imagine why this would be happening. I even implemented my own distance function to replace the distance node here, but I suspect that the problem is with the screen position node?

#

from what I see, when screen.x > screen.y, the distance being returned is decreased by some factor

regal stag
#

Oh a UI image? Should be able to remove that now

#

You use that feature to apply the fullscreen graph. It's not suitable for UI

severe edge
#

can someone help me get the textures back? I went into rendering > pipeline converter and converted it, and now I get pink everywhere, any way to fix this?

civic lantern
#

It cant auto convert custom shaders. You likely need to remake them

severe edge
fast shore
#

Is there still no way to pass in float/vector arrays into shader graph?

regal stag
fast shore
#

I'm wondering whether it's easier to just squash it in a texture2d

#

Any quick insights as to how expensive it is to make a roughly 128x128 texture and pass it as opposing to just passing a bunch of 2D vectors directly into a shader?

regal stag
#

No idea really, might need to try both and profile if performance is a concern

snow depot
#

Can I make light exposure affect the color/alpha of an object? So like on areas that are brightly lit its color in those areas is set to white but on areas without light it becomes black.

#

Like this

idle ivy
#

Hello,

how can i make this scrolling effect with shader?
I want to do it with shader in terms of optimization, but I couldnt find an idea how to do it because there is Text and Font.

flint yew
#

for example

west fulcrum
#

Can anyone give me some hints for shader graph on how to make it so that i can adjust the speed, and then the offset of a Tiling and Offset node scrolls slower or faster, but without jerking or going backwards?

I'm trying to make a simple rain effect in a full screen shader, where i can control the speed of the drops falling down.

So for this the rain drops animate by scrolling the Y offset in the Tiling and Offset node. It works with just multiplying time and a speed parameter.
But the problem comes when increasing or decreasing speed. This makes if stutter up/down and/or play it backwards.

I tried sending a custom time, like suggested in some threads, and also lerping the strength (which is 0-1 that will control the size, speed etc) like this:
strength = Mathf.Lerp(strength, strengthTarget, Time.deltaTime * lerpSpeed);

But even if i do that, it animates weirdly, and the rain goes backwards as the strengthTarget goes down. And kinda fast forwards as the target goes up.

Any idea how i should set this up?

regal stag
west fulcrum
regal stag
#

Then yeah you'd use that CustomTime straight as the offset, without adding to the original time and no Speed property since that's controlled from c#

fast shore
#

Shaders are so annoying, seemingly simple things are either pretty hard or impossible to achieve because of how gpus work 😒

#

I'm guessing I'll be feeling a lot of this as I continue to get into shader programming

dim yoke
fast shore
#

Seemingly simple things turned out to be really complicated and you needed to shift the way you think about achieving stuff in order for it to work

dim yoke
#

That is the reality of extreme parallelism. Luckily there's quite much resources available for everyting shader related

fast shore
#

The worst thing about parallelism is that it's pretty common for stuff needing to know about other stuff, which is pretty common in games down to the visuals level

#

"I need the mesh to be emissive..." Ok, fairly simple
"...but brighter when near vertices" Literally no idea

dim yoke
fast shore
#

I'm currently in a process of doing some seriously unholy things

fast shore
#

Can you do bitwise (left right shifting) in shaders?
Yes you can I found it

royal bloom
#

im still stuck on my arm problem

#

i need to make a shader in which i have two floats

#

start - how far up the arm from hand the fade starts
end - how far up the arm from hand the fade ends

#

can someone help me make this?

#

i also want to be able to choose a color

#

of the arms

rare wren
#

Calculate the distance between the position node (world space) and the camera and then use that to lerp colors, right?@royal bloom

What did you try and where are ya stuck

fast shore
#

I'm going insane. Why doesn't my property work in the ease function here? Is there a precision mismatch? Something with the references?

#

If I manually supply 5.0, it works as expected. If I pass the literal same value of 5.0 through inspector via a property it doesn't. Crazy stuff

#

And it's not an isolated problem, it's tied to the ScreenBlend function somehow

#

If I use both it just stops working with a property

#

Is it something caused by loop unrolling?

#

No, I just tried

                float result = ease(sides[0]);
                result = ScreenBlend(result, ease(sides[1]));
                result = ScreenBlend(result, ease(sides[2]));
                result = ScreenBlend(result, ease(sides[3]));
                result = ScreenBlend(result, ease(sides[4]));
                result = ScreenBlend(result, ease(sides[5]));
                result = ScreenBlend(result, ease(sides[6]));
                result = ScreenBlend(result, ease(sides[7]));
                
                return result;

To the same result

#

Ok something really weird is going on with contsnats in hlsl

#

Or I suspect arrays

lilac mist
#

In shader graph, can I somehow detect the edge of a masked sprite?

That is, the point where the sprite and the mask intersects

#

For example, sprite outlines shaders don't look right when the sprite is partially hidden by a mask

royal bloom
#

someone suggested this

#

and i tried it

#

but didnt know how to make the shader

fast shore
#

Somebody please explain

lilac mist
#

Explain what part

fast shore
#

Isn't one minus supposed to invert colors?

lilac mist
#

it does

fast shore
#

Is there some other inversion method that produces what's on the right picture and not the middle?

#

Because I have no idea why I'm getting the middle one

#

UVs are correct (default unity plane)

lilac mist
#

I mean it should... It could be a display thing?

#

like the preview isn't displaying it the way you expect

fast shore
#

That's just pixels tho

#

No idea what can cause this

regal stag
fast shore
#

So I can achieve the right one with quadratic falloff?

#

I think it's quadratic

#

Or is there an automatic switch for that somewhere

regal stag
#

There are functions to convert between them. I think UnityCG.cginc has LinearToGammaSpace(v) and GammaToLinearSpace(v)

#

or Colorspace Conversion node if working in graphs

fast shore
#

GammaToLinearSpaceExact seems to do something

#

Not super accurate and still looks off if you look close enough, but it's something

lilac mist
#

Hmm, there's no "distance to sprite edge" node or anything like that, is there

#

Imagine you have a sprite with alpha like this

#

and you want to apply an effect to this area

hushed silo
#

so, I have a minimap which is an orthagonal camera, passing it's position, 1/orthographicSize, and rotation in radians into a shadergraph.

I am trying to overlay a grid texture to it, and edit it's UVs so that they actually scroll with the camera/rendertexture. I've tried how I thought it should work, and it didnt... then how chatgpt said, which was similar, and didn't, then tried ot get gpt to write a custom hlsl function, which also is not.... What is happening at the moment is that the speed of translation of the grid texture is not in sync with the camera scale, it's moving very fast. secondly, rotation seems to start rotating, then slows down and reverses. I've checked the input values and they are all good. Here's what I have:

lilac mist
regal stag
lilac mist
#

I guess the easiest way is to just make it myself

#

But what if that area changes like if I want it to pulse

hushed silo
#

make a gradient that stretches off and animate a subtract float on it or something?

lilac mist
#

like if it was one central object I could pulse it, but because I have two objects the only way I could pulse the gradient would be knowing the distance to the edge

regal stag
#

You'd want to precalculate the distances (commonly referred to as "signed distance field") and store that in a texture passed into the shader

lilac mist
#

If I had access to a blur node or something similar then I could increase or decrease the blur intensity to pulse it

regal stag
lilac mist
#

the manually made one, I mean

#

if crude compared to an actually calculated one

regal stag
#

To make it pulse you can remap the distance from that texture. Probably using sin(_Time.y)

lilac mist
#

That's true, it was just a crude manual photoshop thing to show like, the concept

#

Yeah

#

Hmm, so if I have a gradient as source data and I want to use that gradient to create a pulse that starts on the bright area and moves towards the darker area

#

I use a sine wave, but I'm not sure how to attach it to the gradient

regal stag
#

Probably something like sin(_Time.y * speed + gradient * freq) * amplitude if you want lines to move along the gradient and * gradient again so it fades as it gets further away

#

In graph is similar to this

lilac mist
#

For simplicity I'll start with just a normal gradient and try to pulse across it

fast shore
#

I keep hitting the weirdest issues. Does this also have something to do with linear/gamma thing?

lilac mist
#

No in this case you have been cursed

#

actually what is probably happening is that your "Base" is not just black but darker than black

fast shore
lilac mist
#

we have been cursed to do shader programming

fast shore
#

Actually wait let me do a max real quick

lilac mist
#

But I'm guessing your "base" actually produces numbers below zero

fast shore
#

Nope, return max(base, 0.0f) + max(blend, 0.0f); same result

lilac mist
#

to satisfy curiosity, what happens if you add 0.1f to the result

#

if you get more gradient on the right side then the bottom right part of the texture is negative

#

sorry, add +0.1f to the base, not the result

fast shore
#

return max(base + 0.1f, 0.0f) + max(blend, 0.0f);

#

Ok, but why tho

#

What's so special about this triangle

lilac mist
#

Your gradient starts at the top left corner and presumably approaches zero at the center

fast shore
#

Wait but that doesn't make sense

#

Here's blend top right corner is white

#

And slightly lower it's grey

#

Here's base, entire right side is black

#

0+1 will still be 1 and 0+.8 will still be .8

#

Why does it jump straight to 0

lilac mist
#

It depends on how "base" is calculated but

fast shore
lilac mist
#

I dunno how shaders respond to NaN issues for example

#

like if you're dividing by zero for the whole bottom right part, how does that show up in the render

#

But I can't see any other way you're adding two numbers together and getting a lower result than you started with

#

If you try to add to a broken calculation it's still broken

fast shore
#

Yeah I'm reading through it seeing if I missed something

#

Ok, wrapping the blend function return in saturate seems to fix it

#

So somewhere, my values are off the limits

lilac mist
#

limit breaker

fast shore
#

And I'm starting to think it's the >1 value issue, not <0

lilac mist
fast shore
#

Like it's not gonna let the value be out of 1 >= x >= 0

#

I butchered that expression but you get the idea

lilac mist
#

But "base" produces positive numbers from the top left...

fast shore
#

What if it's like, 2.0?

#

So whiter than white

#

Should that have caused a purple pixel?

lilac mist
#

Then the pattern doesn't make sense given the colors

#

the bottom right isn't above 2.0 because it's black + black

#

it would be broken on the top left corner instead

#

If your base calculation is:
1 - (uv.x + uv.y)
Then anywhere past the halfway point would be a negative number

#

that is, that straight diagonal line you see

fast shore
#

Yes, I should've divided it by 2 for diagonal checks

lilac mist
#

that line denotes the line where uv.x is 0.5 and uv.y is 0.5 and 1-(0.5+0.5f) is zero

#

(Is this the only place you're using base and blend?)

#

like, what is blend a blend of

fast shore
#

Wait a second I'm checking something

hushed silo
fast shore
#

Now I just need to firgure out what to do with outwards corners

lyric copper
#

Hey folks. I have been searching for a couple of days and trying different approaches but nothing seems to work.

I currently have an inverted sphere that mirrors the x,y and z position of the camera but not its rotation. The first part of the shader is setting a Color/Texture and the second part is a reticle that I created using the Sphere Mask that should always remain in the center of the users view.

I tried to input the Camera Nodes > Direction into the Center of the SphereMask node and I set the Coordinates to World Space via a position Node but that doesn't work. View Space kinda work but its way off and seems broken.

Is this the way to get the forward gaze point of the user to use for placing the SphereMask correctly?

lilac mist
#

very useful guide, I appreciate it a lot

lyric copper
#

Here is a visual of what I currently have the only issue is that The transparent cutout is not always at the center of the cameras view when I look around

#

Actually this setup does work with object space.

fast shore
#

I'm really damn close to getting what I had in mind but still there's one thing that's bugging me. You see those seams around the center cube?

#

Or am I tripping

#

That's using screen blending. When using lightening same happens to inwards corners

fast shore
#

I'm also confused as to how you're supposed to grab scene color (with screen position, to get whatever's been rendered underneath)

#

You can in shader graph easily with a node but I can't find a way to do the same in hlsl

#

It's using some "SHADERGRAPH_SAMPLE_SCENE_COLOR" and I have no idea how

#

Ok there's _CameraOpaqueTexture

fading silo
#

why isn't the texture appearing in the plane?

#

someone pls

regal stag
# fading silo

Make sure you save the graph, using Save Asset in top left

#

Also check the texture is assigned on the material

fading silo
#

oh i didnt apply the material, for some reasons the color was changing when i used as a input a RGB node

#

thanks

fading silo
#

i want to animate that parameter on the right , why is it not controllable and how do i keyframe it?

grizzled bolt
fast shore
#

Facing a dilemma

#

Cram a transparent overlay as pass into one shader or create a separate material

#

Shouldn't be any different in terms of performance right?

#

Not to the point of being of matter

#

Also while we're at it is messing with texels expensive?

#

There's no easy way to tell whether your shader sucks like with Unreal's shader debugger view so I could be creating the most abominable shader in existence without even knowing

harsh surge
#

Hey, new to shaders in general, still learning. Would cell shaded be the appropriate term to describe what's being done to these 3d characters?

kind juniper
kind juniper
kind juniper
kind juniper
harsh surge
kind juniper
desert herald
#

We can't avoid branching in fragment shader if we need to conditionally discard pixel, right? Or there is some magic trick

#

Shouldn't be a big deal anyways

fast shore
desert herald
#

It will make it black, but still drawn

fast shore
#

Relatively big deal, not in the grand scheme of things

fast shore
desert herald
#

I think in my case a branch will be more efficient. It's instancing shader with up to 40k instances, and I use alpha value as "brightness" multiplier for XYZ rest of a color

#

As I've heard transparent is ok for not too many objects especially on mobile

fast shore
#

Honestly when it comes to performance of Unity shaders I'm clueless myself

#

The most tedious approach would be to make one shader that uses branching and another that uses transparency and manually check the performance

desert herald
#

Probably yes but that would mean I will have to redefine layout of structured buffers 😅 I'd prefer just don't use discard feature for this material if performance cost will be to big

#

Still would be glad to know about that branch thing

#

At first I thought that for instanced mesh it will always take the same path no matter of the instance, but it was stupid assumption that even AI proved wrong

#

All these wavefronts are still a great mystery for me

fast shore
#

Actually, now that I think about it, how expensive is transparency, really?

#

Cause I'm relying on it as well 🤔

desert herald
#

Afaik they're rendered back to front then re-rendered front to back, so you can forget about culling.

desert herald
fast shore
#

I searched a bit and apparently it's heavily hardware dependent

#

Some hardware can chew through it and most likely has some optimizations built-in, but most mobile ones do not

hushed silo
#

so I just had a little play with putting slope based blending of textures on my terrain mesh (it's in a custom shader on a mesh not unity terrain system) and it looks pretty, though does obvs have a performance impact... I guess I should use a greyscale blend texture instead? Anyone know of a tool within unity that you can provide it a mesh and it could bake a steepness texture?

desert herald
#

Strange though, I was almost sure that some pro mentioned that rendermeshprimitives() doesn't cull instances

fast shore
desert herald
#

Shader random() function taking instanceID as a seed for a bw mask "threshold"

#

And bw mask is per material constant texture sampled with also randomized uv

#

But randomization and sampling does not introduce any overhead. Without discard it runs smooth, that's why I think this is the reason

agile field
regal stag
zenith grove
#

hey i subdivided a plane in blender and exported it to unity
now when i modify the vertexs it doesnt really work as intended

for example when i change the y coordinate of the vertex the z coordinate of the subdivided plane changes.

agile field
desert herald
#

this probably indicates that you exported subdivided plane with different Fwd and Up axis than the others, also mind the scale

regal stag
agile field
#

Okay I will look into it, thanks.

agile field
regal stag
agile field
#

Do you think there is an easier way to handle this or might this be one of them? Games like Valheim handles this extraordinary well (Of course, that is way beyond my knowledge).

#

In short, I generate a 2D color map onto a material with colors and different biomes, then I apply that to a 3d mesh with a Texture2D. I am just looking for a way to blend the pixels.

hushed silo
#

I have a custom shader being drawn in a command buffer (with commandBuffer.DrawRenderer(renderer, overrideMaterial);)

shader has #pragma multi_compile_instancing
and UNITY_VERTEX_INPUT_INSTANCE_ID

but framedebugger is showing it as 6 draw calls (with "reason unknown" ) , they also have static batching on and are marked static.... In the main render thread they are all batched together with another shadergraph shader.... Anyone know what I'm missing?

regal stag
hushed silo
#

it's a single pass, I've updated it to commandBuffer.DrawRenderer(renderer, overrideMaterial, 0 , 0 );)

visually the same, though still at 6 draw calls. Thanks for the suggestion!

regal stag
hushed silo
#

they all have the same values in them and clicking on each call shows the same thing so not visibly differentiable

regal stag
hushed silo
#

it's six renderers, it's all the same mesh and material, with static batching on

#

it is indeed looping through the renderers here

#

(my first time using a command buffer, is it that there are multiple calls to drawrenderer then rather than that somehow being mashed into one?)

regal stag
#

If using multiple DrawRenderer calls I don't think it will batch

#

Is this for URP though? That has DrawRendererList instead

agile field
hushed silo
#

yes this is URP, interesting.

jagged lodge
#

I'm trying to get holes in objects working in a nice way with URP. I'd essentially like to just cull front faces that appear through back faces. I've accomplished this somewhat by drawing a stencil with front faces culled and making my mesh respect that stencil. This works well for simple object as seen above but for more complicated objects I notice that back faces will hide front faces even if they are occluded by a front face closer to the camera, which leads to very strange behavior. Any ideas on how to fix this? Here are some pictures of the setup and the misbehaving object

fading silo
#

why does my surface look like pixelated , im pretty sure i used shade smooth on blender before exporting

civic lantern
fading silo
#

no , its a .blend file

#

a normal circle with uvs

#

i tried smooth shading it still looks like that

hushed silo
regal stag
# hushed silo so this is very interesting and I've been looking into moving that way but faili...

You create the renderer list through the ScriptableRenderContext. See https://docs.unity3d.com/ScriptReference/Rendering.ScriptableRenderContext.CreateRendererList.html

For URP 14 / 2022 versions there's also context.DrawRenderers (is obsolete in favour of renderer lists in 2023+). I have an example of that here (via custom renderer pass/feature) : https://www.cyanilux.com/tutorials/custom-renderer-features/#drawrenderers

hushed silo
#

also super interesting. seems i've slipped into the cracks between versions. Do you know if there's a way to take a list of renderers and make it fit into a cullResults? I'm not using a camera, and everything I've tried so far has been a fail

regal stag
bold ore
#

hey ive been using custom function nodes in shader graph, but whenever i use more than 1 in the graph, it breaks

#

using just 1 of either works fine, and they arent linked at all

#

anyone familiar with this problem?

regal stag
bold ore
#

so they are in seperate files, and i solved it by removing exactly this in one of them

regal stag
#

Each file needs a different keyword there. If they are the same it'll conflict

#

If you know the file will only be included once (one Custom Function node) then leaving it out too also works

bold ore
#

ah ok that makes sense

#

can MYHLSLINCLUDE_INCLUDED be anything?

regal stag
bold ore
#

ok cool

#

thanks for the help 🙂

tacit parcel
tacit parcel
vague pendant
#

What's the best way to made a grid of scalable 3d blocks where there are no block faces, just the outlines? Like if Tetris Blocks were only outlines.

I'm using this shader asset, but the outlines that touch each other don't get rendered. I tried pushing back the shader's rendering order to Queue: Overlay, which almost works, but the lines in the back get rendered instead of the front, making it look "open"
https://assetstore.unity.com/packages/tools/particles-effects/quick-outline-115488

rain parrot
#

Does anyone know if it would be possible to use a tilemap as a heightmap for a shader?

#

I'm trying to handpaint a heightmap for a water shader. If theres another option out there then let me know.

desert herald
#

Ofc there isn't much difference for compiler. Pretty sure my IDE showed that this directive is supported as well (or it was unity docs, not sure)

desert herald
#

btw how to make ///<summary> in hlsl? i'd like to have something like this for my custom utils

grizzled bolt
regal stag
desert herald
#

Yeah, I based my statement on C++ knowledge which is quite poor tbh. Good to know it's not supported before 2020, thx for pointing that

fallow pendant
#

Hello, I am trying to make a shader in shadergraph that emulates the rifts from zelda echoes of wisdom. Right now I am doing it by only rendering the back faces of a cube and inverting the order of the deph buffer, so it only shows the faces that are covered. This almost does it but there is a portion of the cube that I don't want to be visible but with this method it is, Is there a way to fix this in shadergraph? Or should I switch off this method completely?

regal stag
lusty smelt
#

Im making a simple blur shader that offsets four copies of a sprite in opposite directions. I'm using it on a render texture placed in Image component on a canvas that is stretched to fill out the entire screen. It's working great but the screen ratio is 16:9 and the blur is inconsistant. If I plug ~1.7 multiplier (16/9) to the vertical offset it looks as intended. How can I get the correct aspect ratio using nodes so it always matches the screen size? I could expose a float param for the vertical multiplier and update it via script, but it would be great to have it in a shader itself

#

I tried using the object node like shown in the picture, but it doesnt seem to work properly in this screnario

lusty smelt
#

I just found the screen node with width and height :)

lilac mist
#

A thing that comes up often in my work but never in tutorials is re-using timed materials for many objects which doesn't really work.

As an example there's the "dissolve" shader tutorial on youtube where a sprite dissolves into nothing over time. As the objects share a material they also share the effect and once the first object is dissolved they all are. How are people applying shaders like these to many objects?

#

Are people using one material per object?

#

Like, making a new material instance every time they want to restart the effect?

regal stag
# lilac mist Are people using one material per object?

Usually yes. For URP/HDRP there's the SRP Batcher so it optimises setup between draw calls even if they share different materials (provided they are still the same shader, and using same shader keywords)
Though sprites only use SRP batching in 2023, for earlier versions it may be better to use MaterialPropertyBlocks. (Same for any version in Built-in RP)

#

You don't need to create the material instances yourself though, when setting a property through code using renderer.material.SetFloat(..) automatically creates an instance

lilac mist
#

I've been told making new materials on runtime is bad because they are "new assets" and aren't deleted properly

#

is that not correct?

regal stag
#

You are supposed to handle cleanup when the materials are no longer needed. Usually in the OnDestroy() method of the script

#

Though I think it might also happen automatically when switching scenes, not sure

lilac mist
#

Right so I have to manually clean up the material on delete of the gameobject

#

Or indeed when whatever effect I wanted is over

#

I can't use material property blocks in URP without messing up my performance?

#

Or does it not matter for sprites because they're already not batched in my 2022 LTS version

regal stag
lilac mist
#

My instincts tell me the system I'm imagining for stuff like this is bad, but I'm not usually the one to work with materials so I'm unsure

#

But you're saying even if I duplicated materials every time say, an enemy took damage, as long as I deleted the materal afterwards that would be okay?

desert herald
#

Why not pool these mats instead of cleanup btw

lilac mist
#

Because the primary concern is the "time" variable

regal stag
#

Is the damage effect different from the regular material/shader in this example?

lilac mist
#

In this theoretical example the take damage effect would be a fire-once effect not achievable by something like replacing the material with pure white for one frame

#

I'm not actually making a take damage effect though so it's just an example so I can understand

regal stag
#

Well you'd probably still only need a separate material per enemy, and only need to destroy it when the enemy is killed

lilac mist
#

But the effect is fire once, right? So taking the material away and putting it back mean the second time I show the material the effect has already fired?

#

For example the tutorial dissolve effect only appears when time is less than say 5 seconds so if the material has lived for more than 5 seconds the effect doesn't occur

regal stag
#

Either way those can be reset via SetFloat on the material

lilac mist
regal stag
#

That would mean a separate time for each object, but it's a global property

lilac mist
#

no I meant like, material instantiation

desert herald
#

That's why asked about polling. Simply reset float on GetFromPool or smth

regal stag
#

Yes, pooling is still useful if materials need to be reused often

lilac mist
#

I see

#

Oh, also you said if I use "setfloat" then a new instance is automatically created for me

#

This only happens the first time I use setfloat, right?

regal stag
#

It's the renderer.material part that creates the material, but yea

lilac mist
#

So getting the material creates a new material

#

So this line would make a new material instance

regal stag
lilac mist
#

I see, thanks

#

this has been educational

opaque grove
#

I have no idea how to really describe this, is there a term for this type of "shine" effect? Id like to try and build it in ShaderGraph - every few seconds theres this... Reflective "shine"? Effect that scrolls across the weapon like in Overwatch, or in games like GTA to indicate you can pickup or interact with some specific item, id like to research how to do that kind of effect but I dont know how to describe that to google
https://pa1.aminoapps.com/6570/a215f17c72c938860cd75da9cfd15ae5f4b2ff27_00.gif

grizzled bolt
#

It's also masked by a wave which is animated to move
Most likely a distance to a position on one axis in object space in OW's case

opaque grove
karmic hatch
#

The wave could be moving along UVs since it wraps around the box after it passes the muzzle

grizzled bolt
#

It could, although they likely are separate objects as they're detachable
Making UVs that allow for scrolling textures is very tricky if they also need to work for the base maps
If they were on a second channel that'd be easy and give you quite a bit of control over how the wave should traverse

foggy ocean
#

Hi

#

How can import the shaders of a model from blender?

grizzled bolt
smoky widget
#

Is there any way to create a shader graph that does one thing when doing shadows, and another when doing a normal render?

#

Or to be more specific, get the direction of the light source when doing shadows, and get the direction of the camera when doing a normal render

#

Im not sure if there's a variable that changes in those cases that i can use to represent the direction that I said

#

The reason for this, Im working on an Impostor shader, and they should be looking at the camera on the render pas, but if it's the shadows, to create a semi acurate shadow, the impostor should be looking a the light source

regal stag
#

Would replace 0/1 with the directions

smoky widget
#

I see, neat!

#

What about Built-in or HDRP?

regal stag
#

Not sure about Built-in, it might be similar to URPs but a different include.
I think HDRP already does the include automatically, but the keyword is SHADERPASS_SHADOWS instead

regal stag
smoky widget
#
half3 objectSpaceCameraPos = mul( unity_WorldToObject, float4(_WorldSpaceCameraPos.xyz,1) ).xyz;
float3 pivotToCameraRay = normalize(objectSpaceCameraPos.xyz-imposterPivotOffset.xyz);
#

basically if I could change that _WorldSpaceCameraPos into something more generic that would include both passes, it would be great

#

I guess I need a reference to the Virtual Camera?

regal stag
#

I think you should be able to extract the position from the inverse view matrix (UNITY_MATRIX_I_V._m03_m13_m23), that should be equivalent to _WorldSpaceCameraPos in the main pass but be the light position in the shadowcaster pass (since that's where it's rendering from)

smoky widget
#

lets see

#

oh wow

#

it works!

#

These are impostors :))

#

THere's still some issue with the light, but I will figure it out

#

Thanks!

#

okay it seems that because now the plane of the impostor is aligne with the light, it's casting a self shadow. Any idea if it's even posible to disable this?

regal stag
uneven dock
#

can anyone help me convert this shader into math in C#?

amber saffron
# uneven dock

For nodes that are not already basic math operations :
Gradient Noise: Use Mathf.PerlinNoise,
Tiling and offset : The doc can help you here : Out = UV * Tiling + Offset;
Remap : since your remap to the 0;1 range, you can simply use Mathf.InverseLerp

hushed silo
#

I'm curious about applying a LUT directly into all of my shaders to avoid doing anything in post as on Quest... I am currently trying

#

I put in that arbitrary float to try and debug... something is happening... but things generally are coming out greener than I'd expect

#

also this, better, but still greeny

hard rover
#

Hello people, the shader in the video below works great with sprites, but looks very wrong on UI Images. I'm trying to figure it out, but in the meantime, I'd love your ideas.
https://www.youtube.com/watch?v=ajbNS8mncRo

In this video, you will learn how to create a 2D ripple distortion effect Shader Graph in Unity engine.
Project Files Download (Patrons only): https://www.patreon.com/BinaryLunar
The Ultimate 2D & 3D Shader Graph VFX Unity Course:
https://www.udemy.com/course/the-ultimate-2d-3d-shader-graph-vfx-unity-course/?couponCode=008A797D623D6F0E6941

00:...

▶ Play video
amber saffron
hushed silo
#

Thanks, I think 3d LUTs don't work in mobile/URP or not performant or something though?

amber saffron
#

You might need also to apply gamma correction to the input uv

hushed silo
#

I saw that using a 2d unfolded lut was better for that stuff somewhere

amber saffron
hushed silo
#

Why sampling twice?

shell wadi
hushed silo
#

Oculus quest post is prohibitively expensive

shell wadi
#

Only if done poorly

#

You are doing exactly the same amount of math if you recolour every single pixel in a surface shader vs. in a post-pro effect

#

(in a best-case scenario)

#

As Remy said, you should use 3D textures as LUTs once you get to the GPU. 2D textures are mainly for ease of authoring in CPU-side programs, you typically convert them to 3D before sending to your shader.

hushed silo
#

Unless things have very recently changed, you lose about 30% of your frames budget going back for a second pass on quest. There is a very new way of pushing lut processing into the forward buffer in unreal but hasn’t been made for Unity yet

shell wadi
#

I haven't done Quest dev but exact same principle applies in mobile. Uber Post = better.

hushed silo
#

Isn’t post instantly a second pass? I have done a lot of quest dev and any application of post processing has been crippling

shell wadi
#

Open up your frame debugger and see what's happening after rendering the scene - I would be very surprised if there isn't at least 1 Post pass by default if you're using URP.

hushed silo
#

I don’t believe there is but I’m just heading out to the shops

shell wadi
#

Np, but yeah if there is legit 0 post going on then yes, different story

hushed silo
hard rover
grizzled bolt
#

You could try isolating the exact problematic part of the shader by process of elimination

amber saffron
# hushed silo Why sampling twice?

Since the texture is "flatten", each slice can interpolate R & G, but not B, so you'd need to sample two slices and blend.
Might just be easier to do with a tex3D

hard rover
# grizzled bolt Non-sprite shaders also work for sprites but have unexpected errors and limitati...

I introduced the philosophy from another video on some aspects and combining some elements already helped move on the right path
https://www.youtube.com/watch?v=dFDAwT5iozo

A shockwave shader graph (or shock wave shader graph) is a relatively simple effect, that can add a lot of pop to actions in your game.

Shockwave updated for 3D in my timeline video here: https://youtu.be/A5jl5RVEjqE

The reason I'm doing this tutorial at all is because someone commented on one of my YouTube videos requesting it. I bring this...

▶ Play video
spring portal
#

hi i'm new here, can i post wip shaders here or is there a different channel for showcasing stuff?

woven prism
#

In unity, are you theoretically capable of applying an additional shader to an object irrespective to what it already has?
For instance, I wanted to make it so that hovering over an object with a mouse applies a fresnel shader, and I come from a TModloader background where you can just slap a screen shader on top of everything
but idk how to apply a shader without completely replacing the material in unity

flint wasp
#

Hey guys, I was wondering if anyone knows how to effectively draw a lot of different meshes indirectly using the same material efficiently. Graphics.RenderPrimitivesIndirect seems to issue 1 draw call for every draw command no matter if it's a consecutive command or a seperate call to the function. I'm hoping for a functionality similar to glMultiDrawArrays in GLSL, which isn't supported for compatibility reasons(or so I'm told).

For now, I'm getting much better performance readingback to a mesh and allowing unity's built-in mesh-renderer to kick in. But if the data's already on the GPU it doesn't make sense to read it back to the CPU only to put it back if I can just manipulate the data with compute shaders. Also I would very much like to still be able to access the mesh information on my buffer for storage optimization. Does anyone have any insight?

kind juniper
flint wasp
#

On the GPU side, I don't want it on the CPU otherwise I would readback obviously

#

Wait so I'm confused, on the documentation for RenderMeshInstanced(which the API says replaces DrawMeshInstanced), it takes a Mesh object which I believe holds the data on the CPU side(?) I'm not sure do you have an example of how you can use it to draw geometry on a compute/graphics buffer?

kind juniper
flint wasp
#

Huh interesting, I'll see what I can do thanks!

flint wasp
kind juniper
#

I don't know the details, as I've never done that in unity.

#

Maybe Google on how to generate a mesh entirely on the GPU side

flint wasp
#

Hmm... I'm not sure that's what I want. I believe that route would need me to readback the size of the mesh from the GPU and then copy the contents into the buffer location the mesh desires.

My goal is to keep the geometry where it is in my original compute shader because it's very accessible that way. RenderMeshIndirect, from what I'm getting, is for rendering multiple instances of a mesh whose geometry you can get from the CPU(or originally) and which the amount of instances and their positions is known by the GPU.

#

If a Mesh object has vertex and index data on the CPU, it must copy it to a gpu buffer to render(always), but my goal is to have it point into a buffer I manage.

kind juniper
#

No, that should be possible. You just need to research it.

#

You need to pass the vertex and index buffers to your compute shader to fill them. Then assign the same buffers to the mesh and use it for whatever rendering you need.

#

Try asking this in perplexity. It provided a great answer for me, although it's too big to share here.

flint wasp
#

perplexity?

kind juniper
#

Ai search tool

flint wasp
#

oh ok, thanks

flint wasp
# kind juniper No, that should be possible. You just need to research it.

I’ve done some research and I don’t think it’s possible. Meshes do own a separate gpu buffer for vertex and index data to be rendered, but I can’t find any information on assigning the location of this buffer to point into a different compute buffer. The documentation only lists ways to set this data with a copy on the cpu, its overrides being an array, list, and native array. I can’t assign the address this buffer points at. The method, Graphics.RenderMeshIndirect, is for instancing large amounts of the same mesh geometry, where the amount and visual information about each instance can exist on the GPU. Say if you had a grass instance and you wanted to render a lot of them for very cheap. If we want to generate different geometry indirectly from the GPU, Graphics.RenderPrimitivesIndirect is used, which has a SV_VertexIndex semantic to differentiate vertices allowing us to find them in our own managed buffers.

What I believe is happening in the background with meshes is Unity’s performing some complex batching that combines the meshes physically since they all have the same material. When I call Graphics.RenderPrimitivesIndirect, I’m not performing any batching so I guess that’s why it’s slower. If that’s the case, I could customly batch them in a compute shader, though I’m not confident enough that this is the bottleneck to try this.

What’s interesting is how in the documentation, Graphics.RenderPrimitivesIndirect has an option for command count which suggests I can issue one call to the function and create multiple meshes with different geometry by making the command count equivalent to the number of unique meshes I want to render. So rather than N calls to Graphics.RenderPrimitivesIndirect, I could have 1 call to it with a command count of N. However when I try this, I’m not getting better performance, rather, my performance is bad even when all the commands are blank(instanceCount = 0, vertexCount = 0) which should cull all the geometry.

#

I honestly don’t know where to go from here; it feels like my options are to readback and accept the unnecessary bandwidth occupancy, or to abandon unity and recreate the project in OpenGL.

kind juniper
# flint wasp I’ve done some research and I don’t think it’s possible. Meshes do own a separat...

Only gonna comment on the mesh buffers. Indeed you can't make it point to an arbitrary compute buffer, but you shouldn't need to. Try approaching the problem from the other direction: pass the mesh buffers into your compute shader and fill them in it instead.

Regarding the indirect rendering, it is basically passing some overhead from CPU to GPU side, so it wouldn't necessarily improve performance, especially if the bottleneck is on the GPU. Though, it is weird indeed that if you set the instance count to 0, it doesn't affect performance.
Might want to have a look at the frame debugger, profiler or some native GPU profiling tools like PIX for more info.

flint wasp
#

Yeah I'll see if I can uncover something with instance count = 0 not effecting performance

kind juniper
#

How are preparing the compute buffer then? I think it needs to have a predetermined size, no?

#

Surely you have some of this info on the CPU side?

flint wasp
#

That’s why I’m using indirect functions to render it as well, because I don’t know the info directly

grizzled bolt
# woven prism In unity, are you theoretically capable of applying an additional shader to an o...

There are many ways to re-render a mesh on top of itself with a different shader, to override its shader or to render a full screen shader
The methods to do that depend on what render pipeline your project is using
There is no way to "mix" two different shaders at runtime, though rendering the object twice can let you do a sort of an overlay if the second material is transparent
A typical method is to include the highlight effects in the shader of all meshes that need it so it can be turned on or off, as long as the effect isn't too expensive
Or alternatively swap to a different shader that does support the highlight and copy all the material properties to the new material instance to keep the shaders separate

sharp frost
#

How can I test ShaderGraph Shaders?

kind juniper
#

Or what do you mean by "test"?

sharp frost
kind juniper
sharp frost
kind juniper
kind juniper
kind juniper
#

I'd suggest to test and profile your game with shader graph and only worry about it if you actually have performance issues

sharp frost
lone estuary
#

sing an asset, one of the shaders doesnt compile in unity 6 and im trying to figure out how to fix it myself , any advice?

#

there is no "," on line 209 in that file, what is there is

#

nvm fixed it by reimporting the shader lol what the actual

neat orchid
#

so can I just keep lerping textures to plug into one vertex color channel? What would happen? Would the blend work worse? Or would it not work somehow at all?

kind juniper
#

Plugging textures into vertex color channel doesn't make much sense.

neat orchid
#

Making a vertex paint shader

#

But using more than 5 colors

#

I meant could I fit multiple lerps into one vertex color, what would happen

#

But at that point I could just make a splatmap I guess

halcyon hawk
#

Hello, how can i use SetInputAttachment in SRP RenderGraph (AddRasterRenderPath)? How to use LOAD_FRAMEBUFFER_INPUT in shaders (HLSL for dx)

steel notch
#

Is there any way to have a sort of ambient occlusion effect with 2D sprites? Just something to create contrast between the subject and background.

ebon moss
#

does anyone know why my directional lights dont seem to be affecting my shader graph shaders that use main light? I'm using URP. it seems like the skybox is the only thing that matters

ebon moss
#

Hey I managed to fix it by changing my shaders from unlit to lit and then back to unlit, does anyone know why this solved it?

dusk ravine
#

How exactly does unity determine the render order for opaque objects? I'd expect it to be exactly front to back based on origin positions, but according to the frame debugger this isn't consistently true. there's no funny business with batching or instancing going on here... I'm not sure what's up. any ideas? I'm on the built-in pipeline if that makes a difference

#

(I'm trying to get some fun masking to work with the stencil buffer, which means that my render order matters quite a lot)

low lichen
#

This is not the case for transparent objects, where a back to front sort order must be strictly maintained for correct blending, which means losing out on batching opportunities.

dusk ravine
#

That makes sense! In my little test case these are three separate draw calls with different materials, so there's no batching going on -- but for some reason the render order changes when I change the distances between them (without changing the z order)

#

If I switch to a transparent shader it works exactly as you'd expect (strictly back to front)

dusk ravine
low lichen
#

Importantly, it has a certain number of distance bands, so maybe it's only sorting the distance bands, but the order within each band is somewhat undefined.

dusk ravine
#

Aha interesting! Okay, that's very useful... thanks!

low lichen
#

For more control over order for stencil operations, you can use the render queue property in the material.

dusk ravine
#

Lovely, I'll take a look at that! much appreciated

#

I think ultimately I might have to just make my own batcher and use Graphics.DrawMesh for this. annoying but will probably end up more performant anyway, since I can make some special assumptions

viral sun
#

is there a way to trigger any kind of function or event from a shader?

dusk ravine
viral sun
#

i have an interactive gras shader (from the internet) and im trying to detect when the player touches the grass

dusk ravine
#

yeah that's tricky. You'll probably have to figure that out separately on the cpu, probably with physics or distance checks or whatever

viral sun
#

ok, well I dont really know how to do this since im not really into shaders or physics stuff

#

do you think it would be smart to learn shaders and make a custom one special for this use case?

dusk ravine
#

I always recommend learning shaders just cause they're super useful & I think they're cool -- but I'm not sure a special shader will help here, since you're not realistically gonna be able to send info back to the CPU anyway. Hard to say without more details though

viral sun
#

what detail do you need, the code?

dusk ravine
#

Well like what exactly are you trying to do? What does the grass look like? how is it getting placed? is there a gameobject "grass clump" or is everything instanced? stuff like that

viral sun
#

So im trying to count how often the player touches the grass with his hands, its in Vr. I think the grass is instanced and the grass is placed with a tool in the editor

dusk ravine
#

Huh okay. well if you can get the data about where the grass is from the editor tool, you should be able to test if the player's hand is close enough that they're touching it. But if the shader itself is moving the grass around a lot, you're going to have a very hard time determining where it is

viral sun
#

so what you are trying to say is that there isnt really a way

#

is there maybe a better way to do this without shaders?

dusk ravine
#

it's not impossible but any way you could move data back to the cpu (like by rendering a depth map from the hands for example) is going to be impractical and almost definitely not fast enough for VR

#

yeah you could move the vertices of the grass mesh from a script! but if you have a lot of grass, that's going to be extremely slow

#

You could probably use a compute shader for this but if you can't write shaders at all yet, I think that's probably too advanced

#

depends on hardware though. Not sure a meta quest could handle a particularly complicated compute shader

viral sun
#

so its almost impossible for me...

#

still thank you

deft osprey
#

Anybody knows how to implement custom blend modes (or disable blending) for ShaderGraph shaders? Basically the same question found here: https://discussions.unity.com/t/how-to-specify-blend-mode-and-operation-in-shadergraph/1496127

Specifically I need an "Add" op for color and "Multiply" for alpha. This is easy to do with ShaderLab which also allows you to change modes via script, but on ShaderGraph, I don't see the option.

I am using ShaderGraph to render transparent objects onto a render texture. Default blending modes provided by ShaderGraph don't work well for this so I need to specify the blending op/mode. If I can't do this, then disabling it and calculating the color blending manually is fine too but even this seems impossible with ShaderGraph.

#

The last thing I want to do is to not use ShaderGraph and rewrite all shaders and subgraphs I have as ShaderLab shaders. This would be very dissapointing

Is there any better solutions than these ideas that I have?

  • Write single shadergraph output to black/transparent texture, then use another ShaderLab to blend results with others
  • Use asmrefs to access shadergraph internals to see if this can somehow be changed
  • Try to mess around with asset importer or ShaderGraph editor API to somehow change this
regal stag
# deft osprey The last thing I want to do is to not use ShaderGraph and rewrite all shaders an...

You could convert the graphs to code (via button in inspector when graph asset is selected) then edit and save that as a shader file to use on your materials. That separates it from shader graph, but at least it's not a whole rewrite

If you're rendering these objects via a custom renderer feature you can also override the blend/blendops in that by passing a RenderStateBlock into the DrawRenderers/CreateRendererList params.

hexed sorrel
#

bump, still no success unfortunately. I am still unsure as to why the "clear" is not even updating the color, I assume "RT_GroundMask" isn't properly being assigned to my "RT_GroundMask_GLOBAL" texture.

deft osprey
proven glacier
#

ive created a shader but it is purple the whole time, does someone know what i should look at?

royal wraith
#

thats how

#

uh if you want i know a place you can learn tho

regal stag
# proven glacier

Might be errors in console. But likely that #if needs changing to #ifdef in newer versions when using SHADERGRAPH_PREVIEW

proven glacier
#

Shader error in 'Master': 'LightDirection_float': output parameter 'Direction' not completely initialized at line 246 (on d3d11)

Compiling Subshader: 0, Pass: Pass, Fragment program with DIRECTIONAL
Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PASS_FORWARDBASE UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: DIRLIGHTMAP_COMBINED DYNAMICLIGHTMAP_ON FOG_EXP FOG_EXP2 FOG_LINEAR INSTANCING_ON LIGHTMAP_ON LIGHTMAP_SHADOW_MIXING LIGHTPROBE_SH SHADER_API_GLES30 SHADOWS_SCREEN SHADOWS_SHADOWMASK UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_VIRTUAL_TEXTURING

regal stag
#

Probably still applies, I can't remember the version when it changed

proven glacier
#

you right there was an error in the console

trim forge
#

hmm does anyone know why my sprites renderers vanish when i change their shader? only happens on some levels and not others?

neat orchid
#

So, to add tessellation to a vertex blend shader, I assume adding heightmaps to textures is the only thing that matters for the fragment shader part

#

Adding tessellattion and displacement to the vertex shader is a separate action that will displace according to the height map blend, yea?

hexed sorrel
#

Hey all! I'm currently having a little trouble masking out a Tilemap using a LayerMask, unfortunately my "RT_GroundMask" is always outputting a full black texture, I have logged and double checked my LayerMask is propertly set. And checked similar approaches however, everything I seem to try doesn't seem to work.

public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
        {
            var colorDesc = renderingData.cameraData.cameraTargetDescriptor;

            // Create Blank "RT_GroundMask", and set it to be the current target.

            RenderingUtils.ReAllocateIfNeeded(ref RT_GroundMask, colorDesc, name: "RT_GroundMask");

            // Set our context "target" to the "RT_GroundMask".

            ConfigureTarget(RT_GroundMask);

            // Set the Blank "RT_GroundMask" to be black.

            ConfigureClear(ClearFlag.Color, Color.black);
        }
        // Draw the mask of our "Ground" tag to our "RT_GroundMask".
        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer cmd = CommandBufferPool.Get();
            using (new ProfilingScope(cmd, _profilingSampler))
            {

                SortingCriteria sortingCriteria = SortingCriteria.CommonTransparent;
                DrawingSettings drawingSettings = CreateDrawingSettings(shaderTagsList, ref renderingData, sortingCriteria);


                context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);

                // Set a Global RenderTexture for our local RenderTexture of our mask. ( To be used in other passes. )

                cmd.SetGlobalTexture("RT_GroundMask_GLOBAL", RT_GroundMask);

            }
            context.ExecuteCommandBuffer(cmd);
            cmd.Clear();
            CommandBufferPool.Release(cmd);
        }

        public override void OnCameraCleanup(CommandBuffer cmd) { }

    }

One thing that is a little confusing is my:

filteringSettings = new FilteringSettings(RenderQueueRange.all, settings.layerMask.value);
Debug.Log(LayerMask.LayerToName(settings.layerMask.value));

is returning "Deployable" which is not the LayerMask I have set in my renderer feature, however I have set my Tilemap to "Deployable" to match, I assume that is a part of the problem, additionally I have set ConfigureClear as so:

ConfigureClear(ClearFlag.Color, Color.red);

however, it is still logging a black screen. If anyone has any idea what could be causing it any help would be amazing! Thanks all.

regal stag
hexed sorrel
regal stag
#

Frame Debugger window might give some clues

hexed sorrel
# regal stag Frame Debugger window might give some clues

I'm currently trying to use that, the way I am monitoring my global texture is by using a square sprite using a test material that is referencing the global texture, which exposes it to my frame debugger, but I can't seem to find much insight as to why unfortunately.

#

Here's how it is displayed:

regal stag
#

I meant the feature itself should be listed under the frame debugger, with the clear and object rendering commands. If not it might not be enqueued correctly, maybe check the AddRenderPasses function?

#

If you're in Unity 6 note that features have changed a lot and use RenderGraph APIs (RecordRenderGraph function) rather than Execute. Unless you set it to compatibilty mode (not sure where that setting is though).

hexed sorrel
#

Oh I see, you're totally right. I don't even see the rendering feature itself I don't believe.

#

which I also think may be worth nothing that my "Layer Mask" is set to be "Ground" however, when logging it's value is actually searching for Deployable, I have tried setting both my tilemap to be "Ground" as-well as "Deployable".

#
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        renderer.EnqueuePass(P_GroundPass);
    }
#

could it be that my renderer is bugged itself?

storm stump
#

hello shader gods, are there any good resources one may refer me to when making impact frames?

hexed sorrel
#

Would anyone happen to know why or how my custom renderer feature attached to my 2D URP asset renderer wouldn't be displaying in my frame debugger? I'm currently on Unity 2022.3.25f1, which I have had it function properly before. Everything should be propertly attached and I appear to be Enqueuing it properly as-well. Any ideas?

hexed sorrel
hexed sorrel
hexed sorrel
cold hedge
#

Hey, does anyone know if using the boolean node in the URP shader graph makes the shader calculate both branches or not, even tho one of them will not be used based on the branch value ?

shell wadi
#

So if you want to do any sort of true branching, your best bet is to write a bit of custom hlsl and [branch] an if statement manually

neat orchid
#

Does tessellation have overhead compared to just a high poly version of a mesh?

mental bone
#

It does

neat orchid
#

So, theoretically, if I can't see shit in my game and objects are culled after 10 meters, it would be better yo just use high poly objects, yea?

ocean viper
#

So i got this outline shader working using Custom Pass, but it sticks into the skybox like an old windows xp bug. Is there an easy way to fix this

amber saffron
ocean viper
#

is there a way to just exclude the sky and fog volume from the custom pass

quaint grotto
#

does the SRP batcher basically replace the need for enabling GPU instancing on a material ?

dim yoke
uneven dock
ocean viper
#

So after digging, the bottem half of my shader graph is fine, but its the HD Sample Buffer that is doing the weird glitch, but if i remove the Buffer, i dont get half the detail in the outline. I have little to no clue what im doing with shader graphs, so i dont know if that helps

#

also, if i change these float values at the top to be a greater value, it lessens the effect of the glitch, but it also lessens the detail aswell.

sage veldt
#

importing a shader graph and its failing to compile is there any way to fix this

#

failing inside the editor not just the build

thin crater
#

Hi! Is there a way to "grow" a texture mask via shader graph? I've created a texture that draws points corresponding where the player has passed in the terrain. I'd like to "grow" the points to use them as a mask for a map and create a fog of war
that's the texture

#

the only method I know right now is by directly creating a green circle where the player passes with a longer diameter, but this creates many optimization problems (I'd have to call it on nearby map chunks since the map is splitted in chunks, and it would be computationally heavier than calculating that on the gpu side)

thin crater
# thin crater

what I'd like to obtain is a "larger" circle where now there's a green line, as if I increased a stencil width with a painting program

kind juniper
#

To answer your question, no, you can't do that in a shader graph.

dim yoke
amber saffron
uneven dock
thin crater
dim yoke
thin crater
#

can I use a simple unlit shader (from shader graph) for a UI element?

#

seems like transparency is not working with sprite unlit in a raw image

dim yoke
hexed sorrel
#

would anyone know if there is a recommended way to convert this to a black/white mask? I am currently trying to create a mask using a custom renderer feature, I understand that when masking it shouldn't matter but I worry that if I am masking a black texture it may not mask property, would I need to convert this to black/white?

hexed sorrel
thin crater
#

Is it possible that a texture is getting compressed (and so colors are different) when I create a texture via code and pass it to the shader?

#

I've created this system to filter out colors in a map and apply an image instead of that color (with a similar color in this case)

#

It works well for every color except the second one in the image, the light green. It's not detecting that no matter what I do

#

I'm pretty sure the color is correct: both via code and with color picker the color is the same (8FD900)

#

That's the result... the green color is the only one not matched

regal stag
thin crater
#

What can I use instead of this?

#

it's also working almost well with other colors 😦 can't find any other shader node useful for this

regal stag
#

There's Color Mask / Replace Color nodes which may work. But with each added colour it gets more expensive...

If your aim is to swap colours, it could be cheaper to have the texture as specific greyscale (or red) values that map to the X coordinate of a palette texture, similar to this example : https://www.cyanilux.com/tutorials/color-swap/#palette-texture

acoustic umbra
#

Anyone know why i get all pink material after downloading Stylized particle effect from unity asset store

amber saffron
acoustic umbra
#

The docs doesnt really help

amber saffron
# acoustic umbra

Wild guess : look into that "URP" folder (if you are using URP though)

acoustic umbra
#

Well, i think im using built in render pipeline, so my objective now is to change it to urp?

thin crater
sharp frost
#

Anyone know why this issue occurring? Some times its visible some times not.

flint yew
#

the operations are causing certain elements to be ignored

#

due to dimension mismatch

#

like passing a vec4 into a vec3 function (the last element of the input will be ignored)

sharp frost
#

Here is the Graph could you please let me know where I am doing mistake?

flint yew
#

passing vec4 into vec3 input

#

for example.

#

Its only a warning, you could choose to ignore it, but know that parts of your inputs are being ignored

regal stag
#

Afaik SG nodes handles truncation automatically. Connecting a Vector4 to a Vector3 port shouldn't create warnings. But there may be mistakes in the generated code which you can't fix. Just have to ignore it

flint yew
#

It's for the developer to know that information is being ignored

#

That might be what you want, and it's just there to inform you

#

because this could be a mistake and could cause unwanted behaviour

sharp frost
flint yew
#

The shader will handle it, and you should be aware that it is happening.

#

And you could choose to be explicit by truncating the vector manually, to get rid of the warning.

hexed sorrel
#

I currently have this shader above which is being utilized in my custom renderer feature, which is supposed to mask out all of the "Light Texture"(TOP) where there isn't any alpha on my "GroundMask" (BOTTOM), with the intended result being a texture containing light only in the blank spaces between my tiles shown in the bottom image, currently this outputs a fully black image when placed as seen in the shader graph with a one minus node. Without the one minus node the output is instead identical to my light texture (TOP). When using other channels other than alpha I get a pretty weird result which sort of obfuscates my "GroundMask" (BOTTOM), mostly darkening it. If anyone knows what I could be doing wrong any help would be very appreciated! isFine

amber saffron
# hexed sorrel

I think that your ground mask RT doesn't have any alpha channel. (so defaults to 1)

hexed sorrel
amber saffron
#

Yep, B10G11R11 format, no alpha 🙂

hexed sorrel
#

Would there be an easy way to configure my renderer feature to support an alpha channel?

#
ConfigureClear(ClearFlag.Color, Color.black);

currently this is how I am creating the blank space with the "ConfigureClear" function, do you know any way natively to just assign a "0" alpha instead?

#

Or if it would be easier just mask the cleared area another way that might be more easily supported if alphas aren't ideal.

amber saffron
#

You can use Color.zero . But to have alpha in the RT, you need to create the RT with a format that does support alpha.
Else , since it looks like the background is black, you could simply do a color mask

hexed sorrel
hexed sorrel
amber saffron
#

Ah, yes, this one. On top of my head, I though "zero" was there.

hexed sorrel
hexed sorrel
# amber saffron Yep, B10G11R11 format, no alpha 🙂

would you happen to know the name of a recommended color format for supporting "RGBA" would the format be "RenderTextureFormat.RGBAUShort"?
*I am quite unfamilliar on the subject but does the "Short" suggest the existence of a "Normal" or "Long"?

amber saffron
hexed sorrel
amber saffron
hexed sorrel
#

that's my bad.

#

does anyone happen to know of a way to directly save a png of the previewed render texture in the frame debugger?

amber saffron
hexed sorrel
amber saffron
#

Else, if you use a CustomRenderTexture, it has a built-in "save as png" option 🙂 (in the inspector menu)

amber saffron
hexed sorrel
amber saffron
#

I'm sure this is somewhere in the absurdly long list of "nice to have" low hanging fruits.

hybrid sparrow
#

Hi, I’m trying to create a shader that animates only once. It would be a transition from one texture to another when a condition is met. Here I’ve used a bool, but eventually this effect will be for a hover effect on an apple vision UI.
The idea is to have a texture that animates when the shader is in Activate, that resets to its initial state when the bool is unchecked, and that the animation resumes when the shader is reactivated.
The problem is that the Time value doesn’t reset to 0 when I reactivate the bool…

I’ll leave a photo of my shader as is and a video of what I’ve got so far.

hexed sorrel
#

Does anyone know the best way to pass an RTHandle between two different passes? For example if in my first pass I have an RTHandle named "Pass1RT" and I am trying to use "Pass1RT" in my second pass, how would I send "Pass1RT" to be used in my second pass?

civic lantern
sage veldt
#

shaders never work and i cant figure out the fix for it

#

ive imported a lot of shaders and they always end up like this

hexed sorrel
#

After you've done that you have to convert the materials to use URP as-well. IIRC it should be in "Edit -> Rendering -> Materials -> Upgrade to..." if I'm not mistaken.

sage veldt
#

this? because its already installed

hexed sorrel
#

in Edit -> Project Settings -> Graphics -> Scriptable Render Pipeline Settings

#

I believe if you don't have one there should be a button to create one? If not, right click in your assets folder, click create, scroll all the way down (you may need to click the arrow at the bottom to scroll further) go to rendering, and create a suitable URP Asset.

hexed sorrel
sage veldt
#

theres already been one assigned

sage veldt
#

it seemed to do nothing

hexed sorrel
#

is the material selected when you click the button?

sage veldt
#

yep

hexed sorrel
#

It should take a sec to load and fix itself, what is the material for if you know?

#

Is it a URP material, or would it possibly be HDRP?

sage veldt
#

its a toon shader

#

its urp

hexed sorrel
#

Hmm, maybe double check that everything in the material is property assigned, if it is I can really only recommend recreating the material by right clicking the shader (not material) in the inspector and clicking Create -> Material which will auto assign the shader to a new material which may work?

#

Sometimes Unity also likes to turn shaders pink if they are using HLSL directly, but should still work fine if used.

sage veldt
#

still the pink

#

its saying they failed to compiled

hexed sorrel
#

It could very well be an old hlsl shader which uses something deprecated.

#

Do you know what kind of shader it is possibly?

sage veldt
#

looks like it does mention hlsl

hexed sorrel
#

Yeah, HLSL is fine but some old shaders to my knowledge need to be updated or they'll sometimes throw errors. I'd try finding a newer shader possibly in some sort of tutorial if you aren't familiar with HLSL. I'm sure there are LOTS of BOTW inspired toon shaders for Unity!

sage veldt
#

whats weird though is that it happens to almost every shader i import

#

not just this one

#

ive tried plenty of other botw shaders

hexed sorrel
sage veldt
#

the botw ones i just find from github but also other shaders ive purchased and/or gotten from the asset store do the same

hexed sorrel
hexed sorrel
sage veldt
#

just did that a minute ago im importing the shader rn

hexed sorrel
#

It could also be possible to just download a matching version of Unity that the shader was made for if you don't need any of the updated features.

sage veldt
#

it works fine in the new project. weird

hexed sorrel
#

It could really be a lot of things, I'd try to delete and recreate a new URP asset in your old project to see if that fixes things.

sage veldt
#

do i have to restart unity or anything when i change the urp asset?

hexed sorrel
sage veldt
#

whats also weird is that one of the shaders used to work on the old project but now it doesnt so im not sure what changed with it

hexed sorrel
sage veldt
#

no, that happened awhile ago i havent messed with anything urp up until i need help

hexed sorrel
sage veldt
#

the new project doesnt have any issues with shaders

hexed sorrel
#

Absolutely worst case you could migrate everything to the new project, not sure if that's an option for you but it could save you some headache.

sage veldt
#

yea, thank you for your help though!

hexed sorrel
sage veldt
#

@hexed sorrel i dont know what changed maybe restarting but it suddenly works now haha

hexed sorrel
neat orchid
#

So is it possible to create a sort of curvature map with shader graph, like you would with a curvature generator in substance painter?

#

Like, I want to apply a texture along the curves of a mesh

hexed sorrel
neat orchid
#

Or, even better, if I have baked a curvature map using substance painter, could I use it?

#

even simpler I guess

hexed sorrel
neat orchid
#

Hmmm....it's a mesh map within painter...but if I could bake it into a texture....

hexed sorrel
#

Shaders are generally used for effects that are affected by a Runtime-specific element, it can take advantage of time, location, scene elements etc.

#

But if you have a 3d object you're creating in substance painter, very likely you could import it directly to Unity.

neat orchid
#

yes I'm exporting substance meshes and textures into unity

#

maybe I should specify what I'm trying to do

hexed sorrel
#

You shouldn't need a shader to do that to my knowledge.

neat orchid
#

I am tessellating and displacing as a separate thing

#

ok I need to tell you my idea

#

so I'm making rocks for my game

#

I changed around whether I wanna uv map and paint them all or if I wanna use a triplanar texture bla bla

#

I've been bouncing around how to do them

#

it looks the best if I UV paint them in substance painter. One thing I do there that looks good is using a curvature generator which is like a mask which is applied to the curves of a mesh

#

so I make a smoother texture along the curves and make rougher, more displaced textures in the middles

#

that looks good to me

#

so I had an idea

#

rather than UV mapping each rock individually (unfortunately atlases are low res for me, don't ask), I can somehow achieve that curvature generator with a shader in unity

#

so that I can use one single material as triplanar to apply to all my rocks

#

for performance reasons is the idea...and build size

#

does any of what I said make sense?

hexed sorrel
#

So, sorry I'm still a little confused here. Are you trying to procedurally randomize a "rock-like" texture based on parameters which can be dynamically randomized in Unity to create "procedurally" textured rocks? Or are you just trying to save space by utilizing your substance painter curvature generator directly on Unity.

neat orchid
#

More like the latter, but it doesn't need to be directly applying my curvature mesh map

#

It could be finding it with shader graph

#

Or something with the nodes

hexed sorrel
#

Also are these rocks very prominent in your project? Generally rocks will use a couple precreated materials which will be unwrapped onto the meshes, and a shader will be applied to add moss or greenery to the tops/polish if that is preferred.

neat orchid
#

Like I would provide a base texture, possibly a noise mask secondary texture and the "curvature" texture

#

Whoch I would provide, not generate procedurally

hexed sorrel
neat orchid
#

It's a cave game...rocks are literally all I have

neat orchid
hexed sorrel
neat orchid
#

No not rly and tbh I'm prematurely optimizing

#

But it's high res, high quality

hexed sorrel
#

Because by far your easiest option from what I understand is going to be unwrapping everything, which will really not be as large as I assume you think it will be.

neat orchid
#

Maybe not

#

But also I am trying to reduce draw calls, yeah?

hexed sorrel
#

I would recommend trying out different rock materials and maybe looking into "polish" shaders that can work with them to make them fit better into the scene if you are really concerned about optimizing.

neat orchid
#

oh I've tried a lot of different stuff, including texture atlases but they are too low res in the end, even at 8k

hexed sorrel
hexed sorrel
#

Do you have a preview of what your game actually is supposed to look like to maybe give me a better idea of a direction you may want to go?

neat orchid
#

yea

#

here's a preview of my textures

#

some wall textures

#

Here's a test rock which I don't like

hexed sorrel
neat orchid
#

they look a bit bland

#

they ARE high res

#

everything is 4k

#

but I'll try to dig out a photo of my texture atlas if I have it somewhere

hexed sorrel
#

Sure, I assume you've looked into megascans?

#

I feel like they might be exactly what you're looking for asset wise.

neat orchid
#

I know of them

hexed sorrel
#

They've also got extremely high resolution materials you could try alongside your own meshes.

neat orchid
#

I'm ok with the resolution of my stuff

#

I use sbsar material

#

and mix and mash them

#

they have an infinite resolution, so it's not a problem

hexed sorrel
#

I see, so what are you looking to change about the rocks that can be done in substance painter (using the curvature generator)?

neat orchid
#

I'm trying to find the photo

hexed sorrel
#

I can almost guarantee with enough time and effort you can pretty much create anything in theory using shaders, it's just the complexity in how worth while it is to do. Shaders can get pretty laggy quickly especially if you don't know what you're doing. Most of the time I'd say especially in your use-case it's best to stick with finding materials and assets that look good together, and maybe polishing with a shader afterward if you feel inclined to.

neat orchid
#

anyway, it doesn't really matter

#

the rock I showed I know how to fix

#

with the curvature map

#

or rather, the texture used for the curvature is so heightmappy that it looks like nothing

#

I know how to fix what I want to fix with the textures

#

I was just wondering

#

whether using one material for all the rocks would be better

#

than just manually painting and exporting textures of each one

hexed sorrel
# neat orchid whether using one material for all the rocks would be better

it really doesn't affect much, generally projects will use a variety of unique materials scattered across their projects. The amount of different materials really doesn't affect performance much unless they are using a shader, if it's just a texture, and a bunch of maps it's really only the tris that are going to be your issue.

neat orchid
#

I found a picture

hexed sorrel
#

The amount of materials will really only increase project size.

neat orchid
#

basically this is the 8k ''low res'' texture from the atlas

#

you can see another rock in the background from the same atlas

#

you see the texture applies round the curves

#

and then a rougher texture inside

hexed sorrel
#

Ah, I see!

neat orchid
#

I will redo that just with heightmap displacement and higher detail

#

it will look good

hexed sorrel
#

If you have the heightmap it's definitely possible in unity.

neat orchid
#

I already am displacing

#

just need to fix and change some textures but yeah

neat orchid
#

or something...I know that amount of materials increases draw calls but might not be the case in hdrp

hexed sorrel
#

I mean generally yes reducing the amount of different materials will create some difference I really don't think the difference is very noticeable at all.

#

But with today's hardware and the scope of most indie projects, unless you've got an insanely poorly optimized project performance should usually be pretty stable. If when you've got it looking good you notice it's not performant it's generally better to optimize from my experience and not give myself a headache trying to make sure everything is perfect during the process.

#

But to answer your initial question yes, using a heightmap texture you could create a similar effect to that of the "curvature generator" in substance painter (if I am understanding that correctly), but I think to get the level of precision I think you're looking for I think you're likely better off creating a handful of really good looking rocks/materials with substance painter and scattering them around your scene. Then after you've got everything to your liking you could fiddle around with using a shader to diversify them even more.

neat orchid
#

I don't need that many rocks tbh

#

As you can rotate them any which way

#

Makes them seem diverse

#

Also might create a planar sand effect on some etc

#

Besides

#

You can't see shit in my game, I'm culling everything beyond 12 meters so I shouldn't worry about draw calls I guess

hexed sorrel
neat orchid
#

I should stop overthinking

#

I always do that

hexed sorrel
neat orchid
#

thanks

#

I don't know about the fun part

#

but yeah, it has its ups and downs

grizzled bolt
#

Remember to make threads for big or long discussion topics

hybrid sparrow
slow socket
#

Hey everyone, I made this simple shader to create a ripple effect. At the moment it simply takes a textures a distorts it but what I want is to have it affect all background elements while being independent from them if that makes sense? I'm just not sure how to do that so if someone can point me toward a tutorial or documentation I would appreciate that :D

kind juniper
slow socket
obsidian wasp
#

At a high level, what's the best way to approach culling/chunking grass instanced via compute shader? Passing data to the GPU every frame, assuming the camera moves, does not seem like a good idea, but I'm blanking.

#

oh hmmm, i guess I don't need to pass any data to the GPU, the calculations for what to cull could technically all be done in the shader. But then with a large enough map/enough grass to cull, running those calcs becomes its own issue.

#

in which case, you'd have to cull the culling.... via chunking???

sleek granite
#

You need to decide where the position data comes from, of course. Textures or meshs are probably going to be the best source.
My terrain is divided up into chunks. I compute the grass positions from the terrain meshs which has the benefit that those are already on the GPU anyway. So all I have to do is dispatch a compute shader per terrain mesh that is visible every frame

slender ore
#

Is it possible to obtain such patern using only nodes in Shader graph?

regal stag
slender ore
#

thanks

amber saffron
#

(so, not only nodes ^^ )

half pine
#

I m currently reworking my 2D-game and some of its systems.
I made a shader for the player (switch colors, invert colors, glow, etc). Nothing really fancy.

Is it a bad idea to use the same shader for other things (NPCs, objects, etc) too, even if they wont use most of the shaders functionality? Or would this affect performance too much?

amber saffron
#

It helps for batching, but indeed will increase global shader cost.
Note that you can disable some features with toggles and "if"s in the code/graph.
If done per material/object, it comes basically for free.

half pine
#

this is my shader I want to use for my enemies and objects. I dont know if I will ever use the color-swap for grass or pots or something.

amber saffron
half pine
amber saffron
#

Well, you can see it from the blackboard ^^

#

The difference is that the keyword version will generate shader variants, so each combination of those toggles is virtually a different shader, and can not be batched.
The non keyword boolean on the other side, doesn't create variants. But since it is constant over the whole object, at execution the unused branch will just be skipped, while objects can still be batched together.

zenith dragon
#

Total 3d noob, can someone tell why this in blender becomes this in Unity? Shader issue?

amber saffron
zenith dragon
#

Lit/unlit shader have the same effect

#

I'm using URP

amber saffron
#

Is there emission enabled when using Lit ? Do you have a light in the scene ?

zenith dragon
#

Emission seems to have no effect, yes there is light

amber saffron
#

🤔
Can you post screenshots of :

  • the model import settings
  • the inspector of the material
  • the scene hierarchy
supple kayak
#

Does anyone know any way for me too get "rid of the material inside of the ship? I am using shader graph and I dont know if there is some sort of setting for it or something. Basically I want my material to behave like water so that means it cant be seen "inside" of the ship

zenith dragon
#

Oh I think it might because I messed something up with the render pipeline, actually nothing 3-dimensional shows any shadows

#

I originally created the project with SRP but I might have done something wrong since I needed the shader graphs

amber saffron
zenith dragon
#

I'll just create a new project honestly, seems the quickest fix since it's so early

supple kayak
vast niche
#

Hello, I'm working with Stencil on a custom Shader on my VR Project.

The material where is applied the material it visible only one one eye, how can I fix it?
In the image you can see a Door that make a hole in a invisible plane and you can see through

amber saffron
supple kayak
#

@amber saffron Sorry for bothering but you mentioned renderer feature and stencil before and I feel like I am on the right path, just need some extra help to get there. So I have done my research on what stencil buffers are and renderer features and so on, and I feel like what I have done is correct(in the image) because I want to render the water layer only when stencil value is not equal to 1. Which is what the ship layer is set to. In my mind this should work but as you can see I still have the problem. And I have been stuck on this for a long time, testing different pass/fail operations but no fix. I have my ship / water set to the correct layers

keen ore
#

🤦‍♀️

#

gather texture != sample texture

slender ore
#

In shader graph, is there a way to have random values generated only once, every time an instance of shader is refreshed, using only nodes?

#

For example, I have a sampled gradient of a rainbow and I want to make it so every time I refresh shader it will have a random color from the gradient

civic lantern
#

Or a seed that the shader uses to generate the randomness

slender ore
#

that is an option, but I was wondering if it is possible to do purely in the nodes

#

I assume it would also be possible by writing a custom node for generating random number but not sure about that

desert herald
#

It would still regenerate each frame, unless you add som weird branching I guess

dim yoke
#

@slender ore I have wondered about the exact same thing earlier and I haven't yet found any run dependent random seed to be used. C# definitely works but if there is something that works with only nodes, I haven't found one at least

amber saffron
#

Water Mask

dim yoke
#

In VFX graph there was something like that built-in if I remember correctly

slender ore
desert herald
#

Either way you'd need to somehow capture a seed for RNG just once. So you need a property that is set ad not changed. Doing this by shader feels kinda hacky compared to pretty straightforward Osmal's solution. Idk about VFX graph, but I think it works different to the shaders, which are basically doing Execute() functions each frame

slender ore
#

alright, thanks for all the answers

last vault
#

Is it possible to add an equivalent to texelFetch(...) in a Unity Shader, such that it can still compile to WebGL2.0? (ideally it actually uses texelFetch in the output code...)

amber saffron
last vault
#

texelFetch is (as far as I can tell) equivalent to texture.Load(...).
It specifically grabs a single texel from a specified LOD (using integer pixel coordinates).
This behavior does not depend on if the texture normally samples bilinearly.

amber saffron
last vault
#

texture.Load seems to require shader model 4.1, which only supports transpiling to GLES3.1+ (whereas WebGL is GLES3.0)

#

on the other hand, this functionality is available since OpenGL1.3

amber saffron
#

Well, texture.Sample is also since shader model 4, but I'm pretty sure WebGL2 can sample textures.
I think the underlying cross compiler has matching functions in that cases, for example the equivalent to texture.Sample in SM3 is tex2D.
Now, need to find the equivalent to Load

last vault
#

I'll try to find one. If not, I guess I'll just hope Unity is lenient about using modern syntax with legacy targets (I don't have a DirectX machine on hand to test).

amber saffron
#

Did you try already with texture.Load, it didn't compile ?

#

Worst case, you can use texture.Sample, but calculate the UV of the center of a pixel using the texture dimentions 🤷‍♂️
What is the use case btw ?

last vault
#

It seems to work fine when compiling to OpenGL. Not 100% on whether it'll work on Windows, but the internals of the core SRP package seem to suggest it all uses shader model 4 internally.

hasty venture
#

Yo, using URP shader graph, is there a way to tile a shape, like you tile a texture?

#

The one on the top tiles, but the one in the bottom only scales down, but never repeats

#

so i'm left with a lot of dots and a single, lonely square

regal stag
quartz otter
#

I am trying to make multiple color palettes for my characters. I want to be able to change them via code. I have multiple sprite sheets per character. Can someone help me out?

lofty marsh
#

Not exactly sure which channel to use for this question but here goes,

#

I have a render texture on my camera that is then assigned to a canvas image to give a cool retro feel to my game with large black bars on each side of the screen. Further in development I decided I wanted to add in some pixel art, but heres the problem, the pixelization of the render makes the sprites almost unrecognizable to the way that I originally created them. I want these sprites to either have a material that doesnt get affected by my render texture. Best way of going about this?

lament scarab
#

What's wrong with my UI gradient shader?

It seems like where it ends, it's actually lighter than the actual screen color (see image below), it's supposed to be a simple transparency gradient from left to right
We can see a line where it ends somehow

Shader "Custom/UIOpacityGradient"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
        _Color ("Color", Color) = (1, 1, 1, 1)
    }
    SubShader
    {
        Tags { "RenderType" = "Transparent" }
        Blend SrcAlpha OneMinusSrcAlpha
        ZWrite Off
        Cull Off
        
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata_t
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
            fixed4 _Color;

            v2f vert (appdata_t v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                fixed4 texColor = tex2D(_MainTex, i.uv);
                float alpha = 1.0 - i.uv.x;
                texColor.a *= alpha;
                fixed4 finalColor = texColor * _Color;
                return finalColor;
            }
            ENDCG
        }
    }
    FallBack "Diffuse"
}
pure vapor
#

is it possible to have an object effect the picture behind it with a shader graph?
im p sure but idk what its called and i cant figure it out myself soooooo
(pic is example mockup)

kind juniper
zealous wadi
#

Is there a way to turn a shader\material around?
I have this liquid shader I got from github and as yyou can see its vertical and moves when the model moves, but I would like it to be horezintal (2nd pic, had to flip model foward for this)
Basically just flip the shader 90 degrees foward while still keeping the liquid effect

desert herald
#

The code you pasted is c# responsible for wobbling, not actual orientation of the liquid, maybe paste actual shader code

#

But imo these screenshots are alright. I mean I'm not sure what you want to achieve. Flipping liquid surface around 90degrees will give you not natural results, unless that's what you re looking for

zealous wadi
zealous wadi
#

But now that I think of it all of the bottles are as one big mesh so that could be the issue

desert herald
#

Probably, yeah. It looks like the angle is based on world orientation so ig it would be easier to make a new shader for your specific needs

zealous wadi
#

Alright thank you^^

gritty sand
#

Hey folks, fairly new to Unity, and hoping I'm going in the right direction here. I have a render texture I'm generating, and then sending out via a plugin as a network stream. However, for some hardware reasons, I need to send a different resolution over the stream, so I need to scale the texture. What I'm looking at doing, and want to confirm I'm understanding correctly, is that I should be able to use Blit to copy from one render texture to a new render texture, the new one being scaled. Just want to make sure I'm chasing the right rabbit before going fully into the rabbit hole 🙂

gritty sand
nocturne hill
#

My shadergraph shader stops working when I enable a second camera. I assume it's because the Screen Position node either doesn't know which camera to use or uses both of them. Any ideas on how to fix this?

#

The shader still works in the scene view with both cameras enabled and in play mode. Just not not in the game view.

nocturne hill
#

So I just used a technique called "Change random settings until it works"
The problem got fixed when I disabled the depth texture and opaque texture on the second camera.
This probably wouldn't be a good solution if you wanted the second camera to render the scene the same way the main camera does but fortunately for me the second camera is just part of another shadergraph and doesn't need to render the scene.

waxen ridge
#

Hello, I am trying to create an inky blob effect for the background of the items in my game.
This shader is added to a material which is added to the Image component of a gameobject which lives on a canvas.
The sahder is Sprite Unlit.

The problem: It looks perfect in the Main Preview window of the shader graph.
When applied to my Image component / canvas element though, it looks like there is no gradual transparency, but a clear cutoff. I can modify the alpha clipping threshold in the shader as I wish, it makes no difference.
Any ideas why?

#

This is how I add my material with the shader, and this is how the shader itself looks like:

grizzled bolt
hushed silo
#

if you think about a game like command and conquer, where you have fields of resources that collectors go and get... I assume back then this stuff was held in tile properties or something, for how much, collectors decision making and stuff, could it be worth figuring out a way to do all of that kind of stuff in compute shaders somehow? like... would there be a tangible enough speed benefit there or would it all just clog up and be unhelpful.. like a procedural texture2d could represent distribution and quantities in a 'grid', perhaps checking that data to determine where to mine, adding and removing pixels etc. without managing thousands of gameobjects

tacit parcel
# hushed silo if you think about a game like command and conquer, where you have fields of res...

I dont think you actually need to manage thousands of gameobjects, except, maybe the unit.
the field resource are treated as tiles just like you said, and the resource collection only change the tile data, which doesnt need to be changed often, and that usually only change at limited number of tiles. Now using compute shader might indeed will clog up the system, as shader will always get executed, for every texel drawn.

hushed silo
#

right... it's just a 2d array of data... I guess in my head i've been thinking a bit about visual representation as well, and projecting a data texture through the shader could visually blend resources in and stuff, but there'd be better ways to do that I'm sure

grizzled bolt
#

Techniques like compute shaders and multithreading are leagues ahead of that both in efficiency but also in complexity so to utilize them well it's important to understand what's possible without them

hushed silo
#

And so, if it’s a 2d grid / array that represents the resources, how about when it’s on 3d terrain? It’s an array of 2d objects and the resource quantity and height are each stored each object? (I guess i was thinking that the rgba of a pixel would nicely store x y z quantity)

stone mantle
#

hey! im not sure if this is the right place to ask but here i go, my friend made me a shader graph for a meteor effect, it seems to work just fine in the shader preview and when looking at the material icons it looks fine, but when put into the scene its just all blacked out, its just the base colour and none of the emission from the custom shader graph is being applied, any idea why, been stuck on this for ages.
here's what im using if important:
Windows 11, HDRP, Unity 2022.3.9f1 (need to be on this version for this project) and whatever <DX11> means

#

what i mean by working in material previeew but not in scene

waxen ridge
grizzled bolt
fast shore
#

What does this mean?

#

What exactly makes a shader support and not support skybox rendering?