#archived-shaders

1 messages ยท Page 52 of 1

cosmic prairie
#

if it doesn't, subtract a constant from the height you just got

#

but maybe it'd be better if it was distance ๐Ÿค”

#

or idk, just see what it does

restive lava
#

it's a bit closer but still i think i can make it better

grizzled bolt
#

SDF textures could likely be a much better option than procedural noise

restive lava
#

this isn't too bad either except too bright

meager folio
#

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?

frail seal
#

yeah i think there isnt, people have to make their own

grand jolt
#

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.
grand jolt
#

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.

meager folio
grizzled bolt
languid kelp
#

okay, I will post it there. I thought that maybe somebody knows a way how to import the blender stuff on an alternate way.

barren stratus
#

any idea where i can get a voronoi tilable texture?

#

want to use it for my thuder storm and dash

shell wing
#

I just learned that the procedural shapes can't be used in the vertex stage, is there any workaround there? ๐Ÿค”

regal stag
lunar valley
#

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;

tight phoenix
#

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

#

Oh I see its normalized by default now

pale python
#

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 ?

regal stag
pale python
split oyster
#

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

shadow locust
#

note that the result of this will be a float3x3 aka 3x3 matrix

split oyster
#
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

split oyster
split oyster
meager pelican
#

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.

meager pelican
#

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.

tight phoenix
#

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

vocal narwhal
tight phoenix
#

like macros for something else maybe ๐Ÿค” but if its just math that explains a lot

split oyster
rare wren
#

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

lunar valley
rare wren
#

Maybe ask on the forums, I'm not too sure

meager pelican
#

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.

lunar valley
#

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??

meager pelican
#

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.

tacit parcel
#

will duplicating the player's mesh work? like one only receive shadow, and one is hidden and only cast shadow?

ebon basin
#

Recieving shadows and blocking self shadows seems pretty hard. I've been stuck at trying to find a solution myself for a while now.

meager pelican
#

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.

ebon basin
#

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.

meager pelican
#

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.

ebon basin
#

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

tacit parcel
#

decals + render texture could work ๐Ÿค”

meager pelican
#

Still sounds like you can do it with the standard system.

  1. 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.
  2. The ground shadows itself from either A) both the baked and dynamic shadow maps or B) a totally dynamic shadow map that includes everything.
  3. the other objects ignore shadow maps entirely.
stable nexus
#

how can i preview shaders in gameview without running the play button ?

lunar valley
#

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;

primal cedar
#

need a little help as to why my skybox material is just making everything black?
it works on gameobjects but not the skybox

meager pelican
lunar valley
#

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

meager pelican
#

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.

lunar valley
# meager pelican OK, but therein lies another possible point of...differences. IDK why it would j...

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
meager pelican
#

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.

lunar valley
meager pelican
#

I get that the camera is moving.

#

There's the shader source:

final wyvern
#

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

amber saffron
final wyvern
amber saffron
final wyvern
#

hmm alright

lunar valley
# meager pelican I get that the camera is moving.

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;

stiff adder
#

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)

amber saffron
stiff adder
#

As you can see here, when i look from above the line changes in width and I need it to stay uniform

amber saffron
#

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

stiff adder
#

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?

amber saffron
#

If it is only for a single object, you could just use a dedicated shader for it.

#

On the object itself

stiff adder
#

I'd like to do that, but I just don't know how to make a line shader like this

amber saffron
#

A very simple plane intersection is done like this step( dot(position, normal) + offset, lineWidth) (try to translate to nodes :/ )

stiff adder
#

Wouldn't that yield the same result? If I use a plane to do this it would have the same issues im facing rn

amber saffron
#

No, because this is to render on the object directly, and will give an object (or world) constant thickness

stiff adder
#

So you're telling me I can do a plane intersection shader on a mesh without actually having a plane in the scene?

amber saffron
#

Yes ๐Ÿ™‚

#

A plane intersection can be done with a shader with pure maths

stiff adder
#

Interesting! tysm

remote prawn
#

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.

amber saffron
remote prawn
amber saffron
#

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

remote prawn
amber saffron
remote prawn
#

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

amber saffron
remote prawn
#

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?

amber saffron
limpid edge
#

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?

regal stag
limpid edge
#

thanks, will try that ๐Ÿ™‚

tight phoenix
#

Question about refraction, what value should I be using when total internal refraction is occuring? ๐Ÿค”

#

regular surface normal? Something else?

frail seal
#

