#archived-shaders
1 messages ยท Page 245 of 1
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
texture2d?
and 2 of them
done
drag each of them into the shader graph
done
the you can drag from each of the nodes
and filter in the window that pops up for "sample"
which sample do i pick?
ok drag from the texture2D node
sorry i did not describe that very clearly
drag to which node?
into the empty space
good
one is for the movie and one is for the maks
ok
the one for the movie you would connect the RGBA connector to the base color of the fragment node
any specific node inside fragment?
"base color"
done
if you want just to cut away anyting defined by your mask texture you can enable the alpha cllip option
done
then connect the channel you want from the mask to the "Alpha" property in the Fragment node
the mask is the second texture2d right?
yes
correct?
if the mask is in the alpha channel of the texture that is correct
this is how i have it rn
set you material to use that shader
and asigne the movie and the mask texture
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.
you can just click on the name of the shader in the material and search for the name of the new one
what now?
how do i create a particle shader material that is additive in shader graph
the black part still isn't transparent
fill in the movie texture / rendertexture and the mask texture
did you save the shader? i can see the * for not saved in the top left
yes I did
what textures?
"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.
Anyone have experience with Texture2DArrays? I want to double-check that I'll need a separate material for each "slice" of the array.
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
is it possible to make the lerp node accept more than 3 inputs
It depends on the shader. Does it make use of different elements of the texture array?
No. That wouldn't be lerp anymore. You can combine several lerpa in succession though.
SUPER new to shaders, but I don't... think so? It's effectively the same but for the albedo.
@kind juniper ty, preciate it
Basically: you'll need a custom shader that can actually use the texture array.
Otherwise there's no point in using the texture array at all.
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
Ok. Can you help me figure out what direction to go? Basically, I'm using HDRP decal projectors, and I want each one to project a different (non-random) slice from the array. (I'm putting posters on a wall.)
Sorry if it's obvious... I'm new to shaders.
Why does it need to be an array? Why not just have different objects with different materials(each using different texture)?
Well, I was trying to optimize a bit and learn a new skill. Not sure I achieved that first goal, though.
I wanted to combine the posters into a single image that I could reference parts of.
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.
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?
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.
Gotcha. I guess I'm just too used to 2d sprite atlases...
Anyone? Scouring the internet is turning up empty
Is it possible to iterate, get and set individual pixels on a texture in a shader?
Your texture is "lit" so it'll be rendered additively after it has received lighting
The alpha input is unused so the black area can still be lit up
You'll probably want it to be "unlit" instead
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?
by transparent I mean completely invisible, idk if that changes something, I've heard of stencils but I couldnt get any workin
They're different noises aren't they
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.
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.
Note, as of this moment, the docs have a typo, COLORMASK 0 disables writing to the color channels, doesn't enable it. https://forum.unity.com/threads/shaderlab-command-colormask.1138768/
https://docs.unity3d.com/2021.2/Documentation/Manual/SL-ColorMask.html
This page says:
channels | 0 | Enables color writes to the R, G, B, and A...
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
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
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Does anyone know how to make a Conway's Game Of Life simulator in a fragment shader?
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
bumpo
That shader needs the accompanying script to blit the results of the shader into the texture2d that it uses as input.
Otherwise you are feeding in the same world state every frame, so you will just get the same result over and over.
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
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.
So it isn't possible to just pass a texture along to the next frame in a shader?
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?
I'm gonna ask the VRChat discord if there's a method to do this with their SDK features, but i doubt it
Because it can simulate forever, a sequence of textures will eventually have to end
And?
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)
I guess so
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?
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
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.
Whats the fastest way to copy data between compute shaders? Currently to copy between two screen sized buffers takes 1.8ms
Research barycentrics...
What pipeline are you using, BTW?
Looks like built-in, yes?
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.
Does anyone know how to make a simple star field with a galaxy effect?
I'm pretty sure universal, though I don't know the effects that has on writing shaders
I kinda listen'd to a tutorial and tried to adapt it for me
I was pinged here?
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.
to what node are you outputting
wdym? like base color, normal tang, and bent normal.
Do not crosspost
Be more specific: what have you tried and what are you struggling with?
oh. wait, I got it.
because you can output to an actual material (maybe if you change targets) and then that output will give you access to stuff
no, I just forgor to change a number on my graph sadly
@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
I beleive I fixed it.
I changed it to urp but now stuff looks pink, and I don't know how to change my shader to work
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
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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.
yeah, and from what I googled people say you basically need to rewrite it
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.
I like shadergraphs since as you guessed i'm complete shite at writing them
just that it doesnt feature stencil editing rn
There are plenty of tutorials for URP stencils
they are confusing
I watched the one with the box showing two different things like 5 times
Oh I'm sure, And now @fair cresthas an example to follow.
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
You have to pick a pipeline first.
So pick one. A) URP B) built-in
Isn't that one just 7 minutes with code, setup and everything?
There's a lot of shaders I want too beyond my current abilities but there aren't many shortcuts to them
I chose urp
Well I copied the code
did the setup
and it doesnt work
OK, so let's get you set up so URP works and you don't have pink stuff.
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
OK, so if you create a lit shader in your URP project, the object is NOT pink, right?
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
What''s it say in "Project Settings -> Graphics" for the pipeline settings?
Did you create the shader in shader graph?
Is there an error message in the console?
ok i'm dumb
I wasnt creating my shaders the right way
no pink on my default shader now
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.
I just created a URP shader but yh same thing
??
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.
So where do I put the stencil stuff
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.
so which pass should I put it in, all ?
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.
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
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).
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
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.
๐
It might be there's only one pass....but there's 3200 lines of code, and not all are lighting I'd think.
How can i Tile uv's without them mirroring?
Set the texture to wrap mode? IDK what you mean by mirroring? if you tile them, you get multiple copies....
well i just do tiling and offset with tiling on x 2, but the texture is mirrored in the center for some reason
Check the texture import settings.
@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
oh bruh thanks
I tried this one already without success
I'll try carpe's way for now and try again prob
I added the respective stencil {} stuff inside the passes but nothing changes
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).
where would the new ones be ?
I just clicked compile and open code
I thought they would transform automatically into edited shader graph aka hand written shader
you have to manually save the file into <something>.shader file. And then set the material to use it.
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.
Doesn't get much easier than having an example project to steal from
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
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!
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
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
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?
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.
how would I go about creating something similar to this?
^ zelda botw mummy death
@gleaming pagoda dissolve shader+ a few particles
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?
Are you looking for something like metaballs shader?
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!!!!
Can't help more with that, never implemented myself, but I think it's used in liquid simulation as well.
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
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
Shader code and Shader graphs are separate files. "Unlit Shader" is code only. If you want a graph can use "Blank Shader Graph" in the create menu instead (assuming Shader Graph is installed).
Then you can select a Target from the Graph Settings. Built-in target is only supported in 2021.2+, or can use URP/HDRP.
Shader Graph also doesn't really support UI properly yet, so it may be better to use shader code tbh
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
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...
ty
it worked
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
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
what's the difference between name and reference? 
Name is for visual purposes within shader graph and the material inspector.
Reference is the value used with c# functions like material.SetFloat / SetVector / etc.
Does anyone know if making a distorsion effect is performance heavy please? Is for a VR game
weird
They don't need to be the same. For example, you can have a property with name "Minimum range", while the reference can be "m_minRange".
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
hm alright
Typically references also begin with "_". Somewhat of a naming convention
oh yeah I noticed that when looking at the docs
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
Using "_" also helps to avoid conflicts with certain shaderlab and hlsl keywords, like "Cull", "ZTest", "Stencil", "Offset", "float", etc
although I don't think it says anywhere that you should use the reference one and not the name one 

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)
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
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
Wild guess : the color is based on the depth, but you have no mesh beneath the water to make the depth value ?
Also : in your URP asset, did you enable the depth texture ?
yes i did.
already tried but thats not working ether
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)
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
Hi @wicked prawn I'm new to this but was interested in what you're searching, did you found this :
https://youtu.be/7M4UmN54hk0
it's kinda old but the principles are the same
A quick run through of setting up the new node based shader system and now to create an unlit UI image shader
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
How do you define your UI ? a set of panels ? or maybe you use the UI generator ?
panels
UI>Canvas>and further panel> inside panel different stuff like play setting buttons etc
So you can just apply a material to them no ? and on that material you select the right shader
that didnt work :/
There's this forum thread that could help you @wicked prawn
https://forum.unity.com/threads/shader-graph-ui-image-shader.628111/
sorry but i've (real) work for my job to do ^^
Could you check that scene depth is working ?
For example, output scene depth(eye) > fract into the emission
its oaky
okay
i used image blur
for now
ill learn this
I went throught that forum thread earlier
thankyou
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...
๐
how do I get the depth texture (hlsl not shadergraph)?
I am new to hlsl but not new to shaders
So I finally got that occluder shader working, but rn the transparent occluder is written over everything when it should only hide what is behind it (and not in front of it)
https://pastebin.com/VTLVACDQ
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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?
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?
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
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...
the question is unclear
I'm not sigma like you ๐ฆ
https://youtu.be/taMp1g1pBeE?t=590 like this ?
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...
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
good luck man
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!
your specs are changing. ๐
what does spec mean in this context
and yes i've managed to make it "work" (not quite yet) thanks for noticing
I'll take any help you may give me
Firstly, congrats on getting the stencil working ๐
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.
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)
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.
Yes
I didnt understand your previous message
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
For debugging, try outputting the normal as a color, like in the preview in SG. You can remap it too if you wish.
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).
oh i get it
quite smart innit
and that depth test thing, didnt ask for it but cherry on top
I'm spitballing here.
thats quite nice
how would I go about that?
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.
What do I need to sample to output the normal as color?
You have a normal now, right? Plug it into base color.
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.
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
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. ๐
I think I'm outputting the wrong normals.. I've been outputting the Normal map, that's prob wrong isnt it
I appreciate the help though, truly! ๐
I think im not outputting the Actual normals, but just the normal map, hence X and Z dont seem to move
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.
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
I'm slow, you have to dumb it down for me. What's a "maunally rotated billboarded tree"?
Oh, its a flat billboard that I am manually rotating in the editor
I'm using that to compare
So the billboard doesn't always face the camera?
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
I thought I understood, but then I tried and I realized I didn't, do I need to make the occluder shader still show the interior faces it resides on?
OK, so you're having the billboard face the camera, and that causes a rotation in most cases, and thus your normals are off, but if you rotate the quad manually, the object2world matrix already includes the rotation so it works out.
Can someone tell me how to get the depth texture?
I am not new to shaders but new to hlsl
yes, And I've tried a bunch of different ways to rotate the normal using shadergraph, but it's Always off
I'm guessing and I'm probably wrong.
But it sounds like if you can figure out how much your billboarding rotated the quad, you could apply that rotation to your object-space normals BEFORE you plug them into the vertex stage of the master stack.
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
Yeah, have the inside-material set the stencil but ALSO DRAW. So it isn't transparent anymore, it just sets the stencil as it draws.
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
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
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)
You can surround code blocks with three ` in a row...for beginning and end of the block so like this
this is a text code block
that's the key in the upper left of the keyboard, below the Esc key on most keyboards. Three of them, paste the code, three of them again.
Or use pastebin, hatebin, etc.
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
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.
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
Probably...
By regular material, I mean normal URP material
hmmmm yeah
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?
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.
So, (Camera pos - object pos).normalized Should be the normal direction as well then, correct? Since the billboard is just a flat plane
I tried adding the stencil to most passes without success
I guess I don't deserve floaty boaty
So shouldnt this then be correct?
Another day of not being a pirate
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
it works great!
Yeah, I think you have to do that tangent too.
Arrrrgh.
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!
You do! You do!
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.
I dont know what those choices entail or what they mean
I just want to make a pirate ship like in sea of thieves
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.
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
For now I've got it working by sampling texture directly in vertex shader
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.
https://pastebin.com/EXKyeiVh
The green object is rendered after the brown one.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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
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
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
Its not possible because vertex shader is run before pixel/fragment shader. Is there some problem with sampling the texture in vertex shader?
Sigh, I expected it would not be possible too
Unfortunately yes, there is a slight problem, when sampling texture in vertex shader, the displacement value is different for each uv island, even when its supposed to be the same vertex (I guess)
this will result in gaps between polygons in different uv island...
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
Thats completely different problem then. Why dont you use world/object space position for the displacement? Btw is the model smooth or flat shaded?
I'd like to displace it in vertex normal direction, by certain amount taken from the displacement map. It seems that the displacement map needs to be precisely baked
btw the model is set to smooth (smoothing angle = 180)
Yup, precisely baking the displacement map seems to remove the gaps, I was manually painting the displacement map before..
Thanks @dim yoke
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
line 20 says Exture2d should be Texture2D
also is there a way to make this as optimized as possible? I'm developing for the Quest 2 and I need some very simple shaders and yeah
The compiler will optimize your code as much as possible
I see
ok I fixed but this line still gives that error
[MainColor] _BaseColor ("Base Color", Color) = (1, 1, 1, 1)
sorry I had that right, you need curly braces _BaseMap("Base Map", 2D) = "white" {}
ohhhhh
yeah right
unrecognized identifier 'VertexInput' at line 44 (on d3d11)
aaaaAAAA-
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
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
Is that the sprite sheet texture that comes with TextMeshPro?
All too familiar
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.
bump
Maybe Queue Rendering will help you
Thanks, where is that option?
Advanced Options in material
This is same to Sorting Priority
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
Hello! I am wondering, anybody has an implementation of a billboard shader that also ignores the rotation of an object?
this is what I have right now, and it works
but, if the parent object is rotated for example, the effect breaks
Can somebody tell me why this shader https://pastebin.com/fCcpPxCX causes 309207M variants to compile when it is included in the always include shader list and does not work in a build if it is not?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
How do I get world space positions as a texture in a compute shader?
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
so im trying to make my shader infinitely tileable using this, but it's scaled to 0 on the z axis for some reason
Use a Swizzle node on the Position output, with "xz". That'll then map the Texture2D to the X and Z axis, rather than XY which is why it stretches through the z axis.
Should be able to fix this by setting the Mesh Type to "Full Rect" on the sprite import settings
thank you
well yes but that stretches it on the other axis..
is there a way to not make in stretch in any direction
Would need more texture samples if you need it to work on planes aligned to other axis. There's a Triplanar node that will handle it for you. https://docs.unity3d.com/Packages/com.unity.shadergraph@14.0/manual/Triplanar-Node.html
alright, thanks!
Is it possible to make a gradient of textures in the shader graph?
You'd sample the textures and Lerp between them
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?
Object node has a Position output which gives you the origin of the object in world space. It extracts it from the model transformation matrix. It won't work if the object is static batched though, or sprites / particle systems which also batch.
The Transform node would let you do that
thank you!
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?
There's no built-in way that I'm aware of. But you could write an editor script or something and use material.SetTexture("_OtherTex", material.GetTexture("_MainTex")); to copy it over.
(Though then you might also want to remove the old property from being serialised too. e.g. https://forum.unity.com/threads/clear-old-texture-references-from-materials.318769/)
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.
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.
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
but it doesnt really work?
is there anything fundamentally flawed about my approach?
@burnt wigeon Maybe Normalize after the Subtract?
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!
thank you
You would probably have to write a script that toggles the effect in c#. Unless I'm misunderstanding?
void Start()
{
Invoke("Toggle", 2.0f);
}
void Toggle()
{
gameObject.GetComponent<Renderer>().material.SetFloat("_On", 1f);
}
This took me so long to figure out
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
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? ๐ตโ๐ซ
What do textures have to do with it ?
UV = UV * Tiling + Offset; just declare two float2's for yout tilling and offset
I want to create radial gradient for whole screen, using distance on uv tiling + offset.
Sorry, I don't know how to put it. Noob here.
Distance to what ? Im very confused. Are you making a pp effect?
I cannot create code snippet in here... I will give you screenshot
The bot will delete your code its bugged use a paste site
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
Im going to repost my question if anyone wants to take a look
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)
I will try it first. Thank you Uri! ๐
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
You dont. You have to convert it to be compatible with built in render pipeline. Btw is it shader graph or shader code?
With most recent version of Unity, you can target the built-in renderer with shadergraph
shader graph
made with urp unlit shader graph
how can i do that
Add the built-in RP to the target list here : https://docs.unity3d.com/Packages/com.unity.shadergraph@13.1/manual/Graph-Target.html
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
if you can give one texture a half transparent edge,then you can read the alpha then do the job
the road edge don't have to be solid? edge can be stone and dirt fade out like that?
yes but if i change the texture its gonna swap it out
not smoothly transition into the next one
the other way is to get a hight map of the road then use the height map to do smoonthness
oh maybe i can lerp between the two textures
"Inverted normals"
what
That's the name of the phenomenon
is there a fix
Plenty
pinned to #๐โart-asset-workflow
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.
The buzzworld would be "world space mapping", and it should work in 2D like in 3D
How does it "break badly" in 2D ?
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
Often the best way to explain is to post a screenshot ๐
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?
I have since deleted the experiment..... Bad practice I know
Not a single node, but it can be achieved, for example, with remap and round
ok thank you
Normally it should be as simple as : take XY or XZ world coordinates, multiply by a scale and use as UV input for sampling a texture ๐ค
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
Feel free to experiment and post here for help
Okay so I followed this tutorial https://youtu.be/vIh_6xtBwsI
and I got this result
Tutorial on how to make a tileable material in unity shader graph.
Works in HDRP or URP
This works great for walls and floors or other objects that use a seamless tileable texture
So I guess the texture isn't repeating like it should?
Check your texture tilling settings (in the texture importer settings)
Looks like it is set to "clamp"
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
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?
Hehe glad tou like it, and also thanks, didnt know you could orbit around like that haha
Is there any way to get bindless textures in a compute shader so I can have variable sized arrays of different sized textures?
please help
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
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?
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
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)
@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
will give you this
oh I didn't notice until now, thank you!
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)
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
sry my unity locked up, I gotta restart it
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
DoDebug is the name
of the function?
oh I thought you said DebugDo previously, my bad
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
oh alright, thank you it's working now
gl!
the numbers are a bit hard to read, but it's working
do you know why it's showing numbers like this at times?
you are using a value thats not a single value
it's coming out of a tangent node, does that give bad things to this?
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.
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
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.
What pipeline and what shaders ? Whats the frame timing with and without detail maps ?
URP, custom shaders. I wish I had frame timing data saved but this was a problem that we had before I came on board and I'm at the very beginning stages of reopening the case file so to speak.
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.
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
If you want to take a look then that would help me out, gimme a day or so ๐
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.
Yeah I just need to check to make sure I'm allowed to share/I have to make sure I grab the right shader
hello fellow developers... I just started began with learning shader graphs
and I want to know, what am I doing wrong here?
give it a base color maybe
are you on the proper pipeline?
Yes, URP
do I need to add anything else?
I used this
And all settings are default
Looks good to me ๐ค weird
๐
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
I made an URP project only
out of ideas, it should just work oob
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 ?
Texture arrays and procedural layering
sorry for slow reply, got distracted
does procedural layering refer to a stack of control maps that are applied consecutively to get the final result
or is it something else ?
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.
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
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
It seems like a wireframe shader + crystal shader
easy to find both with a simple google search
Thanks, I will start with these points in mind
Hey, would anyone be able to tell me how I ought to access a texture that I've defined through https://docs.unity3d.com/ScriptReference/Shader.SetGlobalTexture.html Shader.SetGlobalTexture within shader graph?
Use a texture property in the blackboard, but in it's settings untick "Exposed"
Thanks
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 ?
If by "no color" you think of a (0,0,0,0) value, you can do this in shadergraph by using a loop in a custom node
yep, so I can use loops, but they aren't exposed in shader graph itself, I see
thanks ๐
time to learn hlsl 
IF the array isn't that big you could also make it purely with nodes
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 ๐
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.
If you want seamlessly repeating noise, you would use an image texture with a seamlessly repeating pattern
Or alternatively use some type of projection to draw the noise on the mesh
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!
This the solution then ?? I'll try it out
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
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 guess shader code for reference
https://pastebin.com/3ATLG8BQ
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I feel like it should be possible to rid myself of the overlap without letting the background render through, but I've been stuck
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?
... 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
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.
ok thx I'll check it out
hmm, I'm not sure, but I think that I'm trying to get like a combination of the two
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.
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
how would i add particles to this dissolve shader?https://gyazo.com/98e911b86d425d10b4630d5f0098ce20
huh?
and also i thought it was
cause it involved shaders
alright
ive got no base here to start with
but i want to make a shader that allows "blobs" to merge and seperate
https://www.youtube.com/watch?v=uqH9fVD-9ec&t=100 like seen here
timestamped
im not really sure where to start
its called metaballs, there should be a lot of tutorials on that
thanks
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
It's likely caused by gamma vs linear colourspace differences
oh, I need to look that up, thanks for the clue ๐
If you're in BiRP there's a few shader functions in UnityCG.cginc to convert between them : https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/6a63f93bc1f20ce6cd47f981c7494e8328915621/CGIncludes/UnityCG.cginc#L84
For URP/HDRP, see Color.hlsl : https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl
And for SG there's a Colorspace Conversion node : https://docs.unity3d.com/Packages/com.unity.shadergraph@13.1/manual/Colorspace-Conversion-Node.html
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?
Should be able to stop colours being really bright/dark by clamping the T input between 0 and 1. (use a Saturate node)
Can also Remap/Inverse Lerp before that to change the range where the interpolation part appears.
Or alternatively use a Smoothstep into the T input, bit less linear.
thank you ๐
The generated code example here should help : https://docs.unity3d.com/Packages/com.unity.shadergraph@13.1/manual/Rotate-About-Axis-Node.html
Why is it called Generated more like, why is it generated?
It's the documentation for a 3d rotation node in Shader Graph. The graphs generate shader code behind the scenes.
That's fine, you can just copy the function and use it. It's just the first place I thought of that had an example of a rotation in 3d.
I need the Degrees one right?
Depends if you plan on using angles in degrees or radians
I think your 2D example would be in radians
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!
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))
@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 ๐
Now that you mention it, I remember that the one who wrote the code used pi for the rotation controller in a script!
Thanks for making it clear!
@regal stag Actually, they even mention it at this moment: https://youtu.be/kY7liQVPQSc?t=1544
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...
A tool for sharing your source code with the world!
does anyone know how can i change the color of the material via script ?
GetComponent<Renderer>().sharedMaterial.SetColor("_Color", color)
thanks
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;
}
Declare it as float3 from the start?๐คทโโ๏ธ
which one exactly?
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.?
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
Maybe with UV node -> Multiply by SomeValue -> Floor (or Ceil/Round) -> Divide by SomeValue, into the UV port on the Voronoi. That should make it look more pixelated if I'm not mistaken
Nice! I'll try it out. Yet again using your handy-dandy blit render feature ๐
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.
in both the division and multiplication?
Yeah
What would you call the Division node? i just called it PixelationDivision lol
I don't really know, probably something like that ๐
Fair fair, thank you v much ๐
is this chat for compute shader questions?
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?
The mesh needs valid UV maps to display the texture
ah you are right, i completely forgot that, thanks :)
Why would you create that many threads?
You realize that the compute shader is invoked multiple times, right?
The most common numthreads is (8,8,1)...
Can i have multiple Blits at once? is that viable?
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
why is the material not rendering? thanks
Urp?
You should be able to use the blit feature multiple times yea.
Would likely be more expensive than a single blit though. If you will always have those effects active can combine them in the same material.
yes
Check your graphics settings
Ok
Make sure there's a urp asset
how do i check graphic setting lol
i download URP and imported
Ok
Check the second link in the #archived-urp channel pinned messages. It has setup info there
rlly appreciate
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
You don't need the .shader part. The property values are stored in the material. Use material.SetColor/SetFloat/SetVector/etc functions, with the "Reference" field of the shadergraph property
https://docs.unity3d.com/ScriptReference/Material.html
I see thanks ๐ I almost had it
Remake what? No? Just upgrade them?
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?
What do you want to do, specifically?
There is the ability to output to multiple render targets...
Assuming it is supported on your target platform.
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
^
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
So what would your blits be doing? Can you not do this in one blit with some if's? (IDK what your input data looks like).
yea thats what im trying to do now
Be sure your camera is rendering the layer the foam is in
its part got 4 components added together in one shader with two subgraphs
maybe the two shader subgraphs arent rendering in?
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
You have to use the lod texture sampler (Sample Texture 2D LOD Node)
Lod selection on regular Sample Texture 2D node relies on partial derivatives which doesnt exist on vertex stage
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
OH wow yeah that worked, thank you, ill be sure to remember that concept!
Just to clarify, they do support that. With shaders, colors and vectors/numbers are the same (same data structures are used to represent both)
On handwritten shaders, it doesnt even matter if you do float3.xyz or float3.rgb, they are both exactly same
Yeah that part I am aware of thanks! I was sure it was a unity thing not allowing me to connect it and not a shader thing. Which it was. Thanks again!
rendering settings fixed, tysm
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
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];
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
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.
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) ?
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)
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
Yes, it's been years since I last had to do that, so I can't remember
I think it was atan2
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
yes
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?
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?
Probably? But you have to watch out for x=0.
Well, I guess if all winds perfectly cancel each other out i will have issues
So you're trying to get the "net wind direction" having 4 vectors with magnitude.
yeah
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?
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.
Ah, so set SetGlobalVectorArray lets you set smaller vectors?
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.
hmmm
I guess I can try to 'fix' the wasted space once I actually have it working with the waste of space
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.
Does anybody here has good resources about compute shaders ?
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:
take a look at triplanar mapping
Looking at tutorials online, this is likely what I needed, thank you!
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)
I cant really recognize single node from such pixelated image
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?
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
All righty, thank you for all the help <3
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?
Figured it out, you just have to use a legacy template
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?
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
If a material has locally set keywords, does it start to ignore global keywords?
For camera position, use camera node.
For depth fade, you'll have to do it yourself by comparing current pixel depth with scene depth value
I can't use the camera node as it's URP only, I'm using HDRP
The camera node is available in both RP
Huh.. documentation is wrong then, I've stayed away from it all this time since it says URP only
Huuu ?
Maybe I've convinced myselft that it works in both, but I don't see why it wouldn't work in HDRP
Not really sure how to do the depth fade comparison part, fairly new to shaders -- just trying to get this one going
Look how this intersection shader is done : https://www.youtube.com/watch?v=ayd8L6ZyCvw
The depth fade is kind of the opposite of intersection.
This is a tutorial on creating an intersection shader using Shader Graph in Unity 2019 alpha which uses the depth scene node
This material is part of the URP Material Pack Vol 2:
https://bit.ly/lwrp-materials-2
Checkout my assets for more Tuts!
...
appreciate the help ๐
following the tutorial and with some changes I sort of got it working now:
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
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:
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
https://docs.unity3d.com/Manual/ShadowPerformance.html
See the part on "Shadow acne"