#archived-shaders
1 messages Β· Page 210 of 1
the road is not raised :
the triangles are on top of the terrain
problem with stencil buffers is the fact that I could see roads through mountains
no, the terrain is hidden where there is roads
I'm pretty sure that the road itself is like 0.01m above the terrain
and then there's a bump up via the dirt
which touches the terrain
that's why you don't see the triangles of the terrain where there is roads
and then forms the height difference for the sidewalks
You can see the triangles of the terrain under the building, but not under the road
don't know if I believe that statement
you can't even see the actual end of the triangles that form the terrain
under the road
I would expect to see the actual points
instead the linesegments cut off
without showing valid triangles
Yes and I guess this is possible only by using a clipping mask
well something you could do
use that same texture you have right now
but make it a float2
Thank you Elliot, I tried with the depth only method but still get the background. Can you please be a bit more specific? again thank you so much
and use the second channel to store ints that reference to a compute buffer
which would have the definition for the bezier curve
that defines the road
and then you could grab the road that overlaps that fragment
and figure out if you're inside it
or next it to it
with whatever precision you need
hmmm ok then I'll have to learn about computeShader, I heard it's hard
you can do that all inside normal shader
@tired canyonAlso I noticed something, here : can you spot the difference ?
you mean the difference between the geometry and what's visible?
sometimes the pavement texture on the terrain covers more than just the sidewalk π€
are you talking about this texture ?
I suppose. This is how I create this texture :
What do you mean by that ?
@tired canyonSo which texture format you think I should use ?
It depends on what information you need to encode in it
@tired canyonyou said "use the second channel to store ints that reference to a compute buffer"
If you are looking to just render a mesh by itself, no backdrop, then try with target initialised to solid color with alpha = 0, and then after drawing you should be able to find pixels where alpha != 0. I can't remember if the post processing stack sets alpha to 1 after it makes it's passes, so you may need to disable post processing
they have the same shader and render queue, literally just wanted a different color between them
ive tried every render queue combination and nothing gave me what i wanted
i just want them to be rendered normally
Yes that's an option
But I can't code the entire thing for ya
I don't even know how good of an option it is
Is there a way of solving the problem of 'Compiler timed out. This can happen with extremely complex shaders or when the processing resources are limited.'
I tried implementing the fast voxel traversal algorithm. It works fine on the cpu but its not compiling on a gpu pixel shader in urp?
Is it better to use a compute shader?
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 had to turn the shader graph into a shader by copying the generated shader into a new file and changing zwrite from off to on
is there a way to make generated shaders shorter?
seeing this on my github repository is really frustrating
andi ts because of the shader graphs
Couldn't you also just change the type to Opaque in the graph? Or do you need transparency too?
transparency is the whole point of the shader, its a shader that lets me fade with a custom texture for the alpha
@ivory sequoia This docs page should help. Reuse a sampler from another texture, or use inline samplers. https://docs.unity3d.com/Manual/SL-SamplerStates.html
Oh right, didn't see the error was a ShaderGraph. Can connect a Sampler State node (equivalent to an inline sampler) to the Sample Texture 2D node.
Yea
If those techniques reduce the number of texture samples you need to do it might still be something to look into, would make the shader more performant
It would likely only depend if you needed a texture / group of textures to use a different wrap or filter mode. If they can be all the same, just use the same SS for all textures.
has anyone here used groupshared memory in a compute shader before
im only doing 1
why is this not working
its just showing this on the plane
im trying to get it to make smoke by subtracting circles with voronoi noise
You understand it wrong, the noise value is just one value at a specific point, its a vector1 and therefore it will show some random white to black value @vocal thistle
right
so if i turn that into a texture and output the rgba into the alpha, will it work?
the voronoi depends on UVs, so if you have some texture and UVs layed out, it should work.
anyone know how i can write a transparent color to one texture, and the depth to a separate texture?
@vocal thistleIt looks like alpha is grayed out on that master node. Do you have the shader set to 'opaque'?
hwo do i do that
No, you don't want it to be opaque, but that is the default.
Go into the settings and change it from opaque to transparent.
@digital gustthe default plane and quad have UVs, so that should work fine
where are the settings
In the same place where you set node settings, there's a tab for the shader settings
well i still dont know where that is
is it in the graph or what
oh ok
foundi t
ok thanks
how do i change the position of an image? like if i had a seemless texture and i jus t wanted it to constantly go right and loop again and again
In this tutorial we'll see how to animate texture offset inside the Shader Graph
ty
i have a shader graph that has a color and a texture that holds a color palette, how do i check which color in the color palette is closest to the initial color?
@grand jolt here's that wireframe stuff
https://github.com/JumbleJumble/WireframeBallDemo
feel free to steal as much as you want!
so i made a custom function to solve my problem, here's the hlsl code
float3 closestColor = (1, 1, 1);
float colorDistance = 1;
for (int i = 0; i < Steps; i++)
{
float3 checkColor = Palette.Load((max(i * (256/Steps) - Steps, 0), 0));
float newDistance = distance(Color, checkColor);
if (newDistance <= colorDistance)
{
colorDistance = newDistance;
closestColor = checkColor;
}
}
finalDistance = colorDistance;
Output = closestColor;```
and here is the result
input and output
color palette
Is there a way to paint the Unity terrain more accurately than this? All the scripts I have tested give me this kind of results where the outlines make "waves" π€
you'll need to write your own terrain generation
and rendering
Really ? there's no way to improve that just by using a custom terrain shader ? π€
don't think you can add geometry like that
and at that point I think it would be easier to just be generating your own mesh
terrain meshes are pretty simple to generate if they are just heightmap based
add geometry? I thought the terrain painting didn't add any geometry
ohhh that's not a mesh
being overlapped by terrain
that's you just painting the terrain
my bad I misunderstood
yes I have this script to paint the terrain :
the brush has some transparency :
How can I fade a shader? When something happens, slowly increase the opacity?
And is there any way to create a transition between 2 shaders?
Sounds like you want to expose a property on a material
And then change that property
Via script
ok, and I was thinking if you can also put a shader on top of another.
I think to transition between 2 shaders, I'd make a shader which is the combination of both
With a transition value
Which you use to lerp between the 2 shaders
And then set that transition value in script
I am doing a fade with a timer and an update which is probably not the best thing. Any other way to make that?
Anyone know how to achieve this kind of sketchy shadow with an outline?
Don't paint a 0-1 mask but try to do a signed distance field
I asked the same thing on the FR discord π³
How do you change the values from a shader only to one object? because it is changing the material values
You either need do create a new material, or use material property blocks (script)
hello people does anyone ever face this problem where the texture of the leafs its getting cut to a certain distance ?
Does anyone know why with HDRP when it's night, it gets bright?
@rich nimbus Don't cross-post. Keep it in #archived-hdrp
Thanks!
shout if you've got any questions, it's not tidied up enough for me to use it for work yet.
ill see if i can tinker with it, if I make any massive progress ill shout you in case i integrate anything you might want to steal π
strange question, I overwrite a property in a renderer with a MaterialPropertyBlock: for example the color
is there a way i can reference that renderer and get that overwritten color? or get the property block to be able to expose the color inside it
in whatever script you do this, save a reference to the original color (or property block and read the color from there?)
the api for it is a little weird - you pass it a MaterialPropertyBlock and it populates the block for you.
It's clever though - allows you to reuse the MPB to avoid garbage collection
hi guys.. i have a wierd issue.. i am using URP, there is a specif model on which area light seems to have no effect when its in "URP/Lit" shader.. But when the shader is changed to "URP/BakedLit" it seems to work better... why this occur?
Is there a way to make a shader extend past the size of the original sprite? Because mine is getting cut off
The shader only gets drawn where the mesh (yes, a sprite is a mesh) is. So to extend it, you would need to extend the mesh itself, this could be done in the vertex stage of the shader.
I tried doing it but in the inner side, and it works fine except for the top part
it has that weird thing going on
i have a subgraph with a propertty, but i cant access it in my main graph?
nvm, i didnt save the subgraph haha
Hey guys π Can someone tell me what I have to do to make this builtin shader work with URP?
Shader "Unlit With Shadows" {
Properties{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Base (RGB)", 2D) = "white" {}
}
SubShader{
Tags {"Queue" = "Geometry" "RenderType" = "Opaque"}
Pass {
Tags {"LightMode" = "ForwardBase"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
#include "AutoLight.cginc"
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
LIGHTING_COORDS(1,2)
};
float4 _MainTex_ST;
v2f vert(appdata_tan v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex).xy;
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
sampler2D _MainTex;
half4 _Color;
fixed4 frag(v2f i) : COLOR
{
fixed atten = LIGHT_ATTENUATION(i); // Light attenuation + shadows.
return tex2D(_MainTex, i.uv) * atten * _Color;
}
ENDCG
}
}
FallBack "VertexLit"
}
Hi I'm new to unity and I tried putting a toon shader I've found but now my objects don't cast shadow on others, what is the cause of that?
is there somewhere Ishoud look to enable it
or is it something I needto edit in the unlit shader graph
hey, I've got a strange bug, some of my shaders in game are using the same texture but I havent assigned it anywhere, I'm not even using it in those materials
as you can see, this is the leaf material, and the base of it is not empty, but it's using a completely random material.
Unlit graphs don't receive shadows by default (since they are unlit). You can add it in though, using something like the Main Light Shadows Sub Graph from here : https://github.com/Cyanilux/URP_ShaderGraphCustomLighting. It obtains the shadow attenuation (0 in shadow (assuming full strength shadows), 1 otherwise).
There's quite a few differences between the built-in and URP shader code. If you just want shadows with unlit you could do that in shader graph though, same as the message above ^
(If you really need to do it in code I have some templates/examples here : https://github.com/Cyanilux/URP_ShaderCodeTemplates, would need to merge the Unlit example with the attenuation values from GetMainLight(shadowCoord) in the DiffuseLit example)
So I have to download the package and put the Main Light shadow sub graph into my existing toon shader ?
Hmm not sure why that error is happening. Maybe try opening the Main Light Shadows subgraph and resave it.
oh ok
thanks it worked
I'm trying to figure out where I should connect it but I can't x) it's my first time on a graph shader
Multiplying it with the toon colour just before you put it into the master stack Base Color port should work.
If you want ambient lighting though that might need to be added with the shadow atten before the Multiply.
Idk if I understood it right, sorry ^^ I created a add node after the main light shadow and I linked it with the Shadow atten
like that?
What's in the B input?
Oh right, you already have your own Main Light function too. The ShadowAtten from that is the same as the Atten produced by the Main Light Shadows subgraph, well, it's supposed to be. The problem is that your Shadow Atten likely doesn't work as the graph requires some keywords to be added to properly handle shadows, which I do in the SubGraph to make setup easier.
You can ignore the ShadowAtten port on your node, but wherever that other connection coming out of it is going, replace it with the Atten instead. Hopefully that makes sense
Yeah that's what I was referring to, use the Atten output to replace the B input on that Multiply
Hmm, oh if you have your own lighting custom function they might be using the same keyword to prevent the file being included multiple times
yea I have a lighting custom function I copied somewhere else
do I replace the one I did with the new?
Yeah, at the top of mine it uses
#ifndef CUSTOM_LIGHTING_INCLUDED
#define CUSTOM_LIGHTING_INCLUDED
You could change those both (in mine, or your hlsl file) to prevent them conflicting
Or alternatively, replace your Main Light custom function with the Main Light subgraph I provide
I meant replace the entire Custom Function node. I use subgraphs for them all to make it easier to use (can add them from the Add Node menu, it's named Main Light).
But otherwise I think it just needs to be float precision and remove the ShadowAtten output.
I've put your additional light to my shader but it's not toon how did you toon yours ?
Check the CustomLighting.hlsl, I have a separate toon version of the AdditionalLights function
is it like that because of my rimlight part in my toonshader?
it's not the rimlight I desactivated it it did nothing
I multiplied it with an ambiant node
not exactly it
well it's not quite a shader, but it seems like the problem is in the shader. I was wondering if I was doing something wrong when applying a render texture. I'd like to project what one camera is seeing onto a plane
Do you have the render texture set as the albedo map in the material?
honestly probably not, I'll take a look in a second..
sorry, I don'tt hink I quite understand. Where would the albedo map be?
this is what I see
Base map
ok! I've got something showing up now
it's a bit washed out, but I'm getting there
Any way i can have a custom black white texture as a gradient for vertex position in shader graph?
can someone help me out with my URP project..
this is scene view.. and the Foam.. Depth thingy works fine in editor..
i cant get it to work in my scene view tho..
i checked the urp asset and depth textures are checked on.. so idk π¦
game view \/
hey there guys, as soon as i turn a parameter in shadergraph to non-exposed, it seems to have the value 0 instead its default which is 1.
I also cant seem to modify it in code. What am i doing wrong?
if it's not exposed, you can't modify in in code, that's what exposed does.
also make sure you're using the reference, not the name to access it in code.
Hey guys, im trying to get the world position of a fragment in a shader but from what im reading im sure im doing something wrong, could someone point me to the right direction?
essentially this is the part im struggling with
struct MeshData
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct Interpolators
{
float4 vertex : SV_POSITION;
float3 worldPos : TEXCOORD0;
};
Interpolators vert(MeshData v)
{
Interpolators o;
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
o.vertex = UnityObjectToClipPos(v.vertex);
return o;
}
this is the full code btw:
https://hatebin.com/brjurvzjzi
@brittle owl i fixed it.. I had already checked 100 times that the depth texture was ticked in the URP Renderer Asset but it turned out the wrong one was plugged into the renderer list π€¦ββοΈ .. thanks for the tip tho π
lol no problem
is it not possible to do a 2d subtract shader in unity? Can't find anything online. Does it go by another term?
Hello2 All,
I' m currently modfying the Viking Asset pack to fit a bit with my game.
However I'm stuck at blending the materials like this;
https://www.youtube.com/watch?v=wyzfF7HjBhA&ab_channel=TheCGEssentials
I know2... its in blender and it is a two mesh instead of materials...., but cant really find a better picture to explain it... π
.
and anyway... here is the screenshot of the viking ice that i want to modify.
I hope my explanation is clear enough..π
Do how do i achieve this blending material in Unity (URP Renderer).. ?
If possible i wanna do it without importing any extra asset...
Hello guys, I have a .. question? May I refer to #archived-hdrp because Iβm not sure which channel to use. Maybe someone has an Idea! Essentially itβs about 2D βshadowsβ and merging them from multiple sprites, then rendering them with an alpha value. It probably needs to be merged to prevent shadow stacking via alpha values.
I dont know if it has any thing to do with code but i opened my unity project and all of black materials look green ish
Any fixxes?
is there a way to get the vertexcolor as 4 bytes? I tried setting mesh.colors32 but the vertexcolor node still outputs 4 floats
In shaders it's going to be a float of some size.
But you can multiply that by 255 and then cast the result to a uint if you want to.
And if you're doing 3 or 4 channels, you can vectorize the operation. But it's going to be awkward to work with as an int.
One reason might be for performing bitwise operations.
And you can't do this in the vertex shader (pretty sure) for interpolaed output since you can't interpolate uints (they must be "flat"). So you'll probably end up doing the math in the frag(). Grain of salt on that.
I was planning on doing bitwise operations.
I saw an approach to texture blending where 1, 0, 0 is one texture 0, 1, 0 is another, etc
I wanted to use something like 4 or 8 bits for a color instead of 32, to allow for more possible materials
that seemed like one of the most viable ways to blend more materials by vertex color
hi, quick beginner question. I know that PBR Master node was changed into something another but I cant find which node I should use instead of this?
Lit
Lit Shader Graph?
yes
Thank you
okey next question, why whole material is moving towards camera?
Hey hi, I still have a problem with a shader I made a while ago. Its a wind shader that moves vertices with noise over time. I'm using it in a 2d project with moving parallax layers. I move the vertices with object position. The problem is that when using 2 objects with the same texture, the strength of the effect gets doubled when moving the objects around. Having them stationary, no problems, but when moving 2 or more objects with the same texture the effect seams to multiply between the different objects. why is this?
watch the mushrooms<
2 different textures (looking fine)
But using the same texture on both mushrooms multiplies the wind effect! Why?!
Is there any up to date documentation/examples of using the additional light shadow maps in URP (real time and baked)? I suppose the most up to date resource is https://github.com/Cyanilux/URP_ShaderGraphCustomLighting, but I wanted to check I'm not missing something else
Is there a way to fetch TAA_jitter value in shadergraph?
trying to create dithered temporal alpha
Yeah, OK, and assuming that all 3 verts have the same value for the polygon in question, you can pull it off in the vert(), pass a flat uint value to the frag, and save calcs inside the frag(). You just can't interpolate differing values of your bits, so sharing verts in the mesh would be a problem. If you need to interpolate, you'll end up doing the conversion in the frag. Or perhaps figure out the barycentrics (gasp, wink).
Again, I think. I know that you cannot interpolate uints from what I've read. And I know that some native texture values are uints, some even 16 bits per channel.
https://docs.unity3d.com/ScriptReference/TextureFormat.html
I guess the question for your use-case is how to best pull all that off with color lookups for bit-packed fields.
The article below indicates that in HLSL, using SM4.0/DX10, bit-fields are somehow directly accessed and binary operations are fully supported. I'm not sure, frankly, how to declare that in Unity such that you can get a uint directly out of the tex2D() without having to screw around with floating point crap but I haven't tried it....the old Nvidia article (also below) indicates that tex2D can return a uint. IIUC, in DX9, if you have to support that, you're still stuck with floating point and possibly work-arounds.
See about the middle of the page here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-common-core for DX10/SM 4.0.
and here https://developer.download.nvidia.com/cg/tex2D.html for tex2D return types.
So it all depends on your target platforms, and your vert color storage. From what I read.
(I was curious too. π )
The Unity Manual helps you learn and use the Unity engine. With the Unity engine you can create 2D and 3D games, apps and experiences.
I suppose another thing you can do is just store an index as a float, hell, even half floats store a reasonable number of whole-numbers (See that last link above, "Medium precision floating point value; generally 16 bits (range of β60000 to +60000, with about 3 decimal digits of precision)". IDK how that works out for your blending when using 4 color channels, but maybe you can get some clever maths in there.
i am using a water shader that is a little wavy on a plane. When i try to connect 2 planes i can see the sea floor and if i put the 2 planes in each other the colour of the water darkens. Any ideas?
@surreal coral what do you mean you can see the floor? The waves don't line up?
no they dont connect if they are on a different object
If you do the waves and foam and stuff in world space instead of object space, it will line up nicely
how do i do that?
Look up 'world space UV' online, you'll get useful results
ok thx
i had another idea
i could just scal the whole plane except for the heit
scale
hey now im looking for an easy to use toon shader for free any suggestions
?
@devout quarry hey now im looking for an easy to use toon shader for free any suggestions?
cancel that
is it post processing?
try disabling it and see if it fixes it
@surreal coral free toon shader for URP here https://alexanderameye.github.io/notes/shaders-done-quick/
thanks for your in depth response
I'm thinking a simple approach would be to make a different version of the unity vertex color node
- read data at each vertex (first 16 bits to an int corresponding to id)
- output up to 3 ids (ids of the three verts at any given pixel) and their weights
pass that data to a function that samples a texture2darray at index of the ids passed, and blends them according to weight
im not very familiar with shader coding or the pipeline so im not sure if this is a good way to deal with it
It head something to do with reflections
Hi guys, I have this outline shader on my characters.
For some reason it keeps rendering through everything. Im doing this in HDRP custom passes.
I tried changing the renderq but nothing happens. Any ideas on what to change?
Im kinda noobish to custom passes so any tips would be appreciated
Tested all kind of z test values and renderq values, nothing seem to work. Made sure im sorting by renderq aswell.
Feels like im missing something simple
Anyone encountered an error like ArgumentException: JSON parse error: The document root must not follow by other values. when opening shadergraphs in 2019 LTS?
It looks like this may be an issue with back compatibility - I have a shader graph from 2020 LTS which I need to port to 2019 LTS
currently, it seems that is not possible
IDK because you didn't post your shader, but just FYI, people often WANT that effect or something similar, so I'd hang onto what you have and make notes of how to do it each way when you get it fixed. π
let's say I wanted to make a shader that fades something in, and then that something just chills there and does nothing...
Would I just make 2 shaders, one that fades it in and then swap to the second one that does nothing or would I keep it all as one shader?
My fear with the one shader thing being, that you would then need some bool or something called isDoneFading and once it's done you set it true, and then it no longer fades, but now it's running if(IsDoneFading) every time which seems wasteful
I was about to tell them their outline shader looks really good, but then I realized they were trying to stop that lol
Not render queue but youβll probably need to change something with ZWrite
It sounds like you are doing some sort of outline pass, which draws objects you want outlines on? If so, that custom pass won't exist on default materials, so other objects in the scene will be invisible to your outline buffer
You can use the frame debugger to see what is being drawn during your custom pass, and verify if that is the case
Yeah you need to add ZWrite On to the shader that you use on the objects that draw outlines
And then in your outline pass, use βCompareFunction.LessEqualβ to test for depth (this is how I do it in URP, probably similar in HDRP)
Tyty, will try all the things later today, will update u on how it goes
And I know the effect is desired but in a scene with many objects carrying outlines it will start to look weird
When they phase through each other
real quick question - Can you call a method that's inside a shader, from outside the shader (so calling a GPU method from the CPU basically)
You can
do you know what it's called so I can google it?
You cant call methods directly from gpu on cpu. You can dance arouns it by storing values that u can later manipulate on the other. I think material values can be found in "material.SetX". So the answer is really no but maybe if u really want to
Depends on what exactly u wanna do
yeah okay that's what I thought you had to do
so i'll just index the methods and have a methodIndex int or something
which I don't mind, just double checking there isn't some crazy easy way
i have a problem. i have impact vfx that i want to be able to see but should also appear where the player punches. the player usually punches inside the enemy though so i made the enemy have a transparent shader. this makes the viewer able to see the vfx but they can also see for example the right arm if they are looking at the left arm from a side on view. does anyone know how to only apply the transparency for another gameobject so you can see through the gameobject to another but not see through that gameobject to itself?
You probably want to keep the enemy using an opaque shader and instead change the impact vfx. You could try changing the draw order of the decal to after the characters are drawn, and disable depth testing for that vfx (for simple cases).
Using a compute shader you can call a GPU method directly I believe

changing the vfx to transparent and the enemy to opaque would literally just mean you can't see the vfx which is the whole problem
and there is no decal
also i kept saying vfx but i meant particle system
not change the VFX to transparent - use a shader which does not depth test so it can draw over things which are nearer
transparency and depth testing are different things
ok
ik
Hi i have a grass shader that i am applying to a procedural terrain. i want the grass to only be rendered above a certain height. How would i go about this?
Would look into splatmaps for an efficient solution
Or heightmaps
As I understand u wanna assign different textures on different heights on the same object.
Yes but I have 2 materials. One for the vertex colours and one for the grass
How do I lerp between those
Any nice free shaders for water for URP out there?
I guess a baseline would be Unity's BoatAttack demo
There is a material.lerp function, google it, might help
https://assetstore.unity.com/packages/vfx/shaders/stylized-water-for-urp-162025 , recently made free, if this style suits u then this one is really good
(Not mine)
Its highly customizable
Well its kind of cartoony but ill take it at this point 
I did the step by step creation of that shader; it didnt look that good at all
@lavish oasis yeah it's stylized but you can make it more realistic, like this
But realism definitely was not the goal
nice nice
Ah tbh i dont want HDRP realism; just "good enough"
If i can get it to something like warcraft's water it would be pretty nice- quite like that kind of water style
god damn u werent lying π
kind of overwhelming
i love that it has buoyancy script
how do i get URP shader graph shader to respect the clipping planes of the camera? it draws the objects using the custom shader outside the clipping planes by default
Does anyone know why I might be getting this weird artifact in my skybox shader when the texture meets itself?
It stays there without changing at all, whatever I set the tiling X to. It's not there in the texture.
try changing the wrap mode on your image in the inspector
hmm, that didn't help. It was a 16000-pixel-wide texture so I knocked it down to 1600 but still no good. The lines move as you tilt the camera up and down.
Ok, I turned off "generate mip maps" for the texture and that seems to have fixed it!
This isn't gonna work right? I need the R, G and B from my color but the A from somewhere else?
Split your Color first, then you can give it each channel
Yeah, just thought it might be nice but actually it would be weird behaviour
how do i turn depth testing off?
ok
but wher
i saw that in a unity doc
but i dont know where to put it cuz i think there are 2 sub shader{} and a bunch of pass{}
Hard to tell, depends what u wanna do
Usually done before a pass or inside a pass
Try around
i wanna make the shader so i can see the gameobject even if it is inside another or behind another
What pipeline are u using
If the standard ones try setting it to always, and play around with renderqueue values
You want to make sure your shader is always rendered on top of any geometry
urp
Yeah, it might be that it works but renderq value is 2 low
Relative to other geometries
Try changing the q value
how
Tags {βQueueβ = βGeometryβ}
Write this
Somewhere
Geometry tag means renderq value of 2000
Then change it around like
Tags {βQueueβ = βGeometry+100}
And see if something changes
Try different values
In the link i linked u can see different tags u can use instead of geometry
Gotta go now good luck
ok thanks bye
hi, how can i make transition between two keys(colors) with a gradient in shader/vfx graph
@grand jolt what exactly do you mean? A lerp?
^no just the gradient node. i dont get it. if i create a new gradient, then the transitions are made, but if i take an existing one, theres no transition when i add a key(color)
I don't understand haha you can add a gradient and then you can click on it and in the little editor you can add/move up to 8 colors right?
in the picture you can see that between orange and red there is no transition
@grand jolt click on the yellow color and lower the intensity
Then it will be more gradual
@devout quarry yeah that does it, thnks for the help!
does anyone here knows a way to convert "Amplify Shader Editor" shader to "shader graph" shader?
or any shader to "shader graph"..?
@trail geyser convert it node by node manually
as far as I understand the data of a fragment is the result, is there a way to define custom data at each vertex and custom interpolation?
like an int or a custom struct or smtng
or is there a way to access the data of each individual vertex that a fragments data is from and write a custom method to determine the dragments data based on those vertices?
well I already know we can manually do that and custom function nodes and the internet says such conversion cannot be done
but idk.. imo if anything can be encrypted it can also be decrypted right? I kinda want to prove them wrong π
question, can u disable a custom pass effect through code
i cant find any documentation
how can i access the enabled box there
encrypted and decrypted?
I had read a bit about encoding data into a float but once interpolated wouldnt the data just be garbage?
I used it as a metaphor.. when you use shader graph, it just creates a "regular" shader file so why can't we convert it back
Why can't you turn a car into a block of steel and other various raw components? It's a one-way process.
unblend a smoothie
ayt
actually Grant Sanderson has a nice video about the fourier transform, where he makes this analogy.
In a way, that's what the algorithm does
well this is also how shader graph works itself whenever you open a compatible file
that could be a good idea for an asset π
Really? I mean, can you open a regular shader, and it will backwards engineer it to build the graph?
no
I mean, I've seen the shadergraph files, and those seem to just hold the concrete data for the graph
What'd you mean then? about how the shader graph works itself
just that it takes a file with some data and knows what to show in the editor lol
so why can't we take a shader and create this json like(?) block of data
oh lol, I just noticed that your conversation here was exactly about how that's not possible
it'll require a really fancy algorithm tho π
I guess... It's just that regular shaders aren't necessarily build in this functional style, where you just have a pipeline of operations that feed into each other
I imagine a lot of it is not directly translatable
yea I also think its too complicated.. but maybe with a very small and basic it can be done
Anyway, if I'm providing an instanced shader with uv data from a compute buffer, how would I do that for different sides of a cube?
would I just have 6 uvs per instance, and use the vertex position to map them in the shader?
Sorry if this is a stupid question, this is kinda new territory for me...
like what I'm doing now is just provide a uv offset, and add that to the uv in the shader. but this obviously draws the same texture on all 6 sides of the cube
lol it's kinda new to me too.. that's why I asked here π because I don't know that much about shaders..
I have a "Amplify Shader Editor" shader file that I thought maybe there's a way to convert it from one "editor system" to another because I'm too lazy to do that manually π
Maybe research "unity procedural geometry" and "draw procedural" with the variants. There's tons of ways to generate geometry and associated data like UV's. But there's no one-way.
For a cube, you have 24 verts, each with data. Color, UV's, position, whatever.
@mossy viper
Right. I have this voxel renderer, and what I did before was generate meshes procedurally, and I would just do the uvs for each quad based on face normal, and add them to the mesh.
I'm trying to achieve the same using indirect instancing, but I can't really wrap my head around how to map the uvs from the buffer. Like, i suppose I could pass it uv data for all 24 vertices, but I'm still not sure how I would map those.
I guess my problem is that data is retrieved per instance, but has to be applied per vertex.
What I'm trying now is passing 6 UV offsets per instance, and somehow use the vertex normals to figure out which of the 6 offsets each vertex should use
Like for any face with uvs (0,0) to (1,1) the actual uv should be offset+uv*tilesize
God I'm so terrible at explaining this...
I guess what I'm asking is, for any given vertex, how to i figure out which side it belongs to so I can map it to one of the 6 uv offsets?
There's an instance ID and a vertex ID that you can grab. Somehow. I haven't done it in a while but you can find examples on the net and IIRC in the unity docs.
Like SV_VertexID or something.
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics
I wouldn't do maths in the shader that you can pre-calc once in the mesh, so I'm not sure why you need to store offsets since if you can store that you can store the actual value? But IDK, whatever blows your hair back works for me. π
well it is the actual value. just only for the lower left corner of each quad. idk... just figured that it'd be better to pass 6 coordinates per instance rather than 24. But I don't know, it might be better to just pass it a huge-ass buffer and apply using the vertexId. Again, I'm not very experienced with shaders
And I'm not really doing anything "once in the mesh" since I'm sort of bound to a single mesh. I don't think I understand what you're suggesting the alternative is?
is there a way for me to make my shader only render in the scene view without the use of an external script? similar to the source engine tool textures.
using the UNITY_EDITOR directive does not seem to work
IDK, I'm not really sure what you're doing. But I'm nearly-certain that you'll work it out. You sound like you're on the right general track and are just absorbing learning curve. I'd suggest researching some videos or tuts on the topic.
But in the end, however you do it, it will probably work out OK. π
It's a lot to work through in a discord chat.
But what you end up getting is an instanceID and for each instance, you get counts through the vertexID for your mesh. That's passed to you by the runtime.
What you do what that information, and how you crank it, is up to you.
That's a C# directive, and it's for if you're in a build, or running in the editor.
So to your base question, IDK, but IDK why you'd want to shade it differently. Have you seed OnGUI functions and such for editor mode?
I intend to use it for stuff that only needs to be seen in the editor, such as triggers and things that need to obstruct light but not be visible in the game. While I know that UNITY_EDITOR is a C# directive, I gave it shot anyways. is there an equivalent or a method to know in the shader if the rendering is happening in the scene view or not?
Not that I know of, but why?
The shader is rendering the triangles/verts. So if you want something in the editor-side to look different, try something like OnGUI and call your own shader on the object to RE-render over top of it or something.
Like...I had some stuff that I render only in the edtior but it's with a game object and OnGUI type of thing. A place holder so I could see where a ray tracer would render a procedural item in pay mode.
https://docs.unity3d.com/Manual/GUIScriptingGuide.html
hello guys, I wanted to ask about something ... So I got an idea of making a player invisible by setting the transparent to zero and the rendering mode to Fade it's working but the problem is that the shadow is not showing anymore because he is invisible, So what if I wanted to make him invisible while his shadow is showing at the same time? How to do it?
how do i turn depth testing off
Hello I can't figure out how to make secondary lights cast shadows in my toon shader, is there a way to do that?
currently my secondary light doesn't stop when object are in the way
idk how to solve that
Light and shader are two different things. I guess you want your shader to stop at that wall, right?
yep
There are some tutorials, even old ones and not super good, but should get you get started on youtube about that sphere effect.
https://www.youtube.com/watch?v=NiOGWZXBg4Y like that or similar
Let's learn how to make an awesome force field with Unity Shader Graph!
β Check out Skillshare! http://skl.sh/brackeys15
β Support us on Patreon: https://www.patreon.com/brackeys
β Project Files: https://github.com/Brackeys/Force-Field
β Water Shader shown in intro: https://youtu.be/jBmBb-je4Lg
β Setting up Lightweight: https://bit.ly/2W0AY...
okay thanks
but wait I did this tutorial for the bubble in the middle, but the blue circle around it is the light area
it's a point light
Oh, but its a volumetric point light, right?
okay, no forget volumetric, I was guessing. So, can you show only the light without shader?
And if you set the light next to a wall, it goes through?
guys, does anyone know how to achieve it?
it looks good without my toon shader
MeshRenderer->Cast Shadows->Shadows Only
You are not casting shadows at all with that light, right?
Nope
Then it will go through
you need your shader to recieve shadows and your light to cast one, otherwise it wont know where to have light and where not
I didn't found how to have my shader receive shadows from secondary light
and my light
I guess you cant use point lights here to use shadows...
yea, so idk what to do
Use a spotlight for example
It sucks unity does not support shadows for pointlight still... but thats what Unity gives us
not supported either
x)
URP v11 has point light shadows, you'd need to update to Unity 2021.1. https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@11.0/manual/whats-new/urp-whats-new.html
oh okay
Thank god, there is still hope. But 2021 is still beta/alpha?
is it easy change version for a project
thanks man, its working! but what if i wanted to be able to make him visible a bit like he is invisible and his shadows is showing but something whatever it is happened to him and caused him to be visible but not visible very much i mean little bit of visibility like he is fading you know what i am saying?
Then you would go for not shadows only and switch transparency, nothing a script cant handle I guess
2021.1 has been released
Oh really? Dang, all those old projects keep me in 2019, barely 2020 π thanks π
you mean to switch cast shadows to on and then control the transparency right?
Yep
Usually, though it depends if you're using other assets and stuff. It's always a good idea to have a backup just in case the update goes wrong. You just need to install the newer Unity version (e.g. from Unity Hub) and open the project using the newer one. Then can check the Package Manager to make sure URP is also updated (might do it automatically)
to backup I just have to copy & paste the whole folder somewhere right ?
Or use something like github
I'm gonna try to update then π
So I did the update and launched the project, it put me in safe mode and these are the errors
are these important ?
I guess you need to update your packages too to the 2021 supported
i'll try to search how to do that
it worked
noice
now I got shadows yey
now if i want the shader to have like differents intensity based on how far we are from the point light, is it done with a ramp texture?
Hey folks, I'm kinda of hitting a wall with Shader Graph and am wondering if people have recommendations or thoughts on how to get an effect that would look something like these old "colorgraph" postcards:
https://upload.wikimedia.org/wikipedia/commons/8/86/Crescent_Beach_station_1910_postcard.jpg
mostly, I'm looking to create a slight color offset and a semi-faded/dusty look to the imagery.
I guess a simple shader that adds that affect might work or better use post processing maybe
how would you create a shader that adds that effect, or post-processing for that matter?
sorry I should've prefaced that I'm still trying to wrap my head around how I'd translate this into shader graph from something like Blender
Really depends, using a shader like this for every material might be a performance hit, you gotta test it. How to use postprocessing, you should look into some tutorials first and come back when you tried something π at least I got no time to test it out for you, sorry. maybe someone else already tried that
Cool, thanks! I'll try to go look at some post-processing tutorials... any good recommendations for getting started?
I was using a really cheap method of doing this using an overlaid plane with a rendered out orthographic image, that that would be really time consuming to recreate across all my models and might be really inconsistent since I have to place them entirely by hand.
if I wanted to make a shader that effected a heightmap, like say an erosion system that treats raindrops as particles that fall and change the height in my texture...
A. is that possible
B. where should i start exactly?
could it be done in a compute shader? or should i use a particle shader, I'm not too strong at shaders but just a point in the right direction and I can figure it out
@simple rivet I saw this done recently, here https://youtu.be/eaXk97ujbPQ
In this coding adventure I attempt to implement a simulation of hydraulic erosion to make a procedural terrain look more natural.
If you're enjoying these videos and would like to support me in creating more of them, I have a patreon page here: https://www.patreon.com/SebastianLague
Interactive demo: https://sebastian.itch.io/hydraulic-erosion...
new question, in hlsl can you call a function inside of a struct?
Can anybody help me with shader striping?
Currently creating a build takes over an hour with all the shader variants included(which is not needed)
I have a shader variant file containing the required shader on a per scene basis (which is really small compared to what's ending up in the build)
Is there a way to strip all the other shaders?
following up (in a way) with my above questions, does anyone have a good resource/tutorial for learning how to write custom HDRP post-processing?
This asset can strip all shader variants not included in a variant collection
https://github.com/SixWays/UnityShaderStripper
Maybe this is a question for #archived-hdrp
Thanks @gray elm I did check the documentation, but this doesn't walk through writing your own Custom Full Screen Passes, it just shows how to create an already existing effect...
Is the Shader Code the same here as it would be for HDRP?
when you say pass, do you mean a render pass? https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@12.0/manual/Custom-Pass-Scripting.html
ah ok, yeah this is helpful, thanks!
no problem
When you search for the documentation on google, for some reason it always shows the HDRP 6.9.2 documentation. Make sure to change it to the latest version otherwise you'll miss stuff.
Yeah thanks... however, when I'm trying to just walk through this initial tutorial, I'm getting an error that my property isn't being recognized
When using the High Definition Render Pipeline (HDRP) we can use a custom pass to change materials on scene geometry, change the draw order in which objects being are rendered, and read camera buffers to use in our shaders. In this video, we'll take a look at how we can build a Custom Pass in Unity and use it to manipulate our scene.
π Learn mo...
ooh, look into Blit, itβs a technique that allows you to apply shaders to the screen image
there are some render features you can find online that make it really easy
search up blit render feature urp
Blit doesn't work with HDRP... I was using that before, and I might go back to it since I'm getting an error trying to use HDRP, but the post-processing stack for HDRP isn't compatible or overrides the blit info... I think...?
oh whoops wasnβt aware you were using hdrp
@crystal ocean does this help? https://github.com/keijiro/HdrpBlitter
oops i was too late
oh thanks, this is helpful
thanks to both @devout quarry and @brittle owl
Though I'm seeing that I can maybe accomplish the effect that I'm going for using HDRP if I was able to get the basic scripting to respond the way it's written... feel like I'm missing something essential and not seeing it right away
does any one have an idea on how they made these clouds in sky ?
just looks like meshes and textures to me
yea but they look so soft... also there moving so i guess theyre using some sort of displacement
i think the softness is just the normal map, i donβt see any transparency
maybe subsurface scattering?
that could be the case but its running on switch and i doubt that the switch has the grafics power for sss
well it can be faked
maybe with custom normals
(also runs on mobile itβs very impressive)
Weβve been working on a project targeting the Oculus Quest, which comes with some tricky constraints. The device is essentially a beefy Android phone, but must render a 2880 Γ 1600 display at 72fps. Compared to a standard 1080p/30fps console game, thatβs a factor of 5.3x more pixels that must be sha
Making a Subsurface Scattering Foliage Shader in Unity, without using Raytracing.
You can read a more detailed write-up of this approach here:
https://www.patreon.com/posts/subsurface-write-20905461
If you'd like access to the source files (shaders and Unity Project) that you can freely use in your own games, please consider supporting me on P...
so this is a test with custom normals
not optimal but i think thats the way to go...
I will try sss at some point tho
not only a normal map, you should also try an albedo texture
but i think sss is the way to go
Does the Custom Pass Volume not work with Custom Shaders? I don't understand why when I try to use the filter and designate specific layers it still renders the entirety of the camera view... (and no I'm not using a FullScreen Pass)
are the new urp 12 features exclusive to the unity beta version?
for some reason all my graphs are broken after updating to urp 12 and the newest unity beta
shadergraph is installed in package manager
wait what?
i cant create graphs
@brittle owl I had the same thing once :/ did not find a fix then
oh i just uninstalled and reinstalled urp from package manager
Oh haha that's good
Hello I have a toon Shader and I want to use the Paint texture tool on my terrain but nothing happen, it is possible ?
Its me again...
Which shader do I use for materials for the trail renderer in hdrp ? At the moment Im just using the unlit shader but it doesnt copy the colors I set in the trail renderer.
Using this image as an example. I am very new to shaders and am struggling to figure out how to do this. But, is there a way to make the overlapping transparent shaders not overlap like that and become darker? Instead its always the same shade?
My project is in Unity 2020, using the URP. Everytime I think I find the solution, its for a non urp object
@latent cryptresearch "unity shader stencil"
You'll just set the stencil value where the squares are, and then in another pass (maybe post processing) you can do whatever you want where the stencil is set.
Thanks appreciated, will look this up!
If there's anyone @here who might be able to sit down with me to chat about this issue I'm having trying to get HDRP to recognize my layers and prevent things from completely melting my CPU, I'd really appreciate it.
hdrp is melting any cpu i think. its like with blender: if you put a wrong value onto some parameter, it can crash your kernel. i have a lot of bugz with rendertextures since i switched to hdrp 2021. i always have to change some camera value in playmode, because the camera wont sample the image to the texture. you could downgrade, maybe it will help
So should I just try to return back to something more simple like the Blit method described above?
may it be that your lightning settings interfere with your custom render passes? or your computer is just not suited?
you can use the frame debugger, profiler and log files to find out whats wasting resources
I was thinking about that too that there's something in the experimentation of what I was trying to implement that made things go wild, I'm going to try and strip things down and see if I can get back to a place where things aren't coming a screeching halt
I think part of the problem is that I was trying to use custom shaders as the base and the override for the custom pass, which when I substituted out helped performance considerably.
However, now I'm getting this strange z-fighting issue when I'm using the Custom Pass Volume:
(I want the red to override the white texture)
it actually looks kinda cool lol
Indeed, but not my desired visual design...
Are you overlaying materials?
Of course, ideally, you'd draw it once, red (or whatever color should be in a pixel) the first time. Once.
But doesn't the Custom Pass Volume override existing materials? I'm following this example:
https://www.youtube.com/watch?v=vBqSSXjQvCo&ab_channel=Unity
When using the High Definition Render Pipeline (HDRP) we can use a custom pass to change materials on scene geometry, change the draw order in which objects being are rendered, and read camera buffers to use in our shaders. In this video, we'll take a look at how we can build a Custom Pass in Unity and use it to manipulate our scene.
π Learn mo...
hey weird question, how would i fake normal maps in an unlit graph?
dont really wanna use lit
"We can use a custom pass to change materials in our scene" is a direct quote from the above demo
Man, shaders are still pretty much beyond my capablities π¦ Spent a couple hours on trying to make a snow trail displacement effect for a snowboarding game...
Just not predictable at all on what's happening. Sometimes the camera doesn't pick it up at all, other times it does, but way off point of where the cube is, etc.
is there any way to get semi realistic reflections on urp for free? planar reflections, box projection, ssr, etc?
iβve been looking at github repos but most are outdated
What would be the best way to apply the same shader effect to all children in a UI image object?
Say I have a "burn up" shader, just applying that to all children makes them all dissintegrate differently since they are all different size. Any way to make them all match?
how do i turn depth testing off
Hey folks, I'm encountering a very puzzling situation with Shader Graph.
I have a shader graph like this:
From every sources online that I can verify, this is what you have to set up to replicate a basic PBR pass.
(Pay no attention to the Dissolve, EdgeWidth and EdgeColor properties for the purpose of this question)
Now, I'm testing this shader out with this 3D model: https://www.turbosquid.com/3d-models/3d-scifi-container-game-free-model-1755450
I first created a Universal Render Pipeline/Lit material without assigning ambient occlusion as a reference (because my shader doesn't take in an AO texture either), and the result looks like this:
Then I created a material using my shader above, assigned all the same Albedo, Normal and Metallic textures, then swapped into the same mesh, and this is how it looks:
What am I doing wrong here?
is your normal map input marked as a normal?
I'm using Unity 2019.4.28f, VFX Graph 7.6.0
the type on the sampler needs to be set appropriately
Oh, this fixed the issue with that model, but created an issue for another model.
This is what happens when my shader doesn't have a metallic texture.
The reference material looks like it can render to this without a metallic texture.
Is it the Default or the Mode?
mode
any good reference to port Cg language to shadergraph?
I try to port this shader:
but get this weird result:
There is not real reference here, take the code and redo the same logic with nodes.
Obviously, if the result is not the same, it means that the calculation is different and something is wrong.
Now it's up to you to figure that out.
Hey, I have a question about Shader node's precision inheritance.
I have 2 nodes set up like this.
So the inheritance rule says the output of a node is the max precision of all input nodes, but when the input nodes are manual input like this, what precision will they have?
I have a sprite sheet to run in a shader. Basically I'm doing this:
half spriteSize = 8.0; half vel = 80.0; half2 animTex = input.texcoord * 1.0 / half2(spriteSize, 1.0); animTex.x += floor(fmod(_Time.x * vel, spriteSize)) / spriteSize; vertData.uv = animTex;
in the vertex shader
however, it's cutting the two last sprites
can someone check if my maths is correct?
it's an image with 8 sprites
https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Precision-Modes.html all u need should be here
are all the pictures in the sheet the same size?
yes
to help understanding, vel 80 means one frame every 0.1s;
that's what the fmod goes for
fmod makes sure it cycles through the sprites and floor makes sure it goes one by one instead of just sliding
here is a video showing how it is behaving, skipping 2 frames each cycle of 8 frames
the shader is for the grass, just to make it clear
are u using a flipbook node or?
actually, just the normal texture
if u are not then I would recommend looking into it, https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Flipbook-Node.html. It's basicaslly does the sheet math for you in a shader graph
i cant see what would be incorrect in your code
should work
i think
can use this without shadergraph?
nah
I can't use shader graph, too complex
I'll see what I can do then
thanks for the tips
The math seems correct to me π€
I seriously don't know why it's wrong
texture is this one
it's a proper texture
I'd recommand that you try debugging it on a simpler object (a quad), and try to output readable values
Any reason to not use shadergraph if you're targeting URP then ?
because I'm editing the terrain detail from urp, so I'm just changing the color and uv, as well as removing waving and wind
Ok, makes sense
but when I change the uv there, it's going wrong somehow
it's the same if I change the uv in fragment shader as well
tried that already
Maybe (not sure here) the UVs are wrong from the begining ?
In object space, the normal values can go from -1 to 1
hm
I'm trying to sample a normal map using the triplanar node
and I can't seem to get remotely functional normals out of it
Note that the triplanar node has a mode to swith to normal sampling.
It will only accept a tangent space normal map
And will output tangent space normals
ok, so I should be able to feed worldspace normal in
and use the output as tangent space
the normal map is in tangent
yes
You could also use object space if you want the mapping to be independant of the object transform.
well I'm in an instanced shader
and in HDRP I can't rely on the Object space
because I can't override the UNITY_WORLD matrices
so I've gotta do those conversions myself
Does anybody know if there was ever a work around for render texture transparency on URP when using post processing? I'm on 2019.4.19f1
Currently it completely ignores the camera clearing and won't allow transparency unless PP is turned off repost from render pipelines
Hey guys, any idea what could be causing these particle squares? my material seems to be attached correctly, so why am I getting these?
All particles are squares by default. Attach a different shader/sprite
If u want the shape to change
Hello, is it possible to have my directionnal light shadow to be as good as the point light one, le point light is the one on the left, the dir is in front, ( idk where do I put this sorry )
there is a channel for lights #archived-lighting
also depends on what pipeline you are using
URP I have a toon shader
ok ty
I have a small city with several buildings all using a single large texture. My question is if it is possible to setup different normal maps for each building, but have them share the same texture?
of course - they just need to use different materials
So I've made some progress on my shader, but I'm wondering how I can get a bit of a Chromatic Abberation effect to "offset" the color slightly off the model:
Kinda like this:
but keep the RGB channels uniform
In the pbr graph theres an option for opaque shaders to have alpha blending. How do I achieve that in URP lit shader graph?
Hello, its my first time using shader graph. I am trying to do pixel outline effect following a youtube tutorial. But I am getting an extra inline effect from opposite side. I cant figure out why, can anyone help?
What do I attatch it to? there seems to be no slot for that particle specifically?
Hrmm... I'll do some research into that, thanks very much!
shouldn't you pass the UV into both sample nodes
oh nevermind
ignore me
you are using the uv0 channel
do you only want the white parts?
yea
I guess the extra "inline" is from the subtract operation returning negative values => the black pixels
Add a "saturate" node after subtract to fix it.
I actually found a fix but it feels like a trick more than a fix. I am multiplying the result of subtract operation with a A channel to remove them
Thanks that feels like a better fix
anyone @here have thoughts on my above question about a uniform chromatic aberration effect?
By uniform, you mean having a "smooth color shift" on the side of your object ?
Usually chromatic abheration is done in post process, if you want to do it on the object, the best you could do I guess is you "shift" the albedo color or something like that, it is hardly possible to do it with the final lit color.
Yes, I mean "smooth" on the side of the object, and yeah I'm trying to accomplish that using a post-processing effect using a custom pass.
I don't ... get the question ? You want to do a kind of distortion effect on a texture ?
I'm trying to create a material override within the URP
Oh, ok then. Well in context of a post process, it's as "simple" as sampling a lot of times the pixels where the object is, and add a color shift proportional to the UV offset.
Sorry I am total beginner at this, how can I make it so yellow pixels stay orange here?
Cool! How do I sample where the object is within shader graph?
Can you show your current setup of nodes ?
Well, in a post process, it samples the color buffer on the whole screen. To seperate your object you need to mask it in some whay.
Right, I'm doing that with a layer
Don't add. Use Max node instead for example.
So that the post-process is only effecting object(s) on that specific layer
Basically I've been able to implement the color/material override that I want, but can't understand how to execute the color shift within shader graph
Are you sure you're doing a post process ? A render feature is not a post process
(not forcefully)
thanks! I guess it was too basic to ask but idk where to look for answers, can you suggest me?
No, here is the good place to learn about shaders π
Well I guess I'm not doing a post-process since I'm using a Render Objects renderer feature
ah alright, normally I can find answers with google search so I am confused haha
But I don't know how the URP handles material overrides using custom passes
either way wouldn't the material override in the Renderer Feature still be able to execute a color shift using a material override?
Yep, so, not a post process, and hardly possible to do.
You might be able to fake it if you set your material to transparent , draw in addition to the original object and use the "sample scene color" node to make the effect.
Material override simply means "render the object with an other material"
OK, gotcha, so then how does the URP handle custom post-processes if not in the Renderer Features?
Is there documentation for writing your own custom post-processing volumes or features?
You can also make your own scripted renderer feature if you want
There's the API doc, but no example from what I know ? https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@10.5/api/UnityEngine.Rendering.Universal.ScriptableRendererFeature.html
anyone knows how to let the shadow change with the dissolve of this sphere for example? I'm using URP, lit shader graph, with transparent surface and alpha blend. All the tutorials I've seen used PBR graphs with opaque surface and alpha blend which I cant seem to get with the lit shader graph.
ugh... ok thanks I really appreciate it @amber saffron
Where's the documentation for that?
@regal stag did some blog post about it : https://cyangamedev.wordpress.com/2020/06/22/urp-post-processing/
You also need to use alpha cutout for shadows
I think you mismatched the different conversations π
But put simple, if you want to have a vector values that varies from pixel to pixel, you need to get it from somewhere, could it be UVs/Position/else.
You can then operate on it like you want.
So if you want to offset the texture, but offset goes from -1 to 1 in UV space, you need to take the UV (range 0 to 1), multiply by two, remove one, input as offset of the tiling/offset node.
If I'm using the Post-Processing stack in URP, can I single out specific objects to apply the effect to? The reason why I was using the material override is so that I can set the effect to specific layers
No, post processing is applied globally on the rendering.
Like I mentioned before, to isolate objects you'll need some kind of fullscreen mask
Do you have a recommendation on how I could create something like that?
This will be a custom renderer feature I guess
What about using a camera overlay? too costly?
Now I'm a bit puzzled. The shader works fine if I play it in the material, but in the grass itself, it's cutting some frames.
you can see it works well in the material by the preview in the bottom right
any idea what I'm doing wrong?
Like, stacking cameras ? Maybe.
Yeah lemme give it a shot... I worry about performance but I can try to experiment
You could give a try to my solution with draw object renderer feature and transparent material.
How do I create a draw object renderer feature?
Like I mentioned, maybe bad UVs on the grass meshes itself ?
An other thing I have in mind : maybe the sampler used in the terrain detail doesn't loop on the texture, and so you're seeing the empty pixels repeated outsive of the uv space ?
Try applying a uv.x = frac(uv.x) before sampling ?
I have 2 shadergraphs and a material for each. How can I show 2 effects at the same time on one object?
Sorry, wrong name "render object renderer feature"
ok, gonna try
Hum, ok ... I really don't get what you issue what and what you're doing, but if you're happy with it ...
You don't. One object (or submesh) = one material = one shader.
half4 diffuseAlpha = SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_MainTex, sampler_MainTex));
this is the sampler, gonna try what you suggested
is combining contents of shadergraph a good solution? Or is there any other solutions?
Yes, fusing shaders is the solution. Else, you need to draw the object multiple times, with a blending mode to overlay them
soo you end up with really huge shadergraph if you want multiple effects?
Sooo, you want to sample a texture with an offset going back and forth between -1 and 1 for example ?
just trying to understand if thats common π
yep
thanks!
You can use subgraphs if it makes it more easy to read though
lemme take a look at them
Is there a way to access Shader Graph Master Node settings in script ?
tried frac and repeat_sampler, but no changes
I want to enable Two Side option from script to be exact.
no
This is what I was doing before, but how can I render a transparent object on top of the existing object?
In HDRP at least you can change it on the material. AFAIK it will come in URP
So what you're saying is create a secondary transparent object that only get rendered in the ForwardRenderer Data?
Change the queue of the renderer feature
To transparent?
yes
I'm out of options π€
me too... if I use the same code in another shader, it works fine, but when I add to the grass shader with surface, it breaks
I don't understand what that really accomplishes? When I do that it removes the material I was using as the initial overlay
I'm not 100% sure, but I think the material/shader needs to be transparent also.
Yeah, it already was...
Was the material override just remove when you changed the queue mode ?
again, it's doing all the things I want, just don't know how to get that "offset" look
no it remained there but became invisible
Oh, sorry, that's my fault, the queue here is for filtering, not when to render
Right, yeah I was a bit perplexed by that...
So, maybe the easiest to do is to use a fresnel node to control a color shift ?
Or something like that.
yeah but how do I get it to shift off the model?
"off" ?
yes, like a chromatic aberration effect:
If you want it like this, you just have to offset the vertex position.
But you said you want something more smooth, like a "real" post process chromatic aberration. But this requires sampling the color buffer. It can be done in an object pixel shader, but to shift off the model, without also shifting the rest of the scene, you have to mask out the model ... and wo get to the same point, of masking it.
Note that you might be able to use the stencil buffer to make this mask π€
does anyone know how given an object space normal and a tangent space normal how I can calculate what the new object space normal should be after applying the tangent
Done:
THATS ALL I WANTED TO DO!
just offset the vertex position, but didn't know what it was called or how I wanted to reference it.
Like, if you overlay them ?
Thanks so much @amber saffron for talking this out with me, I really appreciate it!
Wasn't obvious at all when you explained it first π
I know, I'm bad at explaining, so sorry! Using terminology from fine arts and not good at using vocab from Unity π
I'm having some weird issues with my normals if I assign via tangent space. They look right if in the fragment shader I don't assign anything to them at all, but when I sample the normal map and apply the tangent normal from it I'm getting weird behavior
I don't get that part
but when I sample the normal map and apply the tangent normal
tangent map when the normal is used to color each fragment
Can you show the nodes setup ?
that above screenshot was with tangent normal of 0 0 1
hardcoded
this is what it looks like when I do use the normal map as both the tangent normal and the color
I get those weird faces where the normals are incorrect
If you sample a normal map, set the sample type to "normal"
fucking hell
Also set the texture to normal map in the texture importer
@amber saffron ty!
I'm a little annoyed that it was such a simple thing lol
but also glad that I don't need to attempt to fix my other math
Why don't you use the chromatic aberration post processing?
Because I don't want to separate the color channels, I want to keep them uniform
when writing a shader for UI Images, how do i do rect clipping? Right now my shader isnt working with masking
or do i just write with builtin?
Hello everyone, I'm very new to Shaders, I'm trying to work with stencils and I ran into a weird situation, I'm hoping that someone can point me to the right direction:
{
Ref 0
Comp Equal
Pass Keep
}``` Passes, but
```Stencil
{
Ref 1
Comp Less
Pass Keep
}``` Does not pass
Am I missunderstanding how Stencils work?
I'm trying to make a shader that will make shadows on the material dithered.
This is what I have so far:
This looks like hot garbage. I'm quite new to shaders, so if anyone has any tips, I would greatly appreciate it.
well i mean, it is dithered
i think its too small though right
oh yeah im having a problem with urp's ssao render feature
ive created an unlit graph and i wanted to have ssao so i used the _SSAO_OcclusionTexture3 to get the ssao texture, but in game it looks like this:
up close you can clearly see the faces of the object, and far away it looks like its dithered
using a normal lit shader, you can sorta see the faces, so i guess thats not a big problem
but from far you dont see the weird dithering effect as the unlit one
i asked this in the lighting forum but maybe it wasnt the right place, i have some night lighting which looks good using spot lights and a stacklit shader, it also looks good with area lights and a lit shader, but both are very expensive for performance, and i'm not sure WHY it happens, do i'm not sure how to fake it. my camera is static
thats how it looks stacklit or area lights, pretty much the same for both
spotlights and lit
you cant see the 'wet patches'
how is lighting from normal maps calculated? i need to recreate it in an unlit shadergraph
Hi fellas, can I ask a quick question about execution order in shadergraph shaders?
I got a scene with 3 shaders I made in shader graph
one is a emmisive plane effect, distorts the mesh, looks nice
and the other 2 are transparent shades, 1 fro glass with refraction using opaque textures, and the other is a bubble effect that uses a reflection probe
if I move my glass and bubble objects in a normal scene where objects are using the normal URP shader, the transparent objects work correctly, they reflect and refract light as you would expect
if i use the transparent objects in a scene with my emmisive grid shader, they look as if nothing is there, no reflections, no refractions
my question is if there is a execution order for shaders that I can adjust so that my emissive grid shader renders first, so that the transparant effects can take it's output as an input???
how do i upload a struct in C# to a constant buffer in a shader?
I see in graphics / compute buffer that the data has to be in an array
I'm working on a water shader, but I'm having some issues regarding caustics
There is a render queue that decides whats rendered first. U can move around stuff in the q how u want. If u want to use output as input for another then simply connect the nodes in shader graph
Or set that in code
I'm trying to implement parallax movement (NOT parallax mapping) but there's a weird issue where the parallaxed plane zooms when I get closer
Another question: _WorldSpaceLightPos0 holds the info about the direction of the directional light and the position of the other light sources yadda yadda etc...
But what that does imply? Is the shader run multiple times for each light source in the scene?
depends on what type of shader you are talking about
A shader doesnt actually know the position of the light, it just cares about the direction of light coming in. So the name of that is not intuitive.
A shader is in most cases either applied to either a vertex or a pixel.
A shader calculates from what direction light is hitting the pixel/vertex then does the calculations to show the results.
So yes, every light hitting the pixel/vertex will be taken into the consideration as it needs the information from the light vectors to display to you
this is done on the gpu ofc
@slow bear
I already know that
That's not the point I'm making
Going by the docs, _WorldSpaceLightPos0 is a vec4 structured as (WorldSpacePosition, 0) if it's handling a directional light and (WorldSpacePosition, 1) if it's handling a point light
of course, since the actual position of a directional light doesn't make sense, in the directional light case the World Position is exactly the light direction
What I was wondering about though was: if the Alpha/W channel of _WorldSpaceLightPos0 can be either 0 or 1, what happens if I have a scene with a single point light and a directional light? What does a simple custom lit shader do in that case, is it run twice?
You can handle all light calculations in a single pass. Meaning that it's ran a single time
Just take in consideration the order in which you do the calculations
lemme write u a code example
is there any difference to cut alpha from texture2d arrays?
` half4 diffuseAlpha = SAMPLE_TEXTURE2D_ARRAY(_MainTex, sampler_MainTex, input.uv, _Index);
half3 diffuse = diffuseAlpha.rgb * input.color.rgb;
half alpha = diffuseAlpha.a;
AlphaDiscard(alpha, _Cutoff);
alpha *= input.color.a;`
Trying this, but it's just showing the color without cutting alpha. The texture is set to have alpha
SubShader
{
Pass
{
Tags {"LightMode"="ForwardBase"}
struct v2f
{
float2 uv : TEXCOORD0;
fixed4 diff : COLOR0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata_base v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.texcoord;
half3 worldNormal = UnityObjectToWorldNormal(v.normal);
//standard diffuse light here
half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
o.diff = nl * _LightColor0;
//ambient light calculations here
o.diff.rgb += ShadeSH9(half4(worldNormal,1));
return o;
}
```@slow bear
I commented when in the places where light is calculated
But they are included in a single pass
meaning the code doesn't need to be running twice
ofc you could also seperate it into different passes
it's up 2 u really
You still don't get what I'm saying, but maybe you got to the point
what's that ShadeSH9 function?
the point im trying to make is, you can decide how many times u run the shader depending on how u set it up with light
sorry if I came out as rude, it's just that I know already how to make custom lighting, NdotL, NdotV, that kind of thing you know?
I know how to handle Blinn-Phong, but the shader reacts only to the main light in the scene; I want to make it so that it also reacts to point lights
it's a built in unity function computing light based on spherical harmonics
Maybe that's what I was looking for, if it computes shadows then it must also compute non-directional lights
I gotta get back to work now doe, hopefully u figure it out. If u dont i can maybe help u after work
Trying to displace the vertices by the value of the green on this texture. Have tried some approaches but it never really does what it is supposed to do. Any references or help is appreciated 
Solved it btw, I couldn't find the specific name of what I was looking for, but it's actually "Additional Lights"
Hi, I am working with veins right now. I am creating a normal map from a height map and I receive this effect. My texture is 512x512. What's the best I could do with this?
Yes you put the data into either an array, list, nativearray, or native list
Then you have to make sure that you set the stride and that the buffer is large enough
And then you can bind it to your material or shader
That class has some examples of wrapper functions that do those things for you
It's MIT licensed as well so you could just use it
Hi everyone, I've a question about performance: a shader with a lot of nodes that they dont be used into my material (i.e. i have a complete PBR shader but i use only 1 texture slot) has worst performace of a shader with only the nodes of the texture that i effectively use?
And keeping in mind this, i have better performance with 1 complex shader or with more simply and specific shaders? (i'm working on Oculus Quest1)
There is no definitive answer to this.
So, in the case of the PBR shader where you only use one texture slot : This doesn't change anything, as you may have noticed, a texture input has a default value : black/white/grey/bump. Those are small (4x4 or 8x8 px) textures that are assigned to the slot if nothing else is there. So even if you don't use the slot, the shader operations are still doing something.
Unless you add some keyword based branching that would really remove the code of the unused slots.
But this is similar as making different shaders
Second question : is it more performant to have multiple "more specific but smaller" shader or a single "generic but bigger" one ?
Once again, it depends. A single one can more easilly batch objects together, but will have more operations per pixels. Smaller one have less operations per pixels but don't batch together ...
It's not great, but my best answer is : try and profile.
That question doesn't really make any sense. What kind of shader, based on the standard lit, or what?
Odd, I can't seem to find the download for the Transparent-Diffuse shader for Unity 2020.3.12
Is it because it's a legacy shader maybe?
Thanks @amber saffron !
Hey, someone can help me? In Shader Graph, I want to go from a gradient noise (represented by the circle) and adjust it so it's like a trail. How can I achieve this effect using nodes?
Hey can anyone tell me why my transparency slider is not working
My materials alpha stays the same transparency
It's stays opaque ? You didn't set a blending mode.
Got it working, thanks very much sir π
question, how would i recreate normal mapping in an unlit shader graph?
i thought this would work but it doesnt :/
mine on the left, urp's lit shader on the right
lol I think so
oh wait, i think i managed to actually do it!
its mostly correct
only problem is the darker parts
And how do you add that with the other colors?
Oh I made it work
I figured out my shader issue. I just had to manually assign the render order of my objects when creating the materials, and make sure I passed it con when updating the material
Not a great fix for everything, but it works for my case
No custom shaders required, haha
Yep, you're almost there.
The main light direction vector is in world space, so you need to set the normal transform output to world space also.
And you don't need to remap the result of the dot product, eventually you can pass it through a saturate node.
And for the dark areas, well, this is kind of expected, at you're only applying a single main light, so the faces that are in the opposite directions are fully black.
You can multiply the result with the light color to ... well, use the light color π
If you want to include some ambiant lighting, there is an "ambiant" node if I'm not wrong, where you input the normal value and it output the ambiant light color. Add it to the previous result to have main+ambient.
Multiply this with your surface color, and you have a basic lamber shading π
awesome! thanks for such a detailed explanation
iβm making a black and white toon shader so i donβt think iβll need ambient lighting
Does anyone know if I can assign compute buffers to vfx graphs
And where any of this stuff might be documented
I know almost nothing about shaders, so bear with me a minute. I have a standard surface shader. All I did was create the shader and adjust the color. But when I adjust the alpha of that color in the inspector it doesn't change in the game window.
Is there a different shader I should be using or something I should change? I want to be able to adjust the opacity of this at runtime and its more difficult than I thought it might be.
is your rendertype set to transparent?
So I am trying to modify an outline shader (https://github.com/chrisnolet/QuickOutline). Right now, for some reason, the shader only outlines objects that have nothing (the skybox) behind them. I would like the outline shader to outline every object that has it (on every face). Maybe the screenshot will help you understand my goal. Is this even possible? Here are the two shaders that it uses: https://github.com/chrisnolet/QuickOutline/blob/master/QuickOutline/Resources/Shaders/OutlineFill.shader
https://github.com/chrisnolet/QuickOutline/blob/master/QuickOutline/Resources/Shaders/OutlineMask.shader
I am using Unity 2020.3 and URP.
@amber saffron not sure if you'd be able to help, but now im trying to get specular working with the normal map, i found this blinn-phong specular subgraph a while back but it only has an input for smoothness, nothing for a normal map
The RenderQueue is transparent/3000 in the material inspector
Yet the alpha change does nothing
I think you also need to add alpha to your pragma
and when I said rendertype I mean in the tags of your shader code
@white cypress The alpha:fade seems to have done it. Thanks!
@white cypress well maybe not. What might be causing this behavior? The flag pole and flag both have the standard shader with alpha:fade and rendertype transparent, no other changes.
try just alpha instead
Hey everyone, sorry for the noob question. I'm using URP but when I extract materials from my models they all have a blueish tint, it also happens when I try to create them using images from sites like Poliigon.
What shader to use when creating materials from texture images with normal maps and displacements etc. Can someone link me to a resource on how to creating high fidelity materials on URP?
how do i change the draw order of a particle system so that it renders on top of other gameobjects?
Hi team - when I have a collision, or have a raycast, to know when I hit a part of the object where the Shader Mask is on or off? Basically making a shield with holes using noise, and want projectiles to pass through where the noise mask is not on the object
Hello can someone help me with shader issue?
I imported some assets on the marketplace to my project; URP pipeline, but material still pink.
- Check if there is a URP package in the asset. If so, unpack it
- Edit -> Render PipeLine -> URP -> Upgrade all project materials to URP
That should fix it
I did the upgrade but the material still pink
did you try #2?
or rather
#1?
if not, you have to contact the asset producer
too many variables, they likely have a readme or faq or something.
that covers specific instructions
or they didn't pack the right materials
when you imported, you imported all the materials, etc?
make sure nothing is missed
Foliage material have the problem, other does not.
and try their demo scenes. if they work there but not in your regular project, that can help you trouble shoot
I did, and it result like above