writes

        Stencil
        {
            Ref 64
            WriteMask 255
            Pass IncrSat
        }

reads and should discard

        Stencil
        {
            Ref 64
            ReadMask 255
            CompFront LEqual
        }
#

what am i missing

tight phoenix
#

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?

frail seal
#

same happens if you use split/append (or combine) nodes?

#

i dont know how they are called is sg

tight phoenix
#

kind of makes the string return worthless but using file is so much more upfront work ๐Ÿค”

tight phoenix
frail seal
#

oh you are making custom nodes

tight phoenix
#

Yeah

frail seal
#

there are nodes that combine values

#

basically casts

#

and split separates channels

#

or break

#

dont have access to sg to check names

regal stag
#

I assume you want refractDirection there instead

tight phoenix
#

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

tight phoenix
clear flicker
#

guys, how would i make graphics like this in a unity project?

grizzled bolt
tight phoenix
#

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?

grizzled bolt
regal stag
#

I think it's because you're using IOR as a function input, as well as a property name

tight phoenix
regal stag
#

Well that's a complete guess really, but I don't see anything else it could be

tight phoenix
#

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

regal stag
#

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.

tight phoenix
#

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

tight phoenix
#

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

bold yacht
#

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 ๐Ÿ˜ฆ

tacit parcel
meager pelican
warm rapids
#

is it possible to randomise the alpha mask in shader graph?

cosmic prairie
#

but random is a pretty broad term

#

there's all kinds of noises, voronoi is one that is also commonly used : )

warm rapids
#

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.

cosmic prairie
#

Oh, so you wish to choose one of them randomly?

warm rapids
#

yeah

cosmic prairie
#

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

warm rapids
#

my only other idea was to just have two particle systems, half the particle count and change the 2nd to a different alpha lol

hexed sigil
#

Hello~
I see generated code from Shader Graph always has 2 sections of HLSLPROGRAM, why have 2 instead of 1?
Thank you

flat hedge
#

Hi, I wanna fill this cube from bottom to top depending on the Essence Fill value.
How can I do that?

fringe pelican
#

Hey, I made a swirling noise kind of thing but I'd like to pixelate it. How can I combine these two things?

regal stag
regal stag
fringe pelican
#

Oh damn, that easy

regal stag
#

Also that pixellation calculation can be done using the Posterize node, if you want to make it simpler

fringe pelican
#

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

regal stag
#

That'll remove the decimal parts of the value, so the random value only changes with each integer. The divide will then work too

fringe pelican
#

Ah, floor times n for n changes per second then

#

Time is in in seconds, isn't it?

regal stag
#

Yea

fringe pelican
#

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

regal stag
fringe pelican
#

I am in URP, yeah! I'll take a look, thanks a lot

flat hedge
#

nvm, it didn't work actually, works ony if the object it os Y 0 0_o

plain urchin
#

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?

scarlet pulsar
#

How ComputeFogFactor fucntion can be implement in shader graph?

regal stag
regal stag
plain urchin
#

Yes saw that haha..

regal stag
flat hedge
#

is it like relative to the origin or the mass of the object?

regal stag
flat hedge
#

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?

regal stag
flat hedge
#

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

regal stag
#

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)

flat hedge
#

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?

terse osprey
#

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.

karmic hatch
terse osprey
#

i am seeing this mesh inside my 3d program, in this case cinema4d. and i am sure i am seeing the vertex colors

karmic hatch
#

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.

terse osprey
karmic hatch
terse osprey
#

here is inside unity

regal stag
terse osprey
regal stag
# flat hedge That's the part I am having trouble understanding, I thought it returns the posi...

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.

regal stag
terse osprey
#

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.

flat hedge
#

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...

regal stag
flat hedge
regal stag
#

The sphere will be -0.6ish to 0.6ish, the cube is -0.5 to 0.5 exactly

flat hedge
#

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:

regal stag
#

Yea, you may want a small offset to avoid floating point differences in the comparisons.

flat hedge
#

Thanks a lot for your help!

lunar valley
#

how can I get heart shaped or star shaped bokeh blur, I have only found a kernel for circular bokeh blur

limpid edge
#

hi, what is the difference between Normals and DepthNormals pass?

modern belfry
#

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?

limpid edge
#

What does UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX do?

smoky widget
#

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?

sharp cloak
#

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?

smoky widget
#

Texturing

split oyster
#

is there a way to sum all elements of an array to a single element in compute shaders?

fringe pelican
#

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

meager pelican
# fringe pelican 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.

