#archived-shaders

1 messages · Page 229 of 1

cosmic prairie
#

if you multiply this direction with the original distance to the origo you'd get the original vector back

#

(this is how you normalize, just reverse , divide a vector by it's length)

#

if you want a circle just try a distance function

compact moth
#

I'm trying to make my material look less like the same tile. I'm trying to do things like flip them 180 degrees in random spots, and move the tiles left and right slightly. does anyone know of a good shadergraph tutorial for this? or just a unity Asset that will do the job?

sweet pine
cosmic prairie
#

no, but you can make one

#

well

#

maybe on asset store, not anything official

#

also, if it is possible, do not use built-in pipeline

cosmic prairie
sweet pine
#

Yeah, I really want to switch to URP. I know this would be pretty easy in ShaderGraph, but I'm taking over a project that's halfway done already, so not sure how much trouble switching the pipeline would be

cosmic prairie
#

depends, how many custom shaders and weird rendering magic the project is doing

left fjord
#

That is, a vector space is a group of directions?

cosmic prairie
#

what do you mean by "vector space"

#

yes I guess?

#

you could also define them as points

#

like

#

(1,2)

#

could be a direction with a length

#

or a point of 2D space

compact moth
left fjord
#

Sorry, I'm not very good at shaders, so I can express myself incomprehensibly.

tight phoenix
#

I am trying to create a "mask" effect between two prefabs.
FAR more robust than just slapping a SortingGroup/SpriteMask on it, which I also cannot do because the assets I need to mask out might be above or below another asset that I do not want to be masked.

I -think- what I want for this is an SRP "Rendering Layer Mask" but I can next to zero documentation on what this thing is or how to use it

#

That field when moused over has a tooltip that says it can be used with the SRP "DrawRenderers" command

#

but where/how do I "use" this "command"

#

I think what im trying to achieve is a shader effect

#

but Its hard to describe verbally without just seeing it, and I cant just show you it without making it first

simple violet
#

you might want to look into stencils

tight phoenix
#

Hmm yes, stencil buffers, cutting holes in things, that is what I am trying to do 🤔

#

Ill do some googling on shader stencils

tulip dust
#

Is it possible to write to an RWStructuredBuffer<T> inside a custom function inside of an HDRP ShaderGraph? Right now it just absolutely refuses to work even with the proper Graphics.SetRandomWriteTarget setup

tight phoenix
#

Why are the URP render mask layers PHYSICS layers and not SORTING layers?

#

I see no reason at all why it has to use the physics layers to decide how something should be rendered, isn't that how the sorting layers, which sort things being rendered, work?

#

like, this seems totally insane to me but maybe im just not clearly understanding the reason why it uses physics layers instead of sorting layers?

tight phoenix
#

I tried to follow this tutorial, but it doesnt work

#

even though my set up is identical to theirs, nothing renders at all

#

Do you have a link to an actual functional Stencil buffer tutorial for Unity URP? Preferably one that actually uses rendering layers and not physics layers

meager pelican
#

@tight phoenixWhat's a physics layer?

#

Physics can use the layer system, but I don't know of "physics layers".

#

Layers are layers to me.

#

Cameras use them, to determine draw call order. That groups your shader calls.

tight phoenix
#

regular 'layers' are physics layers

#

and things like triggers and collisions are per layer

tight phoenix
#

Does anyone have any working examples of shader graph + stencil buffers?

#

I can't find any online

#

I am trying to cut a hole in multiple SpriteRenderers to reveal other sprite Renderers, or the opposite, only render a group of sprite renderers masked by a stencil buffer

Ideally with transparency, not just binary visible/not visible

shadow locust
upper sphinx
#

Hi I followed a wind shader tutorial (https://youtu.be/L_Bzcw9tqTc) for shader graph and everything worked until I wanted to add this lerp so that the bottom of the swaying grass won’t move and now my mesh has these gaps as seen in the photo. what can I do about that?

Let's learn how to make realistic grass with Unity Shader Graph!

This video is sponsored by Unity

● Download grass assets: https://ole.unity.com/grasssway

● Art That Moves: https://bit.ly/2VW85He

● More realistic vegetation: https://bit.ly/2EAxC5d

● Mesh Generation: https://bit.ly/2u7vee3

♥ Support Brackeys on Patreon: http://patreon.com/b...

▶ Play video
shadow locust
#

so they're drifting away from each other

#

One solution is to use a model that doesn't have duplicate vertices

upper sphinx
shadow locust
#

It's so you get flat shading

#

Because a mesh has a normal per vertex, and if you want the three faces to be perfectly flat shaded and not shaded as if they smoothly curve around the corners you need to have separate vertices with separate normals

static hollow
#

I already have a screenspace dithering effect that displays under certain lighting, but I don't know how to make it a solid shade when the lighting gets even darker

#

I've been using a shader which Cyan, on this discord provided when I had similar questions earlier (which I realize now that I forgot to reply to their help and I'm sorry about that lol but it was super helpful) changes which what shade of pixels are visible on the dither texture, which is really close to what I'm looking for, but not quite

#

which is this shader

#

Just to me more clear is ideally I want to have a shader like this:

#

and the main issue is that I don't know how to make it switch from the dither shading to the step-styled shading when the light gets low enough

#

any advice would be awesome

plain urchin
#

Hi all. I'm doing a Blit to a renderTexture containing some data for the GPU to use (it's related to vfx)
It used to work back in 2019.4, but now for some reason after upgrading to 2020.3 and ONLY in my laptop, there's a weird problem...

The target RT is 64x6 size. So, 6 channels of 64 float array
The thing is, when all 64 float are supposed to be 0s, some floats above [32] gets full value (or flickers, idk)
If all 64 float has a tiny bit of values, some of those floats above [32] gets more "balanced", but still "corrupted"

#

And i use it like so

        _buffer.SetData(toneEqArray, 0, 0, w); // Toned Spectrum
        _buffer.SetData(tonePeaks, 0, w * 1, w); // Tone Peak Amp
        _buffer.SetData(pitchToneArray, 0, w * 2, w); // Pitch Tone
        _buffer.SetData(pitchFreqArray, 0, w * 3, w); // Pitch Freq 
        _buffer.SetData(pitchAmpArray, 0, w * 4, w); // Pitch Amp
        _buffer.SetData(filterPass, 0, w * 5, w); // Filter Pass including Bypass(volume)


        _material.SetBuffer("_Waveform", _buffer);
        _material.SetInt("_Width", toneEqDampen.Length);
        _material.SetInt("_Height", texHeight);

        Graphics.Blit(null, spectrumTexture, _material, 0);```
#

It does feel like a mipmap issue, but it's already initialized with FilterMode.Point

        spectrumTexture = new RenderTexture(width, texHeight, 16, RenderTextureFormat.ARGB32);
        spectrumTexture.filterMode = FilterMode.Point;
        spectrumTexture.Create();

        _buffer = new ComputeBuffer(width * texHeight, sizeof(float));

        // Debug.Log("XY: " + width + " : " + sizeof(float));
        var shader = display.bakerShader;// Shader.Find("Hidden/Lasp/WaveformBaker");
        _material = new Material(shader);```
regal stag
crisp trellis
#

to fade out a GameObject with multiple MeshRenderers what would a good solution be?

#

(urp)

regal stag
crisp trellis
#

my idea is I should have versions of the materials that are transparent and swap them before the fade out
then transition,

#

but when doing this (swapping opaque materials with transparent ones) the swap would be notable for some meshes, because transparent renders differently

regal stag
crisp trellis
#

thanks but that would not work with urp/lit shader though? - would have to make a custom one?

regal stag
#

Yeah you'd need to make a custom one

crisp trellis
#

I feel trying to replace the default shaders is problematic. maybe some people do that on a regular basis. though the default ones are probably very optimized or at least complicated. also from a point of view of maintaining them
(mainly talking about lit one)

#

oh wait probably ignoring shader graph here lol

regal stag
#

The URP/Lit shader is quite similar to the Lit shader graph, which handles all the lighting for you. Just need to add the properties and Sample Texture 2D nodes for albedo, normal, metallic/specular, etc. Might also be able to find a graph online that replicates the URP/Lit. There's a Dither node so adding that part is easier.

crisp trellis
#

bingo. thanks for refreshing my memory 😄

#

I thought shader graph lit should be pretty much the same as the normal lit shader

#

you say quite similar. is there a difference in behavior you know about? (not an implementation difference though, as they must obviously slightly differ)

regal stag
#

I say quite similar because the lighting style is the same afaik but the graph is blank and wont have any properties/textures

crisp trellis
#

alright 👍

#

hm

#

alpha clipping means rendering it transparent with a clip threshold, is that correct?

#

which mean using the transparent shader - therefore I'd have the "transparent rendering artefacts" still?

#

meaning if I didn't want that I had to go with dithering

regal stag
crisp trellis
#

but that does not fade for materials with alpha 1 everywhere I guess

regal stag
#

Yea you'd need the dither too

crisp trellis
#

except I'd do it in the shader perhaps

#

oh

#

have you done that before?

#

are the results good?

#

combining dither and alpha clip then?

#

didn't think of that that sounds good

#

hm yeah you said that. sorry got that wrong

#

well thank you

meager pelican
silver sparrow
#

what is the colorspace of the Color node by default? HSV or RGB?

silver sparrow
#

aight thanks

fringe hound
#

Hello! Someone knows how to use a video in shader graph???

wraith inlet
# static hollow Just to me more clear is ideally I want to have a shader like this:

imo, it seems like the strategy should be to create the banding first, and then if it is in a certain band create the dither effect. I don't use shader graph, so I don't know if there are specific nodes to do that easily.

  1. Get illumination
  2. transform illumination into stepped/banded illumination levels
  3. calculate remapped level so that it is 0 if below dithered band, 0-1 in dithered band, and 1 above dithered band
  4. pass remapped value into dither pattern to get dither pattern for your current band. If you're outside the dithered band, it will just give you a solid color. otherwise, it'll give you the pattern.
  5. Combine original banded illumination levels (2) with dither pattern (4) to get your final color
tight phoenix
#

Im trying to edit someone else's shader to use a texture as a mask instead of their math as a mask

#

I don't really understand it so I don't know how to get it to do what I want

#

I have the texture input as a mask (I think) good to go, but I am struggling to position the mask in world space where I want it to be positioned

