#archived-shaders

1 messages · Page 104 of 1

keen bay
#

im not very good with shader, can anyone tell me why this glass material let me see through wall?

eternal kestrel
#

ok today is not my day. How do I make this gradient horizontally wavy?

#

I'm drawing a complete blank for some reason

#

like I practically just wanna apply a sine curve to that line

eternal kestrel
#

ok I sorta managed it, am I overcomplicating this?

eternal kestrel
#

I deleted a node connection and unity crashed bruh

eager folio
#

What is the end goal?

eternal kestrel
#

ok so, what's the name of a sine wave that's completely comprised of straight lines

#

essentially, I want to make this effect spiky

#

oh I found out there's a thing called a sawtooth wave and it looks pretty much like what I'm trying to achieve

#

oop yeah that's it, problem solved

untold forge
#

Hey! Im using unity 2022.3.30 URP. I want to make a basic image effect shader. I did this a while ago with no issues but cant seem to get it workig now, how can i implement it? Dragging it in to the full screenpass renderer feature doesnt do anything... onrenderimage doesnt do anything... do i need my custom scriptable renderer feature to blit the screen or what? My shader is in CG
Figured it out.

hot brook
#

Hello there, I'm trying to change the code to use a gradient and blurring it instead of a texture for a toon shader in Shader Graph URP Unlit

#

this is my current setup

#

I would like to use a Sample Gradient, blurry it a little bit and then use it the same way but it does not receive the same params as Sample Texture obviously

supple cove
#

hey, does anyone here know how to use materialPropertyBlocks? I have an object and want to dynamically change its alpha, and i was just testing how the materialBlocks work and i just cant get it to work. I have this test script and it literally does nothing. I will also show you how the material is configured if that helps

regal stag
# hot brook I would like to use a Sample Gradient, blurry it a little bit and then use it th...

Gradient objects can't be exposed to the material and usually already blend between colours so a blur wouldn't be needed - and is an expensive operation anyway.
You'd be better off keeping it as a texture. If the problem is those are harder to create, Can probably find editor tools/C# scripts shared online to generate textures from a gradient from unity's inspector / custom editor window.

regal stag
abstract dagger
#

Hello guys, I need to generate a simple depth map in HDRP. I have a script that screenshots the scene. Anything in the docs about this? What is a good way of doing so?

supple cove
regal stag
supple cove
regal stag
#

Idk, maybe more memory but I doubt it would affect performance that much

supple cove
hot brook
#

How does skinner mesh works? Is there a way to use both textures in order to make an unlit shader based on that textures?

#

i tried blend node but with no success

#

if i put base color, only the head texture for example is drawn in whole 3d model and i dont want that

regal stag
# hot brook

The mesh has two submeshes, so you need to assign two materials. You should use a Texture2D property and connect that to the sample node. Then each material can have the appropriate texture assigned

hot brook
#

the thing is that i'm doing a Outline color material which is drawn on top of the material using Render Objects

regal stag
hot brook
#

so i have to do two materials and stack them on top is the only way?

stoic flint
#

how is this even possible to render? anyone got idea?

regal stag
stoic flint
#

how do they render that realtime ?

ebon basin
hot brook
#

