#archived-shaders

1 messages Β· Page 185 of 1

novel tulip
#

hey guys, i have an issue with my shader that i need some input for

#

you can see on the left it renders fine but once i use a camera to capture it and render to a render texture, it causes the texture to look funny

#

it's because the shader isn't aligned to screenspace uv i think

#

so the camera gets some nearest neighbor jank going on

#
            {
                float2 uv = i.uv;
                uv *= _GridSize;
                uv += float2(_X, _Y);
                uv /= float2(_ScaleX, _ScaleY);
                float ns = PerlinNoise2D(uv) / 2 + 0.5f;

                if (ns < _Threshold1)
                {
                    return tex2D(_Tex1, i.uv);
                }
                if (ns < _Threshold2)
                {
                    return tex2D(_Tex2, i.uv);
                }
                if (ns < _Threshold3)
                {
                    return tex2D(_Tex3, i.uv);
                }
                return tex2D(_Tex4, i.uv);
            }

            ENDCG
        }```

is there a simple way to modify this to use a screen UV value instead somehow?
native garnet
#

hey

#
            deathShader.SetTexture("_normalMap", mesh.material.GetTexture("_BumpMap"));
            deathShader.SetTexture("_baseMap", mesh.material.GetTexture("_BaseMap"));
            mesh.material = deathShader;```
#

I am using this to set a dissolve shader and keep the normal and base map the materal had previously

#

the problem is SetTexture doesn't seem to change anything

placid kettle
#

Does anyone know how to change the default 2D material to Sprite-Unlit-Default?

silver valve
#

Does distortion not work in the most recent release for VFX Graph?

quaint coyote
quaint coyote
quaint coyote
native garnet
#

@quaint coyote i found the problem already, forgot to reply

#

thanks for help tho!

quaint coyote
native garnet
#

the code I provided was executing more than one time so the textures were invalidated on the second call

placid kettle
#

@quaint coyote every time I make a sprite renderer, the material defaults to Sprite-Lit-Default. I want it to be Sprite-Unlit-Default

#

Is this possible?

novel tulip
#

i'm trying other approaches using v2f but it's not giving me good resules

#

i.screenPos.xy = i.screenPos.xy / i.screenPos.w * _ScreenParams.xy * _Tex1_TexelSize.xy; is screenPos.xy supposed to be a UV with this logic?

#

normalize it then multiply by screen params and texel size, it seems like it's meant to be a screenspace uv... but my shader doesn't look right with this

quaint coyote
quaint coyote
novel tulip
#

on the left you see the shader in action

#

it looks fine

#

but when a camera captures a mesh with the shader and renders to a new render target, you can see the result on the right

#

which has a bunch of inaccuracies

#

this is due to the shader not being aligned to the screenspace UV i think?

#

if it has pixels that are technically overlapping 2 positions it would explain why the right hand side has grass that is 2px wide

#

so basically i need to ensure that my shader is properly aligned and pixel perfect so that cameras can render what they see properly

quaint coyote
#

That triggers a question. Is the left image rendered by a camera?

novel tulip
#

the left image is a mesh with a material using my shader

#

the right image is a render target

quaint coyote
#

Right, but that image is rendered through a camera right?

#

I mean the image on the left is screenshot by you in editor or game window?

novel tulip
#

editor window

#

screencap taken while inspecting the mesh

#

i can try and get a look at it in the game view and see what its like

quaint coyote
#

Sure, so if the camera is rendering it fine, then putting it on a render tex is should not create any issues. I might be wrong, but screen space uvs are not reqd

#

It will render whatever is there in the game window direct to a render texture

novel tulip
#

it looks fine from the game view before it gets rendered to a render texture

quaint coyote
#

Hmm, puzzled now. Are you rendering the whole camera image to rt or just this material?

novel tulip
#

sprites also render fine when captured and rendered to the render target

#

ah well basically this is a map generator i'm working on

#

it creates meshes and sprites, then a camera captures it and renders what it sees to a render target and i output that render target as png

quaint coyote
#

Oh nice, that's awesome. Will have to take a look closely to understand. Because if tou are rendering what's seen in camera to RT then it should not distort as such. Did you check your render target properties? Is aspect ratio n all correct?

novel tulip
#

yeah everything is pixel perfect except for this shader

#

no distortions that i can see

#

it's gotta be something to do with the capture camera doing some nearest-neighbor work when it sees this shader

#

this shader aligns to the mesh UV but maybe the mesh isn't properly aligned so this pixel perfect texture isn't aligned with the rest of the sprites

placid kettle
solar sinew
#

@devout quarry I've been using your DepthNormals pass and was wondering if you had run into this. cameraData.isStereoEnabled is now obsolete, and intellisense says to use xr.enabled but that doesn't exist. I assume it means the bool XRGraphics.enabled and the enum StereoRenderingMode. I was curious if this has affected your implementation.

https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@5.8/api/UnityEngine.Rendering.XRGraphics.html
https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@5.8/api/UnityEngine.Rendering.XRGraphics.StereoRenderingMode.html

smoky pewter
#

is there any alternative to unity's shader graph that is compatible with the standard render pipeline? some technical limitations are stopping me from using URP/HDRP.

mint flax
#

writing your own shaders maybe?

smoky pewter
#

yeah but like. For me, its way harder to actually visualize whats actually going on with the shader by just writing lines of text. Like personally, with making a website, write every line of code but its just more intuitive to design with visual stuff.

mint flax
#

yeah I get what you mean

novel tulip
#

i'm trying to change my shader so it doesn't use v2f_img but now it just renders a solid color

