#archived-shaders

1 messages ยท Page 78 of 1

tired skiff
#

IS there any way to make stancil shader in shader graph?

tame topaz
#

If you can help people, you can do so freely. But this isn't a job board.

deep acorn
#

ok this might sound stupid, but i feel like i gaslighted myself into thinking a shader i got from a youtube tutorial worked for me. i am like 99.99% sure i had it working at some point, but now i simply can't get the shader to work again. i've been stuck for hours. i checked out my older git commits, even one i did right after implementing the shader, but even in that state the shader is not working anymore... i have no idea what i did wrong, everything should be working fine..?

if there is anyone, that would be willing to look at my problem a little closer, please message me. i could really use somee help here. ๐Ÿ˜ญ

deep acorn
#

thanks to @full sail my problem was fixed!

full sail
#

For anybody who cares about this later, fixed it myself but it's foul, if anybody looks at this code and can see a more elegant solution, I'm all ears:

{
    // Calculate intermediate colors
    fixed4 topLeftCol = (LeftCol + TopCol) * 0.5;
    fixed4 topRightCol = (RightCol + TopCol) * 0.5;
    fixed4 botLeftCol = (LeftCol + BotCol) * 0.5;
    fixed4 botRightCol = (RightCol + BotCol) * 0.5;
    fixed4 centreCol = (LeftCol + RightCol + BotCol + TopCol) * 0.25;

    // Calculate gradient values
    float lX = clamp(uv.x * 2, 0, 1);
    float rX = clamp((uv.x - 0.5) * 2, 0, 1);
    float bY = clamp(uv.y * 2, 0, 1);
    float tY = clamp((uv.y - 0.5) * 2, 0, 1);

    // Interpolate colors for each quadrant
    fixed4 blQuadrant = lerp(lerp(botLeftCol, BotCol, lX), lerp(LeftCol, centreCol, lX), bY);
    fixed4 brQuadrant = lerp(lerp(BotCol, botRightCol, rX), lerp(centreCol, RightCol, rX), bY);
    fixed4 tlQuadrant = lerp(lerp(LeftCol, centreCol, lX), lerp(topLeftCol, TopCol, lX), tY);
    fixed4 trQuadrant = lerp(lerp(centreCol, RightCol, rX), lerp(TopCol, topRightCol, rX), tY);

    // Determine the quadrant based on UV coordinates
    if (uv.x < 0.5)
    {
        if (uv.y < 0.5)
            return blQuadrant;
        else
            return tlQuadrant;
    }
    else
    {
        if (uv.y < 0.5)
            return brQuadrant;
        else
            return trQuadrant;
    }
}
tired skiff
#

Is there any way guys to connect all these outline of these sphere and remove the inner outline among the intersection of those?
I just need one outline resulting from the sum of all ispheres

#

Anyone have any ideas?

lost stirrup
#

Hey guys. I'm trying to make a toon shader using shader graph and it's working so far. At the moment, I want to add support for normal map, so I isolated the normal map logic in another shader to do my tests and this was the result I got, but the result is not convincing me, I wanted to know if anyone understands what I am I doing it wrong? In particular, there is a vertical stain that accompanies my material and I have not been able to resolve it.

foggy pulsar
#

guys how do i remove the shine

#

im quite new

kind juniper
kind juniper
foggy pulsar
kind juniper
foggy pulsar
#

sorry im new to this

kind juniper
#

I don't see any shine now

foggy pulsar
#

i set thespecular color to black and now its gone

#

thanks

wanton grove
#

Are materials all compiled independently or is it just the shader they use?

kind juniper
toxic canopy
#

Hi is someone experienced with shader code and can help me modify a shader to show transparency with alpha from a png?
I currently use a shader to offset vertices to deform with distance to camera to give a small planet feeling like animal crossing or subway surfers. I give texture as input but I dont know how to get the transparency from the texture to work

toxic canopy
#

I just now got it working :)

#

i added alpha:auto to my pragma

regal stag
blissful finch
#

Hello! I want to make an outline for some object in my game. I've searched up some techniques, but they all seem flawed in some way. Is there a way to make a shader that would change the pixels outside of the object? Or can it only affect the pixels inside? I thought if one could color the pixels that are just outside the object, it would make quite a good result?

regal stag
toxic canopy
#

Has anyone got a clue why my plane goes fully transparent and then gradually goes back to normal again?

#

if the shadow displays kinda depends on my viewing angle

#

from the back it display from the front it vanishes

#

the error does not exist while not in play mode

hexed sorrel
#

Does anybody know how to log a texture created by a custom render feature, it unfortunately is not showing up in my frame debugger at all, so I don't really have much confirmation whether or not it is actually working, if anyone has any debugging tips that would be amazing, thanks all!

jovial moon
#

hello, I'm still working on my water shader and faced another issue: I'm doing refraction which probably is screen space related. To avoid refracting parts above the water i decided to use scene depth. Everything works fine, but there is an issue, with this strange border line, where i guess depth is enough for not refracting, but there is still color of the object underwater. Please, help me, if you know how:/

viscid knoll
#

depth is nice to create foam or intersection effect with the surface

viscid knoll
jovial moon
#

๐Ÿ˜ฆ

viscid knoll
#

your water surface should be depth writting less equal, so you should not have refraction everywhere by default

hexed sorrel
jovial moon
viscid knoll
#

@jovial moon ah ok I understand your issue, in the shader you add the depth to the "refracted UV", don't do that, to get or the refracted or the non-refracted UV in the scene color node, just Lerp the refractedUV and the ScreenSpaceUV, using the depth as the Lerp influence/mask, then plug the lerp output as UV in your SceneColor

viscid knoll
hexed sorrel
jovial moon
#

๐Ÿ˜ฆ

#

ill try to filter it with calculating near pixels

glossy pulsar
#

(ideally using shadergraph as much as possible, idk hlsl yet) I want to make an effect like this for my character, and I was thinking I could use edge detection but the issue is that most stuff seems to be so close together in terms of normal and depth values it would just be near impossible. Is this actually possible in shadergraph to perfectly line up the edges or am I just going to have to give up that dream and use textures and emission?

steel notch
#

So I have a photoshop file here with a series of images/layers that I want to recreate in Unity.
Some of the layers have specific types of blends (such as pass through) so I can't simply export them and then layer on top.
And tips?

grizzled bolt
steel notch
#

No fancy shmancy stuff?

grizzled bolt
#

Every layer would have to be a sampled texture in your shader, which you then blend

#

That's probably all

steel notch
#

A bit annoying when there's many layers involved.

#

Meh, should be fine.

paper maple
#

whenever i create a new sprite shader graph lit or unlit. the color doesnt seem to effect the preview, the preview is always bright purple regardless of the color output node

grizzled bolt
paper maple
#

how can i fix that?

twilit vessel
#

my material works fine when placed on an image, but when placed on the spriterenderer its completely gray

#

this is the material

#

the object then looks like this

kind juniper
# twilit vessel

A sprite renderer would pass the Sprite as the main texture, which would probably override the albedo texture in your material.

twilit vessel
kind juniper
twilit vessel
#

the only image option is in UI

twilit vessel
kind juniper
#

If you want to use an arbitrary material, use a mesh renderer with a quad mesh.

twilit vessel
#

nevermind i got it

twilit vessel
#

does it have to do with lighting possibly or the material

kind juniper
#

If you need to render an unlit sprite, why not just use sprite renderer with it's default material?

twilit vessel
kind juniper
#

If you have multiple sprites, maybe you want to use a tilemap..? Are they tile sprites?

twilit vessel
#

but i have considered it

kind juniper
twilit vessel
kind juniper
#

Maybe provide better explanation, so that we can give better guidance.

twilit vessel
#

wherever ground is supposed to be

#

but when the actual png is side by side its not stitched and clean there is an obvious line

kind juniper
#

What does it look like? What does the game supposed to look like? Are there any existing games that have a similar look?

twilit vessel
#

not pixel

kind juniper
#

Is it sidescroller, like terraria, or top down view like jrpgs?

twilit vessel
#

no top down

#

farming aspects

kind juniper
#

Then tilemaps most definitely sound like what you need.

twilit vessel
#

alright sounds good

#

i need to relearn it, how to scale the png down to fit

kind juniper
#

Yeah, go though the manual or maybe a course on unity learn

wet ermine
#

Hi all! Would anybody know if it is possible to "unwrap" a mesh into it's UV islands shapes using Vertex Displacement? I mean something like this:

kind juniper
wet ermine
#

Can't I transform vertices in a way that they take their position on the UV space?

kind juniper
#

Just loop every vertex, assign the uv position to it's actual position and reassign the positions array to the mesh.

low lichen
paper maple
#

when i input my texture it gets distorted. its just a sprite sheet of a bunch of 8x8 pixel sprites

kind juniper
#

Try disabling compression and setting filtering to point/none in texture import settings.

paper maple
#

yes ive done that

#

i found that when i put it in a sprite atlas it got distorted in a similar way

#

but enabling alpha dilation seemed to fix it

#

theres no option for alpha dilation in shaders

kind juniper
# paper maple

Are you just relying on the node preview? Is there actually an issue when you use the shader in the scene view?

paper maple
#

well when i watch videos on this their preview typically shows the sprites. i have tried playing once or twice and saw it was distorted in game but havent been consitantly testing it

wet ermine
paper maple
#

i just tested and it didnt work in game either

kind juniper
paper maple
#

didnt change anything

#

i just tried with a few different sprites and saw the same distortion

kind juniper
paper maple
#

stays the same

slate badger
#

im pretty new to hdrp is there an equivalent/similar of SHADERGRAPH_SAMPLE_SCENE_DEPTH and SHADERGRAPH_SAMPLE_SCENE_COLOR like in URP

#

oh wow it was literally just SampleCameraDepth and SampleCameraColor

#

me feel dumb

steel notch
#

Alright I need to understand the implications of this. So I have a PSD with these color space properties.

#

I export individual layers in sRGB.

#

When I bring them into Unity, the colors look off.

#

Especially with semi-transparents.

#

Initially I was in Linear space, but the colors seemed to return to normal in Gamma.

#

All the textures have this property set.

#

Why do things look off in linear? What are the implications of gamma? What do I need to do to make these textures behave in linear?

steel notch
#

This is the issue I'm experiencing.

raw cliff
#

Sup. What's up with a generic HDRP/lit and built-in color change? I made a cutsom shader with hue value (left) and this is how color-wheel works in HDRP/lit shader (right). Is there a build-in way to do hue change without custom shader?

hexed sorrel
#

Does anybody know how to log a texture created by a custom render feature, it unfortunately is not showing up in my frame debugger at all, so I don't really have much confirmation whether or not it is actually working my full code can be found in this thread: https://discord.com/channels/489222168727519232/1237362201099108352 Any ideas would be extremely appreciated, thanks!

tacit parcel
trail void
#

why when i set alpha is transparency , this happens?

#

even on preview it is right

low lichen
trail void
grizzled bolt
# trail void even on preview it is right

The preview is misleading to imply that "alpha is transparency" makes the background transparent
In reality it dilates colors as you see above, so that the black or white pixels that normally fill the transparent areas cannot leak into the visible pixels

grand jolt
#

How could I create this sort of pattern in HLSL? I'm not very good at shaders yet

glossy pulsar
# glossy pulsar

as a follow up to this, it works great up-close or with larger objects but on more detailed objects it has a bit of a fit when the camera is even vaguely far away, which is an issue

#

is this just a reality I have to accept or is there a way to account for the distance to the camera? I assume it's due to less precision so is it even viable to maybe eat the performance cost a little and pre-process over a higher resolution?

