#archived-shaders

1 messages Β· Page 169 of 1

teal breach
#

left is scene, right is game

#

I thought the node just sampled _CameraDepthAttachment anyway?

regal stag
#

It samples _CameraDepthTexture

teal breach
#

ahh ok, that's probably it then

#

(I have some custom pass stuff set up)

regal stag
#

I think _CameraDepthAttachment is related to the actual depth buffer / render target, but it's copied (or possibly recreated) into _CameraDepthTexture so it can be sampled

teal breach
#

yeah I found I had to make changes to _CameraDepthAttachment to get post processing working for SRP

low lichen
#

@tardy spire You still need help with your problem?

teal breach
#

Weirdly, if I blit the _CameraDepthAttachment into the _CameraDepthTexture the scene view goes to pot (and the effect is still broken and cant be sampled in the game view)

#

argh

#

It's like just reading the depth buffer can be enough to screw it up

regal stag
#

@teal breach Is the cube using a custom shader? And if so, does that shader have a shadow caster pass? (because I think it might use that when creating the depth texture, while in the scene it only needs a depthonly pass).

teal breach
#

yeah it has the shadowcaster pass

#

the actual depth buffer itself looks fine in frame debug

regal stag
#

Can't really think of why it wouldn't show in the depth texture then.

teal breach
#

and so does the _CameraDepthTexture

#

(after the blit)

#

I don't entirely trust the Frame Debug though

#

in the same frame, if I go forward a few steps in the debugger, then back to the original step, it now looks different

#

I suppose something must be left in an undefined state

tardy spire
#

@low lichen that'd be great! I found out how to get shadowcoords and sample the shadowmap but haven't figured out how to add a fade yet. (Slight tangent:) Oddly if I pass 0,0,0,0 as the shadow coord the attenuation still works. Not sure why that is πŸ€”

low lichen
#

I'm trying to understand your description of the custom lighting model. If surface angle doesn't affect it, what determines which surfaces are in shade?

#

Or do you mean surface angle matters, but it's binary rather than smooth?

tardy spire
#

The shader is unlit and lerps between a light and shadow tint by the attenuation. There's no ndotl or anything. (Not at computer now but when I get back I can send images to better explain)

low lichen
#

So you have a directional light with shadows, but objects are fully lit unless another object casts a shadow on them?

tardy spire
#

Yup!

#

There's self shadowing so it doesn't look too weird, but I'd like to add a fade where the shadow starts so that it looks softer and you can't see as much artifacting

tardy spire
#

Not sure how the shadow rendering works, but if it's rendering a depth value I could check the fragments distance from the light source against the depth of whatever is casting the shadow to create a gradient which I can use to fade in the shadow over some distance

#

I know it's not even remotely physically correct, but I'm trying to mimic another stylized lighting look and this is something they're doing with custom light/shadow rendering. I want to see how much of it I can do without ditching Unitys lighting system

#

neither does NdotL, both tint base color with lerp(shadow color, light color, attenuation)

meager pelican
#

Well, that's cool looking.

So you have some self-shadow that I don't understand, but it has to change anyway. And then you have cast shadows, but you can do a "soft" version of those. Like that greenish line on the upright in the right foreground on a "flat" surface...that's cast and could be soft shadows.

But for self-shadows, you'll probably have to do (you're going to hate this answer) an NdotL-ish calc anyway, maybe with a smoothstep or step function, I'd think. Because you need to know when you get near the threshold of your shadow. But you can do it differently to have less gradient I suppose.

Off the top of my head and best guess.

#

But IDK how that would fix your "cube" to be soft. Hmm. you can always check out the code for shadowcaster pass, if you're using their lighting (lit) shaders. But you'll have to manually edit. For the BRDF calc on your cube IDK how you know unless you can use normals and some post process. Dang.

Rambling. Oy.

ripe sinew
#

Hello can anyone tell me how to apply a gradient affect, my two scenes are two drastic colors and i want to soften the transition πŸ™‚, its for a 2d game πŸ™‚

tardy spire
#

@meager pelican yea so the first image of the pipe is a completely custom lighting/shadow system. I didn't write it, but my understanding is an orthographic camera is used for the "directional light." it uses a separate urp renderer to render the depth of the scene from the light's transform and then fragments can check if they are in shadow by checking if the world position is further away from the light than the depth the camera rendered at their position in shadowspace. having this depth lets the fragment check how close to the surface that is causing the shadow the fragment position is in. using that distance the shader makes the shadow fade in over some distance.

i'm assuming unity's lighting is doing something similar? if i could get the fragments distance from the surface that is casting a shadow i could implement my own fade. I guess the question is: does Unity's lighting system store enough info for me to calculate this:

#

I'm using ASE and have made my own attenuation function with this as the core code

float4 shadowCoord = TransformWorldToShadowCoord(position);
Light light = GetMainLight(shadowCoord);
return light.distanceAttenuation * light.shadowAttenuation;

this is "default" attenuation you normally get. so i'm trying to see if i can modify it to fade in over some distance

#

I've thought about using ndotl and offsetting/remapping it, but i fear unity's shadows start too "high" up on the model to do this without it feeling like normal lighting. The light has to bleed around the backside of the model a bit for it to feel soft and fluffy.

#

I guess I could increase the depth bias on the light and use tweaked ndotl like you mention, but i worry that would result in weird shadows since shadows cast on other objects would have a large bias but selfshadowing would look a lil more normal do to tweaked ndotl

honest bison
#

I'm in forward mode and drawing large decals on the ground. How can I bake shadows onto my decal, but avoid dropping a shadow onto the mesh underneath?

eager folio
#

@regal stag would that blit feature be usable by shaders on, say, a sprite as well, or is it only for full screen stuff?

regal stag
#

@eager folio It's fullscreen but I think you can blit to a render texture rather than back to the camera, though I've never really tried that. Then get that texture in a regular shader. I imagine you'd probably need to make sure you handle the blit before those objects are rendered though.

teal breach
#

If you are looking to only apply a fullscreen effect to certain objects, you can render only those objects to an off screen render target and then use that as a mask for the post process effect

thick roost
#

would anyone be able to explain to me how I can tell if an objects depth is within a fixed range in shader graph?

I've been experimenting with the scene depth node and reading online in linear space it should return a value between 0-1 using near plane and far plane. But just simply plugging this into color shows this not to be the case - the color is the same regardless of its position in my cameras clip range ( which is 0-10)

#

What would be a good result for me is at near plane the object was black and at far plane the object was white I think

#

oh that's why I subtract the screenpos.w

#

because I have the max of the far plane

#

I kept seeing examples of multiplying scene depth by far range which confused me

teal breach
thick roost
#

I did read that yeah

#

not the twitter thread

#

it's been difficult for me to convert information into my use case

#

I'm basically trying to enable / disable an effect by comparing the objects depth value

#

it should only be enabled if the object is closer to the camera than my player is

fossil torrent
#

Hi, I'm back with my foam problem :)
Like you said @amber saffron, I've used the DDX and DDY nodes like this

#

I don't know where I'm wrong with the graph :/

honest bison
fossil torrent
#

Yes, that's what I'm trying to do !

thick roost
#

I solved my issue πŸ˜„

#

turns out I didn't need scene depth at all

cold rain
#

Has anyone dealt with shadergraph? I have a issue when I enabled double sided. I'm able to see it in scene view but when I press play I lose the double sided.

primal comet
#

Hello! Anyone know if you can expose the blend modes like additive and alpha outside of shadergraph?

#

@honest bison that looks amazing! any insight how to achieve that outward pulsing?

amber saffron
#