is there a way to cast shadows in unlit shader or lit shader in a way that only effect other objects and not itself? This is because I'm doing toon shader but I want the object still project it's shadow on the floor in some way (don't matter if manually or lit)

ebon basin
#

Depends.

#

Do you want shadows to affect the object at all?

hot brook
#

I only use Main Light Direction for the light computation in the unlit toon shader, but there's a bottom material which is drawing the textures which I change it to unlit in order to avoid it drawing the shadows of itself

ebon basin
#

Well, if you want an unlit shader with shadows you'll need to make a custom unlit and add the shadow libraries to it and the method calls

#

As for self-shadowing, you can turn off receiving shadows completely which would eliminate that but you won't be able to receive other shadows. If you do want to cast shadows and prevent self-shadowing while also recieving shadows, then there's some juggling with the renderer layers (light layers / shadow layers) you'll need to reseach into

hot brook
stoic flint
#

so do u not need more memory?

#

also, in the video, the foot ik reacts to the very fine details

ebon basin
#

They're different chunks of meshes that are loaded at different times. Tesselation mapping / heightmapping helps reduce the overall cost of these meshes as it can be stored as a texture

stoic flint
#

and the cost ?

ebon basin
#

Most detailed chunk is rendered close to the camera, but those far back are using a lesser LOD that's less complex but because of shader magic it can appear complex

stoic flint
#

ah u mean the far things get the low mimaps of the displacement map ?

#

i get you

#

but its still very expensive to render such high count of verts

#

still

ebon basin
#

Stuffs actually pretty advance nowadays it might not even be chunking doing some advance texture streaming and mesh deformations

stoic flint
#

such as what

ebon basin
#

take a look into parallax mapping too, it's a pretty cool technique to fake tessellation when you further away

stoic flint
#

yea ik about it

#

not used here though

#

shadows appear really well at fine details from distance

ebon basin
#

really it's just all textures and interpolating the surface area between a handful of verts

stoic flint
#

@ebon basin idk about tesselation, i get pretty horrible results with very high vert count

#

maybe you mean sth else?

ebon basin
stoic flint
ebon basin
#

It very much covers what I've said. Obviously it can be expensive but the article goes through different ways to lessen it through various methods

woeful breach
eternal kestrel
#

tyvm lmao

#

nvm it's a pain to implement in urp

#

hdrp has a tessellation node for shader graph but urp doesn't that's super annoying

#

ok so to confirm because I'm a little iffy on something

#

- sorting priority means that material gets rendered before others and + means it gets rendered after right?

teal lynx
#

Why is this making my object black instead of flipping it's color?

#

!code

echo moatBOT
teal lynx
kind juniper
halcyon plank
#

Anyone might know why this is facing the wrong direction instead of at the camera

humble geyser
stray gorge
#

how can i get tex_texelsize in a hlsl function without passing through parameter ?

zinc sequoia
#

Hey, does anybody know how to get APV data in the shader graph?

#

Baked GI doesn't return anything

#

in this case

stray gorge
zinc sequoia
#

im sorry you misunderstood me

#

what i mean is

#

the baked GI node in shader graph never shows anything other than black

#

i just want to access the data baked by APV

hearty obsidian
#

say I have global colors A, B, C. Is there a way that a single graph can point to any of those based on a per-material instance parameter?

#

e.g. different instances of materials of the same shader could point to either A, B or C depending on an exposed parameter

regal stag
# hearty obsidian say I have global colors A, B, C. Is there a way that a single graph can point t...

Could pass those global colours into shaders using an array via Shader.SetGlobalVectorArray, though may need to take into account colorspace differences - (by using .gamma on the Color object on the C# side iirc?)
In graph would use an exposed float property, as input to a Custom Function node to declare & index that array. https://www.cyanilux.com/faq/#sg-arrays

But tbh, if you're exposing a parameter anyways, kinda feel like you might as well just expose a Color one. If you really need global colours can probably find a way to handle that on the C# side instead and set the color property with material.SetColor(...)

glacial lantern
#

Hey has anyone experienced this before? This white glow and black mesh is happening with any shaded material? This object was generated with code and it does not happen with normal meshes like the cube or plane. Is there some normals or uv thing that causes this effect?

#

ah ok it seems to be a normals issue. Im setting all normals to 0 by default, I guess for now I set to up by default should be fine, I wsn't ready for having normals compute yet in my code so yeah nvm

amber saffron
glacial lantern
grim bridge
#

I don't know if this is the right chat for this but why do i get these artifacts when calling this function?

    void SetMaterialOnce()
    {
        Texture2D tex = img.sprite.texture;
        
        //tex.Apply();

        material.SetColor("_Color", color);
        material.SetFloat("_Radius", radius);
        material.SetFloat("_Blur", blur / 10f);
        material.SetFloat("_Alpha", opacity / 100f);
        material.SetTexture("_MainTex", tex);

        RenderTexture rendtex = RenderTexture.GetTemporary(tex.width, tex.height, 0);
        Graphics.Blit(tex, rendtex, material, 0);

        _shadow_img.texture = rendtex;
    }
#

The shader does gaussian blur and works as you can see, but those artifacts idk where they come from.

low lichen
#

Well, there might an issue with using a temporary render texture and then keeping it around for a long time. If you need to use this texture for a while, you can't use a temporary texture.

hushed silo
#

i'm trying to do some basic lighting stuff in an amplify graph. specifically i am looking to sample a triplanar normal map from a light position to get a bit more depth in my material.

#

outputting the result is getting me diagonals through world space

#

here's my triplanar settings

#

any idea what I'm doing wrong?

#

logic is (or should be) normalize(lightpos - worldpos) , dot producted with the world sampling of normal map

low lichen
hushed silo
low lichen
#

Oh, you're talking about the angle of the shadow. Sorry, I was looking at the microdetails.

hushed silo
#

yeah, thanks. I think it's not a shadow either, just the result of some maths i don't undestand (this is on unlit shader)

low lichen
#

It's the shaded part of the basic Lambert lighting function you are doing (NdotL).

hushed silo
#

hmm. So it's trying to be from a point, rather than a direction, and has no distance sampling atm, so I don't know how its deciding that everything off that way is 'behind' so to speak

#

(the light position is in the middle of the room

low lichen
#

I think the problem is that you're expecting the Triplanar Sample node to return a world space normal direction, but it might just be returning the blended normal maps in tangent space. Could you try connecting the output from the Triplanar Sample node directly to color just to see what it looks like?

hushed silo
#

this is set to tangent space output

low lichen
#

Ok, the normal seems fine. Let's try visualizing the light direction after normalizing.

hushed silo
low lichen
# hushed silo

Looks a bit strange. Are you hardcoding the position of the light in the shader? Or is it a property assigned from script?

hushed silo
#

from script with . it works fine for other aspects of the shaders lighting that i've already done

grim bridge
#

Also here is what i get if i do Graphics.Blit(tex, rendtex); instead of Graphics.Blit(tex, rendtex, material, 0);

#

This is why i think this overload of blit Graphics.Blit(tex, rendtex, material, 0) does something wrong with shaders.

#

And I tried running the scene on a friend's pc with Windows but he has the same result.

low lichen
grim bridge
#

yes and i fixed it

grim bridge
grim bridge
#

@low lichen I dont mean Ifixed my issues btw 😅 it's still there

low lichen
grim bridge
low lichen
grim bridge
#

i used a shader graph, so there is a lot in there that is not me

low lichen
grim bridge
#

ok

grim bridge
low lichen
low lichen
grim bridge
low lichen
#

Just see if it changes anything.

grim bridge
#

🥲

low lichen
# grim bridge 🥲

I'm going to assume that means it didn't change anything. What type of shader graph is this? Unlit? Fullscreen?

grim bridge
#

unlit

#

also it's a 2d project so, maybe...

#

and i am using unity6.0

low lichen
#

Maybe try fullscreen, see if it does anything. You won't be able to use it on objects in the scene like now, only in the blit.

grim bridge
#

id't get it

low lichen
#

Change the shader type from Unlit to Fullscreen, in Graph Settings.

grim bridge
#

dude...

#

@low lichen|| WASSUP||

#

Omg thanks bro, how do you explain this?

low lichen
#

I don't know where those artifacts were coming from, but usually blit shaders are written a bit differently from shaders intended to be used in the scene. Unlit is for scene objects, Fullscreen is for blit shaders.

#

The graph type is just a different template Shader Graph uses when it converts your graph to shader code. Fullscreen has the right code for a blit shader.

grim bridge
#

thks

hardy juniper
grim bridge
#

yes, you mean in the custom fonction or directly in the graph? @hardy juniper

hardy juniper
#

where ever the sampling is done for the blur, the pos has to be clamped into the sprite uv region (you annoyingly have to add the uv min max range yourself)

grim bridge
#

is there a node for this? or is it hlsl

hardy juniper
#

can be done on either with min() or max() or clamp()

#

the point is to stop it sampling another sprite outside the sprite range

grim bridge
#
float2 sampleUV = uv + offset;
if (sampleUV.x < 0.0 || sampleUV.x > 1.0 || sampleUV.y < 0.0 || sampleUV.y > 1.0)
    continue;

fixed it thks

hardy juniper
hearty obsidian
# regal stag Could pass those global colours into shaders using an array via [Shader.SetGloba...

Thank you!

For the latter, I'm trying to dynamically test color schemes and I have tons of stuff creating instances of materials. If I change a color after the instantiation, then those instantiated materials aren't accounted for. Whereas if I use global vars, then instances or not, they're all pointing to the same location, making it a breeze without having to implement an event system across the board and without having to reference the materials anywhere.

grim bridge
# hardy juniper You want to avoid if which is why we prefer min, max and clamp I don't know eno...
void GaussianBlur_float(float2 uv, float radius, float blur, UnityTexture2D tex, float2 texel_size, UnitySamplerState samplr, out float4 result)
{
    if (radius == 0.0 || blur == 0.0) {
        result = tex.Sample(samplr, uv);
        return;
    }
    float4 color = float4(0, 0, 0, 0);

    float total_weight = 0.0;
    int kernel_size = int(radius * 2) + 1;

    [loop]
    for (int j = -1 * kernel_size; j <= kernel_size; j++)
    {
        [loop]
        for (int i = -1 * kernel_size; i <= kernel_size; i++)
        {
            float2 offset = float2(i, j) * texel_size;
            float2 sampleUV = uv + offset;
            if (sampleUV.x < 0.0 || sampleUV.x > 1.0 || sampleUV.y < 0.0 || sampleUV.y > 1.0)
                continue;
            float weight = GaussianWeight(i, j, blur);
            //float weight = GaussianWeight2D(float2(i,j), blur);
            color += tex.Sample(samplr, uv + offset) * weight;
            total_weight += weight;
        }
    }
    result = color / total_weight;
}
hardy juniper
#

Yes that's a shader alright

candid tree
#

im making a shader thats try to recreate an doom billboard sprite with a spritesheet.
someone know how to make this shader cast/receive shadows?

cobalt wing
#

Guys i want create the grid of XCOM, how i can do it?? I don't understand nothing of shaders

stray gorge
#

how can i keep this lighting effect from value bigger than 1 in game ?

gloomy fractal
#

is it possible to randomly scale the height of my grass

#

rn they have all same height but i wanted to add some variation by randomizing the height of the model

grim bridge
#

I don't get it, this is so frustrating

low lichen
# grim bridge I don't get it, this is so frustrating

You could try clearing the texture before blitting to it. The blit should be overwriting the whole texture, but maybe it's not for some reason.

To clear the texture, after setting it as RenderTexture.active, call GL.Clear(true, true, Color.clear);

grim bridge
low lichen
#

Right, I was looking at the code fix you posted. You'll have to also set it as the active render texture before the blit, so you can clear it.

grim bridge
#

GREAT, now it works, what is happening!?

low lichen
# grim bridge <:notlikethis:1068134558123442236>

I see a potential issue with your gaussian blur function. In the end, you are doing this:
result = color / total_weight;

If total_weight is zero for some reason, you will be dividing by zero, which is undefined.

grim bridge
#

hum...

#

ok ok

low lichen
#

Whether total_weight can be zero depends on what GaussianWeight returns.

#

As a test, you can try ensuring you never divide by zero, by setting result to zero if total_weight is zero.

cobalt wing
#

Hey guys, sorry to interrupt your discussion, but I need some advice. If you take a look, the black borders seem a bit glitched because of the screen resolution. I wanted to see if Shader Graph could solve this issue. Do you think it would look better if I used shaders instead of the sprites I'm currently using?

grim bridge
#

Maybe PP can solve it

#

@low lichen the thing has been rendering smoothy for a lot of build now. idk even know what solved it

cobalt wing
#

what is PP

grim bridge
low lichen
#

You can check if mip mapping is enabled on those textures and enable it if not.

#

Mip mapping generates lower resolution versions of a texture and automatically picks the best resolution depending on how far away it is from the camera.

ebon basin
gloomy fractal
#

is there a way to random 2 colors for my grass?

#

it looks boring when the grass always has same color

cobalt wing
#

Not using sprites and instead switching to Default with mip mapping enabled seems to have worked. I don't think I'll dive into shaders for now. I'll just use different textures for each tile. Thanks for the help!

dense bane
#

did cubemap from refprobes change in unity 2022 compared to 2020?

stray gorge
steel notch
#

Hey sort of confused with something here. I have a basic flow map shader set up here. I am giving the shader a texture that has 0.5, 0.5, 0.5 in all channels, and yet I am still seeing movement.

#

I am using the UVFlowMap node included in Unity's Shader Graph Feature Example package, so I'm assuming the implementation is correct?

steel notch
#

Is this a float accuracy issue?

amber saffron
#

(or maybe you've imported it in RG format ?)
Also, double check that sRGB is disabled in the texture import settings 😄

grizzled bolt
#

Flowmaps only need RG don't they
If the texture is sampled as a normal map it probably should also be imported as a normal map

amber saffron
# steel notch

That graph doesn't seem to do the 0:1 to -1:1 remapping, so you might need to do it before

grizzled bolt
#

I assume sampling as type: normal should do that also?

amber saffron
#

(there shoud be a usage exemple to compare to)

amber saffron
steel notch
#

So the texture that came with the Feature Example package was this.

#

and this is the demo shader

amber saffron
steel notch
amber saffron
steel notch
#

Is the Unity sample implementation here wrong?

amber saffron
steel notch
#

which would actually produce a very slight movement

#

ya?

amber saffron
#

Yep, if your middle value is 128, it is slightly positive, so makes movement.

steel notch
#

jesus christ it all goes back to the 1970s

amber saffron
#

You could easily "hack" away this by doing some filtering on the flow map value though.

steel notch
#

...is it subtract by 0.0039215686274509803921568627451

grizzled bolt
#

I can replicate the issue, 128 color values tug one way and 127 to the other
But how much is relative to strength and compression
At the default 2 strength it's not noticeable to me, even at low compression

amber saffron
#

Something like the following should nullify the imprecision
v = v * saturate( abs(v) * 128 )

steel notch
#

Said there was a slight ghosting on a small element.

#

Had to zoom in to notice it.

#

And now I'm down the rabbit hole.

steel notch
amber saffron
#

saturate( abs(v) * 128 ) gives a 0:1 mask of the imprecision around the 0 value, and applying it to the flow value will force it to 0

grizzled bolt
amber saffron
#

But 128/255 seems more correct to me.

steel notch
#

I don't think just subtracting 1/255 works I just kinda blurted that out. What's gonna happen is that you're going to get either a -1/255 or a 1/255 value when it SHOULD have been 0. So any values in that range need to be clamped to 0.

#

Actually, is it even standardized how programs handle a 0.5? Will some round up when mapping it to the 255 range?

#

Wait... does this mean that Normal Maps also have this problem? That the default value is actually slightly tilted because we can't get true 0.5?

grizzled bolt
#

Yea, in a real world scenario you'd have values roughly around 128 in places where the flow intensity is meant to be generally the lowest so subtracting causes a bit of a jump between 128 and 127
Tbh usually flow maps don't need to be that precise because the whole thing will be flowing

steel notch
grizzled bolt
#

Might want to lerp out the effect entirely in another step

steel notch
#

I had a picture of a ship on some waves and wanted the waves to move and the ship not to move.

grizzled bolt
#

Or map the flowmap to a curve so it becomes proportionally less intense around mid/0, and more extreme at the ends of the color range

steel notch
#

Do you guys have any good tools for making Flow Maps btw?

grizzled bolt
amber saffron
grizzled bolt
#

Quite!

steel notch
#

I'm okay with doing a small clamp on the flow map to gt rid of hyper small values though.

#

Jesus what a world.

grizzled bolt
#

The ship and other objects separate from the background could also be geometry, with vertex colors or an atlased flow map if you need to get funky with it

steel notch
#

wait it would actually be values -1/512 an 1/512 right? Because it was the midpoint between 127 and 128, rounded to one of them, and then remaped to 0 to 1 when we're in shader land

#

So...

v = abs(v)
v = v * step(threshold, v)

I think?

#

Otherwise you do some branching stuff.

amber saffron
steel notch
#

Ah true so just
v = v * step(threshold, abs(v))
right?

karmic roost
#

hello, ive spent forever hours trying to fix this but i just can't get it to work. does anyone know what is up with my normals? please ping me. Using URP

grizzled bolt
grizzled bolt
karmic roost
#

i assume

grizzled bolt
#

Could show them

karmic roost
#

its the almost purple textures

#

usual normal maps

grizzled bolt
#

With the import settings

karmic roost
#

sure give me a minute

#

@grizzled bolt there is in fact no normal texture plugged in

stray gorge
#

2d tree overlay shader, any tip for hide the trees behind the moutain ? (trees and the terrain currently are 2 object). The trees is just a plane

grizzled bolt
karmic roost
#

it would just be

#

a plain texture with no bumps

#

but the lighting issue persists

#

do you want me to show you the shader graph nodes¿

hushed silo
#

Is anyone able to tell me why the output of the highlighted node here

#

puts diagonal lines through my mesh? I'm trying to get a reaction from a point light to the normal map

grizzled bolt
karmic roost
#

how can i add a neutral normal? i didnt even know that existed

#

also this is happening
this material DOES have a normal map yet:
there is visible normal map stretching
weird jittery texture in those edgfes (i made sure there are no overlapping faces)
same angle shadow

grizzled bolt
karmic roost
#

i got the node settings here

grizzled bolt
hushed silo
slate wasp
#

I need some help with my 3D model, it doesnt appear to be culling properly, If i look at it from like a whole direction (lets say south) the model dissappears completely. I have to be looking at it from the North to be able to see it.

hardy juniper
hardy juniper
#

Hmm first thought is that it has bad bounds making it be culled too much

low lichen
#

The bounds of the skinned mesh renderer is probably incorrect.

hardy juniper
#

snap!

slate wasp
#

Goddammit, for some reason the Bounds are in the Origin coordinates while my model is moved. But if i move the model it messes with the positions of various things in the heriarchy

#

ok what is going on, if i move my 3Dmodel anywhere the Bound won´t follow!

slate wasp
#

Yeah there is some kind of problems with the bounds

slate wasp
#

Alright solved it by checking the "Update when Offscreen"

serene condor
#

hey, so i see that HDR colors aren't an option in sub shader graphs, is this the correct implementation ?

#

i see mixed discussion whether its the alpha channel is used as intensity multiplier, or if the raw vector values are just presented (like 5, 5, 5, 1). if i were to route in an HDR color into the "Emission color" input would this work the same as the standard emissive component?

it looks ok comparing side by side, but just doing a sanity check

fresh flame
#

any ideas where to start implementing this effect? What should I search for? I think it adds an outline to selected grid area? also what about the gradient going upwards

serene condor
sharp mural
#

Hey folks, wondering how I can reduce the reflection on the floor? It's using a simple triplanar shader I created by following a youtube tutorial

#

Not sure if the reflection would be changed on the MAT or inside the shader itself?

eager folio
#

What is it reflecting? Skybox? Light?

grizzled bolt
sharp mural
eager folio
#

Is it a pbr shader?

sharp mural
grizzled bolt
sharp mural
#

Do i just reduce the 0.5 value of smoothness?

grizzled bolt
sharp mural
minor remnant
#

How would I sample a texture that's set by CommandBuffer.SetGlobalTexture()?

#

I cant for the life of me find how to access it in a shader after setting it

hardy juniper
fresh flame
#

I'm trying to keep edge line same size regardless object size, what am I doing wrong here?

amber saffron
steel notch
#

Keywords literally create shader variants right? Does that shit scale exponentially? Like if I have 1 boolean keyword, that's 2. If I have 2 keywords, 4 variants? If I have 3 keywords, 8 variants etc etc.

amber saffron
steel notch
steel notch
#

So I was thinking about how to best set this up from an optimization perspective (why do all this work in cases where some of the effects aren't needed?) and a clean inspector so all the fields don't become a mess.

frosty linden
#

Hello, I'm trying to create a HDRP lit layered shader graph with alpha mask being in one separate texture property each instead of one packed texture so I can tile and offset them individually.

#

I don't understand how I'm supposed to use the branch node if I add more layers

#

Plus it also seems like I need to create branches for each of my values (color, ao, normal...) which is a lot of branch? Or am I missing something?

frosty linden
#

Ok nevermind, I've added the branchings directly inside the sub graphs, so 5 different branching (I'm using alpha from main layer as global alpha so no need branching for this property). I think that should be the normal way to do that. If there's a better way to handle branching, let me know.

amber saffron
# steel notch So I was thinking about how to best set this up from an optimization perspective...

Keywords are good for really stripping code of the shader but create variants as you know.
But sometimes, for enabling or disabling a feature a constant float value is enough. Use dynamic branches in the code (if(f > 0)) to toggle the feature, and because the float value is constant on the material, only one branch is evaluated. But it doesn't result in multiple variants.

As for the clean inspector, either write a custom inspector, or use something like shadergraph markdown to have more UI options

GitHub

Markdown-like syntax for ShaderGraph properties, to make better material inspectors - needle-tools/shadergraph-markdown

amber saffron
steel notch
amber saffron
#

Branches are bad when the different branches of a same condition need to be evaluated in a single wavefront (screen space pixels group, 16x16 or 32x32 iirc).
IE, when you use screen space noise to select between branch A and branch B. In that case the gpu group can properly optimize which branch to use for all pixels of the group, and needs to evaluate both for every pixel.

But is you use a constant value on the material for the branching, it knows that all pixels within a single group either use branch A or branch B, and can then only evaluate a single branch, without running the other one.

#

And yes, this also applies to shadergraph

hardy juniper
# frosty linden

The branches should be controlling if only 1 layer is used OR if layer 1 and 2 are combined (e.g. by a mix/lerp). This will repeat till you have all layers combined (e.g. 1+2 combo combined with layer 3 ect)

humble geyser
#

where are these patterns coming from? I get them when trying to use normal from height in shader graph (for a height/displacement map)

frosty linden
frosty linden
#

And if the enum is set to one layer, then the 3 other layers won't be processed at all, making it more efficient, is that correct?

frosty linden
#

My current sub graph is like this, the branching for each property is inside and I'm currently using a float for the number of layers. But this way, all layers are processed which is inefficient if I understood correctly?

#

The only way to make it efficient is to use a keyword then?

#

(I've been using the lit mask map as my default albedo since I only use greyscale, and I put my grayscale albedo inside the mask map blue channel, replacing the details map which I don't need

amber saffron
strange prairie
frosty linden
#

Are all layers still evaluated even with the keyword ?

amber saffron
#

If you want to squeeze even more performances, you might be interested in this layer packing technique : https://unity.com/blog/engine-platform/experimenting-with-shader-graph-doing-more-with-less

(also, I find it suspicious that you are using overlay blend between the layers)

Unity

You can improve the runtime efficiency of your shader without sacrificing the quality of your graphics by packing physically based rendering (PBR) material information into a single texture map and layering it into a compact shader. Check out this experiment.

abstract dagger
#

I'm trying to get a depth map from a screenshot that I take in game. How do I do this in Unity 6.1?

frosty linden
#

I haven't tested my shader yet actually, I was just assuming the default lit layered was already using overlay blend since it's the default option

#

Thanks for the link

kind juniper
frosty linden
#

That was an interesting read. The dual color ramp method is actually a huge plus for grayscale albedo. I'm amazed by what people can think about to optimize stuff.

abstract dagger
kind juniper
abstract dagger
#

hm. to be consistent I think i'd rather add the pass through the render graph. So I'm guessing I can trigger the render graph to apply the depth map shader and then save it? sorry if im asking too many questions

kind juniper
#

I can tell you how that would work from the graphics API perspective:

  • you bind the render texture render target to the pipeline
  • bind whatever buffers and textures you need to the pipeline
  • record a draw call with the specified shader that would draw the depth to the render target.
    Done.
abstract dagger
#

hm. ok thank you for your help. i will have to go more in depth

steel notch
#

Like if I expose a float in the inspector. Is that a constant? What if I do operations on it before throwing it into a branch node?

humble geyser
cosmic thorn
#

Is anyone else experiencing the shadowCaster bug with unity 6?
the compiler for me just gets stuck on compiling the shadowCaster and prevents me from testing my game.

amber saffron
regal shuttle
#

This here seems to be the place for culling issues. I believe my issue is simple but I still struggle with it. I'll have a video about it later (I'm short on time right now.) I'm actually working on a world for a game called VRChat but I think my issue is just basic / general enough. I'm tweaking Occlusion in my world and as you can see in my lil camera view, some things are not showing up. I did select very small object sizes, so those cubes should appear... even if they were too small, the big, darker box should definitely show up. I'm not entirely sure what's causing this issue. I can try smaller and smaller objects culling but it doesn't see to be the fix? Oddly enough, depending on where I'm looking, even if I'm right next to the button, sometimes they appear, sometimes they don't

amber saffron
fresh flame
#

okay then it didn't work 😄

#

thanks though

#

sec

#

yeah its working, got another issue. thanks a lot!

cobalt idol
#

hi!

is it possible to use tessellation in URP?

and is it valid to use URP in 2025 anyway for a pc game?

I hate shader graph so much I just want to write my shaders but it seems URP is really limited and HDRP more or less demands using the shader graph?

amber saffron
# cobalt idol hi! is it possible to use tessellation in URP? and is it valid to use URP in 2...

is it possible to use tessellation in URP?
Technically, yes, if you are willing to hand write your shaders

and is it valid to use URP in 2025 anyway for a pc game?
Yes, even more if you plan on releasing on more platforms, aim for more stylized graphics or higher framerates. But you don't have as many features provided out of the box as in HDRP.

I hate shader graph so much I just want to write my shaders but it seems URP is really limited and HDRP more or less demands using the shader graph?
Is it still possible to hand write shaders with URP and HDRP, but it is drastically more complex than in built-in because there is not equivalent to surface shaders.

minor remnant
#

can someone give me a monkey brain example of how to use Graphics.CopyTexture with a CubemapArray? the docs only go over how to use the SetPixels() method

low lichen
minor remnant
#

I want to save reflection probe cubemaps to a CubemapArray so I can access them in any shader

#

basically sidestepping unity_SpecCube0 so I can sample multiple probes at once

low lichen
#

It's definitely possible to copy one face at a time into the array, can't find confirmation whether you can copy a whole cubemap in one call.

minor remnant
#

my current code is along the lines of

CubemapArray reflectionProbeArray = new CubemapArray(2048,8,TextureFormat.RGBAHalf,true);

///...

    void SetupReflections(CullingResults cullingResults)
    {
        NativeArray<VisibleReflectionProbe> visibleProbes = cullingResults.visibleReflectionProbes;
        if(visibleProbes.Length>0)
        {
            for(int i=0; i<visibleProbes.Length; i++)
            {
                VisibleReflectionProbe probe = visibleProbes[i];
                Graphics.CopyTexture(probe.texture,0,reflectionProbeArray,i);
            }
        }
    }
low lichen
#

All the cubemaps must be the same size and be a compatible texture format to work with CopyTexture.

#

I think you may also have to copy each mipmap individually.

minor remnant
#

rn im just prototyping so I dont necessarily need mipmaps

#

CopyTexture seems to throw some error about Graphics.CopyTexture called with null source texture

heady osprey
#

hey first time working with shaders so I don't know what I'm doing, I want foam where water intersects with objects, but isn't this supposed to be showing on the water surface, instead of on the object it's intersecting? 😅

primal spruce
#

Does anyone know if its possible to fix this distortion? Or at least make it so that the side without distortion faces the camera?

#

I can take closer sc for anybody who need them that shader graph is very hard to see

teal lynx
#

!code

echo moatBOT
teal lynx
#

I'm trying to understand how renderer features work(URP). Here, I full screen pass renderer that's taking in a material named "temp" with a shader named "temp". This should make the whole screen white, but it's not and I'm not sure why. Here's my shader code although I doubt that's relevant:
https://paste.mod.gg/cxwfgmahmvtb/0

teal lynx
regal stag
molten pike
#

How do make my textures not pink?

teal lynx
molten pike
#

I know its a broken shader, i need help fixing this

hardy juniper
molten pike
hardy juniper
primal spruce
ebon basin
primal spruce
#

worth noting that I'm trying to avoid UVs by putting the world position into the UV input for the noise

#

because UVs will always have a seam

ebon basin
#

usually I just use like local/world uvs for spheres if I'm just doing noise to get around the wrapping issues with em

primal spruce
#

yeah thats what I tried but it produces that weird distortion around the x axis specifically

ebon basin
#

but if that's what you're doing then carry on, just can't make out from the graph there lol

primal spruce
#

ahh lol, here are some better sc

ebon basin
#

Ah, yeah my shaders do still have somewhat a seam even with world UVs for the unity sphere, so there's probably a bit more to it

primal spruce
#

actually that gives me an idea, let me try a non-unity sphere and see if that works

#

better yet, I'll import a quadsphere so that the UVs can be even better

#

since I'm doing position I doubt it will change much but still

ebon basin
primal spruce
#

oh damn, I'll have to take the time to read through that later

#

bruh now it just stretches on the z axis

torpid vault
#

Quick question for anybody who knows about optimization tricks -
what is the performance difference for wrap mode? Clamped vs Repeat?
I was just recommended to do an operation inside of an HLSL shader as opposed to setting the texture to repeat, citing it is slightly more performant. I'd like to know why / how but google is not giving me the deep lore I'm looking for

kind juniper
#

The "deep lore" would depend heavily on the used graphics API. If you're going with d3d11/12, you should be looking at it's documentation. But there's very little info in terms of performance. Performance is also very context dependent.
If you really want to optimize, you should use dedicated profiling tools, like PIX, Nvidia Nsight(or whatever tool is native for your target platform), maybe render doc.

#

Before deep diving into shader optimization, I'd use the unity profiler to see where the bottleneck is in the first place.

#

Maybe there's a way better candidate for optimization.

crisp radish
#

im not sure if this is the right place to ask this cause i dont even know how you would accomplish this but how would one go about making a texture or shader like the clothes in chowder or stans jacket from monkey island? that thing where it seems like the texture is just a global background that dosnt move when the object its on does. i want to use it on a shirt for a 3d charicter model im making but i have no idea how to gow about it, these are decent examples of what im trying to accomplish https://youtu.be/htGt6frPSH0?t=76
https://youtu.be/STnYDchAn78

Chowder learns that messing with Truffles' game night means certain doom. But he's willing to risk it all for a taste of the Mevilled Eggs she's serving.

Welcome to Cartoon Cartoons!

Dive into a world of nostalgia with Cartoon Cartoons, your ultimate destination for classic cartoons. Relive the golden era of animation with timeless favorites l...

▶ Play video

From the series Stan makes a return as a lawyer. Gotta love Telltale.

▶ Play video
ebon basin
#

Er actually it's a screen position shader

#

Yeah, screen space UVs

crisp radish
#

ah yea thatl work, i think i found some decent tutorials for those. hopefully this goes well, thanks

grizzled bolt
#

When the camera moves, the pattern does not move though

#

Is that important?

torpid vault
# kind juniper Who were you recommended by to do that? These settings just change the sampler p...

in house tech artist that used to work at unity.
I believe him but didnt have time to ask him to go in depth
it's also not an optimization stage. I hit a point where it was "2 options how to fix this development problem: Do an extra step in the shader or modify all our texture import settings" and he said do it in the shader. I'm just curious if there's a well known reason why, and it sounds like not 🤷

frosty linden
#

Hello, using hdrp shader graph, which blend node or similar node do I need to use to stack a texture on top of another, the black color being ignored and the whiter the top layer is, the more it replace the bottom layer texture.

#

Overlay and screen don't see to do that

amber saffron
amber saffron
frosty linden
#

I've got a weird bug in my shader graph. The default value field does not appear at all. It's supposed to be a float. Is it fixable?

#

Even restarting Unity doesn't fix the bug

regal stag
#

(allows you to set a custom name rather than the regular input field - you'd usually use it with the Branch On Input Connection node)

frosty linden
sharp frost
#

How can I use sprite Unlit shader on Overlay UI?

Its coming black.

#

on Screen Space - Camera its working fine but not working on "Overlay".

regal stag
odd wraith
#

I made a triplanar shader for my hdrp project. I found how to add a normal map but I can't find how to add a height map. Are height maps supported by shaders? That's what I have so far

amber saffron
# odd wraith I made a triplanar shader for my hdrp project. I found how to add a normal map b...

The heigh map is either used for :

  • Parallax mapping through the parallax node or parallax occlusion node. But it doesn't work well with triplanar and you might have to do your own implementation
  • Vertex displacement with tesselation, in that case you need to enable tesselation on the shadergraph setting and make the displacement yourself in the vertex stage (position + normal * height)
odd wraith
#

so it would be better if I used vertex displacement right?

amber saffron
#

Probably easier to setup.

odd wraith
#

I put the position + normal * height here?

#

also when you say normal * height normal map * height map or normal map * the depth I want?

amber saffron
#

vertex normal * heightmap value * amplitude multiplier

odd wraith
#

is that a node that I need to activate somewhere

amber saffron
odd wraith
#

thanks

#

Do I multiply these and then add the position

amber saffron
odd wraith
#

It wasn't letting me put the texture in directly

amber saffron
odd wraith
#

so like this do I set it as normal or like this. Also is the position good

amber saffron
amber saffron
odd wraith
#

wdym just attach the multiply immediately?

amber saffron
odd wraith
#

did I select the wrong things?

sharp frost
amber saffron
odd wraith
amber saffron
odd wraith
#

woops

#

It still stayed the same

#

increasing the phong thing

amber saffron
#

Well, should still be ok, the phong tesselation is for smoothing geometry

odd wraith
#

should I send a pic of all the shader graph

#

I might have messed somethng up

#

It's texture on top, normal in the middle and heigh map on the bottom

amber saffron
#

What does the height map look like ?

odd wraith
#

and the textuer on too?

#

wait I had the wrong height map selected let me send a pic

#

it fixed with the normal thing

amber saffron
odd wraith
#

this was the correct height map

odd wraith
amber saffron
odd wraith
#

as in I can choose a value for the depth of the heigh map

#

height

amber saffron
odd wraith
#

so after the first multiply I add the float I had

amber saffron
odd wraith
#

sorry multipy I meant

amber saffron
#

heihtmap value * float height * normal

odd wraith
#

It doesn't seem to be having an effect

#

shoudl I try increase the tesselation factor right now I put it as 4

amber saffron
odd wraith
#

what's a good average number to start the testing>

amber saffron
#

I can't give a magic number here, it can depend of many things.

  • the "minimum triangle size" limits the amout of tesselation for a single triangle isn't smaller than X pixels on screen.
odd wraith
#

so I just put a bunch of random numbers if it gets better I stick close to those numbers

#

and are there any big downsides to having a big number

amber saffron
odd wraith
#

its looking like this?

amber saffron
#

Interesting, it looks inverted. But it's definitively doing something and I can distinguish the heightmap shape here.

odd wraith
#

That's me trying to offset it inwards cause the normal height map that's what it was doing but this one feels off when I go the other way round it offsets the planks in a detached style and in the wrong places

#

I'm trying to mimic the block next to it

#

so I can have an easily tileable version of it

amber saffron
# odd wraith

The "detached style" is expected because the cube mesh has "hard edges" : eight cube face ha a normal pointing in a different direction, so it is "pushing" the displacement along it, resulting in the holes at the edges where each face is pushed in a different direction.

odd wraith
#

yeah that makes sense. That's why I was trying to give a -depth

#

but at the same time it shouldn't be leaving the height map at that point

#

could it be I need to also apply the triplanar to it?

amber saffron
#

Also, the displacement is not matching the color/normal maps because the displacement texture is sampled using the UV, when the other ones are using triplanar.
Sadly, you can use the triplanar node in the vertex stage and would have to recreate the triplanar logic with multiple "Sample Texture 2D LOD" nodes for it to match.

odd wraith
#

true

#

triplanar is a vector 4 tesselation is a vector 3

amber saffron
odd wraith
#

so I create a triplanar from just one value the red as its black and having all the colours and stuff and I attach that to the multiplies?

amber saffron
odd wraith
#

could we multiply the world position with everything?

amber saffron
#

Yes but ... why ?

odd wraith
#

since the swizzle things doesn't work to try to shift the height map according to the world position

amber saffron
odd wraith
#

ye

#

so splitting it didn't work what else could I try

#

recreating the triplanar how you said with the texture 2d lod stuff?

odd wraith
#

do you know how I could do that or should I try looking it up

amber saffron
odd wraith
#

I'll continue looking into it tmrw

#

From what I'm feeling I think I'll need to make 3 uv maps for the z y and z of the texture and then map it out to thst location

frosty linden
#

How do I change the value of an enum keyword at runtime? Do I need to use DisableKeywords on all values of the enum and EnableKeywords on the value I want or do I use SetKeyword?

frosty linden
#

How do I properly colorize my greyscale texture ? When I use a simple multiply, black color will show details but when I use white, details disappear and some barely opaque pixel becomes more visible.

amber saffron
#

The usual manner to "tint" an albedo texture is indeed to multiply with a constant color.

frosty linden
#

This one. But I packed it into the blue channel and I load this packed channel from the streamingassets.

#

And I'm using UnityWebRequestTexture to load it.

yield return uwr.SendWebRequest();
Texture2D tex = DownloadHandlerTexture.GetContent(uwr);```
#

But I remember there was a linear option when creating a texture. It seems like this method of loading can't change it to linear so maybe it's the gamma affecting the result?

hardy juniper
#

it probably presumes the image is srgb (which is usually the case for most imported textures too)

neat orchid
#

Do you guys know any black magic fuckery to make particles meant for unlit shaders to work with lit shaders?

#

I tried several sample lit shaders and they all render my particles as solid blocks

#

maybe it's a transparency issue, I don't know. What should I even look into?

grizzled bolt
neat orchid
#

the particles use flipbooks. There is a flipbook lit shader as well but it behaves the same way

#

I'd assume it's something related to transparency + lighting, but I don't know what do look for

neat orchid
#

shuriken

young mantle
#

I'am new to Unity and i have just found out about shaders this monday. I have found and tried with 5 tutorials but i still can't configure 2D shaders in Unity 6.1 are there any tutorials about how to do it?

neat orchid
# grizzled bolt PS or VFX Graph?

Ok I fixed my issue. When I changed the material's shader to one of the lit ones, the albedo map got cleared. Just needed to assign it

#

now it works but looks kinda cursed, I will attempt to fix that with settings

neat orchid
#

Fixed some of the issues. Seems like the default hdrp particle lit shader has smoothness set to 1 for some goddamn reason and it's not an exposed property

#

can't imagine why

odd wraith
amber saffron
odd wraith
#

And then i take the subgraph for the triplanar copy it and make a new one with the texture 2d lod instead of what it uses

frosty linden
#

Hello, when I change my enum keyword at runtime, the material does update but not the value in the inspector

#

I use this to change the keyword at runtimemat.EnableKeyword("ENUM_VALUE");

#

Is there something I'm missing?

amber saffron
frosty linden
#

Oh ok, thanks a lot

frosty linden
amber saffron
frosty linden
#

Ok thanks

frosty linden
#

My custom shader trying to replicate the HDRP Lit with the difference being the albedo is grayscale and packed directly in the blue channel of the mask map (I don't use the detail mask) but it seems to be struggling with the mipmap. First image is the HDRP Lit and the second one is my shader graph. The cloth gets blurry when it gets far away from the camera which should be a mipmap problem. The HDRP Lit doesn't have this issue. Is there any solution to have better mipmap with a packed texture?

strange prairie
frosty linden
#

But there's only one sampler in my customer shader for the mask map. How can it be wrong?

strange prairie
#

Is this one of those shader graph things?

frosty linden
#

Yes

#

I'm using the same channels as the HDRP Lit mask map. So red is metallic, green is ao and alpha is smoothness

#

The only difference is the blue channel. For Lit, it's used for the detail mask but for my, I use it for greyscale albedo which I multiply by the color then plug to the color of the graph

#

Color, smoothness and AO seem to be working fine as you can see from the images

#

But it gets blurry when the texture gets further away, I think that's related to the mipmaps

#

But there's not option for mipmap in the shader graph so I'm not sure howto fix that

#

It should be the same as the lit

strange prairie
#

Actually not entirely sure if this is correct thinkies

#

That's just the global mip bias.

frosty linden
#

Hm, not sure I understand your reply but is there any fix for this difference ?

#

The lit shader should also use the sampler function shouldn't it?

strange prairie
#

Just thinking it through

strange prairie
#

Should be set to "Standard"

frosty linden
#

Yes it's set to standard by default

strange prairie
#

Does your texture use anisotropic filtering? It looks more like that than a mip issue tbh.

frosty linden
#

This is my mask map texture

#

But both the lit and my shader graph use the same texture

#

And lit also use the greyscale albedo in a separate image

#

Which I packed into the blue channel of the mask map for my shader. It should be ignored by the lit since I don't use a detail map

strange prairie
#

Alpha is set to "none"

frosty linden
#

Yes, this is a packed texture. it has no alpha

strange prairie
#

Can you set the aniso level to the maximum value?

frosty linden
#

Ok

#

Hm, no luck, same result. Texture gets blurry only on my shader when far away from camera

frosty linden
#

I've tried another simpler shader graph with my mask texture and this blurry bug doesn't occur so there must be some node issue in my complex shader. I'll look into it

frosty linden
strange prairie
#

That just turns mipmapping off

hardy juniper
#

mip maps + tri linear filtering should be making something look blurry at a distance, thats the whole point

#

ofc not crazy blurry but enough to look natural vs shimmer

frosty linden
hardy juniper
young mantle
amber saffron
strange prairie
harsh marsh
#

what's the equivalent to godot's MODEL_NORMAL_MATRIX in unity?

It's described in Godot's documentation as

Model/local space to world space transform for normals. This is the same as MODEL_MATRIX by default unless the object is scaled non-uniformly, in which case this is set to transpose(inverse(mat3(MODEL_MATRIX))).
harsh marsh
#

for context I'm trying to translate this from godot's glsl to urp hlsl

vec3 vec_dir_wd = MODEL_NORMAL_MATRIX * vec3(vec_dir_tg.x, 0.0, vec_dir_tg.y);
hardy juniper
#

Though ObjectToClipPos() will be introduced automatically I think when using that one in a shader 🤔 (i forget)

harsh marsh
#

yes but I don't know which one I should be using

hardy juniper
#

Oh I dont actually know if there is easy conversion to/from tangent space

regal stag
tacit parcel
#

this might be not shader specific but I'll ask this here anyway

I have a mesh with two materials, I want to overlay another material (parryIndicator) over those material by adding the overlay material into the mesh renderer
But somehow it only overlaid on the last material (the straw cape/Mino), is there a way to make it overlaid on the whole mesh instead?

ebon basin
#

I usually just do another mesh rendering if I want to do some overlay

tacit parcel
#

Ah right, I forgot that its treated as submesh, and the additional shader only applies to the last submesh 🤦‍♂️
Seems like the "fix" is to not having submesh? either join everything as a single mesh or make it as another mesh?

ebon basin
#

Probably yeah

tacit parcel
#

Cool thanks

odd wraith
#

what's the difference between the pink and blue node connectors

odd wraith
#

I'm trying to first make a normal shader with a height map and then going to triplanar. But the heigh map looks a bit choppy and not smooth. What can I change to fix it?

neat orchid
#

Are texture 2d arrays always more performant than sample texture 2d if you're blending different textures on the same material via vertex color?

pseudo escarp
neat orchid
supple sentinel
#

i followed along a tutorial, but is there anyway to make this toon shading colored? i think shadows being grey tends to look kinda ugly (second pic is whats inside the node group highlighted)

#

i keep trying to do something like this, but it changes the body instead of the shadow

regal stag
supple sentinel
#

ok let me try to understand this and report back :D

#

thank you so much 🙏

cerulean nexus
#

what am i not understanding about Sorting Priority? I have 2 gameobjects, the first has a sorting priority of 0 and the second has a sorting priority of 50. To my understanding, the second object should always render after the first, but it still gets blocked for some reason. is there anything that im missing?

lucid perch
#

hey i made this toon shader and im trying to add normalmap support to it. can somebody explain why i cant drag it into the normal output?

#

idk if its important but its in urp and unity 6000.0.41f1

regal stag
# cerulean nexus what am i not understanding about Sorting Priority? I have 2 gameobjects, the fi...

Afaik Sorting Priority is an offset to the Render Queue behind the scenes, which is determined by other settings. (Opaque has a queue of 2000, Opaque & Alpha Clipping is 2450, and Transparent is 3000). The priority would only affect the order objects render in if both materials have the same Surface Type & Alpha Clipping.

If both are opaque, the sorting priority still wouldn't force the second object to render over the second though - as opaque objects write to (and test against) the depth buffer. You'd instead need to override the ztesting mode using the RenderObjects feature or a custom shader. (Probably using ZTest Always, but then faces in the mesh also won't know what order to render in unless you do 2 passes like this discussions post)

fast igloo
#

shader I made completely in shader graph, anything I should add lighting-wise?

regal stag
# lucid perch hey i made this toon shader and im trying to add normalmap support to it. can so...

The normal map would need to override the Normal Vector node probably used inside the CalculateLights subgraph. Can add an input to the subgraph to handle that. (Good place to use a Branch On Input Connection too, but optional)

The normal sample also doesn't look correct. If it's a blue/purple-ish texture Tangent space and a Transform node to convert from Tangent to World for the lighting calculations. Also no need for the Normal Unpack node - the Normal mode on the sample handles that

lucid perch
regal stag
lucid perch
#

this is what my normalmap looks like and what my object looks like with my shader (top) and the default lit (bottom) i see progress but its still not working right

#

also the colors i set are different but i think thats not the problem

drowsy marsh
#

any recs for an already made reveal shader?

#

willing to purchase one

sand ingot
#

Im using unity 6 urp, custom shaders are working fine in play mode but in build they are pink.

#

no shader errors at all and i've tried disabling all the stripping options for shader varients

#

I've also created a new shader variant collection and added it to this list of preloaded shaders and added the specific shader to the 'always include shader' section in graphics settings

#

im sorta losing my mind here what haven't i tried yet

kind juniper
sand ingot
#

Yeah that all seems in check

#

i've tried it in new unity projects as well and builds are still breaking

#

i've also tried using different unity versions

kind juniper
#

Did you try looking at the player logs?

#

Or attaching a frame debugger to the build.

sand ingot
#

I looked at the player logs

#

didn't see much but i'm not familiar with the specific logs its putting out

#

chatgpt says its fine but 🤷‍♂️

kind juniper
sand ingot
#

haven't tried frame debugging

sand ingot
kind juniper
#

Try the frame debugger then. It might reveal more details.

sand ingot
#

will do

hardy juniper
#

addressables had a bug a while ago that would cause 100% stripping for shaders used

sand ingot
#

what am i looking for exactly?

#

I'm now getting an issue with the standard urp/Lit shader but that seems unrelated?

hardy juniper
#

there should be a stage where it lists all shaders and it processes the variants and reduces the variants built

sand ingot
#

ok i don't see the custom shaders being included

hardy juniper
hardy juniper
# sand ingot ok i don't see the custom shaders being included

Look for things like this:

    Full variant space:         301989888
    After settings filtering:   24576
    After built-in stripping:   48
    After scriptable stripping: 16
    Processed in 0.00 seconds
    starting compilation...
    finished in 0.62 seconds. Local cache hits 0 (0.00s CPU time), remote cache hits 0 (0.00s CPU time), compiled 16 variants (4.34s CPU time), skipped 0 variants
    Prepared data for serialisation in 0.00s```
#

here it only keeps 16 variants. If it goes to 0 but you know its used then thats a bad sign

sand ingot
#

I'm not getting those debugs, maybe i need to enable something?

#

I see a lot of

Uploaded shader variant to the GPU driver: Hidden/Universal Render Pipeline/LutBuilderLdr (instance 0x128), pass: LutBuilderLdr, stage: vertex, keywords <no keywords>, time: 0.077 ms
Uploaded shader variant to the GPU driver: Hidden/Universal Render Pipeline/LutBuilderLdr (instance 0x128), pass: LutBuilderLdr, stage: pixel, keywords <no keywords>, time: 0.089 ms
#

Looking into frame debugging now

hardy juniper
sand ingot
#

oh im in the wrong place

hardy juniper
#

you want to basically check what happened with shader compilation for your builds

sand ingot
#

yeah im in player logs

#

yes ok it is getting stripped

#
Compiling shader "Custom/Portal" pass "Unlit" (vp)
    Full variant space:         1
    After settings filtering:   1
    After built-in stripping:   1
    After scriptable stripping: 0
    Processed in 0.00 seconds
    Prepared data for serialisation in 0.00s
#

how do I exclude it?

hardy juniper
#

it must think no variant is used so its fully stripped

sand ingot
#

can i whitelist it somewhere?

hardy juniper
#

is the shader used by a material that is in the build?

sand ingot
#

yes

#

i've tried setting up a dummy scene with just the shader and a camera

hardy juniper
#

Resources?

sand ingot
#

doesnt workj

#

I could try turning off all stripping but that took like an hour to build last time

hardy juniper
#

yea not a solution as builds will take a stupid amount of time. Is it shader graph or .shader file?

sand ingot
#

.shader

#

oh god well

#

ive changed absolutely nothing and now it works

#

thanks for your help

#

i might be back if it decides to stop working

heavy plover
#

What type of shader do I need to use if I want a procedural material for a UI image?

#

It doesn't seem to work using the same one as the sprites

#

At least not transparency??

#

Ok, wtf, why does it show tranparency alright on the scene window but in game decides not to

#

Can be something in the camera?

regal stag
minor remnant
#

how can i rotate a float4x4 matrix around a vector by x degrees?

olive igloo
#

Hi, is there a way for a material with emission to be affected by lighting? like if theres a light it can have shadow and if its dim the color will slightly darken? i really like the color of the mat with the emission and hdr

dim yoke
minor remnant
#

that is indeed what I mean

#

thank you

dim yoke
minor remnant
#

unfortunately even though I know its more expensive my needs kinda require it to be done on GPU

dim yoke
wise igloo
amber saffron
wise igloo
strange prairie
#

I'm working on a custom terrain shader - trying to hide holes at a certain distance and for some reason that if test is doing nothing:

#ifdef _ALPHATEST_ON
if(posInput.positionWS.z < 10)
{
        float hole = SAMPLE_TEXTURE2D(_TerrainHolesTexture, sampler_TerrainHolesTexture, input.texCoord0.xy).r;
        GENERIC_ALPHA_TEST(hole, 0.5);
}
#endif

This is a custom pass that takes a PositionInputs struct.

#

I tried to debug using:

    terrainLitSurfaceData.albedo.r = posInput.positionWS.z / 300;

And I'm seeing expected results there - fading to red approximately 300 meters from the camera.

#

Alternatively, going branchless, still nothing:

float hole = SAMPLE_TEXTURE2D(_TerrainHolesTexture, sampler_TerrainHolesTexture, input.texCoord0.xy).r;
hole = lerp(hole, 1.0f, posInput.positionWS.z);
GENERIC_ALPHA_TEST(hole, 0.5);

posInput.positionWS.z behaves like it's returning 0. Unless I plug it into the albedo, where it returns the expected value. In the same function.

amber saffron
strange prairie
#

No, it works fine if I set hole to 1 manually

amber saffron
#

Oh, ok, my bad.

#

At first I'd say to instead use length(posInput.positionWS) instead (else you are purely testing on the z positive value), but it's still strange that it behaves differently when plugged in albedo 🤔

strange prairie
#

From what I can tell the clipping happens during the depth pass, while albedo is done during the Gbuffer pass

#

This does raise the question why they run this entire expensive pixel shader for the depth pass thinkies

#

Solved using input.positionSS.w, which is filled during the depth pass.

steel notch
#

I am making a Chromatic Aberration subgraph. I am creating it by sampling the same texture 3 times at slightly different UV offsets, and then combining the R, G and B from the different textures samples. How do I combine the alpha? Here is the current graph.

tacit parcel
# steel notch

isnt it usually used in post process where alpha doesnt matter?

amber saffron
steel notch
#

😛

amber saffron
#

Yes

#

Or something using these constants :
alpha = 0.2126 * RAlpha + 0.7152 * GAlpha + 0.0722 * BAlpha

But like rakiat mentioned, usually chroma aberation is a post process where you don't care about alpha.

slender ore
#

I tried using real time raytracing in my HDRP project and my shaders stopped compilling and I got error message Shader error in 'Shader Graphs/BarkShaderMoss': Opcode DerivCoarseY not valid in shader model lib_6_3(closesthit).. I have disabled the raytracing but this error remains, any idea on potentiall fix?

static star
#

Trying to create a color replace shader (so I can recolor outfits of players for example).... but this doesn't seem to work.

Tried following a simple tutorial but am I doing something wrong? Cause it works in the tutorial
https://www.youtube.com/watch?v=XW2qW1sDj_A

static star
#

ok so I seemed to fix it when I changed the Range to "0.1" but why is this the case?

amber saffron
slender ore
amber saffron
strange prairie
#

Should also make ray tracing work

slender ore
static star
#

a friend of mine said something about "material variants" or something? But doesn't know a specific term for this so its hard for me to google or lookup what exactly I need to do

amber saffron
static star
amber saffron
static star
#
using UnityEngine;

public class ColorChanger : MonoBehaviour
{
    [SerializeField] Color color1;
    [SerializeField] Color color2;
    [SerializeField] Color color3;
    [SerializeField] Color color4;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        SetColour();
    }

    private void SetColour()
    {
        foreach (MeshRenderer renderer in GetComponentsInChildren<MeshRenderer>())
        {

            foreach (Material material in renderer.materials)
            {
                material.SetColor("_SwitchToThisColor1", color1);
                material.SetColor("_SwitchToThisColor2", color2);
                material.SetColor("_SwitchToThisColor3", color3);
                material.SetColor("_SwitchToThisColor4", color4);
            }
        }
    }
}
#

cause here... I am trying to make it so I put it on a parent of the character body, then apply the color changes to everything that is a childed object of that parent

amber saffron
#
foreach (MeshRenderer renderer in GetComponentsInChildren<MeshRenderer>())
{
    var mats = renderer.materials;
    foreach (Material material in mats)
    {
        material.SetColor("_SwitchToThisColor1", color1);
        material.SetColor("_SwitchToThisColor2", color2);
        material.SetColor("_SwitchToThisColor3", color3);
        material.SetColor("_SwitchToThisColor4", color4);
    }
    renderer.materials = mats;
}
static star
#

still not working, am I just not connecting to the renderer still I guess?

Because I if I edit the Material variables from the Shader Graph directly it works... so its a connection issue to the renderer right?

amber saffron
#

From what I see, it should work 🤔
Any errors in the console ? Did you try loging things (like renderer names) to check that it passes on the proper objects ?

static star
#

no errors, but I can try logging

static star
stable bolt
#

Hi there, I retrieved an asset using Command Buffer in URP, those call don't batch with the SRP batcher, I'm trying to squeez every last drop for mobile and I was wondering if there were an extensive guide somewhere to help me port the Render Feature to use the BatchRenderGroup API ?

static star
# amber saffron Makes sense.

but ty for helping me.... I finally got that figured out and I think I can probably figure out how to replace meshes with the skinned mesh renderer

stable bolt
#

The documentation seems nice but as I don't know the Command Buffer API neither I'm a bit at a loss, or better, I'd like to know if I can 1:1 the thing or if Command Buffer and BatchRenderGroup are totally unrelated ?

low lichen
stable bolt
#

CommandBuffer is for executing many

unkempt hollow
#

Hello, I am looking for guidance or resources on how to add height map functionality or displacement to the unity toon shader. Its based on DX11 tess but its Tess CG file is missing any references to height.

stray gulch
#

is there any reason transparency wouldnt be working with urp? trying to convert my shaders to urp but it just totally disregards my transparent pass

left: built-in
right: urp

#

didn't even touch the shader code and it already doesnt work

grizzled bolt
knotty surge
#

anybody know if there's a (preferably simple) way to make an arbitrary amount of semi-transparent sprites, positioned, say, like this, have the same brightness throughout instead of blending with eachother

strange prairie
knotty surge
#

i see

strange prairie
amber saffron
strange prairie
#

Right, so all of them except probably ray tracing

#

I suppose shadow could live without too thinkies

amber saffron
strange prairie
#

Yeah will have to experiment there

hushed silo
#

I am doing SDF lighting/shadows/ao using primitive SDFs. I am coming across these artifacts sometimes, what are they? like, what should i search for to try and figure it out

amber saffron
strange prairie
#

That or some kind of anti aliasing

#

Or blur

hushed silo
golden raven
#

how can I make my outline shader thicker? to match my character's artstyle

#

this is my current setup atm

#

when i try increasing thickness it just renders incorrectely because its not filling the space between the object and the outline (and me trying to explain the issue just rubberducked it lmao)

hushed silo
golden raven
#

but again, for him it looks good, not for me

hushed silo
#

sorry didn't mean it as a lmgtfy

golden raven
hushed silo
#

but it is the BEST so you should be good 😛

golden raven
#

im on urp if that helps

golden raven
hushed silo
#

i'd assume the proper proper way would have something to do with stencil buffer etc but i dunno

golden raven
#

my objects are definitely not smooth shaded, its low poly

hushed silo
#

isn't it just a screenspace outline effect applied over whatever?

#

no sure that shading would have any impact

hushed silo
#

that the outline is its own shader

golden raven
#

oh no, its a shader graph

grizzled bolt
golden raven
#

let me show a pic

#

thickness: 0.01235

#

thickness = .1

#

you can see it better on the couch down there

#

and also its not adding an outline to every part regardless of direction, I believe that has to do with normals?

grizzled bolt
#

In couch's case I believe the outline is going inside the wall because it's above the couch's surface but the couch is right up against the wall
And floor for the radiatior

golden raven
#

i forgot why it was on back and not both

golden raven
grizzled bolt
#

It's an issue for the outline

golden raven
#

it wasnt clipping through the wall, so idk then

#

it should just be black between the outline and the actual object

grizzled bolt
#

Move the sofa up and away from the surfaces until the outline appears

#

Anyway those are fundamental limitations of this particular outline method
You can tweak the properties and the object positions to make it look potentially adequate from the camera's perspective
If the player can't move the camera right up where the errors appear, the errors won't matter

#

Otherwise you'll have to find a different method
Each has drawbacks
https://ameye.dev/notes/rendering-outlines/

golden raven
grizzled bolt
#

The normal offset method is similar, but it fixes the outline becoming proportonally detached
But it has the same clipping issues and additionally it'd have a splitting issue with any flat shaded geometry edges

golden raven
grizzled bolt
# golden raven i dont want anything floating around

Currently your outline is created by duplicating the mesh and expanding the duplicate
You can shrink the mesh by the same amount so the space doesn't change
If the outline is resting on the floor against the wall without clipping, it won't really be "floating"
Only the object inside the outline is floating but to an outside viewer the outline is a part of the object so there's no floating

golden raven
#

how do I even shrink the mesh in unity?

#

because scaling it doesnt change anything

grizzled bolt
#

The same way you shrink anything else
What precisely are you trying to scale

golden raven
#

the gameobject itself

strange prairie
grizzled bolt
#

All outline methods are pretty good but all of them have drawbacks and require attention when working around the drawbacks

golden raven
strange prairie
#

No, that's the method you're using

#

This is a full screen effect based on signed distance fields

ebon basin
#

as far as inverted hull goes

golden raven
ebon basin
#

The real way to fix this if you do want to silhouette inverted hull is make a secondary mesh that you do smooth shade / bevel down

grizzled bolt
#

I assume you have two separate objects for the mesh and its outline, so you'd be scaling them together or scaling a parent empty

ebon basin
#

the silhouette is a good idea though and worth a try, similar to the stencil shader idea above

#

what you can do too if just apply another material to the mesh renderer and make it black

#

that scales it but a few units

grizzled bolt
#

Smooth shading the mesh for specific purposes like this is very helpful
Why isn't it an option in the mesh renderer or even the mesh import settings

dim yoke
# ebon basin The real way to fix this if you do want to ~~silhouette~~ inverted hull is make ...

I guess one way would be to store the smooth shaded normals on some secondary UV channels. One could maybe create some sort of asset importer/editor script that does that automatically for certain models. Could also work the other way around by keeping only a smooth shaded mesh and drawing it as flat shaded via normal maps or partial derivative normal reconstruction but those may not be visually (nor technically) the best solution.

warm pulsar
#

is there any documentation for how ScenePickingPass and SceneSelectionPass work? I'm trying to make sense of them for a custom terrain shader

#

So far, I have the following understanding:

  • ScenePickingPass is used to click on things. If you discard a pixel, it can't be clicked on. If you return a bogus ObjectID value, the pixel can't be clicked on.
  • SceneSelectionPass is used to draw the outline. You return a 4-component vector. If the second component is negative, the outline is faint.
#

I can manipulate these on the Standard Unlit particle shader

#

and I get results that (sort of) make sense

#

I haven't gotten either to work on my terrain shader yet

golden raven
#

is this a good method or nah?

#

performance wise will it take a hit?

warm pulsar
#

ah, right, i forgot that the pass name would just be "Picking"

#

the rest is the name of the shader

#

oh lmao, I can just do

UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"

since I'm not doing anything different to the shape of the terrain

#

i'll have to figure out why my own passes were not working

stray gulch
#

initially every section was given the alphatest queue

#

but since some textures don't have any alpha that needs blending, I can just check the texture type and make sure the alpha multiplier is 1 or 0, then set it to geometry queue

#

and everything works fine and I can remove the dupe transparency pass

gloomy fractal
#

how can i achive sunlight shining through my grass?

grizzled bolt
gloomy fractal
#

this effect

#

i also looked for subsurface scatering

#

really difficult to find any helpful infos

#

by the way the image i posted is using urp

grizzled bolt
# gloomy fractal

Shader Graph's importable Production Ready Shaders sample has an example implementation of that

#

For both grass and shrubs

gloomy fractal
#

wow that sounds really helpfull. i will check that out

#

thank you very much

grizzled bolt
gloomy fractal
#

yeah looks really interesting

teal lynx
stray gulch
#

super tired of trying to figure this out, does anyone have any resources for a pixel-perfect outline system for urp

grizzled bolt
atomic glade
#

I'm trying to make a shader that shows intersections with terrain, and I'm trying to follow this guide to do it: https://www.youtube.com/watch?v=Uyw5yBFEoXo

I'm at about 4:00 into the video. The cube is apparently supposed to be looking like the first image, but what I'm getting is the second image. I'm on URP, and I followed the instructions at the start for making sure the depth texture is checked in the URP asset. There isn't a point in the video where he shows the entire graph to compare screenshots, but starting at about 3:45 you should see everything and compare it to mine in the third screenshot. What have I missed, why is mine so... incorrect?

stray gulch
#

trying to replicate the edge marking effect on the Pokemon nds games

stray gulch
#

preferably a stencil solution too, so I can just mark which ones I want to be outlined

kind juniper
atomic glade
kind juniper
atomic glade
kind juniper
#

I'd attribute the screen position a being a solid color to there being a very small spread that is not noticable to the human eye.

kind juniper
#

But yeah, the frame debugger should make it more clear.

atomic glade
#

Just to be sure, this stuff should be working in scene view, right?

kind juniper
atomic glade
#

Scene Depth is still solid white, opaque or transparent

kind juniper
#

Yeah, so frame debugger it is

atomic glade
#

Actaully, Scene Depth does darken it when I get like, right up into it. It starts to dim literally moments before it's too close to render

kind juniper
#

Sampling mode of the depth I mean

#

Or raw

atomic glade
#

Same with Raw

kind juniper
#

Hmm... I'd try these mods with he actual final shader and see if it works perhaps.

#

It could look like solid black to you simply because the range is very small.
Maybe try zooming way out back, such that it aligns with the furthest thing in the scene.

atomic glade
#

Okay, so, the cube was very small and the scene is quite large, so I blew up the cube to 1000x1000 to see if I could notice anything at a distance. On "Eye" mode, it rapidly cycles through black to white as I scroll in scene view, but not if I hold down the right mouse button and move the camera in or out...

#

I really don't understand what these nodes are even doing, I can't explain why it's doing any of this

#

This is with the shader as pictured in the original question, the "partially complete" shader

#

I'm gonna have to come back to this tomorrow, but if anyone has any ideas ideas in the meantime for me to try when I get back, I'll give them a shot

regal stag
kind juniper
#

Now, it can be linear or non linear(such that differences closer to camera are more impactful then those further away).

#

The value ranges could also be different. Some platforms/apis have it in reverse, where 1 is closest and 0 is furthest. Sometimes it's also non normalized or an integer, so the farthest value is something like 60k, depending on the depth format.

atomic glade
hardy juniper
#

From what i can tell this shader uses the difference in the fragment depth to the depth in the depth buffer to change alpha?

atomic glade
hardy juniper
#

So the cube is transparent in their video and the floor is opaque? Import to know for what is writing depth

atomic glade
#

They don't show the floor but that sounds correct, that's what I have

teal lynx
#

!code

echo moatBOT
teal lynx
#

I think I'm supposed to use unity_CameraToWorld but I'm not sure how.

kind juniper
#

This is likely more than just a shader issue - it has to do with when and what the render pipeline is rendering to the depth buffer/texture.

kind juniper
teal lynx
#

thanks for the info

brazen nimbus
#

Hello there ! What would be the best way to create a mask in black and white depending on the layer of what my camera sees ?
I'm trying to work on a post process effect but I don't want it to affect my characters. I'm using a fullscreen shader graph that I plugged into my Universal render data. My guess is to modify the render pipeline so I can create a render texture without my character which will be full black, another one with only the characters which will be full white and combine both but I'm not quite sure that's a good (and not even the best way !).
If you have any ideas, I'll be glad to know ! Thanks in advance ! 🌺

golden raven
#

anyone has an idea on how to make the glass not render the wall that it's going through?

#

im making a shopfront simulator

strange prairie
#

Like, sure you could do it with shaders but that's kinda weird lol

golden raven
#

you basically set in your size (in meters) and it'll just show up on your scene once you're done

#

im trying to make a program to pitch in my idea to the company im interning at right now

strange prairie
#

You can use stencil shaders

golden raven
#

but the principle would to just have the glass material ignore the wall material no?

strange prairie
#

Wall wouldn't render if glass was in front of it

golden raven
#

ohh true

golden raven
strange prairie
#

Yes

#

It's in the documentation. Pretty simple.

neat orchid
#

Does anybody know how to create a flipbook frame interpolation shader for lit particles

timid fossil
golden raven
strange prairie
golden raven
#

all pixels behind the glass should be set to that value that gets discarded

#

but how?

strange prairie
#

Let's take the example from the docs. This would be the glass

Stencil
 {
   Ref 2 // The value to set the stencil to
   Comp Always // Do this always
   Pass Replace // Replace the value
 }  

and this would be the wall:

Stencil
 {
   Ref 2 // The value to compare to
   Comp Less // We only render if the stencil buffer is less than Ref
 }  

So if the glass is in front of the wall, it's already been rendered when the wall renders and the stencil buffer will be 2.

golden raven
strange prairie
#

Yeah pretty much.

neat orchid
golden raven
#

shits tiring but fun

#

so what am I supposed to do? I applied the shaders onto the materials

golden raven
vocal axle
#

im trying to make a stereogram shader, but its not working and i cant for the life of me figure it out since there hasnt been good info about them since there hasnt been info good about them for decades probably.

probably some issue with not being able to properly duplicate the displacement to the right or left? ugh.

strange prairie
#

It still needs to render

#

Magenta means you have errors anyway, if you select the shader in project view it'll show you the errors

golden raven
#

not sure where to look, on the inspector its clean, the console has unrelated warnings, but no errors

golden raven
#

he left me on read so I'm unsure as what to do or search even

golden raven
amber saffron
amber saffron
golden raven
#

well which one of these works?

amber saffron
#

Using stencil is URP is a bit different an requires the use of RendererFeatures : https://www.youtube.com/watch?app=desktop&v=y-SEiDTbszk

Hey game dev enjoyers!

Here we are: the mighty tutorial about the stencil buffer that I’ve been working on for weeks now. I hope you’ll enjoy it ;)

WARNING: Please make sure to follow the instructions of the “IMPORTANT” chapter (it's only 30 seconds long no worries), otherwise you would not be able to use the stencil buffer.

The sha...

▶ Play video
golden raven
golden raven
golden raven
amber saffron
golden raven
#

imma come back if i dont understand the video

ebon basin
#

If you dont understand the video then start researching how the stencil buffer works because that's the keyword here

#

Not unique to unity

golden raven
#

instead of the ground, im making it onto a wall but my wall is still not rendering

#

the left is his video, the right is my settings

#

my glass material itself is rendering correctly, its only my wall material that isnt

#

i tried reverting it and still kept not being rendered (the wall)

atomic glade
# kind juniper I'd check the frame debugger after all. You can see what the depth texture conta...

I'm back and I'm working on finding out what's wrong with the renderer here. I've opened and attached the frame debugger and it gives me no information. Every step looks exactly like this. I made a fresh new scene that just has a plane and a cylinder with this material on it. What kind of information am I supposed to glean from this debugger? Nothing looks like the material I've set and I can't get detailed info on any of these steps.

atomic glade
#

I am wondering if this has something to do with it. I do have scriptable render passes for rendering outlines, and I do not know enough of this system to convert them. Changing this compatibility setting just spams that I have a pass that doesn't implement some graph function and I have no idea what that does or how to convert it