paper maple
#

Giving up on this for now but if anyone knows a fix please lmk. ive changed half the settings in unity but i cant seem to get a sprite 2d shader graph to work with my sprites

#

it feels like it stretches them to fill the page idk

#

most of the sprites are 8x8 but a could are 8x12. i tried changing them all to 12x12 for consistancy and even that didnt work

#

heres my current settings brw

#

i have no compression and i use mitchell resize

regal stag
grizzled bolt
paper maple
#

oh fr

#

yea i disconnected it

#

because it was mess up

#

ive been trying to add a custom alpha imput

regal stag
grizzled bolt
regal stag
grizzled bolt
regal stag
#

Should be able to use them in a custom function node yea

copper vessel
#

hey. can someone help a bro out? im not sure what im doing wrong i followed every step of tutorial guy

regal stag
copper vessel
#

Although, i have now a new small problem. When the outline is at 0.99 is not visible at all. when its at 1. it will cover ALL the object. I tried with others objects which were not streched and stuff but its the same.

grizzled bolt
copper vessel
#

I also checked and make sure the material on the Graph inspector built in material is Unlit.

grizzled bolt
copper vessel
#

i closed the project, open it again and it works ๐Ÿ’€

tired bobcat
#

Hey guys how to know which shader variant a material is using?

regal stag
tired bobcat
#

my guess is that this variant is not getting included in the bundles

#

Because if i uncheck the shader stripping (don't strip unused variants) the problem goes away but it crashes on ios and also take so long to build bundles

regal stag
tired bobcat
#

Is there a way to increase this limit. Sorry this shader is not written by me

regal stag
#

I don't think so, it's a hardware/gpu thing

tired bobcat
#

whats weird is that this issue has only been recently come up and these same variants were working fine a week ago. Do u think any urp settings can cause this ?

grizzled bolt
tired bobcat
zealous quiver
#

Hey has anyone else run into the issue with the Unity Toon Shader package, where transparency doesn't work on webgl?

regal stag
regal stag
tired bobcat
heavy plover
#

Is there a simple way of creating a "mesh based layer mask shader". Like hide the part of the grey cube that is inside the collider with a given tag?

stiff nexus
#

@deep moth There appears to be another bug with the outlines. The outlines are staying visible in the same way they were staying on the sky, but now they are doing it on objects with the unlit shader.

deep moth
#

And sometimes shows thru

#

You could try to make the effect run right after opaques in the queue

#

Rather than after or before post processing

stiff nexus
#

but before fog

#

so the outlines don't appear over the fog

stiff nexus
#

or should I instead make the object transparent

#

Oh wait, enabling alpha clipping on the object gets rid of the outlines on top of it?

little bloom
#

How do I create a white shader like this?

heavy plover
little bloom
heavy plover
#

The surface seems rather flat, if you want it curved I guess you could just straigh up apply a dotted border texture to the material itself

deep moth
deep moth
#

check if writing depth fixes it for you -- there's probably another fix there too

tacit parcel
#

using texture works, but the dotted lines will be stretched as you scale the decal

gusty portal
#

Hey! For some reason my shaderGraph effects arent rendering in the game, but it is in the scene. Is there anything I should be looking for to fix this??

deep moth
#

do you have the depth texture enabled for your camera ?

wild valley
#

hi all, is there any web with shaders or shader graphs, to learn or even to use?
I'm trying to make a circle, with a smaller circle inside, each with one color, but I'm having a problem with the lerp mixing the colors

what i want is the "step" output to be used as a mask for the colors but instead they are "mixed" in some way, i want a clean "ring" with a clean "circle" inside each of one with the color i choose

#

i can see videos like this one: https://www.youtube.com/watch?v=rj129Wc1vyo&ab_channel=PabloMakes
but is there any place to get resources like those shaders so i can use them or play with them? Can't find too much in the unity store

Being able to draw different shapes in a shader can be really useful to avoid having to use a lot of textures, make images that can scale in resolution without being pixelating like a texture would or make shapes that can be modified on the fly.
This tutorial shows the principles that can be used in any shader, but focuses on using ShaderGraph, ...

โ–ถ Play video
regal stag
wild valley
regal stag
wild valley
regal stag
#

Actually also, what graph type is this? I think canvas and sprite types already apply vertex colours automatically, which may be the problem

wild valley
#

I want the vertex color on a ring outside the circle and another color inside. "Group Color" but they seem to mix with that graph. the Group color for the center is not what it should be it is a strange mix as you can see on the purple example

regal stag
#

Check under the Graph Settings. I can't remember if they've added an option to disable the graph auto-tinting

wild valley
#

ummm triying, i suppouse i should set disable color tint on the Color fragment

wild valley
#

I want to make some kind of "biologic cell" with pseudopodos or something but it seems I need tons of youtube videos and months of experiments

main sable
#

Hi there, would like to know if you know a way to make a kind of emitting object but with a non solid aspect, like in my game I would like to play a star as the main character in a cartoon style but I don't really know how to make it smooth enough to remove the solid aspect

main sable
#

Omg ๐Ÿ˜ญ

#

It looks really good for real but omg I definitely don't have the required level to reproduce it ๐Ÿ˜ญ

wild valley
#

I was thinking the same to me ๐Ÿ™‚ also the graph image needs some "imagination" against the png quality ๐Ÿ™‚

main sable
#

My first thought was : "hey this guy sent a behance link, I'm pretty sure I won't be able to understand it" ๐Ÿ˜‚

#

That's also true like I could copy and paste but imagining the same quality for what I have in my mind

#

well

#

nah

regal stag
wild valley
#

!!!!!! that's a tutorial! thx!

main sable
#

Omg thank you so much!

#

Look, what I wanna do is to make this star looking like a particle that later I would control as the main character you know, but I tried many ways to do it but I don't really know how to make disappear this solid aspect, i took a random 3D model to test it

#

I think that using a particle would be better than using a model

main sable
#

I found this which would be more similar to what I want

#

๐Ÿ‘ Special effect tutorial! How to create a glowing orb using Unity's particle effects! In this tutorial we build a blue electric sphere visual effect by combining different types of particles.

++++++++++++++++++++++++++++++++++++++++++++

โค๏ธ Subscribe to Oxmond Tutorials. New tutorials every day! Stay tuned!
https://bit.ly/SubscribeOxmondTutor...

โ–ถ Play video
knotty yarrow
#

hi, im trying to get binormal and tangent vectors out of ddx and ddy, but for some reason I cant connect my position vector to it, anyone happened to know why? ^^

regal stag
knotty yarrow
#

can u explain? im a bit new to this..

regal stag
# knotty yarrow can u explain? im a bit new to this..

I assume you are connecting the Add node to the Position port, which is under the heading of "Vertex" in the master stack. Shadergraph is designed to lock nodes into a specific stage when connected. It usually doesn't let you connect to any nodes already connected to the fragment stage, and in this case possibly nodes that can only function in the fragment stage (like DDY and DDX)

#

In short, it's best to keep chains of nodes going into ports in the Vertex and Fragment stages completely separate

knotty yarrow
regal stag
#

You can't connect DDY and DDX nodes to the Vertex stage, they only function in the Fragment stage

#

If you're using a Lit graph type, there is a Normal port there too. (Defaults to tangent space, but can change that under Graph Settings if required)

#

e.g. if your aim is to generate flat normals from the vertex displacement (note, uses Normal Output Space : World)

knotty yarrow
#

and yes i am on lit graph type

#

do i need to toggle something first?

#

wait no nvm i found it

#

let me try

regal stag
#

You might have removed the block, but you can re-add it by right-clicking in-between or at the end of the list

#

Changing the output space under the graph settings might also make it appear

knotty yarrow
#

uhh i am still unable to connect my position to the ddx nor ddy port

regal stag
#

You need to use a new Position node, not an existing one connected to the Vertex stage

knotty yarrow
#

oh it works, i didnt know u need to use a new position node

knotty yarrow
pseudo wagon
#

Does it mean that if I connect a node to both the position and the color outputs, then the bloc will be computed twice if the final shader ?

regal stag
regal stag
pseudo wagon
#

Yep I realized that some blocks cannot be connected to some outputs

#

Damn that's interesting, sounds like a massive extra work

#

Maybe there's not much I can do about it

regal stag
#

Not sure what you mean by massive extra work. It shouldn't really be that hard to keep the stages separate

copper vessel
#

hey i have question. why i cant connect to vertex? i need to.

#

im using an unlit material.

#

not sure if that matters.

regal stag
copper vessel
regal stag
#

Though if you're using some custom lighting functions you may require URP

copper vessel
regal stag
#

If a graph uses Universal under the Graph Settings, the project has to have URP configured for it to work. But any other materials using custom shaders for Built-in RP may stop working.

copper vessel
#

wait i do have a custom function

regal stag
#

I'd recommend backing up the project before configuring. Just in case you need to roll back.

copper vessel
#

alrighty

bleak raven
#

Good afternoon,
I'm having trouble with a shader graphs' custom node. I'm following this article https://storyprogramming.com/2019/09/17/shader-graph-force-shield-with-hits/ and I'm stuck at the custom node section. I'm using a different unity version(2022.3.16f1) than the article (2020.2.1f1) and the code for the custom functions returns two errors, that say in the beginning:
"Shader error in 'Shader Graphs/Master': variable '_CalculateHitsFactorCustomFunction_d729218cb39c488cbcbb5ce3ed13d5c2_HitFactor_1_Float' used without having been completely initialized at line 404 (on d3d11)"
, propably pointing to the "out float factor" in line 16:

#ifndef FORCE_SHIELD_BULLET_HITS
#define FORCE_SHIELD_BULLET_HITS

int _HitsCount = 0;
float _HitsRadius[10];
float3 _HitsObjectPosition[10];
float _HitsIntensity[10];

float DrawRing(float intensity, float radius, float dist)
{
    float border = 0.05;
    float currentRadius = lerp(0, radius, 1 - intensity);
    return intensity * (1 - smoothstep(currentRadius, currentRadius + border, dist) - (1 - smoothstep(currentRadius - border, currentRadius, dist)));
}

void CalculateHitsFactor_float(float3 objectPosition, out float factor) // <-- this one here maybe?
{
    factor = 0;
    for (int i = 0; i < _HitsCount; i++)
    {
        float distanceToHit = distance(objectPosition, _HitsObjectPosition[i]);
        factor += DrawRing(_HitsIntensity[i], _HitsRadius[i], distanceToHit);
    }
    factor = saturate(factor);
}
#endif```

But I can't seem to find a solution by myself. Do you have any idea, what's wrong there?

Using Unity 2019.2.1f1, LWRP 6.9.1 and Shader Graph 6.9.1. You can get the articleโ€™s code and shaders here. I sawย the tweetย byย Cyaniluxย and found out that Shader Graph&#82โ€ฆ

regal stag
bleak raven
copper vessel
#

๐Ÿ˜ญ

#

ok i fixed it i think.

#

Although, it seems like my toon shader broke even worse and now it says on the top "nothing loaded" like say what

plain hedge
#

i dont know if this belongs to shaders but my 3d object like flash bright white when i turn the camera in the editor and also in game

#

it falshes like every second degree i turn the camera

#

either its original or bright white

lone crow
#

How to keep the color same no matter what the angle is

kind juniper
lone crow
kind juniper
#

What surface? What shader I'm asking. The standard shader? Or is it a custom shader?

lone crow
#

custom surface shader

kind juniper
#

Share the code/shader graph of the shader

lone crow
#
Shader "Custom/Grass"
{
    Properties
    {
        _WindNoise("Wind Noise", 2D) = "blue" {}

        _TopTint("Top Tint", Color) = (1, 1, 1, 1)
        _BottomTint("Bottom Tint", Color) = (1, 1, 1, 1)

        _Metallicness("Metallicness", Float) = 1.0
        _Smoothness("Smoothness", Float) = 1.0

        _WindSpeed("Wind Speed", Float) = 1.0
        _MaxDisplacement("Max Displacement", Float) = 1.0
        _PositionToUVModifier("Position To UV modifier", Float) = 0.1

    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }

        // Allow Grass to render both sides of the mesh.    
        Cull Off

        CGPROGRAM
        #pragma surface surf Standard fullforwardshadows addshadow vertex:vert
        #pragma multi_compile_instancing
        #pragma target 3.0

        sampler2D _MainTex, _WindNoise;

        float4 _TopTint, _BottomTint;

        float _Metallicness, _Smoothness;

        float _WindSpeed, _MaxDisplacement, _PositionToUVModifier;

        struct Input
        {
            float2 uv_MainTex : TEXCOORD0;
            float3 worldPos : TEXCOORD1;
            float value : TEXCOORD2;
        };

        float looper(float2 coordinates)
        {
            coordinates.x -= floor(coordinates.x);
            coordinates.y -= floor(coordinates.y);

            float4 value = tex2Dlod(_WindNoise, float4(coordinates, 0, 1));

            return value.x;
        }

        void vert(inout appdata_full data, out Input o)
        {
            ...
        }

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            o.Albedo = lerp(_BottomTint, _TopTint, IN.uv_MainTex.y);

            o.Metallic = _Metallicness;
            o.Smoothness = _Smoothness;
        }

        ENDCG
    }

    FallBack "Diffuse"
}
kind juniper
lone crow
#
void vert(inout appdata_full data, out Input o)
{
    UNITY_INITIALIZE_OUTPUT(Input, o);

    float3 mesh_world_pos = UNITY_MATRIX_M._m03_m13_m23;

    float2 lookupCoords = float2(mesh_world_pos.x * _PositionToUVModifier + _Time.y * _WindSpeed, mesh_world_pos.z * _PositionToUVModifier);

    float3 displacement = float3((looper(lookupCoords) * _MaxDisplacement - .5) * data.texcoord.y, 0, (looper(lookupCoords) * _MaxDisplacement - .5) * data.texcoord.y);

    displacement        = mul(float4(displacement, 1), unity_ObjectToWorld).xyz;

    data.vertex += float4(displacement, 0);
}```
#

the position of the mesh in world space is used to get a noise value from a scrolling noise texture, this noise value determines the amount of displacement that is applied

kind juniper
lone crow
#

in the video i sent above

kind juniper
#

in shader code I mean

lone crow
#

wait

kind juniper
#

If that doesn't help, then it must be your albedo calculation

lone crow
#

nope

#

nothing changes

kind juniper
#

Assuming the _BottomTint and _TopTint are constant, the IN.uv_MainTex.y is probably dependent on the camera angle for some reason.
For starters, define constant values in the shader instead of _BottomTint and _TopTint and see if that helps.

lone crow
#

aight

#
float4 bottomTint = float4(0.5656912, 0.7830189, 0, 1);
float4 topTint    = float4(0.2227924, 0.7735849, 0, 1);

o.Albedo = lerp(bottomTint, topTint, IN.uv_MainTex.y);
#

same results

kind juniper
#

Since it doesn't seem like you modify the uvs in your code, it must be unity doing something to it.

lone crow
#

If I set the color to black then there are no highlights

kind juniper
#

What color?

lone crow
#

only happens when I use different top and bottom colors

kind juniper
#

Well, yeah, that's what you're lerping between

lone crow
#

yeah, when I lerp between different colors then it appears to have this weird highlight

kind juniper
#

I'd try using a fragment shader instead of surface, since we don't know what unity does with the uvs

lone crow
#

well yeah I thought I get built in lighting thats it

kind juniper
#

If you want to debug this further, you'll need to see the full shader.

deep moth
# lone crow ```glsl void vert(inout appdata_full data, out Input o) { UNITY_INITIALIZE_O...

hi!

I'm 90% sure the issue you're having is that your normals aren't being recalculated in your vertex shader. If you wanted to get constant lighting you could just have the normals point up. To me it looks like they're pointing toward the camera. I'm pretty sure that surface shader is giving you a little bit of reflection from the skybox which is that line you're seeing.

I'm too sleepy to explain this well tonight but the easiest way to get accurate normals is to sample your displacement function three times (at a position, tangent, and bitangent) and then combine them together with the cross product to get your resulting normal. Ronja explains really well here if you scroll down: https://www.ronja-tutorials.com/post/015-wobble-displacement/

If you look into other ways to get normals in my experience you tend to get swept into a calculus rabbit hole.

steel notch
#

I've been looking into card games recently, specifically how they build out their 3D cards (parallax, distortions, holographic effects etc). I tried my hand at this a while back and was mostly satisfied with the result.

#

But this was built from a combination of layered/masked sprites (flat 2D transparent images).
When it comes to games like Pokemon TCG Pocket, Marvel Snap, Legends of Runeterra, MTG Arena etc, do you think they go the layered sprite route, or try to build the card out as one big opaque 3D mesh? Do you think a proper mesh is the way to go?

humble robin
#

would adding a functionality to shader that is going to used by a low amount of objects negatively affect the performance for other objects more than creating a new shader? i might be bad at explaining but heres what i want to do: i'm planning to add a dissolve effect to my toon lit shader. But it is only going to be used by a few objects, should i make a different shader called toon shader lit with dissolve or add it to the main one? which one would be more optimized?

regal stag
# humble robin would adding a functionality to shader that is going to used by a low amount of ...

For simplicity, rather than duplicating the shader and needing to keep them equivalent, you could use keywords to enable/disable that part. It'll compile the shader into multiple variants for you. (Though may also need to override stuff on the material such as renderQueue - you'd want the regular toon lit to be in "Geometry"/2000 but dissolve should be after that)