iirc, they are only exposed in HDRP with HDRP/* master nodes.
For the pulsing effect, it's probably done using some maths (ex: sin(x+time)) after the scene depth VS current depth comparison.

primal comet
#

@amber saffron ahh ok awesome ty on both points!

regal stag
#

I think they are using signed distance fields (SDF) by passing the sphere positions + radius in through an array, as the scene is called "SDF_Array". Might be able to get a similar result with depth too though

amber saffron
#

Good catch Cyan on the scene name πŸ˜„

honest bison
#

Sorry guys, that is exactly right. Alan Zuchoni has a great tutorial on how to send arrays to a shader.

grand jolt
#

is there a way to make garaud shading with the shadergraph?

meager pelican
#

i'm assuming unity's lighting is doing something similar? if i could get the fragments distance from the surface that is casting a shadow i could implement my own fade. I guess the question is: does Unity's lighting system store enough info for me to calculate this:
I don't think so @tardy spire

Others may know more, but with the shadow map (which is where that shadow comes from as you're saying) you don't know WHAT caused the shadow to be there.

But like I said, shadow casting process knows, and it supports "fuzzy" soft-shadows. So why not just use that? They blur the shadow map before casting it onto the scene. So the cast shadows get the blur that way.

The nasty question was the OTHER one, how do you SELF SHADOW that cube of yours to get what you want? With roundish objects you can use the NdotL stuff and get an idea how close you are to a boundary because it's a numeric result. But with that cube, the sharp edge has an abrupt change.

tardy spire
#

Gotcha, I guess it's not lookin too promising :/
In regards to the cube - if I could calculate a fade, the sharp edges shouldn't be a problem, but I agree they would be an issue with NdotL

low lichen
#

@tardy spire Is that the effect you want? Do you have an asset that does what you want, but you want to recreate it?

meager pelican
#

I think you're basically talking about having to completely write your own shadow system from scratch, including self-shadows. Then maybe you can pull it off.

tardy spire
#

Roger that @meager pelican
@low lichen yea I'm just trying to see how close I can get to the custom look while still using unity's lighting/shadows

#

the shadows is really the only thing i can't control enough it seems πŸ˜›

meager pelican
#

Is it an existing asset? I don't know that you answered that.????

#

I thought you were faking all that up.

tardy spire
#

haha nah it's a lighting thing https://twitter.com/CynicatPro is working on
it doesn't appear to be released anywhere tho

A spooky art witch! Summoner of bullshit and snarky videa games since the world was young. Icon by @floofyfluff

Tweets

12948

Followers

2573

meager pelican
#

Did you try the shadow blur (soft shadows) in lighting for cast shadows?

tardy spire
#

Yea I've been using Unity soft shadows ℒ️ in all the screen snips I've sent

meager pelican
#

That shadow on the bottom right doesn't look very "soft" right now. Hmm. And it looks like you have some hella bias settings. Guessing.

tardy spire
crystal light
#

Is it possible to have a properties block inside a custom fullscreen pass?

low lichen
#

@crystal light You mean MaterialPropertyBlock?

crystal light
#

@low lichen Thank you for your response. I would like to sample a 2D texture inside a custom fullscreen pass, so how exactly could I pass it to the shader?

low lichen
#

@crystal light How are you performing the full screen pass now? A material is always required, as far as I know.

#

If that material has properties, those properties will be used in the pass.

nimble perch
#

I have another problem with my leaves. Close up, they look as intended, but as i walk away from them, they start to disapear

#

why is this happening

regal stag
#

Might be due to texture mip maps. I think there's an option on the texture to allow mip maps to "Preserve Coverage" which should help fix that.

sage moss
#

Yea I've got some weird bias settings, but it's definitely soft shadows
@tardy spire try setting the light distance setting higher. Usually that gives a bit more blur

nimble perch
#

@regal stag that does not fix it.

low lichen
#

@nimble perch Does this happen gradually or does it pop out of existence at a certain distance.

nimble perch
#

gradually

#

but only with alphaClipThreshold. when i set it to 0 it does not disapear but than my transparency does not work

regal stag
#

I still think it's related to mipmaps. Is there a reason why the AlphaClipThreshold needs to be as high as 0.9? If the texture alpha is just black & white a value around 0.5 would probably work just as well.

nimble perch
#

setting the threhold to .5 does fix it mostly but im still getting some wiered outline bugs, but i guess thes due to my texture not heaving perfect alpha.

regal stag
#

Is the shader transparent? I'd probably keep it opaque, that way the alpha is just used for the clipping.

nimble perch
#

let me try

sage moss
#

What do your texture import settings look like @nimble perch ?

nimble perch
regal stag
#

Well, I think the outlines are gone at least πŸ˜›

nimble perch
#

yea

#

also in some areas it looks perfekt

regal stag
#

Might be something to do with shadows, hard to tell

nimble perch
regal stag
#

Does changing the shadow bias settings help at all?

nimble perch
#

where do i change thatπŸ˜…

regal stag
#

Eh, either on the light or URP asset

sage moss
#

@nimble perch I'd also experiment with making that just a black and white image, and importing it as greyscale, with the alpha as "From Grey Scale"

Not only will that be lower memory, it'll be cleaner

regal stag
#

I think the shader is probably two sided right, and it looks like it's casting shadows onto itself. The faces are too close to really handle that properly, so increasing the depth bias will likely let the shadows through.

nimble perch
#

im sorry but i still cant find any shadow bias option

regal stag
#

Are you using URP or HDRP?

nimble perch
#

HDRP

regal stag
#

Apparently if some property fields are missing, you need to click the more options cog to expose them.

nimble perch
#

OOoohhhhhhh

#

well im sad do tell you guys... but its not fixing it...

digital vector
#

im wondering: in a shadowcaster pass, is it possible to make only select triangles cast a shadow, but make everything receive shadows?

#

i added grass particles on top of a surface shader (with geometry shaders etc), and i wanted the grass to not cast a shadow

regal stag
#

The shadowcaster pass is only responsible for casting shadows, not receiving them

meager pelican
#

You can manually write custom shadowcaster passes in all the pipelines AFAIK.
As far as receiving, that's an attribute of the model/object.

digital vector
#

shadowcasters also seem to validate how a shader receives shadows

#

otherwise it appears like something is transparent

#

in terms of how shadows are placed

#

also, this is for per object @meager pelican :p i need specific polygons in a shader to cast and others not to

#

in a single object

regal stag
#

I'd assume you can use a custom shadowcaster pass which discards for certain triangles, probably based on some texture mask or vertex colors or something.

digital vector
#

i do have a method to know which ones would cast already, i just need to know how to make em not cast :'D

#
            float4 frag(g2f i) : SV_Target
            {
                if (i.uv.x < 2)
                {
                    // this should not cast
                    float4 col = tex2D(_FolTexture, i.uv);
                    if (col.a < _FolClipping && i.uv.y < 2) discard;
                }
                else
                {
                    // this should
                    if (i.uv3.y <= 1)
                    {
                        float borderAlpha = tex2D(_BorderTex, i.uv3 * float2(1, 0.5) + float2(0, 0.5)).a;
                        if (borderAlpha < _BorderClipping) discard;
                    }
                }

                SHADOW_CASTER_FRAGMENT(i)
            }
#

this is what happens when only the else statements does the shadowcaster fragment

#

granted, the grass already looks good to me, but if its possible to not make them cast a shadow, then i'd gladly do so :p

uncut robin
#

Hey, I'm trying to apply a render texture to a material but struggle to do so, I tried doing this RenderTexture rend = enemyCam[i].targetTexture; enemySprite[i].GetComponent<AIScript>().quad.GetComponent<Renderer>().material.SetTexture("_BaseMap", rend);
but it didn't change BaseMap

clear vector
#

Hi all. Today i tried to create little flipbook shader through shader graph for my 2D character. I have sprite sheet with 8 frames of character animation in a row. I decided that using shader graph flipbook node will be nice and clean solution to pass different sprite sheets that supposed to be animated in a same way instead of having tones of animation and animator or complex custom logic for sequencing those frames. I thought it would be simple and inside shader graph result looks just great. But when i created material and sprite renderer with this shader my character was looking wierd.
The first thing was that result sprite renderer looks like it was shredded. That was fixed by changing mesh type from Tight to Full Rect in import settings.
The 2nd thing was that result renderer was was expanded by X. I thought that this is because sprite sheet have 8 frame in a 1 row. So i set X scale to 0.125 (which is 1/8) and now renderer looks perfectly.
So my question is: why 1st wierd thing appearing? And what can i do to not scale sprite renderer for every sprite sheet?

crystal light
#

@low lichen seems like they are NOT. I can't even declare a property block within a fullscreen pass shader...

#

All I really want to do is render a texture in a fullscreen pass, really.

nimble perch
#

is it posible to create a shader, that does not cast shadows on itsel, but on anything else in shadergraph ?

uncut robin
#

Hey, I'm trying to apply a render texture to a material but struggle to do so, I tried doing this

            enemySprite[i].GetComponent<AIScript>().quad.GetComponent<Renderer>().material.SetTexture("_BaseMap", rend);```

but it didn't change BaseMap
echo badger
#

I'm trying to figure out how to make one of those stylized grass shaders using Amplify Shader Editor.
I have gotten close. The problem I am having is that when rotated, my grass is shaded differently and I am not sure how to fix it.

In blender I have rotated the normals of the vertices of the mesh to face up. And that makes it this close.

tardy spire
#

@sage moss good call. looks like anything that lowers the pixel density (like lower res, less cascades, higher shadow distance) gives it more blur

mortal kiln
#

I have a system im devising where I feed my shaders a list of primative shapes, and operations , plus other data, found out I couldnt feed it a struct only floats, ints, vector4. i imagine if i switch to a computeShader I can feed it the custom class/struct

#

but i havent really grasped the concept of computeShaders so if anyone has some links or tips would appreciate it. for the most part what Im building works its just a ugly hack where I used a vector4 to pass it data I wanted as string etc

grand jolt
#

is there an easy way to keep textures tiled instead of manually changing the tiling every time an object's size changes?

steel river
#

can i have help with transparency

summer jetty
#

Im not sure if this is a shader issue but my objects appear transparent on a side

#

I imported my models from blender

nimble perch
#

are your normals oriented in the correct way ? i dont now which shader you are using but i think its cullinng your backfaces

summer jetty
#

shader says standard

#

also the normals should be facing the right way

#

It was a cube and I removed three sides and flipped normals to get a corner of my room

nimble perch
#

well i would atleast check it

summer jetty
#

ok

nimble perch
#

sometimes blender does wiered stuff to your normals

quick holly
#

yeah, i think there is a toggle in blender to check which way the face, well, faces

summer jetty
#

Im flipping the normals of all of the problem areas so it should work after its done

nimble perch
#

blue = rendered

summer jetty
#

ok I think i fixed it
My normals were indeed weird

honest bison
#

I asked this question yesterday. I am in forward render mode. I want my decals to receive baked shadows. I don't want them to drop baked shadows. How to achieve?

summer jetty
#

I tried flipping the normals to both sides but I still get this problem with this one wall

#

and that one part of the desk

steel river
#

like effect wise

#

anything else to add to the effect

regal stag
steel river
#

dang those are some nice effects

#

ill definitely take a look into it

eager folio
#

@clear vector You seem to have figured out the basic issues; For the first, you should always use full rect if you are doing UV based animation because animating only the UV won't update the outline. For the second, it is probably easiest to just expose the scale in the inspector.

clear vector
#

@eager folio thank you for answer. I think it will be easy to do through script. Anyway i will pass different sprite sheets to shader and i need to know frame count, so while i know frame count and count of rows and columns i can calculate proper scale.

meager pelican
#

also, this is for per object @meager pelican :p i need specific polygons in a shader to cast and others not to
@digital vector
Assuming that code fragment was for a shadowcaster pass, did you try to discard() the pixel if you don't want it to be shadowed? As long as you can tell on a per-pixel basis.....

digital vector
#

I sent in Screenshots of what it looks like with discards in each if statement

#

Neither works

#

Everything should receive, but not everything should cast

meager pelican
#

You'd only discard where you don't want a shadow cast.

digital vector
#

The grass doesn't receive shadows anymore too

#

Maybe I did something wrong with how shadow data is passed along, idk

meager pelican
#

Receiving shadows is a different thing. This is for the pass called SHADOWCASTER. You didn't show the whole pass so I can't tell.

#

Shadow casting is a PASS

digital vector
#

More than the fragment function?

meager pelican
#

It has a frag function in it.
But it's it's own pass

digital vector
#

Yeah it is

#

I have a pass just for it

#

I can send more details tomorrow, kinda 1 am here lol

meager pelican
#

Fine. And if you can tell which polygons cast and which don't, do a discard for those that do not.

digital vector
#

but thats what I did in the Screenshots I sent

meager pelican
#

IDK why you have discards on both 'sides'
That's not what your code did.

digital vector
#

I sent the code for the original

meager pelican
#

But I'm not sure....

digital vector
#

The second Screenshot had an added discard

meager pelican
#

OK

#

Go to sleep. Dream of shaders.

#

lol

robust inlet
#

Frack matrix projection 😱

meager pelican
digital vector
#

Jokes on you I actually had a dream about writing this exact shader lol

meager pelican
#

lol

ripe wigeon
#

Trying to make a shader that applies a glow when the player is close by but I think I'm doing something wrong

#

PlayerPosition is a global variable set by a script on the player

#

so the above works but I'm not sure how to completely remove the fresnel if they are over a certain distance

crystal light
#

how can I render a custom pass from another point of view (camera)?

amber saffron
#

@ripe wigeon The fresnel power is not the intensity, but the curve of the effect on the edges.
To controll the intensity, multiply the output of the fresnel by the output of the divide node

alpine karma
#

Hi. Does anyone know of an example or a tutorial of Chunked LOD, CDLOD, Geo Mipmapping or Geo Clipmapping? I figured that I need to use 1 of these as my LOD system, but have no idea how to even begin making such a system.(Yes, I have googled, but can't find anything unity specific)

steel river
#

ok i have some heavy shader graphs and i want to be able to control when it runs

#

i plan to have 100s of objects with this shader

novel summit
#

Beautiful

steel river
#

but i will only have 5 running at one time

#

how do i "disable" the shader from running

ripe wigeon
#

Thanks @amber saffron, that looks to be where I was going wrong!

steel river
#

heres the shader in action if you want to see it

#

but to get back to the question

#

can i just disable the gameobject the shader is attached to or disable a parent object?

ripe wigeon
#

Nevermind, switching to absolute world position fixed it

meager pelican
#

how do i "disable" the shader from running
@steel river There's an old saying in CG....the fastest polygons are the one's you DON'T draw.
You "stop it from running" by not drawing the object.
Is that what you mean?
If you mean "don't animate the distortion"....then pass in some fixed time index (say 0) and don't update it. Or set some scalar variable that you multiply by, and scale to 0 for "off".

#

@ripe wigeon If you want you can just "not add it in"...
the graph equivalent of
col += (dist > threshold) ? float4(0,0,0,0) : fresnelCol;

#

If dist is not at the pixel level, like if it's per object origin, see if you can get it to calc in the vertex stage but IDK that you can force that in SG.

steel river
#

@meager pelican like i mean i dont want to have the shader running when it doesnt need to. like i disable the renderer but the shader still runs in the background

#

i assume that isnt the case though

#

if i disable it it wont run period

meager pelican
#

Yeah, it only runs when the object is drawn.

crystal light
#

Is it possible to have some original vertex position in the Shader Graph before Wind?

regal stag
#

You are referring to getting it in the fragment stage right? I don't think it's possible in shader graph yet.

crystal light
#

@regal stag yup. I'm thinking of a way to "bake" some original vertex position into UV2 for example, and get it in a fragment stage. Maybe some custom function code would do?

regal stag
#

You could probably bake the data in via C# (as in, copying the vertex positions and put them into the mesh.uv2 channel), but I don't think it's possible within shadergraph, even through a custom hlsl function. You don't have access to the struct in order to allow it to interpolate between the vert and frag. It's something that's on the roadmap but no idea when it's going to be implemented.

#

Unless you can somehow cheat it through the vertex tangent or vertex normals, but I'm pretty sure they get normalised during the fragment so wouldn't really work. (and would likely mess with shading if it's a pbr/lit shader)

crystal light
#

@regal stag I've found a workaround for my case. Use a conversion of Vector 0, 0, 0 from object space to an absolute world space. That should do fine to look up some color variation.

meager pelican
#

That would give you the object position in world space, but IDK about vertex pos.

crystal light
#

@meager pelican well, I've needed some kind of anchor point for color variation that would not account for Wind

#

some kind of stable basis point

#

How can I write a custom shader material editor for my Graph?

regal stag
#

Are you referring to the material inspector? I know some newer versions of shadergraph allow you to override that - (unsure if the package manager versions include that or not). For the actual editor script, I assume it would be like the example here : https://docs.unity3d.com/Manual/SL-CustomShaderGUI.html

crystal light
#

@regal stag yes, I mean the material inspector. I've already saw the doc. Just want to know how to infuse that CustomShaderEditor directive into the shadergraph

regal stag
#

@crystal light Some versions have an override on the master node, URP v8.2.0 does at least, not sure about previous ones.

teal breach
#

oh @regal stag , the other day I think you mentioned a SHADERPASS_SHADOWCASTER define

#

I tried it out but it doesn't get defined for 8.2 - not sure about later versions

regal stag
#

Hmm, I'm using 8.2.0 and the generated code has it defined

teal breach
#

argh

#

could well be a SRP thing

regal stag
#

@teal breach Are you trying to find out which pass it is for a built-in pipeline shader? I think built-in uses UNITY_PASS_SHADOWCASTER instead

teal breach
#

nah, I have to change the alpha based on whether the object is in a shadowcaster pass or not. I tried using the above define, but it doesn't get set during the draw call (as verified from frame debugger)

#

I already have a separate material I need to apply to get around the lack of custom passes in ShaderGraph, so I just moved the Shadowcaster pass there

#

I'm basically just saying 'be wary of that define' - it didn't work for me on 8.2.0, 2020.1.0f

regal stag
#

I'm not too sure what you mean by "it doesn't get set during the draw call (as verified from the frame debugger)", but doing something like this in shadergraph would output an alpha value of 1 for the shadow caster and 0 for anything else. I haven't come across any issues with this, it seems to work fine.

#

Is it just me or is that image file not showing as an image. Is discord okay?

teal breach
#

nah its broken 😦

#

let me go back and double check

teal breach
#

@regal stag I take it back, it looks like it is defined in the generated code. I thought it was defined as per a shader keyword (so I was expecting to see that keyword defined in the frame debugger when making the draw calls on those objects for shadows). I guess my shader wasn't working for some other reason!

regal stag
#

Ah right

novel summit
#

the book of shaders is interesting but difficult πŸ˜„

nimble perch
#

ahm anyone know whats causing this wiered lighting bug ? where do these lines come from ?

eager folio
#

@nimble perch Might be shadow cascade settings?

spiral bay
#

Hello everyone! I want to repeat a tiled grid.

#

Take this image for example. I want each of the symbols to randomly change between each other as well as colors

#

I did something cute with ShaderGraph that does more or less what I want, but it's limited to one symbol only

eager folio
#

@spiral bay You would need to change the integer feeding into 'tile' for every tile the uv tiles.

spiral bay
#

yes

#

That little part is OK

#

when I change the integer, the symbol moves and all

#

that little part works.

#

I want to take that whole thing and make it one tile, and have like 64 of them

eager folio
#

You'd want to make some noise and then convert that into an integer you can feed into the flipbook tile

spiral bay
#

That would make it move automatically, right?

eager folio
#

Not sure what you mean by move automatically

spiral bay
#

I have a 8x8 grid. Each tile in that grid has a symbol in it. I managed to make a flipbook that takes those symbols and move them. This works. Now, I want to fill my 8x8 grid with all those moving symbols

#

The solution I have right now is to make a new plane with a new script and tile it manually

#

but I want to eventually fill a whole wall with these

#

that means thousands of tiles

#

So I was wondering if I could have a way to "fill" a plane with these single tiles randomly

thick fulcrum
#

as it's a flipbook I imagine not, simplest way is to create c# code to spawn a quad / prefab dynamically and repeat the spawning on x,y axis for however many you want per row etc.

eager folio
#

@spiral bay You scale it down to use only a portion of the UV and use the noise texture to 'choose' a tile for each one

spiral bay
#

@thick fulcrum yeah, that's what I feared. I really didn't want to do this because it would kill my framerate

#

@eager folio Aye, but how do I get it do make out a huge square with 32, 64, 128, etc of these at the same time?

eager folio
#

You tile it.

eager folio
#

Hrm, no

#

lessee...

#

I am not very good with shadergraph. might be easier to just write it as shader code>.>

regal stag
#

The graph is in the tweet comments, used UV * tiling into Floor node for a seed to generate a random numbers to offset the UV * tiling -> Fraction coord.

#

Didn't use the Flipbook node but that might have made it a little easier

eager folio
#

I figured out what was wrong

#

I, er, set the input on the noise to an integer.

#

derp

crystal light
#

@regal stag nice, thank you! not in 7.1 though .. 😦

eager folio
#

Cyan's is probably better though

#

...correction, definitely better:D

clear vector
#

I figured out that using shader from shader graph in URP 2D breaks batching at RenderLoop.Draw. When using just regular sprite renderer all renderers with the same sprite drowned by the 1 RenderLoop.Draw. Am i doing something wrong?

eager folio
#

@clear vector are they different materials?

#

By default all sprites use the same material so they batch together

clear vector
#

@clear vector are they different materials?
@eager folio No, i use just one material for my shader

#

Also tryed create a simple shadergraph shader without any nodes, just empty. And it breaks batching))

eager folio
#

Welp, guess shadergraph sucks πŸ˜„

desert orbit
#

@clear vector No reaction gifs, please

clear vector
#

Ok, didn't know this rule, sorry

novel summit
#

glsl ruler?

#

alguien habla espaΓ±ol?

desert orbit
#

@novel summit This is English only speaking server, sorry.

novel summit
#

But I want to know who talk spanish πŸ˜„

#

Is there a spanish channel?

cobalt bolt
#

hey shader masters

#

your soul will rise to the heavens if you contribute and you will have my eternal gratitude!

sage moss
#

@cobalt bolt why don't you just apply new materials when you load the model? If the material property names are the same, it should transfer over

cobalt bolt
#

@cobalt bolt why don't you just apply new materials when you load the model? If the material property names are the same, it should transfer over
@sage moss The asset uses 3 custom shaders. They need to be converted.

sage moss
#

Then, how does GLTF know the mapping when you serialize and deserialize anyways?

cobalt bolt
#

huh...what? I have no idea what you're saying. But the asset works like when you import an FBX into Unity. You can click to expand and see what's inside.

#

It doesn't convert the gltf into a prefab or anything like that

#

Anyways, converting the shaders is probably easy for people who knows how shaders work? Hopefully?

lusty badger
#

Is there a way to make CustomDrawRendererPass to affect VFXGraph particles?

grand jolt
#

@meager pelican I have a whole world full of meshes with a regular shader. I need to render them a 2nd time into a temporary texture with a random color like the pic attached. Is there a way to do that without remaking the whole camera frustum culling system to get a list of Renderers to draw using CommandBuffer.DrawRenderer?

meager pelican
#

Why not let Unity figure it out, it already knows!
Have you seen https://docs.unity3d.com/Manual/SL-ShaderReplacement.html ?
IDK how you're assigning colors, but if it's "just" geometry flat shaded like that, however you do it you can have a flat-shading shader that grabs the color and renders it to a render texture (set that destination texture on the camera).

#

@grand jolt

#

So you can call Cmera.RenderWithShader

grand jolt
#

I'm on URP.

#

I have my own custom Render Objects To Target render feature already, but the issue is I need to pass a custom random color to each mesh somehow while they're all going to share a material.

#

And the only solution I see is drawing each individually and presetting the material prop for color before each cmd.DrawRenderer.

meager pelican
#

Yeah, you'll have to stick the color into the mesh data, like a UV set.
Or maybe assign an index into a color array so you can change it without having to update all the meshes.

#

Really? So no replacement shaders in URP, eh? :/

grand jolt
#

Render Objects feature allows you to replace the material, it's the same thing.

grand jolt
#

Seen and seen.

meager pelican
#

They replace the material

regal stag
#

The RenderObjects override material won't copy over shader properties like replacement shaders do though

meager pelican
#

If he's got the color [index] stuffed into mesh data, might not be too bad.

regal stag
#

Yeah if it's stored in the mesh it'll be fine

grand jolt
#

The color should differ on a per object basis, not a mesh basis.

meager pelican
#

Crap

#

Yeah

#

OK, let's solve it on the C# side.

#

when you get a "will render object" event, add the object to a list of renderers.
clear that list at the start of a frame

#

So now you know who is going to render.

#

Then iterate throug that list and render

#

Maybe to a render texture.

#

?

#

Draw calls will suck

regal stag
#

It might make sense to use material property blocks & instancing stuff. I'm not really an expert on that, but what Alexander Ameye asked in #archived-hdrp seems somewhat related to this problem too.

grand jolt
#

SRP Batcher isn't compatible with property blocks.

regal stag
#

I know, but you can still use instancing if you can write the shader to support that

grand jolt
#

Would it even make sense considering I won't have a million of the same object.

meager pelican
#

Does your target platform support multiple render targets? As long as we're spitballing....

grand jolt
#

What if I generate the random color inside the shader?

meager pelican
#

You might be able to do both at once.

regal stag
#

Is the random colour important? If not then sure, might be able to generate it in the shader

grand jolt
#

The platform is PC.

meager pelican
#

IDK how you want to assign the color, but I'd seriously consider making it an index

grand jolt
#

I just need distinct colors for edge detection.

meager pelican
#

Uh.....

#

Hmmm.....

#

Do you have control over the models?

#

Like blender or other software, and can you assign vert colors?

grand jolt
#

I can.

meager pelican
#

Are these quads with a masked/transparent image, or is it a mesh?

grand jolt
#

Meshes.

meager pelican
#

You only want outside edges?

#

Like/similar outlining?

grand jolt
meager pelican
#

Yeah, outlineing!

regal stag
#

You could probably generate a random colour based on the world position of the object.

grand jolt
#

I guess I could hash the world position, use it as input to noise and make that a color.

meager pelican
#

Yeah, he says right in that post he uses an assigned vertex color + random color

#

Then a post-processing pass

grand jolt
#

And we're discussing the + random color part πŸ˜„

meager pelican
#

So Vert colors baby!

grand jolt
#

But ya all great rubber ducks, I forgot about hashing the position.

meager pelican
#

But Maybe pick random color based on some instancing index

regal stag
#

Looking at the comments, they are actually using manual vertex colours

meager pelican
#

Yeah, but random color added

#

Yeah, but your other question was "How do i get it to render without duplicating frustum culling" then the replacement shaders....material....

But NOW I'm thinking you can do the whole damn thing in one pass with multiple render textures if you want. Same shader. But it might take custom editing I don't think SG supports MRT's.

grand jolt
#

I'm not using Shader Graph for my custom effects, I like the control.

meager pelican
#

So you'd output the "normal" color to one RT and the flat randomized one to the other. Then run your post processing after that.

#

I haven't tried MRT on URP

grand jolt
#

No worries, I got the rest of the pipeline down.

#

This is like the 3rd custom effect I'm writing where I use objects from some layer as a mask and ignoring all the boilerplate it's as simple as that in URP: cs context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings, ref renderStateBlock);

#

I actually have never needed to use a RenderTexture, I just create a temporary in the command buffer and then release it.

#

And so does URP itself, at least most of the passes I've checked out.

meager pelican
#

Yeah, I'm not saying you can't use temp RT's at all....

grand jolt
#

I'm not making a point, just being a boring nerd πŸ˜„

meager pelican
#

πŸ™‚

teal breach
#

@grand jolt , I take it you want some way to distinguish different objects so you can outline them?

#

the way I did this was to make a separate outline material, and apply it to the objects (so they have two materials and one submesh)

#

The outline material defines only a pass with LightMode=Outline

#

I then add a render feature which renders only objects with LightMode=Outline, so only those objects get drawn to the screen (in this case, a render texture I use for post processing)

real basin
#

is randomness really necessary if world position would be unique for each object?

meager pelican
#

"Randomness" could = hash-to-some-color

grand jolt
#

@teal breach oh, the pipeline won't render the mesh in regular mode with this custom LightMode?

meager pelican
#

That tweet mentioned depth buffer too.
Probably using derivatives on both color and depth to detect changes in PP

teal breach
#

if you define it as a separate pass you can basically have it so the normal rendering is unaffected, then when you have your render feature it will only use your custom pass

grand jolt
#

But yeah, since hashing inside the shader doesn't break batching, I think I'll try it.

teal breach
#

(the reason I did it that way rather than world position is because sometimes I want an outline to go around certain entities - eg a character and their items)

grand jolt
#

Oh yeah, I do have filtering by the lightmode tag in my custom render objects feature.

meager pelican
#

So the separate outline material is basically a hand-drawn outline? So double materials.

#

Or is it computing an outline?

teal breach
#

It's for coloring pixels on the screen with a unique ID - you then have to make a separate pass to do the outline (look for dissimilar pixels)

#

Unity gives you a warning about over-drawing, but if your custom material defines no other passes (eg, forward lighting or shadow casting) then there isn't any additional overhead beyond what you already need for the outlining

meager pelican
#

Yeah, that's basically what beat is talking about. So give it a custom renderer with a different LightMode. Hmm.

teal breach
#

It feels really hacky to have another material, but its the only way I could get it to work in my case because I want to support ShaderGraph (and you cant define other passes for shadergraph materials)

#

If you are using ShaderLab, no need for a separate material, you can just add the pass as normal

meager pelican
#

He's in URP, but custom editing shaders.
I still think he can do it with MRT's too. Either way sounds like it will work. If MRT's then only one pass needed.

teal breach
#

yeah MRTs would be nice

grand jolt
#

Why do you guys keep talking about multiple render targets like having over 1 texture is something fancy πŸ€”

teal breach
#

if you can't get MRTs to work, you might be able to hack it by using the alpha channel, if you are only ever rendering opaque objects, and inject a pass before rendering transparents

meager pelican
#

Because you selected URP.

#

πŸ˜‰

teal breach
#

I think they aren't supported on all targets either?

grand jolt
#

But why is it necessary.

#

I need 1 texture.

teal breach
#

That outline method works for me though, I also pack other metadata into the outline texture (like color of the outline, object ID, etc) for per-object outline control

meager pelican
#

Beat?
You'd be outputting the "normal" color to the color buffer, but AT THE SAME TIME be outputting your "flat" color to your temp RT. So two birds (Ha!) with one stone.

#

One pass.

#

READING textures is easy in shaders, right? You can have 20 of em.

#

But outputting results gets more complicated outside of what is "stock".

grand jolt
#

Damn. They don't write about that in the manual.

teal breach
#

I don't worry too much about a separate outline render pass though, the material is literally just writing the color property to the output with no other calculation beyond visibility so it's pretty fast

meager pelican
#

See what they do in the "standard" pipleline, it will be similar for URP (prolly the same syntax).
Can't hurt to try it. Just output "white" to start and test it.

grand jolt
#

I can even tweak the color by rotating slightly.

meager pelican
grand jolt
#

(I use world pos + forward to hash so rotations also influence the color)

#

Pretty sure in URP you're supposed to use ConfigureTarget in custom pass's Configure.

#

But yeah, maybe later.

grand jolt
cobalt bolt
#

Anyone with a good, kind soul here?

sage moss
#

You spelled Transferwise incorrectly

cobalt bolt
#

Benjamin! Are you the chosen one? I saw you typing!

#

@sage moss I am sure your shader skills are unparalleled.

teal breach
#

whats up marks?

digital vector
#

How can i get the camera view direction?
Not the direction of the camera position to the vertex, but the actual direction that the camera is pointin

#

i tried it like this float3 viewViewDir = mul(UNITY_MATRIX_V, _WorldSpaceCameraPos.xyz + float3(0, 0, -1)); but idk if its correct

#

doesnt look like it lol

#

im pretty sure i can somehow get it using the view matrix, but im not sure how

regal stag
#

Shadergraph's camera node uses this as it's generated code apparently : float3 _Camera_Direction = -1 * mul(UNITY_MATRIX_M, transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)) [2].xyz);

digital vector
#

yesss thanks! I'll try it out!

regal stag
#

Oh that might be in world space though

digital vector
#

yes thats why i need

#

dont worry

#

definitely looks more correct than what i had going lol

cobalt bolt
#

whats up marks?
@teal breach There is an open source project with 3 custom shaders that need to be converted to URP shaders https://github.com/Siccity/GLTFUtility/issues/75
It's probably not difficult to do for shader people, but the author doesn't know.

grand jolt
#

Why does an importer even ship with custom shaders, that makes no sense at all.

cobalt bolt
#

I don't knooooow T_T. All I know is that it's the best gltf importer for Unity!

regal stag
#

I would assume the shaders are there because one uses _Roughness while unity uses Smoothness (1-roughness), (or _Glossiness?), but I doubt it would be that difficult to just apply the values correctly to the standard shader. Maybe there's some other differences there too.

#

Converting them to URP isn't exactly easy if you want to keep them in code form, as URP doesn't support surface shaders. You could use shadergraph though, with the PBR Master node. It's basically the same inputs, just set up the textures and other properties with the appropriate references, sample them, maybe a few multiplies with colours like in the code, then connect them up to the master.

frozen mason
regal stag
#

@frozen mason Correct, for the aura outline you'd probably want an unlit shader anyway though. In URP you wouldn't want to use a multi-pass shader, but separate the toon effect and aura into separate shaders/materials.There's already tutorials on toon shaders using shader graph.

The inverted-hull outline technique is a bit awkward to do in shadergraph because you don't have access to "Cull Front". You can however have a Two Sided shader and use the Is Front Face node to set the alpha below the alpha clip threshold for front faces to have them be clipped, personally I don't really like that method. The alternative is writing it via code. Unity actually has an example for URP that does inverted-hull outlines here : https://github.com/Unity-Technologies/UniversalRenderingExamples/blob/master/Assets/_CompletedDemos/ToonOutlinePostprocessCompleted/Shaders/ToonBasicOutline.shader, Shouldn't be too difficult to add a noise texture to that.

#

Once you have the separate materials, you can apply both of them to the MeshRenderer. It'll warn you about using shader passes instead but using this method works with the SRP batcher.

frozen mason
#

Whoa as always a lot of info @regal stag thanks for tips! Will check them out !

regal stag
#

Oh, Joyce's shader isn't actually using inverted-hull outlines, it's modifying the clip space position. That's also a bit awkward in shadergraph though as the vertex position input expects object space. The inverted-hull technique might still work though.

frozen mason
#

Im lookig at some of the docs and the code for shaders is nightmare to me... I can play with graph but code is different to handle ;/ damn why its so hard πŸ˜„

regal stag
#

Doesn't help that the code for URP is a bit different. The Shaderlab stuff is the same, but the hlsl code uses different function names compared to built-in.

frozen mason
#

How do I even create shader out of the code from that github u pasted?

regal stag
#

Create an "Unlit Shader", then replace the contents

frozen mason
#

Or do I need to modify this one to accommodate the noise in it ?

teal breach
#

bgolus also had a really nice article on outlines, but its a slightly more complicated method

#

that is the deep end though!

frozen mason
#

To advanced for sure πŸ˜„ at least for me πŸ˜†

regal stag
#

Yea you'll want to modify and add the noise. Can't go over it much now but might tomorrow if you can't figure it out. For the hlsl part urp tends to use TEXTURE2D(_TexName); SAMPLER(sampler_TexName); outside function for declaring, then SAMPLE_TEXTURE2D(_TexName, sampler_TexName, uv); instead of tex2D, though that might still work too idk

frozen mason
#

Cool will try and play with that. Thank you so much !

regal stag
#

For the rim bit later I think you'll also need viewDir and world normal passed from vert to frag. I think those would be calculated using float3 viewDir = vertexInput.positionWS - _WorldSpaceCameraPos; float3 worldNormal = TransformObjectToWorldNormal(normalOS);

#

That might help cover some of the annoying URP specific function stuff

woeful crypt
#

I need some help figuring out what's wrong with my water shader. I wrote it following a Catlike Coding tutorial on water shaders (this one: https://catlikecoding.com/unity/tutorials/flow/looking-through-water/), and it seems to work fine on my machine both in the editor and in builds, but when I gave a build to my friends, the water was messed up on each of their machines.

In the picture (all post-process effects have been turned off to rule them out), the right side is what it's supposed to look like (transparent with displaced vertices for objects behind it), but it appears as the left side for other people, a solid surface.

#

Would love for some help figuring out what's going on here, thanks!!

ornate blade
#

Is it possible, given a 100x1 input texture, to make a shader that outputs a square 'filled' up to the points in that texture?

#

(example input and output there)

deep hemlock
#

Hi Guys ! πŸ™‚ I hope you're doing well ! I'm working on a shader using the shader graph. I would like to know if it's possible to recreate this kind of effect (screenshot from S.Designer) ? My input doesn't have any "anti aliased" border (only black and white) and I would like to simulate a smooth transition.

amber saffron
#

Depends on what your input here is, but there is no easy or optimised way to "blur" like this else than by sampling multiple times with offsets and average the value.

#

@ornate blade Yes.

#

Sample the texture, and then use the output value in a step node. Value as threshold, and uv.y as input.

regal stag
#

I would assume that's using signed distance functions rather than texture sampling

amber saffron
#

Well, ideally that is what you'd like to do, but he specifically said that the input is only B&W

regal stag
#

Ah i see, ideally you'd change it so the texture already has that distance information baked in if it needs to be applied to any shape

ornate blade
#

Thanks for the feedback @amber saffron , ill give that a go πŸ™‚

deep hemlock
#

Thank you, that's what I thought, it's not the best approach. I'm going to take the problem in a different way.

lusty badger
#

Why are the UVs inside struct AttributesMesh only float2 when they're float4 in ShaderGraph?

meager pelican
#

@deep hemlock You might be able to use a derivative function on the color value maybe combined with step. It will "shift" it slightly though, as the lower/left directions will "smear" extra grey values unless you're careful. And you'd have to put in logic to decide what the values can be, but you can detect a drastic change from the previous pixel. Tends to be "splotchy"/aliased on irregular curves.

#

And that works at the per-pixel level, so it will vary depending on distance and also on the monitor/resolution.

cobalt bolt
west fulcrum
#

Why doesn't the alpha show correctly? The bottom part of my image is a transparent shadow.

amber saffron
#

In the texture preview ? That's just because of the preview, you should look at an object in the scene that uses this material.

west fulcrum
#

sorry, the texture is incorrect, i messed it up.

#

Thanks for the reply πŸ™‚

thick fulcrum
#

@cobalt bolt Don't want to sound rude but. The OP in that issue spells out the solution, no new shader needed. This is not a shader problem, c# code is required to fix the issue.

cobalt bolt
#

The project uses 3 custom shaders "if URP then: change shader references from standard shaders/materials to URP shaders". The author himself is not familiar with URP

eager folio
#

@cobalt bolt Well, you haven't actually mentioned what these custom shaders do that standard URP shaders won't.

cobalt bolt
#

Sorry, I am not familiar with shaders at all. I have no idea. I am just a user of the asset, but I need to use it on a URP project, and I can't because of the shaders. The shaders are just a blackbox to me, they are needed for the asset to work. The shaders are here https://github.com/Siccity/GLTFUtility/tree/master/Materials . I was hoping an experienced shader programmer could take a look and convert them, if it isn't too much trouble.

amber saffron
#

You don't have to write a shader to make it work. Use URP/Lit shader, and bind the textures to the proper properties, and it's good to go

fiery granite
acoustic canyon
#

Hey there, new to the server, wondering if I could get some help with HDRP orthographic depth buffers. I'm using a setup similar to @regal stag's URP shadergraph for intersection (attached image), but I can't seem to read anything from the depth buffer in HDRP from an orthographic view. I'm reliant on a number of HDRP only features, but being able to do orthographic depth intersection would be insanely useful. Thanks!

regal stag
#

@acoustic canyon Just tested the graph in HDRP, it needs to be transparent (same as in URP), but it seems to work fine? I'm using the HDRP template project, didn't really change any settings. Also targetting windows, not sure if it would be different for mac/linux, not sure how I'd test it.

acoustic canyon
#

@regal stag you're totally right, I just forgot to enable transparent in both the shader and material on HDRP. Thanks a ton!

faint notch
#

Any ideas why I get artifacts?

#

Just making a simple Transition shader plugged into Sprite Unlit Master, seems my step node is not precise enough to filter the gradient values in my texture?

acoustic canyon
#

Could be that your gradient texture has some noise in it (often added to prevent visible banding) which would case the jagged edge you're seeing when the step is applied?

sick pawn
#

Sorry to intrude, but does anyone know what sub shader I have to write to get LWRP shaders to work in the Standard Render Pipeline?

#

Please ping/dm if you know

frozen mason
#

@regal stag I miserably fail trying to compose something πŸ˜„

regal stag
#

@frozen mason πŸ˜…
Need some help?

devout quarry
#

I've got this pattern

#

And I want to make the cutoff hard, so I apply a step function

#

step(edge, color) and this works

#

but the color is cyan in the end

frozen mason
#

@regal stag If possible. Yes please πŸ˜„ What I got is bunch of errors nothing more

devout quarry
#

this is with an edge value of 0.04

#

I kinda get why it's happening when I try to use a step function on a color but I'm not sure how to make it so the color is green all the way?

#

even for small values for 'edge'

regal stag
#

Would be better to step on a greyscale / single value, then apply the colour after.

devout quarry
#

Yeah that's true but the issue is I don't have access to the color at that point of the process

#

but maybe I should reconsider my design then :/

frozen mason
grand jolt
#

Can someone give me some good shader graph tutorials?

regal stag
#

@frozen mason This should work. It's basically the same as the code Joyce (minionsart) shared, but converted to URP. Also using inverted-hull outlines but I've left in the version they used as well : https://pastebin.com/ze7XZu0q
The noise kinda changes size based on distance away though which is a bit weird, probably will want to look into a way of fixing that.

grand jolt
#

ok

frozen mason
#

@regal stag Whoa, didn't expect that. Thank you! And yeah definitely wouldn't be able to even come up with such thing xD You rock!

regal stag
#

@frozen mason oh I forgot to normalize the view direction, might want to add that in. πŸ˜…

faint notch
#

@acoustic canyon thanks for the suggestion, but that cant be it - i have tried with various textures, some from tutorials where others made it work. Starting to wonder if it could be a setting i missed.

faint notch
#

I am thinking it could be a project setting issue, or a bug due to the Sprite unlit being experimental

#

Does anyone have a example of overlay shader for URP using Blit maybe?

amber saffron
#

@devout quarry I don't know how much controll you have over the color input, but the best way is to do how Cyan mentioned.
If you can't, as I see it the gradient is going from a single color to black. So this could be interpreted in HSV color space as a linear change in the value.
You could convert the color to HSV, step the V value, and then reconvert to RGB, keeping the hue and saturation ?

faint notch
#

Guess ill just write a sprite unlit shader with code, also just found this note about experimental 2D renderer Note: If you have the experimental 2D Renderer enabled (menu: Graphics Settings > add the 2D Renderer Asset under Scriptable Render Pipeline Settings), some of the options related to 3D rendering in the URP Asset don't have any impact on your final app or game.

devout quarry
#

@amber saffron that seems like a nice workaround that would work!

#

But indeed I'm going to try a different approach first

cursive girder
#

Hi all, I'm having a slight issue with depth of field and transparency sorting. I have a semi-transparent object with a shader that pushes its position in the render queue to 2450, which stops it from blurring with depth of field. However when this transparent object sits in front of the skybox (which is on 1000 in the renderer queue), blue is rendered through the transparent object. I just want the skybox to be rendered behind the transparent object. Is this possible? Sorry, real shader noob here...

neon gull
#

@cursive girder can you send an image of how it currently looks?

frozen mason
#

@regal stag This would be it ?
output.viewDirWS = normalize((vertexInput.positionWS - GetCameraPositionWS()));

Given that It actually gives almost the exact result at least its looking good to me πŸ˜„ ❀️ one thing is that camera distance but I think its not that bad but the other one after doing normalize I can see green artifacts if close to the target

regal stag
#

@frozen mason Yeah, not sure what's causing that really. It's probably some negative values in the calcualtions somewhere. saturate usually fixes that (clamps between 0 and 1). Though if you are using HDR colours & bloom you probably don't want to clamp values above 1. Maybe return max(0, result); on the final line would fix it? Although maybe the alpha also shouldn't go above 1... Might need to separate them and do something like return float4(max(0,result.rgb),saturate(result.a));? 🀷

wary horizon
#

Does anyone know how i can edit this and have a texture that is "hologrammed" ? for example: an earth texture

regal stag
#

You'd want to swap the Albedo input on the master node out for a Sample Texture 2D rather than a solid colour property. Unless I'm misunderstanding what you want to achieve.

wary horizon
#

If that makes sense?

#

@regal stag putting a texture as the albedo isnt doing anything unfortunately

regal stag
#

Oh, if you want the texture to glow with the hologram then you might want to sample and multiply it with the hologram result, before putting it into emission, rather than using albedo.

wary horizon
#

Shaders are hard lol

meager pelican
#

@cursive girder You didn't mention what pipeline you're using, but you can try something like camera sacking or layer masks to draw that object on top, later, after the PP effects.

#

That would make it more of a procedural/C# side issue, rather than a shader issue. But I'm unclear from your post for exactly what you want.

regal stag
#

@wary horizon Maybe add them instead of multiplying then?
I understand that you want to apply the texture to the hologram effect but there is a few ways you could do that depending on the result you want. Multiplying would replace the "white" of the hologram with the colour from the texture. If that's not what you want, then Adding might be more what you expect.

wary horizon
teal breach
#

Cyan I saw you tweeted about a retro challenge?

acoustic canyon
#

@wary horizon that looks killer! If it's the scan line seam that you're trying to avoid, you could try doing the scan lines procedurally based off object local/world position like so:

wary horizon
#

@acoustic canyon i think its the texture wrapping around the sphere, since its a vertical line

#

and thank you πŸ™‚

glad warren
#

I want to make a mesh gradually visible from top to bottom. What am I looking for ? Something like reverse dissolve shader ? I'm not accustomed with the terminology so I will appreciate any directions

wary horizon
#

Vertical dissolve?

#

@glad warren ^

#

@acoustic canyon but yea, its this line which is the problem, which i believe is the seam of the texture

glad warren
#

@random silo, yeah the opposite of it

#

thank you

#

can you pass the shader to me ?

#

is it somewhere available ?

wary horizon
#

i gave you a full screenshot of how to set it up

grand jolt
#

woop woop , I have just fnished writing some shaders for the legacy renderer which are fully compatible with HDRP's packed texture masks. I even have variants now which support colormapping.

#

now I can use the same packed textures in both HDRP and legacy UnityChanCheer

digital vector
#

ok so, back at my shadowcaster problem:
I mentioned how my shader, when discarding pixels in the shadowcaster, treats fragments that are being discarded like there is no geometry at all, and renders the shadows behind that geometry

#

and maybe it has something to do with the way i do the shadows?

#
geometry to fragment struct -> unityShadowCoord4 _ShadowCoord : TEXCOORD4 (only for forwardpass)
in forward pass: vertex._ShadowCoord = ComputeScreenPos(vertex.pos);
in shadowcaster pass: UnityApplyLinearShadowBias(vertex.pos);

forward fragment function: SHADOW_ATTENUATION(i)
caster fragment function: SHADOW_CASTER_FRAGMENT(i)
#

this is basically how i get the shadows

#

is anything not happening like expected that causes the behavior? πŸ€”

grand jolt
#

are you trying to write one shadowcaster to handle transparent and opaque things as a single material?

#

but by discarding inside that "if" block everything inside SHADOW_CASTER_FRAGMENT will no longer execute.

#

so that will prevent your foilage from casting shadows.

#

which is what I expect from reading that.

#

@digital vector

digital vector
#

my goal is to have the entire rendered geometry (the grass generated through a geometry shader and the original geometry) receive shadows, but only have the original geometry cast one

#

and everyone said "just discard the pixel on the shadow caster", but as seen in these screenshots, that obviously wont work

#

at least not with the current way i do it

grand jolt
#

is this inside a standard shader?

#

because this code might also be executed inside meta and any pass which writes to depth.

digital vector
#

its a shader pass on top of a surface shader (but it overwrites the original shadows)

#

the orig. geometry uses a surface shader, but the grass particles have two passes have special functions

grand jolt
#

hmm

#

hmm. idk

#

😭

digital vector
#

it looks like the shadow caster fragment writes to some depth buffer, so i'd only need to figure out how to do that manually

regal stag
#

@digital vector Been looking into this more and I can kinda understand why this is happening. As you mentioned, the shadowcaster pass is also used for a camera's depth texture. It's compared with the directional light's shadowmap in order to determine whether a shadow should be cast or not. And that's put into a screen space shadow texture before anything is even rendered. By discarding it's like that pixel isn't there so you see the shadows through it.

I'm unsure if there's a way to manually handle it, but I am aware that the mesh renderer has a Cast Shadows option - which has the ability to remove the object from the shadowmap, but keep it in the camera depth texture. That should mean it doesn't cast shadows but still receives/draws them correctly? My suggestion would be to separate the geometry grass bits into a separate shader without the rest of the ground and see if using that cast shadows option would work (with a regular shadowcaster pass).

meager pelican
#

I see what you want now.
Some have implemented their own shadow maps.
However, you're in a catch-22 situation. I think.
One suggestion if Cyan's method doesn't produce what you want, you may wish to research transparent objects receiving shadows. As that would not cast them, but would receive them and shade the object. Not exactly the same, but it would give you some ideas. You could consider actually putting your grass in a transparent pass so the shadowmap casting isn't done for it, even if it returns opaque alpha.
Just spitballing.

#

There are forum posts and sample shaders on the topic.

hasty vessel
#

Basic shader help question:

To start, I tried doing this with the default standard material and it works fine. It only stops working when I make my own shader. What I am doing is using "SetTexture" in a script and updating the material in real time.

I made a new shader, which for now is just an exposed Texture2D > Sample2D > Master. The name of the exposed texture is "BaseTexture". In the code, I am running gameObject.GetComponent<Renderer>().material.SetTexture("BaseTexture", _tex); When I do this, however, the texture in the game is not updating. Anyone know what I'm doing wrong?

spark wind
#

quick question:
My unity scene view no longer shows the shaders as they look in game view? not sure if I ticked a setting or not but I can't find anything different.
What it looks like now

#

what it should look like

#

(note the shader in scene view is also no longer animated)

sage moss
#

@spark wind Maybe you turned off the depth pass, or the water surface is included in the depth now?

spark wind
#

Why would it appear different in game view then scene view if depth was interpreted differently?

#

example, then next to eachother in both views

#

AH ********* @sage moss thanks for the answer, but it turns out I had view in ISO and tilted it at some point and didn't notice.

#

Iso seems to disable depth pass

regal stag
#

Isometric doesn't disable the depth but it works differently so produces a different result. Mainly, it's already linear so the raw to linear01 conversion isn't needed.

#

@hasty vessel Are you sure it shouldn't be "_BaseTexture" instead?

hasty vessel
#

I'm not sure, does the C# scripting require _ be added to the property name you generate?

regal stag
#

You can change the reference, thats the one you need to use in c#

hasty vessel
#

Ahh, gotcha. That would do it

#

Yep that fixed it, thank you

regal stag
#

I think it doesn't need to start with _ but that tends to be what most shaders do

digital vector
#

i'll see if i can find something about that. thanks for the help guys!

#

on another note, what editor do you guys use to program shaders? im using visual studio, and while it has syntax highlighting, it does not have auto complete or error highlighting

devout quarry
#

@spark wind isn't this from an asset?

#

you could contact the publisher?

devout quarry
#

Skinned mesh renderers don't get instanced?

#

Is there a way to make them support instancing?

acoustic canyon
#

@digital vector I just use Visual Studio as well, there's a number of extensions you can get to help with syntax highlighting and auto complete, etc

toxic fable
#

Hello there fellow devs. I've got a problem with Shader Graph (URP) and I couldn't find any help on the web. I've created a shader for fading materials into transparency. It's only used for map edge tiles, as you can see in below attached screenshot. It works just as intended in Shader Graph preview, the scene view AND in the game view as well (the screenshot itself is rendered from the game view). Although when I hit play and enter play mode, meshes that are using this shader are not rendered at all. What might be the trouble?

#

The graph is pretty complex for screenshoting, as I've put all the variations in, so if needed, I can provide the shader graph file right quick

#

The selected part is what creates the fading effect, it's just being repeated with different split values to variate the fading orientation

minor vapor
#

how do you enable shaders

#

is it just an option in hdrp

grand jolt
#

So what's up with URP outputting the wrong color despite me simply outputting it in the shader?

#
 float4 Fragment(Varyings input) : SV_Target
 {
             
     return _OutlineColor;
 }```
#

Linear colorspace, tonemapping and color correction turned off.

spark wind
#

@devout quarry yep that's the asset demo scene, my scene was a bit of a mess at the time so I felt it best to show my issue using the demo πŸ˜…

ripe wigeon
#

I have what I imagine is a pretty simple problem

#

My model has a diffuse with an alpha channel

#

We are using a custom shader that takes all of the mask inputs as individual textures

#

When I try change my surface type to transparent, the whole model goes invisible

#

Any idea why?

regal stag
#

Your master node alpha (Vector1) input is coming out of a Vector4, which means it takes the first component only, aka red, not actually the alpha channel. Is that intended? If not, use the A output from the sample texture instead

ripe wigeon
#

Ah, I had actually changed that a minute ago - it does it even with the alpha output from the sample

#

@regal stag

regal stag
#

Hmm okay, is the AlphaClipThreshold culling it maybe?

ripe wigeon
#

No - changing that to any value has no effect

regal stag
#

If you use a Preview node on the sample texture A output what does it look like?

ripe wigeon
#

Let me just drop the texture I'm playing with in

regal stag
#

What does the preview of the A channel look like?

ripe wigeon
regal stag
#

Hm okay. Not really sure why it would be going invisible then. Might be something specific to HDRP.

ripe wigeon
#

Possibly πŸ€·β€β™‚οΈ

regal stag
#

If parts of the model doesn't need to be transparent then using separate materials would be better yeah. Still not sure why it would go invisible though.

spiral kite
#

How do i fix this

spiral kite
#

it looks like this in shader graph

sage moss
#

@spiral kite check your UV's

spiral kite
#

how

#

?

#

im using the default cylinder

#

thats the world space UV i made

toxic fable
#

[ShaderGraph] What is the reason for Position node set to object space to produce different look in edit mode than in play mode? Why is there a difference at all?

regal stag
#

@toxic fable It's possible that there is some batching going on, (like combining multiple meshes into a single one). Therefore the object space positions are no longer relative to the game object's origin, but a combined origin?

toxic fable
#

Oh yeah, that might be it. The batching is happening, intentionally in fact. I completely overlooked that

regal stag
#

You could potentially do the fading using UVs, or even just vertex colors instead of relying on the position

toxic fable
#

Actually I thought I need to rely on the position because I needed the fade to always go from the center of the mesh, regardless of its UVs, shape or anything. And this method worked, just not in the play mode. I need to revert Lerp min max values to get it working properly in play mode (but then it's not working properly in edit mode). But realizing the batching is behind this is a huge step forward. Thank you for that sir

toxic fable
#

Switched off the batching for the fade tiles (really just a couple of them, so the draw call number increase is minimal, barely noticeable) and it works perfectly. Thank you again @regal stag

regal stag
#

@toxic fable No problem. Also something of note, if the SRP Batcher is enabled those draw calls should also be batched using that (or I guess technically the "setup" for those draw calls is the part that's batched) - and as far as I'm aware that doesn't affect the object space positions.
I assume the other batching is either some custom thing, or due to marking objects as static - I tend to do a lot of procedural stuff so hardly use it.

spiral kite
#

idk if the world pos uv is causing that

#

and y do it look like that

regal stag
#

It would be. You can think of world space uvs as "projecting" the texture through the axis that isn't being used in the uvs. If you are using the X and Z position for example, the texture would stretch through the Y axis since it's not being taken into account.

spiral kite
#

so how do i fix

regal stag
#

It's better for flat meshes. Triplanar mapping is a way to apply the same concept to 3D, but if you just want to apply a texture to a 3D object you usually want to use the UVs from the model. (leaving the UV input blank or using the UV node).

spiral kite
#

and how do i make it match when the obj is scaled

#

like the texture to not scale

regal stag
#

You would want to control the Tiling of the UVs using the object's scale (which could be obtained via the Object node, or perhaps passed in as a property and controlled from script instead). Probably only need one axis of that scale, so you'd want to Split it. I'm not sure which axis corresponds to the diameter though.

rich ice
#

So, this is my first time working with shaders and I'm using a pbr shader graph...
I have a circular alpha connected to a slider.
It works well on the front but I need 2 things that I can't figure out.
I want to feather the alpha edges and I also want only the front and back faces of the wall object to use the shader alpha.
Currently, my sides are fully transparent on the sides, top, and bottom (when I tick two-sided, which I want).

rich ice
#

Anyone know shaders that can help? πŸ˜…

rich ice
#

I got a tip from someone to look up triplanar techniques!
However, most tutorials i'm finding work with multiplying for emissions. Anyone know how to do triplanar shader graphs for alpha?

#

I just need 1 side to have the alpha. the other 2 would be solid.
But i wanted the alpha in both directions on the 1 axis

acoustic canyon
#

@rich ice something like this should work. Triplanar involves mapping textures around all 3 axes, you're really only looking for mapping on a single axis if I'm correct. This is just using the default soft particle texture with a step to control the size of the hole

rich ice
#

@acoustic canyon
I appreciate the response!
Unfortunately, it seems your set up doesn't do anything except remove the hole, keep the sides invisible, and make the object disappear when clip is below 1?
I'm pretty sure i have the same setup?

#

though, my circle in step seems bigger..

#

So, actually, the sides seem to disappear due to two sided being checked... but i want that effect to see the inside of the object.. is there a way around this?
The normals seem flipped

#

Ah, yes. They are on the back to.

obsidian shore
#

Hello,
I have a problem. I am making a game with URP Forward render. I have a Spriteshape object with a custom Sprite-Lit-Default shader.
The Shader is thisone.

#

i can't change the SpriteShape Renderer color via inspector. I would have to create a different material for every color. How can i fix this?
(I can't use the 2D renderer because if i do my device do not support the app)

regal stag
rugged verge
#

I have some "torches" in the game, and I would like to apply "Bloom" on it.

What's the cleanest way to do so? Separate camera? I don't want it on other sprites. Or a material? Or is there a better way?

2D Game.

obsidian shore
#

@regal stag yes that one, but it does not work, it only work if I use the URP with 2D renderer

#

but i can't do so because if i do i get an "hardware not supported for this application" on my device

#

It was a problem some months ago but then they fixed it on 2D renderer, but not on Forward renderer

regal stag
#

@obsidian shore Have you tried changing your color property to _RendererColor instead of _Color? Maybe also with and without it being exposed, not sure if that would change anything.

The fix in that post seems to just suggest adding that to the shader includes that I assume the 2D renderer's sprite master nodes end up using. I imagine the colour is being passed in still on the C# side, it just needs to use the right property reference.

obsidian shore
#

i'll try it

#

@regal stag it works! thank you

#

but i get an error in shader graph

regal stag
#

Hmmm okay, that's annoying. If it's already defined somewhere you might be able to output it from a Custom Function node rather than using the color property then

obsidian shore
#

i am new to shadergrpah can you explain?

regal stag
#

Hmm it doesn't appear to be working

#

I'm unsure if there's a way to stop that error then. It doesn't seem to be accessible in shadergraph, but defining it causes redefinition. I think it only happens with the sprite master nodes though, would the Unlit one still work with the SpriteShape?

obsidian shore
#

i try

#

i have to create a new shadergraph with sprite unlit and copy all the nodes from the sprite lit?

regal stag
#

Should be able to create an Unlit master node in the graph, you can then right-click and set it as the active one

obsidian shore
#

i get the same error "redefinition of _RendererColor"

#

how can i use the custon function node?

regal stag
#

What about after closing and reopening the graph?

obsidian shore
#

nope still error

regal stag
#

Also which URP version are you on?

obsidian shore
#

8.2.0

rugged verge
#

I have some "torches" in the game, and I would like to apply "Bloom" on it.

What's the cleanest way to do so? Separate camera? I don't want it on other sprites. Or a material? Or is there a better way?

2D Game.
@rugged verge nvm just found out ShaderGraph's intensity is quite helpful for this

regal stag
#

@obsidian shore Okay, so I've installed the SpriteShape to check what's going on. It looks like the "Sprite Unlit Master" actually works with the color as is. It doesn't need the property. The "Sprite Lit Master" does not, but if you aren't in the 2D renderer I don't think you are using that lighting system anyway.

obsidian shore
#

well i am using 2D lights in my scene

regal stag
#

I don't think the 2D lights work without the 2D renderer though? I can't even create them without switching

obsidian shore
#

oh right. Well it's becasue i had 2D renderer but then i get hardware error on my device, so i deleted the 2D renderer and added a forward renderer

#

and the 2D lights created with 2D renderer are still in the scene

regal stag
#

Right, those lights would have stopped working then

obsidian shore
#

but the lights works, i dont' see the scene black

regal stag
#

I think they basically become unlit in the forward renderer

obsidian shore
#

With Unlit it does not works for me

#

i have empty Main Preview in shadergraph and in the scene my spriteshape is magenta

#

oh nvm i forgot to click on save asset......

regal stag
#

You'll need to remove the _RendererColor too if you haven't already

obsidian shore
#

i did

#

Thank you very much

#

for the help

obsidian shore
#

@regal stag hey, sorry if i bother you but i have another problem. I don't know if it related to the sahders or something else

#

nvm i think i understood how to fix it, sorry again

regal stag
#

No worries

obsidian shore
regal stag
#

Ah okay, might be some precision issues with the _Time input getting too large. Might be able to use a Vector1 property instead, (either passed into the shader using material.SetFloat, or probably easier setting it globally using Shader.SetGlobalFloat). Control that value from script but rather than keeping it growing, have it repeat instead.

#

The downside to repeating is there will be a jump where the UVs suddenly change, but if the pattern repeats perfectly too it shouldn't be noticeable.

obsidian shore
#

okay i'll try, thanks

#

one more thing, i can't see the preview in my shadergraph window

#

is that bad?

regal stag
#

Mmm not sure. If it works in-game that's all that really matters. I hardly ever use the main preview in shadergraph.

#

It might be something like the default property values in the graph aren't the same as what it uses in-game. Not sure which mesh the main preview has been set to either, but if it's a quad it might just need rotating.

#

Unless you are referring to the main preview isn't visible in the graph at all? There's usually a button at the top to show/hide it

obsidian shore
#

the main preview window is visible

#

it's just empty

regal stag
#

Might be something specific to the Sprite master node too

#

I'd check the Tiling property default values

#

If it's set to (0,0) it should probably be changed to (1,1) instead

obsidian shore
#

it's 1,1

regal stag
#

Idk then, might just be the fact it's a sprite node

#

At least it still works in-game

obsidian shore
#

ye as you said that's the important thing

quick holly
#

is there a way to make shaders for hdrp not using shader graphs (i.e. code) but still using the lit base (like, surface shaders)? they get a bit unsolvably tangled up and unreadable at times like here

rugged verge
#

ShaderGraph seems so good, but it's really hard to convert my existing 2D project with lots of assets used to be compatible with it.

regal stag
#

Technically you could probably also handle everything in the custom function and just pass each output out and connect it to the master node.

wary horizon
#

i have a heat distort shader on that purple orb, it distorts the air around itself, but why it is not distorting the "moon" thing i have right next to it? O.o

quick holly
#

any way i can stop shader graph from freezing the editor for 15 seconds every time i change something in the shader? it really isn't helping when trying to figure out what nodes i should delete

rugged verge
#

Does this happen to anyone else? I just installed URP and sometimes this started happening

#

Fixed it by adding/removing a random component.

#

Is there a way to soften the shadow? I found out about "Shadow Caster 2D" that Unity just added, seems to work really nice.

#

oh it's apparently not possible https://answers.unity.com/questions/1757684/is-it-possible-to-use-soft-shadows-in-2d-using-urp.html

It's a great start though, since it means I might not need to rely on assets for the lighting

#

Another thing I wanted was how to "refract" the shadows and light, when it hits a wall. Just like how it does in the real world.

#

and a feature to make the "shadow shape" the physical shape of the sprite

rugged verge
#

Shader Graph + URP is so good, wish some older asset authors could make their assets compatible with URP (some asset authors seemed to have trouble with it due to some constraints, e.g. custom rendering injection) and the shadow to have soft shadows. Hope to see Shader Graph + URP come more popular and ingrained into assets and the future.

rugged verge
#

To summarise, these two ideas would be nice for the Unity URP team to implement.

1. For 2D Shadows: soft shadows vs distance (lots of demand for soft shadows, just search on Google to see this), option to choose what defines the shadow shape (e.g. collider, or the Physics Outline/Shape of a sprite) - this is important for tilemaps instead of toil of manually adjusting the shadow shape in tilemaps.
2. Work with existing popular Unity asset authors to help migrate their asset to become compatible with URP. A lot of popular assets like SC Post Processing is not able to become compatible with Unity URP 2D due to not being able to inject custom rendering.

Keep up the great work Unity, really love the updates and hope to see more.

meager pelican
#

@quick holly While there's no surface shaders for URP, shader graph is a CODE GENERATOR just like surface shaders are.

Sooo....... start with a simple lit graph, put a couple token nodes in to do what you want where convenient, and then skip all the spaghetti and just right click on the master node and "view code" (whatever they call it). Edit from there and tweak it. But once you edit it, you can't go back to SG. It's a one-way operation.

frozen mason
#

How can I determine which parts of the texture are responsoble for given parts on the mesh? I have a blade with texture where I would like to add some HDR color for bloom to the blade but cant say which part on texture is the blade

meager pelican
#

UV mapping (the XY texture coordinate mapping for each triangle vertex) is done in the modeling software. Unity's shader gets passed the UV's from the model. Unless you're procedurally generating the mesh, then you calc the UVs.

#

@wary horizon One object doesn't know about the others. The way that is done is either

  1. draw it later and get a hold of the back-buffer somehow (grabpass, or URP's screen grab thing) and blend
  2. Do a post-processing effect over top of the finished screen.

I think unity has a tutorial for distortion, they used option #1 for some force field thing. IIRC

past comet
#

Never been to URP but is Speculative surface achievable in URP by default?
I know a shader graph can, but I'm wondering if there's anything by default. Just a curiosity

coarse path
#

Does the HDRP layered lit texture work with polybrush vertex painting? It's telling me it's an unsupported material

amber saffron
#

@coarse path Yes it does.

coarse path
#

It says none of the materials on the object support vertex colors.

#

I've tried changing vertex color mode into multiplicative and additive

amber saffron
#

Hum, last time I tried it worked :/

#

iirc, you should use multiplicative

obsidian shore
#

Ah okay, might be some precision issues with the _Time input getting too large. Might be able to use a Vector1 property instead, (either passed into the shader using material.SetFloat, or probably easier setting it globally using Shader.SetGlobalFloat). Control that value from script but rather than keeping it growing, have it repeat instead.
@regal stag hey sorry to bother you again but despite my efforts i am not able to make it work properly. Could you show me how to do it? (Just the few lines of code for the repeating cycle) I would like not to use code on Update function. Can i do it directly in the shadergrpah?

regal stag
#

Shaders can't really update properties, so it would have to be in C# using Update. Would probably be something like

float speed = 1;
float t = 0;
int property = Shader.PropertyToID("_CustomTime"); // might need to be set in Start idk
void Update(){
  t += Time.deltaTime * speed;
  if (t < 0) t++;
  if (t > 1) t--;
  Shader.SetGlobalFloat(property, t);
}```

If you want different speeds for different shaders, could also provide it as a Vector4 instead, with each component increasing at a different rate. Unity's _Time variable actually already does this too, but they still don't repeat so will probably reach a point where precision issues become a problem.

You might be able to produce repeating using the Fraction node instead. (Removes the integer part of a number. Basically a repeating 0-1 value. So if _Time was a value of 5.5 it would return 0.5. As time increases to 6.0 it would return 0). But I'm not sure if that would fix the precision issues though.
#

It's possible that the fraction node will still help as the precision of a float in C#/cpu vs the shader/gpu might be different for mobile/tablet?

obsidian shore
#

okay thanks a lot again

#

@regal stag the Fraction node solution seems to fix the issue

regal niche
#

hi how can i create a terrain with shader ? thanks a lot

#

i just used a plane it works now

frozen mason
#

How can I achieve this kind of effect where Items has some glowing colour and also that blink of white glare effect which comes from side to side (not that constant slow one the one which blinks fast)

#

This is what I got so far. Dont know how the blink effect can be achieved. And I feel the colors are to much vibrant??

#

This is my graph. Do I need the Normal and occlusion? Can I do something fancy with those?? How I could improve the look of those to be more similar like on the videos with the characters

grand jolt
#

@wary horizon does your shader use a GrabPass?

#

if so , everything else must render before your orb.

spring field
#

Can I get a uniform half with GetFloat? I appear to be having an issue with it.

lost stirrup
#

hello guys, I tried to make material for my character's hair, but I had this problem with the normal map in my shader. it is as if the material did not have a good resolution when rendering the normal map. Has anyone had this problem?

#

just for the record, I tried to use larger textures and it didn't work.

low lichen
#

@lost stirrup Looks like aliasing to me

#

As in, it's too high resolution

spice tinsel
#

I was wondering what node do you need to add to a shader to remove a color from the sprite?

low lichen
#

@spice tinsel Like keying for a green screen?

spice tinsel
#

yeah basically

#

but I dont want to replace the green only remove it

low lichen
#

I don't know of a node that does that, but I'm sure you can combine some other nodes to get the same effect

amber saffron
#

You need to create a "mask" from the color you want of the sprite.
This doesn't need a lot of nodes : subtract, absolute, step.

spice tinsel
#

Ok created them now how do I remove the specific colour

#

@amber saffron

amber saffron
#

Hey, I gave you some hints, please try to think by yourself how you could isolate the color πŸ™‚

spice tinsel
#

ok

amber saffron
#

I'll be here to help if you can't figure it out

#

If it's "easier", you could also make it in two nodes : distance and step

spice tinsel
#

ok

#

Cause I think that for Diastance A is your Sprite and B is the color you want to remove

amber saffron
#

Yep, you're on the good path

#

You can increase the tolerence using the "in" input of step.

#

This is maybe cause by texture compression

spice tinsel
#

I tried that too but the sprite is now like distance

amber saffron
#

idk what you used a value, but remember that the distance is a small fraction, as color value goes from 0 to 1

spice tinsel
#

I think I just solved the problem with a diffrent method

#

I'll send a pic

#

The main preview is Subtract without the black

#

thanks still

#

for the help

amber saffron
#

Oh, I forgot about this node πŸ˜„

#

But the calculation there is probably pretty similar

spice tinsel
#

Also another question how do I remove or shrink the main preview tab?

low lichen
#

It can be resized on the bottom right corner

#

But it should have been the top left corner, or just all corners.
Remy pls fix

spice tinsel
#

The minus on the bottom left corner I had seen it before and tried to shrink it but finally now it worked

amber saffron
#

This is already in the work for future updates iirc

#

Oh I think I got why the distance method didn't work ... do you have alpha in you sprite ? You were doing the calculations on RGB+A, while the color mask node only works on RGB

spice tinsel
#

oh yeah it alpha

crystal light
#

Is it possibly to write a Tessellated Terrain shader in HDRP?

amber saffron
#

Technically, yes. But hard

twilit elbow
#

any idea how i activate "back then front face rendering" on URP Standard Lit Shaders? the render order is totally messed up

#

at least that is what i think to be the problem

amber saffron
#

There is no option for that, but you could do it using custom render features.
Back then front rendering is basically two passes.

twilit elbow
#

that seems pretty dumb to be honest. :/ i know that hdrp contains such a thing and i wonder how it has worked before that. the problem is not unique and always occures when working with transparent objects

meager pelican
#

Cheap work around is making the model two-sided.

amber saffron
#

Transparent sorting has always been something tricky, and the double side option doesn't exist in built-in unity, so it was a non issue

#

Making the model two sided will not help when using transparency.

twilit elbow
#

that doesn't change which faces are drawn infront of each other @meager pelican

meager pelican
#

True, if it's a sort-order thing.

#

Sorry

twilit elbow
#

no problem

amber saffron
#

In HDRP when you enable this option, it automatically handles it in two passes

#

In URP, you have to do it by yourself.

twilit elbow
#

huh

meager pelican
#

There is the concept of order-independent-transparency, but it's going to be even harder to implement than your other options, and not practical for SG at all. It's an accumulation buffer.

twilit elbow
#

do you know a tutorial how to achieve that Remy? i never had anything to do with the custom render features. and i am an idiot

amber saffron
#

But it seems that it relies on the settings of an override material ... and I don't remember if its possible to do front face culling right now.

meager pelican
#

Can you change the model? What about opaque for it all except the glass?
@twilit elbow Transparent should still clip to the depth buffer, but it won't update it, but if it's just the glass........
That model looks like it's mixed use...opaque parts and glass parts in one model, which is what I think is creating your problem, right?

twilit elbow
#

@meager pelican that is what i try right now but it will take some time since today is definitly a bad day for me

#

so yeah making the railing there own objects and splitting it from the glass worked so far. it's kind of a shame to have more unneccessary objects in the scene but at least the railing no longer looks glitchy ^.^

verbal drum
#

hey friends, i have finished the roguelike tutorial and i am personalising. I want to add rain but no matter what I do it always initiates behind the Board like this:

#

does anyone know how I might fix this?

meager pelican
#

How are you doing it now?

verbal drum
#

i havent changed anything

#

i tried sorting layers for the tile pieces and game objects but it made no difference

#

each level is generated by script and prefabs

#

the rain is a permanent game object i the scene

meager pelican
#

I'm still not 100% on how you did it, but it sounds like you're experiencing clipping against the depth buffer. What pipeline are you in? Is there some quad on the camera for the rain to "fall" on?

verbal drum
#

URP and Im guessing no quad because it does not sound familiar

meager pelican
#

Well, you could try VFX graph if your target can support it.
With Shader Graph, you could put a transparent quad up in front of the camera and scroll a rain texture vertically.
Or use a native particle system.
Thoughts.

verbal drum
#

@meager pelican thanks for this feedback! i hope it'll help πŸ˜›

grand jolt
#

@twilit elbow you can assign different materials to the same object without splitting the mesh in Blender.

twilit elbow
#

@grand jolt true haven't thought of that. but i still have the extra drawcall for the 2nd material now. but hey my game will never be published anyways so who cares about performance xD

marsh turret
#

bit of a specialist thing

#

but is there any way to deduce the distance between a vertex we're shading and an object vertically beneath it?

#

I'm doing water shading and currently I'm using the scene depth multiplied by the camera's far-plane to get a depth effect on the water

#

but obviosly when the player moves, the depth of the water "changes" based on the view point etc

#

what i need is the distance between the surface of the water we're shading and the sea-bed directly underneath it

meager pelican
#

If you can compute the world-space depth of both points, then subtract them, you get a consistent value regardless of view location. So world-space.

marsh turret
#

yeah but how do i get the world-space depth of the seabed?

#

that's the bit i'm stuck on

meager pelican
#

Are you using shader graph, or built-in?

marsh turret
#

cos it's not where the camera might be pointing

grand jolt
#

You can bake a heightmap or an SDF.

marsh turret
#

shadergraph, URP

acoustic canyon
#

You could potentially use a separate camera, rendering from above the water to a render texture

marsh turret
#

ooho, heightmap

#

how would i go about that? Any tips?

meager pelican
#

SG can give you worldspace of a vertex, and then interpolate it for the water surface, for example. As far as computing it yourself, you can just project a vector from the camera to the point, and add that to the camera WS value.

acoustic canyon
#

For a two camera approach, add a second orthographic camera directly above your water facing down, andhave it render to a render texture with the depth texture, then use that depth texture in your water shader to do what you want

grand jolt
#

Actually, true, you could render depth of the seabed from top down view and then reproject it to worldspace in the shader.

marsh turret
#

SG can give you worldspace of a vertex, and then interpolate it for the water surface, for example. As far as computing it yourself, you can just project a vector from the camera to the point, and add that to the camera WS value.
@meager pelican I understood about half of that

acoustic canyon
#

You'd also want to set it's render layers to ignore the character and anything else that's not water or seabed, but it should be a relatively straightforward setup

marsh turret
#

i like the idea of what carpe said cos then it will account for waves, other objects etc

meager pelican
#

There's a formula for reconstructing the WS pos of a depth-valued pixel. I don't have it off the top of my head, but google is your friend. No additional rendering required (and faster).

marsh turret
#

but i'm still lost...I need a vector from the worldspace of the surface of the water

#

to the point with the same x, z coords but the y coord of the seabed

meager pelican
#

That's in your water shader. But it would grab the scene depth texture to get the bottom point (which you want to calc the ws from too). For the water, you already have a WS point for all the pixels.

#

Just a sec, I'll google it for you.

marsh turret
#

i have the ws for all the points of the water;

#

what i'm not "getting" is how I pass in the depth of teh terrain at that instance

#

like, we're shading water at 102, 0.3, 203

acoustic canyon
#

Although @meager pelican if you have a camera angle where the bottom of the seabed isn't visible, there's no screenspace method of getting the position of the bottom of the seabed, as it's not rendered, correct? (Shallow camera angle in deep water)

marsh turret
#

how do I get the y position of the seabed underneath it, so 102, -34, 203?

meager pelican
#

Agree....

marsh turret
#

aaaha

#

i see what you're saying

meager pelican
marsh turret
#

that's what i'm currently doing

meager pelican
#

I think that would technically only happen if the view was partly submerged, or you were "out to sea".

marsh turret
#

and using the out to lerp between a shallow and a deep water color

meager pelican
#

There's a bunch of water shaders too. Even a good demo in the boat attack project.

marsh turret
#

that's what that was "lifted" from πŸ˜‰

#

but it seems to shade some of the water a different colours based on view direction

#

so you'll be walking around a nice turquiose beach then look up and it suddenly gets darker

acoustic canyon
#

@meager pelican The case I'm thinking of is something like this:
The blue point at the water's surface is visible, but the point directly beneath it on the bottom of the seabed isn't visible, so there's no way to find it's depth from just the camera

devout quarry
#

@marsh turret I'm only reading parts of the convo but most ways of getting depth are camera dependent

#

so if you do coloration based on that, it might shift when changing your view

#

most shaders subtract alpha component of raw screen position from the scene depth in eye space right?

#

but then you're working in eye space, so camera relative. If you want more 'robust' way of getting depth, you'll need to do something else

#

convert scene depth to world position then check the difference between that world position and the world position of the water pixel

#

ah I see @meager pelican already mentioned that

#

oke yeah I'm exactly saying what he said oops

#

@marsh turret you can take a look here at the 'scene depth to world position'

#

but it's an old document and might be full of errors so don't look at it too much ahha (it was basically just me dumping my thoughts in a document while writing a shader)

grand jolt
#

You can steal world space depth reconstruction from basically any SSAO URP project on Github.

marsh turret
#

thanks everyone

meager pelican
#

The trick is that you want the pixel under the water, so it depends on your needs. If you're at a rather oblique angle, you get mostly reflection anyway. And the more "downward" you look, the closer the pixel is to the proper pixel from a y-axis perspective. That's why the top-down camera depth works if you can afford the 2nd render pass, because you can use the worldspace xz postion and get the y depth at that water pixel, not counting refraction. Or you just fake it with calcing WS from the depth buffer and see if it's "close enough".

#

One trick is to render to a lower resolution (like 1/2 each way so 1/4 the pixels) texture for the seafloor depth. Fewer pixels = faster.

acoustic canyon
#

Yep, you might be able to get the render resolution even lower than that and just let bilinear filtering do the job. You could potentially use a single pass simple blur on the camera, although that could start to add more overhead instead, you'd have to try it and see

grand jolt
#

@meager pelican can you help me with picking a graphics format for a fullscreen temporary for custom effects?

#

Am I supposed to use GraphicsFormatUtility.GetGraphicsFormat(RenderTextureFormat.ARGB32, isRgb: true) for a format with alpha channel?

#

Usually I use the camera texture descriptor URP provides me but I need an alpha channel now.

crystal light
#

@amber saffron thank you for your response. I have managed to hack-port the tessellation shader inside a custom terrain shader, and the whole sub-division is fine.

#

the only problem I'm getting is due to shading artifacts.

#

what could cause those?

amber saffron
#

Is it projected shadow issue ? If yes, have you also applied your tesselation/displacement code to the shadow caster pass ?

meager pelican
#

@grand jolt Mobile or desktop? How much do you care about precision?

#

With mobile, you want to be aware of Half4 type stuffis.

grand jolt
#

@meager pelican desktop. I guess float is the highest precision, I'll be fine with that.

#

Since halfs are macrod to floats anyway.

meager pelican
#

Yeah, on desktops it is.
Did you see this list of formats? The next question is "what's generally fastest" or maybe "smallest" if you care about memory.

grand jolt
#

I peeked at URP post processing and it seems R8G8B8A8_SRGB is the default for linear color space.

#

They try to use B10G11R11_UFloatPack32 if it's supported but this looks like aliens made it.

#

I just don't want the game to run only on my PC πŸ˜„

meager pelican
#

I usually pass that type of enum to whatever render texture api call. I think it often ends up being the 8-bit format in the end, but intermediate work textures you might want floats and 32 bit.

grand jolt
#

It's for a fullscren noise texture.

#

That shaders sample and blend how they want.

meager pelican
#

So basically you work in high precision and then end up dumping it back down to 8 bits for outputting the results. If I understand correctly.

#

Again, precision. 32 bits

#

if you want full precision floats.

grand jolt
#

So 8 bits per channel, got it.

meager pelican
#

Uh...

grand jolt
#

Oh, you mean 32 per channel.

meager pelican
#

πŸ™‚

grand jolt
#

Alright, dumb q: why do all formats have r, g and b in random order.

#

Does it impact the rgb value order in shaders?

meager pelican
#

IDK

#

But 32 for all is probably overkill

sleek granite
#

It's not a random order. Some monitors expect pixel values in different orders.
Mine for example in BGRA

meager pelican
#

I"m just saying you might not want to limit to 8 bits...loosing precision

#

Some are 16 bits for example.

#

IIRC Unity has some defaults and figures that out for you somehow.

#

You want a script created RGBA temporary rendter texture, or just texture?

#

Are you computing the noise in a shader?

grand jolt
#

I pass a RenderTextureDescriptor to CommandBuffer.GetTemporary.

meager pelican
#

Is it writable by shaders?

grand jolt
#

In my custom scriptable render pass I allocate a temporary, blit my noise shader into it and then all world shaders sample it using screen positions to blend it on top of them.