fringe pelican
#

Hm, I see.. I'll try the first way, thanks a lot!

jagged lodge
#

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 :]

jagged lodge
#

HDRP at the moment.

meager pelican
#

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?

jagged lodge
#

Both honestly

split oyster
#

is there a way to sum all elements of an

jagged lodge
#

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

meager pelican
jagged lodge
#

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

meager pelican
#

IF I were you, I'd be creating benchmark scenes and in at least 2 pipelines.

jagged lodge
#

That would be too smart

meager pelican
#

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.

jagged lodge
#

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?

meager pelican
#

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.

jagged lodge
#

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

meager pelican
#

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.

Medium

An Exploration of GPU Silhouette Rendering

jagged lodge
#

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

meager pelican
jagged lodge
#

0 being highlight worked fine for the non graph version. Tried both orientations with the graph version, neither version rendered the yellow material.

meager pelican
#

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.

jagged lodge
#

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

jagged lodge
#

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

stable nexus
#

is there a good resource to learn shader ? (coding shader not shader graph)

summer sparrow
stable nexus
#

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 ?

grand jolt
#

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
  • return Base
  • Grab Pass : GrabBase
  • Second Pass : LightMode -> ForwardAdd
  • return GrabBase + 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.

lunar valley
#

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

royal crane
#

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,

grizzled bolt
royal crane
#

thx very much my friend

cursive spade
#

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.

smoky widget
#

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?

cursive spade
#

Hey everyone is there a way to visualize

vivid fable
#

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?

cosmic prairie
vivid fable
#

Would it even work in editor if that wasn't setup correctly?

vivid fable
#

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

karmic hatch
simple pagoda
#

Don't just say hi

#

Ask question

slim junco
#

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?

cosmic prairie
ancient oriole
#

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?

cosmic prairie
#

is that not a 3D object?

ancient oriole
#

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

split tangle
#

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.

grizzled bolt
ancient oriole
#

Shadergraph can do most simple things like blender

#

Yep, wrong terminology using "sprite"

grave vortex
#

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

split tangle
ancient oriole
#

shader graph is Unity's shader building tool

split tangle
#

ah

#

okay let me check if i can figure it out!

#

is it this one?

ancient oriole
#

aye that be it

split tangle
#

noice!

#

do i now make new > empty shader graph ?

#

oh my

#

that editor is crowded o.o

wispy edge
#

Dose someone knows why dose my png sprite looks like this in the shader graph?

Even that in the scene looks normal?

wispy edge
#

how can i place the multiply outline on front of the texture?

raven hamlet
#

Is there a best practice for modifying standard shaders? Do I just need to copy the URP shader folder into my project?

grand jolt
limpid edge
toxic bluff
#

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?

limpid edge
sharp cloak
#

My shader is alphatest and shows objects behind it even if the return color is 1,1,1,1; what could be wrong?

dim yoke
#

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

sharp cloak
#

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

lilac mist
#

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.

limber imp
#

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.

lilac mist
low lichen
limber imp
#

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.

slender gate
#

i was messing around with custom shaders and SRP. Now for some reason if theres no ground, this happens. so strange.

slender gate
#

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

latent rampart
#

does URP not support non URP shaders?

limber imp
latent rampart
#

That is doing a whole thing

round hedge
#

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?

cosmic prairie
#

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

round hedge
regal stag
round hedge
regal stag
# round hedge 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.

regal stag
# lilac mist I see a lot of people recommending I base my custom shaders for UI elements off ...

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.

lilac mist
#

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?

regal stag
#

Shader code would be recommended. Though the first link I posted has some workarounds if you really want to use a graph

silk sky
#

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

grizzled bolt
silk sky
#

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?

grizzled bolt
silk sky
#

nvm I used alpha

#

the result seems good enough

raw frigate
#

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

regal stag
raw frigate
silk sky
#

Is it possible to create a simple 2 color gradient from shadergraph withtout having to use a mask?

amber saffron
silk sky
#

so I guess I need an external mask to make the gradient

amber saffron
silk sky
#

Oh, didnt knew that, let me try

sudden spear
#

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?

silk sky
#

Nice trick, thanks @amber saffron

glacial horizon
#

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.

Gist

GitHub Gist: instantly share code, notes, and snippets.

#

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

amber saffron
glacial horizon
#

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 ๐Ÿ˜„

amber saffron
#

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.

glacial horizon
amber saffron
glacial horizon
#

Thanks, i'll see how to use the frame debugger