Different shaders/variants means those objects batch separately though. You'd probably need to try both and profile to see which option is better. But as dissolve relies on alpha clipping which disables early-Z, I'd guess it's a good idea to keep that functionality separate.

humble robin
#

Thanks a lot! I didn't know about keywords, it looks like the exact thing I was looking for. I think it was possible to change render queue on different materials so it probably wouldn't create a problem.

woeful breach
#

How could I add fish to my water shader ?

regal stag
woeful breach
#

okay

tropic crow
#

Hi! I have a lightmap that I baked on a static object and I want to apply this lightmap in a shader graph (as a texture) on a skinned object. What are the math steps that need to be taken to achieve the same look as if the object was using the lightmap the normal way? (Because simply multiplying the basecolor doesn't work)

safe kelp
#

Hey, I'm having a very difficult time understanding how to create a shader graph shader that uses the Image sprites "Image Type" to mask out shapes. This is for the URP Pipeline (Universal Render Pipeline)

I notice that shader graph materials (even sprite ones) break when applied in the image settings.

What I'm trying to do is mask my custom material to the Image component. I have an animated material that I want to stay inside the "loading bar" but as soon as I add it, it loses the features of being maskable and the sliced settings go away as well.

Do I need some kind of custom hlsl? I've never hand-coded a shader before and I've not found any good beginner tutorials. They always seem to skip core steps and just assume the audience knows specific things automatically.

If not, is there any known store assets that achieve masking/additive/custom animated material hooks? So that it's got masking capabilities, but allows for fully custom shader graph materials to be hooked in? The main issue is the masking, and things like making the materials additive (unity doesnt seem to have an additive sprite setting without using a custom material?)

regal stag
safe kelp
#

Oic, ya the implication i got from everything was a custom hlsl shader would be needed to force these kinds of settings

neat elbow
#

Anyone have suggestions on how to render a grid for a board game over terrain/meshes in the scene? It'd be used for lots of different things. Displaying move/attack information are the primary concerns.

hexed sorrel
#

Hey all! I'm currently working on a custom renderer feature and am wondering if anyone knows why a global texture I have defined is being referenced in black/red, *(image attached) I am trying to use it as a mask for a shader I have, however for obvious reasons it needs to be black and white, in the pass that creates the global texture it displays as if it's black and white, if anyone knows why that might be any help would be super appreciated!

#

^ how the global texture is set supposedly. (and how I need it to be formatted)

grizzled bolt
#

If you only have data for one color channel anyway, it won't matter if it's visualized as red or white

#

Masks are single channel, unless you're storing multiple in one texture map

regal stag
#

But as Spazi mentions might not matter that much

hexed sorrel
hexed sorrel
#
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
        {
            var colorDesc = renderingData.cameraData.cameraTargetDescriptor;

            // 1st
            RenderingUtils.ReAllocateIfNeeded(ref rtMaskedLightTexture, colorDesc, name: "_MaskedLightTexture");

            // target 1st
            ConfigureTarget(rtMaskedLightTexture);
            ConfigureClear(ClearFlag.Color, Color.black);
        }

        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer cmd = CommandBufferPool.Get();
            using (new ProfilingScope(cmd, _profilingSampler))
            {
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                SortingCriteria sortingCriteria = SortingCriteria.CommonTransparent;
                DrawingSettings drawingSettings = CreateDrawingSettings(shaderTagsList, ref renderingData, sortingCriteria);

                // draw output of lightMaskMAT to rtMaskedLightTexture ?
                Blit(cmd, rtMaskedLightTexture, rtMaskedLightTexture, lightSettings.lightMaskMAT, -1);

                //context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);
                cmd.SetGlobalTexture("_GlobalMaskedLightTexture", rtMaskedLightTexture);

            }
            context.ExecuteCommandBuffer(cmd);
            cmd.Clear();
            CommandBufferPool.Release(cmd);
        }
regal stag
#

Add colorDesc.depthBufferBits = 0; in OnCameraSetup

hexed sorrel
#

I am currently trying to draw the output of lightSettings.lightMaskMAT which is the material using my shader masking the tilemap global texture and the 2d light texture, to ideally draw the masked light to "rtMaskedLightTexture" which is an RThandle. My current output is black.

hexed sorrel
#

unfortunately still drawing a black output, however now the depth value is set in the details of the frame debugger pass

hexed sorrel
# hexed sorrel

also, seems to be doing five draw procedural passes which I am also unsure about.

regal stag
hexed sorrel
#

I honestly thought that was the passindex relative to the main pass so realistically am not too sure why I set it to -1 in the first place haha.

hexed sorrel
regal stag
hexed sorrel
regal stag
#

It's some extra gpu memory but shouldn't be that significant

hexed sorrel
#

No dice I'm afraid, maybe a problem with my shader?

#

using a shader graph for simplicity of the masking shader, will use an hlsl shader afterward for blurring.

regal stag
#

You should use the Fullscreen Graph with blits

hexed sorrel
regal stag
#

It's required yeah, otherwise it won't draw the tri/quad correctly

hexed sorrel
#

if that is a global texture it would be super easy to just reference it myself, but I highly doubt that would be the case if the fullscreen shader doesn't allow for the node directly.

quartz slate
#

can someone explain me how to fix this problem so all faces of any objects are correct?

karmic hatch
#

probably tiling = (length(tangent * scale), length(bitangent * scale))?

#

or the inverse perhaps

hollow loom
#

Does anyone have a quad wireframe shader that maintains its quads even after Vertex movement far from each other. I'm looking for it for my 3d modeling software

chilly robin
#

Shader graph question: But if I have two sample texture2D nodes that are both using the same texture, does that count as two texture samples or one? Is there any kind of built-in optimization for this?

