#archived-shaders

1 messages · Page 201 of 1

grand jolt
#

for ever!

#

i think its due to depth buffer

#

the cameraobject became completely useless

#

its the third bug i had with depth buffers. also: the property binder script is completely useless for me

mental quest
#

Hey guys, can anyone tell me where am I going wrong? I see the matcap texture as pixelated on android build while it works fine in editor. Apparently it seems like UV precision glitch but couldn't find where I went wrong.

main coral
#

Thanks, I'll have a look at JetBrains then

mental quest
#

nvm fixed

#

i was using fixed for uv values. Fixed by changing it to float

main coral
#

Pretty irrelevant question, but how are shaders executed? Does the shader program run for all triangles of an object in parallel or does it run triangle after triangle? Or is it a mixture and per clock on the GPU as many triangles as possible are calculated until all of them are calculated?

full ravine
#

How do I get an output from a compute shader?

#

I'm very new and can't find a tutorial explaining how to get an output

lean lotus
#

in a compute shader, would it be better to have 1 large structured buffer, with a larger struct that defines it, or would it be better to split it into 2 structured buffers, with smaller structs for both?

craggy grove
#

hey guys, not sure if this is a shaders problem and probably is a really stupid one... I was trying to make some of my UI buttons fancier by adding a material but whenever I add one the button turns full black or just doesn't show the material right. I have searched on google, there are a lot of topics about this, tried many things but none work... I am really desperate something so simple and I've wasted so much time already. Anyone got any clue? really appreciated... thanks

vapid garnet
#

anyone know how to get nodes in shader graph to snap into alingment, it sais in the productboard it is implemented and the blue lines show up but the nodes dont snap to them

regal stag
vapid garnet
#

for some reason it doesn't work for me on any project on any version of unity

covert birch
#

Why can I not connect a Sample Texture 2D to my Normal Vertex?

regal stag
covert birch
#

Unlit Shader Graph.

#

works, thanks.

regal stag
#

If it's an unlit graph, why do you need a normal map?

covert birch
#

Yeah I just realized that.

#

:V

hazy sage
#

Where could I change that to have the voronoi effect colored ?

#

To have it looking like this :

#

instead of this :

#

Here it doesn't change anything :

#

And here it changes the whole color :

regal stag
vapid garnet
#

Lerp(sample texture RGBA, (color), voronoi)

hazy sage
#

Oh thanks ^^

#

It works thanks !

#

How could I make it way softer now ?

obsidian epoch
#

hey, ive got a bit of a problem with my shader

vapid garnet
#

multiply the voronoi by the color's alpha (use the A output of a split node)

obsidian epoch
#

ive made this cube in blender, and my plan is to normalize the vertices in a shader to make a sphere, and use a lerp to blend between cube and sphere

#

sounds pretty smart on paper right?

#

for whatever reason, though, normalizing the vertices causes this:

#

what could be happening?

vapid garnet
#

and change the color's alpha value (it defaults to 0 for some reason)

hazy sage
#

How do I do that ?

vapid garnet
#

select the color property and change the default value

hazy sage
#

Oh thanks!

hazy sage
#

Anyway I change this :

#

to this ?

#

It's not really an outline and I don't really know how to call it to search on google/youtube

tender wyvern
#

@hazy sage vignette?

hazy sage
#

Oh yeah thanks ! How did I not think of it

#

I can't find any tutorial xd

#

Found a way! The fresnel effect

tender wyvern
regal stag
#

Fresnel Effect isn't what you want, that is based on normals & view dir.
You can use a Distance node with the UV and a Vector2 set to (0.5, 0.5) to get a radiual gradient like that.

hazy sage
#

Oh I'll try that thanks

#

I was about to ask why it didn't work, when I saw you saying that fresnel is not what I want x)

#

oh, it doesn't work with tiling

#

@regal stag How could I change that ?

#

I have this

regal stag
#