raw frigate
#

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?

amber saffron
raw frigate
#

ok thanks, i will try following his exact steps but on shader graph, and hopefully it will work :P

glacial horizon
amber saffron
#

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 ?)

glacial horizon
halcyon panther
#
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.

polar stone
#

Does anybody here know how you would achieve a crystal shader for 2d sprites in unity?

civic lantern
sudden spear
civic lantern
sudden spear
#

Ooh wait you mean the new Color32() arguments are between 0 and 255?

raw frigate
#

Does anyone know if its easy to create this effect where light reveals objects in shader graph? or very hard

civic lantern
#

Yeah exactly @sudden spear

sudden spear
#

I'm stupid ๐Ÿคฆ

#

Thank you! ๐Ÿ™‚

raw frigate
sharp cloak
#

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?

limpid edge
#

Hi, is there a way to render the scene into a texture without shadows using context.DrawRenderers?

sharp cloak
#
  // 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);```
cosmic prairie
#

theres a bit of messing around with custom hlsl blocks since you cant access much lighting data

#

in shader graph

sharp cloak
#

instead of fading each chunk by itself, it should be fading the entire chunk if it's away from camera

scarlet spear
#

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?

polar stone
#

Guys does anyone know how to achive a crystal shaderin 2d?

scarlet spear
#

ive tried installing more noise packs but all of them show up grey, does anyone know why?

karmic hatch
karmic hatch
sharp cloak
#

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?

scarlet spear
karmic hatch
#

the slot is the input

scarlet spear
#

wait nvm i updated unity and it fixed

sharp cloak
# sharp cloak I'm currently using TRANSFER_SHADOW_CASTER SHADOW_CASTER_FRAGMENT TRANSFER_SHA...

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?

buoyant geyser
#
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?
buoyant geyser
#

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)

limpid edge
#

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?

tight phoenix
#

are there any known useful guides/breakdowns on transparency best practices? It seems very easy to get really messed up results

vocal narwhal
tight phoenix
tacit parcel
#

in.uv += ParallaxOffset(...);

fleet olive
#

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

cosmic sphinx
#

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

opaque cipher
#

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

regal stag
regal stag
stable nexus
#

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 ?

amber saffron
stable nexus
#

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

halcyon panther
limpid edge
craggy ledge
#

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?

frigid jay
magic raptor
#

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?

frigid jay
buoyant geyser
#

Tyvm, Iโ€™ll give this a shot when I get home

#

I assume though that this could effect hardware compatibility

frigid jay
buoyant geyser
#

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

raw frigate
#

i have light pos, direction and angle, how should i go about using these to make a light reveal an object?

#

like shown here

amber saffron
raw frigate
#

position of the object thats being revealed or?

amber saffron
raw frigate
#

ah this top node right here minus the light pos? ok thanks can do!

amber saffron
raw frigate
#

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

tight phoenix
#

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?

regal stag
tight phoenix
# regal stag In newer versions SG seems to create a Material asset under the graph asset. It'...

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??

regal stag
#

The object probably wasn't using that material, but the auto-generated one

tight phoenix
#

oh the shader itself unfolds into a material UnityChanThink I have never once seen a shader do this

regal stag
#

Yep it does that now

tight phoenix
#

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! ๐Ÿ‘

raw frigate
raw frigate
#

Ok i think its working now!!!!

#

Thanks for the help!

magic raptor
#

Hi, masking doesn't work when I add ui shader, can you help me?

regal stag
flat hedge
#

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?

raw frigate
#

how to change black to white?

flat hedge
#

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 :/

raw frigate
#

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

flat hedge
#

yeah I was just thinking about that, then just multiply with a completely white color to fill the rest of it

raw frigate
#

yea but howd i do that then, lol

#

like its got R,G,B,A

flat hedge
#

you can get separate channels from the texture by using the sample texture node

raw frigate
#

mhmm okay

#

im so confused as to how

#

i would create the new texture but with Alpha being 0

flat hedge
#

let me try it rq

raw frigate
#

ok thx

flat hedge
#

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

flat hedge
# raw frigate ok thx

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

raw frigate
#

its kinda working, but now

#

how can i eh

#

change that red to black

#

lol

flat hedge
#

you have to play around with the range and fuzziness parameters

flat hedge
#

invert might work but afaik invert literally inverts the color, black would become white and red would become greenish or sm

raw frigate
#

the coulour could be red, green, blue etc

flat hedge
#

I am not entirely sure how you'd achieve that tbh(it's 100% possible)

raw frigate
#

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

regal stag
raw frigate
#

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

raw frigate
#

oh well its al lgood anyways

karmic hatch
# raw frigate

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

raw frigate
brittle bolt
#

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?

tight phoenix
#

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

grizzled bolt
tight phoenix
#

Ill google how to bake them into the vertex colors then I suppose

tight phoenix
#

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

tight phoenix
#

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

grand jolt
#

sorry to bother but ill have a shader problem and would like to ask if someone has 4 minutes spare time...

grizzled bolt
tight phoenix
#

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

grizzled bolt
tight phoenix
grave vortex
#

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.

karmic hatch
# tight phoenix I am aware all polygons are two triangles, the flatshaded normal map does show t...

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...

โ–ถ Play video
#

(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)

tight phoenix
regal stag
# fleet olive why tinting versus swapping?

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.

fluid salmon
# regal stag Mostly as multiplies will be cheaper than the length() calculation that the Repl...

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

regal stag
fluid salmon
#

(to the first part of your statement)

regal stag
fluid salmon
#

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

proper hornet
#

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.

fleet olive
#

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?

grizzled bolt
marsh dust
#

#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 ^^

karmic hatch
# proper hornet I had this toon shader setup in blender- i was wondering if anybody could help m...

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

hearty obsidian
#

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?

supple ledge
#

is there a way to exclude an unlit material from receiving the fog pass?

tight phoenix
#

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..

regal stag
# tight phoenix

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)

tight phoenix
# regal stag Shader graph expects the custom function (in the hlsl file) to be named `<name>_...

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

regal stag
#

You have 4 inputs on the Custom Function node, but only 3 in the code

#

I assume the "r" one isn't needed

tight phoenix
#

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

tight phoenix
#

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

low lichen
fluid salmon
#

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?

tight phoenix
toxic kettle
#

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...

regal stag
regal stag
toxic kettle
toxic kettle
fluid salmon
tight phoenix
#

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

tight phoenix
#

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

true ocean
#

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

tight phoenix
true ocean
#

ok thanks

tight phoenix
#

this is the distance through a cube

#

and so far I havent gotten a single successful output

fluid salmon
#

im sorry man i wish I could help

#

i feel your pain

tight phoenix
#

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

tight phoenix
#

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

tight phoenix
#

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

grizzled bolt
tight phoenix
#

i spent 9 hours trying to go from a cube to a capsule and it just didnt go anywhere and hurt, a lot

grizzled bolt
frigid jay
tight phoenix
frigid jay
grizzled bolt
#

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

tight phoenix
grizzled bolt
low lichen
tight phoenix
tight phoenix
frigid jay
#

To properly handle internal holes we can mark face-forward and face-backward pixels separately based on normal (for example)

tight phoenix
#

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

grizzled bolt
#

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

tight phoenix
#

maybe?

#

looking at that oit github now

round hedge
#

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.

grizzled bolt
# tight phoenix maybe?

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)

tight phoenix
#

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

tight phoenix
frigid jay
#

I will look at this OIT technique, and maybe can give some advice

tight phoenix
grizzled bolt
tight phoenix
#

the style that turns pink and tells you reinstall

low lichen
#

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.

frigid jay
tight phoenix
#

there is depth write, and depth test

#

but neither of those say ZWrite to them

frigid jay
tight phoenix
#

Oh okay, in that case I DID find it, I just didnt realize they renamed it

grizzled bolt
#

Me neither!

tight phoenix
#

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

grizzled bolt
tight phoenix
low lichen
tight phoenix
grizzled bolt
#

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

tight phoenix
#

Yeah that one looks jumbled compared to middle and far side

grizzled bolt
#

In any case it depends on the mesh and how intertwined the polygons are which method suits it sufficiently

tight phoenix
#

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

grizzled bolt
#

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

tight phoenix
grizzled bolt
#

I guess it usually isn't, and I expect new games will be avoiding it entirely
because it's genuinely difficult

tight phoenix
#

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

grizzled bolt
#

Basically so ๐Ÿ’ฆ

tight phoenix
#

๐Ÿ”ฅ

fluid salmon
#

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

tight phoenix
#

Mecabrix isn't doing much better than I've gotten

frigid jay
#

Unfortunately it is not working in URP scene view

#

Unlit shader from that repository is very basic and need to be improved

tight phoenix
# frigid jay

Hm yeah I knew it only works in game view but mine didnt evne look like that, it looked like nothing