kind juniper
#

Or it might even be optimized on the code gen level. Might want to have a look at the generated code.

chilly robin
kind juniper
#

Depends on where it ends up in the code and in what context. And of course on whether it samples with the same parameters both of the times.

#

Basically, it depends on many small things that you don't always have control of and/or can see/know. That's why if you want to see for sure, you should look at the generated code.

chilly robin
#

Gotcha, thank you

glad oak
#

Hello there.

Could you please help?

I followed this tutorial: https://youtu.be/X8538W0puoE?t=171

And you can see in youtube there's Distance input for the subshadergraph, but mine doesn't have one...

In this video, we will learn how to make a depth fade sub-shader in unity.
Depth fade is needed in many water shaders. So knowing how to make one is essential.
You will also learn the basics of sub-shaders.

Download the Sub Shader: https://github.com/GhostStudiosGS/DepthFadeSubShader.git

Subscribe: https://www.youtube.com/c/GhostStudios?sub_c...

โ–ถ Play video
#

Here's how the subshadergraph looks like on my system.

#

What did I do wrong?

glad oak
#

Oh, I forgot to do save asset

solar marsh
hushed silo
#

can you use sprites in a shadergraph? I've tried setting it to an unlit sprite graph but I don't see any option for importing sprites themselves into the shader exposed properties

lunar valley
hushed silo
#

yeah, I was kind of worried about that, I guess I could do some kind of UV tile offset thing with an image instead

lunar valley
#

I don't know what you wanna do but good luck

solar marsh
#

If so you can use a node called flipbook

hushed silo
#

interesting, thanks! ๐Ÿ™

regal stag
drowsy pasture
#

I have to ask question so a little bit of a context my scene is set to 0 saturation from global volume but i want to display one object with 200 saturation how can i do that

#

i dont know which channel should i ask from here or from post processing

regal stag
drowsy pasture
#

where can i find those

#

somewhere here?

regal stag
#

The asset in the Renderer List at the top

drowsy pasture
#

this the right one

regal stag
#

Yea, you'll want Event set to after post processing and set filters to the layer your object is on. Shouldn't need to worry about overrides

drowsy pasture
#

and the global volume that is set 0 wont affect the object

regal stag
#

Shouldn't do, as it'll be rendering after the post processing is applied

drowsy pasture
#

Thank you very much i got it to work

#

for some reason it doesnt work in the particle even though they are on the same layer

#

nevermind

hexed sorrel
#

Anyone know of any fast blurring shader methods? I am looking for a gaussian blur-like effect where it will expand the visual area of the blurred object (image attached) which is decently performant and doesn't require much detail or precision. If anyone has any ideas or shaders they've used in the past to reference that would be amazing! (To be used in a custom renderer feature).

runic swallow
#

Is there any way to turn off specific multi-compile keywords without deleting them from the shader?

low lichen
hexed sorrel
low lichen
runic swallow
royal pier
#

Hey, is it possible to make this based on a mesh instead of bounding box? I use this to cut out holes. I created a cylinder, where the 2 ends have their faces flipped which have this shader on them.

It seems to work when it's outside of the mesh, but not when it's a more complex mesh with curves and it's inside the bounding box. In the first 2 images you see the hole going through the outer layer. The second 2 where I elongate it. Then you can't see the hole shining through the 3d model anymore.

"Custom/StencilMask"
{
    Properties
    {
        [IntRange] _StencilID ("Stencil ID", Range(0, 255)) = 0
    }

    SubShader
    {
        Tags { "RenderType"="Opaque" "Queue"="Geometry-1" "RenderPipeline" = "UniversalPipeline"}

        Pass 
        {
            Blend Zero One
            ZWrite Off

            Stencil
            {
                Ref [_StencilID]
                Comp Always
                Pass Replace
            }
        }
    }
}
runic swallow
dull magnet
#

how would I do a smooth transition from green to blue at the point of intersection?

#

im wondering if there's a smoother way to do it than if x < 1 then green(x) else blue(x), by using smoothstep and other math utility functions

deep moth
#

Is smoothstep not working?

#

For smoothstep ud basically lerp between them

#

Graphtoy can smoothstep too btw!

dull magnet
#

I'm trying to make a game where the player is flying in a tunnel and they can make turns in real-time by pressing WASD keys, e.g pressing D will make a turn to the right.

it has been surpisingly challening to implement the turns in real-time

cobalt hawk
#

I have this problem where the render texture always lags behind the viewport... here it's just on a RawImage object

#

I don't even know if it's possible to make a render texture not behave like this

#

Is there a way to fix this, or an alternate way that has a higher chance of working?

deep moth
#

the displacement is really nice for those turns

dull magnet
dusky arrow
#

test

grand jolt
#

Am I right in saying that it's not possible to do tesselation within URP shader graph? I'll have to convert it to code and write it there?

grand jolt
#

If I want different uniforms per go instance is the unity standard way to do this to create new materials per object or is there a way to make per-instance properties?

#

A weird workaround would be to repurpose values from the transform I'm not using but there's probably a way to create your own CBuffers

grand jolt
#

So when URP generates a shader from a graph it contains a lot of different passes

    Universal Forward
    GBuffer (Deferred)
    Shadow Cast (Shadow mapping)
    Depth
    Depth Normals
    Meta (?)
    SceneSelectionPass (Editor selection)
    Picking (Editor selection)
    Universal2D
    ALL REPEAT with target 2.0 instead of 4.5

Can someone explain what's going on with the "LightMode"="Meta" pass?
And why does every pass repeat in the file?

regal stag
grand jolt
#

Thanks

hushed silo
#

I want to have a render texture from a camera just write the alpha of that camera, how can I do this?

regal stag
grand jolt
#

Alright grand thanks for the help

regal stag
hushed silo
#

Thanks for the reply. I guess I was thinking about performance, mabye it's a waste to read and record and then discard RGB values when the only one I care about is (0 or 1 only ) A?

regal stag
hushed silo
#

ok thank you ๐Ÿ™‚๐Ÿ™

regal stag
#

Depending on what you're doing some kind of custom pass that writes to an red-only format and overriding materials could be an option

hushed silo
#

mm. I'm using the rendertexture as a map in a texture on a mesh. If there's not much difference I'm happy enough to go with it

grand jolt
#

I'm getting this error and Unity is crashing when I try implementing hull/domain shaders. Anyone familiar with what can cause this?

Here's the code but beware it's long. Highlights are the vert/HS_MAIN/DS_MAIN functions and the Varyings/VaryingsTess structs. Anything related to the fragment shader is fine
https://paste.ofcode.org/JR6XiH2MdMWfmjcKXnPM5v

royal pier
#

@regal stag any chance you can help me out with something? I'll treat you to a coffee. Send me a pm

grand jolt
#

idk if this is the right channel to ask for help to my problem but, its simple, but i rly idk how to do it, i created a slide bar on a canvas, and then i applied an effect for my camera, but the effect affects the canvas as well, and my slider bar becomes distorted, how can i put a straight bar again?
I am a new in unity sow i rly cant understand much.

grizzled bolt
royal crane
#

hey guys

#

when i try to add a texture layer to unitys terrain i cant select the sahder of terrain

#

i want it to be mobile shader and i need layers beacues im gonna use textre pain feature

hexed sorrel
#

Hey all! I'm currently attempting to blur a render texture in a custom renderer pass but to no avail, somehow the output is identical to the "Texture" variable in the input. If anyone may be able to see what could be going wrong or have any ideas as to why I'd be super appreciative, thanks!

#
void GaussianBlur_float(UnityTexture2D Texture, float2 UV, float Blur, UnitySamplerState Sampler, out float3 Out_RGB, out float Out_Alpha)
{
    float4 col = float4(0.0, 0.0, 0.0, 0.0);
    float kernelSum = 0.0;

    int upper = ((Blur - 1) / 2);
    int lower = -upper;

    for (int x = lower; x <= upper; ++x)
    {
        for (int y = lower; y <= upper; ++y)
        {
            kernelSum++;

            float2 offset = float2(_MaskedLightTexture_TexelSize.x * x, _MaskedLightTexture_TexelSize.y * y);
            col += Texture.Sample(Sampler, UV + offset);
        }
    }

    col /= kernelSum;
    Out_RGB = float3(col.r, col.g, col.b);
    Out_Alpha = col.a;
}
grizzled bolt
hexed sorrel
tired verge
#

Hello guys!
Has anyone tried using bfloat type variables in shaders?

low lichen
deep moth
hexed sorrel
hexed sorrel
#

this is the blur pass result, however the image displayed is the exact same as the "_MaskedLightTexture" which I am referring in my material, I'll send the pass line!

#
lightSettings.blurShaderMAT.SetTexture("_MaskedLightTexture", maskedLightTexture);
                lightSettings.blurShaderMAT.SetFloat("_BlurSize", lightSettings.lightBlurAmount);

                Blit(cmd, rtBlurredLightTexture, rtBlurredLightTexture, lightSettings.blurShaderMAT, 0);

                //context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);
                cmd.SetGlobalTexture("_GlobalBlurredLightTexture", rtBlurredLightTexture);
hexed sorrel
#

I do this same operation in a different pass here:

// draw output of lightMaskMAT to rtMaskedLightTexture ?
                Blit(cmd, rtMaskedLightTexture, rtMaskedLightTexture, lightSettings.lightMaskMAT, 0);


                //context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);
                cmd.SetGlobalTexture("_GlobalMaskedLightTexture", rtMaskedLightTexture);
``` and this does work properly, (rtMaskedLightTexture is an empty handle also)
#

^ my blur shader graph set to be a "fullscreen" material.

deep moth
#

Hmmm. The other point I'd double check in the set global variable. Often those give me trouble in shadergraph. Maybe your shader receiving the texture is missing something? You could double check the setup is the same as the mask that's working. The other way to test would be just to set the color of the blur to like purple and see if it comes through when sampled. That will help narrow in on where the issue is.

hexed sorrel
#

I'll try that now!

#

I can confirm setting the blur output to a full purple does actually output, which is good to narrow down. However, that now leaves the blur problem still I suppose.

#

New output declared as a global texture on a temporary material to view result ^

deep moth
#

Wooh!

#

So materials can read it...

#

Or have access to it thru your code.

hexed sorrel
#

yeah, it must just be a problem with the custom function node not actually blurring, which still confuses me.

hexed sorrel
#

And it is definitely able to recognize the global masked light, as it does draw as a reference in the frame debugger which is also good.

grizzled bolt
regal stag
# hexed sorrel

A BlurSize of 2 might be too small if it's going into that Blur param in the function (would result in loop upper/lower values of 0). I would try a larger value

hexed sorrel
# grizzled bolt You're combining a lot of different features here Have you tested them each in i...

Yes, if you are referring to the passes. Currently all of my other passes have been confirmed to be working as intended, however when this material/pass attempts to blur the texture inputted to the custom function node it doesn't appear to be blurring, however the passes prior have worked in succession to first create a render texture based on the visible tilemap, and the next pass uses that texture to mask the light texture visible to create my "_MaskedLightTexture" being used in this blur material, seems a little strange the blur isn't working.

hexed sorrel
#

Same output unfortunately it seems.

#

There is a very very slight variation between the _MaskedLightTexture inputted and the output, (the blur seems to be creating what looks like a 1px outline of color around the texture, I will send results of both side by side for comparison)

grizzled bolt
hexed sorrel
# grizzled bolt I mean every part including the blur itself

I mean everything besides the blur yes, I would consider this to be "testing the blur", I don't think I could do much more to test it other than feed it a texture and hope for it to blur :/ (which is the intended result of what I'm doing now anyway)

#

^ "BlurredLightTexture"

grizzled bolt
hexed sorrel
#

^ "MaskedLightTexture" (what the blur texture is using)

hexed sorrel
grizzled bolt
hexed sorrel
#
void GaussianBlur_float(UnityTexture2D TextureMainTexture, UnityTexture2D TextureLight, float2 LightUV, float LightReduction, float2 MainTexUV, float Blur, UnitySamplerState Sampler, out float4 Out_RGBA)
{
    float4 col = float4(0.0, 0.0, 0.0, 1);
    float kernelSum = 0.0;

    int upper = ((Blur - 1) / 2);
    int lower = -upper;

    // cut out light from Texture

    for (int x = lower; x <= upper; ++x)
    {
        for (int y = lower; y <= upper; ++y)
        {
            kernelSum++;

            float2 offset = float2(_MainTex_TexelSize.x * x, _MainTex_TexelSize.y * y);


            float4 light = pow(TextureLight.Sample(Sampler, LightUV + offset), LightReduction);
            col += light * (1 - TextureMainTexture.Sample(Sampler, MainTexUV + offset).a);
        }
    }

    col /= kernelSum;
    Out_RGBA = float4(col.r, col.g, col.b, col.a);
    //Out_Alpha = col.a;
}
``` ^ old working blur shader which was blurring but not masking as intended.
deep moth
#

