#archived-shaders
1 messages ยท Page 52 of 1
SDF textures could likely be a much better option than procedural noise
this isn't too bad either except too bright
I followed a tutorial on how to make stylized water the shader works very well but when I change my camera to the orthographic mode it doesn't render the foam. How can I fix that?
i think there is no depth buffer in orthographic, might be wrong
yeah i think there isnt, people have to make their own
I'm using the vertex/fragment shader functions to draw a texture, tinted by a color... (Unlit)
where the appdata is:
struct appdata_t {
float4 position : POSITION;
float2 uv_map : TEXCOORD0;
float3 normal_map : NORMAL;
};```
and `v2f` is:```cpp
struct v2f_t {
float4 position : SV_POSITION;
float2 uv_map : TEXCOORD0;
float3 normal_map : NORMAL;
};```
the issue I'm facing is the `normal_map` application... I'd like to be able to apply it to introduce finer details to the mesh...
however, I'm not sure how that's done, nor am I able to initialize it in the `vertex` shader.
```cpp
// NOTE: vertex shader
v2f_t vert(appdata_t mesh) {
float4 _position = UnityObjectToClipPos(mesh.position);
float2 _uv_map = TRANSFORM_TEX(mesh.uv_map, BaseTexture);
// TODO: figure out the cause of this error: cannot map expression to vs_4_0 instruction set
float3 _normal_map = UnpackNormal(tex2D(_NormalMap, mesh.uv_map));
v2f_t _result = { _position, _uv_map, _normal_map };
return _result
}``````cpp
// NOTE: fragment shader
float3 frag(v2f_t input) : SV_Target {
// TODO: learn how to apply the normal map to the end result
float3 _base_texture = tex2D(BaseTexture, input.uv_map);
float3 _display_result = (TintColor * _base_texture).rgb;
return _display_result;
}```
I hope the information provided conveyed my message to you,
please let me know if you need any further details, I'll try my best to elaborate.
in case you need a wider view beyond the current bounds:
https://paste.ofcode.org/UrTgR4MDghSpFjDEyeQ5Ei
please ignore all of the above messages of mine, it's all good now!
if you were even just thinking of helping me out, I really appreciate your efforts!
however, I no longer require any type of support for the issue I've had.
How can I fix that I am not really good at shaders
#๐โart-asset-workflow is more appropriate, and a Blender server/channel would be even more appropriate
okay, I will post it there. I thought that maybe somebody knows a way how to import the blender stuff on an alternate way.
any idea where i can get a voronoi tilable texture?
want to use it for my thuder storm and dash
are you working with shader graph? it has a voronoi node built in
I just learned that the procedural shapes can't be used in the vertex stage, is there any workaround there? ๐ค
Can replicate what they do, either in nodes or as a Custom Function. (can view code in docs. e.g. for Ellipse : https://docs.unity3d.com/Packages/com.unity.shadergraph@12.0/manual/Ellipse-Node.html)
But instead of /fwidth() use a Step / Smoothstep, or InverseLerp->Saturate.
this is the viewProjection from the last frame right? cam.previousViewProjectionMatrixSo this should give me the current viewProjectionMatrix right?: cam.projectionMatrix * cam.worldToCameraMatrix; So why am I getting here two completelly different results?cs float3 pos = _WorldSpaceCameraPos + viewVector * depth; // Current viewport position float4 viewPos = mul(_CameraViewProjection, float4(pos, 1)); // Hopfully Previous one float3 prevViewPos = mul(_PreviousCameraViewProjection, float4(pos, 1)); return i.uv.x < .5f ? viewPos.xyzx : prevViewPos.xyzx;
I am importing a shader from one of my old projects to a newer version and I got an error on the View Direction node - Unity View Behaviour node changed in 2021.2
I am trying to google it but I am not finding thge answer of what actually changed about it compared to whatever it was before
Is there a change log somewhere to read? Or should I go back through every variation of this page?
https://docs.unity3d.com/Packages/com.unity.shadergraph@12.0/manual/View-Direction-Node.html
Oh I see its normalized by default now
hey i have a noobie question.
I have a .cginc file that i include in my shader called rules.cginc by the code #include "rules.cginc"
is there is anyway I could just copy the rules/functions I want from rules and paste it into the .shader file and keep it all in 1 file ?
Yes, you could replace the #include line with the contents you need.
But include files tend to make shaders more organised, and lets you share code between multiple shaders. Having all code in a single shader file can sometimes be pretty long.
Not sure, but may need to use this function (on cam.projectionMatrix) : https://docs.unity3d.com/ScriptReference/GL.GetGPUProjectionMatrix.html
Thank you! , i'll be mindful of that โค๏ธ
uhm, hi, I'm scripting a compute shader
I want to multiply 2 arrays like they are 2 matrix
someone can explain me how to use mul()?
thanks
just put your data in two float3s and do mul(a, b)
note that the result of this will be a float3x3 aka 3x3 matrix
dataBuffer[id.x].temp.x = 0.005/(dataBuffer[i].pos.x - dataBuffer[id.x].pos.x);
dataBuffer[i].vel.x = mul(unios[id.x], dataBuffer[id.x].temp.x);
I'm getting a race condition error, I can't read and at the same and write on a single variable
Another guy told me to use memory barriers
I just want get that kind of operation
from this
to this
Is there a way to do that without specify the thread id and get the type of operation all in once I posted above my last message
What is the "terrain data generated in a C# script"? I mean, you pass ALL data to shaders from the CPU side somehow. You or the engine does.
So it depends on what the data "looks like". I mean, you can set it on a scalar float, a vector float/int. Or into a table (CBUFFER) or "compute buffer" (structured buffer)...or you can build the data into a texture.
Without more information it's hard to communicate methodology.
Given your first sentence, you could "just" set a gradient texture in the editor. But shader graph doesn't have a way to map a unity gradient that you get in the inspector to a shader dataset directly. What you usually do is create a high enough resolution texture to map all the pixels to that gradient...for example a 256x1 or 512x1 or whatever texture. And then in c# you compute the values for each pixel, set them on the texture, make sure to apply changes, and use THAT texture as input to your shader.
You'd then take max, min world-space Y value and map it to a 0-1 range and use that as the UV.x value to read the texture at a Y position pixel center....so float3 myRGBcolor = tex2D(myGradientTexture, float2(zeroOneHeight, 0.05));
Note that SG also has a gradient node that you can use that is "pure math" and doesn't require such a texture, and I'm 50/50 on its value as I find editing it all in the inspector and mapping to a texture to produce smaller code and more convenient tooling. Last I knew the gradient node's data wasn't exposed externally to the engine's inspector.
The problem with this approach is that it might introduce a dependent-texture-read, where one texture read is dependent upon the results of a previous texture read, and thus has to be deferred even more. That might not be all that bad though, as it wouldn't be shrouded in a huge conditional block, it's just that such things slow it all down a bit but performance may be acceptable. Whereas the "pure math" version of a gradient doesn't have such a dependency.
Then again, I'm thinking that the texture read of the height map would be in the vert() and the texture read for color per-pixel would be in the frag(), and that they'd be decoupled anyway. Unless you're doing something other than that.
And....he deletes the question after all that typing. lol. Oh well. I guess others can't benefit from the shared information either. For reference it was about setting color based on a gradient on the y-height results of a height-mapped set of "mountains" or some such terrain.
https://www.cyanilux.com/tutorials/depth/
I'm trying to learn more about what all these depth tests are/mean/how are used
I was reading this article by Cyan but I didnt find answers to specifically what those tests are or how they're used
What are you asking about specifically? It's all just never < == <= > != >= always in relation to whether it renders based on testing against the depth buffer
Oh I didnt realize that it was the math symbols, I thought it was.. I dont know what I thought it wqas
like macros for something else maybe ๐ค but if its just math that explains a lot

for more details
Why do you want to do the shadow casting manually?
If it's in order to simplify the shadow maybe use decals?
Ahh got it.
For mobile devices having another texture map might be subobtimal due to GPU bandwidth limits. But you could keep the size and resolution small in order for it to look sharp while not being that much of an issue.
Otherwise maybe use layers on the light to cull shadows and lighting etc? Not sure what the exact setup would be
that helped I think, but I have printed out the previous view projection matrix and figured out that it never changes doesn't matter how the camera is rotated or positioned it doesn't change, but my currentviewprojectionMatrix does whats going on here?
Maybe ask on the forums, I'm not too sure
I'm a bit slow, I guess, so spell it out for me. Because the Unity shadow caster pass will calculate all the shadows, but applying them can be selective.
You want the player to receive all shadows. So apply the shadow map results to the player.
You don't want the other game objects to receive shadows, so don't apply them.
You want ONLY the ground to receive shadows from the player (and only the player????) Unsure of this last part...does the ground get shadows from the other game objects sitting above it?
How many light sources do you have that cast shadows?
OK, so that makes it easier....you can apply the Unity shadow map to the ground. You don't have to be selective about it.
Okay is there any reason why my previousViewProjectionMatrix doesn't get the viewProjection from the last frame but only gets it from the first frame and then never updates??
OK, so the standard system will work for you except for the player's shadow issue.
So for everything else in the game, you can have all the other objects cast shadows but not receive them. Except the ground, which receives all shadows. Yes?
But the other game objects don't get shadows. The ground does. So that's the opposite.
There are only two things in the game that receive shadows....the ground and the player.
What I was thinking is that you'd have the player NOT cast a shadow into the shadowmap.
The only object that gets shadowed by the player is the ground.
So the ground would have to be smart about the player's shadow.
but everything else, like you say, could even be baked if the light pos is static.
And the player only gets shadowed by the baked shadows, that don't include itself.
So the only question is "How do I dynamically calculate a shadow cast for my player character on my ground (and ground only)?"
Shadows are expensive.
But yeah. Sec
I was contemplating a couple of things. Maybe ask in lighting though.
But I'm wondering if you can't have TWO lights.....One that's visible and another just for casting the player's shadow into a separate shadow map for the player's shadow.
They'd be in the same spot.
Now you have two maps.
And can selectively apply them.
The ground would apply both shadow maps. The player would apply only the one main shadow map. (so excludes itself) The other objects don't apply any shadow maps.
But IDK how to tell the shadow system to do that.
I mean, you only want the player to cast a shadow into the 2nd shadow map, not the first.
The other thought I had was to ray-cast the player shadow onto the ground object, like a decal or some such.
Is the player object a complex mesh?
Is it skinned/animated?
And you want a proper-shadow, not just a blob shadow
like with a projector
You want real shadows
And what happens when there's a wall bisecting the player's shadow? Does this happen? Is the shadow on both sides of the wall on the ground? (Does that make sense?)
No, uh, player standing outside in the sun, low wall by feet...so the shadow on the ground goes from feet to wall...stops doesn't show on wall...then shows on the OTHER side of the wall on the ground?
Yeah, but I think the only thing in the 2nd shadow map is the player's shadow. And it's the dynamic map, not a static baked map.
will duplicating the player's mesh work? like one only receive shadow, and one is hidden and only cast shadow?
Recieving shadows and blocking self shadows seems pretty hard. I've been stuck at trying to find a solution myself for a while now.
If you can use a decal for the player's projected shadow, you don't have a problem that I can understand.
You'd have static shadow maps for all the static stuff which excludes the player. And the player's decal works for the ground shadow of the player.
The player and the ground apply the baked shadow maps, which don't have the player in them.
It's more that I'm using 2.5D with quads and the angle of the self shadows don't render as correct as you want when you shift the camera around. Also point lighting creates a load of other issues.
The ground gets the additional decal.
I don't understand that sentence.
the ground RECEIVES the decal, which is the player's shadow.
No, the decal is the shadow. But IDK how you calc it to by animated/skinned/dynamic.
So we're back to "smart ground".
You'll have to either do a custom shadow map for the player's shadow cast (From the light's perspective to the ground's result).
or dynamically ray-cast to the light per pixel in the ground object's calcs, seeing if it intersects the player...kind of the other direction, but only intersect test against the player, as the static shadow map already knows about everything else.
The best solution I've kinda played around with, as far as using spriterenderers, is to render create two spriterenderer of my sprites: one sprite receives shadows, while the secondary sprite I disable its rendering, yet it still is able to cast its shadow. Requires some tinkering but that's probably the way to go about it.
Otherwise decals
decals + render texture could work ๐ค
Still sounds like you can do it with the standard system.
- The player shadows itself from baked shadow maps that don't include the player. The player casts a shadow into a dynamic real-time per-frame shadow map.
- The ground shadows itself from either A) both the baked and dynamic shadow maps or B) a totally dynamic shadow map that includes everything.
- the other objects ignore shadow maps entirely.
how can i preview shaders in gameview without running the play button ?
Ok I found a solution with the previousViewProjection by simply keeping track of the variable myself, but now for example I am getting weird jittering which shouldn't happen. This is my shader code```cs
float depth = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv));
float4 H = float4(i.uv.x * 2 - 1, (i.uv.y) * 2 - 1, depth, 1);
float4 D = mul(_CameraInvViewProjection, H);
float4 worldPos = D / D.w;
float4 currentPos = H;
float4 previousPos = mul(_PreviousCameraViewProjection, worldPos);
previousPos /= previousPos.w;
return i.uv.x < .5f ? currentPos : previousPos; ```
the left part is the currentviewProjection and the one on the right is the previous one, the right one should lag behind which it does I guess but it shouldn't jitter so hard why is it doing that?
this is _CameraInvViewProjectioncs _CameraInvViewProjection= Matrix4x4.Inverse(cam.projectionMatrix * cam.worldToCameraMatrix); and this is the previous one from the last frame it is simply calculated before the camera is moved rotated etc.```cs
_PreviousCameraViewProjection= cam.projectionMatrix * cam.worldToCameraMatrix;
need a little help as to why my skybox material is just making everything black?
it works on gameobjects but not the skybox
If they're calced at different times, and thus one is previous and the other is "current"....
why are the two calcs different? One is an inverse, the other isn't.
because I need the previous inversed and the current not inversed
I have logged them tho they seem fine and dandy, what doesn't seem fine and dandy is the jittering I can't explain
~~I have also tried an approach of storing the previous Depth Texture instead of doing some matrix mulitplication, to get that well previous position, that had the same jittery results tho```cs
float depth = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CurrentCameraDepthTexture, i.uv));
float preDepth = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_PreviousCameraDepthTexture, i.uv));
float4 preH = float4(i.uv.x * 2 - 1, (/1-/i.uv.y) * 2 - 1, preDepth, 1);
float4 H = float4(i.uv.x * 2 - 1, (/1-/i.uv.y) * 2 - 1, depth, 1);
return i.uv.x < .5f ? H: preH;
nevermind nevermind
please forget that
OK, but therein lies another possible point of...differences.
IDK why it would jitter. Just for "fun" humor me and show me the inversed version on the right. Apples to apples.
well you allready know this code```cs
float depth = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv));
float4 H = float4(i.uv.x * 2 - 1, (i.uv.y) * 2 - 1, depth, 1);
float4 D = mul(_CameraInvViewProjection, H);
float4 worldPos = D / D.w;
float4 currentPos = H;
float4 previousPos = mul(_PreviousCameraViewProjection, worldPos);
previousPos /= previousPos.w;
return i.uv.x < .5f ? currentPos : previousPos;
float2 velocity = (currentPos - previousPos) / _Speed;```and then on the c# side I am doing```cs
public static void PreUpdate(Vector3 pos)
{
previousViewProjection = cam.projectionMatrix * cam.worldToCameraMatrix;
}
private void OnRenderImage(RenderTexture src, RenderTexture dest)
{
cameraInvViewProjection = Matrix4x4.Inverse(cam.projectionMatrix * cam.worldToCameraMatrix);
PPMotionBlurMat.SetMatrix("_PreviousCameraViewProjection", previousViewProjection);
PPMotionBlurMat.SetMatrix("_CameraInvViewProjection", cameraInvViewProjection);
Graphics.Blit(src, dest, PPMotionBlurMat);
}```I would also like to note that cam is static and previousViewProjection is also a static variable
Well, I'm not going to duplicate your test environemnt.
As for what you're doing, I'm picking up in the middle, so it's hard to tell. But if your object positions are static, and it's just the camera moving, you're attempting to calc the "motion vector" between frames with a moving camera.
I'd suggest checking into Unity's skinned mesh renderer code, and motion vectors. They account for camera motion as well as object motion. But they only do it on skinned meshes I guess.
They do pass the previous frame object transform, which if your stuff is all static you may not need.
okay where can I find that?
oh and also you might have missunderstood me the camera is not static in the scene, I meant the reference to the camera component is static, and that the previousViewProjection is also a static variable
I get that the camera is moving.
Where to find it is...hard. It's in the source code, but it's not documented very well, from what I understand (not my area, really, but a recent post was discussing all this too).
https://discord.com/channels/489222168727519232/1124246409399504926
There's the shader source:
https://unity.com/releases/editor/archive
And I suppose the SRP github repositories.
Hi everyone
I'm using hdrp custom pass
The problem I'm having is when i have many passes
the last pass overwrites the one before it
This fully depends on how you passes are setup
In shader code or custom pass script?
mostly for the custom pass I think (so more a #archived-hdrp question)
hmm alright
so I have done a little bit of testing and now what I did is to simply pass over the previous camera position and the current camera position and then get the difference of it to get my velocity vector, so I then outputed that velocity vector and when going in a certain direction it jitteres
its literally just this ```cs
float3 pos = _CurrentWorldSpaceCameraPos;
float3 prevPos = _PreviousWorldSpaceCameraPos;
float3 velocity = (pos - prevPos) / _Speed;
return velocity.xyzx;
and I have switched up my movement code to just this and its still doing the funky thing```cs
transform.position += Vector3.forward * Time.deltaTime;
Hey everyone, I've been trying to make a shader that displays a straight line going through a mesh (basically around the edges of the mesh), but I can't seem to get the intended result. Can any shader magician here suggest an approach I could use? I'd really appreciate it.
The attached image is the current shader I have, which is an intersection shader on a plane that is intersecting with a cube (this is pretty much the intended look, but this shader has many issues like changing line width depending on the point of view of the player due to the plane, so it's unusable)
Not sure to understand.
Do you want to have a line that is straight whatever the angle of view ?
Or is the issue more about the thickness and the gradient ?
As you can see here, when i look from above the line changes in width and I need it to stay uniform
For the line/plane intersection, I guess you are using something like dot(position, normal) + offset, giving you a signed distance field ?
Oh, or maybe you are using an actual plane and an intersection detection based on depth ?
For the former, the usual solution is to divide the depth difference by the view direction Y. For an horizontal plane.
For any plane, it by the result of dot(view direction, normal) I'd think
Im using the screen position and scene depth nodes in the shader graph
This shader is causing more issues like intersecting with other unwanted objects (if I make the plane smaller it will mess up the line because it will look like its cut off)
Do you have an idea for another shader that could be of use instead of this one?
If it is only for a single object, you could just use a dedicated shader for it.
On the object itself
I'd like to do that, but I just don't know how to make a line shader like this
A very simple plane intersection is done like this step( dot(position, normal) + offset, lineWidth) (try to translate to nodes :/ )
Wouldn't that yield the same result? If I use a plane to do this it would have the same issues im facing rn
No, because this is to render on the object directly, and will give an object (or world) constant thickness
So you're telling me I can do a plane intersection shader on a mesh without actually having a plane in the scene?
Yes ๐
A plane intersection can be done with a shader with pure maths
I have a very old playground with a "cross section" shader, basically doing a plane cut : https://github.com/Remy-Maetz/ShaderGraph_Doodles/tree/master/Assets/Shaders/CrossSection
Interesting! tysm
Sorry for the noob question: how do I create a lit shader using Shader Lab that uses the URP pipeline? All of the tutorials I've seen are about how to create an unlit shader for use in URP but surely I would want my objects to react to the lighting in the environment so idk why I would want to make an unlit shader.
Just create a new lit shader from the menu ?
Sorry, I don't see that
Shadergraph submenu
OH sorry, shaderLAB !
Well hum, not possible :/
I mean, technically it can be done, but there is no template for it, you will have to write it all from scratch, with all the required passes, there is no equivalent to surface shaders in URP
Is that because it's something I shouldn't want to do or am I misunderstanding? I'm pretty sure the kind of shader I'm trying to make isn't possible in Shader Graph
Shadergraph is the prefered solution if you want to make lit shaders (and even unlits) for the SRPs, as it manages for you all the boilerplate of declaring the different passes .
What kind of shader do you want to do ?
I'm not at all experienced with Shaders but I want to make one that calculates intersections between the object and a set of spheres and color the intersection purple. I did a bit of research and I think I need to use Stencil Buffers to accomplish this
Ok, yes, this is a bit tricky indeed.
You can use stencil with lit shader(graph) using URP render object renderer feature
Ok, if it's possible I guess I will try to research how to use Shader Graph. Also, why would I want to use an unlit shader? Is it just because it offers a more bare-bones template to implement my own lighting solution if I want something more stylized/custom or can it be used to provide performance benefits even with realistic lighting?
Like, can I set all the materials in my scene to use unlit shaders and then just bake all the lighting to increase the performance?
If you wan't to do some form of custom lighting, indeed starting from unlit and implementing your own lighting function is the easy choice.
But also, for the example you've juste showed, as each color is rendered by the different spheres, using unlit will just hide all the different and non consistend shadings of the 3 spheres merged into one
Hi, I am trying to read from the SSAO texture in a ShaderGraph, but getting a redefinition of '_ScreenSpaceOcclusionTexture' error, any ideas why this might be happening?
How can I reference the SSAO texture in my custom shadergraph shader?
Might already be defined by the graph through URP's ShaderLibrary? https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/ShaderLibrary/AmbientOcclusion.hlsl
If so, should be able to sample it in a Custom Function. Could even call the SampleAmbientOcclusion function provided in that file, passing in the Screen Position node as the UV.
thanks, will try that ๐
Question about refraction, what value should I be using when total internal refraction is occuring? ๐ค
regular surface normal? Something else?
writes
Stencil
{
Ref 64
WriteMask 255
Pass IncrSat
}
reads and should discard
Stencil
{
Ref 64
ReadMask 255
CompFront LEqual
}
what am i missing
the net says I should return reflection instead of refraction when TIR is occuring, but for some reason the method returns an error that I can't fix. Even when I set it to a float instead of vec3 it just spits another error
it spits the same error but in reverse, it says cant turn a half into half3, or it says cant turn half3 into half
hrmgh it works if I ONLY execute that one line
I have no idea why its this persnickety, there was a ; at the end, is it written too badly to be able to parse more than a single line?
same happens if you use split/append (or combine) nodes?
i dont know how they are called is sg
kind of makes the string return worthless but using file is so much more upfront work ๐ค
I am not sure what you mean by that
oh you are making custom nodes
Yeah
there are nodes that combine values
basically casts
and split separates channels
or break
dont have access to sg to check names
I think the problem might be the last line, as the variable Refract isn't defined
I assume you want refractDirection there instead
oh yeah ๐ค was having problems with trying to tell reflect and refract apart so I kept changing the variable names
the 'cant convert' error wasnt useful and didnt tell me the real problem I guess
๐ Works now, I kept hyper focusing on fixing the return I didnt see the name problem at all
guys, how would i make graphics like this in a unity project?
Cubes with an unlit shader for their materials
That's all really
okay thanks
Trying to port my code to a file instead of a string and I got this error that I am not sure what it means
void ReflectRefract_float(float3 viewDirection, float3 surfaceNormal, float IOR, out float3 reflection, out float3 refraction, out bool TIR)
{
refraction = refract(-viewDirection, surfaceNormal, IOR);
reflection = reflect(-viewDirection, surfaceNormal);
TIR = (refraction == float3(0.0, 0.0, 0.0));
}```
undeclared identifier it says at line 182
I am not seeing whats undeclared
does it not like the variable names maybe?
changing the names didnt fix whtever its trying to say
still undeclared identifier no matter what I do
but nothing is undeclared, I dont get it
nothing is spelled wrong
no missing ;
wtf there's no error when its not within a subgraph :|
something about an hlsl file inside of a subgraph is handled differently to a string in a subgraph, differently to NOT a subgraph?
I think the errors may be vague because they are reported by the generated shader code, not the custom function itself but I'm not totally sure
I think it's because you're using IOR as a function input, as well as a property name
I am? Where? What do you mean by that?
Well that's a complete guess really, but I don't see anything else it could be
its a float, and being used as a float in a method that takes a float ๐ค
or do you mean IOR is a special variable name?
like how you cant call something certain words
either way it has no error outside of a ssubgraph so I am going to chalk this up to Unity things
at least I am not crazy there was no syntax errors
I meant like you have both of these. But now that I think about it, I don't think this should be a problem.
If you have multiple custom function nodes it might just be the include file is being included multiple times too, so there's a redefinition?
Or maybe some left-over error and there's actually not a problem anymore. Sometimes you need to open and close the node preview or graph to refresh it.
Either way if it works in a new graph I guess it doesn't matter.
Ooh like that, yeah thats a good point Ill change it up and see if that fixes it
since outside of that subgraph there is no IOR input, at least not by that name
changing the name of IOR did resolve that error, it has a new error that it doesnt know what refract is
but it works outside of subgraph so I am not going to poke it further
oh no sorry I forgot to rename ior to the new name
once I fixed that it was back to the same old error
Hey
I've been looking for a good wireframe type shader for a good 3 hours now
This is the effect in Blender. It's not actually transparent, but rather a black unlit with a wireframe overlayed
I don't know how to replicate it in Unity. I have basically zero experience with shaders.
I tried looking for made examples, they all have "real" wireframe where it's transparent. I just want the solid black ๐ฆ
just disable the transparency? Or maybe instead of assigning 0 to alpha, just multiply the output color with 0
You could
- build the outline into a B&W texture set with proper UV mapping techniques for each triangle.
- Use a uv set or vertex color and embed BARYCENTRIC COORDINATES into each polygon. These let you detect how close to a polygon edge you are. You can then make coloring decisions in the shader. Google is your friend here.
is it possible to randomise the alpha mask in shader graph?
you could sample a noise map or generate noise in the shader
but random is a pretty broad term
there's all kinds of noises, voronoi is one that is also commonly used : )
yeah sure i'll be more specific. What i'm doing is making vfx, using a vfx shader graph in the output block. I'm looking to vary what the particles look like by using a variety of custom alphas that I have.
Oh, so you wish to choose one of them randomly?
yeah
hmm, I haven't worked with both tools together, ideally you'd want a particle ID or a property of the particle inside the shader graph, and then either sample a texture array or use a texture atlas and change the UV based on particle ID
I don't know off the top of my head how you'd do both this together, but I'll look into it, I'm interested in this aswell : D
my only other idea was to just have two particle systems, half the particle count and change the 2nd to a different alpha lol
Hello~
I see generated code from Shader Graph always has 2 sections of HLSLPROGRAM, why have 2 instead of 1?
Thank you
Hi, I wanna fill this cube from bottom to top depending on the Essence Fill value.
How can I do that?
Hey, I made a swirling noise kind of thing but I'd like to pixelate it. How can I combine these two things?
I'd use a Position node, Split and take the Y axis (G output) into T of Inverse Lerp (or Remap) to remap the mesh bounds (if it's the default cube, probably -0.5 to 0.5) into a 0-1 range. Then Step against the fill amount.
Kinda similar to some "fake liquid shader" tutorials if you search for those.
Try putting the pixellated UV into the UV port on the Twirl node
Oh damn, that easy
Also that pixellation calculation can be done using the Posterize node, if you want to make it simpler
Posterize? I'll take a look, thanks!
First day of messing with the shader graph ๐
How can I make the time change slower? Dividing doesn't work and I can't find something like round to digits
You'd need to Floor (or Ceil, Round, Truncate) before the Random Range
That'll remove the decimal parts of the value, so the random value only changes with each integer. The divide will then work too
Yea
Wait that doesn't work
Hm, I'll figure it out
Thanks a lot
Multiply first, then floor, of course
Hey, can you recommend any extra shader node assets? I saw there's a bunch you can download
I mostly just stick to the nodes provided, or write HLSL in the Custom Function node. But maybe Remy's node library - https://github.com/RemyUnity/sg-node-library
If you're in URP and want to do any custom lighting stuff, I've also got - https://github.com/Cyanilux/URP_ShaderGraphCustomLighting
I am in URP, yeah! I'll take a look, thanks a lot
Thanks a lot, it worked flawlessly.
Would be awesome if you could detect the size of an object automatically but this is fine ig.
nvm, it didn't work actually, works ony if the object it os Y 0 0_o
Hi all
I'm trying to find this color prop
Then switched to debug in the inspector and found this. But accessing either of these results in error doesn't have a float or range property '_Color'
So how to find the color's propertyName?
How ComputeFogFactor fucntion can be implement in shader graph?
I'd use Object space rather than World. But if you want to stick with world can offset using the Position output of the Object node. I think that can also give you the bounds of the renderer too now.
It would be a colour property, not a float/range one
Yes saw that haha..
Lit graphs should handle it for you. For unlit, should be able to Lerp with your current Base Color result, the Fog Colour and Intensity outputs from the Fog node.
yeah, I wanted to ask if I was supposed to use the Object option from the dropdown, do you mind explaining what it does because I couldn't find it in the docs?
is it like relative to the origin or the mass of the object?
Object space is the coordinates directly from the mesh data. (0,0,0) is the pivot of the mesh. For the default unity cube that would range from -0.5 to 0.5 as it's modelled to be 1 unit wide/tall/deep.
World space is the coordinates in terms of the scene, so translated/rotated/scaled. Positions will depend on the values set in the Transform/GameObject. (0,0,0) is the scene origin.
I see, that makes sense, I changed the space to object but it's acting really weird now
for example, if I set the Vine Size parameter to 4(which is the amount of world units the cube fills when it's s caled to Y2) it starts filling up properly but it's filled to the top at like .27.... Essence Fill
Ok, I discovered something.
Remapping the Position -> Object -> Split -> G from X 0.5, Y -0.5 to X 0, Y 1 and then keeping the rest of the nodes works regardless of the object size.
Do you mind explaining to me why this works and why do X, Y of the Remap In Min Max need to be inverted?
The X/Y might need to be inverted because you have the inputs to the Step inverted also
yeah, that was it
I am quite confused as to how this works because I am never actually getting the size of the object, could it be that it's somehow scaling the shader with the object or something?
because -.5 and .5 would work if the object was 1 on the y axis, shouldn't work for the value of 4
Object space isn't scaled (or rotated/translated) by the gameobject, it's the positions of the vertices in the mesh data. (See my previous message about Object vs World too)
That's the part I am having trouble understanding, I thought it returns the position of the object(where it's origin is placed in the world) and then you work with that value.
What do you mean by it returns vertices.
Does it send each vertex's position every frame or something like that because that would confuse me even more?
hey, i downloaded this model. and this is the vertex colors of it.
my question is how does it have perfect crisp vertex color without having two vertecis really close to each other? this mesh has 8 vertex.
I think those vertices have to be doubled up since Unity interpolates over triangles. Maybe there's some setting that told Unity to use flat shading and it doubled them automatically? Can you use a c# script to print mesh.vertices.Length()?
i am seeing this mesh inside my 3d program, in this case cinema4d. and i am sure i am seeing the vertex colors
Another program will probably do things differently but by my understanding, to have vertex colour with no blending in Unity, you need the vertices to be duplicated because one vertex can't have multiple colours.
but i used vertex colors for edge detection and creating outlines and it is working like a charm. so i assume the vertex colors are transfered correctly inside unity also. i will quickly make a shader to show the vert color now
Unity might be doubling the mesh vertices when it imports it because of some flat shading setting. Can you check mesh.vertices.Length()?
here is inside unity
That program may have a way to assign vertex colours per face, similar to how you can also have different normals or UVs without affecting the "vertex count". But once exported / imported into Unity, it'll duplicate those vertices
i made it editable with probuilder and i still can grab 1 vertex in each corner. it is defenitly weird to me.
Vertex data probably isn't uploaded to the GPU every frame as it doesn't change. But there are matrices that are sent for each object. The model matrix (which stores translation, rotation and scale) converts the vertex positions in the mesh (object space) into world space.
There's also matrices for the camera (view and projection) which convert those world positions to clip space (basically ending up as a 2D position on the screen)
You might need to look up some resources if you need a better explanation.
Probuilder is probably allowing you to select multiple vertices if they share the same location.
so i did print out the mesh.vertecis.length and i got 24 for this mesh and for default unity cube. here is the cube if anyone is interested.
I see, I kind of get it now.
Still doesn't explain why -0.6 and 0.6 are the perfect values for remapping this:
the shader works flawlessly but it's driving me crazy that I don't understand the reason behind -0.6 and 0.6 being the correct values for this...
The sphere mesh used in previews is a bit of a weird scale, that's just how it is. For other meshes those values will be different though.
well it works for both the preview sphere and the cube I instantiated
The sphere will be -0.6ish to 0.6ish, the cube is -0.5 to 0.5 exactly
interesting, I thought so too but then I made it -.5 to .5 and the bottom and top were covered in the emission shader instead of the base color, let me show you
Both pictures use the value of .5 and -.5
First one shows the emission completely filled up and you can still see the red base color getting through
Second one shows the emission with the value of 0 still being visible at the very bottom:
Yea, you may want a small offset to avoid floating point differences in the comparisons.
Thanks a lot for your help!
how can I get heart shaped or star shaped bokeh blur, I have only found a kernel for circular bokeh blur
hi, what is the difference between Normals and DepthNormals pass?
Hey everyone, im trying to create blending between regions for my procedurally generated tilemap. I currently have this kind of tilemap ( im using unity tilemaps ). In this example i want to blend between grass and sand for example. I've looked up some things and found this interesting article: http://devmag.org.za/2009/05/28/getting-more-out-of-seamless-tiles/. He uses custom alpha masks to create the blending, and i think it looks really cool. Unfortunately i dont have much experience in shader graph to recreate it. Im struggling to know what data i need and how to provide it to the shader graph to recreate that effect. Is it even possible with unity's tilemap solution? Or do i have to build my own mesh where i store my uvs ? Does anyone know how i could approch this?
What does UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX do?
I have a native array, or a mesh, containing the vertices position, i need to use them on a compute buffer, what's the best way to do it?
hi! I've been using a custom Surface Shader I created but now I need to use texture UVs from 0 to 7 as float4 and Unity doesn't support it in the Surface Shader; it can be used just in the Vertex Fragment Shader. So I pressed the show generated code button in the shader Inspector and it's opened in the Visual Studio as an huge file. I copied it to another file and started editing it so I could use the other UVs but I'm not actually sure of what I'm doing right now; is there a faster or easier way? Do I really need to rewrite/change all the generated shader code?
Im gonna shamelessly plug my blog for you https://ensapra.github.io/2023/06/Texturing-the-World
Texturing
is there a way to sum all elements of an array to a single element in compute shaders?
Hey, can you tell me whether I can use a shader to edit the appearance of any texture? Basically a highlight shader
I'd need to be able to assign it to arbitrary objects at runtime
Shaders are assigned by materials. So you'd add a 2nd material to an object at runtime.
As to what it does, though, that's up to you. Each material on the object is another draw call, they are called in order.
There's 1000 ways to "highlight" something, so IDK, but probably some sort of additive effect on top of what was drawn the first time with the previous/normal material.
At least. that's one way.
Another way is to have your own "standard" shader...and it could have an "IsHighlighted" switch up and above everything else. You'd then have unique instances of materials per object (or at least per set's of objects that have the same attributes) which might suck for batching.
Hm, I see.. I'll try the first way, thanks a lot!
Is there a significant memory impact to having every object require it's own instance of the material?
I'm doing something very similar to Trapture it seems :]
What pipeline?
HDRP at the moment.
SRP batches per shader. BiRP batches per material. That's a potential performance hit.
OK, HDRP.
Probably "just" the overhead of all those material instances. Not sure for HDRP.
What memory are you worried about? CPU or GPU?
Both honestly
rip I got ignored
is there a way to sum all elements of an
I'm doing VR BS, and I like how HDRP looks but don't have very much experience working with it
The one time I did it was sloooow with like a couple cubes
Well HDRP is for high end stuff. Performant stuff.
IDK how it is rated for VR headsets.... You've seen this? https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@8.0/manual/VR-Overview.html
Ah, I have not. Good to know, as I've just switched to HDRP as I'm only now working on visual stuff
Miiiight just stick to urp then lol
IF I were you, I'd be creating benchmark scenes and in at least 2 pipelines.
That would be too smart
lol
But to get back to material handling....regardless of pipeline....
I've done things like create a dictionary of materials. Then I'd have "tree-normal" and "tree-highlight" and only need those two materials for trees, and I think I had material property blocks for a few other things, but that was in BiRP. In SRP the material property blocks are screwed up and they end up wanting you to just create several material instances anyway. lol
So that way I could reuse material instances and get better instancing performance.
Unfortunately every object that can be interacted with will need its own
I had thought about adding and removing it at runtime but I'm not sure thats evern possible as afaik we only get sharedMaterial properties?
OK, ".sharedMaterial" is what you get when you link the same material reference to multiple objects.
Whereas if you create a unique material instanced for each object (clone materials as needed) that's the .material ref on the renderer.
You can do either.
I'm relying on multiple materials on one object atm, and sharedMaterial and material aren't a collection is what I'm trying to get at. In any case I've solved that issue I believe (Going with a switch on the shader and I'll just take whatever hit the instancing produces) but now I'm running into a funny issue.
I have very little experience with both shader graph and writing shaders (just a bit more with writing) so I've gotten part of the desired effect, but I'd also like to add an outline for the contours, like where it ends or is obscured. (Desired line shown in red). The shader isn't a shadergraph, but shadergraph seems to be the right thing to do for something like this, but I have no idea how to do the hatching in shadergraph ๐
Actually it appears you can't overlay in the same way as you usually can with shader graph materials
Outlines are seldom trivial things. Unfortunately.
Here's some articles to get you started on concepts:
https://alexanderameye.github.io/notes/rendering-outlines/
https://bgolus.medium.com/the-quest-for-very-wide-outlines-ba82ed442cd9
As to the hatching, depends on if you want it in screen space or object/world space. But you can calc it probably in screen space easiest, similar to a screen space dither. So I'd start by researching screen space dithers, and adapt it to hatching.
I've already written the hatching (and also shaded dithering but that's for an unrelated object) and it is in fact screen space. My only experience outlining is generating a duplicate mesh though, which isn't ideal lol
I think you can, it's just warning you that it's overdrawing it. Costing performance.
But you'd also need to swap the order on those materials. 0 being normal, and 1 being highlight.
0 being highlight worked fine for the non graph version. Tried both orientations with the graph version, neither version rendered the yellow material.
Huh. Maybe getting depth-clipped on 2nd material.
I mean, it's up and telling you it's inefficient to overdraw...so you'd think it would overdraw. Make sure to do a blend if that's what you want.
AFK for a bit.
alr
It was the blending
Okay I've put together a really simple hatching and outline graph which kind of works as intended. The upper half, the hatching portion is meant to replicate my hatching code:
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = _Color
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
if ((i.vertex.x + i.vertex.y) % 20 >= 4) {
discard;
}
return col;
}
But in the preview it appears rounded as if it's following the geometry (Am I misunderstanding the screen space node incorrectly?) and in the game it does whatever it's doing
The hatching is at least consistent with the preview but the fresnel isn't appearing at all
Ah, I had the screenspace node set up incorrectly. Still working on the fresnel
hmm yeah I think I'm just going to try a different way to indicate what you are selecting lol
Because I use screenspace the hatching lines are at a different positions in each eye. Can't believe I forgot about that lol
Too lazy to correct for it
is there a good resource to learn shader ? (coding shader not shader graph)
Especially recommend the youtube playlist if you're new to shaders
is the book of shaders not complete yet ?
I can see only Fractal Brownian motion on the website and till image processing on the offline pdf
is it still under progress ?
finally finished writing xD
I'm trying to understand how Passes work... I've been having troubles getting them to work together...
here's my terminology:
Properties
- Base :
White - Additive :
Black
Sub Shader : RenderType -> Opaque
- First Pass :
LightMode->ForwardBase returnBase
- Grab Pass :
GrabBase
- Second Pass :
LightMode->ForwardAdd returnGrabBase + Additive
Output
Gray
here's the actual code for reference: <https://paste.ofcode.org/DqdcZ8DB7ZDzzsUZwMtGjn/>
however! on my end, output is the Base alone... (aka White)
while I agree that more than a single pass isn't needed in the above example of mine,
it doesn't stop the fact that I want to learn about them ๐
please if you have any idea on what's going wrong (||more like, what's not xD||), let me know as I'd love to!
I'm going to be absent for the next few hours, if you do elaborate and/or suggest anything, I'll try to reply ASAP.
Hello is there a way to retrieve the cameras depth Texture in c# somehow without using SetTargetBuffers. I would like to copy the contents of the depth texture to another texture preferibly using Graphics.Blit or something
hi guys
i use double sided shader whic i found in github
the front faces are looking fine but the back faces of the object are looking whiter ten front faces
how can i solve this
can anyone help,
"Double sided" shaders still calculate lighting only for one side, so the backface often ends up looking incorrect
Instead you'll need a shader that flips the normal from the backface direction, or simply a mesh with its faces duplicated and flipped
thx very much my friend
Hey everyone, is there a way to visualize the average draw calls or sample counts per pixel as seen from the camera for performance debugging purposes?
Microsplat has the option to visualize sample counts, bright red being the highest amount of samples but I would also like to get an idea of how expensive other shaders in the scene are.
Any ideas why a Scan and compact algorithm is way faster at reducing the size of a compute buffer, than doing it with an AppendComputeBuffer?
Hey everyone is there a way to visualize
I've got a stencil shader, that will show objects within a mesh and cull anything on a set layer outside of it.
It works in editor, but not on Android .. is there anything extra that needs doing to get it working on mobile?
do you have stencil enabled in URP settings?
I've sorted it now. Wasn't a shader issue - I'd setup the stencil stuff on the URP settings for URP-HighFidelity-Renderer but the Android build was using Balanced in the quality settings
The fresnel won't show up because it's based on the normals and the normals don't vary across the cube's face; the fresnel is exactly the same value at all points.
hey I have this moving synced with sine and they're meant to act like waves. I'd like for the wave to not take up the whole width. Here, for example, how could I split the white lines into 2?
perhaps layer two different waves on top with a noise map to transition in between them
Did they make a full 3D object for this and then have a shader that takes one camera's perspective of that object and turn it into a sprite for this?
is that not a 3D object?
Well in the editor, it's 2D, but they have a way to rotate the object and have it project the 2D thing accurately, so I think what they did is take a 3D model and have a shader that turns it into a 2D image
Yeah. Way cool.
It does shadows too
heya, i have no experience in shader creation, so i am wondering if you can recreate blender shaders in unity?
i'm not talking aboiut super advanced one, i have a prietty simple one.
It doesn't turn it into a "sprite", it just squishes the verts closer together as you can see happening in the video
Shadergraph can do most simple things like blender
Yep, wrong terminology using "sprite"
Quick question: What's the best way to pass a set size array of float2's to a compute shader? I don't feel like setting up a GraphicsBuffer, but I might need to
what`s that?
shader graph is Unity's shader building tool
aye that be it
noice!
do i now make new > empty shader graph ?
oh my
that editor is crowded o.o
Dose someone knows why dose my png sprite looks like this in the shader graph?
Even that in the scene looks normal?
โฅ
how can i place the multiply outline on front of the texture?
Is there a best practice for modifying standard shaders? Do I just need to copy the URP shader folder into my project?
Hi, I am trying to follow @regal stag 's code on how to use context.DrawRenderers()
https://www.cyanilux.com/tutorials/custom-renderer-features/#drawrenderers
But when the objects render it seems like they are not being z tested, can I get some help please?
Guys, I'm trying to make some volumetric fog using shader graph. I can make an object invisible in the shadow using additive blending mode, but if I rotate it, it becomes transparent due to the light's angle. How can I fix it?
this is the issue I'm seeing
the code is super simple, only 70 lines to generate the texture, idk what I'm doing wrong ๐ข
My shader is alphatest and shows objects behind it even if the return color is 1,1,1,1; what could be wrong?
You should probably take the red channel from that multiply node and based on that lerp between the upper image and red color
You could also quite simply use branch node comparing by checking whether the red channel gives value larger than 0.5 or something like that. That assumes the outline is only having values 1 and 0 so you are not going to smoothly blemd the outline, hard to tell from that picture
the only way I found to solve my problem is set the render queue to transparent, but I didn't need it for alpha test shader created using Surface Shader. What should I add to my Vertex Fragment shader so it hides objects behind it?
I've just created a new unlit shader to try to find the problem; I don't understand why is the opaque geometry showing in front of a unlit shader but still the transparent geometry is hidden
ok, one problem solved, the opaque geometry was optimized tree material and changing it to Transparent Queue solved the issue
now I need to rewrite the shader AGAIN because I messed up everything trying to find a solution
I see a lot of people recommending I base my custom shaders for UI elements off of the "default UI shader", but that's not avaialble for me in the list in shader graph. What do people mean when they make this recommendation?
I am on URP, 2022 LTS by the way, don't know if that matters.
Hi, anyone know how to make a geometry trail shader effect like in this recording? I'm making an avatar in VRChat and trying to recreate this effect.
I'm asking because I'm getting a bunch of issues with masking, etc when I use sprite unlit as the base
This will require writing and rereading old vertex positions between frames, something shaders can't do by themselves. Since this is for VRChat, I believe a RenderTexture asset is your only option, which means encoding the vertex positions into the texture.
Thanks, I'll look into that.
Here's a few other angles of the effect that might give more of a hint of how its made. Looks like the effect is only visible from certain views/angles. Also I noticed it doesn't appear over itself, only behind it.
i was messing around with custom shaders and SRP. Now for some reason if theres no ground, this happens. so strange.
I found this information by the author, I think this will help https://github.com/pema99/shader-knowledge/blob/main/camera-loops.md
turns out the issue was a bug in unity if you dont have a background on camera?
i had set to skybox but i think skybox is bnroken with my srp
does URP not support non URP shaders?
One more recording I made to help me understand how the shader works... I stood near someone using a shader called "dope shader" it breaks. They said their avatar's shader duplicates the edges of meshes near it and extends out a few copies.
That is doing a whole thing
I am trying to write a stencil shader to mask an object, however, after following the tutorials, bot of my objects are hidden in the scene:
These are the shaders
Does anyone know what the problem could be?
is there no mod / addon to rip out those shaders from memory?
I'd imagine someone has made such a thing, since the assets are downloaded from an API
the player model should be stored in there along with the shaders
Found the issue, it is the first reply under this post:
https://forum.unity.com/threads/custom-shaders-make-mesh-invisible-in-urp-2021-3-22f1-solved.1422327/
Disabling depth priming does fix the issue, though the actual fix would be to add the DepthOnly (and DepthNormals) passes to the shader which URP uses to populate the depth buffer when that's enabled.
Even if you disable depth priming, those objects might not appear in the depth texture (if it's using a depth prepass to generate it)
Can you guide me to how I could find the named shader and add the passes?
I'ved used something like this - https://github.com/Cyanilux/URP_ShaderCodeTemplates/blob/main/URP_Unlit%2BTemplate.shader (repo also has some other examples)
If you're in 2022+ change the DepthOnly pass to use ColorMask R instead of 0
Though it may instead be easier to use Shader Graph and set up stencils with a RenderObjects renderer feature (at least for the Comp Equal one). Can even override stencil values for existing shaders.
Otherwise could look at the URP/Lit or URP/Unlit source under the Shaders folder in the URP package. That could also provide an example.
They are referring to shader code. Shader Graph does not really support UI currently, I have more details here : https://www.cyanilux.com/faq/#sg-ui
Afaik URP uses the same UI shaders as the Built-in RP currently. It's possible to download the Built-in shader source from Unity's site - https://unity.com/releases/editor/archive
There's also https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/DefaultResourcesExtra/UI/UI-Default.shader though may be a bit outdated.
Right, so if I wanted to make UI-facing shaders I would have to do it through shader code directly, not with the shader graph?
Shader code would be recommended. Though the first link I posted has some workarounds if you really want to use a graph
I have a texture with a simple text in it, using the shadergraph is it possible to let that image scroll from left to right kinda like an old bus display?
I've already set the texture to clamp so after offsetting it wont duplicate, now I need a way to warp it to the left after its completely on the right side
As a visual example Sine Time on X Offset works fine but I only need the first half
If you set the texture to repeat there won't be any need to worry about wrapping it when offsetting it
Oh thats actually good
but how can I add some space between the 2 textures then?
Should I just add alpha to the base image on the left and right? Or does exist a better way?
That's the simplest way
You can also do some UV math in the shader to get to the same result if you want
mhhh... what node should I use?
nvm I used alpha
the result seems good enough
what changes to this custom shaders code
do i gotta make, to make it work with URP?
its only like 55 lines of code, so im wondering if theres a few lines that i just have to change and it will work lol
It would not be that simple. URP does not support surface shaders, so the whole thing would need rewriting. Could be easier to use Shader Graph.
Ah okay, so id have to make this shader from scratch? (it reveals objects under light)
Is it possible to create a simple 2 color gradient from shadergraph withtout having to use a mask?
To make a gradient between two colors you would lerp between them using some variable factor.
It's up to you do determine what this factor is. Is that the "mask" you are talking about ?
Dunno, I just want to achieve a node with vertical Red to Blue color, but in a with lerp where T its just a number the color will be the same everywhere
so I guess I need an external mask to make the gradient
You could then use UV.y as input value for T
Oh, didnt knew that, let me try
Hello!
I'm trying to make a simple shader to render colors on a mesh using vertex colors.
I found this one on Internet :
Shader "Custom/VertexColor" {
SubShader{
Tags { "RenderType" = "Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert
#pragma target 3.0
struct Input {
float4 color : COLOR;
};
void vert(inout appdata_full v, out Input o) {
UNITY_INITIALIZE_OUTPUT(Input, o);
o.color = v.color;
}
void surf(Input IN, inout SurfaceOutput o) {
o.Albedo = IN.color.rgb;
}
ENDCG
}
FallBack "Diffuse"
}
It works fine when I set vertex colors using Color but it does not work (the whole mesh becomes black) if I use Color32, which is annoying since from what I understand, Color32 would be much better for performance.
Is there somewhere a shader that would do that and work for Color32? Or can this one be modified to use Color32?
Nice trick, thanks @amber saffron
Hey everyone i've been learning about shaders, mostly following this book,
Building Quality Shaders for Unity: Using Shader Graphs and HLSL Shaders by
Daniel Ilett
It helped me create a shader (URP) which lerps between the two colours based on _CameraDepthTexture to draw silhouette of opaque objects behind it.
Shader code here: https://gist.github.com/MzaxnaV/e2b54eb86e57e5ab8421b1ea0971e1af
It said that adding a depth only pass would allow it to be rendered into the depth texture and show up in effects.
I expected the green box to be visible in the red sphere
Did I misunderstand something, or is this what's expected to happen?
I expected it to be filled like this
It is expected to happen like this : The depth pass will ... well, write to depth.
Then the transparent pass will be drawn (in general it is in that order), using the default z-test LEquel if nothing is specified.
That way the back gree box pixels are culled when drawing
I see so merely adding a depth pass wouldn't have made any differencebut the book i am following says otherwise. I guess time to change where I am learning from ๐
The statement is not totally wrong, but the depth pass must be rendered after the other one, and it looks like it is not doing that in your case.
Is there a way I can check that?
The frame debugger or renderdoc
Thanks, i'll see how to use the frame debugger
Theres this youtuber, who made a vid on creating object revealing shader but with some unity store asset called "amplify shader", do you think i could follow the steps he did with his "amplify" unity store asset and replicate it in unity graphs?
Yes, the workflow a quitte similar
ok thanks, i will try following his exact steps but on shader graph, and hopefully it will work :P
it was surprisingly easy to find haha, but yeah they don't show up in the _CameraDepthTexture
Maybe it can be done by simply adding a depth write in the original pass. Transparent are drawn from back to front, so they should still overlap
Else, you will have to resort on custom renderer features (maybe that's how it's done in the tutorial/book ?)
ohh. I could try that, though i don't fully understand how i would do it. This is the book I am following: https://learning.oreilly.com/library/view/building-quality-shaders/9781484286524/. Also i am not sure if it's allowed to share excerpts/screenshots from it here.
Shader "Unlit/MultiplyShader"
{
Properties
{
_MainTex ("Main Texture", 2D) = "white" {}
}
SubShader
{
Tags
{
"IgnoreProjector" = "true"
"Queue" = "Transparent"
"RenderType" = "Transparent"
}
Pass
{
Tags
{
"IgnoreProjector" = "true"
"Queue" = "Transparent"
"RenderType" = "Transparent"
}
ZWrite Off
Blend DstColor Zero
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
// Vertex shader
struct appdata {
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f {
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
v2f vert(appdata v) {
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
// Fragment shader
float4 frag(v2f i) : SV_Target
{
// Sample the source texture
float4 srcColor = tex2D(_MainTex, i.uv);
// Calculate the multiply blending for each channel
float4 result;
// Multiply the RGB channels with the alpha channel
result.r = srcColor.r * srcColor.a + (1.0 - srcColor.a);
result.g = srcColor.g * srcColor.a + (1.0 - srcColor.a);
result.b = srcColor.b * srcColor.a + (1.0 - srcColor.a);
result.a = srcColor.a;
// Output the final color
return result;
}
ENDCG
}
}
FallBack "Diffuse"
}
Alrighty, I've got this shader I'm trying to make for RimWorld. It only takes the _MainTex. Right now it is behaving like my other, properly working, multiply shader. I need this one to behave like a linear burn effect similar to Photoshop's linear burn blend mode. The only thing I need to do still is get the pixels to be darkened a bit. However, everything I try also darkens any white pixels and pixels with any white in them. Similar to Photoshop's multiply blend effect and my multiply shader, any white in the _MaineTex should essentially cancel out and leave behind transparency in it's place. How can I do this?
If I had direct access to any of the Texture2D's under the _MainTex here this would be a lot easier but the texture this shader is applied to should act as the linear burn effect itself.
Does anybody here know how you would achieve a crystal shader for 2d sprites in unity?
Do know that Color32 uses values in the 0..255 range, while Color is 0..1
Yes thank you, I've just figured that out 5 minutes ago ๐
So I must multiply by 255 in the shader right?
Multiply it in the code where you pass it into the shader
Ooh wait you mean the new Color32() arguments are between 0 and 255?
Does anyone know if its easy to create this effect where light reveals objects in shader graph? or very hard
Yeah exactly @sudden spear
me too
anyone plez?
I'm doing this shader where I need to fade the material with alpha based at distance from camera, but some objects are faded halfway like as if inverted. What should I do to fix it?
Hi, is there a way to render the scene into a texture without shadows using context.DrawRenderers?
// map the distance to an fade interval
float beginfade = _fadeStartDis;
float endfade = _fadeEndDis;
float alpha = min(max(dist, beginfade), endfade) - beginfade;
alpha = 1 - alpha / (endfade - beginfade);```
medium hardness
theres a bit of messing around with custom hlsl blocks since you cant access much lighting data
in shader graph
looks like my shader is basing the fade value by the center of the game object to the camera instead of the vertex position; what
instead of fading each chunk by itself, it should be fading the entire chunk if it's away from camera
anyone know why the voronoi is showing up like this?
im new to shader graphs so i dont know much
i think none of my noise nodes are working, anyone know a fix?
Guys does anyone know how to achive a crystal shaderin 2d?
ive tried installing more noise packs but all of them show up grey, does anyone know why?
What's going into the UV slot?
I'm guessing the input in the UV slot is (0,0) or otherwise some constant
I'm currently using
TRANSFER_SHADOW_CASTER
SHADOW_CASTER_FRAGMENT
TRANSFER_SHADOW_COLLECTOR
SHADOW_COLLECTOR_FRAGMENT
How can I limit the shadow casting and receiving by distance from camera in my shader?
i dont think whats going into the uv slot is affecting it, when i added another node with nothing attached it still came out gray
what is going into the slot though
the slot is the input
wait nvm i updated unity and it fixed
this post is the same problem I have: https://forum.unity.com/threads/shadow-strength-in-shadowcaster-pass.543309/
But I don't have the knowledge yet to understand what is the solution presented. Can someone help me with it?
for (int x = 0; x < sampleSize.x; x++)
{
for (int y = 0; y < sampleSize.y; y++)
{
sample = tex2D(_MainTex, IN.uv + (subPixel * int2(x, y)));
Samples[(x * sampleSize.y) + y] = sample;
avgCol += sample;
}
}```
Indexing an array during a for loop causes a compiler error, `Shader error in 'Opposition/Downsample2': forced to unroll loop, but unrolling failed. at line 98 (on d3d11)`
This does not occur if i don't access the array during the for loop. Is there any way around this?
i tried using a structured buffer instead, but this results in a new error
struct colorSample
{
fixed4 color;
};
RWStructuredBuffer<colorSample> Samples;
Shader error in 'Opposition/Downsample2': maximum ps_4_0 UAV register index (0) exceeded - note that the target doesn't support UAVs at line 54 (on d3d11)
Did anyone manage to call UniversalFragmentPBR from an unlit shader graph?
I got it almost working but when I pass the baked gi using the Baked GI node in shader graph it's ignoring it for some reason, maybe it has to do with keywords?
are there any known useful guides/breakdowns on transparency best practices? It seems very easy to get really messed up results
https://unity.huh.how/graphics/materials/rendering-issues/transparent-materials
My resource isn't really a guide, but it does talk about why it all sucks and things to look into
Thanks, reading now ๐ Found some posts by bgolus as well
in.uv += ParallaxOffset(...);
how might i need to modify this so that i can reuse it for 3d models (color zones) instead of sprites like this
ideally, you apply this shader to a material (texture for a 3d model, clothing item in particular)
so that you can select a certain color, and replace it with another color
am i using a texture 3d or what
i havent really ventured into the 3d space for this
ping me if you get an answer im going to bed
My project fails to build due to the error:
Shader error in 'Hidden/InTerra/HDRP/TerrainLit_Basemap_2022_2': "Undefined punctual shadow filter algorithm" at /Unity Projects/MyProject/Library/PackageCache/com.unity.render-pipelines.high-definition@14.0.4/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl(47)
What puzzles me, my teammates don't have any problem with the project building. Any suggestion about how to fix it?
Unity version: 2022.2.0f1
HDRP version: 14.0.4
does anyone know if there is a way to have an array of vector3s in shadergraph ?
or use an for loop
i need to add alot of variables to make my gersnerwaves look more realistic
Can do array & loops inside a Custom Function node -
https://www.cyanilux.com/faq/#sg-arrays
Though that also means the Gertsner Wave calculations needs to be in the code too, either in the loop or a function called by the loop.
When making 3D models you typically "UV unwrap/map" them so a Texture2D can be applied.
That way the colour swapping should work the same. Though I prefer using this setup rather than the Replace Color node : https://www.cyanilux.com/tutorials/color-swap/#tint-color-channels
are there any advantages to learn shader programming when unity has shader graph ?
Like is there some advantage that coding shader has over shader graph ?
More advanced things can only be done with code, like loop or some "obscure" hlsl functions not exposed in shadergraph.
Also, if at some point you want to work with compute shaders, it's code only and almost the same syntax
oh, it might also help me in other game engines where there is no node based shader editors and i have to write shader code there as thats the only option
Could still use some help on this if anyone can.
I managed to do it ๐ I replicated the URP Lit shading inside an unlit graph with a custom node
guys i post this question in Unity Forum about skewed effect for 3d character shader
can you help me to see if the way i do it is good enough?
You can try
[loop]
for (int x = 0; x < sampleSize.x; x++)
{
[loop]
for (int y = 0; y < sampleSize.y; y++)
{
sample = tex2D(_MainTex, IN.uv + (subPixel * int2(x, y)));
Samples[(x * sampleSize.y) + y] = sample;
avgCol += sample;
}
}
hi i want to write unity ui shader, but when i type it i see different results on game screen, different results on scene screen, and it doesn't work on alpa game screen
I'm using canvas render mode as overlay. I can't change it. Is there a different way?
Add
#pragma target 5.0
To shader pragma section
Tyvm, Iโll give this a shot when I get home
I assume though that this could effect hardware compatibility
You can try target 4.5 (never used this version intentionally)
If your syntax with the array loop works Iโll probably end up using that since Iโm sure it works on a lot more hardware than the structured buffer
Guys
i have light pos, direction and angle, how should i go about using these to make a light reveal an object?
like shown here
- calculate pixel pos - light pos => relativePos
- normalize relativePos
- dot ( relativePos, light direction ) => cosValue
- ArcCos (cosValue) => pixelAngle
If pixelAngle > angle, alpha = 0
Thanks i will try this, btw what do u mean by pixel pos?
position of the object thats being revealed or?
It's the "position node" in the fragment stage in shadergraph
ah this top node right here minus the light pos? ok thanks can do!
No, that's a "block" or "shadergraph output", I'm talking of the "Position Node" : https://docs.unity3d.com/Packages/com.unity.shadergraph@7.1/manual/Position-Node.html
Ah okay my bad, ok thanks! will try all of waht u said and see if i can make it work, will show results :D
I exported a shader I made from an earlier version of unity to my current project but it came in with all its surface inputs greyed out ๐ค
I have never had this happen before, at first I thought it was doing this because some of the nodes needed to be updated, but even after doing that its all still greyed out
What are possible causes of all shader params being greyed out?
I dont see anything in here that could be responsible for locking edit to every parameter
Other materials work as expected, no grey out, only this one is grey out
Huh its NOT greyed out on the material in the project itself, but is on the instance of the material attached to a mesh
anything wrong in here?
In newer versions SG seems to create a Material asset under the graph asset. It's useful, but only uses the default property values set in the graph. If you want other values you need to make your own Material
I am a little confused by this, what do you mean SG created the material? I exported this shader/material from my older project, I am using a material I made as far as I know? You're correct that making a new material of this shader allowed me to edit the params on the mesh carrying this new material but I am not seeing why a single thing is different between this material and the one I just imported, they're both
materials of the same shader??
The object probably wasn't using that material, but the auto-generated one
oh the shader itself unfolds into a material
I have never once seen a shader do this
Yep it does that now
Oh so its something new from a newer version ๐ค I see, that would make sense since I imported it from an older project
weird behaviour and not well signposted but at least I know this occurs now, thanks! ๐
Hey thanks for the help! it nearly fully works, but how can i make the opaque bit more solid
Hi, masking doesn't work when I add ui shader, can you help me?
I have info here about using SG with UI - https://www.cyanilux.com/faq/#sg-ui
Goes over editing the generated code to make it work with masking, but then it's separate from the graph.
Hi, I have this simple shader.
I wanna add another layer of noise(just paste the current block) to have separate settings for the fill part.
Would that be unoptimized?
how to change black to white?
I am guessing that you are using a mask or something to paint that red part(preview should look the same as this one but with the red part being white)
You can then add that node to the current one and you should get the correct result
I should mention that I am still quite new to the shader graph so this prob isn't the best approach :/
its jsut a texture lol
the texture got an alpha property, so maybe if i made it transparent?
it would get rid of the black background, but howd i go about doing that mhm
yeah I was just thinking about that, then just multiply with a completely white color to fill the rest of it
you can get separate channels from the texture by using the sample texture node
mhmm okay
im so confused as to how
i would create the new texture but with Alpha being 0
let me try it rq
ok thx
I am too dumb for this, sorry :/
there is a combine node to combine different channels and a split node to separate them, the thing is, I can't figure out how to remove a color 0_o
I actually find something that you could use but I have no clue if it's what you want or if it's any good :/
you jsut have to play around with the range and fuzziness parameters
ok thanks good idea
its kinda working, but now
how can i eh
change that red to black
lol
you have to play around with the range and fuzziness parameters
ig using the same node but with the red color this time
invert might work but afaik invert literally inverts the color, black would become white and red would become greenish or sm
yea but i want anything but white, to be black
the coulour could be red, green, blue etc
I am not entirely sure how you'd achieve that tbh(it's 100% possible)
actually
im kidna stupid
but i want anything but black
to be white lol
my bad, this shader stuff is confusing, but i 100% want anything but black, to be white
so this red here to white
I'm not sure what the setup is here, but if it's from a texture you should be able to use one of the colour channels (either red or alpha if it has that?) into the T of a Lerp node. Then you can set A/B to colors.
Similar to this - https://www.cyanilux.com/tutorials/color-swap/#lerp
yes its just this texture
hmm that did work, but what about the blue? xd
like if i had a blue texture, would the blue change to white as well?
or it would be jut black
ye i think itd be just black
oh well its al lgood anyways
no he meant put one of the texture outputs into the T node and then use that to lerp between two colors of your choosing
Ooh lol, i will change it later then i guess
Hey all, I am in the proces of converting my game from Unreal to Unity. I rely a lot of Material Parameter collections, which are parameters that can be used in shaders and changed globally across any shader using it. Is there an equivalent to this in unity?
I am trying to write a wireframe shader in shadergraph and I've gotten this far based on studying some other tutorials, but those tutorials rely on using baycentric coordinates which I don't have access to in SG. Looking at what I have so far is there any obvious steps or resources on how to take this and turn it into a wireframe?
currently it has many problems, like not working on the cube, and not even being 'wireframes' and the lines not being fixed width, all of which require baycentric coordinates from the tutorials I cant use
From what I hear you do need the barycentric coordinates
Baked into vertex colors if you can't get them otherwise
Ill google how to bake them into the vertex colors then I suppose
hm maybe there is some way to perform some kind of 'edge detection' on the face flattened normal values?
is there maybe some way to combine these two assets to essentially 'map' UV 0 to 1 coordinate grids into every face?
hrmg guess it cant be done and baycentric is the only way
hrmg having issues with encoded barycentric values, there's no way to mask out the diagonal lines, I wanted wireframe without triangles, only polygons
also janky results on rounded things
I am using a script I found on github to encode the barycentric as a test, maybe the script itself is the cause
progress ๐ following the catlikecoding tutorial
sorry to bother but ill have a shader problem and would like to ask if someone has 4 minutes spare time...
All polygons are triangles
There would have to be some extra system to differentiate quads or n-gons, because that information is lost on export
I am aware all polygons are two triangles, the flatshaded normal map does show the triangle lines faintly but for the most part they appear like quads rather than tris over all
I was hoping there'd be some kind of way to take the <???> of both of these and <???> to mask out the diagonals
dont ask why the bary one is fuxed, I am still working on that
They appear like quads because the angle between the triangles that make up the quad is flat
I think some wireframe shaders use that as the deciding factor of where to draw the edge lines and where not to
I do not fully grasp DDX and DDY but they seem to be brought up in regards to edge detection and get used in the barycentric a bunch, is there some way I can use them on those flat vectors to make a mask to use on the wireframe?
There isn't a specific channel for editor issues (not editor scripting) related questions, so I'm asking here. I'm working with compute shaders, and since the first time I compile a compute shader in an editor session, this annoying progress bar appears in the bottom right of the editor, saying it's compiling compute variants. It never makes progress or stops, and regardless, the actual compute shader compiles fine, leaving behind this job which seems to be stuck. I assume this is a bug.
https://www.youtube.com/watch?v=fu5HYNu-lw4 this might help
Improving our existing wireframe shader, to only render quads. This removes many of the diagonal lines from the mesh you may not want.
We use the technique of longest edge removal from the triangles. This removes the majority of cross diagonals in a mesh that is predominantly made of quads. It isn't perfect, but if this is the effect you requir...
(he basically finds the longest edge of the triangle and doesn't draw a wire along that edge; if you have something made of quads, that edge will be the diagonal of the quad)
why tinting versus swapping?
Good find, thanks Ill check this out extensively
Mostly as multiplies will be cheaper than the length() calculation that the Replace Color uses. For some texture inputs with more of a gradient / anti-aliased edges it's kinda difficult to mask correctly - there's an example in that post too.
hey Cyan sorry to tag you but I just saw you were in here and you're probably one of the best people I can ask this question to because I'm using a reworked version of the animal crossing water shader you made a tutorial for on twitter a while back. The one where you used the clever UV Y=0 for deep sea, Y=0 to 1 for shoreline and 1 for sand.
I'm currently trying to add sparkly stuff to the water.
This works great for the water close up but far away, I get white (colour of the glitter) streaks along the edges of the mesh. I've made my mesh pretty large because I want the sea to go on into the horizon if that has something to do with it. Do you have an idea what could be causing this? I'm using hurl noise to create the glitter effect
If these sparkles don't need to follow the shoreline, I'd use a worldspace planar mapping instead (worldPosition.xz) for the UVs when sampling that noise.
Otherwise you'd probably need to mask the result so you don't use values < 0.01
im quite new to this but I believe I am. I've got a position node set to worldspace > split (R and B outputs) > vector2 > UV input of sample texture 2d node
(to the first part of your statement)
Yea, could also use a Swizzle node (with "xz" in text field) instead of the Split/Vector2. But either works.
https://www.cyanilux.com/faq/#sg-planar-mapping
oh neat, thanks
they dont need to follow the shoreline, i kind of just want them to be everywhere on the water
im thinking I could just make a new mesh that slots on the outside of the beach mesh far enough into the horizon but without the glitter lol
potential bandaid fix but kind of gross
I had this toon shader setup in blender- i was wondering if anybody could help me figure out how to set it up in Unity? I'm new to shader graph and all that stuff...
what i understand about this setup is that the color ramp in constant shades the material differently based on view & lighting. I dont think the other nodes are as important?
I tried doing something with the Gradient node in HDRP Shader Graph, but I couldn't figure out what to hook it up to for an output.
having some issues with the color tinting from before
made a uv wrap
and it looks fine, and applies to the model fine
issue is that changing one of the colors tints the entire texture
as opposed to specifically red green or blue sections
changing red makes the entire texure greenish
when made to a more orangey yellow color
uv map looks like this
is this how its supposed to work
or is the entire texture meant to be red/green/blue
and also, would this method not prevent you from using more than 3 colors?
i copied the shader in your example almost completely
ok my internet loaded the site right htis time i was able to see the text properly
any way to give more than a 3 color channels?
"Shader to RGB" has no equivalent in Unity
You'll want to search for "toon shaders" for your render pipeline instead
#archived-urp message I'm not sure if this counts more as shaders or urp or even code so I'll post it here also! Please do let me know where it would've been most appropriate so I can "spam" less in the future ^^
i think you will need to use the actual shader code if you want to use good lighting since unfortunately shader graph is either lit (in which case it does all the lighting for you and you can't play with the results after that) or unlit, in which case you have to do all the lighting yourself (except shader graph doesn't have nodes for lighting, so you need to make custom nodes or set them via script)
the color ramp node is equivalent to the sample gradient node in shader graph
I'm trying to create some sort of rainbow effect. I randomized a base value and then from there, I cover about 25% of the hue spectrum and map it to a texture. It could be [0...0.25] or it could be [0.58...0.83], etc.
Now visually for reasons beyond my understanding, the hue spectrum green/teal seems to cover an extremely large part of the spectrum, and royal blue for instance is very short. I guess I'm trying to say, colors as we have been taught to recognize them are spread unevenly.
Since I only cover 25%, I can have something that almost looks like it's fully teal, and then I'll have another instance that covers an entire pink/purple/deep blue gradient.
Now I'm hoping for a more consistent effect based on how we perceive the colors.
Is anybody aware of anything that could help?
What kind of "rainbow effect"?
is there a way to exclude an unlit material from receiving the fog pass?
Why is my code throwing Undeclared Identifier Float on my translation of this code to HLSL?
void sdBoxFrame(float3 p, float3 b, float e, out float output)
{
p = abs(p) - b;
float3 q = abs(p + e) - e;
output = min(min(
length(max(float3(p.x, q.y, q.z), float3(0.0, 0.0, 0.0))) + min(max(p.x, max(q.y, q.z)), 0.0),
length(max(float3(q.x, p.y, q.z), float3(0.0, 0.0, 0.0))) + min(max(q.x, max(p.y, q.z)), 0.0)),
length(max(float3(q.x, q.y, p.z), float3(0.0, 0.0, 0.0))) + min(max(q.x, max(q.y, p.z)), 0.0));
}```
I am not seeing the mistake I've made anywhere in this
and if the error is not inside the code but in the node..
Shader graph expects the custom function (in the hlsl file) to be named <name>_float or <name>_half to match the Precision set on the node (currently set to "Inherit" from it's inputs)
whoops, I had re-written it again trying to fix a bug but must have forgotten to re-add that part. Here is the new code that errors No Matching 5 parameter function at line 194
void sdBoxFrame_float(float3 p, float3 b, float e, out float output)
{
p = abs(p) - b;
float3 q = abs(p + e) - e;
output = min(min(
length(max(float3(p.x, q.y, q.z), float3(0.0, 0.0, 0.0))) + min(max(p.x, max(q.y, q.z)), 0.0),
length(max(float3(q.x, p.y, q.z), float3(0.0, 0.0, 0.0))) + min(max(q.x, max(p.y, q.z)), 0.0)),
length(max(float3(q.x, q.y, p.z), float3(0.0, 0.0, 0.0))) + min(max(q.x, max(q.y, p.z)), 0.0)));
}```
I was trying to fix this 'no matching 5 param' error which is what lead me to cause the other error
I dont know why its asking for 5 param when nothing in there is 5 param
You have 4 inputs on the Custom Function node, but only 3 in the code
I assume the "r" one isn't needed
Yeah it wasnt, that was me stupidly copy pasting an attempt at a rounded box for this frame
as usual error exists between screen and chair
its working now though ๐ฅ or at least its not erroring
(it goes without saying that ALL of this is XY of course)
im 110% aware that self overlapping transparency is an unsolved problem in computer graphics, I am trying all kinds of techniques and shaders and tutorials and github repos trying to find some way to "describe" this shape to the shader to even begin to aproximate it roughly
'hollow cube' basically
i maybe have an idea to try next ๐ค
some actual progress ๐ ๐ค
instead of trying to do one perfect function I am just calculating two boxes and subtracting the inner from the outer
hrmgh tried to get a cylinder instead of a cube using the cylinder math from https://iquilezles.org/articles/distfunctions/ but I cant figure out the math
I also found this which claims to be a cylinder distance function but couldnt get it to work either
a cylinder feels like an even simpler shape than a cube to describe
but no dice
Capsule is simple, but cylinder complicates things with its flat caps.
I have this as an animated wave effect that loops. I've figured out that that X value on the multiply is what affects the speed. How can I make it so that the waves/lines speed up near the end?
Oh interesting, I had ignored capsule but will explore that ๐ค capsule is basically just an SDF line iirc
I'm probably missing something quite fundamental here, but I cannot figure out why the Geometry > UV node in Shader Graph outputs 4 values, when UV coordinates obviously only have 2 components: U and V? Am I always supposed to split the output, merge it back into a 2D vector and do things with it? Currently I'm still struggling to even get sensible values out of the node...
It's typically Vector2 from modelling programs, but the Mesh API supports up to Vector4. https://docs.unity3d.com/ScriptReference/Mesh.SetUVs.html
You likely also want the first UV0 channel, not UV2
I'm aware of the different UV channels. I'm just storing custom color and non-color data in UV2 and UV3.
Nvm, I had bad input data. The node works fine. In my screenshot the Split node R component is the horizontal U or X component and the G contains the V or Y value of the UV coordinates.
how is this possible. What am i misunderstanding here? I simply want to increase the speed according to the value of UV.y
I almost have a cylinder working, except for some reason its always facing directly towards me ๐ค
hm actually this is more of a capped sphere
getting disheartened, I knew it wouldnt be simple but I thought I'd still be able to get something, given how common and easily found the formulas for SDF shapes are, and how simple the math is for getting the depth through two points of a primitive described by an SDF
What is the corrrect syntax to include sub-methods in an HLSL file running in a custom function?
it doesnt follow the void <name>_float(out value var) shape
https://github.com/Kodrin/URP-PSX
i got this funny little shader, how do i actually apply it so that its just like on the whole project, i cant find any option on ShaderGraph to actually open anything up
sorry this is really basic :(
and i tried looking it up, the github doesnt say anything im just too incompetent i think
if I understand correctly, you have the shader and want to use it on objects? Right click the shader and create Material, or find an existing material and assign it's shader to be that
ok thanks
It stopped erroring when I tried inline float <name>() { return float }
this is the distance through a cube
and so far I havent gotten a single successful output
yeah me too
im not going to solve this today because the more distressed i become by how everything i do results in a worthless failure causes me to fail even more and then become more distressed, feedback loop
gave up for cylinder for now, trying to add refraction to the cube one
not sure how/what/where/when to replace with refracted UVs though
im so burnt out I cant see the forest for the trees
since im obviously struggling to do anything on my own, I am just going to ask: what can I do to make transparent meshes not look like dogshit?
i wish blendmodes other than additive, multiply, alpha, premultiplied existed, those four give awful results
I know that transparency is an unsolved problem in 3D rendering but there must be some way to make it look less.. shit
Hmm I guess that depends on the type of object and artstyle, what should it be like?
I know something they called "transparency improvements" was unceremonously implemented into HDRP which may be relevant
https://portal.productboard.com/8ufdwj59ehtmsvxenjumxo82/c/1889-transparency-improvements
am I supposed to be seeing more on this link? ๐ค There doesnt appear to be any kind of button that leads to an article or anything
As for what I am shooting for, translucent plastics. I've managed some decent results using scene color, but as soon as the mesh overlaps itself, eg like a hollow cavity, it looks real bad
I have tried to use SDFs to describe hollow shapes https://cdn.discordapp.com/attachments/669975874455732224/1127336320251994172/sorta_this.gif
but its agonizing to do literally anything with it, or change its shape in any way
i spent 9 hours trying to go from a cube to a capsule and it just didnt go anywhere and hurt, a lot
There is no more info ๐ฆ
But apparently it's in 2023.1.
I didn't read all your message earlier, but if you want to render objects like this transparent lego figure correctly, you need to implement order independent trasparency technique. It is not really hard: https://www.cs.cornell.edu/~bkovacs/resources/TUBudapest-Barta-Pal.pdf
Nuts. I can upgrade to 2022.3.4 at least to see if anything fancy comes from that
I don't think there any easy ways at all to emulate internal density with translucent materials
I expect all of the techniques expect understanding actual math papers
Really picked a legendary difficulty challenge again
What is or isnt hard is extremely subjective person to person
but then you linked a repo with it maybe done already so I will go look at it
Subjective to person's experience*
But isn't that just to fix the issue of transparency draw order? I don't think this helps you render volumetric transparency.
Yeah ๐ฌ and im an artist, not a mathematician
but shaders are the only path to the shiny golden pixels ๐ฅ
I mean that might help since currently most of what I am looking at looks like this
Algorithm can be easily improved to properly handle volumetric thickness. With linked OIT techniques we know depth of all transparent fragments that contribute to final screen pixel. With this knowledge we can adjust color depending on volume depth.
To properly handle internal holes we can mark face-forward and face-backward pixels separately based on normal (for example)
a side tangent I got decent results from having a material on the inside have negative alpha, which then subtracts alpha from the higher alpha in front of it
but it was almost impossible to get it to do anything else but exactly that, and broke under like 50% of the viewing angles
I guess what's happening there is that the inner cube was being rendered through the outer cube, which happens with transparency sorting when the geometry depth is ambiguous
Hi everyone, I am making a foil card shader.
I have done all the effects for the main card, but I'm wondering if you could help me with some suggestions regarding what effects I could add for the outer border and window border, and also for the energy cost circle to make the card more interesting.
Some easy and accessible tricks I use are to enable ZWrite on a transparent material to have it render the faces closer to camera correctly, and another to render no transparency through the mesh itself at all by using two materials in the same slot, first one with an "empty pass" (which may not be recommended for performance reasons in URP but since there really isn't multipass shader support I guess it's the only way)
I brought in the OIT package and attached the renderer thing, its upsetti about something though, reading their forums to see if this is a known issue with a fix
their oit sample scene looks kinda broken
and I am not seeing any kind of tutorial or instal explination beyond 'drag it in, attach thing to renderer'
the example shader in the scene isnt a shadergraph shader, its a regular one, even though its in URP :/
meaning im guessing that none of this can be used
I will try to explore this thing you said
Shadergraph shader is ordinary shader but created with tool that convert fancy blocks into code ๐
I will look at this OIT technique, and maybe can give some advice
Cool. My understanding is regular frag vert shaders can't be used in URP, like its written in the old style
ZWrite should be easy enough to test with SG
For the second method instructions here
#archived-shaders message
the style that turns pink and tells you reinstall
This is not true for unlit shaders. It only renders pink if you have a shader with an unsupported pass type, like ForwardBase, because those are for the built-in RP.
For simpler geometry, where you have some faces inside other faces, you can use Blender to reorder the triangles so that the inner most triangles are drawn first, and then out from there. That will guarantee correct transparency.
But not all geometry is guaranteed to be that simple.
Fragment shader can be very simple (like "return 1;") and very complex (like Lit). And becuse of big complexity of Lit it is hard to do it manually. But at end this is just equivalent shaders in terms of structure, in/out data, etc.
I am trying to try these two things but I cannot find any Zwrite property, googling it all the answers are from 2019+ saying its impossible
there is depth write, and depth test
but neither of those say ZWrite to them
No, you cant, unfortunately. Because correct order when viewing model from one side will turns into incorrect when viewing from opposite side.
Should be here
Oh okay, in that case I DID find it, I just didnt realize they renamed it
Me neither!
it still looks kinda janked up if you see a setting I set wrong
also after bringing in the OIT package, all of unity is lagging severely badly, I cannot even pan camera smoothly
going to delete it and restart unity
You can expect faces to render through the mesh even with ZWrite but they'll at least be the correct faces
Here's 1. default alpha blending 2. zwrite 3. empty pass
I mean that default alpha blending already looks 10,000* better than this thing
As long as you're only rendering the front face, like in the cube inside a cube example, the triangles of the inner cube should always be drawn before the triangles of the outer cube.
Better in which way?
It doesnt appear to be a hideously janked up mesh of faces overlapping themselves, yours that is
In my first leftmost example as well as your earlier one the faces from inside the mesh were rendered in front making it look all jumbled in my opinion
Yeah that one looks jumbled compared to middle and far side
In any case it depends on the mesh and how intertwined the polygons are which method suits it sufficiently
Maybe I should try to explore non-transparent materials that are just inside out to fake transparency?
but this probably will just introduce a whole different bag of worms
Could work but probably hard to get it to look realistic so some heavy artstyling could be useful
@tight phoenix Have you looked at how lego games usually handle these kind of blocks? New and old both may have interesting techniques
I was looking at some of the lego 3d rendering builder playbox things but their transparency rendering was not very good
I guess it usually isn't, and I expect new games will be avoiding it entirely
because it's genuinely difficult
thats a good point though there are buttloads of videogames, my gut guess is they just dont bother doing translucent but Ill look for refs instead of guess
Yeah
the more research I do, the more I learn how to do transparency: don't do transparency
Basically so ๐ฆ
๐ฅ
anyone have an idea how I could make the speed of these accelerate over time? They're meant to act like waves on a beach so i'd like them to kind of gain momentum as they get closer to the shore.
I've been trying to use UV.y as the multiplier in the node after the time divide I've got it so that the quads along which the waves are supposed to be are going from Y =0 to 1 but it gives me a crazy fractal pattern.
This is based off Cyan's animal crossing water shader if anyone's experimented with that before. That subtract output feeds into the multiply input in the second screenshot. Been struggling and just getting all kinds of weird unexpected behaviour, would appreciate any help
Oit from github is working
Unfortunately it is not working in URP scene view
Unlit shader from that repository is very basic and need to be improved
Hm yeah I knew it only works in game view but mine didnt evne look like that, it looked like nothing
It looks to me that OIT is what you want. It's just sad that that package didn't work for you for whatever reason. It's isn't "free" of GPU runtime costs, but the technique is a weighted over/under blend that SHOULD theoretically handle these types of models. Too expensive for mobile though.
I just skimmed all of the above, so probably missed some things.
It isn't easy or cheap to do.
I will try upgrading to the latest version of unity and importing that OIT package to a fresh project, maybe thatll resolve any conflicts
can i make something like an array or list of colors in shadergraph?
not really
Can create arrays in a Custom Function node - https://www.cyanilux.com/faq/#sg-arrays
But depends what you intend to use it for. Perhaps just a gradient/palette texture would work?
yeah i just realized i could put the colors i want into a seperate image. gonna try that now
You can make a gradient parameter, or gradient constant:
Not exactly list, but can be used depending on your needs
i tried making a spritesheet out of my textures, but cant select the individual sprites
can only select the image containing them all
giving them all their own image does seem to work as intended, why doesn't the spritesheet work?
Learning how to setup custom lighting for the first time but I'm a bit confused on one thing.
The left is a standard URP Lit material and the right is one using custom lighting hlsl. I'm a bit confused on why the shadow is completely black. What should I be doing for the shadows to look similar to the Lit material?
It looks like you're missing the ambient light. URP uses an ambient probe for that, which is sampled the same way as light probes.
here an image of what im trying to do, im already noticing that depending on the sprite and texture i need to finetune the multiplication so the colors get applied correctly, is there any way to keep those 1 to 1? or am i just better of making different sprites for different colors?
Ah ha. Color is a bit off but that is a lot better. Thank you very much
how can i make my previews quads instead of spheres
Shader "Unlit/LinearDodgeShader"
{
Properties
{
[Header(Properties)]
_MainTex ("Main Texture", 2D) = "white" {}
}
SubShader
{
Tags
{
"IgnoreProjector" = "true"
"Queue" = "Transparent"
"RenderType" = "Transparent"
}
ZWrite Off
BlendOp Add
Blend SrcAlpha One
// Grab the screen behind the object into _GrabTexture
GrabPass
{
"_BackgroundTex"
}
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
// Vertex shader
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
float4 color : COLOR;
float2 bguv : TEXCOORD1;
};
sampler2D _MainTex;
fixed4 _MainTex_ST;
sampler2D _BackgroundTex;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.color = v.color;
o.bguv = ComputeGrabScreenPos(o.vertex);
return o;
}
// Fragment shader
float4 frag(v2f i) : SV_Target
{
// Sample the source and dst textures
float4 mainColor = tex2D(_BackgroundTex, i.bguv);
float4 blendColor = tex2D(_MainTex, i.uv) * i.color;
// Calculate the linear dodge (add) blend for each channel
mainColor.r = mainColor.r + blendColor.r * blendColor.a;
mainColor.g = mainColor.g + blendColor.g * blendColor.a;
mainColor.b = mainColor.b + blendColor.b * blendColor.a;
mainColor.a = blendColor.a;
// Output the final color
return mainColor;
}
ENDCG
}
}
FallBack "Diffuse"
}
I have returned... this is the updated version of an "Add" shader I'm making that should take the pixels of the _MainTex and add them with the pixels of the _BackgroundTex from the GrabPass. Similar to Photoshop's Add blending mode for layers. The adding of the RGB seems to be working just fine, even with duplicate instances of the same exact Texture2D with this shader applied. However, this shader is being used on textures in RimWorld that should be fading either in or out and that part does not seem to be working properly. Can someone way cooler than me take a look at my code and the videos here and tell me what the hell I need to fix? lol The video of the projectiles shooting right is what should be happening, notice the fade out behavior. The video of the projectiles shooting down is with my shader above. :/
how do you make position nodes work for the y and z axis as well?
I am not followed previous discussion, can you point me why this grab pass is needed in this case?
Looking the videos seems you do overcomplicated stuff.
I need the GrabPass to get the pixels underneath the _MainTex since I'm not directly sampling any specific Texture2D underneath the _MainTex.
i believe there's a setting somewhere in the top right, might be a bit hidden
I've got an issue where the result of a compute shader doesnt match what the cpu produces.
I basically just pass a premade texture to both versions as input
They look the same when not doing anything
But once I simply multiply them by 2 they look different
One is a Texture2D the other one (compute shader) is a RenderTexture
I'm new to compute shaders (and rarely use RenderTextures) so it could be something pretty simple I didnt do
Thanks in advance!
This might be an sRGB issue. The texture might be gamma corrected on the GPU.
Is sRGB enabled on either texture?
Thy for the response!
This is how I make it, not sure what the answer is. Sorry.
RenderTexture CreateRenderTexture()
{
RenderTexture renderTexture = new RenderTexture(_resolution, _resolution, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
renderTexture.enableRandomWrite = true;
renderTexture.filterMode = FilterMode.Point;
return renderTexture;
}
What about the Texture2D?
Texture2D texture = new Texture2D(_resolution, _resolution);
texture.filterMode = FilterMode.Point;
You will have to specify that as linear as well, it defaults to sRGB.
I'll try that, thank you!
It still looks a bit different
My bad
Thank you so much! I've been stuck on that for hours
im not having much progress with my shader for replacing spritecolors, im now thinking about replacing each of the 8 colors with their counterparts from a different texture, can i select which row to use by inputting different uv's? also im quite unclear on how much of a performance impact a shader like this will have. will all the sprites update once to the correct colors or is it continuously updated?
#archived-shaders message for reference
so, basically you wish to get colors from a palette using a grayscale image, correct?
also, for your performance concerns, that doesn't look bad, 4 texture samples isn't much
it is updated every frame, that's what shaders do, everything you add there is constantly calculated
this is just an early prototype, i will be adding a lot more stuff, + will have multiple characters with it on screen
but it's way better than having separate sprites for each color
What do you mean by lot more stuff?
clothing sprites and normals will be added here aswell
that would probably still be fine
if it is updating everyframe i dont think i can get away with calculating every color seperately, alternatively can i link a float to each of my textures somehow? i noticed that each sprite needed its own adjustment so the colors will be applied correctly
why would you need adjustments? don't you have color palettes for each character?
aren't the color palettes applied in the same way on the same pixels in every variation?
i noticed that on the same settings (1.0 f.e.) my character will look fine but the hair is messed up i think it has to do with how detailed the different sprites are and more detailed ones needed a higher value
or now that i think more about it, its probably because of the different greyscale values of the original colors that need to be corrected
i could probably circumvent that by feeding it greyscale images directly
the greyscale values should be evenly distributed along the gradient
that way you don't have to voodooo magic multiply them
like, on a grayscale gradient if you were to put your grayscale values gathered by a magic process from an already colored sprite they will be placed like this
but to sample from a palette you'd need these values evenly spaced like this
(imagine I didn't place those by hand and they are actually evenly distributed)
because if we have this blue-ish palette I just made up
lol yeah i see what you mean, ive just been going with colors that feel right. ill try to make a color palette for my spritework that keeps the greyscale values in mind, i think i can get the desired effect that way
you can see that the evenly distributed ones have actual palette values while the top ones are just picking them kinda randomly
yep, that should do it
thanks for the help! much appreciated
np! for a streamlined process for each pixel you could check which palette index the color is assigned to, and do index / paletteSize * 255 to get a correct color
and make a sprite with this that is only grayscale, no color ๐
was thinking of making some color palettes with still some color but with standardized greyscale values but not sure on how to influence the color without changing that greyscale ( in aseprite)
ive looked into that before but couldnt really find an answer, just painting with greyscale will be kinda hard to imagine what the end result will be like
I cannot find really any info on this online. If I make an intersection shader, all the tutorials are dependent on it working based on the distance from the camera to the object. But how do I make it work no matter what?
hello how can i access the color node from the editor i want to multiply it with the sample texture 2d but i can't figure out how
According to your shader you don't do any image distortion. I don't understand why you don't use plain ordinary alpha blending?
I actually just fixed it. lol
also, why can i abritrarily not connect the same output/input when ouputting to the vertex group?
I don't expect this to even really do anything, but i feel like it should let me if they're both 1 channel
The only way to do that would be using SDFs which would either be a) static and baked b) expensive to calculate realtime, also both would have a large memory requirement
Unreal engine has a way of automatically generating the SDF I think but maybe only for static objects, not entirely sure
There's also a Unity asset that does it called Erebus I think
I see. Is what I'm trying to figure out how to do impossible then? I want this:
Black is a polygon. Blue is what appears on that polygon at the intersection with the red object.
is the red object always a sphere or sphere-like?
or is the blob always this undefined
like the shape of it
it would always be sphere like
because you could send the shader a list of positions and based on that find the minimum distance
find the minimum distance?
iterate positions, calculate distance and find the minimum of the distances
that's how close your surface is to an object
I'm sorry, i think I'm misunderstanding something. Why would I want to find that?
You want to make a blob based on distance to the surface, no?
that's kindof what an intersection is
not exactly, but in the shader world you can get away with approximations usually
oh, yea I suppose.
ShaderGraph doesn't make it very clear, but there are certain nodes that cannot be connected to the Vertex Stage, only the Fragment one. Such as the Scene Depth node here. I've got a few more listed here : https://www.cyanilux.com/tutorials/intro-to-shader-graph/#fragment-only-nodes
Can also check the documentation by right-clicking a node, that should tell you if it's limited to the fragment stage.
I'm pretty sure he's referring to the fact that the distance is usually view-dependent
because it is calculated from the camera
but, let's say this, there's no way to do this?
kinda looks like two of your objects next to eachother
this is top down. But if it was 3D, the blue would only be on the black plane.
basically have some way to.. well get the intersection of those two objects. But on the tutorials online are dependent on how close the camera is so it ends up changing how it looks as the camera moves around.
yeah, like how shoreline foam is made
usually
but!
if your black area is flat
there's a trick
you could also use a top-down camera to render the objects, and then it's independent of view
yea a shoreline. Sorry, maybe I should have just said that. All the videos seem to not work for me. My camera in the game is going to be a bit farther away, and it stops working when it's pulled back.
oh you are actually making a shoreline? ๐
yea, essentially. It might turn into something else.
okay, so for a shoreline all you need is a top-down ortographic camera rendering the objects, and a shader to blur the rendered result. you'd also use a replacement shader that renders pixels closer to the surface white and far pixels black in this special camera
If the shores don't change or have to overlap, the shore could be UV mapped, or have a simple vertex color to determine distance to from inner edge to outer
yeah it could be static like that
would it be easier if the water didnt have to be transparent? Ik that sounds weird...
or a combination of the two
Making 2D SDFs at runtime is also much simpler than 3D ones, for if the shore needs to change
I think flood fill algorithms can be used for that
not really I don't think
or blur it with URPs bloom shader ๐ maybe it's more efficient if it doesn't have to be precise, cause of the mipmap-chain like structure
anyhows, it's not a begginer friendly topic, but a great learning project, so if you got the time go for it
yea, unfortunately. I've only ever worked on basic stuff and only in the shader graph, not shaderlab.
I think I'll just shortcut it for now and basically use a plane with a little simple shader on it, since i know how all my objects in the water will look like. I do have one idea that I think i can do though....
what about something like this, but only on this plane? (i.e. it won't ever render on anything else)
like, so it won't render on this cube
how do i replicate that old analog tv visual effects you see here, where the screen fizzles, you see that scanline rolling down the screen?
specifically that lone scrolling scanline, so subtle yet cool!
actually, I got that working with a camera stack. Thanks for your guys's help so much!!!
I took a crack at trying to get this quad renderer shader going and im hitting some snags still. Can you confirm if I have translated this function correctly into shader nodes?
I am having some trouble still, and I am not sure if my issues stem from the shader being wrong (the above) or if the code that encodes the barycentric values into the vertexes is at fault
I've gotten it to render triangles correctly so I think the shader is correct, but when I try to encode the extra data to eliminate the longest edge of each triangle (in order to create quads) it turns fucky (pictured left)
I'm going to thread this as its getting lengthy
Encoding Barycentric coordinates into vertex colors
Someone have an easy solution to make shadows appear again on a mesh, that uses (vertex colors and) the vertex shader provided by unity?
If there's no other solution I might just plant a dummy mesh inside the vertex color one to provide shadows, unless there's some better way.
What do you mean by "vertex shader provided by unity"?
Which render pipeline are you using
how to render textmeshpro as opaque instead of transparent renderqueue?
What to use when shader works well on quad but not on circular quad
I'm having a little bit of difficulty trying to find the exact specification of the RGBA_8 format for each platform. It's obviously 8 bits per channel, but how is this mapped to the (0,1) range? is it [0,1)? (0,1]? I'm assuming something like 256 values, 0 and 1 inclusive, fixed precision?
is there any way I can make a shader like this? Like a volume that can addapt to custom meshes
im trying to palette swap through a shader, when the shader decides which colors of the palette should go where does it compare greyscale values and gives it the closest one, or do greyscale values link to the index of the texture?
More like the latter. You're using the greyscale/red values as the X coordinate of the UV - those coords are the normalised position of where to lookup on the texture. X=0 being the left edge and X=1 being the right edge.
thank you, wanted to confirm that before i redo all my sprites
If the mesh has rounded/smooth normals you might be able to cheat it somewhat by using a Fresnel Effect.
Otherwise volumetric stuff usually requires raymarching through signed distance fields. I think there are methods/tools to bake 3d SDFs from meshes, but you'll probably need to google for that.
Yeah, I was thinking of that. But I can't get the fresnel effect to apply to the alpha
I use URP, I got the code (for the shader) for visualizing vertex colors from here https://docs.unity3d.com/Manual/built-in-shader-examples-vertex-data.html.
The Unity's vertex color shader is good, in an unlit style it seems - it just doesn't cast or receive shadows. My goal would be to at least cast a shadow and maybe even receive some.
Edit:
Got something close to what I wanted when messing around enough with shader graph.
So in a perfect world I'd like to be able to generate a 3d grid of cubes, which then get destroyed if they are outside a given mesh. I guess one way of doing this could be using the pcache tool on a mesh that has vertices exactly on a grid, but would it be possible to do this procedurally, I'm thinking in VFX graph. I don't see volume as an option in position mesh. obvs position sequential 3d can make the initial grid.
why this shader batches are in transparent drawcalls?
Because Queue is set to Overlay.