#

they did this, but I dont understand how any of it works so I can't modify it to do what I need

#

TLDR: How do I position a texture in a shader at an explicit position in world space?

quaint python
#

I'm implementing a custom render pipeline. Does anyone know if it's possible to schedule a compute shader as part of the pipeline, perhaps in the ScriptableRenderContext?

#

Specifically, what I'm looking to do is precompute some information over each (preferably culled) vertex, which I'll eventually need to access in the vertex shader, but if it's possible to inject a compute stage I think I can figure out the rest.

#

I can't find any documentation around this on Google - it's just people looking to run a compute shader between the vertex and fragment stages, which doesn't seem possible. I want to run it before the standard pipeline, but after culling.

cerulean mountain
#

FOW progress: https://youtu.be/MTN1oZf4t-I
anyone ideas how to use a int bitmap 128x128
and render it with some shader magic into a nice looking FOW? (using build-in)

I am currently using a Color array and putting that into a texture each frame, which is even less performant than my old FOW system.
So that won't do

Hi there,
I've been experimenting with making a completely new FOW system for my RTS game.

The old system uses Ray-casts around each unit on a circular plane to detect obstacles and builds an umbrella shaped mesh, which is then used as a mask for the FOW camera which renders this into a render-texture which in turn is then used by a projector.
...

▶ Play video
tight phoenix
#

The left node graph scales from the center of a texture instead of the bottom left coordinate

#

but it stops scaling from the "center" of the texture if I use an offset parameter in the Tiling and Offset

#

I want to scale from the center of the offset, how do I do this?

#

There must be some math to combine these two concepts, center-scaling and offset position

quaint python
#

Now I just have to figure out how to get the vertex stream into the compute shader and pass forward the generated info

tight phoenix
#

Im so close but I dont know whats wrong

#

if I use the cut out position in the Scale from Center portion, I can set "where" it scales from

#

but when I try to actually use it in the Mask, the "center" is never centered right

#

the scale from center / position doesnt align perfectly

#

These two values control where the "center" of the scaling happens, but they also dont

#

if I change them to any other value, it does move the "center" but then it also stops scaling from the "center"

#

What am I doing wrong!?!?!?! I don't get it , atall

#

Getting frustrated

regal stag
tight phoenix
#

How do I reverse values

regal stag
#

Negate

tight phoenix
#

nevermind, it goes here

#

position 0,0 in theirs is the bottom left, but for me because of my scale offset stuff, its dead center hrmmgh

#

because I need it to scale from the center, but also offset

#

everything keeps screwing up

#

every time I offset it, it stops scaling from the center

#

I cant figure out how to "offset" it the RIGHT way

regal stag
#

Did you try what I posted above?

tight phoenix
#

Trying it now

tight phoenix
#

it sort of works but the position is still wrong

#

I know I need to move the final thing -0.5 -0.5

#

but i dont know where to insert that movement that doesnt fuck up the positioning/scaling in some way

regal stag
#

I think Add it between the Vector2 and Subtract nodes.

tight phoenix
#

I'm unclear on which "between" vector2 and subtract refers to

#

vector 2 goes to a subtract, and it goes to the add at the end, if I add it back after that vector2, isnt that the same as just the vector 2 being zero?

regal stag
#

I mean the Vector2 in your Cutout Position group

tight phoenix
#

The shader is very close to being done

#

Theirs uses the Screen Position as part of the Cutout Position

#

the "Cutout Position" is a world space coordinate

#

you can see in the preview theirs is a perfect circle on the sphere

#

if I plug what I have in, it does not show a perfect rectangle because its not taking the screen position into account yet

#

I need to now somehow use the screen position hhmm

#

I did it all on my own, I'm not a total moron!

#

plug in the screen position in place of the UV coordinate

#

😺

#

@regal stag Could not have figured it out without you

#

in practice it works exactly as I was hoping, its cutting a hole in my SpriteRenderer, but more importantly the hole has gradiated transparency, something a simple SpriteMask doesn't have

runic sundial
#

I am having trouble on installing Universal Render Pipeline package anyone knows something?

upper sphinx
cobalt hawk
#

How would I create a shader similar to the metal mario effect in mario 64?

delicate spire
regal stag
delicate spire
regal stag
narrow beacon
#

Any way to implement like an event system in shadergraph?

#

Like if I shoot an object with a bullet, that object will have a dissolve effect

simple violet
#

not the way to go about it

#

make a material manager that changes the values of the material and other objects have access to that manager

narrow beacon
#

material manager?

simple violet
#

materialmanager.cs or name it whatever you'd like
then access the materials made from the shader you want to edit

narrow beacon
#

oh like a material manager script

narrow beacon
simple violet
#

not necessarily

#

look at how he accesses the shader

regal stag
#

You can have the dissolve included in the bullet shader but based on a float property which you only change when you want the dissolve to happen. See material.SetFloat

narrow beacon
#

The dissolve affect is based off of time so how would I implement that?

simple violet
#

coroutine

narrow beacon
#

can you have coroutines in shadergraphs?

simple violet
#

no?

narrow beacon
#

oh wait me dumb

simple violet
#

seems like you need to look at more tutorials

#

not trying to be rude but just giving advice

#

:)

narrow beacon
#

I'm just gonna experiment and see if I can figure something out, thanks anyways

tight phoenix
hearty obsidian
#

Is there any way to get a mesh's local bounds from inside shader graph? I'm trying to paint a mesh from top to bottom and expose a normalized value to paint it. E.g. 0 = unpainted, 1 = fully painted, 0.5 is half painted starting from the top.

I did it initially by manually inputing the top and bottom values but now the meshes will change and will hold different proportions. I can sample the mesh's verts and pass the top-most and bottom-most values to the shader, but I wondered if there's a more convenient way that I could possibly be unaware of?

meager pelican
hearty obsidian
meager pelican
#

The problem with GPU mesh data is that there is no "mesh global" data associated with a mesh, other than what you set on the shader.

hearty obsidian
#

@meager pelican Hm, that's better for my use case actually! Good thinking

#

Pardon my ignorance, but how does shader graph expose a scale property

#

Object scale that is. Wouldn't that mean that there can be per-instance data passed while still maintaining a global material?

narrow beacon
#

Took some trial and error though

meager pelican
#

Or it's just set somehow. Then there's the macros to abstract those functions/values. So Object2World type of stuff.

#

Or whatever the hell it is called these days. lol. I think it's changed 3 times since I've started messing with Unity. lol

#

But those are standard things the engine "give you". So it's set up to do it.

#

Then there's user-defined instance data.

#

And that is where we get into GPU instancing and batching and stuff.

#

Which is actually more CBUFFERS but cloaked in macro abstractions.

#

And it's an array for the batch

hearty obsidian
#

CBUFFERS are basically a query tagged with data sent over to the GPU? Sort of like MPBs in unity? I'm trying to make sense of it. IIRC MPBs broke SRP batcher but would there be a way for me to batch that data and send it over to the GPU?

#

If you don't have time to enlighten a noob no hard feelings

meager pelican
tight phoenix
#

im working on editing someone else's shader.
I would like the effect to be size independent of the camera's height/width/aspect ratio.

Their version currently remains at the exact same size relative to height/width (shown here) but I need to change it to not get bigger/smalller relative to the world

#

I tried removing the "Divide" aspect ratio stuff, but doing that just makes the sprite squash and stretch instead of retain its aspect ratio

meager pelican
# hearty obsidian CBUFFERS are basically a query tagged with data sent over to the GPU? Sort of li...

CBUFFER is just "constant buffer" and you map it to a struct. Could be an array of struct.
MPB's are implemented with CBUFFERs too IIRC. Since they're constant and the shader doesn't write to them. They're just a special cased version used for material properties, with special macros.

This is contrasted with UAV's and "Structured buffers" (Read-only, or read-write) which are newer constructs.