Eh, I'm not really sure why it's cut off like that (is the Vector2 using the correct value of (0.5, 0.5)?
Also not too sure what you actually want to achieve either, before you just showed a radial gradient over a single tile. If you want it to outline multiple tiles as a group that's not easy.

hazy sage
#

(is the Vector2 using the correct value of (0.5, 0.5)?
Yep

main coral
#

I'm following the art of code's tutorial on ray marching and I don't understand this function that calculates the normal on a given point:

#

get_distance is the distance function and returns the distance to the object as a float

#

why would he subtract a float3 from a distance to get the normal?

#

wouldn't that have to be:

#

?

hazy sage
#

@regal stag I would like the shader to achieve something like this :

regal stag
# main coral

Not really an expert on raymarching, but the idea is to compare the distance field at the point p with similar points offset slightly in each axis direction. Subtracting the two distances basically gives you a sort of gradient/derivative to approximate the direction of the normal.

(This uses a similar idea too, but offsets in both directions : https://www.alanzucconi.com/2016/07/01/surface-shading/#step2)

hazy sage
#

Cyan? xd

regal stag
# hazy sage <@!357936113983291393> I would like the shader to achieve something like this :

Yeah that's not really something you can do in a shader. The data about where the edges are would need to be passed in through additional UV data or vertex colors.

Personally for something like this I'd look into creating a tilemap (as in, having the gradient/edge baked into the texture, providing multiple tiles that can be drawn, rather than just a single repeating one). e.g. https://blogs.unity3d.com/2018/01/25/2d-tilemap-asset-workflow-from-image-to-level/

winter mantle
#

Good evening everyone, Is it possible to have a sprite that completely occludes everything behind it? pretty much making an invisible hole to anything that is occluded by it? need this to implement an "erasing" feature in a transparent drawing board

My use case: I have a CanvasCamera pointing at a RenderTexture, i instantiate sprites in front of it to "draw" stuff, over a transparent texture, and i save that into a material after so many instantiated brushes, but now i need to be able to "paint transparency", i tried reading and setting the pixels alfa but it seems to expensive performance wise. so i'm trying to use the same idea of instatiating a brush (sprite) but have it somehow subtract everything that is behind it from the CanvasCamera

knotty juniper
#

you could try to sample the texture that generates the mask in a lower mip map value , that would blure the texture and probably soften the edges

real pilot
#

I just "downgraded" my project from 2021 back to 2020.3.7f1 for DOTS reasons, and now I'm not getting runtime recompilation/hot reload of a compute shader so I have to keep exiting play mode and restarting it to see changes made - I thought hot reloading was still a thing in 2020 wasn't it?

real pilot
#

Hmm it works if I refresh the .compute file in the project window, that's better than having to restart play mode!

meager pelican
# obsidian epoch ive made this cube in blender, and my plan is to normalize the vertices in a sha...

Did you get an answer? What pipeline are you in?
http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html
Here's an article, but you have to realize that he's talking about a cube with a length of 2 units per side (-1 to +1) for each dimension. So change your cube to be 2x2x2 with origin in object space at (0,0,0).
Then here's a sample vertex function:

        void vert(inout appdata_full v) {  // Called for object-space. 
            // we don't touch the size/scale of the original cube mesh.

            // Math is from http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html
            float x2 = v.vertex.x * v.vertex.x;
            float y2 = v.vertex.y * v.vertex.y;
            float z2 = v.vertex.z * v.vertex.z;
            float3 s = float3(
            v.vertex.x * sqrt(1. - y2 / 2. - z2 / 2. + y2 * z2 / 3.),
            v.vertex.y * sqrt(1. - x2 / 2. - z2 / 2. + x2 * z2 / 3.),
            v.vertex.z * sqrt(1. - x2 / 2. - y2 / 2. + x2 * y2 / 3.));
            float3 sphereNormal = normalize(s); 
            float3 sphereVert = sphereNormal * _Radius; // extruded/scaled vert
            v.vertex.xyz = lerp(v.vertex, sphereVert, _RoundnessPct);
            v.normal = lerp(v.normal, sphereNormal, _RoundnessPct);
        }

Including reference/credit to the site shown.
It has _RoundnessPct and _Radius as shader defines coming in.
You can duplicate that in Shader Graph if you want with relatively little effort, if you're in another pipeline. This one is from a surface shader that has a custom vertex function.

#

Scale it all using the game object's transform, if you want to scale it. You might want to change the way the radius works relative to object-transform scale, depending on needs.

meager pelican
#

See "builtin shaders" in the appropriate drop-down box.

#

@grand jolt

regal stag
#

It has cginc files in CGIncludes folder, but shaders are also included in the DefaultResourcesExtra folder.

#

In the built-in shaders downloaded from that link Carpe posted.

uncut valve
whole herald
#

Hi guys, i'm new here and i'm having an issue, i have followed this tutorial https://www.youtube.com/watch?v=dyiLJ1PFhM0, but shadows are not casting on the toon shader. The guy in the video said it's an issue with URP but i didn't understand the way to fix it. my unity version is 2019.4.8f1. Would be nice if someone could help

The Legend of Zelda Breath of the Wild has a beautiful aesthetic, characterized by the use of cel-shading.
Today we try to recreate his shader on Unity.

Repo:
https://github.com/ToughNutToCrack/ZeldaShaderURP2019.4.0f1

Roysten analisys:
https://roystan.net/articles/toon-shader.html

Sketchfab plugin for unity:
https://github.com/sketchfab/unit...

▶ Play video
regal stag
open flax
#

does anyone have an example of compute shader with texture sampler?

wraith wing
#

for game asset, is it common to not unwrap and set the mapping on the engine or is it much better if everything unwrapped?

dusk tapir
#

Ive started work on a 4D mesh renderer within Unity, it displays individual 3D slices of 4D geometry, but its pretty slow, roughly .0032seconds, or 1/5th of a frame for just a 4D cube, and was wondering if compute shaders would be a viable way to generate real time meshes

blazing grotto
#

I'm using Shader Graph with HDRP to create a Lit shader with a wind effect. It's working great, except that the lights I have in my tent are shining through to the exterior of the tent, which I don't want. This does not happen with the standard HDRP Lit shader. Anyone have an idea what might be causing this? Thanks for any help!

whole herald
blazing grotto
winter mantle
#

Good evening everyone, Is it possible to have a sprite that completely occludes everything behind it? pretty much making an invisible hole to anything that is occluded by it? need this to implement an "erasing" feature in a transparent drawing board

My use case: I have a CanvasCamera pointing at a RenderTexture, i instantiate sprites in front of it to "draw" stuff, over a transparent texture, and i save that into a material after so many instantiated brushes, but now i need to be able to "paint transparency", i tried reading and setting the pixels alfa but it seems to expensive performance wise. so i'm trying to use the same idea of instatiating a brush (sprite) but have it somehow subtract everything that is behind it from the CanvasCamera

meager pelican
#

Try turning blend off in transparent queue, and writing (0,0,0,0). That will probably require a different shader for that purpose.

If that doesn't work, and if you cannot write transparency any other way, you can always use a stencil to flag what you want to clear and blit to another pre-cleared transparent texture, skipping stencil areas, and then swap textures., and continue on. Swapping again when needed.

That seems like a lot of work, but if you're in opaque you cannot write to the transparent alpha that I know of. And if you're in transparent, you may need a special blend or these other techniques.

I suppose another way is to always composite layers, having a 0,0,0,0 background, or even a static color (so not a real layer) and then have a mask layer for erasing, and then stacking other layers on top. Or have each layer have its own mask layer.
Spitballing.

limber mica
#

how would i go about adding a bloom to a 2d pixel art sprite?

#

i want to be able to create a glowing green outline on a sprite to highlight it

limber mica
#

used a 2d light for that ^

mental bone
#

There is a complex lit shader that uses a height map use that one

marsh venture
#

I have one problem , that was after setting aniso level to 0 my Fps raise from 40 to 60 but my texture get blur , so I want my texture quality should be nice and also I want to aniso level to 0 , so there is any other ways do it in shader like texture2dlod or some other thing?

mental bone
#

Well if you dont want use the complex lit shader with a build in height map you need to sample your texture and add the values from it to the vertex position and feed that result into the position part if the vertex stage

#

If you want to use parallax offset the supply the texture sample as the height in that subgraph and add the output to the uvs of your other texture sampling

sinful shuttle
#

Is there a tutorial somewhere showing me how Unity builds a scene with Forward Rendering? I'm having issues getting a multi-pass shader I'm working on in Amplify displaying some weird shadow artifacts, but I can't find any documentation explaining the order stuff is rendered in Unity in detail, so I don't even know if the shadows are being rendered all at once in a pre-pass, or in a post pass after the albedo for each individual object in front to back order, or if transparent objects are drawn back to front but opaque objects front to back, and then lighting is rendered on top of them, and then shadows on top of that. I have absolutely no clue what order any of this stuff is being drawn in and the docs are no help. The only thing they describe in the second on the Forward Rendering path are what mode lights are rendered in if they're set to important or not important, but it makes no mention of shadows. https://docs.unity3d.com/Manual/RenderTech-ForwardRendering.html

silk cloud
#

Hey all, is there anything I have to do to get a shader graph to contribute and receive global illumination in URP? Haven't done a huge amount of testing yet but hoping there's a gotcha i haven't considered before I go and replicate in a clean project

#

using lit master node

#

Actually, it looks like baked lights are baking onto the shader, but none of the emissives are

regal stag
silk cloud
#

Yeah, I've tried that, thanks. It was about the only direction I could find googling, but it didn't seem to make a difference

marsh venture
#

Just tell one thing how to make shader like I want to display high clarity image within 50 m and low clarity image after 100m

lost stratus
#

hello everyone

#

i have a very dumb question

#

how do i add a texture that i downloaded from cco textures to unity ?

vocal oxide
#

How can i access the color property in shader graph? if i click on plus and choose an option i can only give it a name

lean lotus
#

so if I have a compute shader that renders to each pixel of a texture, each pixel requires say X function to be called Y times
Now lets say every time X function is called, it increments a number special to that pixel(so it counts how many times that function is executed)
Is there a way for me to get the TOTAL number of times that function is called across ALL pixels?

dense halo
#

hey how can i add a bump map to this

sacred stone
#

i have a feeling its something to do with with one-minus but im not sure

regal stag
sacred stone
#

Ahh I see, thank you, never used that node before

regal stag
regal stag
vocal oxide
#

@regal stag thanks mate, i found it 🙂

zenith bronze
#

Anyone know where I can get the doctrina fur shader, The website link is broken on youtube, and I can't find it anywhere else.

dusk tapir
#

hey, any ideas why this doesnt work:

struct vertices
{
    float3 verts[6];
    uint vertCount;
    void Add(float3 a)
    {
        verts[vertCount] = a;// Error Here
        vertCount++;
    }
};```Shader error in 'TetrahedralizeCompute.compute': array reference cannot be used as an l-value; not natively addressable at kernel Main at TetrahedralizeCompute.compute(20) (on d3d11)
sinful shuttle
#

I'm having some issues with self-shadowing on transparent objects. Is it possible to adjust the bias and normal bias on a per-shader basis? If I adjust the global values for my directional light I have to make them pretty high to remove the artifacts, but it causes shadows to not be pinned to objects on the ground any more, so I want to adjust it more on my transparent objects than on the rest of my stuff.

I've attached the shadow caster pass for my shader. Also, I've made this in Amplify, so if there's a way to do this within Amplify instead of editing the shader code directly, that would be useful!

wet lion
#

i have joined this server with the express purpose of asking why this basic depth buffer read isnt working

#
    SubShader {
        Tags{ "RenderType" = "Opaque" "Queue" = "Geometry"}

            Pass {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            v2f vert(appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                UNITY_TRANSFER_DEPTH(o.uv);
                return o;
            }

            sampler2D _CameraDepthTexture;

            float4 frag(v2f i) : SV_Target
            {
                float depthValue = LinearEyeDepth(tex2D(_CameraDepthTexture, i.uv).r);
                float4 depth = fixed4(depthValue, depthValue, depthValue, depthValue);

                return depth;
            }
            ENDCG
        }
            
    }
    FallBack "Diffuse"
}```
#

aaand here's my camera's script

using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
public class CustomRenderPass : MonoBehaviour
{
    public Material TestMaterial;

    void Start()
    {
        GetComponent<Camera>().depthTextureMode = DepthTextureMode.Depth;
    }
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        Graphics.Blit(source, destination, TestMaterial);
    }
}
#

sorry to ask people to read code, but ive scrounged around so much, and everything is so inconsistent because of all the changes to this stuff over the past few years, and I just can't get it ironed out

#

as of right now, depthValue which should return the texel's depth buffer value, is just returning a constant, so my screen is a solid grey

#

i think that it must be something to do with either my camera's script or some global project setting which causes the depth buffer to just not work

sinful shuttle
scarlet trail
#

Hey guys. I'm currently working on a psx era inspired horror game in the vain of silent hill 1 and I'm using the psx retroshader provided by dsoft20.
However, I seem to be running into an issue with white lines appearing between faces on the mesh of my level's map.

As was common in the era, I'm utilizing a number of texture atlases, created in gimp, for texturing purposes to save on file size. Each map is made up of an 8x8 grid of 32 bit textures, reaching a total image size of 256 x 256. When importing these atlases, I've made sure to disable the generation of mip maps / aniso filtering, turned the filter mode to point, and set the wrap mode to clamp.

I'm modeling all assets in blender and have been sure to remove all double faces / vertices as to ensure that there are no seams that could be causing the issue. Furthermore, the lines seem to only appear whilst the psx_retroshader is active. Specifically the vertexlit iteration.

Any idea what could be causing it or how I would fix the problem?

Here is a link to dsoft20's shader on his github page: https://github.com/dsoft20/psx_retroshader .
Here is the gif of the issue occurring in my game (It's most noticeable on the road to the right of the placeholder character):

GitHub

Shader that "emulates" the rendering style of ps1. Contribute to dsoft20/psx_retroshader development by creating an account on GitHub.

fallow rune
#

Hi, Is there a way to do depth bias fade in shader graph?

#

Like this

regal stag
# fallow rune Hi, Is there a way to do depth bias fade in shader graph?

Haven't tried it myself, but the URP particle shaders use this function : https://github.com/Unity-Technologies/Graphics/blob/2010bda30b0bb94f25e6fc5e03530f559554d75c/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl#L85
I think the near and far parameters is basically a Vector2 property to control the fading
projection is the Screen Position node (Raw mode), and sceneZ is the Scene Depth node (Eye mode).
Hopefully that helps

meager pelican
# wet lion i have joined this server with the express purpose of asking why this basic dept...

If I were you, I'd change the vert() function's use of the macro and the name of the float2 uv, to float2 depth.
It's not a UV, it's a depth. Less confusing. Besides you're probably clobbering the uv value. Which might be your problem, since you use it in frag().

Next, see definitions and example here:
https://docs.unity3d.com/2019.3/Documentation/Manual/SL-DepthTextures.html

The macro you're using in the frag() will get the depth info currently stored in the depth-buffer but that's NOT the one for the current object you're rendering. It's the depth "behind" what you're rendering.

#

That may or may not be what you wanted, IDK.

keen patio
#

I want to blur the screenspace shadow, how to choose the blur weight ?

proper plover
#

anyone knows how to make a blend between two game objects that have meshes in them? the example I found above is from Sebastian Lague's raymarching tutorial but he used shapes which isnt really what I am looking for

meager pelican
#

You're going to have to specially craft the meshes to do that, have the same number of verts or something, in the proper order, then maybe you can "morph" them with a lerp. Guessing, haven't tried it.

proper plover
#

hm sounds interesting, thanks i'll try

oblique hornet
#

upgraded my project ot urp and everything seems to be fine but when i apply a shader (made for urp!) to my materials they turn pink in game view even tho the asset view hs them working fine o(-(

#

im also getting this error which i didnt get when i played around with this yesterday

solar sinew
# oblique hornet

To me it just looks like your include syntax is wacky or something with the file path for your included HLSL script is wrong.

When upgrading your project is it possible that the file path changed or your project just hasn’t registered the files current location?

Did you upgrade your materials to URP? What version of URP? If it is past 10.0 then all HLSL (used in shadergraph custom node at least) must use #define rather than #def

There are other guidelines here: https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.0/manual/upgrade-guide-10-0-x.html

#

@oblique hornet

oblique hornet
#

oh and yes i did upgrade my mateirals but it didnt look like it did anything so ill try again tonight djdjf

wet lion
#

@sinful shuttle @meager pelican thanks to both of you for the insight, but apparently the issue was fixed by a full restart of my computer. guess I should have pulled out all the stops before coming here. I thought for certain it would be the directional light thing, since my scene doesn't have one, but apparently not.

#

and carpe, could you elaborate on the specifics of the macro im using in frag? did you mean UNITY_TRANSFER_DEPTH in vert? or is LinearEyeDepth a macro?

#

additionally, what's your opinion naming conventions for a shader which uses both the main render texture and the depth buffer? I understand using depth in my case, but if I expand the shader to include the maintex it becomes confusing again.

hazy lagoon
#

Greetings all, I am looking for a shader that will take a sprite and sort of diffuse/disperse it like a shadow. Essentially instead of having hard edges, somewhat soften and spread out the pixels to give it blur

#

anyone have any ideas on what to call this so I can search for one?

solar sinew
#

I also haven’t downloaded 3.8f1 yet but have been meaning too

meager pelican
# wet lion and carpe, could you elaborate on the specifics of the macro im using in frag? d...

They're both macros, IIRC.
Transfer depth is for when you're using a shader that writes to the depth buffer (usually opaque).
IDK what you're asking in your last paragraph. You should adopt naming conventions that are clear to you. I don't usually include depth-buffer use or not in shader names.

But if you mean the UV thing, the uv is the texture coordinate for texture mapping. It's a float2 or 4 depending on if you use tiling and offsets. The depth is a completely different variable, a float2, that stores an encoded depth. So your v2f structure would normally have maintex, uv, and depth as THREE variables in it. That is, if you're trying to pass an interpolated depth value of the current polygon.

The depth texture read macro that you're using in frag() is reading from the depth texture and would tell you what is in the depth buffer OTHER THAN what your current pixel is. Could be less or greater (or equal) than the current polygon's pixel. That's for previously rendered objects.

wet lion
#

okay okay thanks, i thought you were just talking about naming conventions when you mentioned UV

#

i dont fully understand what you mean by the flaw in lineareyedepth. ive stopped using it because I don't need it but i was under the impression that all it did was scale the depth buffer values

#

when you say its "reading from the depth texture and would tell you what is in the depth buffer OTHER THAN what your current pixel is" does that mean that the depth buffer and the depth texture are markedly different things? i thought the depth texture was just a way of formatting the buffer so that its accessed with a sampler2D, and they would be updated by the same amount

meager pelican
#

Same thing, for this purpose. Not all GPUs have a hardware depth buffer, but these days most do, AFAIK. In the case of them not having an actual depth buffer, they can use a depth texture. But no matter, the macros deal with all that. And to read it directly, I think you need a depth texture. But to just test against it, or to know the current pixel's depth, a depth buffer only is ok.

Flaw?

I'm just saying there's the current polygon's depth. And then there's the "scene depth"...what is in the depth buffer/texture. Two different numbers. The depth buffer for the current pixel is written when the frag() outputs the depth at the end. Until then, it holds the "background"'s depth (could be foreground too, like some big tree in the foreground occluding the current pixel that you would otherwise write out, if you're not texting zbuffer/depthbuffer/depthtexture automatically).

#

The thing is, if ztesting is on, the frag() is never executed if the pixel is occluded. That's a good thing (faster).

oblique hornet
ocean bison
#

I’m trying to do a terrain with vertex displacement. I’ve got it LOOKING alright, but I’m not so sure about the way I’m computing the new normal. This is the sub-graph that computes the normal and new position. (One note: the input heightmap texture is encoded as an RFloat- so the values it stores are just straight floating point values [NOT limited to 0-1]. This is why the vertex spacing param exists.)
Is there a better way to do this?

#

^large image- can zoom in to legible

wheat quail
#

I have "similar" logic feeding my vertex deformation and creating a track/trail texture. For some reason my vertex deformation mirrors in the opposite axis(?) but my trails do not so I'm clearly doing something right and something wrong. ( the unwanted deformation is hard to see but its there...)

#

but I use this to feed my trail texture and it works perfect

#

this is the vertex displacement

#

Im guessing its something to do with the texture coords in custom functio not getting the right data... but im currently stumped

past lake
#

Hello, can anybody help me? Why is the "Main Preview" showing me just as a purple ball?

ocean bison
ocean bison
ocean bison
#

ok, that part looks right then... sorry, no other ideas.

past lake
#

np

oblique hornet
#

ahaha sooo...fun issue...you guys suggested changing the defs to defines and uh. they already are but also it says the issues are on lines like, 546 and stuff like that
um

#

that file doesnt even go to 500 lines unity why are u telling me theres an error on line 546 hdsjgdhg

#

so i thought ok, maybe it meant on the graph itself
so i open the graph and line 546 is just ????

#

unity what are you trying to tell me here

#

it worked at first til it kept yelling errors at me so i opened the graph but then all my materials went pink again aaaaaaaagh

oblique hornet
#

its also listed under "failed to compile" in the shaders menu but i dont know why it keeps failing gaaaaaa

solar sinew
oblique hornet
solar sinew
rigid silo
#

How do I point the object space vector towards an object in my scene? Or how do I rotate it at all? Is it even possible to rotate the direction?

rigid silo
#

I gave up on doing it in shader

#

took me a whole week and yet I gave up

#

thank you

tacit quartz
#

Does anyone know any android emulators (bluestacks, memu, etc) that fully support compute shaders? I want to test out vfx effect graph in android builds

soft harness
#

Trying to make an effect that if the player goes into shadow, the shadowy bits have an outline
here's my code:
o.Emission = lerp(_RimColor * pow(rim, 10), float4(0,0,0,0), IN._LightColor0);
here's what's happening

patent kettle
#

Hi! I have a small issue with shaders and drawing to an RT using GL. I continuously draw singular lines to the rendertexture using

GL.Begin(GL.LINE_STRIP);
GL.Color(new Color(1f, 0f, 0f, strength)); // strength: 0.005f
GL.Vertex(startPos);
GL.Vertex(endPos);
GL.End();

but the color intensity never exceeds 30% of pure red. Using the unity color picker on the render texture, the flat area has an RGB value of (76, 0, 0). Is there something I'm missing? Should there be some sort of "Additive blend" option in GL?

#

Right now it looks a bit flat. I'd like to be able to use the full range of red to make it have more detail without the effect getting completely flat really fast

soft harness
#

My character is looking a bit funny

            half NdotL = dot(s.Normal, lightDir);
            half4 c;
            c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * saturate(atten + unity_AmbientSky));
            c.a = s.Alpha;
            half rim = dot(s.Normal, s.viewDir);
            rim = 1 - pow(rim * 6, 50);
            return lerp(c + saturate(rim)/3, c, c.r);
        }```
marsh venture
#

Is Standrad surface shader having image base lightning (unity default sky box)? We don't need to write code for lightning in standard surface shader?

oblique hornet
rocky sparrow
#

I currently do not understand unity shaders but I am attempting to. I found this code that scales my texture based on world position. what part of it allows me to control the size/scale of the texture? it creates a grid with a dev texture, exactly what I want. right now it is repeating too small. https://hatebin.com/hzcnafomaa

#

this is the current output. right now it scales each texture to a 1x1 unity unit. I would like the texture to scale on a 5x5. so each tile should be 5x larger.

regal stag
rocky sparrow
wraith forge
#

Hey everybody! Anybody know how to access the position of a directional light with a cookie in ShaderLab? My current setup works if I use a directional light, but not a directional light with a cookie. I don't need any information about the cookie or what kind of lighting it masks, just the equivalent of _WorldSpaceLightPos0

oblique hornet
oblique hornet
#

took a few hours but i put everything into a new project and the shaders all working perfectly fine now o(-(

#

still have no clue what messed it up before but hey it works now!

junior kelp
#

Does anyone know if i call MeshRenderer.material and modify some part of it, would it change the material asset (and thus every object with that material) or would it just change that gameobject's instance of the material?

knotty juniper
junior kelp
#

ahhh thank you thats useful info

loud remnant
#

Anyone made fake light shafts before? i want to have fake lightshafts and make them disappear as player gets closer

#

By fake, I mean material based. (Applied to a cone or cylinder mesh)

marsh venture
#

Hello firends, How to take the environment lighting(under lighting setting) into account in my unlit urp shader?

knotty juniper
wraith forge
loud remnant
#

@wraith forge I was able to do this

wraith forge
#

You could feasibly do it with a cone or cylinder by having an unlit transparent shader that a) fades out as an axis increases and b) globally fades as the distance to the camera increases

#

oh that's pretty good!

loud remnant
#

I'm very happy with the result, I also calculate the distance between the pixel and the camera to fade the light in and out

wraith forge
#

fantastic work

#

it uses an additive blend mode, right?

loud remnant
#

It's alpha

#

What's the difference? What does the blend mode do exactly?

wraith forge
#

Blend SrcAlpha OneMinusSrcAlpha , which is what I believe you are referring to, is the default

#

Blend Add should do an additive blend mode, which will add the color to whatever is in the frame buffer

#

Normally it's a replacement, or in a Translucent shader's case, an average of the frame and the material (weighted depending on alpha) - I think

#

Using Blend Add isn't necessary but it may get the rays looking more like light

loud remnant
#

Switched to additive, thanks for the advice

#

And explanation too

wraith forge
#

Of course! Share a pic if you have any spare time

past kraken
grand jolt
#

i take it that shader graph's missing Range property is just float?

regal stag
grand jolt
#

i see. is it possible to fully convert srp shader to urp shader graph?

#

so far i replicated fresnel, and properties

#

but theres lot of other math

#

oof it may be not possible in the end, or take months uwu

distant sparrow
#

I tried making a procedural shader in a 3d project but the material just turned fully pink, like when there's no output. I tried the same thing in a URP project and it worked but i can't export that mat to the other project

oblique hornet
#

god i just live in this channel huh. i hope this isnt an faq but uh...how do i get this to be transparent lol

#

currently using a lit graph bc it was the only one that seems to have alpha blending but also i dont know hwo to get it to work without just making the shader disappear entirely bc that seems to be whats happening every time i plug my shader into the alpha box on the master

feral turtle
#

is it possible to use shader Graph with Assetbundle for Android App? using AR Foundation ? im trying but im getting nothing!!

meager pelican
# oblique hornet god i just live in this channel huh. i hope this isnt an faq but uh...how do i g...

There's two things: Alpha clipping (this is in the opaque queue) and transparent blending (in the transparent queue).

Try alpha clipping first. You supply a threshold value below which the pixel is discarded. Note, beware of the performance of discards on tile-based mobile.
See documentation on either the alpha clip threshold master-stack block, or the alpha-clip threshold on the master node depending on what version of SG you're using.

#

If you want alpha blending, you'll need to do some math on the alpha value based on some condition I guess. Or just make sure you're in the transparent queue.

#

You could just subtract the threshold value and then pass that to a clip node.

oblique hornet
#

changed the blend mode to additive as was suggested in #✨┃vfx-and-particles and that kinda fixed it for the most part? now it lookin like this which isnt 100% what i wanted but hey close enough for now. ill still try out that stuff though and hope it helps :0

#

(excuse teh low resolution)

meager pelican
#

Additive is the default transparent blend, but according to degrees of alpha channel.
That extra "white" you're adding in is indicative of the problem. What usually happens with "normal" alpha blended transparency is a src-alpha and 1-src-alpha blend, premultiplied.

If you want traditional transparency you can just use that, I would think.

#

If that's what you are doing, then IDK why you got all that black before.

#

Or your texture doesn't have alpha.

#

@oblique hornet

#

There's an import option to compute alpha from greyscale, see texture's import settings.

#

@oblique hornet

untold shoal
#

is there any way to use a shader to generate the heightmap for the default unity terrain object ?

#

i know i can use a vertex displacement shader for a mesh but unfortunately that isnt what i have in mind

#

id assume i can render to a rendertexture and then update the terrainData.heightmaptexture property and then flag the entire thing as dirty but heightmaptexture is readonly so that doesnt exactly work

mystic trench
#

Hey all, I'm experimenting with cubemap sampling in a custom shader, however despite using the given sampling and HDR decoding functions the sky comes out looking very wrong:

#

like the colours have been inverted - the actual envmap I'm using should appear more like this

meager pelican
#

You'd have to show us your code (use pastebin or something) and also note that many cubemaps (like for reflections) are encoded so check the convolution type in the settings. And of course your source texture, ensuring it matches what unity expects.

Is it a skymap? What do you mean "sky looks very wrong"?

mystic trench
#

@meager pelican Okay, so this is the map

mystic trench
mystic trench
#

@meager pelican setting the convolution type to none fixes the colour issue but then gives me a blur in the centre

strong musk
#

i was tryna make a shader, the square should apparently turn yellow when i've done all the values correctly, but it's not. I'm not sure why.

mystic trench
regal stag
# strong musk i was tryna make a shader, the square should apparently turn yellow when i've do...

If you move the graph inspector window there should be an error message attached to the custom function node to help tell you what is wrong. I'm not sure you need the 0 parameter in the GetMainLight function but I'm also not sure that would fix the error. I can't really see anything wrong with it.
If you'd prefer, I have some custom lighting functions/subgraphs shared here that you could use instead : https://github.com/Cyanilux/URP_ShaderGraphCustomLighting

mystic trench
#

wait, I think I've figured it out

mystic trench
#

Colour buffer overflow - the envmap was getting added in the deferred lighting pass to what I already added, so it was overflowing the float values I think

strong musk
strong musk
#

i managed to fix it :P

onyx jungle
#

Can anyone provide any help at all on an atmospheric scattering shader?

stiff maple
#

I created an Unlit shadergraph (sprite).. Realized I wanted it to be lit. After changing the Material to Sprite Lit in the Graph Settings and saving it... its still unlit. Is there something more i need to do?

#

2d URP

stiff maple
#

nevermind i'm an idiot

pliant jay
#

anybody here know how to blur ui objects using universal render pipeline?

brittle owl
stiff maple
#

@pliant jay what kind of UI object?

brittle owl
#

there should be a show off channel just for shaders

pliant jay
stiff maple
#

so like you wanna blur the game but show the UI?

#

or just blur everything - including the UI

brittle owl
#

probably blur the background

stiff maple
#

use Post Processing in that case

brittle owl
#

its a very nice effect, i was trying to do that a year ago or so, i kinda just worked around it by chaning depth of field values to make the focus distance really short

stiff maple
#

^this

#

or use the other mode for better control

#

thanks for the idea! i'm gonna use that lol

untold shoal
ocean bison
#

I've made a terrain shadergraph with Vertex displacement. Along with offsetting the mesh (a simple plane) vertex vertically, I compute and assign the appropriate normal in the vertex part of the shadergraph. (so it will be lit properly based on light direction- and this works.)
However, in the fragment section when I try to look at the interpolated normal- it LOOKS like it’s not using the normal I gave it in the vertex section- but the source mesh normal instead. (test to confirm: when I assign the tanget-space normal in the fragment section- directly to the base color output- I just got a consistent, unchanging blue- which would be correct for the UNALTERED plane-mesh.)
What’s going on here/what am I misunderstanding? (and any ideas on how to fix it?)

#

^for testing, obs

regal stag
ocean bison
#

so tanget space normal vector is always 0,0,1.. ah yes, I guess I would need a diff space then

#

@regal stag thank you, cheers!

#

hmm... does it look like only 2 sides are getting "cliff" texture to anyone else?

regal stag
ocean bison
#

hmm.. thats what I tried at first- then went to dot product.. I suspect it's my normal computation now.

#

ah... yep that was it...

#

thanks again! 🙂

tawdry depot
#

Hey, just starting to learn shaders and my preview isnt working. Anyone know a quick fix?

quick oxide
#

can someone hlep me making a simple 2D shader?

#

i wanna make an effect like this:

#

the wave effect

#

please ping me if you can help

quick oxide
#

but how can you add renderer features in 2019.4?

#

like in this screenshot

#

for me the renderer looks like this

#

if I could add render features to this it would have worked

quick oxide
#

so how can I use those render objects?

left stump
#

Some knows how to change the color to a Texutre? on code

quick oxide
#

okay this sprite seems to move with the screen instead of the object

#

my graph

#

how to I make it move with the object?

#

I think it has something to do with the screen space

west knoll
#

Hi everyone!! Anyone can help me with Cross fade Shader? I'm working with unity 2020.3 URP

mystic trench
#

Sorry I have to swing in with more shader questions: I've written a shader to render the world-space coordinates of objects, bizarrely I'm getting a weird transparency effect on anything rendered using this

#

this ring for example: you can see the underside through it.

#

Trying to figure out if it's an issue with the shader code actual or some metadata. Also is there an easier way to get world position as a g-buffer for deferred shading than just writing my own?

errant turtle
#

Hey, I'm writing a shader myself and I have a small problem: In this scene there are 2 objects (the purple cube and a red model of vessels) inside another brown cube. Usually it should be rendered like in the one image where only the cube is being seen because the other objects are inside of it. But when I got around the cube and look at it from the other side or even from an angle from the sides, it shows the inner objects although they should not be shown.

What do I have to do to make them not show there? Keep in mind that I'm using transparency in other parts of the shader so transparency still has to work.

Here's the shader code: https://gist.github.com/staddle/7f14d9a084b191e5aef556738a50d893

Gist

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

wheat quail
#

I need help with my shader logic. I have tiles uvs mapped relatively to a large splat map(plane) underneath. Whats really confusing me is the logic that draws the trail texture is similar to the logic that deforms vertex height. The issue is that the vertex deformation gets mirrored every 20 tiles and I dont know why, but that same tile-UV to splat map logic works perfectly for my trail texturing. I think it might have something to do with how the custom function reads UV coords but I dont understand how to fix it.

#

this is my functioning trail texture

#
    //world end at +350x +350z, -350x, -350z. giving us 700 plus the zero positions add +1.
    //World bound will be 700*700 giving us 49,000 tiles. 0,0,0 will be the center. range(-350/ + 350)
    private void Start()
    {
        float x = transform.position.x;
        float z = transform.position.z;
        //Get the % that the coordinate is between 0 & 350. That % is only half of total UV.
        //Add or subtract depending on position to set proper UV.

        if (x > 0 || x < 0)
        {
            x = (x / (worldSize/2)) / 2;
            x = 0.5f - x;
        }
        else
            x = 0.5f;

        if (z > 0 || z < 0)
        {
            z = (z / (worldSize/2)) / 2;
            z = 0.5f - z;
        }
        else
            z = 0.5f;

        //Set UV offset in shader:
        UnityEngine.Material snowMat = GetComponent<MeshRenderer>().material;
        snowMat.SetFloat("xOffset", x - (1 / worldSize)/2);
        snowMat.SetFloat("yOffset", z - (1 / worldSize)/2);
        snowMat.SetFloat("Tiling", (1 / worldSize));

        StartCoroutine(DelayedStart());
    }
    IEnumerator DelayedStart()
    {
        yield return null;
        //Find the splat map render texture.
        UnityEngine.Material snowMat = GetComponent<MeshRenderer>().material;
        RenderTexture splatmap = DrawTracks._splatMap;
        snowMat.SetTexture("_TrailMap", splatmap);
    }```
#

^^ the logic feeding the splatmap to tile UV. each tile is 1x1

royal prism
#

my shadergraph doesnt work when build by assetbundle and i didn't open the scene before I hit "build assetbundle". but when I open the scene briefly, before building, it works

#

these numbers "currently tracked ... " seem to change when i open some scenes before building the assetbundle:

#

I use URP

#

Unity 2019.4.24

#

it seems when i open the scene before hitting "build assetbundle" the shader works in the assetbundle and on mobile.

#

is this some kind of stripping bug in unity or do i do something wrong

strong musk
#

How can i add an outline effect to my CelShader Graph?

past kraken
#

any ideas?

mortal elbow
#

is the decal shader or some other shader exist that can project and tile a fixed-size material over a large area? I'm basically looking to project a grid over my level

#

Nevermind, seem to have found it!

#

didnt realize I had to set the image to repeat when importing haha

broken ridge
#

Im coming from Unreal and I'm having a hard time getting specular information to display correctly. Roughness in PBR handles color and intesity in one map. What is the proper setup for specular information in Unity? If I have a roughness map that I;ve converted to specular map, what should smoothness be set to? What is smoothness? Is it not alreayd set inside the specualr map? if not what is the specular map actually doing?

#

the documentation is very vague

torpid sapphire
#

Anyone would have an idea how I would go about this :

I want to use a stencil buffer to always show my object (so it doesnt render objects in front or behind my main object that I want shown at all time). The problem is that the stencil is working, but I would like to have everything BEHIND my object to still renders on screen.
thank you for your help

mystic trench
#

@broken ridge Are we talking about converting from something like Phong to PBR?

broken ridge
#

that information is linear, so why are their two controls?

mystic trench
#

crap, I can't answer without better knowledge of substance painter I'm afraid

broken ridge
#

well, if you were using a spec map, what would determine your smoothness value?

mystic trench
#

Well I'd guess that you'd have specular colour in your RGB channels and smoothness in the Alpha channel

#

But my knowledge is that the whole PBR concept removes the need for a separate specular colour map and instead only needs metallic and roughness values to compute all specular data

quasi adder
#

anyone have the grassflow add on?

broken ridge
#

I can get decent results with the standard shader, but connecting those same values into a custom shader graph yields vastly different results

uncut valve
#

Is there a way to get child objects having their vertices animated by a shader, to stick to their parent object, also being animated 😛

broken ridge
#

youd need to sample some attachment point and add that offset to all the children

uncut valve
#

interesting

#

I mean, it makes total sense, if only I knew how to.. do any of that.

#

fml

broken ridge
#

well, it depends on your setup

uncut valve
#

using urp, shader graph

broken ridge
#

the dynamic way is to raycast from object to object and find the uv coordinate at that intersection

#

but thats happening live in the scene, and using urp its probably too expensive to do it this way

#

the other way is to replicate the same animated value in the shader for just the children

#

so the same information that animated the parent is the same on the child + child movement

uncut valve
#

some clarity on what im working on - trees, trying to make a set of urp tree shaders - branches have a shader anim, trunk has one too

#

yeah, considered that option - but the trunk's sway lerps towards the top

broken ridge
#

so i assume your uvs are root to tip for the trunk yeah? the whole object

uncut valve
#

yesr, probably not the best, aiming for low poly 😛

broken ridge
#

have a second uv channel with the leaves in their relative position to the trunk

uncut valve
#

hmm

broken ridge
#

ill make a simple illustration one sec

#

so the position uvs are relative for the trunk and leafves

broken ridge
# uncut valve hmm

but you can also add motion to just the leafs also with the second uvs

#

as long as the settings for both UV 1's in the material are the same they will follow

mystic trench
#

wtf and I continue to get this weird transparency stuff with my world space position shader

#

Wait, and like that it's fixed

uncut valve
#

sorry, feeling super dumb, not following

broken ridge
#

you have to do that in your DCC package

#

so in blender/maya/max

uncut valve
#

I see

broken ridge
#

usually called uv sets/ uv channels

lyric pebble
#

Please guys I want to create a shader to make a skin glow in the borders

broken ridge
lyric pebble
#

Wut ?

#

I don't know how to use shaders

broken ridge
#

thats a much bigger ask then

#

there are two ways to edit shaders. You can change the code in a text editor, or use custom shader graphs.

lyric pebble
#

coz most tutorials use PBR but I don't find it

#

I'm using Universal renderer pipeline

#

you don't have some tutorials ?

#

@broken ridge

broken ridge
#

This is how you create a blank graph

#

i would follow the documentation

#

@lyric pebble ^^^

lyric pebble
#

Ok so for the glow effect I should use fresnel and emissive ?

broken ridge
#

fresnel is whats known as a facing ratio

lyric pebble
#

this ?

broken ridge
#

it gives you a black white value based on the angle the surface is to the camera

#

yea that the one

lyric pebble
#

Ok

#

I'll try to understand how it works

#

bcs it seems difficult

broken ridge
#

theres a learning curve but its not a difficult process

lyric pebble
#

I can't find Emissive effect ?

broken ridge
#

emissive is the input channel

lyric pebble
#

Where 😅

broken ridge
#

so shaders ahve different inputs: color, normal, smoothness, metallic, emissive

#

it looks like you may have made the wrong shader

#

your inputs should looks like this

lyric pebble
#

Yes you've made a lit and I made an unlite

#

I'm good

broken ridge
#

k

lyric pebble
#

and how can I change the color

broken ridge
#

so anything other than black in the emissive input will ignore lighting

#

hence

#

glow

lyric pebble
broken ridge
#

k

#

you gotta start simpler than

lyric pebble
#

Like what please ?

broken ridge
lyric pebble
#

Wait look LMAO

#

I've made somethinf

broken ridge
#

you did lol

lyric pebble
#

The preview Is pretty

broken ridge
#

but that bottom right sphere is the preview of what your output will be

#

so its not connected yet

lyric pebble
broken ridge
#

drag that end of the red njode to the emissive channel input

#

yeah

#

se how the center isnt black

#

its just not emissive

lyric pebble
#

oh so the center won't receive the "glowness"

broken ridge
#

now if you want the boittom layer to be skin texture instead of grey

#

add a texture to the color input

broken ridge
lyric pebble
broken ridge
#

so, the fresnel is saying make the center black ALWAYS

#

if you want to also have the center glow a different color we need to use the fresnel as a mask only

#

so youll need a blend node

lyric pebble
#

is blend a multiplyer ?

broken ridge
#

no its a blend

#

well

#

actually

lyric pebble
#

oh wait

broken ridge
#

use a lerp instead

lyric pebble
#

LERP ?

broken ridge
#

its called lerp

#

its short for linear interpolation

lyric pebble
#

isn't it a maths function ?

broken ridge
#

it is

#

material are math

#

color math

lyric pebble
#

If I'm not too annoying can we speak in a vocal channel ?

broken ridge
#

honestly i cant spend much more time on this

#

gotta get back to my work lol

lyric pebble
#

oh sorry

#

bro for annoying u I'll do my reseach

#

but thank u and good luck for ur work 😉

broken ridge
#

when you hit a wall mention me here ill get back when i can

lyric pebble
#

broken ridge
#

@lyric pebble One last quick note on the fresnel node, if you wanna change the position of the fade, change the power value input on the fresnel node

#

a number like 10 makes the fade very small

#

almost like an outline

knotty kindle
#

I'm not sure if i just have to add mesh and apply material and shader to it or its something else

lyric pebble
whole echo
#

Does anyone know where the option to disable "Receive Shadows" is for a mesh in URP? In built-in it was in the mesh-renderer > lighting tab...

gritty zephyr
#

I've created a material/texture for a rectangle with a scale of 1024px width x 2048px height as I wanted the material/texture to cover the tile in full rather than repeat. Just wondering whether this is a good idea or am I going to experience issues? Probably matters to state that this is also for mobile

waxen grove
#

Can I fix this at all??

dusky haven
#

getting hit with this error on this custom function in my shader, what dumb mistake am I inevitably making here?

grand jolt
#

How can I make a fade shader with shader graph ?

#

like a darkness fading thing.

true relic
#

Hello guys, does anyone can help me,trying to figure out, the best way to access texture from camera to render throughout shadergraph (talking about basic image processing (grayscale for example))?

grand jolt
#

how could i make the color of an sprite change in the parts where an object with an specific tag is moving through with shaders?

frosty copper
#

dead in here

desert orbit
#

@frosty copper Please don't spam the channel.

frosty copper
#

what does spam mean?

desert orbit
#

@frosty copper If you don't have anything constructive to say don't spam on the server.

frosty copper
#

i was discussing shaders with someone

grand jolt
#

yes

frosty copper
#

then you said go to the shader room

#

sorry mod is messaging

grand jolt
#

so

#

i have this object

#

with a sprite renderer

#

there is also 1 object with the "Attacker" tag

#

and another one with the "Defender" tag

#

both objects move around

#

the attacker object is meant to change the color of the parts of the first object where it goes through and make a trail.

#

the defender is meant to do the same thing with a different color

#

but i don't know how to do it

proper plover
#

anyone knows how to make those water shadergraph into 3d? right now if I try to use one of the water shader graph and place it onto a cube, the cube will appear as a plane with the water shader.

#

or do anyone have a reference for things like this ^ ?

regal stag
# true relic Hello guys, does anyone can help me,trying to figure out, the best way to access...

If you're in URP, for objects in the scene you could use the Scene Color node, in a shader graph using Transparent surface mode. It will obtain the camera's texture after rendering opaque objects. Opaque Texture option needs to be enabled on the URP Asset too.

For full-screen image effects, you'd need a renderer feature to draw a fullscreen quad / blit to the screen. And use _MainTex to obtain the source texture. I have a post here that goes through that (a little old but haven't got an updated version yet) : https://cyangamedev.wordpress.com/2020/06/22/urp-post-processing/#CustomEffects

regal stag
grand jolt
#

(I'm using it for making a corridor that fades into darkness)

#

wait.

#

You are the author.

#

Right ?

misty flame
#

I've been trying to follow this tutorial but I really don't understand how this works https://www.youtube.com/watch?v=NiOGWZXBg4Y&t=303s

Let's learn how to make an awesome force field with Unity Shader Graph!

● Check out Skillshare! http://skl.sh/brackeys15

● Support us on Patreon: https://www.patreon.com/brackeys

● Project Files: https://github.com/Brackeys/Force-Field
● Water Shader shown in intro: https://youtu.be/jBmBb-je4Lg

● Setting up Lightweight: https://bit.ly/2W0AY...

▶ Play video
#

So what I think is happening is that the scene depth will get the current pixel on the screen that's being drawn and the depth of it to the camera.

#

But I'm really confused about the screen position and what the w component is and why it can't just output a Vector2

#

What's the 4th value on the screen position? Is it depth or something?

solar sinew
# misty flame What's the 4th value on the screen position? Is it depth or something?

Small tip that isn’t exactly relevant to screen position, if you hit F1 with any node selected you will open its documentation in browser

Anyways here are some answers.
Essentially Unity stores many different things in w depending on the situation. ComputeScreenPos is a little confusing at first (I still am familiarizing myself with all the coordinate spaces)

https://forum.unity.com/threads/what-is-screenpos-w.616003/

https://forum.unity.com/threads/w-component-of-in-screenpos.242314/

misty flame
#

Oh thanks I looked at unity's documentation but I'll check out those forums and I also found thishttps://gamedev.stackexchange.com/questions/186226/understanding-screen-position-node-in-unity-shader-graph

solar sinew
misty flame
#

So I can look at how the nodes work?

solar sinew
#

Yes. If you look at the documentation it’ll say what function any node is using more often than not. If you then look through your included files you can exactly what the contents of the functions are

#

You can find this via GitHub but looking in your local version of unity editor will ensure you are seeing what your project is using

misty flame
#

Ok that sounds good thanks. I'll try that out if I don't understand something else but I think I understand how the intersection effect works now

solar sinew
#

I think that’s under GeometricTools.hlsl or something similarly named

misty flame
#

oh ill check that out in the github

solar sinew
misty flame
#

thanks I found it idk what a cginc file is though

solar sinew
solar sinew
#

Common.hlsl can be found in a few different packages (like vfx and post processing) as well. All containing many different included helper functions relevant to each package (typically by Common.hlsl #include -ing many other files)

grand jolt
#

help

untold shoal
fading fable
#

Hey guys, I've updated my Unity and suddenly my scenes' lighting got messed up: it's much brighter.
Any ideas? :\

untold shoal
#

howd i go about removing the voronoi cells close to the texture "borders" ?

#

and i mean entire cells, e.g resulting shape could be :

#

hope that makes sense.

grand jolt
#

Hey guys. I got a code in many languages (JS, C#, CPP).
I have converted it to GLSL, and it works, but I can't make it to work with CG Language.
It is a shader used to convert a Specular/Diffuse texture into an Albedo texture.
Could anyone give me a hand? I can buy you a coffee if you prefer 🙂

#

It has no compiler errors or whatsoever. Only the math seems to work differently in Unity.

#

80 lines of code, not a huge thing

grand jolt
#

Hello. I'm sorry if I'm asking this in the wrong area, as I am new to all of this..

My model has haircards and was made in Blender.
I want to use this model in Unity but I am having 2 issues.

  1. I can't figure out the setup for texture maps... ( Albedo, Normal, Height, etc )
    For the hair to look realistic like it does in Blender.
    When using the Standard shader and the rendering mode Cutout, it either leaves too much "Alpha" or there is no more hair left.

  2. From the front of the hair, you can see through it. From the back, you can see the hair.. As if the texture is only on one side.

I really appreciate any sort of help.
If you need for information, just let me know. Thank you.

mild lynx
#

does any one know if you can render specific layers using scene color node
something similar to using 2 cameras for different layers and rendering one to a render texture

#

but as i am using a single camera can not figure this out

meager pelican
#

@mild lynxI don't know that you can, unless you do what you say and use multiple cameras. The scene-color node is a grabpass that runs between the opaque and transparent passes. So if you've composited opaque layers, it would get them all. IIUC. So your guess about multi-camera is a good one. Or you need to do whatever you're doing differently.

#

@grand joltHair is usually a special-function shader by itself. You'll need one of those. HDRP has one, and a hair master node for SG. For other piplelines, go shopping, or google is your friend. It is specialty stuff.

#

@echo kettle Do you have animated materials turned on in the editor?

#

@grand joltThat's the GLSL. What did you do for HLSL? Doesn't look too bad.
You might want a compute shader, or you can use a vert/frag (IDK what pipeline you're in either).
What do you mean you can't make it work? What happens?

grand jolt
#

It takes the diffuse texture and a specular texture, then mix them to build an albedo texture

#

I could post the Unity version too (HLSL)

#

The SolveMetallic method on HLSL is returning mostly full black values with some overbright pixels

#

I have checked my inputs and made a 1:1 copy in HLSL

astral mason
#

Anyone have a grabpass distortion shader that works on mobile?

untold shoal
woven fractal
#

I may have messed up something here, I installed the shader graph package then the URP package and this is what I get as default
and I see no option to create a PBR shader

astral mason
#

What render pipeline is compatible with unlit master?

woven fractal
#

both urp and hdrp I guess?

#

maybe I need to remove the packages and install them again

regal stag
woven fractal
#

I see

#

cause I get the pink color on the object

regal stag
#

Make sure you have configured URP (or HDRP) properly in the project. Just installing it isn't enough, you need to assign the pipeline asset under the project settings.

woven fractal
#

alrighty

#

do I need to install the Scriptable Build Pipeline for it?

regal stag
#

You only need to install the URP package. All other dependencies are automatically included

woven fractal
#

well I can't seem to find the pipeline asset in the project settings

#

and no, its not the option

regal stag
#

You need to create the asset first. The docs link above goes through the setup

woven fractal
#

oh there we go!

grand jolt
#

Hello there 👋 For my models I'm trying to add this glue residue from removed tape / stickers to add more detail, does anyone have an idea how I could achieve this material? Thanks in advance

#

I have cut rectangular planes to match the shape but I've been messing with different noise combinations to create a texture, with no results so far

#

For some reason legacy shader ain't working in unity urp..

onyx jungle
#

Hey guys, say I have a sphere and I want to basically make the inside of the sphere completely white almost like a really intense white fog, how could I program this in a shader.

swift loom
#

Is it not possible to read an array like this? https://hatebin.com/puazvbkjmz
I wanted to pass an array to the shader, then divide the current screen position by my tile size and then check the value in the corresponding array index to see whether to render the square or not. I'm doing something similar already but using a texture, do I have to do something different for arrays?

#

i'm just declaring it like float arrayName[10800]; in the shader

#

currently unity is telling me socket exception: terminating shader compiler process

empty elm
#

Hello, does someone know why this is happening? It basically happens when i'm chaning the Vertex Position with a Position + Combine node.

#

I want to put back the visual part of the cylinder into the object itself

willow pike
#

Recently my Shader Graphs have all been bugging out when trying to add new properties or change them in anyway. Giving me a NullReferenceException. They are still rendering fine but this is super annoying. Anyone know how to fix this?

NullReferenceException: Object reference not set to an instance of an object UnityEditor.ShaderGraph.Drawing.Inspector.PropertyDrawers.ShaderInputPropertyDrawer.UpdateEnableState () (at Library/PackageCache/com.unity.shadergraph@11.0.0/Editor/Drawing/Inspector/PropertyDrawers/ShaderInputPropertyDrawer.cs:142)

#

I've removed and reinstalled Universal RP to see if it would fix but no luck.

opaque timber
#

how do i change the reference of texture2d properties in shader graph
there's no dropdown showing up beside it for me

#

it's just nothing except the name

regal stag
#

The property settings moved to the Graph Inspector window (Node Settings)

opaque timber
#

ah ok
thank you

shadow kraken
empty elm
#

Ah yes i've forgot to upload it

shadow kraken
#

You probably don't want the world position there

untold shoal
#

how do i make a voronoi noise node sample its values from the centroid coordinates =

empty elm
shadow kraken
#

There's a dropdown

empty elm
#

Sorry, but where?

#

Ahh

#

I saw it

#

Thanks Ole

opaque timber
#

what am i doing wrong

shadow locust
#

Also It needs to be exposed pretty sure

#

(the exposed checkbox)

opaque timber
#

i've tried both, it still shows the warning
i've also saved the asset

grand jolt
meager pelican
# grand jolt I could post the Unity version too (HLSL)

The code you're showing doesn't make much sense to me. diaelectricSepecular (a float3) is set to (.04, .04, .04) and then you mostly use the .x component except for maybe one call. Which IDK why anyone would code it that way, but to each their own I guess.

Whatever it is doing, you can trace it through step by step by outputting the colors, maybe scaled, and seeing what you get at each step with each version.

But my looking at the GLSL source won't help debug the HLSL converted shader, at any rate.

#

Oh, you edited. 😉 Hang on

grand jolt
#

It is used as a float3 when it is multiplied with the specular color, since every component must be multiplied

#

The GLSL version works fine (Running on Shader Factory)

#

The Unity version outputs black pixels only

#

The desired result (GLSL result is not the same, but is close enough)

meager pelican
#

Yeah, IDK off the top of my head.
The ThreeJS is using a multiplyScalar function call though, when calcing baseColorFromSpecular. But your input vector is .04 for all three components. So IDK.

Could be floating point issues too. Remember you're converting CPU to GPU. See
https://forums.developer.nvidia.com/t/floating-point-operations-difference-between-cpu-and-gpu/27334/3

But that's a SWAG.

#

Try doubles maybe?

grand jolt
#

In CG?

meager pelican
#

you're writing an HLSL

grand jolt
#

Ah, you mean the inner floats

#

ok

#

I guess that if this is a precision issue, that should be happening in GLSL too

#

But I'm doing that

meager pelican
#

Like I said, SWAG.

#

(Silly guess)

#

Otherwise you'll have to step through both, step by step. And compare results.

grand jolt
#

Same result with doubles

#

Yes. It is just a pain in the a... from my experience (debugging shaders)

#

Tks anyway @meager pelican 🙂

grand jolt
#

@meager pelican there should be something wrong with my Unity inputs or the way I'm calling it.
I've tested both the HLSL and the GLSL shader in Shadered and they yield the same results

#

Maybe it has to do with the texture colorspace...idk

#

They're binded correctly, tho

meager pelican
#

I thought you were saying they yielded different results.

But I guess you're saying they yield different results from the CPU version.

#

@grand jolt

grand jolt
#

The Unity version yields different results

#

But it is the same code used in Shadered

#

Specifically the "baseColorFromSpecular" line is returning different values in Unity

#

Trying to figure out why

meager pelican
#

Have you checked texture import settings?

thinking color-space

#

And then there's this shadered thing...
Looks interesting

grand jolt
#

Shadered is fantastic. You can debug the shaders just like a C# file

#

You pick a vertex/pixel and step thru the execution

#

I'm creating my textures dinamically, but I've already tried creating them as linear textures with no luck

meager pelican
#

You could search your unity version for any shader compiler issues in it, or fixed in later versions. But that's another SWAG.

#

I'm not seeing it, as a 2nd pair of eyes.

#

You could try a native-software debugger and inspect it directly. But there's learning curve to that too. Another PITA, but you can also set breakpoints and inspect values. Both AMD and NVidia have them for download.

#

That's all if outputting color values for the various components doesn't help you. That's the easiest thing to do for shader debugging.

grand jolt
#

Yep, I could use RenderDoc as well, I guess, I have it here

#

But that is veeery strange, since, theorically, it should output the same bytecode as the HLSL from Shadered

meager pelican
#

Yeah, theoretically. 😉
It's supposed to be platform independent bytecode from the HLSL compiler, and then gets compiled by the platform, IIUC.

#

So IDK why the SHADERed compiler and unity's HLSL side would output different bytecode, since they should go through the ?same HLSL compiler? But maybe options?

#

Might be one for Unity Tech to handle/look at too.

#

I'm sorry but I can't tell much from here unless I really dug in and duplicated your setup.

grand jolt
#

Yep, I will set up a demo project

#

To test it with RenderDoc also

meager pelican
grand jolt
#

Yep, I have to create a new project, since I'm not using it as a regular shader, but as a "image processing" shader

#

So it is harder to catch it with the debugger

meager pelican
#

I'm curious now that I got this far.
But i have to upgrade to a later version of Unity. Be a bit.

grand jolt
#

I guess you can use your current version without issues

#

It is a simple project

meager pelican
#

It should upgrade...On unity 2020.3.something

#

How do I know what to compare it to though?

#

I have to install SHADERed?

#

Is that your test base?

grand jolt
#

Well, if you want to install Shadered, I can send you the Shadered project as well

meager pelican
#

Wait.
It loaded.

grand jolt
#

But I've tested it in some online editors like Shader Factory

meager pelican
#

I have two boxes, one is black, other textured.

grand jolt
#

Yep, the textured one has the optimal output result as a diffuse texture

#

The left one is using the shader to create such texture

#

Which isn't working ,as you can see

meager pelican
#

OK, that gives me a comparison.

grand jolt
#

But I can say the "baseColorFromSpecular" has wrong values, for sure

#

"baseColorFromDiffuse" too, it has some overbright pixels

meager pelican
#

baseColorFromDiffuse has this:

grand jolt
#

Yep

#

It seems right

meager pelican
#

Specular has:

#

black

grand jolt
#

baseColorFromDiffuse from Shadered (left one is HLSL, right one is GLSL):

meager pelican
#

lol

grand jolt
#

baseColorFromSpecular:

meager pelican
#

Still lol

#

OK, I'll play

grand jolt
#

baseColor

#

I appreciate a lot. I can buy you a coffee later for the help

#

I'm also working on it

meager pelican
#

You're getting zeros or nans, because of that black.
I've tried multiplying by 10,100,1000 and still black, and also abs() so not negative. So it's zeros or NANs

grand jolt
#

Division by zero !?

#

I'm getting this strange compilation warning too:

Shader warning in 'Custom/SpecularDiffuseToAlbedo': use of potentially uninitialized variable (solveMetallic) at /Repos/ShaderTest/ShaderTest/temp.hlsl(904) (on d3d11)
meager pelican
#

I'm not getting that warning, but that's a function name.

#

I think it's whatever the metallic function is returning that is producing weird results (so far).

grand jolt
#

Yep, that is what I guess

meager pelican
#

Do you know what values to expect?

grand jolt
#

But every place in the internet I search for this method, uses the same formula

#

Also, there isn't an explanation on how the formula works

meager pelican
#

If you have it return like .5 or something, you'll get a blown-out white cube

grand jolt
#

If you move the specular/diffuse sliders, the baseColor value is updated, that is the value I want

meager pelican
#

I'm checking function inputs. (Maybe we should DM this, might annoy everyone)

grand jolt
#

lol

#

Well, yeah, since it is supposed to work as HLSL, right?

meager pelican
#

Inputs to the function

#

Suspicious.

grand jolt
#

hhhmmmmm

meager pelican
#

AFK BBIAB (10 min)

grand jolt
#

Ty

#

Ok, if I remove the "sqrt" call from "solveMetallic", the result is getting better

meager pelican
#

Back

#

OK

grand jolt
#

The -b part is throwing the float range < 0

#

If at least I knew where they got this formula from

#

This is the shader I'm testing. I've based it in the PBRUtilities.cs from the glTF toolkit. It is slightly different from the one in the GitHub

meager pelican
#

Yeah, and it is weird since there's a constant 4.0 and a "looked up" .04..which you could just multiply out. The shader compiler will probably optimize that though. But you could end up with a negative value in there, which is undefined.

grand jolt
#

hmmm

#

Now I wonder if optimizations are messing up stuff

#

GOT IT WORKING

#

If I move both constants inside the methods (frag and solveMetallic), it works

#

Definitely optimization error

#

Maybe this is a bug worth to report, not?

#

Result is not 100%, but is close enough (right one):

meager pelican
#

Yeah IDK, you could try. IDK if it is unity or MS or us.

grand jolt
#

Maybe when the constants are outside the function blocks, they get scrapped out by the optimizator

meager pelican
#

I had an expression messed up from earlier testing. 😊

#

So IDK.

grand jolt
#

I mean, they may end up being used by one or another, but not both methods

meager pelican
#

I'd be surprised if that was it.

#

But could be

grand jolt
#

The only thing I did was moving them inside the methods (had to copy it twice)

meager pelican
#

Oh, I moved the function call inline

#

And I substituted constants for that const float3(0.04,....)

grand jolt
#

It worked?

meager pelican
#

Meh

#

Better than before! 😉 Sec

#

But I think I still have an abs() in there and maybe f-ed up other stuff testing.

#

If yours is working, no reason for me to go dig to figure out what I may have done, or not.

grand jolt
#

Yep, moving the constants inside the methods worked

#

Not the most pratical solution

#

But since I'm running out of time with that...

#

Btw. I've PM u

meager pelican
#

I'll delete the sandbox project and ensure I don't have your code in my possession anymore.

grand jolt
#

Np, the code has nothing special

limber fossil
#

Hello. I can not use time node and do not know why? Sine and others work but not the time node.

meager pelican
#

I suspect it may be because Time is an ever-increasing value.

#

But sin would be a result between -1 and 1

#

So would cos()

#

And the others are frame time each frame (in fractions of a second).

#

@limber fossil

limber fossil
#

how can I restrict it between -1 and 1

#

because I need it to start from -1 to 1

#

and it should have started again

#

contuniously

meager pelican
#

Do you want it to cycle back and forth like sin() does?
Or when it reaches 1, go back to -1 again and then count up?
I think you mean the 2nd one.

limber fossil
#

when it reaches 1 go back to -1

meager pelican
#

OK, yeah.

#

The trick to that is to get it to cycle from 0 to 2.

#

And then subtract one.

#

And the way you do that is with the modulus operator.

limber fossil
#

thank you

#

Ill give it a try

meager pelican
#

So result = mod(time, 2) - 1.0;

#

🙂

tired crown
#

Hello, I have a problem with one step in my shader. I am basically creating texture for a throwing dices. I want to have customizable colors.

#

I have a texture for symbols, which are just white symbols (one color, various alpha on its borders) on transparent background. All works well untill I wanna combine the two together - I just want to take the background color (the yellow one in this example) and over it place the green colored symbols.

#

I cant manage how to do it, you see, the background turns into more orange-red as I increase the opacity in blend node and the symbols are yellow instead of green.

#

When I lower the opacity they are transparent - so only the yellow background is visible. Does anybody know what to do to make it work, pretty please? 🙂

regal stag
tired crown
#

Oh, so I need to use blend, where Base is yellow, blend is green and opacity is a texture, which is black symbols on white background without anything transparent?

quartz flume
#

Does anyone here writes the shader with code instead of using shader graph?

regal stag
regal stag
tired crown
#

I tried that too, it doesnt work... 😦

regal stag
tired crown
#

Oooooooh, sorry!

quartz flume
#

I'm trying to control transparency of my material (which is a property of my shader) through a script, attached to that gameObject with my material

#

But is jsut doesn't work

tired crown
#

Cyan, thank you very much! You saved me... I was stuck on that for hours. 😉

quartz flume
#

This is the part of pixel shader input, can someone tell me if it's wrong?

#
void frag(v2f i, out fixed4 col : SV_Target)
            {
                half2 uv = i.uv;
                col = tex2D(_MainTex, uv) * _Color;
                col.r = _Transparency;
            }```
#

Before instead of void I wrote: fixed4 frag (v2f i) : SV_Target

#

but it's not functioning

#

While in the script I used material.SetFloat to control the _Transparency

#
public Material hpMat;
float health = 50;
float maxHealth = 100;

    void Start()
    {
        hpMat.SetFloat("_Transparency", health / maxHealth);
    }

void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            health -= 5f;
            hpMat.SetFloat("_Tranparency", health / maxHealth);
        }
    }
#

the health diminished by 5 each time I pressed space

#

And the _Transparency is 0.5 in view mode, so let's say it has been set in the Start as result of health / maxHealth

#

But in the game mode it remains 0.5 and cannot be changed

regal stag
#

I would usually use the fixed4 frag (v2f i) : SV_Target method but that might still work too.

.r would correspond to the red colour channel, so won't affect transparency. You want .a instead. Though .r may still be useful to check the property is changing correctly. The Update in your C# code currently has the property misspelled (missing the s).

For a shader to actually be transparent, it should also be in the transparent queue Tags { "Queue"="Transparent" } and use an appropriate Blend mode. https://docs.unity3d.com/Manual/SL-Blend.html, e.g. Blend SrcAlpha OneMinusSrcAlpha in the ShaderLab section of the shader.

quartz flume
#

Man

#

I hate this

#

...

#

That misspelling!!!

#

Every single time I'm committing the same mistake!

#

Thank you so much!!

#

col.a doesn't work btw

#

The value of transparency in the inspector is going down

#

but in the game view it remains red

#

as I set it in the shader inspector

regal stag
#

You could copy-paste the property name to avoid typos.
Also, it's better to convert it to an int to use in the SetFloat function if you're updating it each frame. That means you also only need to copy/type it once. e.g.

public Material hpMat;
float health = 50;
float maxHealth = 100;
int shaderProperty;

void Start(){
  shaderProperty = Shader.PropertyToID("_Transparency");
  hpMat.SetFloat(shaderProperty, health / maxHealth);
}

void Update() {
  if (Input.GetKeyDown(KeyCode.Space)) {
  health -= 5f;
  hpMat.SetFloat(shaderProperty, health / maxHealth);
}
quartz flume
#

I see, I didn't know this before. Thanks!

regal stag
quartz flume
#

lol I forgot to delete the // in front of my blend mode

#

Looks like it's working!

#

Thank you once again!

quartz flume
#

Putting: fixed4 frag (v2f i) : SV_Target in place of: void frag(v2f i, out fixed4 col : SV_Target)

#

Did I forget any line of code, or it just doesn't work?

regal stag
#

With the function declared as fixed4 frag (v2f i) : SV_Target, it needs to use fixed4 col = ... and return col; too. It's just a slightly different way of writing it, both end up being the same afaik.

quartz flume
#

Okay. I thought that writing void means that it can be changed and updated

#

While the other one can't

regal stag
#

No, void just means it's a function that doesn't return a value. (same in C# and other languages too)

quartz flume
#

But why it needs a return col;

#

While the void one doesn't?

#

Oh

#

You just answered that

#

lol

tame topaz
#

@drifting lance This isn't the space to ask for free work.

drifting lance
#

oh

#

sorry

loud remnant
#

How can I scale the UV? I need the UV to stay the same when I scale the object

lean lotus
#

Hey does anyone know how the performance would compare if you did all the lighting calculations and shading in a compute shader instead of in the usual graphics pipeline?

meager pelican
#

@loud remnant I'd suggest you google "unity world-space texture mapping" or "unity triplanar mapping" or some such, then come back with questions.

meager pelican
# lean lotus Hey does anyone know how the performance would compare if you did all the lighti...

It would probably suck big time.
The thing is, all these "regular pipeline" things have been developed over time as "tricks" to avoid doing what you seem to be suggesting. That is because if you want to do what you say, you'd end up ray-tracing your entire scene. If I understand you correctly.

Even the fastest beefiest cards right now only do a limited about of that type of thing, like for reflections as an example. And then they use AI to fill in the blanks.

Now, if you want to go Hollywood style, get ya a render farm, and ray trace everything. Only a few minutes per frame, and you can have movie-like results.
😉

But otherwise, unless you can mathematically describe your whole scene, or you can make a lot of buffers (color, depth, normals, etc) and then ray-trace it all, it is hard to even approach at all, but even if you can, you'll be faster the standard way.

Compute shaders aren't faster than regular shaders, really, they just organize the processor cores differently.

#

You're talking about not only screen space shadows, but screen space lighting, and screen-space reflection, and ambient occlusion, or whatever you're talking about. There's a lot of stuff to it all.

#

I think we'll get there eventually. 10 or 20 years?

lean lotus
#

ok thank you!

wintry ridge
#

Hey , want some quick info from you guys.
Is there some limitation with Render Textures and their formats in ios?
Do Render Texture behave differently on ios devices?

#

This is what comes in an iphone X (just talking about the shader working on the characters, it uses the depth to calculate those white outlines and renders them together to a RT that is pasted on a Quad infront of the camera)

rough plover
#

SVT for URP - any estimations?

low lichen
tacit parcel
#

Are you using multiple render target?
I'm not sure is mrt is supported on iOS

wintry ridge
wintry ridge
low lichen
#

@wintry ridge The effect just looks like standard fresnel to me. I don't see what depth could be doing in this effect. What occlusion type of effect are you talking about?

#

Avoid doing fullscreen effects on mobile if you can

tacit parcel
#

not necessary fresnel, looks like a simple rim lighting with some transparency could do the trick

low lichen
#

And how would you do rim lighting without fresnel?

tacit parcel
low lichen
#

@tacit parcel Yes, that's fresnel. The dot product of the surface normal and the view direction.

wintry ridge
#

Let me show the standard fresnel that we did

#

Photo from Nakul🎮

#

Did not look as good as that one. I am sure it can look good.
All because I can't fiddle around with the shader code and my friend does not have time to do a lot either.

low lichen
#

Do you like the low poly look of the other effect?

wintry ridge
#

Can anyone here help me with this effect? I'd love to hire someone to enhance the visual effects of my memory snippets.

wintry ridge
bitter path
#

Anyone knows why activating emission but settings it to 000 (to animate it later) on the URP standard lit shader turns it off on compile?

pale tapir
#

Hello there, someone knows the equivalent of that Shadergraph node in Amplify Shaders please? 🙂

#

I need the position of the gameobject... :/

regal stag
pale tapir
#

oh of course!

#

I should have though of that damned

#

as always you are the best @regal stag

#

Should be that then

#

without having to give any vector in

#

thanks again

regal stag
#

Yeah that should be right

#

@pale tapir Though something to bear in mind is that if the object is dynamically / statically batched it'll combine meshes and it'll change the origin. This'll only work for non-batched (or srp-batched) objects.

pale tapir
#

good to know!

#

but it's all dynamic

#

so that works 🙂

tight forge
#

I tried my hardest to convert the shader code logic as it was written into nodes

#

but i'm having no success in getting it to work on a hi-poly ribbon mesh
It's a big ask but if anyone has the time to take a look at my graph ....maybe you can see what I'm doing wrong?

#

long shot but it'd be massively appreciated ❤️

meager pelican
#

@wintry ridge I'd check the shader for half/float problems. What happens fairly often is that when you run on a desktop, all half values are done as full-sized floats due to the 'bigger' card. They don't even bother with half-precision. But in mobile, they use half to save on processing (heat/battery/bus-speed). So when you move to mobile calculations that worked on desktop don't work on mobile the same way.

I'm totally guessing here.
Check precision in the shader.

#

But since you didn't post the shader, IDK if this even makes sense or not. I'm surprised at the pattern and transparency.

meager pelican
#

@tight forgeJust my 2-cents, but if I were you I'd seriously consider making a custom-function node and putting all that math in that, with appropriate inputs and outputs to the vertex position. And maybe upgrading SG to one that has the vert/frag stack.

The example shader in your link is mostly a custom vertex function in a standard Surface Shader. If I read you properly.

spark spade
#

Hey guys. Any idea why Unity calls every shader pass twice?

tight forge
#

I can certainly give the custom func node a try, i hadn't thought of that! thanks @meager pelican i'll give it a go

spark spade
#

This is related to both custom and built-in shaders.

willow pike
#

I'm trying to solve an issue in my grass system. TLDR: I'm spawning dense fields of grass across large terrain-like mesh objects and combining the field of blades into one game object and what I'd like to do is be able to start with a grassy terrain and place buildings, rocks, trees and other details after spawning the grass but allow those details to displace the blades so they are compressed and not poking through geometry. Is there a feasible solution for this?

Deleting blades by hand has become untenable. I've tried using a custom renderer with mask shader to hide the blades. It works okay but it ends up masking the grass that should appear in front of objects too and it should only remove or hide the blades that are poking through geometry. I've also been trying a render texture solution where a top down ortho camera grabs mask objects on a hidden layer and feeds them back to the grass, but have been unable to translate the positions correctly back to the shader.

meager pelican
#

You could try calculating the worldspace position of the grass blade's x/z plane (no height) and then checking the depth buffer to see if that worldspace position varies from something. Like draw all the rocks/trees first, not even terrain, and then you can tell if you have any "objects" there, then draw terrain, then grass.

Guessing.

#

Would work all long the height since you can ignore height.

#

IDK why you want to draw grass first, you can't really "take that back" and displace it later after it is drawn.

willow pike
#

Yeah it makes for a difficult problem. The reason we're doing it this way is so we can compose and visualize large areas of the game world and we want to be able to have the option to change the locations of buildings and trees and so on without having to rebuild the grass mesh each time we move something.

spark spade
#

You won't need to rebuild the grass mesh if you displace the blades in the shader.

willow pike
#

Trying to find a way to do this that is non destructive. The grass fields are spawned and combined into one large mesh obejct after blades are placed to avoid performance issues or having hundreds of blade object.

low lichen
#

Do you want to prevent grass from appearing to clip into objects or do you want to prevent seeing grass from outside clip inside interiors?

#

To rephrase, would you be okay with a solution that only hides the part of the grass that has clipped inside, rather than hiding the whole blade of grass if part of it clips?

willow pike
#

Hmm potentially

low lichen
#

You mention trees, though. I'm thinking more about building interiors.

willow pike
#

This image summarizes my problem pretty well, you can see the grass appearing to stab up through the tree trunk and rocks

low lichen
#

The solution I'm thinking of wouldn't fix this example

#

Is this grass just quads with grass texture on it or is each blade modeled?

willow pike
#

The grass is one combined mesh composed of quads mapped directly to the terrain mesh it sits above. The quads are spawned at each vertex on the terrain and offset slightly randomly to look more natural. Then the quad is UV mapped to 1 of 4 grass blade textures randomly to look more natural as well.

low lichen
#

I don't think there's any shader trick you can use to fix this problem. There just isn't any way to determine if something is inside other geometry vs just behind it.

#

So I think the solution would be via script

willow pike
#

Yeah...hmmm

low lichen
#

maybe if you had a top down texture of the terrain marking where objects are on the terrain, you could sample this in the grass shader to determine whether it's inside an object

#

I think that's what you meant by the mask shader approach

willow pike
#

Yeah exactly

#

I was trying something like this but the render texture wasn't properly capturing the view. I could only get my "grass benders" to stay positioned properly when my game was using a 1:1 ratio camera

low lichen
#

You're not using Unity Terrain, right?

willow pike
#

No it's just a subdivided plane made in probuilder and distressed

#

These images might not be useful at all to you but here's where I'm at with the render texture in a test enviro. The blue circles should stay positioned to the player as well as the tree trunks. The black area represents grass that would be uncompressed and blue would be fully compressed. Could soften the effect around edges later. In 1:1 display it's working.

#

But here you can see that in 16:9 the render texture doesn't map properly. It seems a render texture camera always captures the image in a square format.

low lichen
#

Why is the view isometric rather than top down?

#

How many of these circles do you think you'll need?

willow pike
#

I'm mapping the render texture using the screen position

#

the circles are captured from sphere meshes that are on a hidden layer that only the render texture camera is grabbing

#

so for a house it may be a blue rectangle, but the idea would be that the blue areas would be read by the shader to do the displacement

low lichen
#

I'm only asking because if it's a reasonable number, you could just pass in an array of sphere positions into the grass shader and have it loop through it

willow pike
#

that was my thought too but they will be different sizes based on the objects and if there are a lot of rocks and trees on screen that would be a lot of stuff to loop through rather than reading from a single RT once

meager pelican
#

You need to map the base of the grass to the xz position of the mask.

willow pike
#

Right that's the solution I've seen although following a few different tutorials that all use the same method did not seem to work in my case. This is the conversion I have found but it does not seem to be showing in the shader.

#

Subtract camera position from world position, multiply by orthographic camera size and offset by 0.5, 0.5 to get center of UV

low lichen
#

It doesn't make sense to use the Screen Position in any of this though

#

Are these two separate solutions or are you using both at the same time?

willow pike
#

They are separate, the second one is the correct one from what I've read, that should be fed into the UV of the RT

#

but I'm getting no results from that, the screen position doesn't make sense but has been much closer to displaying what I want

low lichen
#

Have you tried outputting some of those values in the shader to see what they are?

#

Like outputting UV directly as color instead of using it to sample the mask texture

#

Is it all black? All white? Something else?

willow pike
#

I haven't but that's an interesting idea, so just output the end of that graph to a color?

low lichen
#

Yes

willow pike
low lichen
#

This part seems to be the 0,0

meager pelican
#

It looks "backwards" too, black should be lower left normally, yellow upper right. But I haven't figured out their shader yet.

#

That's not flipped rendering.

willow pike
#

Hang on my values for ortho size and cam position are not reading here

#

Hmm I just manually put the orthographic size and position into the graph and the results look the same

meager pelican
#

IDK if it depends on what direction you're facing or not. Those are offsets I suppose.

#

Is your main camera ortho or perspective?

willow pike
#

Main cam is ortho

grand jolt
#

None of this math makes any sense to me and I wrote smth like this in HLSL 😄

meager pelican
#

So you're drawing this "map" for a really large area all the way to the far plane? And trying to map worldspace gras location to it.

#

Hey Beat. 🙂

grand jolt
#

Heyo.

#

It me, the serial project non finisher.

willow pike
#

Does this look more correct?

meager pelican
#

Yes, but I'm guessing. I don't understand your shader yet.

willow pike
#

If it helps, this tutorial is what I've been following

meager pelican
#

That would put 0,0 to be center.

#

Or near it

stable lake
#

Hello, anyone with more knowledge on shader graphs, can anyone tell me why the texture scales like this?

#

trying to make a tree material that works with hdrp but im trying to scale it so it fits better, rn it looks like this

verbal python
#

hi
umm i need help if u can please?

- Library\PackageCache\com.unity.xr.management@4.0.5\Editor\XRGeneralBuildProcessor.cs(83,52): error CS0117: 'BuildPipeline' does not contain a definition for 'GetBuildTargetName'

idk what to do to this thing and i cant rename anything its just wont let me

grand jolt
#

@stable lake maybe the texture is set to clamp in texture settings? Is that a thing?

verbal python
#

umm help?

verbal python
#

;-;

grand jolt
#

@verbal python you need to use at least Unity 2019.4 to import that package.

#

Anyway, pretty sure you can also override the sampler on shader level.

verbal python
#

i have 2021 @grand jolt

#

2021.1 ....

meager pelican
#

@willow pike They're using grass polygons, and offseting them based on a lookup texture that represents bend forces. Right?

But that's not exactly what you want. You want to clip your grass, and IDK if you have individual polygons for grass (I was unclear on that).

verbal python
#

ey

grand jolt
#

Wrong chat btw, Malusic.

stable lake
#

another thing, does anyone know how to create a material for leaves in shader graph? i tried the texture to alpha node, then made it transparent, but doesn't quite behave like it should.

grand jolt
#

Alpha transparency for vegetation is crazy expensive.

#

Just use alpha clipping.

#

You probably didn't tick Alpha is transparency in texture import settings.

verbal python
#

@grand jolt wish channel can i get help with?

grand jolt
#

Or maybe you forgot to split the base color vector and connect the alpha channel with the Alpha on the master node.

willow pike
verbal python
#

😐

grand jolt
verbal python
#

umm k

grand jolt
#

@stable lake I answered a bit higher 👀

stable lake
#

yeah man i am trying to get it working but this shader graph thing is basically chinese to me, but your answer is really helpful

#

just not sure why my alpha clip threshold is greyed out

grand jolt
#

Cause you didn't enable alpha clipping in master node inspector.

stable lake
#

ah

meager pelican
grand jolt
#

You can do fast culling by emitting a Nan, Nan, Nan vector as vertex position 👀

#

Courtesy of Far Cry V terrain.

meager pelican
#

In mobile, without crashing them? Cool.

grand jolt
#

Only on PC and all consoles 😢