meager pelican
#

I just skimmed all of the above, so probably missed some things.

#

It isn't easy or cheap to do.

tight phoenix
tender edge
#

can i make something like an array or list of colors in shadergraph?

regal stag
tender edge
frigid jay
#

Not exactly list, but can be used depending on your needs

tender edge
#

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?

chilly robin
#

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?

low lichen
tender edge
#

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?

chilly robin
fluid salmon
#

how can i make my previews quads instead of spheres

halcyon panther
#
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. :/

vagrant hill
#

how do you make position nodes work for the y and z axis as well?

frigid jay
#

Looking the videos seems you do overcomplicated stuff.

halcyon panther
karmic hatch
slim steppe
#

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!

low lichen
#

Is sRGB enabled on either texture?

slim steppe
# low lichen 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;
    }
low lichen
#

What about the Texture2D?

slim steppe
#
        Texture2D texture = new Texture2D(_resolution, _resolution);
        texture.filterMode = FilterMode.Point;
low lichen
#

You will have to specify that as linear as well, it defaults to sRGB.

slim steppe
#

I'll try that, thank you!

slim steppe
slim steppe
#

Thank you so much! I've been stuck on that for hours

tender edge
#

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?

cosmic prairie
cosmic prairie
#

it is updated every frame, that's what shaders do, everything you add there is constantly calculated

tender edge
cosmic prairie
#

but it's way better than having separate sprites for each color

cosmic prairie
tender edge
cosmic prairie
#

that would probably still be fine

tender edge
cosmic prairie
#

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?

tender edge
#

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

cosmic prairie
#

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

tender edge
cosmic prairie
#

you can see that the evenly distributed ones have actual palette values while the top ones are just picking them kinda randomly

tender edge
cosmic prairie
#

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 ๐Ÿ˜„

tender edge
#

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

radiant meteor
#

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?

mortal basin
#

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

frigid jay
halcyon panther
radiant meteor
#

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

cosmic prairie
#

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

radiant meteor
#

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.

cosmic prairie
#

is the red object always a sphere or sphere-like?

#

or is the blob always this undefined

#

like the shape of it

radiant meteor
#

it would always be sphere like

cosmic prairie
#

because you could send the shader a list of positions and based on that find the minimum distance

radiant meteor
#

find the minimum distance?

cosmic prairie
#

iterate positions, calculate distance and find the minimum of the distances

#

that's how close your surface is to an object

radiant meteor
cosmic prairie
#

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

radiant meteor
#

oh, yea I suppose.

regal stag
# radiant meteor also, why can i abritrarily not connect the same output/input when ouputting to ...

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.

cosmic prairie
#

because it is calculated from the camera

radiant meteor
#

but, let's say this, there's no way to do this?

cosmic prairie
#

kinda looks like two of your objects next to eachother

radiant meteor
#

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.

cosmic prairie
#

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

radiant meteor
#

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.

cosmic prairie
#

oh you are actually making a shoreline? ๐Ÿ˜„

radiant meteor
#

yea, essentially. It might turn into something else.

cosmic prairie
#

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

grizzled bolt
#

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

cosmic prairie
#

yeah it could be static like that

radiant meteor
cosmic prairie
grizzled bolt
#

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

cosmic prairie
#

anyhows, it's not a begginer friendly topic, but a great learning project, so if you got the time go for it

radiant meteor
#

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....

radiant meteor
#

like, so it won't render on this cube

austere pier
#

specifically that lone scrolling scanline, so subtle yet cool!

radiant meteor
tight phoenix
#

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

sturdy pond
#

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.

grizzled bolt
surreal locust
#

how to render textmeshpro as opaque instead of transparent renderqueue?

grim bloom
#

What to use when shader works well on quad but not on circular quad

teal breach
#

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?

heady mortar
#

is there any way I can make a shader like this? Like a volume that can addapt to custom meshes

tender edge
#

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?

regal stag
tender edge
regal stag
heady mortar
#

Yeah, I was thinking of that. But I can't get the fresnel effect to apply to the alpha

sturdy pond
# grizzled bolt What do you mean by "vertex shader provided by unity"? Which render pipeline are...

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.

hushed silo
#

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.

surreal locust
#

why this shader batches are in transparent drawcalls?

low lichen
grim bloom
#

Why shader doesn't work?

#

I have texture 2d property and then I access it in script and change it(in start method) but nothing happens

#

Then when in game mode I manually change it then it works bruh