You can batch up and send data in several ways. As to the mysteries of SRP batching, it goes by shader, but yeah, crap like that (MPB's or whatever) have historically been a problem.

I'm not a SRP pro like Cyan or others here so maybe they can comment more, but yeah, that stuff seems to confuse it. Although Shader Graph had/has some "experimental" instanced stuff last I knew, so it would be worth digging in. Sorry I can't help more but I don't have time to keep up with their moving target.

hearty obsidian
#

@meager pelican I really, really appreciate you walking me through this. This has helped shed some light onto the topic. Baking the data into the mesh will do just fine!

merry rose
#

Any idea anyone about how to correctly accumulate light? I now tried several accumulations but each of them stales at not being able to go down to zero, it stays right above zero giving this grayish look onto the scene.

fathom glacier
#

Playing with shader graph for the first time and for some reason just piping a texture to the fragment color output through a sample texture 2d node mangles the texture and I can't figure out why. Any guidance?

runic sundial
#

So I followed a couple of tutorials on how to use URP, but my project settings looks different from the tutorial anyone can help?

#

here is how it looks to me

#

here how the tutorial looks

fathom citrus
#

It could be that there are 2 different versions of unity and or URp

runic sundial
#

Among all these assets which one should I use? because none of them seems to work to me

fathom citrus
#

What are you trying to do?

runic sundial
#

I was trying to use the shader graphs

fathom citrus
#

Is it 2D?

runic sundial
#

Yes

fathom citrus
#

Did you already set up urp or this is what you want to do?

#

Like the URP asset do you have it set up in the project settings already?

runic sundial
#

I just installed the package

#

I createrd the assets

#

but it just makes all my materials pink

#

all the particles

fathom citrus
#

Go to Project Settings and see if the URP Asset is selected

runic sundial
#

like this

fathom citrus
#

Under Quality

#

Something like that

#

Yea

#

Now

runic sundial
#

no wait thats different

#

I put it under graphics

fathom citrus
#

Go under Edit > Rendering > Materials > Upgrade All Built-In materials to URP

fathom citrus
runic sundial
#

now I put it my self

fathom citrus
#

Yh

runic sundial
#

yeah its not there

fathom citrus
#

Did you put it in the Quality as well?

runic sundial
#

yes

fathom citrus
#

That’s strange

runic sundial
#

right

fathom citrus
#

Restart the editor?

runic sundial
#

restarting

fathom citrus
#

Alright

runic sundial
#

nope still same result

#

I must be missing somethin

fathom citrus
#

Lol idk sorry

runic sundial
#

np

fathom citrus
#

Maybe others have a better solution

#

I am more an HDRP guy😅

runic sundial
#

I only wanted to use the shader graphs if you have any better Ideas

fathom citrus
#

Lol try the built in one?

#

Or try downloading it from package manager

runic sundial
#

built in one?

#

I did not find it

fathom citrus
#

No the built in render pipeline

regal stag
# fathom glacier Playing with shader graph for the first time and for some reason just piping a t...

The texture is probably fine. The preview looks like that as they do not show transparency - only the RGB channels. You can preview the alpha separately by attaching a Preview node to the A output.

If you need the colour channels to be masked by alpha, Multiply the RGBA with the A output. Otherwise, just connect A to the Alpha port on the master stack if graph settings is Transparent (or using alpha clip)

regal stag
runic sundial
deep siren
#

hey

#

im wondering, is simple lit with specular highlights faster than lit?
i cannot find this information anywhere on google and i'm pretty bad at shaders. My guess it is a little bit faster but is it significant? what about non specular highlighted simple it? is this one significantly faster than lit?

#

in URP

meager pelican
#

These days, "lit" is PBR, which is more math per pixel. It adds up.
"significantly" is a subjective term, and will vary according to hardware/target-platform.

If you don't need PBR, you don't need it. It depends on what LOOK you're after. Simple specular shaders are fine if that's what you want.

mental thorn
#

Is there any way to have transparency work on on materials for UI images? I have an URP unlit material assigned to a UI image and it looks as expected in game view when the game isn't started yet, but if I start the game it disappears. This does not happen however if the material has no transparency. I'm using Amplify Shader Editor btw.

patent plinth
#

I noticed there;s flipbook node in shadergraph, are there any good tutorials regarding this node?

#

nevermind, Apparently @regal stag mentioned this a couple of time on his blog.. 👍

tight phoenix
#

I have a SpriteRenderer render texture of a camera, in the Shadergraph, how do I make the Render Texture UV match the world size of what it's rendering?

The render texture should be of the full size of the camera, but I only want to display a slice of it the size of the object

#

the tiny square there is the render texture, instead of the full render texture, I would like to only see a slice of that texture identical in size to the actual world objects

#

like a seamless "window"

tight phoenix
#

In Shadergraph, how do I set up my nodes so that if I scale my object, the texture doesnt stretch

#

if I scale the object, the UVs get stretched, which is normal, but how would I make that not happen?

#

Hmm Tri-planar projection can do this, ill look there

tight phoenix
#

how do I make my render texture not squished

#

I know the problem is that the thing I am projecting it onto is not the same aspect ratio as the camera

#

but I dont know how to fix that in shader graph

#

I want it to be not squished, and match the exact world size, I want it to be indistinguishable from the game

#

hrmgh I cant even figure out why the camera is the size that it is

#

"size" is just a single number, that doesnt explain why its a rectangle

#

the internet keeps saying 'Go to Game View and set an aspect ratio'

#

but this camera is not my Main Camera, its not listed in gameview anywhere

grand jolt
#

Dumb question, how do you map a cubemap as a texture overlay for a material?

#

As in, imagine you had a cube, and a cubemap for a skybox - by looking at the cube, you should see the skybox as it would normally be

grand jolt
#

Nevermind it's literally just view direction

fallen oracle
#

Trying to make a shader for rendering SpriteRenderers in 3D (using URP) where lights and such work properly. I currently have this, and it works for casting shadows, however lights dont really light up the sprite at all. Additionally theres some weirdness where other objects (and stuff like the editor grid) show up rendered in front

silver sparrow
# regal stag RGB

sorry for the ping but, the values are from a 0 - 1 scale as opposed to a 0 - 255 scale right?

silver sparrow
#

👌

south temple
#

Is it possible to use transform feedback in Unity ? (i'm using a geometry shader that output a lot of geometry that i would like to store)

grand jolt
#

Hey

#

How can I make a shader that applies a texture to the intersecting objects in shader graph?

#

eg.

left monolith
#

Is there a possibility to have height-maps with shader-graph?
or i guess, parralax is the better way to explain it.

I saw there was a node added in september 2021, but i can't find the paralax node

deft root
#

Hey! Is there a way to Change a property of a shader for only one gameObject? I have 3 gameobjects that need the shader, however, 2 of them work but for one it doesnt, it only works if I turn the "_Thickness" Property up. I know I could just make a new material and change it via there but I'm wondering if there's a different way

vocal narwhal
#

If you're not using SRPs then look into Material Property Blocks

#

if you are, then you modify the materials

deft root
#

ah alr

mental palm
#

Hey guys, I know this is a nauseatingly general question, but Im trying to make a psychedelic experience for my game but have no idea where to start or what trippy effects unity is capable of making and was just wondering if anyone had any cool ideas

#

I guess an animated skybox is a good place to start....

shadow locust
#

you can do some really cool things there

#

and custom shaders in general

trail lodge
#

anyone know why this is happening with sprite unlit shader? I'd expect the add node would add the white offset next to the original sprite, but instead its doing some sort of intersection between the two? not sure whats going on

quartz bison
#

Hi, is there somewhere an example of how to write a simple PBR shader with URP (without shader graph) ?

#

I'm looking for an equivalent of the default standard shader :

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

        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows

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

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;

        // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
        // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
        // #pragma instancing_options assumeuniformscaling
        UNITY_INSTANCING_BUFFER_START(Props)
            // put more per-instance properties here
        UNITY_INSTANCING_BUFFER_END(Props)

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

I'm trying to make a shader with multi passes and I cant find how to make it with shader graph, so I'm trying this way

quartz bison
#

What I want to do is to render transparent objects, but only the faces that are the closest to the camera (occlusion), both backface and front faces, but it creates some issues with some transparent meshes.

The workaround I have in unity standard is to have two passes like this, and it fixes the sorting issue:

Pass {
  Cull Off
  ZWrite On
  ColorMask 0
}
Pass {
  ZWrite Off
  ZTest Equal
  Blend SrcAlpha OneMinusSrcAlpha 
  Cull Off
...
...
...
#

Any idea how I can have these two passes for one shader in urp ?

wraith inlet
dim yoke
#

This is probably dum question but can division by zero in shader make the performance worse? I made shader that can sometimes do division by zero but I wrote the code in a way it doesn't have any visual artifacts even if the division by zero happens. Now I'm just wondering if it's bad practise (in terms of performance) to have shader that can have division by zero on it. I could use dynamic branching to avoid that but if it calculates it exactly as fast as regular division, there's no point of doing so.

mental bone
#

If it doesnt result in garbage values then I say its fine. Would love to hear other peoples oppinions on it

regal stag
#

I've heard that division by zero can result in different things depending on the platform but if it works on the one(s) you are targeting it's probably okay

dim yoke
# regal stag I've heard that division by zero can result in different things depending on the...

I have heard that too so I used ? operator to replace the result with the result I want if the divisor is zero (should probably change it to divisor < someSmallValue even though it seems to work now). According to my googling, hlsl doesn't produce branches when using ternary conditional operator but evaluates both sides always so I'm only worrying about the performance (because the division by zero happens even if I don't use the result of the division)

regal stag
# quartz bison What I want to do is to render transparent objects, but only the faces that are ...

Multipass shaders break the SRP Batching for those objects so it's not really recommended. But I do have a URP shader code article if you want to write without shader graph (it's linked in a pinned message).

I'd recommend splitting the passes into separate shaders/materials instead though and set the render queue on the first to 2999 (Transparent-1) or render it with RenderObjects feature in the Before Rendering Transparents event. Should give the same result if I'm not mistaken

regal stag
dim yoke
fast shore
#

ok I read the docs but I still don't get how threads work in compute shaders
look here I place quads using a position buffer in 12x12 grid using numthreads(256, 1, 1) and despite 256 not being divisible by 12 it works fine with a single dispatch group
the code is _PositionBuffer[id.x] = float4((_Width - 1 - (id.x % _Width)), floor(id.x / _Width), 0.0, 0.0);

#

but it uses a floor so I wanted to change it a bit to instead use numthreads(16, 16, 1) which should be the same and place quads using _PositionBuffer[id.x + id.y * _Width] = float4(id.x, id.y, 0.0, 0.0); but it breaks for some reason

#

at this point my brains not working very well so please let me know if theres an obvious error or if Im just using threads wrong

#

nevermind I understand why now still need to fix it somehow

#

fixed it but now there's an if smh if(id.x >= _Width || id.y >= _Width) {return;}

lofty vector
#

Why the water "reflection" 2d shader distorts normally inside unity, but not after build (on mobile)? It doesn't move and it looks like distorts only by x axis. Shader works like that: additive camera translates part of a screen into render texture, which is used as a shader texture to distort.

#

Upper is unity, lower is phone

nocturne ermine
#

No matter what I do in the Shader Editor my preview is always just flat pink. I am using 2021.1.9f1 and have ensure both Universal RP and Shader Graph packages are installed. Is there something obvious I am missing? I am VERY new to shader graph stuff.

regal stag
#

Make sure you also save the graph with the "Save Asset" button in the top left of the graph

nocturne ermine
midnight dagger
#

is there a way to make a shader that hides all objects behind it?

#

for a situation like this

#

i need to make the objects on sky hidden when player is below them

#

and all i can think of is adding a big plane object at sky that makes stuff behind it invisible

regal stag
midnight dagger
#

i cant think of a way to disabling them when the player is below

#

and my scripting capabilities for this project is limited, im not making a game im modding another unity game

#

its a huge map from an AAA game

deft root
#

Hey so I have an issue with my Shader that I made for my android game. The problem is that it doesnt show in the game when its built but it does in the in-unity editor, what could be the reason? its a simple cell shading thing

fringe hound
#

Hello! I am almost new in the shader graph world. I need to make an alpha mask but gradient! It seems that it is only possible to change the tolerance with the Alpha Clip Threshold but nothing about any gradient option. I am very curious to know if there is some way !!

native dome
#

how can i open this in shader graph and edit it? (URP, Shader graph package is installed.)

dim yoke
native dome
dim yoke
native dome
#

ohhh

#

i downloaded shader graph to URP but i cant seem to open any graphs

dim yoke
#

you can convert shader graph into some sort of shader code, but it doesn't work wise versa

native dome
#

i see

#

well but how can i open a new shader graph in urp?

dim yoke
native dome
#

any graph

#

closest i found was unlit but after opening that shader graph type i get many many errors for every node i open, and the main material doesn't exist:

dim yoke
native dome
#

oh, alright

dim yoke
native dome
#

new project with default render pipeline i believe

dim yoke
#

and then upgraded right?

native dome
#

i selected "3d"

#

no, i just installed "Shader graph"

#

i thought urp was the default

dim yoke
modest zealot
#

Hey all. This is is the issue I am having: I am trying to make a shader that works exactly like Standard, except that it inverts reflection probe data on the X axis

native dome
dim yoke
# native dome i thought urp was the default

the default is called Built-in Render Pipeline. urp is more optimized for low-end devices and hdrp is looking nicer on high-end devices. hdrp is much harder to set up and urp is pretty much same as build-in rp so ig urp is much easier to start with

native dome
#

OH MY GOD, it worked!!! @dim yoke thank you so so much!!!

#

all the errors disappeared, 😄 for some reason the material is still missing its texture, but il look on that online now

#

welp, unity shaders are really broken for me. any material i make is missing textures (pink)

#

if anyone know how to fix this, i will be really happy to know

dim yoke
native dome
#

yes, someone sent me a dm about this, apperently this is a huge problem with my computer (that also affects HDRP and shaders in general) basically a bug in unity. he is guiding me right now and seems to be fixing it

dim yoke
#

👍

upbeat nimbus
upper sphinx
#

In all the tutorials I watch, the Sample Cubemap node has a Normal input. Why doesn’t my node have it? I use URP shader graph

regal stag
restive girder
#

can someone help me or guide me on how to achieve this fake mirror effect(from the game ZOMBI) with shadergraph? I tried using the ScreenPosition node piped to the uv channel of the Sampletexture2d node, works well when moving the player but looks weird when rotating the camera.

steel notch
#

So I have a mesh that has Shapekeys (blender) and I want to color parts of the mesh based on how far the vertexs move from 1 key to the other.

hearty obsidian
#

any way to have an empty texture field default to clear instead of white in shadergraph?

boreal pewter
#

Hi guys, is there currently any way to have a property within shader graph be instanced? I've been looking at material property blocks, but it seems that they work for the entire material instead of just a single property..

dim yoke
restive girder
dim yoke
restive girder
#

Yeah i could use reflection probes
too, but since the player is Just an invisible first person type i dont need realistic reflections

dim yoke
restive girder
#

You are right , maybe i will try that, thanks

dim yoke
# restive girder You are right , maybe i will try that, thanks

np. in case you still want to use own single texture approach, you have to do something like this: so imagine the texture being somewhere in the world behind the mirror. to sample the texture correctly, you have to calculate the intersection point between the ray coming from camera to the fragment and the texture. you could for example have parameter (on the shader) that tells how many meters behind the mirror the texture is and also some parameters for the scale of the texture.

upper sphinx
#

how can I create a folder for the menu where you select the shader you want?

upper sphinx
dim yoke
#

no idea

upper sphinx
#

ok thank you

upper sphinx
#

does someone know how to make a black thing like this?

regal stag
regal stag
regal stag
upper sphinx
open linden
#

Is branching based on a property bad for performance, or is it mostly okay as all the pixels should execute the same body?

tranquil socket
#

is it possible to have LUTs wihout post-processing?

#

if I referenced the LUT texture in each material, and had the shader color-grade each pixel on each object, would that work as intended?

low lichen
tranquil socket
#

that's great, thank you 🙂

low lichen
#

The only thing that would be a bit different is transparent objects, since with post processing, the LUT is applied after everything has been blended

tranquil socket
#

oh yeah, didn't thank about that

#

any way around it?

low lichen
#

For normal alpha blended transparency, it shouldn't be very different, but additive or multiplicative blending could have quite a bit a difference

tranquil socket
#

should be fine then, we don't have anything except alpha-blended shaders, and there are very few objects in the scene that are transparent

tropic smelt
#

Is it correct that if I want 2 variants of a material at editor time, I need to create 2 completely separate materials & theres no way of making it share some of its data?
I would like 2 materials. Both should have the same textures, but I want one to be tinted slightly darker - and I would preferably like to make it so that if I swap the textures on one of them - the materials should swap on the other*(please ping on reply ❤️ )*

acoustic mirage
#

Hey, i have that problem with every material. But what means "Hidden/InternalErrorShader" and what can i do to fix it ?

torpid sapphire
tropic smelt
#

To be absoluetely honest, it sounds like a pure hell not being able to share properties across materials. To the point that I feel like telling my team that I refuse making the Unity materials x3

torpid sapphire
#

@tropic smelt material variants is currently in beta in 2022.1 for URP 😆 I agree this would've been handy a couple time for me in the past

tropic smelt
#

Well our project might be long finished before that becomes stable

#

Thanks for the sympathy though

torpid sapphire
#

@tropic smelt Material property blocks are not that complicated to implement though, and if you are using a custom shader, you could use a global texture parameter that are shared across all material instances, so you would only have to change the texture in one place with a little script.

tropic smelt
#

At least, ctrl C ctrl V or ctrl D works to duplicate materials in Unity's file explorer right?

hoary rain
#

Hello, everyone. So, recently I've managed to draw a rectangle in an unlit shader, and now I want to go further. How do I draw multiple rectangles? I've tried using for loop, but its performance wasn't good. Thanks in advance

broken vigil
#

pretty new to shader graphs, but how would I go about an effect like this? the main problem I got is figuring out how I would displace all the triangles of a mesh without them still attached to one another. https://www.youtube.com/watch?v=ndhFZ7WlWB8&t=1s&ab_channel=TNTC

Nowadays, in the video game world, it's not uncommon to find a disintegration effect applied to the body of the fallen enemies.
This kind of effect is also often used to recompose the player when it spawns.

Today we'll recreate this effect on Unity.

MODEL:
https://skfb.ly/6xowz

GITHUB:
https://github.com/ToughNutToCrack/Disintegration

OUR D...

▶ Play video
dawn prairie
#

I'm not sure if this is a shader issue or maybe a post processing issue, but I have this problem

#

I made a reddit post but didn't get any responses, I thought i'd try here, any help would be appreciated!

quaint python
quartz bison
#

Hi, I'm "cuting" my cylinder inside a shader and reconstructing a normal of the backfaces. So I send the normal and the position of the plane that is cutting the cylinder, and everything works fine. Now I'd like to generate coordinates for the backfaces using projection matrix, but I'm not good enough at math, can someone help me ? ^^

#

I'm not sure if what I want is clear

meager pelican
deft root
#

Asked this before, but does anyone know why my outline shader doesnt work when Exporting to Android (APK and URP)? Instead of being an outlines its basically inside of the gameObject, so when I zoom in on it, the inside is black. This works fine in the editor Image 1 is editor and in the export its well without that outline

#

None of my shaders work properly actually

#

I've never done shaders before

static hollow
#

how can I use a comparison node for getting in-between two values? I want my shader to do a specific thing between .4 and .5 but don't really know how to make that work with the comparison node

sly breach
#

nvm restarted editor now i can see the UV's

tropic smelt
#

Or do you want to invert the normals on a shader level?

quartz bison
#

I actually managed to do what I wanted, I think I was not clear so here is an image to explain, the checker on top of the cylinder seems to be mapped on a plane, though this plane does not exists, I'm constructing it from the positions of the backfaces

#

And I'm discarding the pixels above that "plane"

grand jolt
#

How can i show tiling and offset using shader graph? dont want to create separated variables just for this probably there is easy solution like in standard shaders

quartz bison
grand jolt
#

hm maybe wrong shader type created? no option for me

quartz bison
#

I'm using URP in unity 2021.2.3f1

grand jolt
#

mine is 2020 ;/

quartz bison
#

Maybe it was not here yet in 2020

grand jolt
#

yep, i tried rn in 2021 and its there, fk

tranquil socket
#

@grand jolt theres a node for tiling

grand jolt
#

i know but the fields are not showing in the inspector

tranquil socket
#

You have to make 2 exposed vec2 properties for that, and link them to the node in the graph

grand jolt
#

yeah.. just updated to 2021, easier 😛 but thanks

dim yoke
#

Its super weird they didnt add that earlier

tranquil socket
#

it has been in sgraph since the beginning, you just had to do it with nodes

dim yoke
#

Of course you could but that sucks

#

On shader code that works automatically (unless you use [NoScaleOffset] attribute)

boreal pewter
sacred patio
quartz bison
#

You could send the value to the shader with a script

#

The time variable continually inscreases so you could do that only once with the shader but it would be right when you open the scene (or at a specific instant dependind of an offset you subtract to the time variable)

sacred patio
# quartz bison Just once ? When ?

Technically the looping wouldn't be an issue if it started dissolving right away. The effect would end by the time it grew back in but that probably aint possible

#

Thinking that perhaps I should either turn to amplify shadergraph and try custon data or animate it x)

quartz bison
#

You have to send a variable with a script, and you increase that variable each frame

spring field
#

Hello. I could I ask for help regarding shaders? I'm trying to use a Opacity Maps but every time I use one in my shader, some faces are flipped and are see through.
You can see the issue in the image. -- Could I be doing something wrong?

upbeat nimbus
#

I'm using this shader from the internet to give my sprites an outline, but when they have the shader they are all translucent, any idea on how to fix?

charred agate
#

Hello ! I was wondering if it was possible to make a shader that replaces certain colors by others and makes them glow. I already did that for giving certain colors a glassy texture (If R and B == 254 then a color is taken from a gradient using G and a glass effect is applied to it) and I would like to do the exact same thing but with glowing in the same shader

charred agate
onyx jungle
#

Hello guys, currently I have an infinite terrain system that works by tiling terrain chunks/planes next to each other in a grid, I am wanting to shade this terrain (grass etc...), and so am calculating the steepness at a certain point and colouring the terrain based on steepness, however it seems because of the multiple tile approach, things dont lign up...

#

Any help appreciated, on a single tile it works fine.

tranquil socket
#

maybe fuse the tiles into a single mesh after generation?

#

just a loose idea, not sure if that's usable in your case

#

would certainly help with UVs

ashen timber
#

So I also asked this in #archived-urp however after turning off the Universal Pipleline it still occures. So I have this project where every material is rendered very aqua blue. I do not know why this is, the materials are succesfully compiled.

onyx jungle
#

A good suggestion though, but wouldnt work in my case

tranquil socket
#

post your shader then, maybe we'll figure something out

onyx jungle
#

sure

regal stag
ashen timber
#

Will do, thanks for the response!

onyx jungle
#

Well

#

there we go

#

thats the shader

tranquil socket
#

you can paste code using ```

#

^

onyx jungle
#

oh, you will need to comment out the line Includes/Math.cginc, not actually using this include right now

onyx jungle
tranquil socket
#

the triple thing

onyx jungle
#

discord wont allow it

tranquil socket
#

oh dear

ashen timber
onyx jungle
#

message too long

#

I mean wait, I can get rid of the wasted space and try and paste it

tranquil socket
#

it's fine, i downloaded the shader

onyx jungle
#

ok cool

#

I dont have the most experience writing shaders, but I like to think that this problem is more related to the fact I am using multiple tiles than the shader code itself

#

this screenshot maybe shows the seams better

regal stag
ashen timber
#

Doing it now!

tranquil socket
#

i don't see anything wrong with the shader, but then again, i'm not some shader wizard

#

the seams are exactly at the edges of tiles in all cases?

ashen timber
#

AAAAH YESS OMGGGGG @regal stag you're awesome 🙂

onyx jungle
#

No worries if you are a bit puzzled also, I think the task is a bit of a weird one.

#

I could send you a sample displaced mesh if you wanted to test it out for yourself

tranquil socket
#

yeah, sure

pine arch
#

What do you think it's the simplest way to randomly pick a channel from a texture in shadergraph ?

onyx jungle
#

Give that a try Festus

#

Let me know if there are problems with the meshes

#

might be a bit of a jigsaw puzzle to fit the pieces together

#

but there are only four pieces so shouldnt be too difficult haha

humble badge
#

Is there someone experienced with shaders, that can help me with a few questions for my homework quiz about shaders? 🙂 I'll make it worth your while. PM me

tranquil socket
#

@onyx jungle i don't have math.cginc

onyx jungle
#

Just comment it out

#

Wait

#

It’s needed for the blend function

#

Let me attach it

#

One sec

#

There we go

tranquil socket
#

thank you

tranquil socket
#

i have no bloody idea why this happens, since the shader operates on absolute values

#
            float3 compositeCol = lerp(_ColA, _ColB, steepness);
            o.Albedo = compositeCol;```
onyx jungle
#

Sure no worries festus

tranquil socket
#

even this produces the edges

onyx jungle
#

Btw, one thing that didn’t produce edges was using the IN.worldPositon and sampling a height value

#

However I want to change colour based on gradient not height so it doesn’t work for my scenario

tranquil socket
#

so maybe there's something fundamentally wrong with trying to do that using a dot product?

#

i don't know why would it be, though

onyx jungle
#

Maybe, I don’t know enough about shaders to say for sure

#

But I appreciate you giving it a try

#

So thanks regardless for your time 🙂

tranquil socket
#

hope you can figure it out

onyx jungle
#

Cheers

tranquil socket
meager pelican
onyx jungle
#

Hmm, again, I am a little unfamiliar with these terms, I’m not the greatest shader writer, however I did clamp the dot product output between 0 and 1 range for the lerp

tranquil socket
#

input vector is just 0,1,0

#

i tried remapping instead of clamping just now, and the edges are still there

static hollow
#

I'm looking for a way to make something like "if x > 0.4 && x < 0.6" with shadergraph, I just don't really know how to achieve the && part with comparison and branch nodes

regal stag
static hollow
#

thanks! sorry for the silly question

stray osprey
#

@regal stag hello! I'm using a toon shader based on your custom lighting for URP shader graph and trying to improve it's additional lights function by adding ramp texture to it just as you did with the main light
I'm not a shader programmer, so asking you (and other people here) for some help
First screenshot is the main bit i'm working with, where light is from GetAdditionalLight and texture is Ramp Texture
It works kind of fine, but ramp is only applied based on the distance between light source and object (in this case - ground) and doesn't work when changing the range of light source (range only cuts off the whole light)
Any ideas?

regal stag
# stray osprey <@!357936113983291393> hello! I'm using a toon shader based on your custom light...

The ndotLerped used to sample the texture doesn't take the distance attenuation from the light into account so I think that's why changing the radius doesn't work as you expect.
Could try * light.distanceAttenuation, but unsure if the way they calculate it would be good for sampling a ramp tex. If it doesn't scale well, it might be better to use the GetAdditionalLightDistanceSqrRange function I added to the CustomLighting.hlsl (if you haven't got it in your version see the updated one : https://github.com/Cyanilux/URP_ShaderGraphCustomLighting/blob/main/CustomLighting.hlsl).
Can use that to get the distanceSqr and radius directly, then maybe do something like ndotLerped *= saturate(1 - (sqrt(distanceSqr) / range)) before sampling (though that code is off the top of my head so unsure if it's correct)

#

(Can probably also do attenuatedLightColor * saturate(NdotL) instead of the LightingLambert() usage, so it doesn't need to do the NdotL calculation twice)

onyx jungle
stray osprey
#

I actually tried to find a way to get the distance and range of additional lights, had a feeling that's the way and good thing that you've already done that function :)

#

also @regal stag I'm fascinated by your stylised procedural skybox shader, do you still think about making a breakdown or opening source?

regal stag
#

Yeah I was thinking about doing a breakdown, started one briefly before the end of the year but haven't got around to continuing it yet

#

There's a few other stylised proc skybox tutorials out there already too. On mobile so can't really link them but I know MinionsArt and Jannik Boysen has one

stray osprey
dawn prairie
#

I have a shader graph issue, where sprites look fine in scene and game view but come out as bloated in the build.
The first picture is a normal sprite and a shader graph sprites in the scene/game view
The second picture is the same normal and shader graph sprites when it comes out in the build
The third picture is the shader graph used to create the glow effect

I tried to find help here before, on reddit, on youtube comments but couldn't find a solution to my issue
Using the default universal render pipeline and 2d renderer, and other than assigning the scriptable render pipeline, everything in the project settings are on their default

any help would be greatly appreciated

vapid garnet
#

anyone know why this takes so long?
During build, always takes way to long to compile shader variants, i don't have this problem in-editor, only when building

rocky rapids
#

How can I achieve this effect

#

rather than this

#

This is what I have now

limber mica
#

before I start poking with shaders and shadergraphs and stuff, is there a simple way to light 2d objects in HDRP? I just want some glowy stuff

tranquil bronze
#

this only happens when I add shadows to my shading

#

Im using urp and hlsl

dim yoke
silver sparrow
regal stag
silver sparrow
#

hmmmm

regal stag
regal stag
# rocky rapids How can I achieve this effect

Could try rendering the circles/viewRanges additively (Blend One One) to a Render Texture (via a second camera) as fully opaque then draw that texture then with lower opacity before everything else on the main camera. Though another camera & buffer might not be great for performace/memory.

Could also try looking into Stencils (but it can't do any partial transparency). https://docs.unity3d.com/Manual/SL-Stencil.html
e.g. Render each viewRange also to the stencil buffer while testing for NotEqual comparison. (so if the value is already in the buffer, the pixel is discarded, removing the overlap)

Stencil {
Ref 1
Comp NotEqual
Pass Replace
}

Or another method is to render all the viewRanges into the stencil buffer only (ZWrite Off, ColorMask 0) and then draw a fullscreen quad testing against it with Comp Equal to colour it all at once.

humble badge
#

Can anyone help me with some shader questions?

stray osprey
#

oh also @regal stag I get this error now for some reason
it's everywhere where I use custom lighting but it doesn't affect the resulting shader and everything looks and compiles ok
it's just appearing in the shader graph editor and messes up previews

regal stag
stray osprey
silver sparrow
#

are the Simple Noise and Gradient Noise in Shader Graph not seamless at all?

#

or are they?

regal stag
silver sparrow
#

ah

#

i guess i'll have to make use of a seamless noise i find online?

regal stag
lost idol
#

so i can google how to fix it, what's it called when a model moving around leaves impressions? think of like winxp when you'd drag a window around while it was processing

regal stag
silver sparrow
#

and the seam is screwing my waterfall mesh

regal stag
silver sparrow
#

hmmm

silver sparrow
lost idol
#

huh, i took a stab in the dark and changed these from pipeline to on and everything fixed itself
thanks cyan for pointing me in the right direction!

regal stag
regal stag
silver sparrow
#

alright will give it a shot

regal stag
#

It will mean the noise is the same on both sides too but that's probably not that bad

silver sparrow
#

now my waterfall is messed up

lost idol
silver sparrow
#

problem solved, thanks cyan 👍

lost idol
#

huh, if i turn it off it goes back to being broken

#

ah doesn't matter

silver sparrow
mint geyser
#

Hello. I have this weird texture flicker when changing the position or orientation of the camera, relative to the object. I am using a custom diffuse shader that is half-Lambertian. Not every object with the shader flickers. It seems the larger the object, the more likely it is to happen. Tried restarting, using full lambert, fiddling with the far/near clip planes, avoiding intersections with other objects, and none of it has stopped the flicker. Googling hasn't helped much either. Would be grateful for any insight on what could be going on.

hearty obsidian
#

Say you have 2 rings in blender, one large and a smaller one inside of the large one, can you automatically fill the space between the 2 rings without filling the hole in the smaller ring?

regal stag
regal stag
hearty obsidian
#

Oh I meant to post this in art-asset-workflow you're absolutely right @regal stag

#

investigating bridge edge loops, thank you

regal stag
stray osprey
#

Trying to make a skybox gradient color
So what I wanted to do is to make the horizon edge a bit sharper, and to do this I thought of regular multiplying. When I'm multiplying "Time" for Lerp by an amount higher than 3, colors go crazy. Two colors are light blue and darker blue, but there's literally no green so it's weird for me...
What is that?

#

I might be wrong with the usage of time but I have no idea on that

regal stag
stray osprey
#

Right! This works

regal stag
#

I'd do the Saturate after the multiply as you probably also don't want values above 1.

stray osprey
#

got it!

mint geyser
stray osprey
#

How can I make it so that the sun isn't visible through clouds?
In shader graph: sun is added to sky, and sky is lerped with clouds by a cloud mask on the horizon (to put it simply - clouds are added to the sky)

static sinew
#

Okay, Im new to shaders and am trying to pick up ShaderGraph. Today I opened up my mostly empty project (URP) and my white shader was now blue. creating a new lit shader and the white is still blue. this was not happening before and doesn't happen on a new unlit shadergraph. how do I fix and avoid this issue?

regal stag
stray osprey
static sinew
#

yeah everything has a cyan tint

regal stag
static sinew
#

I'm noticing this isn't happening in URP's sample scene

regal stag
# static sinew yeah everything has a cyan tint

Then yeah, it's a bug that I think is caused by shaders compiling (which show as cyan) when baking lighting/GI. I think the bug is meant to be fixed but still seen a few others with the problem. Could try updating Unity/URP, but otherwise you should be able to fix it by going to Preferences -> GI Cache, and clear the cache. Then rebake lighting via the Lighting window (might also rebake automatically anyway).

static sinew
stray osprey
regal stag
#

Where does the Remap go into?

stray osprey
#

Top is sun + sky, remap is the second value and time is the mask (just colored with float3 color)

#

oh nvm it's actually float4

#

but alpha is 100% all the time

regal stag
#

Okay the problem is probably the Multiply with CloudColor, you should do that on the B input after the Remap, not on the T input.

stray osprey
fast shore
#

Can someone explain me how I'm using transformation matrices wrong? Here's the simples thing ever

v2f vert (appdata v)
{
  v2f o;

  o.vertex = mul(v.vertex, _LocalToWorldMatrix);
  o.vertex = TransformObjectToHClip(o.vertex);

  return o;
}

_LocalToWorldMatrix is a float4x4 and I set it from script using transform.localToWorldMatrix

Rotation is inversed and translation does not work... Literally why

#

This is a HLSLPROGRAM if it makes any difference

#

This mesh is also drawn as instanced indirect hence the matrix I pass

regal stag
fast shore
#

💀

#

That was kinda embarassing but wasn't it always left to right??

#

It works now

#

I guess it's a hlsl thing

#

@regal stag thanks

dim yoke
fast shore
#

I should really dedicate some time to learn proper math huh

#

Left to right as in you multiply a pont (left) by matrix (right)?

dim yoke
#

You just gotta remember putting matrix first and then then vector

#

Matrix goes (usually) always first

#

It would be more intuitive to give vector first but thats not correct

fast shore
#

Yes, that was a bit confusing at first

#

Logically you transforming the said point

regal stag
#

Probably just matters on the format of the matrix. If it were transposed I think the other way around would then work. But in Unity it's usually matrix first.
I guess the order is kinda similar to how rotating a vector by a quaterion in C# is Quaternion * Vector.

fast shore
#

One of these things to just remember then

#

Now that I think about it inversed rotation was probably a big clue to try and swap these two lol

sacred patio
#

Has anybody here controlled shaders though custom data here? Mine doesn't seem to work, or is there a big difference on which channel goes where? For now I just tried looking on which one doesnt screw up the current effect

regal stag
tacit ivy
#

Anyone know how to make the texture of Sample Texture 2D very clear, because when i put it on an object its pretty pixelated up close

#

I use a png file for the texture but i heard of another way

regal stag
#

It won't clamp no. If floating point errors are a problem you'd probably need to use a float property instead and have control over if from a C# script.

sacred patio
gentle crow
#

Quoting myself from #archived-code-advanced since this channel may have people with the relevant experience:

Does anyone here know of a viable GPU hardware occlusion query implementation?

I'm looking at GPU Instancer but that seems to only support Hierarchical-Z for instanced objects, and I'm aiming to have complex one-off geometry occluded by it without baking.

regal stag
# sacred patio When saying UV1 channel, do you mean I should delete the UV2 and only keep the U...

I mean that the CustomData "Custom1.xyzw" is assigned to "(TEXCOORD1.xyzw)" on the particle component under the custom vertex streams in your screenshot. So if you want to get those values in Shader Graph, you would use the UV node, but change the Channel on the node to UV1 (TEXCOORD == UV in Shader Graph).

While using a UV node with channel set to UV0 would mean the (R,G) of the vector corresponds to the UV (TEXCOORD0.xy) and the (B, A) of the vector is the UV2 (TEXCOORD0.zw). Can Split and put it into a Vector2 if you need that. Hopefully that makes sense.

sacred patio
regal stag
sacred patio
regal stag
#

The C# Mesh class is just as bad. They use .uv .uv2 .uv3 which doesn't really line up with the shader side (TEXCOORD0, 1 and 2) 😛 (There is Mesh.SetUVs instead which does use a index starting from 0 though at least)

dawn prairie
gentle crow
#

Did you end up having to disable the mipmaps, or did you add an alpha channel to them?

dawn prairie
#

the emission texture was pure white with pure black background so i used a color channel instead of the alpha channel, it was the mip maps that were changing how the sprites looked in the build view, i just had to disable it in the sprite settings

#

i guess they generate mipmaps by default

#

also today i learned what mip maps are and that they existed in the first place XD

#

always learning o/

sacred patio
grand jolt
gentle crow
#

Ouch - you seem to know what "it" is that is missing- do you have a name for what it is that I'd need to make to compensate, so I can use that when looking up resources?

gentle crow
grand jolt
#

@gentle crow uhm no, all of SRPs is built upon command buffers.

#

Predication queries have their own API calls that aren't exposed in Unity at all.

#

See here.

gentle crow
#

Hmm - that looks like it allows fully on-gpu occlusion, while I'm looking for something akin to Hi-Z

grand jolt
#

Need to insert query commands into the command list.

gentle crow
#

(Am I understanding correctly that Predication implies essentially "on-gpu logic switching based on a predicate"?)

grand jolt
#

🤷‍♀️ But this type of occlusion testing is called hardware occlusion queries.

gentle crow
#

I believe there's a few ways of doing that; the one I am hoping is possible with current pipelines is closer to "dispatch a list of positions and sizes, then asynchronously get back a list of which ones were visible a few frames later"

#

the CPU organizes what to show/hide based on those results, and that separation of handling causes frame asynchrony and potential artifacting. Hardware predication seems to be intended to reduce or even resolve that.

grand jolt
#

Well, you will have to code Hi-Z yourself. Cause occlusion queries aren't available.

gentle crow
#

VK_EXT_conditional_rendering appears to provide this capability portably, for what it's worth, but...

kindred oxide
#

can i use shaders to go from the first image to the last?

low lichen
kindred oxide
#

not sure if you can help me with that

static hollow
#

I'm trying to find away to make my Lighting.hlsl support point lights/multiple lights. This the shader code:

#ifndef CUSTOM_LIGHTING_INCLUDED
#define CUSTOM_LIGHTING_INCLUDED

void CalculateMainLight_float(out float3 Direction, out float3 Color) {
#if defined(SHADERGRAPH_PREVIEW)
    Direction = half3(0.5, 0.5, 0);
    Color = 1;
#else
    Light light = GetMainLight();
    Direction = light.direction;
    Color = light.color;
#endif
}

#endif

I've tried looking at some other .hlsl files used for the same thing but those ones often are much less simplistic (and I really don't need all of that other stuff for what I'm trying to do)

neat hamlet
#

you need to grab the additional lights amount with GetAdditionalLightsCountand loop over them

#
 int pixelLightCount = GetAdditionalLightsCount();
        for (int j = 0; j < pixelLightCount; ++j) {
            Light aLight = GetAdditionalLight(j, WorldPos);
            // grab direction and colors
}
static hollow
#

Thank you! That worked!

silver sparrow
#

if i want to edit a property of a material of just one gameobject, do i create a script for it and reference the material(not sharedMaterial) of the Mesh Renderer ?

regal stag
#

For the built-in RP there's also Material Property Blocks that can be used instead. But for SRPs that breaks the SRP batcher.

cinder chasm
#

Anyone know if we can change the target shader model of shadergraph? I'm trying to use a StructuredBuffer but it won't allow it (presumably because it's pre-SM5.0)

silver sparrow
#

but the thing is, how do i edit the property values without going into play mode?

deep siren
#

anyone wants to save me some headaches and give me a shader graph that is similar to the default URP/Lit shader?

#

I'm trying to replicate it so that i can use it with virtual textures

regal stag
# cinder chasm Anyone know if we can change the target shader model of shadergraph? I'm trying ...

Might change depending on pipeline but in URP the last time I checked it generates two SubShaders, one with target 4.5 (which should still support compute buffers according to https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html) and another with target 2.0 (I think for gles platforms?).
I've had StructuredBuffer working in a custom function (file mode) without needing to do anything else, but if you're getting errors, might be able to have #pragma target or #pragma require compute in another custom function (usually string mode works better as that gets pasted directly into the generated code rather than as an include file).

cinder chasm
deep siren
#

hmmm

#

wdym

#

you mean there is an example shadergraph that is the default urp lit?

cinder chasm
deep siren
cinder chasm
deep siren
#

yeah.. detail albedo and detail normal maps too if it was possible

cinder chasm
#

I believe that's some kind of custom inspector, and not possible within shadergraph

#

Grain of salt

deep siren
#

🥲

cinder chasm
#

You can reconstruct a less versatile version of it pretty easily since most of those nodes attach to the master directly

deep siren
#

fair enough

cinder chasm
#

Unless my shadergraph is some kind of old version?

deep siren
#

but im too bad at this...

regal stag
cinder chasm
regal stag
silver sparrow
regal stag
#

Like, how you'd usually create materials, in the project window.

silver sparrow
#

ahh i see

#

do i have to make a custom inspector though if i were to create an entire script dedicated to edit the material?

regal stag
#

Would probably be a bunch of public fields which would make them appear on the component. Doesn't necessarily need to be a custom editor/inspector unless you want to organise it in a particular way.

silver sparrow
#

alright thankss

sacred patio
#

Can anyone tell what's wrong with my depth fade? It completely ignores the floor and the mountains that are definitely not touching the mesh 🤔

regal stag
sacred patio
steel notch
#

How exactly do you add vertex displacement maps to a material?

#

The standard URP Shaders only seem to have height maps

cinder chasm
steel notch
fathom kiln
#

How do I change this to affect the whole object instead of the pixels

regal stag
chilly bolt
#

hiya, I tried following a guide to make a dither-fade effect based on camera distance

#

this works great except i'm trying to use screen position instead of camera distance to ensure that objects fade about the same time in front of the screen, right now objects slightly closer to the camera fade sooner

#

here's my attempt to use screen position. the problem is that objects don't seem to cast shadows anymore?

#

weirdly, if i flip ditherStart and ditherEnd so that objects further from the camera will fade, it does cast shadows, but the shadows seem to be unaffected by the dither effect and continue to show even after the object has disappeared

#

pretty new to shadergraph so admittedly i have no idea what's going on here

regal stag
chilly bolt
#

let me give it a try 👍

fathom kiln
#

why is one face not fading like the others?

regal stag
#

Static batching would probably also move the origin to the world center (0,0,0) since it combines multiple renderers, so make sure the object isn't using that

chilly bolt
#

additionally, flipping ditherstart and end again so that objects further from the camera are faded now don't cast shadows

#

i just wish i understood why this doesnt happen when using camera position. thanks for helping btw! didnt occur to me to try using view/world position, i have some more things to fiddle with

south temple
#

How do I do geometry shader instancing in Unity ? I'm not talking about normal instancing, i'm talking about having n invocation of a geometry shader

deft root
#

Anyone know why my shaders dont run in URP?

#

they work fine in the editor

#

but as soon as I build it to android, they break

#

2019.4 LTS building for VR Quest btw

regal stag
# chilly bolt i just wish i understood why this doesnt happen when using camera position. than...

Don't know for sure, but my guess would be that the Position from the Camera node uses _WorldSpaceCameraPos, which is always based on the camera that is rendering (the actual camera). But when rendering the realtime shadowmap Unity is likely overriding the view and projection matrices.

And pretty sure the shadowmaps use an orthographic projection, which means the W component of the Screen Position (raw) will actually just equal 1. In perspective projections (like your camera) it's the viewspace depth, hence why I suggested using the Position node in view space directly. But if the view matrix is also different the z values won't be the same for both passes, so no dither in shadows.

I think there may be a camera view matrix that doesn't get overridden, (I'll see if I can find what it is). But otherwise could probably also try setting up a global matrix property in a C# script and set it to cam.worldToCameraMatrix. (That method won't work if you have multiple cameras rendering though, unless you change the matrix before each one renders)

chilly bolt
#

thats really helpful and ill look into it more, thanks!

deft root
regal stag
# chilly bolt oh huh

I think it might be the unity_WorldToCamera matrix so could try doing Out = mul(unity_WorldToCamera, float4(positionWS.xyz, 1)); in a Custom Function node (with Position node in World space as input).

deft root
#

Im using a Unlit shader, could that be the issue?

regal stag
regal stag
# deft root Anyone know why my shaders dont run in URP?

It's kinda hard to tell without seeing a shader. If you're using shader code, there is a few differences between built-in and URP shaders (though unsure which parts would be required to make it work in a build). It's usually easier to use shader graph but I also have an article : https://www.cyanilux.com/tutorials/urp-shader-code/
The URP docs also have a few bits : https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.0/manual/writing-custom-shaders-urp.html

deft root
#

Its a custom shader, but I was able to figure it out with the shader graph, thanks anyways :)

#

Custom meaning a coded shader

near karma
#

Hi, I'm trying to mark an object's position on a skybox by setting a _body_position property on the material, but I don't know how to determine the vector to that object or how to make the skybox render a fresnel around the object. Here's a screenshot of my current graph, you can see the fresnel is only on the z axis. How do I center it on the given object position?

deft root
# regal stag It's kinda hard to tell without seeing a shader. If you're using shader code, th...

basically I spent 2 hours making a custom shader while this made it in 1 minute https://www.youtube.com/watch?v=s_P3dVZvVxY

Bytesize Gamedev is a series of videos featuring tiny effects, delivered in 60 seconds or less. In this video, learn how to make an outline effect in Shader Graph and URP.
This video was previously posted on Twitter: https://twitter.com/daniel_ilett/status/1313815235103518723

Unity 2019.4.12f1, URP/Shader Graph 7.3.1
-------------...

▶ Play video
#

👁️ 👄 👁️

regal stag
regal stag
south temple
regal stag
south temple
#

I only the code of the .shader file

#

weird

#

wait a second

regal stag
south temple
#

ok it's working, i just had a random bug for no apparent reason

deft root
#

I feel like I picked the wrong one, however I have no idea which one I would pick

regal stag
# deft root What is wrong with the 1st one?

It's just that Shader Graph doesn't allow you to just cull front faces (that may have changed in newer versions though, can't remember). There is some cost to rendering both sides and alpha clipping the front away though, while the shader code version just uses Cull Front.

regal stag
deft root
#
Shader "Outlines/BackFaceOutlines"
{
    Properties
    {
        _Thickness("Thickness", Float) = 1 // The amount to extrude the outline mesh
        _Color("Color", Color) = (1, 1, 1, 1)
    }
    SubShader
    {
        Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }
      

        Pass
        {
            Name "Outlines"
           Cull Front

           HLSLPROGRAM

           #pragma prefer_hlslcc gles
           #pragma exclude_renderers d3d11_9x

           #pragma vertex Vertex
           #pragma fragment Fragment

           #include "BackFaceOutlines.hlsl"
            
            ENDHLSL
        }
    }
}
``` I did this before
#

It worked fine in the editor, just not in the build

#
#ifndef BACKFACEOUTLINES_INCLUDED
#define BACKFACEOUTLINES_INCLUDED

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

struct Attributes
{
    float4 positionOS       :POSITION;
    float3 normalOS        :normal;

};

struct VertexOutput
{
    float4 positionCS      :SV_POSITION;
};

float _Thickness;
float4 _Color;

VertexOutput Vertex(Attributes input)
{
    VertexOutput output = (VertexOutput)0;

    float3 normalOS = input.normalOS;
    float3 posOS = input.positionOS.xyz + normalOS * _Thickness;
    output.positionCS = GetVertexPositionInputs(posOS).positionCS;

    return output;
}

float4 Fragment(VertexOutput input)    : SV_Target 
{
    return _Color;
}

#endif
near karma
deft root
#

Alright so small issue with the one you sent me hehe

regal stag
deft root
#

I scrapped that one anyways, since it gave me too many errors but I just wanted to show what I had before trying the unity one out (Which also seemed to break)

#

I dont really do shaders so ye haha

regal stag
deft root
regal stag
near karma
deft root
near karma
#

@regal stag, thanks and respecc for multitasking

regal stag
#

Like this. It might show a warning but that's more for the built-in RP.

deft root
#

ah thanks

near karma
#

I thought I would need a 3dimensional output to have something centered around a position, but dot is only 1

regal stag
# near karma Not sure where to go from here

Okay so this is for an atmosphere around the planet? Is there a particular reason why you need this on the skybox rather than just using a sphere mesh to surround it? That way you probably have more control over the position.

#

Or I guess a sphere mesh with faces inverted

near karma
deft root
deft root
regal stag
deft root
#

ah....

#

So what would I do instead? I really do want to get these outlines working haha

worthy ridge
#

Anyone know of a way to have per-particle motion blur using the default particle system? The "per object motion vectors" option only seem to blur the particles based on movement of the particle systems transform. Open to ideas. Using HDRP.

regal stag
quaint python
quaint python
#

The way that method works is the model is duplicated, the faces are flipped, and the flipped faces are extruded out from the model (and colored black)

#

It's called the inverted hull method

#

You can also just bake the hull into the model itself

deft root
#

ah okay, so how would I do tha tin blender?

quaint python
deft root
#

thank you

quaint python
#

But in your case I assume you'd need to create the hull from a smoothed normals version of your model, then split the normals on the main model

#

So I'm not sure if that method would work

deft root
#

I'll try it out

quaint python
#

You can also use screen-space outlines using per-pixel depth & normal discontinuities but they tend to suck

regal stag
#

The downside to manually modelling the inverted-hull is you can't easily resize it in Unity but yeah that works.
Assuming you still need the flat normals for shading another method would be to calculate the smooth normal vectors and store it in an unused UV channel or vertex colours, and use that input in the shader instead of the normal.

near karma
#

object position in skybox graph

deft root
#

Seems more grayish

quaint python
#

I'd guess it's still interacting with light

deft root
#

No light in my scene

quaint python
#

Blender emulates ambient light, no?

regal stag
#

The colour in blender probably isn't as important. Can always change the material in Unity

deft root
#

No idea, I'll just put it in unity and see how it is

quaint python
#

Not sure how people normally implement it but I think the hull itself needs to be unlit

deft root
harsh oracle
#

stuck on something simple but I can't figure it out. I want to use the FX/Glass/Stained BumpDistort shader with a 2D image to make it looks like there's a semi-transparent splat of goo on the camera. how should I do this?

I tried doing this using a quad w/ a material that has the shader set and the splat image as the texture, but it appears as a giant square for some reason (as shown on the right in the image)

near karma
deft root
regal stag
fast shore
#

Is there a way to wait for a compute shader to finish it's tasks?

#

And is it a good design to try and do this?

#

Tbh I could really use some feedback on the way I use compute shaders, because I don't think I'm doing it right

#

Basically I have multiple compute buffers and I need to modify them all using a compute shader. Like process buffer 1 -> process buffer 2 -> process buffer 3

#

I can dispatch multiple times, however because I set said buffer with .SetBuffer and then dispatch in a loop the shader only processes the last buffer

#

Would I be better off changing the entire structure and using one big buffer instead? I will need to resize it somehow though

spark moth
#

What could cause this number of variants?

hearty obsidian
#

In shader graph, is there any difference at all from a performance standpoint between re-using an exposed property node or simply duplicating it? e.g. say I expose a float named foo. foo is hooked into 2 different nodes VS putting foo twice on the board, each hooked into a node

fallen ocean
#

https://roystan.net/articles/toon-shader.html

I'm just following along this tutorial while trying to convert it to a URP workflow, I'm a bit stuck at

float3 normal = normalize(i.worldNormal);
float NdotL = dot(_WorldSpaceLightPos0, normal);

…

// Modify the existing return line.
return _Color * sample * NdotL;```

I'm a bit new to shaders but I thought maybe this could work: 

```float4 frag(VertexOutput i): SV_Target
{
  Light mainLight = GetMainLight();
  float3 normal = normalize(i.worldNormal);
  float NdotL = dot(mainLight.direction,normal);

  return _Color*NdotL;
}```

I would have thought ```GetMainLight().direction``` would have been equel to using ```_WorldSpaceLightPos0``` but I just get a black circle instead of a basic shadow.
regal stag
hearty obsidian
#

thank you @regal stag

regal stag
fallen ocean
regal stag
fallen ocean
outer lake
#

I was trying to recreate this setup on blender, I think I got it, position or location seemed the good one, but normal seems to match the tutorial

rustic adder
#

Hi, I recently followed this tutorial by brackeys for a dissolving shader: https://www.youtube.com/watch?v=taMp1g1pBeE&ab_channel=Brackeys

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

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

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

♥ Support Brackeys on Patreon: http://patreon.com/brackeys/

····················································································

♥ Subscribe...

▶ Play video
#

Only thing is, the shader keeps looping the dissolve and I dont want it to do that

#

Is there any way I can make it so when a game object is enabled, the dissolve in effect is played and when its disabled the dissolve out effect plays

near karma
#

Hey, I am trying to make my billboard sprite shader scale the generated colors by the distance from the camera like a sun flare. Here is my graph, I don't know where to go from here:

fallen ocean
#

Is there a simple way to do shadow catching in URP with an unlit shader? I'm just finishing trying to convert this tutorial: https://roystan.net/articles/toon-shader.html - but I'm missing on how URP does shadow catching I think. I figured out the alternatives to things like shadow coord and what not (I think) but I'm not exactly sure how to get the correct data? Hope pastebin links are fine: https://pastebin.com/DqYrM1pJ - probably easier to read it than me doing code snippets.

sleek kite
#

Anyone know if the "z" (sorting) coordinate of a tile in a tilemap is somehow accessible?

sleek kite
#

I can't seem to get it via the position or the transformation matrix...

regal stag
# fallen ocean Is there a simple way to do shadow catching in URP with an unlit shader? I'm jus...

Usually something like

// Main Light & Shadows
float4 shadowCoord = TransformWorldToShadowCoord(IN.positionWS.xyz);
Light mainLight = GetMainLight(shadowCoord);
half3 attenuatedLightColor = mainLight.color * (mainLight.distanceAttenuation * mainLight.shadowAttenuation);
...
half3 shading = LightingLambert(attenuatedLightColor, mainLight.direction, IN.normalWS);
// aka attenuatedLightColor * saturate(nDotL)

But you also need the appropiate keywords :

#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
// Note, v11 changes this to :
// #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN

#pragma multi_compile _ _SHADOWS_SOFT

Can also move the shadowCoord calc to the vertex shader if not using cascades. (Shadows.hlsl sets up a REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR define you can #ifdef against)

If it helps, I also have some templates here : https://github.com/Cyanilux/URP_ShaderCodeTemplates (DiffuseLit is closest to this, the PBR and SimpleLit use the methods in Lighting.hlsl which handle shading for us so might be less helpful)

regal stag
tardy bobcat
#

Hey gorgeous people, so im having a weird issue where my water shows properly in the VIEWER, but ingame its just gray

#

Does anyone have ANY idea what it might be? Using URP

near karma
#

scale billboard with view distance

fallen ocean
night sleet
#

Hey folks! I want to let the ground glow from beneath the water and so far everything is good. both components work, but the water surface seems to block the emission from below. If I go into the water with the camera I still see the glow, so it should be something with the surface. Can you support me finding the right direction? Thank you for your time!

It's URP on 2020.3 and water is an unlit shader while the glow is a lit shader, might this be the issue?

regal stag
night sleet
#

it's a second transparent map on the cube

#

one base material with the base map and one material with the glow shader on it

regal stag
#

Then yeah, it's not going to appear in the Scene Color node that the water uses. It uses the Opaque Texture (captured after rendering opaques + skybox). Transparents won't appear in it.

#

Might be able to change the render queue to make the glow render after the water though

night sleet
#

Oh, thanks for clarifying! Would it also be possible to get the transparency into the Scene Color? I'll try playing around with the render queue, thanks for the suggestion!

#

Works! Thanks a bunch 🙏 🙏

silver sparrow
#

right now my waterfall refracts anything that is behind it, how do i refract the texture of the water ripple as well?

#

making the Render Queue of the waterfall 3001 and the Render Queue of the water ripple 3000 just cause the water ripple to disappear behind the waterfall

long shadow
#

So how do you implement shadows when using Shader Graph?

near karma
devout spoke
#

I am currently working on a custom glass shader, specifically the refraction part. It works good, it refracts everything that is visible on the other side, however, the only thing it doesn't show is any materials that have their Surface Type set to Transparent. What nodes can I use to "capture" all Transparent materials that are rendered on the screen?

#

Note the cube on right is "Transparent" and just emissive. The cube in center is Opaque. The items on the left use the same shader I'm working on.

#

Here is my refraction setup.

slim steppe
#

Is there a way to make the entire triangles have the same have the same specular color?

#

@regal stag

devout spoke
#

Is there a way to customize the shadows? Say I want the shadow to be a different color for a particular shader (or materials that use that shader)

stray osprey
#

cyan actually has a good custom lighting sub-graphs to work with

devout spoke
#

So for instance, if I want my "glass" to have a lighter shadow as if light is passing through, like a magnifying effect. Is that possible?

#

I am using HDRP

slim steppe
stray osprey
#

yee

stray osprey
devout spoke
#

I'm sure there is, I just need to get a general direction of where I would control this.

stray osprey
# slim steppe

you can try to set up something like this in shader graph, where "ramp" is a simple texture like one I attached

slim steppe
#

Thanks!

stray osprey
#

it's a simple method I've got from Cyan's lighting

slim steppe
#

would step also work?

stray osprey
#

personally don't use it rn so i'm not sure

static hollow
# slim steppe

I have a very similar question to this, I want faces to be shaded evenly with step-shading, instead of partially shading it with 2 different shades

stray osprey
static hollow
stray osprey
#

ohh

stray osprey
#

that's the way I do this at least

stray osprey
#

might work

static hollow
#

Didn't work unfortunately,

#

I think it has something to do with the fact that I'm using spotlights to light it

#

since it works perfectly with directional light

#

although directional light doesn't really give me the lighting I want

fallen ocean
#

Hey, trying to figure out how to get the top plane of objects. I did something like float TopPlane =dot(normalize(i.positionOS.y),i.worldNormal.y); which almost works but flat plans still end up being black? Is there a better method?

#

Hmmm sorry I guess it's because the plane was at 0,0 and it didn't know how to calculate the top face as a result. Still not sure exactly how to fix that, so any tips would be appreciated.

slim steppe
shell ice
#

so having some trouble regarding disabling receieve shadows for a mesh

#

i have it disabled in the mesh renderer but it still receives shadows, im using a custom shader graph for the first material, and the second material is an unlit material

#

is there any way I can make it so shadows dont render on the mesh?

fallen ocean
nimble solstice
#

Hi, via shadergraph is there a way to take an output 1 node & essential turn it into something I can offset via uv? For instance, I'd like to shift the output of this over a half a block essentially

regal stag
nimble solstice
#

nah, not shift the seed values but shift the whole outputed texture over, sec, I'll show you the chain up until that point

#

Like I'm doing the bottom section of this

#

like its a texture I'm panning over in x by 0.5 a cell

regal stag
# fallen ocean One last thing, I added a depth pass/depth normal pass to my shader but SSAO doe...

You basically need to sample the _ScreenSpaceOcclusionTexture. There's functions in the URP ShaderLibrary to handle it for you but it's location might vary on which version you're on.
e.g. For v10.8.1, https://github.com/Unity-Technologies/Graphics/blob/v10.8.1/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl
UniversalFragmentBlinnPhong uses :

#if defined(_SCREEN_SPACE_OCCLUSION)
        AmbientOcclusionFactor aoFactor = GetScreenSpaceAmbientOcclusion(inputData.normalizedScreenSpaceUV);
        mainLight.color *= aoFactor.directAmbientOcclusion;
        inputData.bakedGI *= aoFactor.indirectAmbientOcclusion;
    #endif

(where normalizedScreenSpaceUV is inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS); from Shaders/SimpleLitForward.hlsl)

regal stag
nimble solstice
#

Oh duh, you're so right. Thanks @regal stag

regal stag
# shell ice i have it disabled in the mesh renderer but it still receives shadows, im using ...

I'm not sure there's an option to turn off shadow-receiving in ShaderGraphs yet. Could try a custom function with #define _RECEIVE_SHADOWS_OFF maybe (but if that custom function is in the generated code before Shadows.hlsl it probably wont work)
Or perhaps set it up as a Boolean Keyword in the blackboard (and probably use the debug inspector on the material to edit the Shader Keywords field as SG won't allow you to expose keywords unless they end in _ON for some reason).

shell ice
#

Yeah I tried going with the keyword approach but when I try to create one in the blackboard the options are greyed out

regal stag
#

You want to create the Boolean Keyword, not one of the predefined Material Quality ones.

shell ice
#

Cant edit any of these properties, supposedly naming the reference to something like SHADOWS_RECEIVED or something like that and flicking a few of these settings could be the solution but havent found a way to be able to edit these settings, since its apparently affected by render pipeline settings?

#

ah ok

#

ill try it out

#

damn youre a genius, that was all I needed

#

changing it to a boolean keyword and modifying the properties seemed to be all I needed

#

threw this on

regal stag
shell ice
#

thanks for the help btw

hollow bone
#

I've created a shader for snow tessalation and displacement. A shader material is applied to a high resolution mesh that is used to simulate snow. The player is able to remove snow from an area by lowering it's height, but I need a way to detect when all of the snow is removed from a zone. Any suggestions?

regal stag
hollow bone
fallen ocean
fallen ocean
near karma
#

Is there a way to calculate the screen depth of a sphere that you're inside, like an atmosphere? I'm having a hard time finding tutorials for a quick and dirty atmosphere

#

with the shader graph, I mean.

rustic adder
#

Hi, im trying to change the value of a childs material using the following: