#archived-shaders

1 messages ยท Page 245 of 1

knotty juniper
#

@stable agate
use this + to make 2 texture parameters

stable agate
#

hey guys
i have 0 experience with making shaders
do someone mind helping me make a shader for transparency cutout on a material so my video is all thats shown?

#

ok

stable agate
#

and 2 of them

#

done

knotty juniper
#

drag each of them into the shader graph

stable agate
#

done

knotty juniper
#

the you can drag from each of the nodes
and filter in the window that pops up for "sample"

stable agate
#

which sample do i pick?

knotty juniper
#

the one without the LOD

#

(the top one)

stable agate
#

i dont have that

#

imma record to show what im doing

#

might be doing wrong

knotty juniper
#

sorry i did not describe that very clearly

stable agate
#

drag to which node?

knotty juniper
#

into the empty space

stable agate
#

dragged like this

#

oh

#

done

knotty juniper
#

good
one is for the movie and one is for the maks

stable agate
#

ok

knotty juniper
#

the one for the movie you would connect the RGBA connector to the base color of the fragment node

stable agate
#

any specific node inside fragment?

knotty juniper
stable agate
#

done

knotty juniper
#

if you want just to cut away anyting defined by your mask texture you can enable the alpha cllip option

stable agate
#

done

knotty juniper
#

then connect the channel you want from the mask to the "Alpha" property in the Fragment node

stable agate
#

the mask is the second texture2d right?

knotty juniper
#

yes

stable agate
#

correct?

knotty juniper
stable agate
#

this is how i have it rn

knotty juniper
#

set you material to use that shader
and asigne the movie and the mask texture

stable agate
#

?

#

oh

#

u mean drag the shader into the material?

toxic peak
#

Aight, I think I've managed to do the PSX or whatever vertex snapping using shader graphs.
I saw people snapping vertices to world position or to view position, but that approach didn't change the object's accuracy depending on the distance, so a mesh would be messed up up close, but look okay from afar.
By using the perspective divide it is possible to put vertex coordinates at the plane of the screen, snap them according to the screen grid, and then magically place them back where they belong, but all messed up.
Look at the mug, LOOK AT IT! It looks a bit bonked up close, but from afar it's phasing out of existence entirely.

knotty juniper
stable agate
#

oh, got that part now

#

and now?

sacred saffron
#

how do i create a particle shader material that is additive in shader graph

#

the black part still isn't transparent

knotty juniper
knotty juniper
sacred saffron
#

yes I did

meager pelican
#

"Specific mesh" is opaque? Opaques are rendered BEFORE transparents unless you take additional steps. Like render layers, queues, or camera stacking. So if you DON'T want it rendered behind a transparent object, you'd stencil check it like was said above but you would also have to render it AFTER your special transparent object. The transparent object would set the stencil, the opaque object rendered later would check to see where the stencil is set and not render a pixel there.

steel perch
#

Anyone have experience with Texture2DArrays? I want to double-check that I'll need a separate material for each "slice" of the array.

onyx heron
#

Does anyone know how to apply Unlit attributes to a Decal Shader Graph (URP)? Apparently the settings force normals and reflections into the mix and I can't turn them off or replace them with Unlit Shaders without accidentally affecting surrounding areas.
The result I was trying to get was that any projected areas without transparency in the projection texture get an Unlit texture (solid black), but the normals and lighting is messing it up

unreal portal
#

is it possible to make the lerp node accept more than 3 inputs

kind juniper
kind juniper
steel perch
unreal portal
#

@kind juniper ty, preciate it

kind juniper
#

Otherwise there's no point in using the texture array at all.

mental lake
#

Can someone explain why this shader's stencil check isn't doing anything? I'm trying to use it a fullscreen blur using URP render feature

steel perch
#

Sorry if it's obvious... I'm new to shaders.

kind juniper
steel perch
#

I wanted to combine the posters into a single image that I could reference parts of.

kind juniper
#

I just think that it's a wrong use case of a texture array.
But anyways, you'll need to have some kind of property that defines the index of the texture that you want to render. Then in the shader you'll sample the texture array with that index to get the right texture.

steel perch
#

I've basically done that (I think) but I've had to use a different material for every index. Is that normal?

#

There's not a lot of documentation on texture arrays that I could find, so I wasn't even sure if this is a good use case. What would you recommend for this scenario, if not texture arrays?

kind juniper
#

Well, that's the issue with your approach. You'll need to somehow pass the index into the instance of the material or get it from the data of the mesh being rendered. Otherwise you might as well use regular textures.

#

I'd just use a regular shader and set different textures via code.

#

I'd profile my game and only attempt to optimize that if it has a major impact on performance.

steel perch
#

Gotcha. I guess I'm just too used to 2d sprite atlases...

onyx heron
unkempt mist
#

Is it possible to iterate, get and set individual pixels on a texture in a shader?

grizzled bolt
tropic field
#

What are the best settings for importing a Custom Perlin Noise texture?

#

I have two different Node setups

#

In the first (top) I am using a SampleTexture2D to get my Perlin Noise from

#

in the second(bottom group) i'm using the Gradient Noise Node

#

Why is there such a difference in between the Brightness of Noise, as well as the final normals?

#

and how do I fix it?

fair crest
grizzled bolt
tropic field
#

yeah

#

i assume there is some diff behind how each was calculated

meager pelican
# mental lake Can someone explain why this shader's stencil check isn't doing anything? I'm tr...

I gave it a quick look but didn't run anything, so I'm guessing here.

BUT...Unity uses certain stencil bits (it's an 8 bit value I think) during lighting and maybe shadow calcs. So I'm assuming that your objects set your stencil ref of 1 when they're drawn, and then you want to blur them using this shader in a post processing pass? (I'm not sure when your render feature is being called).

Now, about stencils...the thing is that they'll operate per pixel. The GPU will check the stencil value of that pixel and decide if it will call the frag function or not. So this blur will only happen where pixels were drawn with a 1 ref in the stencil. Unity may have clobbered that value in its lighting cals. Try another value, such as a 2, and use a mask also (there are read mask and write mask keywords, use them to mask off all the other bits you don't care about).

Also, it won't blur outside of the drawn object, it will only blur where the pixel drawn was a N ref.

The render feature thing is a bit weird to me, so maybe check their stock shader to see how it handles such things.

meager pelican
# fair crest by transparent I mean completely invisible, idk if that changes something, I've ...

Yeah, it matters. It doesn't have to be in the transparent queue, there's nothing drawn. You were right to check into stencils, you need to use that if at all possible, much faster too. The GPU will literally skip the frag function for pixels that fail the stencil test...saves work, makes things faster.

"Just" draw your transparent object (your stencil mask object) with COLORMASK 0 to not output to the G buffer, and ZWRITE OFF. Set the stencil (See post above for more info). Maybe draw it in geometry-1 queue so it gets drawn first.

Then all your other objects that care about this effect have to honor that stencil and check for it. But of course you'll want something to be behind your transparent object...right? You don't want the camera fill color, and probably don't want the skybox. So you'll have to suss it all out and decide what gets drawn and what doesn't.

heavy panther
#

I'm trying to translate a gradient based on the uv coordinates of a face. I'm trying to make it so the gradient is translated for each face of the object the material is applied to.

#

I'm having trouble finding some kind of node or mathematics that allows me to translate the gradient based on that particular pixels coordinates on the face

fair crest
#

I understand the theory between stencils but not the actual syntax because i'm new to shaders

Hide surface should write to the stencil buffer on every one of the pixel it's covered in.
Hidden surface should then compare and only pass when the stencil is not equal to 1.

But this doesnt work and the HiddenObject is never hidden by anything
https://pastebin.com/jaMNftZh

unkempt mist
#

Does anyone know how to make a Conway's Game Of Life simulator in a fragment shader?

unkempt mist
#

I found this, but it only runs the first generation. Either that or it runs the same generation over and over again on the same frame. https://github.com/sevelee/2d-game-of-life-by-frag-shader/blob/master/Assets/2DGameOfLife/Shaders/Cell Shader.shader

GitHub

A simulation of Conway's Game of Life. By fragment shader of Unity. - 2d-game-of-life-by-frag-shader/Cell Shader.shader at master ยท sevelee/2d-game-of-life-by-frag-shader

eager folio
#

Otherwise you are feeding in the same world state every frame, so you will just get the same result over and over.

unkempt mist
#

Is there any way to make it run in just a shader? I'm trying to make a VRChat Avatar compatible shader, which means no scripts.

#

I've seen compute shaders of it but i don't know if those are compatible with avatars

eager folio
#

Probably not.

#

You could cheat and just make a flipbook of the game of life running and use it as a texture.

#

Since you can't use a script, you can't have any interactivity anyway.

#

So you might as well just prerecord your states.

unkempt mist
#

So it isn't possible to just pass a texture along to the next frame in a shader?

eager folio
#

It is very possible. With a script.

#

But otherwise, not very possible.

#

Fragment shaders don't generally keep track of world state; they process an input into an output.

#

Given how fast a small grid game of life simulates you could perhaps do something stupid like simulate one step, then simulated 2 steps the next frame, then simulate x steps on subsequent frames until it breaks something. But there is no way that that is a more effective solution than just pre simulating it.

#

You won't be able to interact with it, so why do you need to simulate it live?

unkempt mist
#

I'm gonna ask the VRChat discord if there's a method to do this with their SDK features, but i doubt it

unkempt mist
eager folio
#

The VAST majority of patterns you will randomly seed into a game of life will quickly end up in a static configuration.

#

Especially in a bounded region(like a texture)

unkempt mist
#

I guess so

eager folio
#

And most of the rest are loops with a known period. That is, an easily loopable texture.

#

And especially for VR, do you really want to be using most of your(and your vr playmates') vram on something like that?

unkempt mist
#

It would just be cool to have an actual simulation of Game Of Life on a shader without faking it is what I'm saying

eager folio
#

I get what you're saying, but you are going to have the same pattern actually displayed either way.

#

It isn't faking to run the simulation and cache that data in a texture.

#

And I'm guessing that this kind of stuff is why they won't let you run arbitrary scripts.

#

Because someone thinks, 'oh, it'd be super cool to run a thousand raycasts a frame' or 'I could do some neat CPU mesh deformations' and suddenly people's VR goggles are melting.

lean lotus
#

Whats the fastest way to copy data between compute shaders? Currently to copy between two screen sized buffers takes 1.8ms

meager pelican
#

Looks like built-in, yes?

brazen mica
#

How do I make things less shiny? Typically you can modify the metalic and roughness of a material in the inspector but I can't here.

cerulean nebula
#

Does anyone know how to make a simple star field with a galaxy effect?

fair crest
#

I kinda listen'd to a tutorial and tried to adapt it for me

brazen mica
#

I was pinged here?

meager pelican
# fair crest I'm pretty sure universal, though I don't know the effects that has on writing s...

Check in Project Settings->Graphics->Scriptible Render Pipleine Settings
If it's empty, it is built-in pipeline. Otherwise it will probably say URP or something.

Anyway, if you're in URP it matters to some degree, since Shader Graph doesn't support stencil yet, and also, the style (includes and such) for shaders is a bit different if you're writing them by hand. So your tut needs to match your pipeline.

fair crest
brazen mica
grizzled bolt
brazen mica
#

oh. wait, I got it.

fair crest
brazen mica
#

no, I just forgor to change a number on my graph sadly

grizzled bolt
#

@brazen mica If you want a smoothness control for your shader like the default ones have, you can create a new float property and connect that to smoothness input

brazen mica
#

I beleive I fixed it.

fair crest
meager pelican
# fair crest I kinda listen'd to a tutorial and tried to adapt it for me

OK, is this what you're after?
So the cube is is the occluding (you called it transparent) object. It is written first.
The sphere honors the stencil mask and won't write where the sphere is, regardless of depth.
The capsule doesn't honor the stencil, and doesn't even realize the cube exists...the cube occluder has no effect on in.
Code here:
https://pastebin.com/9GpNErx0

fair crest
#

yes that is it

#

i'll try that thanks

#

stuff still looks pink tho

meager pelican
#

Well, that's the syntax. I cannot help you much with URP specifics since I mostly avoid it.

Pink? That's because you have a shader error. And it is probably due to your messing with pipelines. Since shaders have to be compatible with pipelines.

fair crest
meager pelican
#

Yeah, it's a different pipeline. But standard GPU things still apply, of course.

#

Include files are different, some function syntax is different, etc. The render feature thing is "new" and is dealt with differently.

#

I just don't see much reason for using URP, personally. Since I hand-write shaders anyway. And I can be "minimal" too, in built-in. I'm not all too sure what URP gives me as an advantage.

I totally get that HDRP is much different and more photo-realistic.

I don't dislike URP, I just haven't bothered with hand-witten shaders for it. Not motivated enough, when there's 10 years worth of good built-in info on the net.

fair crest
#

I like shadergraphs since as you guessed i'm complete shite at writing them

#

just that it doesnt feature stencil editing rn

meager pelican
#

Exactly.

#

(on the feature thing, not your skills)

grizzled bolt
#

There are plenty of tutorials for URP stencils

fair crest
#

I watched the one with the box showing two different things like 5 times

meager pelican
#

Oh I'm sure, And now @fair cresthas an example to follow.

fair crest
#

I just want that one shader I can't do in shadergraph

#

but this syntax is so shite and its not even written like a proper coding language

#

and visual studio doesnt do syntax on it

#

proper shite

#

Optimally I'd get a finished working shader

#

and try my hand at shader writing on an easier task

meager pelican
grizzled bolt
fair crest
#

did the setup

#

and it doesnt work

meager pelican
#

OK, so let's get you set up so URP works and you don't have pink stuff.

fair crest
#

I know how to get urp to work

#

I just create a lit shader

#

I dont know how to occlude stuff like the thing you sent

meager pelican
#

OK, so if you create a lit shader in your URP project, the object is NOT pink, right?

fair crest
#

I did think I knew since I had done it before

#

but now it doesnt

#

It works for standart material of course

#

but if I create a urp shader it doesnt

meager pelican
#

What''s it say in "Project Settings -> Graphics" for the pipeline settings?

Did you create the shader in shader graph?

fair crest
#

Yes I did

#

there is my URP asset in there

meager pelican
#

Is there an error message in the console?

fair crest
#

ok i'm dumb

#

I wasnt creating my shaders the right way

#

no pink on my default shader now

meager pelican
#

Good.
Since SG doesn't support stencil yet, you have to hand write them. But you can start with a basic one you generated from SG since SG is basically a code generator.

So take your default one, and in the inspector, click on the "Show generated code" button or whatever the hell it says these days. Copy the code and save it into a new file with a .shader extension. You won't be able to edit it from now on with SG, it's a by-hand shader from now on.

fair crest
#

I just created a URP shader but yh same thing

meager pelican
#

??

fair crest
#

Okay I have the shader

#

3200 lines ๐Ÿ˜‹

meager pelican
#

Yeah. lol. OK, so go to that pastebin link I gave you and get the two stencil commands from them. Note the occluder shader is real minimal, and it also has color mask and zwrite off in it.

You'll have to create two hand-written shader materials. One for the occluder object, the other for all the other objects that need to handle the occluder stencil.

The occluder one can be really simple, you can probably pare down those 3200 lines to around 100 lines. ๐Ÿ˜‰

But the other one....the "all the other" shader....that one you'll have to go through and for each pass in the shader where it matters you'll have to apply the stencil logic. IDK what the hell is going to happen with shadows yet. Shadows are going to be a B.

fair crest
#

So where do I put the stencil stuff

meager pelican
#

After the Pass { but before the HLSLCODE. See pastebin for where they are placed. But there's going to be a lot of versions in that generated code. These are shader variants.

fair crest
#

so which pass should I put it in, all ?

meager pelican
#

all of em that matter! ๐Ÿ˜‰
But the thing is, shadows will suck.
Maybe you don't even want to do this, but I cannot tell what your "big picture" plan is. I can only answer the question you asked originally. So if you can turn off shadows for the occluded objects, that's the easiest.

fair crest
#

I have ship

#

ship on water mesh

#

water mesh is visible inside ship

#

so me occlude water with a mesh with the shape of the ship

meager pelican
#

OK, fine. So the water won't draw where the ship is. The ship is the occluder, and the water is the occluded object.

#

The water doesn't need to cast shadows, I hope. So no problem.

#

So any pass that draws the water itself (not a shadow pass or whatever other pass, just the normal passes) should honor the stencil and need a stencil command in the pass. (occluded)

The ship should set the stencil (occluder).

fair crest
#

well it's the inside of the ship that will be the occluder but yeah

#

cuz otherwise you can always see the ship

#

So stecil in universal forward pass

meager pelican
#

Yeah, but doesn't matter unless you use different materials for inside vs outside. "ShipMaterial" will just have an occluder stencil.

#

Yeah, and any base passes. Whatever, me no do URP.

#

๐Ÿ˜‰

fair crest
#

me no do either

#

so base passes is even more abstract to me but i'll try

meager pelican
#

It might be there's only one pass....but there's 3200 lines of code, and not all are lighting I'd think.

spring night
#

How can i Tile uv's without them mirroring?

meager pelican
#

Set the texture to wrap mode? IDK what you mean by mirroring? if you tile them, you get multiple copies....

spring night
#

well i just do tiling and offset with tiling on x 2, but the texture is mirrored in the center for some reason

meager pelican
#

Check the texture import settings.

grizzled bolt
#

@fair crest I can confirm this one https://youtu.be/EzM8LGzMjmc works on both 2020.3. and 2021.3.
Only needs one shader and which doesn't have to be generated
There's even a link to an example project in the video description

spring night
fair crest
#

I'll try carpe's way for now and try again prob

fair crest
meager pelican
#

I like @grizzled bolt 's video version with the render feature, easier.

#

But OK.

#

He still had to hand-write a custom shader to set the stencil.

#

Anyway...

#

Check that you're using the new shaders on the material...not the SG version (no offense, just double-checking, since nothing happened).

fair crest
#

I just clicked compile and open code

#

I thought they would transform automatically into edited shader graph aka hand written shader

meager pelican
#

you have to manually save the file into <something>.shader file. And then set the material to use it.

fair crest
#

They told me I have a syntax error after the stencil block

#

on both

meager pelican
#

IDK man you'll have to play with it. He (in that video @grizzled bolt showed, and also in my examples for built-in) had it just inside the pass {} block. Make sure it isn't inside anything else like inside tags or something.

grizzled bolt
#

Doesn't get much easier than having an example project to steal from

fair crest
#

I tried thfjkgjizurh ziyh

#

multiple times

#

straight up copied it

#

I put the stencilgeom.shader on my occluder

#

but then nothing

#

I'll just try again again again again another day

#

thanks for the help tho

#

i'm just slow

hazy vapor
#

Hello, I know nothing whatsoever about shaders so I was hoping if somebody would be able to inform me about a question I have. I am using a water shader from the asset store and I noticed that waves/foam form wherever the material collides with other gameobjects such as the terrain. My question is, would it be possible to obtain the contact points between the terrain and this water shader?

#

Thanks, if anyone does reply to this please @hazy vapor, just so I see it!

lean lotus
#

so...
How would I go about making a shader I could use in the camera and spit out world space normals, distances, etc?

#

as textures

lean lotus
#

Or I suppose how would I go about getting the albedo of all objects in a compute shader or as a texture to pass to a compute shader

junior sky
#

Hello Shader people. New to the game. Hopefully a normal question.

I have a project where I instantiate prefabs. Instead of having them pop out of nowhere I want to use a cool shader asset that just went on sale (Materialize/Dissolve). It's guide is here. https://inabstudios.gitbook.io/documentation/#yui_3_17_2_1_1653633683282_2692-1

But the simple question is: I see this says to use it I apply the script and use their 'MaterialDissolve()' function. Does that mean that I just basically take out my 'instantiate' function and replace it?

If I instantiate on something like this:
GameObject bigBarrel = Instantiate(gamePieceArray[winningBarrel], new Vector3(7, .5f, 0), spawnLocation.rotation);

should I just stop instantiation on that line, just define bigBarrel, then write some sort of GetComponentInChildren statement (the prefab is an empty GameObject with the barrel with the script as a child) in order to run the MaterializeDissolve() function that the FAQ says I should run?

wraith inlet
# junior sky Hello Shader people. New to the game. Hopefully a normal question. I have a pro...

You should instantiate the object with the dissolve set to be completely dissolved, then animate the dissolve parameter to have it dissolve in. Essentially, you have to instantiate the object so it exists before you can do anything with shaders to change how it looks.

You might also need to do some extra work to prevent it from doing gameplay stuff until it is done dissolving in, but that's kind of a case by case thing.

gleaming pagoda
#

how would I go about creating something similar to this?

#

^ zelda botw mummy death

west eagle
#

@gleaming pagoda dissolve shader+ a few particles

winter timber
#

not certain if this is the right place to be really asking this, but how do i mash objects together, to look like one object, a bit like if in real life you had a bunch of things you threw a blanket ontop of them

#

guessing shaders of somekind would be easiest to do this with, by getting a list of all positions, and then moving up and down points in the "blanket", or something like that?

desert orbit
#

Are you looking for something like metaballs shader?

winter timber
#

i have no clue what that is, let me quickly google that

#

oh my that looks exactly what i need, and it is with spheres, which is what im working with, thank you so much!!!!

desert orbit
#

Can't help more with that, never implemented myself, but I think it's used in liquid simulation as well.

winter timber
#

its ok lol, there appears to be tons of tutorials on it, thank you so much though for putting my weirdly worded idea into a coherent term

wicked prawn
#

hey guys
i cant seem to open my shader
like i created a shader and i want it to open in shader graph window
but thats not working
i even removed shader and reinstalled it from package manager
any idea what could be wrong

#

right click create>shader>unlit

#

in project settings

#

it opens its c# script

#

no

#

im gonna use this shader on my ui

#

is it available on package manager

regal stag
#

Shader Graph also doesn't really support UI properly yet, so it may be better to use shader code tbh

primal harness
#

Does anyone know how the fog of war/Volumetric fog in an RTS game like Dune: Spice wars gets generated?
I'm trying to recreate something similar, but not sure where to begin doing research into this kind of effect.
https://youtube.com/clip/UgkxwqJEuBTNYWtYhTl4SY83MMa1uimR8Awa

YouTube

22 seconds ยท Clipped by dicemaster ยท Original video "The New DUNE: SPICE WARS Game is a PERFECT Example of Early Access DONE RIGHT | FIRST IMPRESSIONS" by Ra...

โ–ถ Play video
restive radish
#

By the way, I managed to set the custom light model for the lit shader graph (a simple cell shader). Result is below.
https://twitter.com/GoodOldPixel/status/1538887367393689601

Tears of Magic - Pixel Art Water

We have created a shader for Tears of Magic so water uses the same pixel art lighting model as the rest of the game. It's just a small pond, but what do you think about it?

Youtube for higher quality: https://t.co/lWoBale9z7

#GameDev #PixelArt

โ–ถ Play video
median gull
#

If anyone has experiences with draw mesh instanced procedural, please tell me how to properly transfer the TRS matrix of an object for rendering to camera

compact pebble
#

what's the difference between name and reference? Huh

regal stag
tulip carbon
#

Does anyone know if making a distorsion effect is performance heavy please? Is for a VR game

restive radish
compact pebble
#

oh

#

wouldn't you want them to be the same though?

restive radish
#

the reference is used in the shader, while name is used in the editor windows and the shader graph

#

you can't use spaces in references, for example

#

you could also be trying to follow some standard inside the company

compact pebble
#

hm alright

regal stag
#

Typically references also begin with "_". Somewhat of a naming convention

compact pebble
#

oh yeah I noticed that when looking at the docs

restive radish
#

yeah, it's c# convention. In C++, the _ is by the end of member variables

#

it's to differentiate member variables from function variables or parameters

regal stag
#

Using "_" also helps to avoid conflicts with certain shaderlab and hlsl keywords, like "Cull", "ZTest", "Stencil", "Offset", "float", etc

compact pebble
#

although I don't think it says anywhere that you should use the reference one and not the name one TrollDespairSmokeTime

restive radish
#

Reference is only used in c#, but if you do your programming in shader graphs and don't access shaders in code, you can safely ignore it

#

You can also convert shader graphs to hlsl, then the name of variables in materials will be defined by the references

#

there are few instances where you want to convert from shader graph to hlsl, though (to use custom lighting in lit shader graphs is one example)

lean lotus
#

Are there any reasources or anything on how to properly read from the motion vector texture for reprojection? so far its seemed completely broken, with only moving forward/backward giving me any geometry information and its infuriating that the built in motion vectors seem to be completely useless, with turning the camera or movving the camera left and right giving no information as to geometry movement

median river
#

Hey, is this the right channel to ask for help? got a Problem with my shader graph and its Mtl color

#

The water does look like water but the colors just wont change, and i dont exactly know why.
Would be great if someone could help me with it

amber saffron
#

Also : in your URP asset, did you enable the depth texture ?

median river
rain niche
#

Hello,
I would like to "mix" a particule system into a shader graph,
(I have a spheric sun in shader graph, and would like to add layers of particules)
Am I imagining functionnalities ? Or is there a way to move the configuration of a particule system into shader graphs ?

#

(So i can resize with no problem the sun, without having to adapt the particules sizes for example)

wicked prawn
#

hi guys

#

can we apply shaders to ui?

#

like a ui image

#

basically

#

I want a distortion effect on my ui image

#

which will make it look like its water

#

if someone can help me with this it'll be great I've been trying to find and do this since 5 hours

rain niche
wicked prawn
#

i did

#

it didnt work for me ๐Ÿ˜ฆ

#

thankyou for sharing though

#

I created distortion shader

#

than thought ill apply it to a particle effect

#

but my distortion shader is also not working

#

here it is

#

so i created two or three kind of distortions

#

this one is heat distortion

#

but the thing is once i create them they never work on scene and i want to apply them to my UI

rain niche
#

How do you define your UI ? a set of panels ? or maybe you use the UI generator ?

wicked prawn
#

panels

#

UI>Canvas>and further panel> inside panel different stuff like play setting buttons etc

rain niche
#

So you can just apply a material to them no ? and on that material you select the right shader

wicked prawn
#

that didnt work :/

rain niche
amber saffron
# median river yes i did.

Could you check that scene depth is working ?
For example, output scene depth(eye) > fract into the emission

wicked prawn
#

okay

#

i used image blur

#

for now

#

ill learn this

#

I went throught that forum thread earlier

wicked prawn
#

https://www.youtube.com/watch?v=XCWRH4FIdKg&t=619s
if anyone can guide me how to use this effect on ui in 2d it'll help me alot ive been stuck in this for like 8 hours

You learn how to create Distortion Shader using Shader Graph in Unity 2019.3 beta which depends on Universal Rendering Pipeline.

We have used the concept disclosed in the following unity video:
https://www.youtube.com/watch?v=atPTr29vXUk
Then we optimized that to work with 2D sprites by adding features to the rendering pipeline.

Shader Graph i...

โ–ถ Play video
#

๐Ÿ˜„

halcyon lance
#

how do I get the depth texture (hlsl not shadergraph)?

halcyon lance
#

I am new to hlsl but not new to shaders

fair crest
near current
#

Hi yall! I'm working on a Leaves shader, in shadergraph (URP). Everything is looking good, but I'm running into a thing in regards to the Cross Leaves our tree models have

#

First of, what are those cross leaves called? I tried googling but couldnt find the correct term.

#

Second: How would I go about masking those? What are some good techniques for that? Or does anyone know of any example shadergraphs I could take a look at?

stray orbit
#

Hello, i have a question does anyone know a good tutorial on a shader that can make 2 shadows for sprites in a topdown game?

steady pike
#

Hi

#

is it possible to cover a collider with a sort of mesh or material and then maybe uncover it, so you can see this effect of creating a object and removing it with a sort of transition?? maybe the question is unclear so lmk

rustic dagger
#

Is there a way to modify soft shadow filtering so they're "fuzzier" in higher resolutions? The blur being resolution-dependant and hard coded is causing me some issues...

steady pike
#

I'm not sigma like you ๐Ÿ˜ฆ

fair crest
#

Letโ€™s learn how to create one of my favourite effects: Dissolve!

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

โ— Download the project: https://github.com/Brackeys/Shader-Graph-Tutorials

โ™ฅ Support Brackeys on Patreon: http://patreon.com/brackeys/

ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท

โ™ฅ Subscribe...

โ–ถ Play video
steady pike
#

I'll look for an animation that explains it

#

wow

#

kinda let me check it

#

oh damn, so I think I should check that first to see if it's what I'm looking for

#

looks clean

#

@fair crest thx, u really are a sigma male

fair crest
#

good luck man

grand jolt
#

Hello, sorry If I'm a total noob with shaders but I need some help with Graphics.Blit() between RenderTextures of different formats. I need to write a shader to normalize/denormalize pixel values. Anybody here who might help me a little? Thanks a lot!

meager pelican
fair crest
#

what does spec mean in this context

#

and yes i've managed to make it "work" (not quite yet) thanks for noticing

fair crest
meager pelican
#

Secondly, the specifications we talked about before had an occluder that occluded without regard to depth.
I'm currently trying to decide if you need/want stencils or not, or what to say in reply.

IIRC, you're dealing with water, and when inside the ship, the water was inside the ship because it's a plane. And you wanted the water to ignore the inside of the ship, so drawing the inside would have the water not be there in that inside-the-ship scene.

fair crest
#

It's one scene

#

sea of thieves style

#

waves are a complex mesh

#

I need the stencil to be depth aware or another method like you said

#

not drawing the water seems easier than drawing everything else over it

#

but what do I know about these things (nothing)

meager pelican
#

OK, SofT is using...uh...galleons....so it doesn't occlude outside. You can see the ship under the water in shadowish. So outside the ship, IDK why you'd need a stencil. Right, or wrong?

#

SO I'm assuming that you wanted a stencil for the INSIDE of the ship, so it doesn't look flooded.

fair crest
#

I didnt understand your previous message

near current
#

Hi guys. I'm working on a billboard shader for trees. So far so good, but I can't seem to get the Normal to rotate in the exact way the billboard does.. It's been driving me up the wall for Weeks now

#

Front lit everything is cool, lighting comes from the top etc

#

Backlit is where the problems start. The billboard shader seems to rotate the normal so that the light comes from the bottom?

#

This is the shader I'm using

#

Last thing that I can't wrap my head around.. The normal seems to change based upon the rotation of the billboard's transform? If the shader is rotating the normal in the same direction as the position, it shouldnt move when rotating the transform in the editor, right?

#

Any help would be much apreciated. This is starting to haunt my dreams

meager pelican
#

For debugging, try outputting the normal as a color, like in the preview in SG. You can remap it too if you wish.

meager pelican
# fair crest Yes

So have two materials?
One of the outside of the ship, that's normal and depth-tested....and the water should just work OK.
And for the inside of the ship, since the inside is dry and can be below water level, it would have a stencil operation, aka be an occluder.

#

maybe your outside-ship material could clear the stencil buffer for it...too.

#

but it may not need to, if you draw that first (the outside).

fair crest
#

oh i get it

#

quite smart innit

#

and that depth test thing, didnt ask for it but cherry on top

meager pelican
#

I'm spitballing here.

fair crest
#

thats quite nice

meager pelican
#

Well you kind of did, since you want stuff in front of the occluder to be drawn...which means water over the outside of the ship below the water line.

near current
#

What do I need to sample to output the normal as color?

meager pelican
#

You have a normal now, right? Plug it into base color.

near current
#

Ahh okok

#

Frontlit

#

Backlit

#

or should I compare it to the manually rotated tree?

meager pelican
#

Well, I'd compare. But...green is up (0,1,0) and red is pointing down the x axis (1, 0, 0) in world space, and blue is pointing down the z axis (0, 0, 1), so your WS normal should conform to that if you have the right normals.

near current
#

Ahh okok... So Green stays up, but if red is X in world space, it should point the opposite direction in one of the viewpoints, so that's already weird I guess

meager pelican
#

So that's just a way to visualize what #'s you're getting for normals. note that the negative ones will be black because they're below 0.

#

As to WHY you're getting what you're getting, IDK, I'm lost and my head hurts right now. ๐Ÿ˜‰

near current
#

I think I'm outputting the wrong normals.. I've been outputting the Normal map, that's prob wrong isnt it

near current
#

I think im not outputting the Actual normals, but just the normal map, hence X and Z dont seem to move

meager pelican
#

The normal map is going to be object space normals before being transformed. You can 'just' ask Shader graph to give you that value (ws normal). The normal you plug into the SG vertex stage is the object-space normal. SG transforms that to WS or whatever you request from the node, using node-magic. I think it's a black art of some kind.

near current
#

Gotcha

#

So, the tree on the left is the manually rotated billboarding tree, the one on the right is rotating the normal through the shader

#

so I need to get the billboarding tree to look like the tree on the right, correct?

#

Here we are Frontlit, so that seems one on one accurate

meager pelican
#

I'm slow, you have to dumb it down for me. What's a "maunally rotated billboarded tree"?

near current
#

Oh, its a flat billboard that I am manually rotating in the editor

near current
meager pelican
#

So the billboard doesn't always face the camera?

near current
#

Yeah, sorry I should have just called it manually rotated tree

#

1 tree is billboarding, the other is manually rotated. The billboarding tree isnt rotating the normals correctly, the manually rotated tree does rotate the normals correctly, and is in the screenshots to compare to what the billboarding tree Should look like

#

Just dumping these pics here again so there's no need for scrolling

fair crest
meager pelican
halcyon lance
#

Can someone tell me how to get the depth texture?

#

I am not new to shaders but new to hlsl

near current
meager pelican
near current
#

Yeah that's what I've been trying to do. I've used multiple billboarding techniques and trying to apply them to the normal

#

this is what it's at atm

meager pelican
near current
#

but I've tried using the normalized direction (after subtracting object pos with the camera pos) for example to. Which should Really be Just the direction.. Doesnt work..

#

it's really starting to get to me lol

#

This for example.. Gives almost polar opposite results

fair crest
#

I had changed it to this but it resulted in what I sent, I must be missing somethin (quite ironic you are forced to send code pictures in a coding discord) @meager pelican

#

I'm a bloody idiot with these things

near current
#

And it flips the direction of the lighting.. Where as manually rotated tree always has the light coming from the top, the billboarding tree rotating the normal that way gets light from the top when front lit, and light from the bottom when back lit ๐Ÿ˜ฟ (see original screenshots)

meager pelican
# near current This for example.. Gives almost polar opposite results
meager pelican
#

Or use pastebin, hatebin, etc.

fair crest
#

I know that

#

The server doesnt allow long messages, and like 15 lines is too much

#

Just deletes it the bastards

#

Anyway you got any idea why it still wouldnt show even with the blend and zwrite off ? or is it stenciling itself or some shenanigan

meager pelican
#

There's no vert or frag funciton, it's just a stencil setter

#

You want a normal material that you add the stencil-set to so it also draws your textures and such.

fair crest
#

sounds fair i'll try that

#

but since it's urp wont I run into trouble ?

#

like regular materials look pink or smth

#

or do I need to do the whole decompiling graphs again

meager pelican
#

Probably...
By regular material, I mean normal URP material

near current
#

I realize I have No idea what matrixes actually are and how to use them

#

Come to think of it, I'm not sure how I got the Direction to Position part of my shader. It must have been with the help from someone

#

But, the normal Vertex Input is a Direction though, right? Like a normal Vector3?

meager pelican
#

It's a vector3 but it's a vector (direction) not a location (point). I thought that link was interesting since it is talking about vector 4's because it wants a 0 or a 1 as the .w component.

near current
fair crest
#

I tried adding the stencil to most passes without success

#

I guess I don't deserve floaty boaty

near current
#

So shouldnt this then be correct?

fair crest
#

Another day of not being a pirate

near current
#

or do I have to specify that the Vec3 direction after subtracting and normalization is a direction with a transform node?

#

No that doesnt change anything with the above posted screenshot. Not when I say its a type Direction or type Normal

#

GOT IT

#

multiplying the Normal Vector with the constructed Matrix did seem to have the best results. No inversion, etc.. I have no idea what a tangent is (shader n00b), but on a whim I tried to just do the same I did for the normal vector as for the tangent vector

meager pelican
#

Yeah, I think you have to do that tangent too.

meager pelican
near current
#

Also no weird results anymore when I rotate the billboard in the editor (that was somethign that bothered me. The normal rotation still seemed depended on the objects original rotation)

#

Awesome, thanks for the help!

meager pelican
fair crest
#

I'm way past my usual giving up time

#

no water and i'll be a happy man

meager pelican
# fair crest I tried adding the stencil to most passes without success

I hope I'm not steering you wrong.
But from what I understand, the only things that need to worry about the stencil, right now, are hollow boat-like objects that have dry areas below water level...like the boat interior. Or a tea cup with mice it it, floating in the water (another type of boat) or a rock that has a center hole/tunnel/stairway down into a secret cave.

#

And of course the water shader, that has to know not to draw water in those areas.

fair crest
#

I just want to make a pirate ship like in sea of thieves

echo flare
#

I'm working on a ghost monkey shader and I've been able to sample depth buffer values while raymarching through a cube mesh, but scaling the object is problematic. The scaling transformation appears to be applied after the shader executes (which makes sense because I haven't changed raymarch step size or step count). I can access object scale in shader graph and I think I could offset the fragment position (object space) by some factor using the scale to calculate the final position of the fragment in view space, but I'm having trouble imagining what that looks like.

tacit parcel
#

Hi, is it possible to pass data from surface to vertex
Example use case, I'd like to mask/multiply vertex displacement using alpha from texture

tacit parcel
#

For now I've got it working by sampling texture directly in vertex shader

meager pelican
# fair crest I'm a bloody idiot with these things

No you're not, this is hard. GPU/shaders are hard.
And there's many ways to do things.
I got it working in URP.
But I have to go to sleep now, I have a 10 hour workday tomorrow, and I'll be getting 5 hours sleep (Had a nap though) but I'll get back with you tomorrow afternoon my time (USA Eastern).
Basically, I edited two shader graph sources (Probably wrongly but it is working).
Another way would be what was explained in that 7 min video.
But either way, here's a mock-up:
The green is the interior object, with the interior shader that sets the stencil. The brown is the exterior object, the blue is the transparent water that honors the stencil, the yellow is the ocean bottom, and the sphere thing is just some old fake-rock with a default lit material on it.

unreal portal
#

Is it possible to make a gradient of some kind in the shader editor that uses given textures? Like the textures ->gradient node -> sample gradient node . Using based on height so preceeded with world pos -> split

halcyon lance
#

I want to make a shader that will draw something as grey if it is behind anything, like in mario odyssey, to do this I want to render in the overlay queue, and compare the z to the depth at that point, but i can't figure out how to get the depth texture

fair crest
#

I added the stencil part to working shadergraph code but it tells me :
Parse error: syntax error, unexpected TVAL_ID, expecting TOK_SETTEXTURE or '}' at line 36
what am I getting wrong about shader syntax

dim yoke
tacit parcel
#

Maybe I should look into compute shader where I can 'paint' the color into the vertex themselves then use the infomation to displace the vertex

dim yoke
tacit parcel
#

Yup, precisely baking the displacement map seems to remove the gaps, I was manually painting the displacement map before..
Thanks @dim yoke

upbeat horizon
#

so I'm trying to make a couple shaders, lit and unlit ones that take in just a texture

#

and I'm very new to this

#

and I have no idea if this one even is very optimized, but it also gives me this error

#
    {
        [MainTexture] _BaseMap("Base Map", 2D) = "white"
        [MainColor] _BaseColor ("Base Color", Color) = (1, 1, 1, 1)
    }```
#

and for pass I wrote this

#

sorry but the chat isn't letting me send the thing through text

echo flare
upbeat horizon
#

oh

#

damn

#

๐Ÿ’€

#

well thank you!

upbeat horizon
echo flare
upbeat horizon
#

I see

#

ok I fixed but this line still gives that error

#

[MainColor] _BaseColor ("Base Color", Color) = (1, 1, 1, 1)

echo flare
#

sorry I had that right, you need curly braces _BaseMap("Base Map", 2D) = "white" {}

upbeat horizon
#

ohhhhh

#

yeah right

#

unrecognized identifier 'VertexInput' at line 44 (on d3d11)

#

aaaaAAAA-

echo flare
#

you have VertextInput instead of VertexInput declared as the struct type

#

course you can call it whatever you want, but they have to be the same

upbeat horizon
#

you know, maybe I do need an IDE

#

maybe I can't type without handholding ๐Ÿ’€

#

yesss it works

#

also don't ask about that texture, it's not mine

#

but yes thank you

serene creek
grizzled bolt
#

All too familiar

upbeat horizon
#

lmao

#

I have no textures so that's what I used

serene creek
#

Anybody knows why a sprite with transparency would always render on top of other sprites? Here you can see how the shadow below is rendering on top, however I already set the sorting layer of it to be less than the layers of the sprites in front. They are all using the default sprite material. Any help is appreciated.

grand jolt
serene creek
#

Thanks, where is that option?

grand jolt
serene creek
#

this is all the sprite shader has

grand jolt
serene creek
#

got it

#

will try that, thx

vague ginkgo
#

I have a shader graph that I'm using for fire distortion(alongside a blit). In order to achieve the effect only over hot areas like above the fire I have a sprite attached to the fire that's masked to camera that renders to a RenderedTexture

#

you can see an example of the final output

#

I am using this as an input for my shader

#

however, as you can see the effect is binary, it's either effecting the area or it's not. I can't seem to figure out how to make the intensity blend with the grey value?

#

whenever I do try to blend I get a ton of artifacting

burnt wigeon
#

Hello! I am wondering, anybody has an implementation of a billboard shader that also ignores the rotation of an object?

#

but, if the parent object is rotated for example, the effect breaks

mental bone
lean lotus
#

How do I get world space positions as a texture in a compute shader?

radiant meteor
#

when I add any kind of material made with any of my shader graphs, the selection outline (?) for my sprite gets messed up. How can I fix this? (second picture is normal).

#

it ends up causing problems like this:

#

yet in the preview it's fine

spring night
#

so im trying to make my shader infinitely tileable using this, but it's scaled to 0 on the z axis for some reason

regal stag
regal stag
spring night
#

well yes but that stretches it on the other axis..

#

is there a way to not make in stretch in any direction

regal stag
spring night
#

alright, thanks!

unreal portal
#

Is it possible to make a gradient of textures in the shader graph?

regal stag
merry oak
#

sry quick question, is there a node to get the origin point of the object my shader is applied to, or do I need to make a property and assign it to that value?

regal stag
merry oak
#

ok thank you

#

can I transform world space to view space?

regal stag
#

The Transform node would let you do that

merry oak
umbral cargo
#

Hello.

Is there a way to change the name of a Shader property that is exposed in Materials without losing inspector references in materials that are currently using that shader?

For example, if I change _MainTex to something like _OtherTex?

regal stag
#

Might also be able to change it if you switch the inspector into debug mode and edit the property name on the material, but that's more manual. Not sure if you can do multiple at once.

merry oak
#

I'm trying to make a shader that causes the lighting on my object to appear as 2d, but everything else looks the same by making all of the vectors move to the view space z coordinate of the object's origin. It's giving me sort of what I want with lighting, but it is also messing with how the object looks in ways I was not expecting.

#

Thinking about it now, I am guessing I know what's happening, so I'll try to figure out how to do the math on it.

burnt wigeon
#

uhhhhh I think I am having an aneurism here because some basic ass math is not working on my end

#

I want to check the view angle of an object

#

which should be, the dot product of the camera view and the distance between my camera and object's center

#

but for some reason it's not working on my end

#

I am doing something wrong here? Because mathematically this makes a lot of sense in my head

#

this is connected to my base color

#

is there anything fundamentally flawed about my approach?

regal stag
#

@burnt wigeon Maybe Normalize after the Subtract?

burnt wigeon
#

no luck either

#

thats what I had before

#

I even tried remapping it

#

I dont see any changes

#

huh

#

if I one minus it it works now?

#

It seems my bloom effect was making the white stronger than it should have

#

using a debugger I can see it works

#

thanks!

steady pike
#

how do I add a delay to a shader?

#

like this one?

echo flare
#
    void Start()
    {
        Invoke("Toggle", 2.0f);
    }

    void Toggle()
    {
        gameObject.GetComponent<Renderer>().material.SetFloat("_On", 1f);
    }
burnt wigeon
#

Still gotta fix some clamping issues (Or maybe use custom textures hehe) but I am happy it works

#

billboard shader + flipbooks with motion vectors for smoothness + angle fade between textures to give it a different look depending on the angle

glossy crane
#

Hi everyone, I have a question regarding the shader code:
I want to specify positionAmount for uv offset. How do I write that in URP?

I tried uv.st , but gives an error.
Thank you in advance

#

for this shader, I don't use texture. So I do not declare _MainTex_ST.
Or should I? ๐Ÿ˜ตโ€๐Ÿ’ซ

mental bone
glossy crane
mental bone
#

Distance to what ? Im very confused. Are you making a pp effect?

glossy crane
#

I cannot create code snippet in here... I will give you screenshot

mental bone
#

The bot will delete your code its bugged use a paste site

glossy crane
#

๐Ÿ™‡โ€โ™‚๏ธ

mental bone
#

Thats not how you declare variables. First declare them in the shader properties then outside a method in the hlsl block

#

Then do your tilling calcs in the vertex stage no need to do it for each frag

#

And it should be uv.xy not st

mental bone
grizzled bolt
# burnt wigeon This took me so long to figure out

That looks good! I can't locate the position of the dust animation, which I guess was your goal
(btw you can move camera with wasd while holding right click, or hold alt + left click to rotate around a focal point so you don't have to do ...that)

glossy crane
wicked prawn
#

hi guys

#

how can i use a shader that requires urp without urp

#

i dont want to use urp in my project

#

i created this shader using urp it worked fine

#

but i want to work without urp

dim yoke
amber saffron
wicked prawn
#

made with urp unlit shader graph

amber saffron
rough haven
#

is there any way to transition smoothly between two textures on a plane

#

i have a road texture on a plane that is being offset every second, i want to smoothly transition to a different grass texture without it being so sudden

#

does that make sense

west eagle
rough haven
#

ah

#

wait what

#

๐Ÿคค

west eagle
#

the road edge don't have to be solid? edge can be stone and dirt fade out like that?

rough haven
#

yes but if i change the texture its gonna swap it out

#

not smoothly transition into the next one

west eagle
#

the other way is to get a hight map of the road then use the height map to do smoonthness

rough haven
#

oh maybe i can lerp between the two textures

strange dock
#

why did the top faces disappear?

grizzled bolt
strange dock
grizzled bolt
strange dock
grizzled bolt
#

Plenty

vocal narwhal
strange dock
#

thank you very much

#

it was a tenor gif but ok

sturdy prairie
#

Ach! I don't know how to google this question so I thought I'd come here.

I'm not looking on help to achieve this, rather I just need to know what I should google. I just want to make a 2d shader that will render the textures in worldspace rather than object space. This way I could chuck a bunch of rocks down for example, and the texture would be continuous between many objects that overlap without borders. I have seen tutorials for this in 3d, but they break pretty badly in 2d. I'm sure there must be some word I'm missing that'll help me find a good tutorial or something.

amber saffron
#

How does it "break badly" in 2D ?

sturdy prairie
#

Well it was different for each tutorial. It caused really weird stretching or backfaces rendering textures in front of the front faces somehow? Even turned things inside out at one point? Was very strange and I honestly can't quite explain exactly what happened

amber saffron
#

Often the best way to explain is to post a screenshot ๐Ÿ˜„

merry oak
#

sry to but in, I just wanted to ask if there is a node that will take a value and return either 1, 0, or -1?

sturdy prairie
#

I have since deleted the experiment..... Bad practice I know

amber saffron
merry oak
#

ok thank you

amber saffron
sturdy prairie
#

I think I'm just no where near experienced enough with shaders to understand exactly what I'm doing wrong lol. Shaders are like,, the thing I don't get when it comes to unity

amber saffron
#

Feel free to experiment and post here for help

sturdy prairie
#

So I guess the texture isn't repeating like it should?

amber saffron
#

Looks like it is set to "clamp"

sturdy prairie
#

Holy hot damn

#

Thank you! Wowza, that is an embarrassing oversight.

amber saffron
#

No pb ๐Ÿ˜‰

#

It's common to be so much focused on something that you miss that the source of the issue can be somewhere else

merry oak
#

when I use things like object and camera to get position and then transform it to view space, should I transform from world space to view space, or from absolute world space to view space?

burnt wigeon
lean lotus
#

Is there any way to get bindless textures in a compute shader so I can have variable sized arrays of different sized textures?

burnt wigeon
#

For the record, if you are gonna use a lot of different textures with that material it might be worth to use the sampler state node and force it to repeat/mirror

merry oak
#

I'm confused, I assumed that if you took the camera node and plugged the direction output into a transform that converts a direction from world space to view space, then it would equal (0, 0, 1). However, using the preview node, it seems to be returning (0, 0, -1).

#

Does this mean that the camera points the opposite direction of view space?

#

I notice that the preview node shows me the result of something in a colour, is there a way to make it show a number instead?

burnt wigeon
#

Yes, gimme a sec

#

There is an open source shadergraph custom function for this

merry oak
#

how do I set that up?

#

also, does the tangent node use degrees, or radians?

#

ok I googled it and found out that they use radians

radiant meteor
#

I made a shader that has a few textures in it. I toggle them on and off. However, whenever I toggle more than one on at a time (I tried even separating by a frame or two, still the same), the sprite the material is applied to turns into a blue square briefly. Is there a way to fix that? (I used shader graph)

burnt wigeon
#

@merry oak

#

save that to a file, put it on a custom function node

#

then set the input/outputs as told

#

and set the Function Name to DebugDo

merry oak
merry oak
# burnt wigeon <@815065725730816000>

hi sry for bothering you, I'm just not sure, I tried to follow what it says and I'm getting this error
Shader error in 'hidden/preview/DebugDoCustomFunction_bbf8a025a920445a9f99954bd450dc53': undeclared identifier 'DebugDo_float' at line 179 (on d3d11)

#

oh and this one
Shader error in 'hidden/preview/mineCustomFunction_eb29cb3ff9b54551b39d693cd4d61435': variable '_mineCustomFunction_eb29cb3ff9b54551b39d693cd4d61435_New1_1' used without having been completely initialized at line 298 (on d3d11)

burnt wigeon
#

take a screenshot of the node

#

you gotta do everything exactly as the script tells you

#

set the correct input with the correct types and names

#

set the correct outputs

#

and in the Name field use the exact name as told

merry oak
#

sry my unity locked up, I gotta restart it

merry oak
#

if I hover over the red exclamation box, it says: undeclared identifier DebugDo_float

#

oh whoops, I used to have the rbga from the sample texture 2D plugged into the split

#

it's still doing the same thing though

burnt wigeon
#

DoDebug is the name

merry oak
#

of the function?

burnt wigeon
#

should be DoDebug

merry oak
#

oh I thought you said DebugDo previously, my bad

burnt wigeon
#

I did say that but I misnamed it haha

#

its on the header of the file

#


// Quick try at doing a "print value" node for Unity ShaderGraph.
// Tested on Unity 2019.2.17 with ShaderGraph 6.9.2.
//
// Use with CustomFunction node, with two inputs:
// - Vector1 Value, the value to display,
// - Vector2 UV, the UVs of area to display at.
// And one output:
// - Vector4 Color, the color.
// Function name is DoDebug.

// "print in shader" based on this excellent ShaderToy by @P_Malin:
// https://www.shadertoy.com/view/4sBSWW

merry oak
#

oh alright, thank you it's working now

burnt wigeon
#

gl!

merry oak
#

the numbers are a bit hard to read, but it's working

#

do you know why it's showing numbers like this at times?

burnt wigeon
#

you are using a value thats not a single value

merry oak
#

it's coming out of a tangent node, does that give bad things to this?

merry oak
#

So I've been trying to make a shader that essentially squishes my object for a long time, and I haven't been able to get it so I figured I'd ask here.

#

The stuff at the end is to colour it in as if it was still 3d and that part is working fine.

#

Please ping me if someone has an idea or needs more info.

burnt wigeon
#

wdym squish

#

any references?

#

if you mean squish like, scale it a certain amount on each axis

#

I would honestly just get the vector from the center of the object to the vertex, divide that in the different axis, then move the vertex position a certain amount

lethal mango
#

Question. Just looking for an at-a-glance opinion from someone knowledgeable. In our VR game project, we had to disable detail maps in our shader(s) when making builds for Quest 2. Detail maps enabled caused very bad performance. This seems strange to me as detail maps should in theory be pretty cheap. Does anyone have any quick theories about why this might be a problem? Too many texture samplers? I don't need a perfect diagnosis, I mainly just want to know if I'm right in thinking that this is an odd thing to be happening.

mental bone
#

What pipeline and what shaders ? Whats the frame timing with and without detail maps ?

lethal mango
#

I'm not a shader/graphics programmer but I am somewhat knowledgeable and am trying to gather whatever info I can so I can pass it on to our future graphics programmer if we manage to find one.

mental bone
#

Cant help much with the custom shaders unless I see them. Maybe having the detail mask breaks batching and the quest doesnt like high draw calls

#

In my experience putting textures in atlases improves quest performance a bunch

lethal mango
#

If you want to take a look then that would help me out, gimme a day or so ๐Ÿ™‚

mental bone
#

I mean I can take a look. Just post them here, lots of other more knowledgable people tham me in here as well.

#

My studio also provides optimization services if you are in need of that.

lethal mango
#

Yeah I just need to check to make sure I'm allowed to share/I have to make sure I grab the right shader

nocturne escarp
#

hello fellow developers... I just started began with learning shader graphs

#

and I want to know, what am I doing wrong here?

simple violet
#

give it a base color maybe

nocturne escarp
#

not working, tried

vague jetty
#

are you on the proper pipeline?

nocturne escarp
#

Yes, URP

#

do I need to add anything else?

#

I used this

#

And all settings are default

vague jetty
#

Looks good to me ๐Ÿค” weird

nocturne escarp
#

๐Ÿ˜…

#

Do I have to make any changes in project settings or anywhere?

#

I don't know cause this was my first ever time opening a shader graph xD

nocturne escarp
#

I made an URP project only

burnt wigeon
#

did you restart unity?

#

I would try that

nocturne escarp
#

yes

#

Restarting unity as well as re-impoting universal RP

#

tried both

burnt wigeon
#

out of ideas, it should just work oob

hexed surge
#

hello guys
a question re texture splatting for terrain shading - are there ideas / techniques that allow to splat a big number of textures other than what Unity uses in their terrain shader ?

amber saffron
hexed surge
amber saffron
#

In my mind at least, it means using more abstract terrain data (cavity, ground normal, altitude, biomes, river map) to "select" the surface properties. IE: at high altitude display snow, on vertical or very steep surface display rocks.

hexed surge
#

oh, for now at least I need to just mix a number of biomes and create a shader that can mix multiple biomes on a single mesh, so pretty basic
but still I need a shader that can mix multiple textures and wanted to know of modern options in that regard
so far I only know how unity does that

#

it won't be high fidelity at any point anyway, it's not a first person game and I want to target average hardware

short kraken
#

hello guys, I am now learning about shader graph. I want to create a shader graph similar to the video attached. Can any one suggest me a base idea or technique

restive radish
#

easy to find both with a simple google search

short kraken
tacit mural
regal stag
tacit mural
#

Thanks

hexed surge
#

I need to sample a texture, and if there's no color in the sample sample the next texture and repeat the same for all the textures in the array until there's a non-zero result
is something like that achievable in shader graph ?

amber saffron
hexed surge
#

thanks ๐Ÿ‘

#

time to learn hlsl TrollDespair

amber saffron
#

IF the array isn't that big you could also make it purely with nodes

hexed surge
#

it's shouldn't be big, 3-4 elements should be the maximum length
so I just sample, compare to 0,0,0,0, sample next, and so on until I get a non-zero vector ? I'll try that, but feels kinda wrong doing it this way ๐Ÿ™‚

lament karma
#

I'm new to shaders, and I'm trying to make a procedual skybox. My clouds are mapping nicely except for one point where they intersect each other and create a seam. Any ideas as to why this happens?

#

this is how it splits the clouds in-game.

grizzled bolt
lament karma
#

oh right, it makes sense that it does this. Even if noise is continuous if you change the offset, two opposite sides of it won't be. Thank you!

steady pike
merry oak
# burnt wigeon wdym squish

by squish, I mean like make it 2D relative to the camera angle, while still shading it in as if there was a light source coming from the top and it was 3D

north thorn
#

So I'm working on a shader for displaying some data onto a mesh, but occasionally where the system has multiple generated meshes intersecting the transparency overlaps with itself making a much darker result than it should

#

I tried applying a stencil test which solved one problem but made another by making background geometry occasionally render past the foreground

#

I feel like it should be possible to rid myself of the overlap without letting the background render through, but I've been stuck

unreal portal
#

I have a terrain model imported from blender, its not showing shaders correctly-only as one color when applying textures. Other objects show the textures just fine so im thinking maybe i messed up the normals or something on the original model, any ideas?

north thorn
#

... I made a solution to my problem
I don't like it, but it worked
I added a pass that does nothing other than prep the Z buffer, and then the second pass does a z buffer equals test

meager pelican
# merry oak by squish, I mean like make it 2D relative to the camera angle, while still shad...

Like a billboarded imposter?
Maybe google "billboard shader" and imposter shader. Also check the asset store, IIRC there's some interesting imposter routines that also have correct lighting.

Although if you use an LOD system, and swap out for a lower detail mesh at distance, the performance gains of a billboard may not be all that great in comparison, it still computes the same # of pixels for its size, it's the poly count that is significantly lower, but unless you're vertex stage bound, you may not see much gain. Spitballing here.

merry oak
#

at first I was just moving all of them to the same z coordinate as the object's origin point, but I noticed that the vertices were a little out of place, so the lovely jumble of nodes I posted a while ago was trying to calculate where they need to be.

unreal portal
#

have a question about the lerp node, am using it to make a terrain gradient with textures. Its working ok, but the colors of the textures become very warped like changing in intensity and becoming really bright or really dark. How do i control the contrast of the lerp to display both textures with a smaller gradient in the middle

gleaming pagoda
simple violet
#

I think you can use mesh shape in particle system

#

Thats not a shader question tho

gleaming pagoda
#

and also i thought it was

#

cause it involved shaders

fleet olive
#

alright

#

ive got no base here to start with

#

but i want to make a shader that allows "blobs" to merge and seperate

#

timestamped

#

im not really sure where to start

neat hamlet
#

its called metaballs, there should be a lot of tutorials on that

fleet olive
#

thanks

hexed surge
#

hello guys
weird question, but how does unity pass Color32's channels into shaders ?
I wanted to use one of the channels to pass bytes into the shader, and was expecting to get the right result by multiplying the channel's value by 255, but instead I got 0
and then empirically found that the multiplier should be around 4000

for example in the code it looks color[i].r = 3
and in the graph I have to multiply the red channel by 4000 to get back 3

#

I'm probably missing something stupid here, it just doesn't make any sense

regal stag
hexed surge
grand jolt
#

I used this to rotate a point in 2D space```
float2 rot(float2 p, float2 pivot, float a)
{
float s = sin(a);
float c = cos(a);

p -= pivot;
p = float2 (p.x * c - p.y * s, p.x * s + p.y * c);
p += pivot;

return p;
}```And now I would like to do the same thing but in 3D space, how would I go through this?
I just copied this code, that's to say I don't know what any of it means, I just just know that it gets the job done...
Could someone redirect me to get it working in 3D space?

regal stag
grand jolt
regal stag
grand jolt
#

Oh!

#

Unfortunately I know nothing about Shader Graph

regal stag
grand jolt
regal stag
#

Depends if you plan on using angles in degrees or radians

#

I think your 2D example would be in radians

grand jolt
#

I know what a degree is however, about the radians, I'm not so sure what that does, maybe a visual demo would make it clear, I'll try to find one!

regal stag
#

A full circle would be 0-360 in degrees, and 0-6.28.. (2 * pi) in radians. But yeah, google it if you need more info.
Shader functions like sin and cos in shaders use radians by default, so you need an extra conversion if you would rather use degrees (e.g. radians(angle))

hexed surge
#

@regal stag thanks again, changed to a non-sRGB texture format for the generated control texture and it works as expected now
would never found that on my own ๐Ÿ™

grand jolt
#

Thanks for making it clear!

grand jolt
#

I'm not sure what to do in here: https://paste.mod.gg/pgzrpnfpwcmk/0

I tried to change my float2 to float3 but that wasn't enough, it says// 'rot': cannot implicitly convert from 'float2' to 'float3'And after the change it says this// cannot implicitly convert from 'const float2' to 'float3'It's my first time working with Shaders, when the guy made the Shader they built it with a Raw Image in mind, mine uses a mesh and that causes some issues...

mint furnace
#

does anyone know how can i change the color of the material via script ?

hexed surge
mint furnace
#

thanks

grand jolt
#

How to explicitly convert the const float2 to a float3 in this scenario?

struct appdata
{
    float4 vertex : POSITION;
    float2 uv : TEXCOORD0;
};
struct v2f
{
    float2 uv : TEXCOORD0;
    UNITY_FOG_COORDS(1)
    float4 vertex : SV_POSITION;
};
fixed4 frag (v2f i) : SV_Target
{
    float3 c = _Area.xyz + (i.uv - 0.5) * _Area.w;
    c = rot(c, _Area.xyz, _Angle);
    float2 z;
    float iter;
    for (iter = 0; iter < 255; iter++)
    {
        z = float3(z.x * z.x - z.y * z.y - z.z * z.z, 2 * z.x * z.y, 2 * z.x * z.z) + c;
        if (length(z) > 2) break;
    }
    return iter / 255;
}
kind juniper
kind juniper
#

The one that you want to be float3

#

I assumed that you refer to z

naive mural
#

Hello, on my system when I create a compute shader with a product of numthreads higher than 1024. E.G [numthreads(2, 1, 1024)]. I get a shader compile error that it can't exceed 1024. Is the limit of 1024 true for all GPUs? Or can some have that limit as : 64,128, 512, etc.?

wary horizon
#

I'm making a screen effect for when you're standing in fire, though my game is voxel. is there a way to clamp voronoi cells to be cube-like at all?

#

I can show the full graph if needed

regal stag
wary horizon
regal stag
# wary horizon You're a genius

Nice, might be good to change the "SomeValue" to a Vector2 so you can scale the x and y differently - to make them square rather than rectangular. Or calculate a ratio from the Screen node.

wary horizon
#

in both the division and multiplication?

regal stag
#

Yeah

wary horizon
#

What would you call the Division node? i just called it PixelationDivision lol

regal stag
#

I don't really know, probably something like that ๐Ÿ˜…

wary horizon
#

Fair fair, thank you v much ๐Ÿ™‚

grand jolt
#

is this chat for compute shader questions?

icy snow
#

Hello, im working on a Customshader for my procedural island, rn i have some problems with the water. When i try the shader on a mesh for example a plane, it works perfectly.
But if i use the shader on my custom mesh, it wont show any cells. Does anyone have an idea why?

grizzled bolt
icy snow
#

ah you are right, i completely forgot that, thanks :)

meager pelican
wary horizon
simple violet
#

Some render freature scripts use multiple passes when calling command buffer

#

Would probably be more efficient to make your own render feature script instead of calling multiple render feature scripts

grand jolt
#

why is the material not rendering? thanks

simple violet
#

Urp?

regal stag
grand jolt
simple violet
#

Check your graphics settings

grand jolt
#

Ok

simple violet
#

Make sure there's a urp asset

grand jolt
#

how do i check graphic setting lol

grand jolt
simple violet
#

Edit project settings

#

Just watch tutorials first

grand jolt
grand jolt
regal stag
#

Check the second link in the #archived-urp channel pinned messages. It has setup info there

grand jolt
#

ty

#

it works now

#

just gotta remake all the materials ๐Ÿ’€

rain niche
#

Hello,
Is it possible to change the value of a property in an object generated from a shader graph at runtime ?
I want to add emission when the mouse is hovering the object so I have this code :

public class Celestial : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler
{
    public void OnPointerEnter(PointerEventData eventData)
    {
        // Make the object glow
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        // Select object and move camera
    }    

    void IPointerExitHandler.OnPointerExit(PointerEventData eventData)
    {
        // Go back to original camera position, unselect object
    }
}

Can I access the shader from the object ?

#

Apparently I can with this :

this.gameObject.GetComponent<Renderer>().material.shader

I'm still searching if I can just modify a parameter

regal stag
rain niche
#

I see thanks ๐Ÿ™‚ I almost had it

dim yoke
unreal portal
#

Is there any reason why the foam Ive created here is only showing in
scene view and not in the camera view thats attached to a first person controller?

meager pelican
#

There is the ability to output to multiple render targets...

#

Assuming it is supported on your target platform.

wary horizon
#

well, i have lava and some enemies that freeze my weapons, the plan is to use the blit feature to handle the screen effect for both the lava and the ice. But i thought of an idea that'll fix it, and make a nice mechanic

#

jumping in lava while you're frozen "melts" you, so you get rid of the blue screen effect and it just goes red

#

Sounds good to me anyway

wary horizon
oak flicker
#

heyo, i am trying to make some water but when i try to add foam something weird happens, i am pretty new to shaders and i have no idea what's wrong

meager pelican
wary horizon
#

yea thats what im trying to do now

burnt wigeon
unreal portal
#

maybe the two shader subgraphs arent rendering in?

glacial lantern
#

Does shader graph not support using rgb values for vertex position?

#

I have a texture that had data about how the vertex positions should move, but shader graph won't let me connect the texture sampler output to the vertex position

dim yoke
#

Lod selection on regular Sample Texture 2D node relies on partial derivatives which doesnt exist on vertex stage

neon snow
#

Hello, I need some suggestions
From yesterday materials with shader which have scene depth have turned white or black on scene view

#

Like water shader, in game mode it working fine

glacial lantern
dim yoke
#

On handwritten shaders, it doesnt even matter if you do float3.xyz or float3.rgb, they are both exactly same

glacial lantern
unreal portal
hexed surge
#

hello guys
I have a question re shader inputs - when I set inputs for a material (GetComponent<Renderer>().sharedMaterial.SetXXX), does it set that input on an instance of the material on that specific GameObject, or does it propagate to all the GameObjects on the scene ?

#

oh nvm, it was doing that because of the "shared" prefix

#

thought it only meant shared as in editor-playmode shared

midnight lily
#

So does this just work? Can I just dump 16 matrixes + index from C# and these lines are enough to unpack it for use? Will float4x4 Matrix = WindData[j * 17] extract the fist 16 floats or set matrix[0][0] to WindData[j * 17] and leave everything else at zero?

float WindData[16 * 17]; float4x4 Matrix = WindData[j * 17]; int TextureIndex = (int)WindData[j * 17 + 16];

meager pelican
#

Won't work AFAIK, they're different data types. You'll get an error. The width of a WindData element is the sizeof(float).
There's no union in CG, just struct.

#

So you could
A) Define an array of struct that is composed of a float4x4 and a float index, and just use that.
B) separate out the data (probably better) into two arrays/buffers, one that is the float4x4 and another that is a buffer/array of floats1's. Probably better since alignment of the 4x4 data in option(B) is going to be on a "proper" memory address boundary. GPU's like data aligned on at least a float4 boundary.

#

But it is hard to say since there's cache consistency to consider when you access two different areas of memory.

#

Understanding memory access by cores in shaders is a black art that I haven't mastered.

#

@midnight lily

meager pelican
# glacial lantern Yeah that part I am aware of thanks! I was sure it was a unity thing not allowin...

Not to butt in, but to add, it's a shader thing because:
GPU's won't compile (from any engine, not just Unity) a tex2D sampler in the vertex stage. As @dim yokesaid, you need to use tex2DLOD because it doesn't know what mip map level to use because the vertex stage happens before rasterization...so it needs the LOD version, which specifies the mip level. This is a requirement of the GPU/CG language.

midnight lily
#

Thanks, I guess it's easier to understand if I split the data too

#

On another note, if float3 lineVec = float3(cos(Direction), 0, sin(Direction)) is Direction -> float3
The float3 -> Direction would be float Direction = atan2(lineVec.y, LineVec.x) ?

meager pelican
#

I'm not sure I understood your notation.

#

Your last line results in a single float value being assigned to the float3

#

So if you have

float3 d = myFloat1;```
d ends up being (1.234, 1.234, 1.234)
midnight lily
#

I meant to ask "what is the opposite operation to float3(cos(Direction), 0, sin(Direction))"

#

If I have the float3 and want the Direction, what is the operation to do so

meager pelican
#

Oh, God. This is my nightmare from math class all over again! ๐Ÿ˜„

#

lol

midnight lily
#

Yes, it's been years since I last had to do that, so I can't remember

#

I think it was atan2

meager pelican
#

arcsine and arccosine are the inverse functions of sine and cosine.

#

Tan functions calc angles though...

#

But let's figure out what you want...because I'm stupid.
So you have a 3D point and want a direction?

#

@midnight lily

midnight lily
#

yes

meager pelican
#

Direction from where to where? Do you have another 3D point....getting direction from that is easy.

#

But if you don't, you want to reverse some calc?

midnight lily
#

I have 4 wind directions I want to lerp through

#

A Direction angle for each of them

#

but lerping angles (-PI, PI) just don't work

#

so I convert them into float3 (cos(dir, 0, sin(dir)

#

then I lerp those vectors, which work just fine

#

then I extract the resulting direction and intensity with (probably atan2) and length

#

right?

meager pelican
#

Probably? But you have to watch out for x=0.

midnight lily
#

Well, I guess if all winds perfectly cancel each other out i will have issues

meager pelican
#

So you're trying to get the "net wind direction" having 4 vectors with magnitude.

midnight lily
#

yeah

meager pelican
#

lol

#

Hmmm....

#

I think you can "just" sum them.

midnight lily
#

Also, how do I set a float2 TextureScale [256]?
There seems to be no Shader.SetGlobalVector2Array(), do I just Shader.SetGlobalFloatArray() with twice the size?

meager pelican
#

Cheat. Use a float4, ignore the zw. Or pack all 256 of them into 128 and figure out how to break it out. But since it's only 1K in size x 4, I'd just use a vector4.

midnight lily
#

Ah, so set SetGlobalVectorArray lets you set smaller vectors?

meager pelican
#

SetGlobalVectorArray is a float4...

#

I'm saying use a float4.

#

You'll have some wasted space. Because you only need .xy. You won't use zw.

midnight lily
#

hmmm

#

I guess I can try to 'fix' the wasted space once I actually have it working with the waste of space

meager pelican
#

Yeah, you can "pack" it.
So even indexes (starting at 0) are using xy, and odd indexes are using zw.

#

You have to f-around with the index math and have an if conditional/ternary. So it may not be worth it unless you're real constrained with GPU memory.

mental bone
#

Does anybody here has good resources about compute shaders ?

neat prism
#

Can anybody help me out in simple Shadergraph stuff? I want to have a material that repeats its texture using world position, but it only works for one axis, rotating the object will stretch it out to absolute zero. I only have a Position (Space: World) node for the effect, and it comes out like this:

dim yoke
neat prism
#

Looking at tutorials online, this is likely what I needed, thank you!

neat prism
#

Update question, is this a perfomance heavy graph, or it is fine with like, batching and things that are not changing up the nodes?

#

(First time doing these, so I need a point of reference is this is optimal for a shader that is used on static walls)

dim yoke
neat prism
#

(This, but twice, as I use it for normal maps too)

lean lotus
#

Hey so why does sampling a texture texel by texel in a compute shader produce different results than using a samplerstate of type point_clamp to sample it with a UV?

dim yoke
# neat prism

Id not be worried at all unless youre making the game for mobile. Sampling the texture 3 (6 in total ig) times is most likely the heaviest part but doesnt sound bad at all on pc game atleast

neat prism
#

All righty, thank you for all the help <3

grand jolt
#

Does HDRP support UI shaders? I am trying to get something working via Amplify but its just nonstop errors. Does anyone else use Amplify and have this issue?

grand jolt
#

Figured it out, you just have to use a legacy template

swift oak
#

So I have a model with some materials using the urp lit shader.
I would like to now add a shader effect to the model (like maybe a dissolve effect) but maintain the shading, texturing and normal maps.
Any suggestions on how I should move forward?

cloud citrus
#

I'm trying to convert this small shader made with amplify shader

#

to shader graph. This is from a tweet, it's a portal card fog shader

#

current issues is, how do I get the world space camera position in HDRP shader graph?
Second issue is depth fade, shader graph has no similar node

midnight lily
#

If a material has locally set keywords, does it start to ignore global keywords?

amber saffron
cloud citrus
amber saffron
#

The camera node is available in both RP

cloud citrus
#

Huh.. documentation is wrong then, I've stayed away from it all this time since it says URP only

amber saffron
#

Huuu ?
Maybe I've convinced myselft that it works in both, but I don't see why it wouldn't work in HDRP

cloud citrus
#

Not really sure how to do the depth fade comparison part, fairly new to shaders -- just trying to get this one going

amber saffron
cloud citrus
#

and you're right, the camera node seems to be working for HDRP. I would've never known if you didn't tell me, I guess you shouldn't always trust documentation

swift oak
#

Helloo. I am following a dissolve by distance shader tutorial.
THe effect I want with is rather a cut instead of a point, and for the effect to occur by the cut. So instead of it just being around a vect3 position, also have a horizontal elongation that can be orientated.
Ill attack images of my graphs:

verbal slate
#

Hi, Im doing cel shading in urp, but when i add shadow into it gets super weird... the shadow becomes serrated... can someone help me with this?

#

the pics below are the shader without and with shadow