another thing you could do is add a preview node in your graph and set a texture to preview w/ to the _MaskedLightTexture input

#

so that you're always seeing the updates you're making

hexed sorrel
deep moth
#

like they're saying above you could try a diff kind of texture to validate too!

#

like what if you plugged in the grid texture

#

from unity

#

that has some really sharp lines

hexed sorrel
deep moth
#

that would tell you pretty quickly if they'rte being blurred

hexed sorrel
#

I used the "Default Checkerboard" which just displays a slightly darker whiteish color, without much detail.

#

However, upon closer inspection, in my hlsl portion of the blur shader

#
for (float x = lower; x <= upper; ++x)
    {
        for (float y = lower; y <= upper; ++y)
        {
            kernelSum++;

            float2 offset = float2(_MaskedLightTexture_TexelSize.x * x, _MaskedLightTexture_TexelSize.y * y);
            col += Texture.Sample(Sampler, UV + offset);
        }
    }
#

I am directly referencing "_MaskedLightTexture_TexelSize.x"

#

which is the reference in the shader graph to the texture, however in the hlsl property declarations I am referring to it as "Texture". I don't think that would be an issue but if anyone could confirm or deny that it could help.

#
void GaussianBlur_float(UnityTexture2D Texture, float2 UV, float Blur, UnitySamplerState Sampler, out float3 Out_RGB, out float Out_Alpha)
regal stag
#

Should be able to change _MaskedLightTexture_TexelSize to Texture.texelSize so it's consistent with whatever texture is assigned

hexed sorrel
#

I assume "_TexelSize" is only possible through external references but I am very unsure.

regal stag
#

The UnityTexture2D object should contain it, so not sure why that would cause an undeclared identifier

hexed sorrel
hexed sorrel
# hexed sorrel

this here is still confusing to me, it seems like the blur is trying to do something and breaking.

#

I don't have much explanation as to why there would be light on those edges only on the blurred texture result if the blur was truly not doing anything.

regal stag
#

The blur probably is doing something, but only over a few pixels. The sampler probably defaults to Repeat so those parts are lighter due to the other side of the texture

hexed sorrel
#

I am getting a visual bug when stopping the game and clicking a material that references the blurredtexture and it appears to be blurred, but I cannot seem to recreate it.

#

The global variable for it is definitely not blurred.

#

when viewing the blur pass, unplaying and clicking on this material that references it, in only that sequence it displays this.

#

I have no idea how to even begin to explain what is going on.

#

I can probably make a video or gif showing what is happening

hexed sorrel
# hexed sorrel

only that exact sequence, produces the blurred result onscreen, I assume that to be a unity bug but that means that the blur is "working"(?) and somehow the blurred result isn't being displayed in the global texture?

hexed sorrel
# hexed sorrel

anyone have any idea what causes the blur to only work in that sequence?

tired verge
low lichen
dull magnet
#

I want to implement a wireframe effect into the tunnel. How inefficient is it to implement it in a script by just iterating the triangles of the mesh and using a LineRender component, compared to writing a shader that does it?

#

I was very easily able to write the functionality in a script, but I'm wondering if it's very inefficient:

    void Update()
    {
            for (int i = 0; i < meshFilter.mesh.triangles.Length; i += 3)
            {

              DrawLine(meshFilter.mesh.vertices[meshFilter.mesh.triangles[i]],meshFilter.mesh.vertices[meshFilter.mesh.triangles[i+1]]);

            }
    }

There are 14k triangles and 7k vertices

kind juniper
deep moth
#

The other thing to consider is w/ gl lines you don't have control over width.

#

I'd guess a shader is pretty fast but wireframe shaders aren't super simple. The way I see them done most of the time uses barycentric coordinates which you need an awareness of every point of a triangle for (which means either using a compute shader, c#, a 3d package or a geometry shader to calculate)

grand jolt
#

Anyone know how I'm getting seams in the mesh here?
I've implemented LOD into my tessellation shader and now there's spacing between some of the triangles
There's no tiling here its just a single plane mesh so I don't even know how it's possible to get seams

Here's the PatchConstantFunction

            TessellationFactors PatchConstantFunction(InputPatch<Varyings, 3> patch) 
            {
                float4 pos;
                pos.xyz = (patch[0].positionWS.xyz + patch[1].positionWS.xyz + patch[2].positionWS.xyz) / 3.0f;

                float lod = _LODFactor / length(pos - _WorldSpaceCameraPos.xyz);

                float tessFactor = lod * _TessFactor;

                TessellationFactors f;
                f.edge[0] = tessFactor;
                f.edge[1] = tessFactor;
                f.edge[2] = tessFactor;
                f.inside = tessFactor;
                return f;
            }```
trail nymph
#

Hi, I understand that this is a very technical question, but does anyone know of an algorithm that would produce a motion texture based on two or three images like this? By velocity texture I mean a texture with r,g standing for x,y of the general direction the pixel has "moved".

From what I understand this is an entire field of study - "motion estimation", so I'd appreciate it if anyone had any pointers, however rough.

#

I'm thinking if I have 3 frames a,b,c I can get the difference between a & b and b&c, then apply some general algorithm for the motion.

brazen nimbus
#

Greetings here ! Is there a way (and if yes, how) to create a pattern pretty much random like this example :
The idea would be to have a float input that allows to modify in real time the radius for every bubble (or a random between 2 floats)

rare wren
#

Seems to have a similar base

brazen nimbus
tired verge
#

In Unity is it possible to use a user-defined shader compiler?

rare wren
#

You can use bools to change features, but I don't think you can do runtime compilation

fair jackal
#

I have a cutout shader so a faded circle lets you see through objects the player is behind. It works exactly like I want it to except there is one problem: it does the cutout whether the player is in front or behind the player. I'm not entirely sure how to make it only perform the cutout when the player is behind the object

karmic hatch
karmic hatch
fair jackal
brazen nimbus
karmic hatch
karmic hatch
fair jackal
karmic hatch
#

Try dot(camera direction, player position - camera position) vs dot(camera direction, fragment position - camera position)

#

(since dot is linear you don't need to subtract camera position but it helps makes things clearer as to what it's doing)

brazen nimbus
molten compass
#

Hello, I'm creating a loading circle shader in Shader Graph where I rotate a gradient using the Polar Vortex node driven by Time. I would like to have the rotation animation snap to 30ยฐ intervals instead of smoothly animating but I'm not sure how to achieve this? Any help would be much appreciated.

brazen nimbus
regal stag
regal stag
brazen nimbus
regal stag
#

Exactly yeah

#

Still want the multiply by 0.01 like ThePinkPanzer had though, since displacing the UV by a 0-1 noise value would be far too much distortion

karmic hatch
regal stag
#

I think adding after would act a bit like masking rather than distortion

karmic hatch
#

It should make the circles a little larger/smaller at any given point

grizzled bolt
#

Try the "accurate g-buffer normals" setting
At least in URP, can't say what the BiRP equivalent setting would be

brazen nimbus
grizzled bolt
#

Dithering enabled on the camera as well?

hexed sorrel
# hexed sorrel

would anyone know why something like this would be happening?

grizzled bolt
#

Hmm "blending" in what context? And which low "values"

deep moth
deep moth
low lichen
#

Just out of curiosity, why do you want to use deferred over forward? Not that there aren't valid reasons to, but I'm just curious.

trail nymph
low lichen
trail nymph
low lichen
#

Hmm, that's too bad. Forward+ is great. Which Unity and URP version are you using? Maybe it's an issue that has been fixed.

#

Also in fresh projects? I think custom shaders can be outdated in such a way to cause infinite loops in certain cases.

deep moth
#

W/ something like OpenCV

chilly robin
#

More shader performance questions: I know that 4k textures consume quite a bit of memory. However, 4K textures can contain detail that a 2k texture just can't.

As an example alternative: Let's say I had a 2K texture, an RGB mask texture, and 3 small detail normal for each channel. So 5 textures in this case. Would those 5 texture samples be more or less expensive than that single 4k sample?

trail nymph
low lichen
chilly robin
#

Actually, I think a better question I should be asking, is how would I go about profiling this for myself?

low lichen
low lichen
#

As long as your bottlenecked by the GPU and you don't have any framerate capping, you can just use the FPS to compare the performance. In an empty scene, you should probably be GPU bound, especially at high resolution and the shader is not too simple.

#

It's more difficult to measure the GPU frame time if you're CPU bottlenecked.

chilly robin
#

Much appreciated. I will try that. Thank you for your time!

grizzled bolt
#

So the issue is specifically with deferred rendering path and a custom lighting shader? If I'm understanding what this texture is for

#

Scene repaint hang is a bug I've had on and off with nearly all the editor versions and render pipelines so it might not be related to forward+ specifically

#

Might be an option to use forward+ for the quality level used to build the executable if it only produces editor issues

#

Deferred is under the best of circumstances kind of lower quality if you get right up close to reflected light, but that's not a practical scenario for many games

low lichen
#

Also, TAA ๐Ÿคข

grizzled bolt
#

I wish Unity URP had it better. UE4 with

junior galleon
#

Bump!!!

grizzled bolt
junior galleon
#

It would be horrible for performance

grizzled bolt
# junior galleon It would be horrible for performance

Performance isn't quite so simple
By far most commonly the kind the tracers like in your example use a Line Renderer, or sometimes a Particle System that fires particles in roughly the same direction, and a mesh works too
VFX Graph can handle at least a couple of million tracers or projectiles per frame with just one emitter with no issues usually
Particle System and VFX Graph can define a minimum particle size in screen space which is useful for your particular issue
Tracers of the type you show as reference are loaded into magazines sparsely between ordinary bullets so you probably don't need every shot to produce a tracer unless yours is an energy weapon of some sort

junior galleon
#

blocks your path

junior galleon
#

My question isn't about performance though. I was looking for advice on how to make a shader for a bullet tracer that looks appealing and can be seen from far away (overcomes aliasing issues)

#

Look at weapons showcases for MW2019, you can see the yellow tracers far beyond what you could if it was a small object

karmic hatch
tidal forge
#

How to make shades with float value? Something like that, but i have shades value (for example, 4) and this wil split to 4 shades

onyx nexus
#

When i plug this normal into the vertex position the shader goes invisible

junior galleon
onyx nexus
#

Heres the full thing

regal stag
# onyx nexus Heres the full thing

If you're trying to do vertex displacement, you need to add the offset to the original vertex positions (Position node)
(Note that the Position port in the vertex stack also expects Object space. If you want to displace in a different space, would use a Transform node to convert to Object before connecting)

tidal forge
#

I don't understand a little how to make a outline for a specific material. I implemented this as a fullscreen renderer. Like, how do I get the depth and normals? How to withdraw?

regal stag
# junior galleon ...I am not using gameobjects and do not have a particle system

Shaders need to be drawn to something, that's why others are suggesting stuff like Line/TrailRenderers or ParticleSystems/VFXGraph.
Even if you do use separate GameObjects for each bullet, you shouldn't be instantiating/destroying, but use a pooling system where you disable/enable and reuse the objects.
If you really want to avoid GameObjects you can draw meshes through functions in the Graphics or CommandBuffer APIs. Though particles may end up being better and more flexible anyway. If you google around for "particle trails" tutorials you might be able to find something close to what you want.

junior galleon
#

I want help with creating the shader I described

kind juniper
#

We can't help you without knowing how you're planning to draw the traces, because the required shader might be vastly different depending on the context.

jolly wing
#

Can sm help me when i try to open a unity project it wont load bc it says i have a public network and idk how to fix

kind juniper
jolly wing
#

no but no one else is typing in any other server damn

kind juniper
jolly wing
#

ok damn hop off

junior galleon
kind juniper
#

In this case just use some simple unlit shader

junior galleon
kind juniper
# junior galleon Did you read absolutely nothing I said?

I did read back to a few hours ago. Didn't see the initial message. If you're feeling like your question is gonna take some time, it's better to create a thread and keep all the relevant info with the original question in it, so it's easy for people to follow.

junior galleon
#

Ok

#

Tracer Effect

fervent socket
#

idk if this is the right place to ask this but i haven't seen any "materials" channel
basically i'm trying to make a transparent material that is depending on the texture itself for it's transparency , but setting the rendering mode to transparent just makes the whole object transparent tho the alpha is set to 255

amber saffron
fervent socket
amber saffron
fervent socket
#

oh yeah

amber saffron
#

Ow ... strange, something must be missing somewhere.
You could also try the "Cutout" mode

fervent socket
#

tho i tried it multiple times before

#

ah well , tysm !

trail nymph
#

Is it possible to use one shader to write into two textures?

#

I'm currently passing two textures into my shader and I want one of them to be a frame delayed. I would like to just write Tex1 into Tex2 at the very end of the fragment shader, after doing all calculations involving Tex2

hasty breach
#

i bought an asset from unity asset store, and all objects from asset seems to load colors from vertex color, is der a way i can change vertex color of it?

grizzled bolt
grizzled bolt
hasty breach
grizzled bolt
hasty breach
waxen merlin
#

Hi, I have some random compute shader questions if I may?

  1. What is the behaviour of reading out of bounds of a ComputeBuffer? Undefined? Mem zero?
  2. Related to (1), I have a compute shader that processes a grid, whereby each cell reads the neighbouring 8 cells. Right now, it's processing it naively, 16x16 with no groupshared memory. But I want to convert it to the more optimal version of reading in 16x16 values into groupshared memory, and then using those values and only writing the valid 14x14 center cells. In this instance, I assume people do bounds checking on the initial 16x16 reads because some will definitely be out of range at the edges.
  3. Are there any speed advantages of compute vs vertex shader? Example: Wind effect for procedural grass. The compute shader is processing the vertices anyway, so could do the wind calculations there, would there be any reason not to?
    Thanks!
molten compass
#

I'm trying to apply a gradient to my shader by using a Gradient node piped into a Sample Gradient node, but now my shader shows the error floating point division by zero . It looks like the errors are coming from the Sample Gradient function. Is there a fix or alternate method I should use to resolve this?
EDIT: Using Shader Graph

#

When looking at the generated code, the error is coming from this line of the Sample Gradient method:
float colorPos = saturate((Time - Gradient.colors[c-1].w) / (Gradient.colors[c].w - Gradient.colors[c-1].w)) * step(c, Gradient.colorsLength-1);

low lichen
# waxen merlin Hi, I have some random compute shader questions if I may? 1. What is the behavio...
  1. It depends on the graphics API you're using. I think only DirectX 11 guarantees that out of bound reads return zero. Other APIs have undefined behavior. Most likely return zero, but it's up to the GPU driver.
  2. I haven't used groupshared memory much, so I'm not sure what the standard approach would be here, but there are definitely cases where bounds checks are unavoidable in compute shaders.
  3. If you're able to make use of groupshared memory or are targeting a platform that has an async compute pipeline, you could possibly do it faster in a compute shader. But at the same time, I think it's easier to mess up a compute shader implementation so that it's slower than a vertex shader. With a vertex shader, the GPU knows what type of data it's dealing with and how best to distribute the work to the threads. With compute shaders, that work is on you.
hexed sorrel
#

I have a "two pass" blur shader which separately blurs the horizontal and vertical axis of my render texture to ideally create a gaussian effect, however my horizontal blur shader while seemingly correctly targetting the x axis is vertically blurring the image, so when passed to my vertical blur shader, it creates a final strong vertical blur with no semblance of any horizontal blurring at all, (I have visual representation of both outputs in each step of the sequence added below)

#
void HorizontalBlur_float(UnityTexture2D Texture, float2 UV, float Blur, float BlurWeight, UnitySamplerState Sampler, out float3 Out_RGB, out float Out_Alpha)
{
    float4 col = float4(0.0, 0.0, 0.0, 0.0);
    float kernelSum = 0.0;

    float upper = ((Blur - 1) / 2);
    float lower = -upper;

    for (float x = lower; x <= upper; ++x)
    {
        kernelSum += BlurWeight;

        float2 offset = float2(0.0, _MaskedLightTexture_TexelSize.x * x);
        col += Texture.Sample(Sampler, UV + offset) * BlurWeight;
    }

    col /= kernelSum;

    Out_RGB = float3(col.r, col.g, col.b);
    Out_Alpha = col.a;
}
``` ^ Horizontal Blur Shader
#

^ It's output

frigid jay
#

float2 offset = float2(0.0, _MaskedLightTexture_TexelSize.x * x);
You are offsetting by V (Y)

regal stag
frigid jay
#

Need to be this: float2 offset = float2(_MaskedLightTexture_TexelSize.x * x, 0);

hexed sorrel
#

Appreciate it! That's my bad haha.

#

I see that now. Thank you for the quick answer!

#

Would anyone have an explanation of why the blur shader is creating random artifacts of light in the output? I was informed it might be due to the way the light was being sampled before I got the blur working, however they are still prominent in the working blur which is confusing to me, same shader base (pre-blur texture) and post blur with different "artifacts" attached:

#

^ Pre-Blur

#

post blur, it seems to be doing a single pixel wide mirroring of the "light" on either side, not too sure why.

regal stag
# hexed sorrel

Would depend on the wrap mode of the texture, though I think you're overriding the sampler used in the custom function too. Connect a Sampler State node to the custom function and use "Clamp" as the wrap mode instead of repeat.

hexed sorrel
#

Worked like a charm, amazing!

dull magnet
#

How can I create bumps inside of a tunnel like this? (made using Splines)

#

It's using my custom shader made in shader graph

#

the problem i have currently is that this is what the UV map looks like:

#

if the UV map was something like this it would be much easier:

brave yarrow
#

So I've been doing bad and rendering streaming point cloud data with cubes and DrawMeshInstanced(), but it's time for me to do better.

I heard that I could instead put all the points into a single mesh with Points topology and vertex color for each point in the script, then render it all at once using DrawMesh() and use a geometry shader to draw a quad for each point with color from the vertex, but when I tried to implement it nothing was working :\

I had an error about The given primitive topology does not match with the topology expected by the geometry shader and after some futzing around it went away but I wasn't able to get anything to render

#

I'm rendering on a cell phone, so perhaps there's some differences there, but using URP

sullen mauve
#

Hi! Im making this very simple setup to create fake god rays. Basically itยดs a gradient with soft edges thatยดs applied to a mesh to simulate rays of light. The effect also has a gradient noise that is stretched and slowly moves to make it feel more dynamic.

My issue is, all the rays look the same because theyยดre going at the same speed, have the same scale, etc. How can I create variation in these so that each time the material is applied it behaves differently? I can also create a different material for each time I use it but it doesnยดt seem very efficient. Any help whatsoever is super helpful, thanks!

livid kettle
#

perhaps using world position as noise?

steel notch
#

Alright guys I've got kind of a strange one.
I have a texture here.

#

I want to apply perlin noise to it on a per SYMBOL basis.
Aka pick a star, and the entire thing will be some value from black to white
and the entire pattern across the whole image will follow perlin noise
Any way I can do that >_>

grizzled bolt
#

You need a texture where the stars are painted with random colors to begin with

steel notch
grizzled bolt
steel notch
grizzled bolt
steel notch
#

You can see that the symbols come and go in a sort of random distrubtion.

#

Just focusing on the appearing and disappearing right now.

grizzled bolt
# steel notch Here's a good reference.

The star colors don't have to be any specific kind of random as long as they're "random enough"
You and also of course use another noise map of any kind together with the star map

steel notch
#

Point is I definitely need some texture that groups the symbols together.

#

Otherwise I'm doing operations on a per pixel basis and it looks... off.

tacit parcel
# steel notch Here's a good reference.

I dont think that is random at all...
seems like some different image patterns layered which fade in/out based on card facing and view angle, I think you can use fresnel with different offset for each image layer.

uneven drum
#

Can I exclude the skybox from a full screen custom pass in the Custom Pass volume?

peak drum
#

how do i fix this the part i highlighted in red is the part thats bad

fallow bolt
tidal forge
#

How to fix artifacts caused by shadow attenuation?

uneven drum
#

Why does my screen go all white when I increase the intensity in the volume? I am trying to create a posterization effect and here's the shader graph for my posterization and I am also not sure if its right

fallow bolt
uneven drum
hollow loom
#

Any good tutorials of geometry shaders?

daring nymph
#

I have something I've been confused over for the past couple days. I have an occluded shader that is used on player and enemys that displays a sihouette when the player/enemy's pixels are also on the same x/y value as an occluded shader (for trees/buildings). I sort the layers by raising/lowering the z value (height) in relation to the y axis so that the silhouette is only active when the player/enemy is above some occluder object. This works perfectly fine except for the case when an occluder shader is below the player and there's another above it (this is fine, the player should display a silhouette; however the above occluder hides the silhouette)

#

ex: in this image the player is hidden by the boulder (occluder) but the silhouette is below or not rendered by the tree (occluder)

#

I can send the shader files if that'll be helpful to anyone that can help me

#

or if yall know of any easier ways to do this lol

daring nymph
#

or is there a different way to check values at specific pixels other than with the stencil graph and ref value

#

like I'm now trying to pass in a float to the Ref and then compare the height to determine which sprite's pixel ends up being written

raven latch
#

hi! i need some help, i cant see the shader graph option, theres something that i can do to see it, i rlly need it, this is all that appears. build 2022.3.29f1

regal stag
raven latch
#

lemme see

#

ok that works but then the urp option doesnt appear too

regal stag
raven latch
#

i dont have any other shaders in the project rn so

#

what would i do?

regal stag
raven latch
#

thx so much

tidal forge
regal stag
tidal forge
tidal forge
steady carbon
#

Hello, where should i connect the normal and height node in shader graph? There's no normal slot in the Fragment panel

regal stag
# tidal forge In your toon shader examples, I see that you control the bends of the material, ...

If you want to control a light other than the main directional you do that in a Custom Function as you need to loop over the lights. See the AdditionalLights_float or AdditionalLightsToon_float functions here : https://github.com/Cyanilux/URP_ShaderGraphCustomLighting/blob/main/CustomLighting.hlsl
And yes, should be possible to do a colour gradient based on the light attenuation.

If you need to have that only affect specific light(s), would likely need to branch based on the light colour or use layers. Kinda similar to what I do in this ultraviolet lights tutorial

regal stag
abstract gyro
#

Hey all.
Anyone here writing HLSL Scripts ?

regal stag
abstract gyro
#

Cool, So my shader is turning out Black
But it only turns Black if I use the UniversalFragmentBlinnPhong() Function in the Fragment Stage.

#

Heres the Basic Structure I have.

float4 Fragment(interpolators input) : SV_TARGET
{
    float2 uv = input.uv;
    float4 ColourSample = SAMPLE_TEXTURE2D(_ColourMap, sampler_ColourMap, uv);

    InputData lightingInput = (InputData)0; // PositionWS : The mesh on the Current Fragment
    SurfaceData surfaceInput = (SurfaceData)0; // Albedo : The Surface material Properties

    surfaceInput.albedo = ColourSample.rgb * _ColourTint.rgb;
    surfaceInput.alpha = ColourSample.a * _ColourTint.a;

    return UniversalFragmentBlinnPhong(lightingInput, surfaceInput);
}
#

If I just return the ColourSample and _ColourTint Mult I get this:

return ColourSample * _ColourTint;
regal stag
#

There's likely things in the InputData struct that you need to be setting

abstract gyro
regal stag
abstract gyro
abstract gyro
broken salmon
#

I'm having trouble getting an unlit shader in URP shadergraph to show up on a material. The main preview window works fine, but assigning it onto a material makes the entire material disappear. Changing the material to Lit makes it appear just fine, but I need to use unlit. I've tried multiple different settings and reduced the shader to just a base color, and it still won't show. Any ideas what I might be missing? Using Unity 2022.3.18

#

Hmm I think this may be due to a post-processing issue from one of my team members, disregard for now

waxen merlin
#

General shader question. If I'm rendering a large grid of vertices, then it's easy to generate the X, Z coordinates in the vertex shader and store only the Y in the mesh data. Is this usually better than storing the full XYZ position in mesh data (along with all the other attributes of course)? Trade off is a few additional cycles in the shader vs reduced data size. I feel like I read that this usually better because a lot of shaders tend to be data bandwidth bound.

meager pelican
# waxen merlin General shader question. If I'm rendering a large grid of vertices, then it's e...

I'd look at cache coherence also....the order in which you store and access the dataset, regardless of size. But I'd hazard a guess that the smaller dataset will "win out" particularly if you can generate XZ values. There's procedural calls for drawing meshes that you might want to explore, like https://docs.unity3d.com/ScriptReference/Graphics.RenderPrimitives.html and cousins. However, you may find that you want to access memory in size of float2 or float4 chunks anyway. If float4, you'd pass the data even if generated. An interesting question, please benchmark and let us know. Mobile platforms may perform differently than desktop too.

waxen merlin
# meager pelican I'd look at cache coherence also....the order in which you store and access the ...

Thanks, yeah, that link is roughly how I'd be doing this. I've also got other data alongside the position, like normals, tangents, bitangents, and some other properties required for shading. I regenerate normals in compute shader and am also considering whether the grid heights should be their own buffer entirely to help with that process. The compute shader to generate normals can write in the main buffer with the other attributes I guess... I don't really know when to split the data to make one compute shader faster vs. that it might make shading slower later given positions are in a separate array to the other attributes... cache issues doing that? It's like I want all the attributes together for shading, but for earlier compute shaders I just want specific values only... don't really have the experience yet to know when to split or keep together.

hexed sorrel
#

Hey! I currently am creating a lighting system in 2D URP where I am using a two pass blur to create a Starbound-esk lighting system which overlaps the blurred masked light texture with a Tilemap (of blocks/tiles) to create a similar lighting system to what Starbound uses, however there is seemingly a problem with my two pass blur shader, if I for example have a single "tile" of masked light assuming an intensity of 1 (fully bright), and run it through my vertical-horizontal blur it will simply create a larger square, which logically you'd expect it to do, I am wondering if anyone knows how to create a two pass blur that would result in more "circular" blurring pattern similar to how photoshop's gaussian blur behaves, labelled photo examples below, sorry for the potentially poor explanation!

#

Circular Blur Shader Question

#

^ Full question moved to Thread to prevent chat spam! Any help would be amazing, appreciate all of you as always! blushie

hexed grove
#

I trying to build a game i gat in this stuck shader and wont pass it can some on tell me how to fix this or somehow go around it

hexed grove
#

||Shader compiler: Compile Particles/Standard Surface - FORWARD, Vertex Program: Internal error communicating with the shader compiler process. Please report a bug including this shader and the editor log. Error code 0x80000004 (Not connected). Thread: 2208 Exception: Protocol error - failed to read magic number (data transferred 0/4) Platform: d3d11 Keywords: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR UNITY_PASS_FORWARDBASE Shader compiler: UnityShaderCompiler.exe compiler executable disappeared on thread 2208, restarting Launched and connected shader compiler UnityShaderCompiler.exe after 0.13 seconds Shader Compiler IPC Exception: Terminating shader compiler process Last 50 lines from the compiler log: Base path: 'E:/Unity Project/2022.3.29f1/Editor/Data', plugins path 'E:/Unity Project/2022.3.29f1/Editor/Data/PlaybackEngines' Cmd: initializeCompiler Cmd: compileSnippet Shader compiler: Compile Particles/Standard Surface - FORWARD, Vertex Program: Internal error communicating with the shader compiler process. Please report a bug including this shader and the editor log. Error code 0x80000004 (Not connected). Thread: 2208 Exception: Protocol error - failed to read magic number (data transferred 0/4) Platform: d3d11 Keywords: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR UNITY_PASS_FORWARDBASE IPCStream (hubIPCService): IPC stream failed to read (Not connected) IPCStream (Upm-12860): IPC stream failed to read (Not connected)||

echo moatBOT
hexed grove
#

I will post only what i gat after build

hexed grove
#

I upgraded from 2021.3.22f1 to 2022.3.29f1

warm moss
daring nymph
warm moss
#

It depends on the pipeline.

#

Which one are you using?

daring nymph
#

hmm 1 sec lemme check

#

I think just URP

daring nymph
#

actually that might not be it i forgot how to check where which pipeline I'm using

#

ok yeah never mind its LWRP which is an URP asset

#

but thanks imma look into doing custom render passes!

sturdy lily
#

trying to do a distortion effect in HDRP but can't get scene color to give any information from transparent 2D sprites - I've heard this is a known issue but I also heard there should be some way to get a final/semi-final render texture pass without rerendering everything using a second camera to substitute the node, anyone got any ideas?

lean lotus
#

is it possible to read/write a shader file/compute file as if it was a text file from unity C#?

low lichen
lean lotus
#

no thats fine, I just need it in editor

#

sweet thanks!

#

can I modify a .cginc file, and then recompile it and all the other files that use it like this?

low lichen
lean lotus
#

ah sweet thanks!

#

also I notice a rare bug where if I am recompiling both C# and shader files at once, sometimes the shader files dont recompile and stay as the old?

woeful breach
#

Im using a render cam to render particles and then i display them on the water using a shader and it works in the editor but in the build the white foam(the particles in question) flash a lot and look extremly weird. Left image is in build, right image is in the editor

#

herere are the settings for my render cam

golden cypress
#

would anyone be able to help me in adding a shader to a 2D tilemap?

hexed sorrel
golden cypress
#

to be honest, i have no clue where to start with this, i have the shader i want to add, which is this glitch filter i got, but i want to apply it to the tile map and not the other objects

hexed sorrel
#

Tilemaps use a "Tilemap Renderer" component natively which you can directly drag the material you just created to, this should apply the shader correctly!

golden cypress
#

all the objects are inviable now

hexed sorrel
golden cypress
#

wait, hold on'

#

i think it not showing up is my camera

#

i will fix my camera and then check

hexed sorrel
#

Sure!

golden cypress
#

the tiles no longer appear but still have their collsion, would it be easier to make the shader affect the ground layer that the tile map is on, as only the tilemap uses that layer

hexed sorrel
golden cypress
#

no, it is just a shader

hexed sorrel
# golden cypress no, it is just a shader

Yeah, if you aren't very familliar with using Shaders directly there are a multitude of things that could be going wrong, unfortunately I'm not the greatest with them myself yet. But if you send it here I could have a look.

golden cypress
hexed sorrel
golden cypress
hexed sorrel
golden cypress
#

oh, ok

hexed sorrel
#

This may be what you're looking for, which will break down what is going on within' the shader graph, and what the nodes are doing.

golden cypress
hexed sorrel
#

Of course! Feel free to ask any other questions you have here, and if I'm still available I'll try to help you out.

#

For really generic and basic questions I recommend Google's Gemini AI, it does a pretty good job linking resources that it is pulling information from which is really helpful!

golden cypress
hexed sorrel
# golden cypress random question: would it cause any problems if I were to be using unity 2D inst...

It can, if you are using Unity2D there are a lot of shaders which are made specifically for 2D, 2D lacks the z axis entirely and a lot of the vertex points that a shader made for 3d could be looking for. I'd stick to just 2D specific guides for now, however converting a 3D shader to a 2D shader is a whole lot easier than vise-versa, but it would be quite complicated if you are just starting to learn shaders.

#

From my experience it is a lot easier to find shader guides for 2D than 3D because it's simply easier to work in 2D overall.

golden cypress
#

ok, thank you!

kind juniper
hexed sorrel
kind juniper
hexed sorrel
kind juniper
hexed sorrel
# kind juniper Then what the heck is "Unity2d"?

He is a beginner and most likely means the default "2D" package when creating a new project. With this assumption in mind, we can make the connection that more than likely all of his assets are two dimensional therefore making 3D designed shaders unusable or broken in their native state.

golden cypress
hexed sorrel
#

Additionally, if that were an AI generated response. Very likely the "AI" would not reference his prior texts in the response referring to Unity as Unity 2d.

#

AI would be much more literal in the response.

kind juniper
#

2d package is just a collection of packages to help with developing 2d games. It doesn't change the engine.
3d shaders would work with 2d objects as expected. Unity uses the same render pipelines and shading language both for 2d and 3d.
The only issue might be with rendering order and lack of support for 2d specific features, like ordering layers(sprite renderers or 2d lights).

kind juniper
hexed sorrel
# kind juniper 2d package is just a collection of packages to help with developing 2d games. It...

Yeah, my response was more to push him in the right direction as far as researching goes, looking up "Unity" as a broad term will often bring a lot of guides relating directly to 3D projects, which can be very confusing when you're working in a "2D" project. Unity recently has made a pretty big push in terms of 2d-specific features that are very nice to have when making a lot of shaders a lot simpler than they'd be in 3D projects I've noticed.

#

But yes, natively you could hypothetically throw a 3d object into the scene with no problems haha.

#

I'm currently working on a 2D game and was mostly trying to get him in the right direction research-wise, but I appreciate your follow up! I am also pretty new to Unity's 2d workflow, so I also may make mistakes as far as accuracy in my responses haha. But that's just how I view it anyway.

daring nymph
#

apparently URP doesn't support multi pass shaders :(

#

I've finally almost figured out a way to make silhouettes work in unity 2d without spritemasks (cause this won't work for my project), and I find out that I can't even have multiple passes with conditional logic

#

Pass1:
Stencil
{
Ref 1
Comp Equal
}
ZTest Greater

Pass2:
Stencil
{
Ref 2
Comp LEqual
}
ZTest Always

#

is there a way to combine this logic so that in either case it continues, but breaks if both aren't true?

#

basically if stencil buffer == 1 and ZTest Greater || stencil buffer >= 2

kind juniper
#

You'd use render features in SRPs for that

daring nymph
#

oh god do I really gotta learn all that

kind juniper
#

Yes

#

Maybe not. I'm not sure if 2 passes is the correct solution anyway.๐Ÿค”

daring nymph
#

it's lowkey a jank solution lol

kind juniper
#

What exactly are you trying to do?

daring nymph
#

ok well it's kinda complicated but I have a "2.5D" project where I want a silhouette to display when a player is behind occluding objects. I have it working fine for this; however if an occluding object is behind and in front of the player it displays the behind occluding object over the silhouette. This is because the occluding/occluded objects are sorted in relation to the camera by the y axis. Ex: the lower the y axis is, the closer it is to the camera

#

the occluding/occluder objects also use a material separate from the rest of the project

#

I'll send screenshots in a sec

#

in these screenshots its working perfectly

#

wait a second it's working perfectly right now I'm confused

#

I have no idea why it's working now