#
v2f vert(appdata_t IN)
            {
                v2f OUT;
                OUT.vertex = UnityObjectToClipPos(IN.vertex);
                OUT.texcoord = IN.texcoord;
                OUT.color = IN.color;
                OUT.screenpos = ComputeScreenPos(OUT.vertex);

                return OUT;
            }

            fixed4 frag(v2f IN): COLOR
            {
                float2 uv = IN.texcoord;
                uv *= _GridSize;
                uv += float2(_X, _Y);
                uv /= float2(_ScaleX, _ScaleY);
                float ns = PerlinNoise2D(uv) / 2 + 0.5f;

                if (ns < _Threshold1)
                {
                    return tex2D(_Tex1, IN.texcoord);
                }
                if (ns < _Threshold2)
                {
                    return tex2D(_Tex2, IN.texcoord);
                }
                if (ns < _Threshold3)
                {
                    return tex2D(_Tex3, IN.texcoord);
                }
                return tex2D(_Tex4, IN.texcoord);```
#

it seems that texcoord is not giving me the right value

#

this is meant to be an unlit shader so maybe that has to do with it?

#

i'm stumped as to why i can't see anything

thick fulcrum
carmine karma
#

Hey everyone!

#

Any of you know if it's possible to bake REALTIME lighting to a texture ? πŸ™‚

#

I'm talking like the basic diffuse-

#

Not a reflective surface

#

Not sure I should post this here..

#

I gonna post it in the code area

novel tulip
#

GRR i can't figure out why my shader is just a solid color

#

it only works as expected if i use v2f_img

#

it's meant to be an unlit shader

#

if i change it to use a v2f struct it just renders the entire mesh as a solid color

regal stag
#

@novel tulip Make sure your v2f struct has the correct semantics attached for each of your outputs (e.g. SV_POSITION, TEXCOORD0, COLOR, TEXCOORD1, etc).

novel tulip
#
struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 screenUV : TEXCOORD0;
                //float2 overlayUV : TEXCOORD1;
                float4 vertex : SV_POSITION;
            };

            v2f vert(appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.screenUV = v.uv;

                return o;
            }

            fixed4 frag(v2f i): SV_Target
            {
                return tex2D(_Tex1, i.screenUV);
            }```
#

screenUV seems to just give the same coordinate all the time or something since the entire material is just a solid color

regal stag
novel tulip
#

should be. it's a procedurally generated mesh so maybe not.. let me check the code

#
var tr = new Triangulator(get_pts_array(m_poly));
        var indices = tr.Triangulate();
        var uv = new Vector2[m_poly.Count];

        for (var i = 0; i < m_poly.Count; i++)
        {
            uv[i] = new Vector2(m_poly[i].x, m_poly[i].y);
        }

        var m = new Mesh();
        m.vertices = m_poly.ToArray();
        m.uv = uv;
        m.triangles = indices;

        m.RecalculateNormals();
        m.RecalculateBounds();```
#

looks like the uv data is being set

#

if i use the v2f_img struct, the uv works fine

novel tulip
#

ohh i found part of the problem

#

the scaling of the texture is weird

#

it's not pixel perfect after all

#

its pixels are like 150% the size of a normal pixel

#

i'm not sure how to fix that

#

ok so applying a scale to the uv fixed it

#

rather hacky but i dont care at this point lol

calm lynx
#

anyone know a good tutorial for a glass shader graph in unity 2020.2?

solar sinew
#

I put this in #πŸ–ΌοΈβ”ƒ2d-tools first but now that I think about it - it should be in here

I'm thinking about how to approach this... how could I detect how much of a shape the player has filled in? I would be using a render texture with different alpha masks for different shapes probably? What about SDFs?
https://youtu.be/YNIIqTXb75E

Best viewed in 60 fps (only available on HTML5 player). I'm Wario, Mark is Yoshi, Tenta is Dry Bones and Waluigi is a computer player set to very hard.

β–Ά Play video
solar sinew
#

this is for a 2d game so I'm unsure what the most efficient way to approach this is

quaint coyote
solar sinew
#

can you point me to some documentation? I understand how that would work but don't really know the syntax

quaint coyote
#

That might help?

solar sinew
#

I'll give it a watch - I wasn't sure if there was some different implementation depending on if I was painting a 3d mesh or a 2d sprite (which I could also just fake as a plane with that texture)

quaint coyote
#

Till the time you are getting uv coords your should be all fine πŸ˜€

solar sinew
#

thanks a bunch!

#

For a different project I was planning on looking at particle interactions with render textures (water ripples for example) but I wasn't sure how to approach this

quaint coyote
# solar sinew thanks a bunch!

There are various ways to create ripples, you can have displacement/alpha maps or height maps basically with some diffuse/albedo calculations πŸ™‚

solar sinew
teal breach
#

If I have a render target with a depth buffer, is there any way to sample from the depth buffer of that render target? In my particular case, I'm actually just trying to copy the depth buffer elsewhere (I wasn't sure if this belongs in render pipeline or shaders, I'll try here first)

#

If I use eg buffer.SetGlobalTexture("_MainTex", _TempTarget);, I can sample the RT 0 of the above texture as _MainTex, but it has no access to depth buffer information

grand jolt
#

Where did everyone learn custom Shaders coding?

I tried looking on youtube, and there are tutorials on how to make specific looking shaders but I want to try learn how, if in the future I need a specific shader. I would go about it? if that makes sense?

#

I started at the beginning with Shader Graph, learn how to add standard textures, then normals, then emission maps, then go a little deeper with planar / tri-planar mapping and parallax occlusion mapping. And finally start adding effects, for each effect you add you can see how they interact and then start merging them etc to make better effects.

All YouTube. Thats how I went about it anyways @grand jolt .

vast sparrow
#

If anyone wants to try and do a ps2 style game I recommend the vertex lit legacy shader, it definitely reminds me of games from that era

#

It provides that muddied look that games of that era boasted

calm lynx
#

i'm using the latest version of unity 2020, and i can't find the pbr shader graph create option. can anyone help me?

#

nvmd, forgot about the help menu in unity

devout quarry
#

@calm lynx it's 'blank graph' now?

#

I think

calm lynx
#

nope

devout quarry
#

blank shader graph

calm lynx
#

no, that doesn't look like any of the tutorials i've seen

devout quarry
#

it is what you want

#

then you can set pbr in the graph settings inside of the shader graph editor

#

it's changed in shadergraph 10.x, that's why it's different now

#

you will also need to set the active target to universal or high def depending on what you're using

#

then set the material to Lit (pbr)

#

other changes you might bump into is that the master node is now a 'stack', but that shouldn't be too different, and also the property settings like the property reference and value have been moved to the 'node settings' menu, they will show up there when you have a property selected in the blackboard

calm lynx
#

ok, thank you!

devout quarry
#

would be nice for Unity to introduce these new features inside of the editor, with like a little 'guide' that shows 'this is new', like a lot of other apps/software does, but I don't think that's ever going to happen

calm lynx
#

are albido and base color the same?

devout quarry
#

yeah I think they replaced that to base color

#

also for the properties, vector1 is now float

#

and if you don't see a certain output in the 'master stack', it's possible you need to add those, or maybe change something in the graph settings menu and then they'll show up

calm lynx
#

ok, thanks

#

i wish there were more 2020 tutorials

devout quarry
#

@calm lynx well these things are specific to 2020.2, which was only released recently so you'll have to wait a bit for tutorials to catch up

calm lynx
#

true

devout quarry
#

but all tutorials should work fine, once you get the hang of those UI changes

#

they didn't remove any functionality

calm lynx
#

yeah. thanks for helping me out

molten jolt
#

hey guys can i ask a question about a shader graph thing?

eager folio
#

Yes.

molten jolt
#

hahaha

#

that was actually funny

#

im trying to assign a material to a square sprite but when i drag and drop it remains white

#

i followed a tutorial on water reflection, so the material is a texture made of a camera view

#

it does work when i apply it to a quad

#

but not with the sprite

#

that tutorial

#

i was thinking that is maybe because of the different versions?

eager folio
#

So why not use a quad?

molten jolt
#

because the quad is always behind the sprites, it doesnt have a sorting layer?

#

cannot find the way to put it in front

eager folio
#

Also, if the shader is expecting a main texture then the sprite renderer component might mess that up by automatically assigning a blank sprite

#

You can set the sorting layer of a mesh renderer via code.

molten jolt
#

im not the programmer in the project😩

#

we are two dudes who know very little abut game development

molten jolt
#

the interesting thing is also that in the video.. the dude effortlessly drags and drops the material into the sprite

#

and boom!

#

water reflection

molten jolt
#

we have a backup if anything happens haha

eager folio
#

Um, I'm not at my computer so I can't send you it but I can toss an invite to a server where I posted a simple sorting layer script a while back

#

Sec

molten jolt
#

yess

#

nice man, thanks

#

or woman.. or person

eager folio
#

Cat

molten jolt
#

indeed my furry friend

#

i mean not as in furries

#

literally you have fur

eager folio
#

Lol

vast sparrow
#

Anyone find my vertex shader suggestion helpful?

cobalt bolt
#

hey shader people

#

I found this awesome project here: https://github.com/AdultLink/HoloShield . It's not compatible with URP though. I just thought, gonna share it here with you guys. Maybe one of you decides to make a pull request with the URP version or something. I can just hope I guess.

tired mason
#

Hello. Need some help as I can't figure out the problem. I'm trying to apply a texture and a transparent to a cube and can't get it to work. I have the texture in the albedo and the transparent in the secondary map, the shader as standard and the render mode as transparent.

tired mason
#

NVM, figured it out. You don't need transparency maps at all, just an alpha channel and to delete the parts of the texture you want transparent.

cinder chasm
#

Question: Why does depth writing from a transparent material completely occlude any other transparent material behind it?

#

And is there a way to stop that happening while still correctly sorting transparent materials

#

This is what happens to two opaque "transparent" queue objects without depth writing

vocal narwhal
#

Because your other materials are depth testing

#

and are behind the depth you just captured

cinder chasm
#

Yes, but is it necessary absolute?

#

This is with writing on

vocal narwhal
#

It depends what order things render in, and what depth order they are in.

#

transparent objects are sorted by their object center for rendering, and typically would not render to depth

cinder chasm
#

Okay, but why does an opaque material render perfectly fine behind a transparent material with depth writing on? Is the transparent pass after the opaque?

vocal narwhal
#

because opaque objects render before the transparency queue

#

you can see how the scene is rendered using the frame debugger

cinder chasm
#

Ah, so I can use the sorting priority to get the behaviour I want then

#

maybe

vocal narwhal
#

Yeah, depends on the setup

cinder chasm
#

How does depth writing interact with sorting priority? Priority seems to override it, from what I'm seeing

vocal narwhal
#

they should be unrelated afaik

cinder chasm
#

Thanks a bunch vertx, I think I may have solved it via sorting

radiant cobalt
eternal lynx
#

build for what target operating system?

radiant cobalt
#

Didn’t work on WebGL nor the Windows, Mac and Linux one @eternal lynx

#

Weird part is that I can see the particles and the canvas, but not anything else. Think it might be a problem with the shaders then, but I tried changing to legacy shaders, and added the shaders to the prebuilt system so I can't really see why it isn't working then

cerulean iris
#

hello, I just downloaded Shader Graph and I have something weird . . .EVERY asset lost their texture, what can i do to get my texture back pleaseeee

radiant cobalt
#

Think you need to update your textures to use the same shaders as given in the pipeline you're using. Go to Edit > Pipeline settings > Update Shaders to "something"

cerulean iris
#

@radiant cobalt sorry to bother you but I really dont want break something x)
It is that ?

radiant cobalt
#

Yup!

cerulean iris
#

thx β™₯

limber fossil
#

Hello.

#

Shader grapgh pbr is not on the list when I try to create new.

#

what is the problem comes from

devout quarry
#

@limber fossil blank shader graph instead

mellow rover
#

Hi, I have this very simple unit shader that I want to use GPU Instancing with. However, when I enable the function from the material interface, sometimes the gameobject just does not show up at all (invisible). Am I doing sth wrong here?

quaint coyote
#

the shader code does not have any instancing support written into it

#

which platform are you rendering for?

mellow rover
#

mobile, iOS for now, but the issue appears both in editor and the build

quaint coyote
#

Check this out, I was just exposing model space matrix calculations:

#

The image was posted above sorry πŸ˜…

mellow rover
#

I...haven't really gotten it? I see you are doing matrix multiplication, but how exactly is it related to GPU instancing?

#

Sorry in advance, I am very new to shaders

quaint coyote
#

Not related to GPU instancing

#

It's just a showcase of the amount of calculations a GPU does only for getting the model space transforms πŸ˜¬πŸ˜…

#
#

Your question answered in that Blog πŸ˜€

low moth
#

I'm trying to create the line of sight effect using Sebastian Lague's tutorial, and it works just fine but I want to make the FieldOfView always visible like a transparent white color

mellow rover
#

@quaint coyote Sorry for the misunderstanding haha, will look into it!

grand jolt
#

When using Parallaxing the Input is a Texture2D as the map, does anyone know a way I can convert a noise node to be compatible with that?

quaint coyote
#

@mellow rover no worries at all man, all cool πŸ‘

#

@low moth did I miss the reference?

low moth
#

It wasn't related to your discussion

quaint coyote
#

I meant reference to Sebastian's shader πŸ˜…

low moth
#

Ohhhh

#

It's on part 3

cinder chasm
#

Anyone know why the HDRP Unlit "Distortion" option might not be doing anything for me?

#

I can't find any documentation on it besides the very unhelpful "Click this to enable distortion!" on the docs

cobalt marsh
#

hello

#

I'm having this issue

#

I'm using TMP and as you can see, the text is beeing shown even when there is hardly any light.
It seems as if it was emitting light.

#

What can I change to modify this behaviour of TMP?

vast sparrow
#

I reccomend a legacy vertex lit shader for ps2 or retro styled games

rotund veldt
#

Hi there, is there someone open to explain me some shader code in a call? About 20 lines only, super basic stuff but for me hard to handle with the time I have...

#

It is from here:

limber fossil
devout quarry
#

@limber fossil where is what?

limber fossil
#

pbr graph example

devout quarry
#

if you want pbr shader, make a blank shader graph, then set render target to universal or high def, and then set type to lit

#

blank shader graph -> set to lit is the new pbr

limber fossil
#

yes I see. but there was a PBR shader instead. So initially we had some features with it. But when I create a blank, I have to start from scratch

devout quarry
#

nah, if you create a blank graph and set it to 'lit', you have everything you initially had with PBR

limber fossil
#

oh my gosh

devout quarry
#

that's really the new way to make a pbr shader

limber fossil
#

thanks

#

πŸ™‚

devout quarry
#

you'll see the master 'node' is now a master 'stack', and some of the settings you got by clicking on the cogwheel on the master node, are now moved to the 'graph settings' window

limber fossil
#

sir thanks!!

teal breach
#

Any idea why ShaderGraph doesn't generate passes for TerrainDetailVertex? eg, for detail objects added via terrain

grand jolt
#

does anyone know how to increase the max render cap for nodes in Shader Graph? I seem to have hit some sort of limit and my nodes are now invisible...

placid kettle
#

I'm making a 2d isometric game and have sprites in my world which can hide the player. I want to make it so that if the player walks behind these sprites, I sort of have this effect where I "punch a hole" through these objects and render my player. How could I use a shader to achieve this?

eager folio
#

@placid kettle if you are using sprite renderers, you can use the default sprite shader. look up sprite masks.

fathom temple
#

Hey, I tried switching my project to the HDRP, but most my textures looks like untextured metal (ignore the purple textures). Is this a common problem? I saw some videos on HDRP and I didn't see this problem. Tips?

shrewd crag
#

@fathom temple i think you need to convert your materials to HDRP materials, it's in the HDRP configuration.

fathom temple
#

i did convert them. The purple textures in my picture are the ones not converted yet, but the rest is set to HDRP Lit

fervent tinsel
#

@fathom temple you have too low light intensity

#

HDRP expects quite high directional light intensity by default

#

alternatively you have to dial down exposure values from multiple places

fathom temple
#

It's weird, because when I turn up my intensity, it gets brighter but slowly fades back to dark. I'm not really sure what these exposure values are though

fervent tinsel
#

that's autoexposure

#

basically easiest way you can make it use proper values quick is to do following:

  • run through HDRP Wizard, make sure everything is green
  • create a new HDRP scene
  • make prefab out of the directional light and sky volume from this new scene
  • open your existing scene
  • replace the directional light with your light prefab and add the sky volume prefab
#

of course you can manually configure all this but it's simpler to do what I just listed if you are new to all this

eager folio
#

Also make sure your materials are properly converted, with textures in the right slots.

stoic bear
#

Hey guys, How can I make an outline shader for my multi-sprited character ? I mean my character has it's body parts separated. like in the right side of screenshot below.

normal rose
#

i've tried to convert a written shader from built-in pipeline to urp but i get this error

flat marlin
#

when writing HLSL shader, is there a way to make a constant shader variable that can be edited through the editor and be used in the code, but not be edited during runtime?

south glacier
#

I tried "copying" this material (with the given textures ofc) to another Unity project

#

but the outcome is different.....

slow bear
#

I'm doing some vertex animation, and I've noticed that the shadows get dragged along the surface of the meshes (e.g., when rotating the object the shadows are still calculated as if the vertex aren't moving at all

#

what could be the cause?

#

URP Pipeline, tried adding #pragma addshadow but nothing changes

regal stag
#

@slow bear Are you referring to the shadows cast by the object or shadows received?

slow bear
#

Shadows received, basically it's still calculating the shadows as if the mesh was still, but I'm rotating some of its parts based on their vertex colors

regal stag
#

Okay, so are you handling shadow calculations using GetMainLight(shadowCoord), or maybe MainLightRealtimeShadow(shadowCoord)? Either way, that shadowCoord should be calculated from the offset position.

#

@south glacier Other than the Height Map slider it looks the same to me. Since it's for the Universal Render Pipeline make sure URP is set up correctly in the other project. Maybe also try right-clicking the material and Reimporting it, that might fix the magenta error, not sure.

slow bear
#

and I'm using a PBR template, but even when calculating NdotL manually the result is the same

regal stag
#

Ah, okay. I'm not familiar with amplify. Seems strange to me that it wouldn't already handle it automatically.

slow bear
#

I'll remake the shader in Shadergraph and see if something changes

regal stag
#

Oh, you're referring to the dark areas produced by N dot L and not actual shadows. You'd need to change the vertex normals to change that shading

slow bear
#

it's weird though, I mean, any surface manipulation that happens in the vertex program phase should carry on to the surface program

#

I'll post some screens

#

this is at t = 0, this is what the mesh looks like without any manipulation to the vertices

#

This is after an almost 180 rotation on the Z axis: notice that the shadow is literally rotating along with the surface, and how some faces appear flat-shaded instead of smooth as they should be

south glacier
#

@regal stag yeah I just fixed it by readding the URP Config in Project Settings, forgot to do that. Thanks!

regal stag
regal stag
regal stag
flat marlin
regal stag
#

I know there's a limit to shader keywords but not properties afaik. If there is I've never encountered it.

flat marlin
regal stag
#

The Standard shader is an example of such a shader that uses some keywords to enable/disable parts of it so if you don't need them all the shader isn't doing unnecessary calculations.

grand jolt
regal stag
grand jolt
#

it does, but it's not at the stage where absolutely everything is sub-graphed

#

now*

slow bear
#

turns out they don't

grand jolt
#

Also, i'm leaning towards a render cap because the nodes are still fully functionable, I can still connect them, they are just invisible, which means i cant edit any of the default vectors on them, and it only happens after a certain amount of nodes have been added, so i started using nested sub-graphs which helped, but like I said it's all sub-graphed now so sort of hit a wall @regal stag

hearty wasp
#

Is there any way for me to make the inspector menu of my shader graph more organized? With tabs or titles? I'm guessing shader graph itself doesn't support this yet

#

I'm not enjoying this mess of properties I got going on very much lol

teal breach
#

I think there is ShaderGUI

#

Not sure if this is of use, but I just discovered the hard way that Linear01Depth doesn't work with Ortho! Specifically, it introduces some nasty bugs if someone sets the near plane to negative.

devout quarry
#

ShaderGUI is useful yes!

#

even simple headers can do so much

regal stag
#

Yeah you can make your own ShaderGUI if you're up to it and assuming you're on a shader graph version with the Override ShaderGUI option on the master node

#

I think there might also be plans to add headers/titles into shadergraph?

grand jolt
#

@teal breach You could probably use a clamp node to counter that negative near plane issue....not entirely sure

devout quarry
#

on the productboard they say 'blackboard categories', but I'm not sure if that would translate to the material inspector?

regal stag
devout quarry
#

they just say 'group and categorize properties on blackboard'

regal stag
#

Ah right. I assumed it would be both blackboard & inspector but I guess that might not be the case

teal breach
#

@regal stag I get the reason why, just would have expect it to 'do nothing' in that case. I should have read the source, it does clearly state it in the hlsl file

#

I was hoping there would be some convenient high level function which makes everything be nearest=0, furthest=1, for all gl/dx and ortho/perspective variants, but I don't think there is πŸ˜…

regal stag
#

Yeah don't think there's a convenient function for it. Would have to handle it yourself. I think it would be something like

if (unity_OrthoParams.w == 1){
    orthoLinearDepth = _ProjectionParams.x > 0 ? rawDepth : 1-rawDepth;
    orthoEyeDepth = lerp(_ProjectionParams.y, _ProjectionParams.z, orthoLinearDepth);
}else{
    linearDepth = Linear01Depth(rawDepth, _ZBufferParams);
    eyeDepth = LinearEyeDepth(rawDepth, _ZBufferParams);
}

For URP at least. Built-in would probably be the same but without the second _ZBufferParams parameter. Unsure about HDRP.

teal breach
#

so, in my case I'm having to use some shader keywords, because the actual processing is occuring during a post processing phase (and not when the depth values were written)

#

in the render feature I'm setting the keywords based on the cameraData

radiant inlet
#

Hey, this may be the wrong channel but is there a way for a 2d sprite to take damage from being hit with bullets? Like in Space invaders pieces of the shield come off where it was hit, is there a way to do that in Unity?

teal breach
#

do you want the damage localised, or would a general 'look of damage' do?

radiant inlet
#

localized

#

I wonder if it can be done on a skinned sprite

#

That's my eventual plan

#

I'm thinking of something really complicated and I'm not sure it's even possible

teal breach
#

easiest way might be to just have detachable objects that you drop off when taking damage

#

like gibs (reminds me of cortex command, if you ever saw it)

radiant inlet
#

I want to do a 2d version of what they do in Doom Eternal, where chunks blow off of a character

#

like there's a skeleton underneath but there's a sprite on top that breaks off

#

I'm not sure that can be done

teal breach
#

I guess that is done by procedural mesh generation rather than shaders - i think the feature you want is called fracturing?

radiant inlet
#

yea

#

i can just parent skeleton sprites underneath without actually skinning those

#

those won't take damage

#

I just looked up fracturing, I don't need them to become separate sprites

#

I just want pieces missing off of the main sprite

#

or sprites

#

I don't know what would be better

#

There's a lot into this that I want I need to tackle these issues one at a time

#

I think what I want is splotches subtracted from the sprite

#

localized damage

#

I don't want the part that falls off to be its own thing though, I can do that with particles

regal stag
#

Might be able to send impact points to the shader (e.g. in a Vector array) and discard pixels (or change their alpha to 0) based on the distance from the fragment position to those impact positions. They would be perfect circles unless you also offset it with some noise.

#

It might be awkward to handle with sprites though. I think multiple sprites tend to batch together which messes with the object-space fragment pos. It would likely need to be handled in world space.

radiant inlet
#

is it possible for a sprite to keep track of what's been subtracted from it?

#

If that's the case I think skinning it should work fine

#

I guess what I really want is like in that movie Bloodshot

#

it's hard to explain, I guess i want it to take damage but regenerate

#

like a reverse burn

#

so damage will do a local burn dissolve, but it slowly reverses over time

teal breach
#

does the keyword UNITY_REVERSED_Z work with URP? Whatever I do it seems to have the same value for both DX and openGL

#

(keyword wrong word - global define? whatever its called)

regal stag
#

I think it should have a value of 0 for openGL and 1 for DX. Might be a bit different from the built-in pipeline - where I think it's not defined at all in openGL?

teal breach
#

I'm finding the following is using the defined() route for both openGL and directX graphics APIs on windows #if defined(UNITY_REVERSED_Z) depth = raw_depth; #else depth = -raw_depth; #endif

#

(target is webGL - will check if that makes a difference)

regal stag
#

Think you just want #if UNITY_REVERSED_Z rather than #ifdef / #if defined, as it's always defined it both, just with a value of 0 or 1.

teal breach
regal stag
#

Yeah, the manual is written more for built-in pipeline. It works differently in URP now

teal breach
#

cool, thanks Cyan. Happy it works at all πŸ™‚

teal breach
#

@devout quarry just out of interest - how do you link your shadergraph to a specific ShaderGUI? Is there a way to specify CustomEditor in the shadergraph?

devout quarry
#

yeah like Cyan said, it's on the master node, click on the cog wheel and then you can enable/set it there, just by entering the name of your class

#

for 10.x it's under graph settings I think

#

but I don't think custom shader gui is for 7.x, only 8.x and above (I think)

teal breach
#

I think that's where I was missing it, I'm still on 8.2 (but need 7.x compatibility)

hearty wasp
#

but I'm having trouble wrapping my head around making it fade beyond a certain point so it doesn't project all the way over the walls

#

or at least not as intensely

devout quarry
#

@hearty wasp you could fade based on depth?

#

also to get rid of those vertical streaks, you might link up the light direction matrix so the caustics seem 'projected' from the light direction instead of top-down

hearty wasp
hearty wasp
devout quarry
#

yeah sure but it's still a projection

#

I see in my code I actually do this

#
                half upperMask = -positionWS.y + (_WaterLevel - _CausticsStart);
                half lowerMask = positionWS.y - (_WaterLevel - _CausticsEnd);
                half heightMask = smoothstep(0, _CausticsFade, min(upperMask, lowerMask));```
#

so a mask in world position, relative to some defined water level

#

and so for that 'projection' I do this

#

half2 uv = mul(positionWS, _MainLightDirection).xy;

#

and you can get world space position from depth, and mainlightdirection is the main light's rotation matrix

#

I know you use shadergraph and all, but just wanted to share, it might be of use

hearty wasp
#

I've used getting the main light's rotation in a shader before so I may try and look into it, shadergraph is a blessing because I'm way more visually orientated so I'm already doing stuff I wouldn't be able to wrap my head around otherwise

grand jolt
wind flame
#

anyone around that has experience with texture arrays?

radiant inlet
#

How do i make this texture follow the player

#

shader i mean

eager folio
#

@radiant inlet use the object position or uvs rather than screen or world coordinates?

normal rose
#

does someone know other method to create a gray effect over the camera without forward renderer?

eager folio
#

@normal rose can you be more specific?

normal rose
# eager folio <@265179128200691713> can you be more specific?

so, i want to create an night vision effect but on grey, soo i searched on youtube some tutorials but all the tutorials i found use a forward renderer with a shader graph material but my question and problem it is, is there a way without the forward renderer because when i switch from the default one to the scanner renderer , i lost around 10 fps

radiant inlet
#

@eager folio i have a position node on my shader that is set to object position

thick fulcrum
limber fossil
#

How can I make my shader stop in editor. It works own by own.

#

(shader graph)

radiant inlet
#

what do you mean

#

how do you make it stop?

#

@limber fossil what do you want it to do

limber fossil
#

I made a dissolve shader. When my player jump out of the standing platform, I will change shader to my custom shader and it will be disappear.

radiant inlet
#

you need to change the shader with code

#

I've never done that before but you have to look up how to change materials

#

don't change shader I meant material

#

in your sprite renderer

limber fossil
#

hmm. ok and one more problem. why on earth my shader works in editor mode.

#

I mean I did not get it played but it works in scene own by own

#

dissolve shader works without clicking "play"

radiant inlet
#

yea it shows you the shader is working do you not want it to do that?

limber fossil
#

I want but only when I start the game.

#

Oh got it.

#

I have to change during the game right?

radiant inlet
#

it depends on what you want

limber fossil
#

There is a standing platform. When my player jump it will be destroyed. I mean I will change my standart shader when player jumps.

#

and the platform will be destroyed with shader that I made. and I will turn off the gameobject

radiant inlet
#

you should have a script that sets the dissolve to do that

#

in Brackeys dissolve tutorial near the end it shows a script on how to change your shader and materials

limber fossil
#

hmm. Is there any event function for it? kinda animation events. I mean when the shader worked once, I want to get informed.

regal stag
limber fossil
#

you are a hero! thanks

radiant inlet
#

yea that's what's in Brackey's video

hearty wasp
#

is it more efficient/optimized in shader graph to reuse nodes? say, if I already had a time node it'd be better to reuse that time node rather than make a new one?

radiant inlet
#

depends

#

I'm not sure it's that much more of a memory usage to add a node

#

if they're doing the exact same thing, then you should be able to use the same node

#

and you don't want to use them independently

regal stag
#

It depends exactly what node is being reused. Nodes that handle "inputs" like the Time node, or Position node are just accessing a variable that's already been set elsewhere.

#

But if it was something like, a Transform node where you're converting a position between two spaces, it's better to reuse the output rather than having another Transform node doing the same thing.

radiant inlet
#

Hey @regal stag, do you happen to know how to fix my issue I had last night? If you scroll up a little bit it's the last video sent

#

I want the shader to stay on my player's position

#

and I have a position node set to Object in the shader already

regal stag
#

Sprites tend to be batched & drawn together for better performance, so "Object" space isn't really a per-object thing anymore, I think it's just the same as World. You'd have to use UVs to keep it fixed to the sprite

radiant inlet
#

how do I do that

regal stag
#

UV node rather than Position node

radiant inlet
#

ok

regal stag
#

It should also use UVs automatically if you leave the UV input on the noise node (or texture sample) blank

radiant inlet
#

well it's not

#

does it matter if I do UV1 or UV2 i don't know what those are I've been leaving it at UV0

#

so I left my Noise node UV input blank and the Sample Texture 2d UV input blank also and it's doing the same thing

regal stag
#

Probably just leave it at UV0. I doubt there's any values in the other channels for sprites.

#

Did you save the graph?

radiant inlet
#

yea

#

nevermind I guess it works now

#

I didn't save it after deleting the position node

#

I have a rotation node that used the default UV0 input

#

oh man it works great now thanks

limber fossil
#

By the way, How can I change my property's value inside graph editor. It is deprecated?

hearty wasp
#

if you're in 2020.2 you click on the property and then open the node settings window in the top right

hearty wasp
limber fossil
#

I found it. But not usefull to take the propery settings all the way right to the screen.

#

Thanks

south glacier
#

Hey, when I try to apply a material with a ShaderGraph on my sprites, it turns white and I get the error message "Material does not have _MainText property" can anyone help please?

grand jolt
#

check inside your shader graph, look at the Main Texture 2D input you have on the properties list on the left. You need to change the Reference name of that to _MainTex @south glacier

#

you can change the actual property name to Main Texture, it's the reference below it that needs to be _MainTex

#

you can find it in Node Settings (top right property box) when you click it

south glacier
#

Works now. Thanks alot!!

teal breach
#

So, according to the unity doc (https://docs.unity3d.com/Manual/SL-SamplerStates.html), you can specify the filtering function of a sampler through the sampler name. eg, sampler_point_mainTex. It's not clear to me what the syntax should be for using the sample though, using URP. For example, using SAMPLE_TEXTURE2D(_MainTex, sampler_point_MainTex, uv) just gives an error

#

does anyone know of an example they could point me to?

grand jolt
#

it's probably something ike sampler_point_trilinear @teal breach , as your already sampling _MainTex with the first input, not familiar with the scripting method though

#

the filter is either trilinear or linear im guessing

teal breach
grand jolt
#

Im two for two, COME AT ME SHADERS

steady schooner
#

Can someone help me so that the material/shader scales the images based on scale so that they don't stretch please?

limber fossil
#

Hello. I have some objects inside the scene. All the objects use the same shader and I want them to be affected individually. When I click one, It will be dissolved but other will remain what they was. What should I do, Should I create individual materials? Or is there any solution for this?

grand jolt
#

@limber fossil you can use .sharedMaterial instead of .material, that should effect all objects with that material

limber fossil
#

I made a dissolve shader and with float property I manuplate it.
I have 100 objects inside the scene.
When I click one of the objects, It should be gone with that dissolve shader.
what do you suggest to me.

limber fossil
grand jolt
limber fossil
#

Thanks Ill take a look now.

brittle owl
tropic crow
#

Hello! Does anyone know the name of the rendering technique/shader used in top down games (Among Us for example) where the objects are hidden/partially hidden depending on the field of view and obstacles between the player and the object? Thanks!

lethal fern
lethal fern
#

of course!

fathom temple
#

I'm making a low poly game, and some assets I've found don't support HDRP, but they do support URP. Is there any way to make these assets work with HDRP or should I switch to URP?

cerulean breach
#

Under Assets

fathom temple
#

So when I do that, all of my purple textures are fixed, but some of them turn grey and look untextured/uncolored. The snow material seems to be working though.

#

These assets are from the Synty Nature Pack btw, and I don't think they support HDRP? At least one of the comments mentioned it.

grand jolt
fervent tinsel
#

@fathom temple put higher intensity directional light value

#

basically this is coming from HDRP default that expect such higher intensity lighting values, alternatively you have to dial down exposure from multiple places

#

by higher value, I mean like in range of 10 000 or 100 000 (can't remember which they default to nowadays)

fathom temple
#

@fervent tinsel I think I already did that, which is why my snow texture on the ground is showing. (Kinda hard to see since its a subtle texture) I have gotten other assets from another unity package showing up in color though. Not on my computer otherwise I could show the pic

teal breach
#

It's not possible to specify the sampler filter for openGL platforms in shader (eg, using sampler_point_clamp or similar). What other options are there for a temporary render target?

#

You can use GetTemporaryRT outside of the shader (eg in a scriptable render pipeline feature) to set the filtering for a render target, but this only works for creating a new one. If I want to sample screen color with a point filter, for instance, this doesn't work unless I blit the screen color texture to my own render target, which seems a bit wasteful

fast mango
#

How can I make other light effect my shader in Unity .shader code ?

feral inlet
#

I'm using 2019.4, how do I see properties for these colors? can you not do it in a shader subgraph? sorry i'm just confused af on how subgraphs work

regal stag
feral inlet
#

thank you :)

#

also, how do i have more than 12 texture units in a shader? i need quite a few layers of masks for this material. just asking here now since i got a quick response

#

i thought that i could use subgraphs for this problem but i don't think i understand how they work very well

regal stag
#

Usually the limit is 16 samplers, but I guess the pipeline might also be using some up for stuff like shadow maps, lightmaps etc. Using inline sampler states instead of the ones created for each texture can avoid the limit

grand jolt
#

@feral inlet Adding to what Cyan said, these SamplerState nodes WILL override any import settings you have, for example, if your texture is set to clamp in import settings but you have a repeat sampler state node attached it will repeat the texture, so make sure you match your sampler state nodes to the appropriate types

feral inlet
#

final question, and now i'm editing a regular shadergraph. i can't find the properties window. i know in newer versions there's some sort of properties panel on the right, but this seems to be different. how do i change the default colors? etc?

regal stag
#

(It's a bit awkward so I'm hoping for this change to be reverted tbh)

feral inlet
#

Node settings tab? maybe i'm blind, but when i click on a property i don't have another window

#

i'm using 7.3.1, not sure if that's why or if i should be using the latest

regal stag
#

Oh, if you're still on older versions the properties are listed in the Blackboard window. There's arrows on the left of each property to expand the settings

#

If the blackboard isn't visible there's a button in the top right of the graph somewhere to toggle it

feral inlet
#

when i click on a color nothing happens. maybe i'm remembering how the graph editor works incorrectly

regal stag
#

I know others have mentioned problems with the colour picker window not appearing. It's probably a bug in that URP/shadergraph or Unity version.

feral inlet
#

thank you for the help, i'm going to try to restart unity and if it doesn't work i'm just gonna use a preview version of the shader graph, might even use 2020 instead

regal stag
#

unity_ObjectToWorld._m03_m13_m23 should get the object's origin in world space

#

Though that will only work if the object isn't static or dynamically batched.

hearty wasp
#

Are noise textures expensive? Gradient noise, etc

#

or Voronoi

devout quarry
#

@hearty wasp generally noise is expensive yeah

#

but a 'noise texture' is different than the gradient noise or voronoi nodes in shadergraph

#

a noise texture is a texture, which would be the noise function, baked into a texture

lethal fern
#

Does anyone know how to get lighting information, specifically shadows, in the latest version of shader graph?

devout quarry
#

I think this worked for me in 2020.2 URP 10

#

@lethal fern

lethal fern
#

thank you i'll look into it

#

everything ive found is broken now

regal stag
lethal fern
#

I'll look at both, thank you both

grand jolt
devout quarry
#

that must be a record, wow

grand jolt
#

it's not finished yet...still have to add around 30 more

regal stag
#

Out of curiosity, what does it actually do?

grand jolt
#

it's an Info Box Effect, it's designed to go on standard Unity cubes, it lets you render textures on each face, with about 4 built in effects, all controllable per-face πŸ™‚

#

it looks a bit non-uniform right now as i'm messing with all the effects, but heres a screenie @regal stag

hearty wasp
grand jolt
#

it depends on the effect you want to achieve, i have an animated pixel effect but it only works via a pixellated UV thats animated, it wouldnt work with a texture @hearty wasp , but yes, if you can get away with a texture it's better

devout quarry
#

I think generally a tileable noise texture would be better in terms of performance than a noise function node yes, but for performance it's hard to speak in absolutes so I'd say test it out

grand jolt
#

it's always good to gate stuff behind bools too, so you need to activate a bool to use said effect

hearty wasp
#

you literally answered the question I was just about to ask haha

#

yeah I had booleans in place but I wanted to ask if it actually mattered in terms of performance

devout quarry
#

but don't use comparison nodes for that, both branches will still be evaluated I think

grand jolt
#

although i'm not entirely sure of the computational advantage of that, Shader Graph seems to do everything then your bools just switch whats showing, where as in a script you IF check something before it bothers doing further calculations

devout quarry
#

use shader features for that

grand jolt
#

oh, variants? yeah, that works

#

unless your me, who has such a massive shader I had over a million variants at one stage XD

devout quarry
#

yeah that's with multi-compile, but I think with a regular shader feature, only a single variant will be compiled in the end for your build?

#

and with multi-compile, it compiles all the variants as well (and they add up fast) to be included in the build

#

I think

hearty wasp
#

so this doesn't actually matter? false being a noise node and true being a texture

devout quarry
#

I think both are computed yes, and only the visual output is different, so I would use a shader feature there to switch between them

#

but honestly, I'm not 100% sure

grand jolt
#

yeah, it's definately good for a build if you can do a multi, more performant at runtime, the problem at the moment for me is i cant convert anything to be a variant, because adding even a single keyword atm means my graph takes like 4 minutes to compile every time something changes XD

regal stag
#

Yeah, I'd use a Boolean Keyword rather than a Boolean Property. That way you can guarantee only one side is computed.

grand jolt
#

^

#

make it one of the last things you do though

#

otherwise your compile time will go through the roof

devout quarry
#

yeah but I think you're really pushing the limits with your graphs lol, I've never had issues

grand jolt
#

well my pc is trash, maybe it's far faster for others

hearty wasp
#

I hadn't ever heard of Boolean Keywords before, thanks Cyan, no idea how I never came across it before

regal stag
devout quarry
#

Also be aware that there is a 128 variant limit, that you can increase in the preferences

#

you're right cyan

grand jolt
#

yeah Strip Unused does that in the settings for it

hearty wasp
#

I'm guessing there's no way to actually hide properties based on a Keyword in shader graph yet?

devout quarry
#

with a custom shader gui, yes

#

then you can do something like this

#
        {
            editor.ShaderProperty(rampTexture, "Gradient");
        }```
grand jolt
#

just add _ON to the end of the properties reference name to expose the Keyword @hearty wasp

#

keywords reference name*

hearty wasp
#

where do you recommend I start learning about custom shader guis, to actually teach myself some basics? I tried looking around a bit but it's a bit daunting as someone who's only really worked with nodes

devout quarry
#

you could just start from the docs and go from there

#

also here is an example of one of mine, but I would look at the docs first since their example is much cleaner

hearty wasp
#

where do I actually access the code of my shader graph shader? or rather, what's a good workflow to use? after looking it up, a forum post I found is saying I should first generate it to a regular shader file

#

can you go back and forth between graph and code?

regal stag
#

If you're in shader graph 8.2-ish onwards there's an option on the master node to override the Shader GUI, so you don't need to edit the generated code.

hearty wasp
#

ah okay I'm in 10.x

regal stag
#

Okay, the Override ShaderGUI option should be in the Graph Inspector window then

#

For the record, the Generate Code from graph option is in the normal unity inspector window, when you click on the graph in the project window

#

But once you generate code it's a separate shader. You can edit it, but it won't make changes to the graph.

hearty wasp
#

I'm still used to sub version 10.x and I'm not sure where to find this Override ShaderGUI option

regal stag
#

I think in the Graph Settings tab

hearty wasp
#

oh right, I see it

lethal fern
hearty wasp
#

or am I misunderstanding?

regal stag
#

I think it just needs to match the C# class name of the custom Shader GUI

#

I haven't actually used it so not 100% sure though

hearty wasp
#

I think this is the point then where I should go off and watch tutorials/read resources haha

#

thanks for the help, guys

torpid magnet
#

Does this mean the buffer ONLY contains buffer arguments or also data concerning vertices etc?

torpid magnet
mortal kiln
#

sup

mortal kiln
#

texture( sam, p.yz ).xzy; how can I do something like this in a compute shader?

#

im donig this but the results are different than my normal shader

#

iChannel1.SampleLevel(sampler_iChannel1, p.yz, 0).xzy;

torpid magnet
#

It's been a while! Just wanted to thank you again for the help. Turns out the issue was that I was using OnPostRender on a script that wasn't attached to a camera xD

simple violet
#

I'm trying to make a texture that moves left but it's just smearing the image

shell ice
#

so just wondering regarding how I could accomplish this

#

ive got tiles like this

#

I want to make a projectile hover over these tiles, and based on its current location i want the white part of the tile to light up a certain color to indicate that its hovering over them currently

#

problem is that, i want it to only light up a part of the sprite, sort of like this:

#

the pink is supposed to be sort of like a fading effect but I couldnt find a good enough color on the default windows paint palette lol

#

but yeah, is there a way I can accomplish this?

#

preferably vertical too

#

as a note, each of the tiles are its own individual sprite

regal stag
quaint coyote
#

I am wondering why the following shader code just renders only on 2 vertices?

real gorge
#

hey guys i have a bit of a math problem but i don't really know where to post it but it is in a shader so i will post it here if that is okay, say we have a circle with a given radius, and a point inside the circle and a direction as well, how long would the point have to travel along the direction in order to reach the circumference of the circle?

devout quarry
#

@real gorge circle is defined by distance(p-c)^2 = r^2 with p a point on the radius, c the center, r the radius

#

if your point inside circle is a, the line of its direction would be defined by a + td, with a being the point, t the units travelled along the line, and d the direction

#

so a point p(t) on the line is defined by the equation a+td, so if you use (a+td) instead of p in that original equation, you'll get a solution for t, and that's the distance the point would have to travel

#

basically you need to solve intersection between line and circle, that will give you 2 intersection points, and then you take the distance between one of those points and your original point to get the distance

real gorge
#

@devout quarry thank you very much for answering, i really appreciate it but i have a few questions, what do you mean by "with p a point on the radius" did you mean a point on the circumference? sorry if im being slow

devout quarry
#

yeah that's my bad, that's indeed what I mean

#

just in that first equation, p would be a point on the outer edge of the circle

real gorge
#

i understand that distance( a, a + (d * t) ) = t but how do i get a + dt?

devout quarry
#

a is your point inside your circle (x,y,z), t is variable, and d is your directional vector

#

so you want to vary the variable t, until you get a point that also satisfies the equation of the circle, and that's your intersection point

real gorge
#

so keep varying t until the length(a + dt) = radius and then that's the solution?

devout quarry
#

yeah, I mean my notation doesn't matter that much, but you said you have a point and a direction, inside of a circle: a point + direction, defines a line, and you can calculate the intersection point between a line and a circle, and at that stage you have 2 points: your original point inside the circle, and the calculated intersection point, and you can calculate the distance between those 2 points for your answer. would be good idea to look up these concepts online for some implementations, also I'm not sure if this is the optimal way to calculate it in shader in terms of performance, but it's the most intuitive way

devout quarry
#

your point a inside the circle + your defined direction, gives you a line

#

each point on that line, let's call it p(t) satisfies the equation 'a+td' where a is your point inside the circle, and d is your direction

#

so you plug in p(t) in your equation of your circle, and solve for t

#

if you get for example t = 0.3, then your intersection point would be p(0.3) = a + 0.3 * d

#

so if your point a is (0,0,0) and your direction is up, like d = (0,1,0), your intersection point is (0, 0.3, 0)

feral inlet
#

I'm trying to scale an image up and down in shadergraph, from the center point. how do i do it?

regal stag
feral inlet
#

how many textures can you have per shader state? and how many shader states can you have per shadergraph?

#

i did a massive tree of colors + masks + lerps and i'm not getting an error, and it shows up fine in the preview, but in the scene view it's just one of the colors i used higher up the chain.

quaint coyote
wind flame
#

Anyone know why my vertex coloring would be doing this? I have put a solid R G B in each corner, (only one color per vertex) and I'm getting these weird 'lines' all over and it makes textures 'stair step'. (ie. see the yellow/purple/green lines) Is there a way to stop this, or blend them differently? (the black dots show vertex locations)

#

(this was painted on a flat mesh grid with equal vertex spacing)

grand jolt
devout quarry
#

@wind flame hmm how is this not the intended behaviour exactly? It's blending between the colors right? what effect do you want?

#

the 'lines' you see make sense to me, if you've put RGB on those vertices

#

it interpolates per triangle, if you single out a single triangle, it looks fine, those lines you see are just because you put those triangles edge to edge and no interpolation happens between triangles, only within a triangle

wind flame
#

why would there be a sharp edge tho?

#

of yellows/purples, etc

#

shouldnt it look like this?

devout quarry
#

yellow is because it's blending red and green, purple because it's blending blue and red

#

yeah within a single triangle it should look like that, but it does in your image right?

wind flame
#

not even close

#

take a look

#

the colors band away only in a line

#

maybe my mesh triangles are being constructed in an order that isnt lining up with my vertex coloring?

#

would that cause it?

#

the yellow stays consistent across the whole long edge, so something has to be wrong no?

#

(its like on all edges its 'over multiplying')

devout quarry
#

but that yellow line, is between 2 triangles right?

wind flame
#

yeah, inbetween 2 separate ones

devout quarry
#

yeah so that makes sense right?

#

for each pixel within a triangle, it interpolates between the vertex colors

wind flame
#

here ill post a pic of the texturing...

#

that doesnt look normal to me....

#

see the hard line in the upper right between to vertices... it should naturally be more traingled. not 'boxed' looking, shouldnt it?

#

and here is a texture on just 1 vertex... shouldnt it be a nice smooth circle... not have those lines running away from it? (its like the color value along those points is way higher than it should be)

devout quarry
#

hmm maybe I'm wrong but to me that just seems like a limitation of the technique, vertex attributes get interpolated within the triangle but nothing special happens between triangles

regal stag
wind flame
#

well that would be better....

#

here ill mock up what i thought it would do

#

like at that same single vertex point, i thought it would 'smooth' away in all directions

#

cause its just a single splotch of color on all vertexes anyway

#

why does it have 'lines'

devout quarry
#

it has lines because it's an edge between two triangles, and no interpolation happens between the triangle edges

wind flame
#

is there anyway to make it look closer to my mockup?

#

or is this just a limitation to vertex painting?

devout quarry
#

for sure one way is to increase vertex density but probably some other tricks that I don't know about

regal stag
#

If you at least add an extra vertex to the center of each quad and break it up like so, you could achieve this

wind flame
#

right... but those lines of course would always exist?

#

(the x pattern)

regal stag
#

Yeah, that's just how the interpolation works

wind flame
#

hm... i honestly expected there to be a math blending mode, that would remove that effect

#

thats unfortunate

devout quarry
#

but if you increase vertex density, it should get much better

wind flame
#

right

regal stag
#

If you want a perfect circle, it would have to be a per-pixel based approach, maybe something like a texture splatmap

wind flame
#

hmm... well im technically using this vertex coloring as my splatmap

regal stag
#

Yeah, so you could swap it out for a hand-drawn texture or something instead. Similar to what the terrain system uses

wind flame
#

and im texturing it via the fragment shader

devout quarry
#

that's indeed good to mention, with vertex colors you'll always be limited by your vertex density, moving to the fragment shader will give smoother results but is more performance intensive

wind flame
#

hmm, alright. ill think about some things. I appreciate the help Cyan and Alexander. Cheers!

feral inlet
#

reposting my question because i messed up on the pic i sent lol:
how many textures can you have per SAMPLER* state? and how many shader states can you have per shadergraph?
i did a massive tree of colors + masks + lerps and i'm not getting an error, and it shows up fine in the preview, but in the scene view it's just one of the colors i used higher up the chain.

#

i have no idea why this is happening at the beginning and end of the chain of lerps and masks. i'm wondering if there's a limit to sampler* states and i'm doing this wrong. tl;dr i don't know what a sampler state is even after reading about it

regal stag
# feral inlet reposting my question because i messed up on the pic i sent lol: how many textur...

You can have up to 16 samplers and 128 textures per shader. There's no limit to how many times a sampler can be re-used afaik. It's basically just something that stores how the texture is interpolated and wrapped. The result you are getting is likely a problem with something else.

I haven't used texture 2d arrays much so I can't remember if they can be exposed in the material. But if they can, make sure they are in the same order that you expect. Check the colour property values too. Changing the defaults in shader graph won't update what's already on the material but would affect previews.

feral inlet
#

πŸ€¦β€β™€οΈ oh my god i cannot believe i didn't check the material. thank you, i'm ridiculous LOL

sonic bear
#

Hey i am trying to make a tilemap shader Using 2d unlit, annmnnd, when i try to offset the texture it does not repeat. Does anyone know how to fix that?

regal stag
sonic bear
#

Assss you can see it dowsnt seem to be acting right

sonic bear
#

I dont know what to do

shy temple
#

i need help..
tutorials im watching shows an option for PBR Graph for them but mine doesnt, how do I get that option?

vocal narwhal
#

Pretty sure Lit is what you want

shy temple
#

are those two the same?

vocal narwhal
#

Pretty sure

shy temple
#

alright if you say so

#

thanks!

solar sinew
#

wanted to double check if there is an equivalent to this Color mode for the Blender Mix node in SG. As far as I can tell there isn't. So I'm going to try to write a custom function in hlsl from this glsl

void mix_color(float fac, vec4 col1, vec4 col2, out vec4 outcol)
{
  fac = clamp(fac, 0.0, 1.0);
  float facm = 1.0 - fac;

  outcol = col1;

  vec4 hsv, hsv2, tmp;
  rgb_to_hsv(col2, hsv2);

  if (hsv2.y != 0.0) {
    rgb_to_hsv(outcol, hsv);
    hsv.x = hsv2.x;
    hsv.y = hsv2.y;
    hsv_to_rgb(hsv, tmp);

    outcol = mix(outcol, tmp, fac);
    outcol.a = col1.a;
  }
}```
#

if anyone knows a process similar to this in SG let me know πŸ‘

#

I think it might just be the Overwrite mode? I'm double guessing because I'm getting inconsistent results between the two

golden pasture
#

so i have a game that imports a sprite during runtime, the sprite will always have a white background, is there a way inside Unity to convert the white background to a transparent one during runtime?

thick fulcrum
#

@solar sinew I think mix is just Lerp if memory serves

solar sinew
thick fulcrum
#

not sure what that's about then πŸ™‚

solar sinew
#

yeah it's weird

thick fulcrum
#

have you checked color space, are you in rgb or linear?

solar sinew
#

I think both Blender and Unity are set to RGB, I'm not in linear but ofc gradients in SG are HDR. I know the color mode for this blender node is converting from rgb to hsv then back (based on the source code I posted)

thick fulcrum
#

I think default sampling mode is linear, so depends what your passing in

#

you could just try a conversion node from linear to rgb before passing it to the custom function to check results

solar sinew
#

custom function formatting always throws me off and I'm not sure why

#

I should be able to reference the included function Unity_ColorspaceConversion_RGB_RGB for colorspace conversion within the custom function right? or is there a different HLSL function?

thick fulcrum
#

good question, especially since I've managed to avoid doing any color space conversion πŸ€”

#

generally you can access the unity functions, though I've had issues with a few

#

in which case I lookup the function and just create a new one in my hlsl custom node file which I can then access with ease

solar sinew
#

custom hlsl and .cginc file or just hlsl?

thick fulcrum
#

sry little distracted at moment, just hlsl it's easier imo than using a string in the actual node

solar sinew
#

yeah definitely

solar sinew
#

I think though changing some color value ranges and a linear to RGB colorspace conversion, I was able to just use the overwrite mode for the existing blend node. If I do end up formatting that custom function properly then I'll see if there's any difference

thick fulcrum
#

πŸ‘

#

it's not doing a loop so could probably do that all in nodes too if one wanted

hollow mica
#

how do i remove the white spot at the end?

radiant fiber
#

I am having a problem working with a shader graph on an object that moves. When the object is not moving the material looks just fine but when I am moving with the material active, it decides to stop working

#

Another thing I noticed is that this only happens in the camera veiw. not in the viewport or preview

#

The way it displays broken like that seems to be random. Sometimes it just because invisible, sometimes the animation lags, sometimes it has random bits of light

radiant fiber
#

After 3 hours of troubleshooting, I FINALLY FIXED IT

#

I had to go to the HDRP settings and uncheck motion vectors

stray moth
#

Anyway to exclude a single object from post processing in hdrp ?

limber fossil
#

Hello.

#

I want to controll a property common in 3 different shaders

#

Is it possible ?

#

common property

low lichen
#

You can set a global property. Is that what you mean?

glacial geode
#

Hi, sorry if I'm asking a question which has maybe been asked 100x before. But I've been scouring the internet for days and can't seem to find a satisfactory answer anywhere.

I'm trying to access shadow attenuation in HDRP to apply shadows to a custom shader, however I can't seem to find an actual reference to shadow attenuation. I've seen some posts say it's not possible, but that makes me question how lit shaders exist at all in HDRP. Surely there exists a method for capturing projected shadows somewhere? Can someone point me in the right direction? Thanks.

limber fossil
fervent tinsel
#

basically, shadows are processed after the main shaders, so they don't exist yet when you want to use that data

#

(that is unless you use forward rendering, like mentioned in few posts after)

#

chances are that you'd still need to run modified HDRP to get access to this even on forward

glacial geode
fervent tinsel
#

I'd explore the forward path route if I needed this

torpid magnet
#
            uniform StructuredBuffer<float4> _Positions;
            float _PointSize;

            struct v2f {
                float4 pos : SV_POSITION;
                uint vertexIdPassed : VERTEXID;
            };

            v2f vert(uint id : SV_VertexID) {
                float4 pos = _Positions[id];
                v2f OUT;
                OUT.pos = UnityObjectToClipPos(pos);
                
                float size = _Positions[id].w;
                size = (1.0 - smoothstep(1000., 0.0, size))*5.5 + 2;
                size *= _PointSize;
                [branch] switch (id % 3) {
                case 0: 
                    OUT.pos.y += 1 * size;
                    break;
                case 1:
                    OUT.pos.x -= 0.5 * size;
                    OUT.pos.y -= 0.87 * size;
                    break;
                case 2:
                    OUT.pos.x += 0.5 * size;
                    OUT.pos.y -= 0.87 * size;
                    break;
                };
                OUT.vertexIdPassed = id;
                return OUT;
            }

            float4 frag(v2f IN) : COLOR
            {
                return float4(_Positions[IN.vertexIdPassed].xy * 0.5 + 0.5, 0.5, 1);
            }
            ENDCG
#

I currently have a shader that looks like this - it takes in a bunch of points in a computebuffer and renders them as triangles:

glacial geode
torpid magnet
#

It works quite well! However, I'd like these triangles to be displayed as circles instead. My initial thought was using UV's in some way to cull pixels in the fragment shader, but idk

#

My problem is that since my points are not in a mesh, but just given through a ComputeBuffer, I can't see how I can use UV's

tranquil bronze
normal rose
#

guys, there is an alternative to dither in shader graph? i want the safe effect but without those dots, if you know what i mean

amber saffron
#

A gradient ? Lerp ?

teal breach
#

Not looking for any question, just shared pain - just upgraded to 2020.2 and URP 10.2.2 from 2020.1/8.2 and everything is busted to high hell...

teal breach
#

Did SHADERPASS_SHADOWCASTER get removed? Or did the way it works change? My statements using it no longer seem to run in 10.2.2. Previously I had eg #ifdef SHADERPASS_SHADOWCASTER and that was fine in 8.2

teal breach
#

I can see that some of the files in URP are now using #if (SHADERPASS == SHADERPASS_SHADOWCASTER), but that doesn't work either

teal breach
#

that looks beautiful!

median gull
#

It's amazing. The only problem is that unity's virtual textures dont work with transparent shaders. Otherwise, no performance impact whatsoever.

foggy slate
median gull
#

I upscaled it to an 80k (eight 20k x 20k textures arranged in a 4 x 2) texture on a single sphere. Unity's virtual texturing didnt even blink. No difference save the 5ish min loading time.

teal breach
autumn elbow
#

Anyone able to give me a tip on why a custom shader will work fine in the scene view, but will not work in the editor in play mode? I can include the code if needed.

#

I was using the URP pipeline, but in my process of trying to figure out the issue, I removed URP and went back with the Unity default rendering. The issue remains and I have not reinstalled the URP. I just recently expanded my programming into writing shaders, and it is probably something simple, but I'm at the point of needing rescue lol. Thanks for any help in advance.

autumn elbow
#

Update: My custom shader will work fine at runtime, and in the scene view if it is applied to a 3D/2D object created within Unity. The custom shader will not work on objects that have been imported from blender, but Unity native shaders will work on objects imported from blender.

quaint coyote
#

Here's a wip of generating foliage on the fly in unityRuntime foliage generation in unity. This uses Geometry shaders to create foliage at runtime.
https://youtu.be/_qpw7qP41Ug

In this video, foliage is dynamically being generated by taking mouse as an input. Geometry shader is being used to create the foliage geometry/mesh.
Various types of leaves are used with different colors. Do leave a comment if you like it.

β–Ά Play video
grand jolt
#

how to improve ?

#

graphics generally

foggy slate
#

texture are terrible they dont fit the realism of the ambience in my opinion

#

especially the foliage

#

also the Anti aliasing is off i think cause right now all the mesh are pixelated

grand jolt
#

which foliage?

#

what is it

quaint coyote
#

@foggy slate is it for the video I posted?

echo tusk
#

Hello there, I'm wondering if there is a way I can achieve this effect With Out using stencil?

#

Oh the gif comppression

foggy slate
quaint coyote
#

@foggy slate lol okay 🀣

unique oar
#

Hey y'all, I'm having some issues with shader graph in URP. So I have two custom render passes (one to get the camera depth normals and one to apply a custom post-processing effect) and a shader (the post processing effect) for displaying world-space normals and camera depth. I turn this into a render texture with RGB representing the normals and alpha representing the depth. Then, I use that render texture in a shader graph material. Currently, I'm just trying to get it to display depth.

#

I wanted to be able to work with the "actual" depth of the objects the orthographic camera is looking at, not just a 0 to 1 representation. So I multiplied it by the camera's far clipping plane minus the near clipping plane. (Which should give me accurate values as I believe orthographic cameras return a linear depth reading)

#

I took this value and put it in a modulo function, and I'm getting some artifacts and imprecise values

#

Here's a screenshot of what it looks like

#

Zooming in, here's a screenshot of the artifacts

#

So, I've got two problems here, the lack of precision (the very visible banding) and the artifacts. I don't understand what I'm doing wrong, so I'm at a bit of a loss for ideas on how to fix this

#

Any help would be really appreciated

foggy slate
#

post processing is a lot of the time the problem

thick fulcrum
echo tusk
teal breach
# unique oar

This one looks like you have a texture with only very large or very small values (the dark and light grey areas), and that the sampler is linearly interpolating between those (the wavy bands)

#

What is the bit depth and range of the material you are putting your depth values into?

#

Try transforming your values so they lie in the range (0,1) and see if that fixes the artefacts

teal breach
regal stag
teal breach
#

I thought I tried that and it didn't, but honestly I've been at this for a few hours so everything is getting a bit of a blur πŸ˜„

#

also, more likely to break again in the future

#

it's fortunate that we can at least fudge the includes into the generated shader, but it's alarming that it keeps breaking

#

still love shadergraph overall though, aint going to knock it

tranquil bronze
#

Im generating the mesh using a script

#

This is where the texture array is created

teal breach
#

If you tilt the surface, are they still ribbons?

tranquil bronze
#

@teal breach yeah

quaint coyote
#

can we have multiple shadow caster passes?

#

or only one?

meager pelican
#

They're cast "per light" into shadow maps, but there's so many pipelines now YMMV.
Maybe say what you want to do.

quaint coyote
#

What's YMMV?

#

So I am trying to add shadows to a geometry shader

#

I am able to do so as well

#

But as I am generating foliage in a separate pass to keep the base geometry static, I am able to cast only shadows for one set of vertices

devout quarry
#

just saying that your results/chances of success/method of implementation whatever depend on several factors

quaint coyote
#

Ohhh... Is it an abbreviation from 90s? I hope so πŸ˜…

#

@devout quarry understood, it's a lil complex with unity...

quaint coyote
#

in the geometry shader, is it possible to assign different textures for different geometry, because all the vertices will be combined into one buffer

#

so what will be the differentiation based on ? uv?

unique oar
teal breach
#

but your depth buffer is probably configured differently to your output render target (eg an output RGBA8 would have only 8 bits per channel, and depending on your setup might be in the range (0,1). By the same token the depth buffer might be a larger bit depth, and still in the range (0,1), but you've done some transformations because you were expecting to store 'world space distance' in your final output).

#

I think best bet is try to map it to the range (0,1) at first and see if it removes the banding. You could always multiple out by some 'scale' parameter when you want to use it, eg divide by 1000 for storage and multiply by 1000 to convert back to world units

unique oar
#

Yeah, I

#

I

#

whoops

#

I'm using the range (0, 1) for now, but I'm still getting the same issue of banding

teal breach
#

whats it look like now?

mellow wave
#

Hey guys, i am trying to pass in a Gradient into a custom function in the shader graph. I have tried to follow the code in the following link (https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Sample-Gradient-Node.html) On how to pass in a Gradient into a custom function but i get the error that colors is a invalid subscript beacuse it is a float4 but if i change it to Gradient type i get the error that it cant convert struct Gradient into a float4. Anyone know how to fix this problem?

regal stag
# mellow wave Hey guys, i am trying to pass in a Gradient into a custom function in the shader...

float4 seems weird to me, it's possible the code snippet on that page is slightly wrong, you could use the Sample Gradient node in the graph and check the generated code to see what it actually looks like. I would try Gradient gradient as an input. "cant convert struct Gradient into a float4" sounds like a different problem. Perhaps you are trying to set the output directly to the gradient?

quaint coyote
#

guys, how do I sample a texture in vertex shader to get exact texture mapped on the geometry/mesh? tex2dlod function is cool. But the texture doesnt get mapped as ddx and ddy arent available in vertex shader

#

if I increase the box mesh vertices :

#

the idea is to sample a density map and generate mesh in geometry shader. if the sampling wont be appropriate, the density wont be appropriate

#

or should I use tessellation shader to enhance the vertices when the user goes near?

#

or do you suggest to not go with density maps but rather a density parameter and get random points on a triangle?

mellow wave
solar sinew
#

Random thought... what does unity use internally to draw Selection outlines in the scene window? I wonder if you could use that same shader elsewhere

devout quarry
#

@solar sinew freya has some tweets about that

#

she links this

solar sinew
#

nice

#

thanks

devout quarry
#

I'm not sure how useful it actually is, but if you look up 'freya holmer twitter outline selection' or something, you'll find some information on them and she got it working so it's possible for sure!

solar sinew
#

I'll check it out! I was just thinking that I've never seen/noticed aliasing with the selection outline

devout quarry
#

this one is useful as well

#

I'd love to see if you get it working πŸ™‚

regal stag
devout quarry
#

so separable blur shader for the outlines? didn't know that, thanks for the link

tall cedar
#

guys anyone had to do a fiibonacci spiral distribution for bokeh smh

#

am struggling

cloud dune
#

I'm trying to make a custom node for shader graph... I get visibility errors when using CodeFunctionNode in C#, someone know why?

grand jolt
#

is there any way to generate a heightmap from an RGB at runtime so I can feed it into a parallax node?

quaint coyote
eager folio
#

@grand jolt an rgb normal map, or...?

grand jolt
#

no, texture

eager folio
#

@quaint coyote not sure what the problem is exactly? The sampling of the vertex shader will always be dependent on the vertices available, because that's what a vertex shader is.

#

@grand jolt ok, what data are you trying to derive the height from? If you have height in one of the rgb channels, you can just pipe that channel into depth. Or is it something else?

quaint coyote
#

@eager folio absolutely. Then how is foliage generated based on density maps in games? Wont increasing number of vertices to sample density maps for generating geometry cause performance issues?

grand jolt
#

i think i found something, nvm, thanks anyways

sly finch
#

Anyone else having the problem that the gradient in a graph shader loises its colors sometimes?

solar sinew
# cloud dune I'm trying to make a custom node for shader graph... I get visibility errors whe...

CodeFunctionNode is internal only now. This was replaced by the Custom Function node as early as Shader Graph v6.7 (I believe).
https://docs.unity3d.com/Packages/com.unity.shadergraph@10.2/manual/Custom-Function-Node.html
https://connect.unity.com/p/adding-your-own-hlsl-code-to-shader-graph-the-custom-function-node

Unity Connect

Using Shader Graph 6.6's new functionality to expand the node library

#

Of course, if you are using Shader Graph 10.2.2 or newer, the options located under the cog wheel on the custom function node have been moved to the Node Settings tab of the Graph Inspector

thick fulcrum
#

@quaint coyote why not just use a texture / single channel of a texture instead of vertex?

quaint coyote
#

@thick fulcrum I'd like to generate geometry at runtime so that would involve sampling based on vertices. Is there something I am missing?

devout quarry
#

@sly finch not sure but if it gets annoying, save the colors as a preset! that way you can easily get your setup back

sly finch
#

@devout quarry y what i did now. and i realised its not the shader itself, its the shader graph editor. if i reopen the shader they are still there.

teal breach
#

Is there a way to use asmdefs with shader define statements? I'm sure I saw it once in the documentation, but I've been searching all morning without luck for it

#

I saw that there is mention in the URP changelog of adding a format like LWRP_X_Y_Z_OR_NEWER, but it appears this stopped being done at some point in URP's lifetime (for instance, there is no define for either URP_8_2_0_OR_NEWER or LWRP_8_2_0_OR_NEWER). Combined with the SHADERPASS changes, that is making it a bit hard to maintain compatibility in hlsl code

neon gull
#

Does anybody know how to get the HDR decode instructions for a texture in a compute shader? The default way (creating a float4 var with the textureName_HDR) doesn't seem to work. Alternatively it would be enough to get the instructions in c# so I can set them from there. Thanks!

teal breach
#

No idea, but perhaps if you sample an HDR texture in shadergraph and then look at the generated code it might give some ideas?

teal breach
#

Thanks Cyan, I'll check it and let you know

low lichen
#

@neon gull You can see what value is passed to a regular shader by checking the Frame Debugger. As to how it's generated, I have no idea. Seeing the value might give you a clue as to how it's generated.

devout quarry
#

@teal breach I did the same in asmdef, version defines to check if a certain URP version is present, it worked well

teal breach
#

@regal stag I guess this will work by correlation between the URP and SRP packages? Because someone on URP 10.2 probably isn't on SRP 8.2? If there is a more robust check that tests the URP version I would still prefer that, it seemed from the changelog that it was introduced but then forgotten?

regal stag
#

Yeah I think all SRP share the same version? So URP 8.2 = SRP core 8.2 too

teal breach
#

@devout quarry Are you able to feed those defines into the hlsl? My issue is that it works for C# code, but they changed how to test for SHADOWCASTER pass and so now I need to switch in the hlsl depending on URP version

devout quarry
#

hmm not sure if it worked in hlsl :/ is there a reason why it would work in C# but not in hlsl? I was only using it in C#...

teal breach
#

The asmdef defined statements are only defined in the C# and not set when compiling the shader code (at least, based on my tests)

neon gull
teal breach
neon gull
#

Basically those values get scaled by M and multiplied with the rgb values from the texture to compute color values outside of [0,1] for HDR

#

Those decode instructions are therefore specific for each texture but I unfortunately cannot find a way to get to them

#

But apparently not for regular textures/skyboxes

low lichen
neon gull
#

True, in my case even only x and y

#

But this doesn't help me to calculate them for the texture

#

Unfortunately it seems as if the function Unity uses to calculate them is internal

low lichen
#

Have you looked at the Frame Debugger to see what values are given for some different textures?

#

If it's basically random, then you probably can't reverse engineer the calculation. But maybe it's always the same values for all textures?

thick fulcrum
neon gull
low lichen
#

Well there you go

#

The mysterious decode instructions were just 1s and 0s all along

#

Maybe there's some specific situations where they are different?

neon gull
#

Hm actually there is something happening at the end of the frame on Unity's side

#

This is the result of the sampling operation in the compute shader

#

And this is the result after the Draw Dynamic call

#

there has to be another internal step that's not shown in the debugger

#

Might be Unity performing some basic tonemapping

teal breach
#

note that there is a bug with URP 10.2 not including the Version.hlsl file, so you need to include Version.hlsl, then include ShaderPass.hlsl if version > 10 (because there's another bug where it wont include ShaderPass and it doesnt exist in earlier versions), then you need to actually test either SHADERPASS or SHADERPASS_SHADOWCASTER according to pipeline version again. getting a bit messy...

normal rose
teal breach
#

not sure I understand completely - you mean the sort of blue/red sparks that flash up when the gray circle starts?

twin nymph
#

Hey guys. I'm working with the ShaderGraph on merging two transparent textures in one shader. I've got the problem that I don't understand how to merge the colors of those two together. There is a blend node, but none of the modes is doing what I would like to have.
Basically what I try to achieve is, that the lower texture is the background and the upper texture should be "above" the background. If there were no transparency, then I could simply check if there is a color value > 0 for the upper texture and simply use that, if not, use the lower one.

#

that's how it looks at the moment. The blend node is merging colors, yes, but I want the yellow flame in the background and then the orange flame on top

#

Anyone has done it in ShaderGraph (or written the shader) and has a hint for me?

normal rose
tranquil bronze
#

I have a wierd shader problem bugging me for some time now

#

For whatever reason the shader creates ribbons

#

This is the shader, its a terrain shader written using urp

#

I tried replacing the textures but forwhatever reason the first texture (grass) always rendered

#

and the second texture which is sand is rendered on top with ribbons

edgy star
#

Hello!
I'm thinking about a possible solution to add grunge effects in cavities to procedurally generated environments (floors mainly). Handling everything through a shader would probably be super heavy, so I'm considering baking the AO at runtime once a level is generated and then using it in the shader together with height data to add dust and stuff. Does anyone have any experience in that matter? Any solutions to recommend?

low lichen
#

@tranquil bronze If I had to guess, I would think this value isn't behaving as you expect
int index = ((int)floor(input.uv.x) & 1) | (((int)floor(input.uv.y) & 1) << 1) | (((int)floor(input.color.r) & 1) << 2);

#

Have you tried to outputting that number directly as a color?

tranquil bronze
#

@low lichen the ribbons still exist

teal breach
#

@edgy star sounds like an interesting idea! Can you do it using a deferred rendering style buffer and world-space coordinates?

#

a fully procedural screen-space approach would be kinda nifty to see

edgy star
#

That's why I'd prefer to prebake AO on level generation.

teal breach
#

ahh ok, depending on how custom you are willing to go you could fill a buffer with the local positions of fragments (at world scale, in the frame of the object)

#

then at least the dirt would stick to props and wouldn't move with them

#

but it would still appear/disappear if you make/break intersections

#

tbf I don't think performance would necessarily be awful

edgy star
#

I still need some kind of AO data to find crevices and I can't really use SSAO here for many reasons.

teal breach
#

you could write a material that writes the fragment positions in object space, and render the scene using that material (should be quite a small shader, only a few lines) into a render target

#

probably you would also want normals, so you could do something like pack the world-space normals and object-space positions into the render target rgba

#

then have a post process that uses that texture to perform some trilinear filtering of your dirt/grunge map, using the world-space normals to blend and the object-space positions as coordinates

#

(of course your pass will also need to do something similar to AO on your scene to figure out where to put the grunge/dirt. Perhaps you can just use the AO texture itself and blend using that?)

edgy star
#

But I still don't see how it would be possible with this method to have some dust on the floor under a furniture piece and have the dust stay there if you move that furniture.

#

At least some world space data needs to be prebaked somehow.

#

AO or some initial fragment positions.

#

Preferably AO to limit unnecessary calculations every frame (since dirt and dust won't change).

#

I could do some simple AO approximation and save it in mesh vertex colors or have some kind of low res lightmap (I doubt I would need more than 8x8 pixels per square meter).

teal breach
edgy star
#

Ohh I get it - yeah, I'm talking about something different entirely. πŸ˜‰

slate abyss
#

Hey, I'm a complete newbie when it comes to shaders and I've been playing around with some things to improve my knowledge, but I'm having difficulties understanding how to fix a transparent grass shader that I created. It looks like this currently:

#

I was creating it in shader graph, but I exported it to code in order to add ZWrite On but that didn't seem to affect anything.

#

Does anyone know what I can do? And even better point me to some articles about how transparency and depth sorting works?

teal breach
#

I'm guessing you have the grass material marked as 'Transparent' - in which case the sorting is done by distance to camera, and it isn't depth tested

#

The alternative is you can switch it to Opaque, and use the alpha cutout style to still produce your grass - it will have harder edges, but won't be drawn based on distance to camera

grim summit
#

https://www.youtube.com/watch?v=a-3miTmB-Zk&feature=emb_logo i need this but for hdrp haha, does anyone know how to make something like this ? or how i could get there ?

Volumetric Fog & Mist 2 is a complete redesign of Volumetric Fog & Mist, written from scratch for Universal Rendering Pipeline, with a focus on fog areas which makes it easier to use and performant.
The package also includes the previous Volumetric Fog & Mist for built-in pipeline.

Check it out on the Asset Store!
https://assetstore.unity.com/p...

β–Ά Play video
slate abyss
#

Is there a way to have softer edges in opaque? Or alternatively sample the color from behind the object? I'm fading the bottom to blend it into the ground

slate abyss
#

Ah, I fixed it by adding dithering