#

there's no way; I'm so confused. I just spent nearly 2 days trying to fix this and I changed one number by accident and it suddenly works?!?!

royal pier
#

Anyone who can help me out with something? I a shader with URP settings. I need to cut out a hole. It seems to work, but for some reason it's also shown from angles it's not supposed to. For example in the last photo from below.

Shader "Custom/StencilMask"
{
Properties
{
[IntRange] _StencilID ("Stencil ID", Range(0, 255)) = 0
}

SubShader
{
    Tags { "RenderType"="Opaque" "Queue"="Geometry-1" "RenderPipeline" = "UniversalPipeline"}

    Pass 
    {
        Blend Zero One
        ZWrite Off

        Stencil
        {
            Ref [_StencilID]
            Comp Always
            Pass Replace
        }
    }
}

}

tough glade
#

_ObjPos ("ObjectPosition", float) = (0,0,0)
how could I set this variable from script?

#

or have I set it up wrong

#

I just need to store three floats
or two, two works as well

regal stag
#

From C# you'd set using material.SetVector("_ExampleName", someVector);

tough glade
#

great! that worked
how could I get any given pixel's distance from that position?

regal stag
#

Transform the vertex position to the same space (e.g. world, using model matrix), pass to fragment and use distance(positionWS, _ExampleName.xyz);

unique magnet
#

any reason why am i not getting shadows when the rendering mode is fade for the plane?

#

i am getting shadows in opaque mode, but the greys cannot look like this, it has to be transparent

tough glade
#

yeah im passing it in for a but it just seems to be returning 0 no matter where it is

#

ohh I see what I did

#

col = float4(0,0,0, ((distance(i.worldPos, _ObjPos.xyz))/_Power));
ok so this is changing the distance of the vignette
how can I change the falloff

hushed silo
#

does mipmapping work on alpha channel? I am trying to use texture2d LOD to get a blurred alpha map but no matter the lod setting the alpha remains unblurred

#

(this is on a rendertexture)

regal stag
hushed silo
#

Thanks. Yes it is. It works on the RGB but not on the A it seems

#

wait, no, thanks for making me double check it, no it;s not. these settings :

mossy iron
#

Hey!
This is my current Cel shader and i was wondering how i could add to it that it casts and recives shadows?
Thanks for any help!

regal stag
mossy iron
regal stag
#

Main Light Shadows

mossy iron
#

kk ty

regal stag
regal stag
brazen nimbus
#

Hello there ! I'm looking to change smoothly the speed of a panner. Is there a trick that allows to not have this rough transition ? (It's happening when i'm manually moving the speed parameter and i'm not quite sure it would be resolved even if it was a script that changes it) :/

regal stag
brazen nimbus
#

Yup, that's the only thing that came to my mind too, I hoped there was another solution in the shader ahah, thanks :d

brave yarrow
#

OK, so this is a little bit of an ongoing issue from my adventures in #๐Ÿคฏโ”ƒaugmented-reality channel, but it's more appropriate to continue here

I used a bunch of SystemInfo debugs and figured out that the GPU on the phone I'm using for this project does support compute shaders with OpenGL ES 3.2, but in a specific way - only compute and fragment shaders can have compute buffers (up to 24), while domain/geometry/hull/vertex shaders cannot have any.

The way I think I'm going to approach this is to write a compute shader that takes in the position and color data as a struct of two arrays in a single buffer, then performs transformation and writes the position to two textures. Then, in the vertex shader, I'll sample the textures and draw the points. I guess at this point I could also just instance some mesh or quads at those points as well.

I just have to figure out how to properly call this from the C# script to ensure that it all flows correctly

red flint
#

Hi everyone!
I'm trying to make a cutout shader that will work to procedurally place windows in a wall.

Here's where I'm at.
I have a cutout shader writing to the stencil buffer
I have an opaque shader that renders when the stencil buffer is not equal to what the cutout writes to it.

Here's my problem.
Cutouts behind the mesh still cut out the mesh.
The cutout cuts all meshes behind the shader, I only want to cut one wall per cutout.

Here's what I've tried.
Writing the depth data to the buffer to use this as a comparison, however I'm not sure how to use the 2 in conjunction.

Any ideas?

tough glade
#

can I make a shader bigger than the sprite it is on? (i;e a simple 2d shadow)

warm pulsar
#

I'm using a Matrix4x4 property to transform some positions, directions, and normals.

I have discovered that to correctly transform a vector that represents a surface normal, you have to multiply it by the inverse of the transform matrix you intended to use (so, for object-to-world, you use the world-to-object matrix truncated to 3x3). I read about it here while digging around for info: http://digitalrune.github.io/DigitalRune-Documentation/html/8c5feee3-4973-8c84-e032-bdb901ea0fb2.htm

And it works!

But I don't understand why -- isn't a world-space normal vector conceptually the same thing as a world-space direction vector?

#

clearly it is not!

warm pulsar
#

but then you'd have a distorted sprite!

low lichen
warm pulsar
#

that's confusing too, since that implies that both TransformDirection and TransformNormal will have identical outcomes, even though one uses the matrix and one uses the inverse of the matrix

glad hearth
#

unity c'est bien ce serveur lร 

regal stag
warm pulsar
#

Oh! That's the ticket.

#

I noticed I was randomly seeing the matrix on the "wrong side", but I figured I was uh

#

I don't know, having a skill issue w.r.t. linear algebra

warm pulsar
#

Do the default values not work for a Matrix4x4 property?

#

It looks like I'm getting an all-zero matrix even though the default is set to be the identity matrix

#

(in the shader graph)

#

this is causing some very wild artifacting!

#

i added a check for an all-zero matrix that just skips using it, but I'd rather not have to do that..

low lichen
radiant meteor
#

Can someone help me understand why this produces results based on the world orientation of the camera? If I look along positive Z axis, I get negative numbers, and when I look on negative Z axis, I get positive numbers.

The documentation for "Camera" says that direction is the camera's forward Z axis. It doesn't specify a space, but I'm assuming world? And for "View Direction" it says that it's the position from the fragment/vertex to the camera. Yet, it doesn't seem to be doing that?

#

I'd expect this to be 1 if I am perfectly looking in the opposite direction that the fragment's "view direction" is facing, and -1 if I am looking the same direction the fragment's "view direction" is facing.

past root
#

When coding a shader, what's the best way to make the object render on top of everything else?

past root
#

Nice

tacit parcel
#

Maybe you also need to make it render last using renderqueue = 9999

past root
#

Doesn't render queue stop at 5k?

kind juniper
tacit parcel
storm cloud
#

This might not be a shader question, but im trying to make a flat shaded grass object that recieves lighting. The problem i have right now is that when i look towards the light source, the surface of the grass model I'm seeing right now is dark.
I need the whole thing to be like the lit side of the face. also, when the face is lit from the side both sides gets dark, which also doesn't look very good.
I tried to edit the normal directions in blender to point straight up, but i can't seem to get that working

civic lantern
storm cloud
#

I was thinking I could have a script on each foilage object that casts towards the lights and calculates a color from that (i have like 200 foilage in the scene at a time)

tacit parcel
warm pulsar
#

I inspected the material in a text editor

#

Matrix4x4 doesn't show up in the inspector

low lichen
warm pulsar
#

afaict it just does not use the default value at all

frail violet
#

Good morning. I'm still pretty new to ShaderGraph. But, these two nodes. Based on what you see in my picture, isn't this 1/1, and shouldn't the color still be white in the right node?

warm pulsar
low lichen
shell walrus
#

Is there a way to stop shadergraph automatically creating a material? I always end up creating a new one elsewhere, so I presume I have two materials and can't delete the automated one?

low lichen
warm pulsar
#

I see.

warm pulsar
low lichen
silk pebble
#

Are there any tools available for building HLSL with HDRP? Visual studio doesn't really pick up the code. I see there are people who are building HLSL shaders for HDRP but have no idea how they manage to build for it. Would appreciate any insight.

sharp frost
#

Anyone knows what is the use of this node?

#

Where I can use LOD for Sample Texture?

amber saffron
amber saffron
regal stag
warm pulsar
regal stag
#

Oh right I see. I guess the matrix isn't initalised until entering play mode. May need to use [ExecuteInEditMode] on the script

warm pulsar
#

The regular Sample Texture 2D node wants to look at gradients based on neighboring pixels

#

and well...there are no pixels in the vertex stgae!

warm pulsar
#

it should just default to an identity matrix

#

that does not look like the zeroth row of an identity matrix ๐Ÿ˜‰

#

it's some catastrophically large value that's blowing out the camera

amber saffron
#

Can't you inspect the matrix node to check the values ?

regal stag
#

As if you break srp-batching compatibility on the shader, it does actually use an identity matrix then

warm pulsar
amber saffron
# warm pulsar

Yes, I was thinking of this one.
If you didn't already overwrite the value by a script or somethings, taths what should be used in the shader ๐Ÿค”

warm pulsar
#

it's a bit weird because it's not an "exposed" property

#

or at least I can't toggle that box!

warm pulsar
amber saffron
regal stag
#

Matrices are weird because they can't be "exposed" to the material as they don't get serialised - but by default the srp-batcher still treats them as objects set per-material, unless you use the override property declaration

amber saffron
warm pulsar
#

to break srp batching, I mean

#

ah, you can turn it off by putting the inspector in debug mode on an HDRP asset

#

yep, that does it

#

so i'm probably getting some weird uninitialized memory

low lichen
#

So the SRP Batcher isn't clearing its uniform buffers ๐Ÿค”

#

Worth it for the performance, maybe.

warm pulsar
#

the frame debugger shows sane values here during the GBuffer step

#

although, interestingtly, I don't see the matching _Ellipsoid_To_World matrix

low lichen
#

Is it used in the shader?

warm pulsar
#

oh

#

i deleted it lol

#

(because it was causing wild artifacting)

#

let's put it back

#

I was only using it in the fragment stage

#

well that's a little bit funny

#

but the matrices are showing up as normal identity matrices

#

they're also fine during the batch that draws the cube in DeferredDepthPrepass

#

the problem is that the mesh just...leaves entirely when I actually apply the transform matrices

#

it goes to space

#

or randomly makes a chunk of the screen turn white

#

i'll use them for something pointless

#

Maybe it doesn't show up properly in the frame debugger?