#archived-shaders

1 messages ยท Page 103 of 1

hardy juniper
#

as B and A do look like a mask or some single value for that chunk

harsh marsh
#

Turns out I can make a similar texture if I use Normal From Height on the voronoi node in shader graph. Then, using dot product on that and the XZ plane of the camera and using the absolute of that value gives me this

#

My main issue with this right now is the shimmering when the camera moves

#

completely procedural so you can easily make it yourself in shadergraph if you want to test

#

have to use an orthographic camera

hardy juniper
#

Eyy, if you step that you can get it closer to a strait line I think

#

may need to mask it a tad better too using A

eager folio
#

...why not just use a triplanar node?

harsh marsh
#

Trying to convert a shader from built-in to URP hlsl and my own blocker atm is a function called WorldNormalVector which doesn't exist in URP

harsh marsh
#

If I draw the value from the voronoi before the normal from height, it doesn't shimmer

#

I've taken the code for NormalFromHeight directly from the ShaderGraph node.

void Unity_NormalFromHeight_Tangent_float(float In, float Strength, float3 Position, float3x3 TangentMatrix, out float3 Out)
{
    float3 worldDerivativeX = ddx(Position);
    float3 worldDerivativeY = ddy(Position);

    float3 crossX = cross(TangentMatrix[2].xyz, worldDerivativeX);
    float3 crossY = cross(worldDerivativeY, TangentMatrix[2].xyz);
    float d = dot(worldDerivativeX, crossY);
    float sgn = d < 0.0 ? (-1.0f) : 1.0f;
    float surface = sgn / max(0.000000000000001192093f, abs(d));

    float dHdx = ddx(In);
    float dHdy = ddy(In);
    float3 surfGrad = surface * (dHdx*crossY + dHdy*crossX);
    Out = SafeNormalize(TangentMatrix[2].xyz - (Strength * surfGrad));
    Out = TransformWorldToTangent(Out, TangentMatrix);
}
keen onyx
#

Hi there, quick question. I am having trouble with the CanvasGroup alpha. It doesnt seem to be entirely smooth
the last digit aroung 0.99 seems to stick.
for example 0.99803 will be fine, but 0.99804 will be totally dark. even tho its obvious it could be much smoother.
Here is the output from renderdoc
is it a known issue? I can workaround by putting another image in the canvas group. like this. but Id like to know the cause so I can explain it
I assume there is some rounding issues perhaps?

#

I also get the same issue with a variable and set it directly from C# using material.SetFloat

woeful knot
spare oracle
#

Hello, I'm trying to play with the Shader from UNity's URP Package Sample called "TrailEffect", where a little ball goes around in some sand and gets a trail by displacing some verticies.

I am completely new to using Shaders and Shader Graph so please bear over with me...

Once I begin to scale the mesh that renders the sand that needs to be displaced, the actual trail effect begins drifting away from where the little ball thats supposed to have the trail effect actually is. How would I solve this?

From what I can understand its a problem with the UV being in local space or something, and not taking the scaling into account, but I simply have no idea how to fix this. What I'm looking for in the end, is just the trail being the same size as now, but the mesh being much larger, so I can use it on the ground of my game since its a pretty cool effect.

Thanks

woeful knot
#

And I don't understand where to put the Height map and spectacular

hardy juniper
woeful knot
#

height/ displacement map yes,

#

but i cant find a way to put displacement map...

hybrid garnet
#

I got the universal pipeline

#

but i need it for specific few scenes ONLY

#

but now every new gameobject i make has that unlit thing and i need light to see it

#

how do i make it so stuff is like before and i can set it to react to light manually

#

2d btw

woeful knot
harsh marsh
#

the generated-at-runtime normal map contains negative values which are crucial for it to work. Any image I make gets clipped to 0..1

hardy juniper
hardy juniper
harsh marsh
#

this one does have negative numbers though. i assume that's a bad thing normally but for my case it isn't

#

(what you're saying here is just the fragment shader returning waveNormal.x < 0)

hardy juniper
#

I think in shader graph it expects the input to be 0-1 range at the end

#

tbh i dont really know for sure ๐Ÿค”

grand jolt
#
float RandomFromSeed(float2 seed, float min, float max)
{
    float randomno =  frac(sin(dot(seed, float2(12.9898, 78.233)))*43758.5453);
    return lerp(min, max, randomno);
}

float4 GetPaletteBaseShadingColor(InputData inputData, Light mainLight, float toonLevel, float2 uv, half specular)
{
    float4 col = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv);
    [loop]
    for (int i = 0; i < _TargetPaletteTex_TexelSize.z; i++)
    {
        if (i >= (int)_PaletteLength) return float4(0,1,0,1);
        float texelWidth = _TargetPaletteTex_TexelSize.x;
        float u = (i + 0.5) * texelWidth;
        float4 srcCol = SAMPLE_TEXTURE2D(_PaletteTex, sampler_PaletteTex, float2(u, 0.5));
        if (all(abs(col.rgb - srcCol.rgb) < 0.001))
        {
            float lighting = saturate((toonLevel + 1.0+ _ColorOffset) * 0.5);
            // return lighting;
            float texelHeight = _TargetPaletteTex_TexelSize.y;
            float row = max(0.000001,lighting) / texelHeight;
            float darkerRow = row+texelHeight;
            float distanceToRow = abs(row - lighting);
            bool isOnShadeTransition = distanceToRow < _BaseMap_TexelSize.y * .2;
            float noise = RandomFromSeed(inputData.positionWS.xz, 0, texelHeight);
            float4 color = SAMPLE_TEXTURE2D(_TargetPaletteTex, sampler_TargetPaletteTex, float2(u, lighting + noise));
            float4 highlightColor = SAMPLE_TEXTURE2D(_TargetPaletteTex, sampler_TargetPaletteTex, float2(u, 1.0 -     texelHeight * 0.5));
            float highlightStrength = smoothstep(0, 1.0, specular);
            if(toonLevel > 0) color.rgb += highlightColor.rgb *  mainLight.color * highlightStrength;
            color = saturate(color);

            return color;
        }
    }

    return col;
}

#

Ive created a texel-based shader which uses palette textures for shading for a pixel art look. The first image is how the shader currently looks, and the second is a manually textured lit shader. Im now trying to get closer to the second image by introducing some noise on the edge of each color band to create a dithering like effect, but I cant seem to be able to figure out how to go about achieving that. How could I identify where a color band is next? and How do I restrict my random to the texel grid?

grand jolt
#

Ive abandoned the previous idea in favor of bumpmaps, but I cant seem to get them to work. Ive copied everything from the URP Lit.shader file but for some reason its not applying the normal map. If someone could take a look at my files to see if they might be able to spot whats keeping it from working then that would be very helpful.
https://github.com/StijnArts/TexelShaderProject/tree/main/Assets/Shaders/PaletteSwap

GitHub

Contribute to StijnArts/TexelShaderProject development by creating an account on GitHub.

harsh marsh
#

just received this response from the original creator of the effect

hardy juniper
harsh marsh
#

i mean i still have no idea what the math is to "extract the horizontal direction relative to the view"

#

I assume dot product would be involved, but everything I've tried doesn't seem to give any usable results.

hardy juniper
#

If i use alpha to reduce the "threshold" of the dot it gets better

#

A bit better in orthographic

rancid rune
#

Random question that doesnโ€™t quite a fit a category but letโ€™s say i have a full screen space shader and i have several other shaders i only want to apply to certain layers while retaining depth, how would i

harsh marsh
hardy juniper
#

has the img embedded

halcyon plank
#

how would i go about making a interactive snow layer / mud layer for the unity terrain, as i have done it with a high poly plane but in this use case that will not work

humble geyser
# halcyon plank how would i go about making a interactive snow layer / mud layer for the unity t...

I've been trying to do that as well, and this is how I did it: Make an orthographic camera a distance above the player, and make it render to a 1024 x 1024 R16_UNORM rendertexture. Make a sprite of the player's foot/whatever you want to print in the snow/mud with, and make it be on a layer which is not rendered on the main camera and rendered on your orthographic camera (culling mask). Then, make another rendertexture of the same settings and a compute shader that writes to that texture, accumulating frames by taking the max of the new texture and the texture the camera renders to. Now pass the orthographic camera's projection and world to camera matrices to your shader, and multiplying the projection and world to camera matrices with the world position of each pixel, dividing xy by w and remapping from -1, 1 to 0, 1, then inverting the y coordinate by subtracting it from 1. Now you have normalized UVs that you can use to sample your second rendertexture. You can use tessellation or parallax occlusion mapping, which simulates nonexistent geometry from a heightmap. For a terrain shader, you'll need _Control, _Splat0, _Splat1 _Splat2 and _Splat3 textures, which get passed in by unity terrain automatically. (However, in my case I'm doing it with shader graph and there's a bug where it works fine with other meshes but not with unity terrain, the matrices aren't getting passed in)

halcyon plank
eager folio
fringe karma
#

alright so one thing I'm trying to figure out is making a texture sampler where instead of inputting a UV value, I can instead input a world position and it'll automatically tile it based on said position. I can do this easily just by splicing the desired axes into a 2D vector if it only needs to be viewed from one angle, but I want to try and figure out how I'd check the normal angle and use the appropriate directions

#

Maybe I can somehow convert the world position based on the space of the normal's direction, then just get two of the axes. But the only 3D rotation function in shader graph is rotate around axis

fringe karma
#

alright here's what I made, it's janky as hell but I think it works for now

#

actually no it isn't

fringe karma
#

How would I go about making gradient noise that continuously shifts and warps, without actually scrolling? E.g. like how with voronoi noise, you can just continuously change the angle offset lerp to make all the cells shift and squish around each other

onyx coral
#

This shader is supposed to fade the top & bottom of this UI tiled image.

#

But when I use its material, the "tiled" image is only repeated once. Maybe I am overriding the UVs?

#

Here is without the material:

onyx coral
#

Looks like it's because of the "one minus": the UV goes above 1 as the image is tiled. But then how can I know the max UV value? ๐Ÿค” to substract from it instead

#

Well I guess I would really just need to get the recttransform's height... if there is no easy way I'll just use a material.SetFloat in a dedicated script.

#

Everything good for me ๐Ÿ‘Œ๐Ÿผ

#

Looks like there are some interesting features in the UGUI samples for Shader Graph (exists only since Unity 6000.0.40f1)

#

Including one for retrieving RectTransform size via a node

dapper hill
#

Hi guys I imported a map into my unity project (I use the latest version of unity) and some textures are pink but they are not always the same it depends on how he takes them so I searched on the internet how to fix it I installed "Universal RP" and I did the render pipeline converter and most of the textures were fixed instead some tell me that there was an error and that they do not support something written is there a way to fix them permanently or do I have to replace them?

ebon basin
dapper hill
#

an ok ok thank you very much

toxic peak
#

Hi everyone. Can anyone suggest a good series of free video or text tutorials for writing HLSL shaders for beginners for Unity 6000?

Ive started following a HLSL coding tutorial for beginners on youtube, but then ran into a problem where the suggested code just wouldnt work in Unity 6000 (the tutorial was made in 2021 ). Even more so - I later found out that the tutorial playlist was cut short 2 years ago and is never getting finishes. So Yikes

kind juniper
#

Honestly, if you want to learn hlsl, you probably shouldn't rely on unity api

#

Just look up general tutorials on hlsl

#

When you learned enough, you'll know how to apply it in unity context.

toxic peak
#

mmm, mmm, aight. Thank you!

gray knoll
#

My shaders are missing but they are declared in my ShaderVariantCollection?


but

  - first: {fileID: -6465566751694194690, guid: 3b226546493bb7445b0881cceaaa5adb, type: 3}
    second:
      variants:
      - keywords: 
        passType: 8
      - keywords: DOTS_INSTANCING_ON
        passType: 8
      - keywords: INSTANCING_ON
        passType: 8
      - keywords: 
        passType: 13
      - keywords: DOTS_INSTANCING_ON EVALUATE_SH_VERTEX LIGHTMAP_SHADOW_MIXING SHADOWS_SHADOWMASK
          _FORWARD_PLUS _MAIN_LIGHT_SHADOWS_CASCADE
        passType: 13
      - keywords: DOTS_INSTANCING_ON EVALUATE_SH_VERTEX LIGHTMAP_SHADOW_MIXING SHADOWS_SHADOWMASK
          _FORWARD_PLUS _MAIN_LIGHT_SHADOWS_CASCADE _SHADOWS_SOFT
        passType: 13
      - keywords: EVALUATE_SH_VERTEX LIGHTMAP_SHADOW_MIXING SHADOWS_SHADOWMASK _FORWARD_PLUS
          _MAIN_LIGHT_SHADOWS_CASCADE
        passType: 13
      - keywords: EVALUATE_SH_VERTEX _FORWARD_PLUS _MAIN_LIGHT_SHADOWS
        passType: 13```
woeful knot
#

Hello, How can I solve this to put and Use the Height / Displacement map ? (like in the right picture)

azure dome
#

Does someone have any tips and tricks, tutorials, whatever, for shaders that work with WebGL?
I'm trying to use Toony pro Colors 2, but I need my lights to be baked, I'm trying to find something that works in this case. Didn't have success with it yet

humble geyser
woeful knot
#

i'm in URP

humble geyser
# woeful knot i'm in URP

then you'll need to add more vertices or use parallax occlusion mapping, tessellation isn't supported in URP shader graph yet.

woeful knot
#

Something like this ?

humble geyser
# woeful knot Something like this ?

the node outputs parallax UVs, so you should use it to sample your main texture, but if you're using triplanar mapping to sample your main texture I don't think that would work.

teal lynx
#

pink ball of death (URP)

golden ledge
#

Hello, have anyone seen a simliar shader to do this effect, is this possible to be done in unity ASE shader editor, its similar like render node in Maya, but I dont remember everything clearly , Any ideas or a simple idea how to do this effect?

stray orbit
woeful knot
ebon basin
#

The parallax node with triplanar node doesnt work right out of the box if I recall.

inner solar
#

does anybody know how to make a sobel edge finder in shader graphs using nodes?

serene condor
#

(BIRP) are these all correct as a "root PBR" sub shader? i'm having weird results w ith some maps so i'm not sure if i'm reproducing their functions right.

#

pretty much just wiring everything up with a scale multiplier for adjustments if it doesn't look great in the environment. but i'm also pretty clueless as to what i'm doing here.

teal lynx
#

I can't change the smoothness property of a shader graphs material, yet the guy who's tutorial I'm following is somehow able to do it.

#

I was told to make a material from the shader in order to get an exposed value, although isn't this what I've already done here? Am I doing this wrong?

neon gale
#

aside from that, for a second, why is your 'smoothness' a vector2 instead of a float/slider?

teal lynx
#

Huh touchรฉ let me check what I'm doing wrong here ๐Ÿ˜†

#

I didn't notice that

#

Wait I just realized they're using a "vector1". Isn't that a float?

neon gale
#

for all intents and purposes, yes (although someone could probably pull an 'well aktually' on us ๐Ÿ˜

teal lynx
#

I must've misheard it then. Thanks. How would I be able to change this though?

neon gale
#

you mean, change it to a float?

teal lynx
#

no I meant make it exposed, sorry

neon gale
#

are you using unity 6?

teal lynx
#

Yes, 6.1 I believe

neon gale
#

oh, i have not used that yet, but in 6, it is already exposed. click on it, in the list where you created it, and then look at the 'inspector' that comes up. sorry for that wrong terms. i rarely use SG. trying to make a SG now, to screenshot

teal lynx
#

alright.

neon gale
teal lynx
#

The guide I'm following just shows an exposed check that I don't seem to have

teal lynx
# neon gale

I have show in inspector checked but I can't change it

neon gale
#

now, right click on your Shadergraph in the Project. (the one you have a screenshot of that shows the initial material) and Create a new Material. it should be exposed in that

teal lynx
#

Yep it works it seems. I'm not sure why that's the case though.

neon gale
#

it is normal. i do not know the exact details to explain it properly though

teal lynx
#

Game of find the 7 differences ๐Ÿ˜ญ

neon gale
#

indeed

teal lynx
#

I appreciate it ๐Ÿ‘

stark monolith
#

Does anyone here have ny good resources for using unity's built in sky renderer tool?

steel notch
#

I have 2 unit vectors, the normal vector of a quad, and the view angle. As the quad rotates, the dot product between the two unit vectors will cycle from 1 to -1 and then back to 1 over a 360 rotation. I want to introduce some value that increases the rate at which this oscillation happens. So, for example, the dot product value will cycle from 1 to -1 and back to 1 over only 180 degrees.

#

What can I do? Acos to get the initial angle back, multiply it, and then cos again?

cosmic thorn
#

[WARNING, LOW POLY GORE]
im so confused over this
i know theres an unneceasrry multiply, dont worry about it
so i multiply white and black by red, the white becomes red and black is unchanged
i then add this to the original texture to replace the white with the red, while not affecting the black, however this simply results in a white color, despite the destcolor value being red

#

could anyone explain why this happens and how i can fix it

prime coyote
#

Hey yall I have a simple question regarding HLSL code in Unity, I wanted to utilize just the G channel of the UV being used on an object, how would I go about calling that in shadercode?

#

I'm experienced in shader-graph but I wanna do this specific thing in unity's shader code, can't seem to find a good answer online for it

prime coyote
# ebon basin uv.y?

Hi there, thank you for responding, it seems to be saying undeclared identifier 'c' at line 39, which is the line at the bottom there that is for the alpha

#

c.a seems to be incorrect but I'm totally confused haha

#

Im basically trying to create a gradient lerp on a material

#

I know the UV might be correct

#

idk what's going on haha

ebon basin
#

I'm not seeing any declaration of c here unless it's supposed to be global in scope

#

I think you mean color

prime coyote
#

hm alright, so how would I declare C?

#

I declared alpha as color.a as the A channel of it would be 0

#

hopefully

#

The error is gone but now the material is appearing error magenta

#

Could it be because I lerped the color incorrectly?

low lichen
prime coyote
#

So what type should I use then?

low lichen
# prime coyote So what type should I use then?

URP and HDRP shaders do not have an equivalent to surface shaders currently. Surface shaders make it much simpler to write shaders that support lighting. In URP and HDRP, you have to implement a lot more boilerplate code just to get lighting working.

#

If you don't need lighting, it's simpler to write an unlit shader.

prime coyote
#

Damn you're kidding right?

#

That's annoying

#

I need it to have shadows basically

#

over the grass

low lichen
#

Is it not possible to do with Shader Graph?

prime coyote
#

I have a very unique issue, you see in shader-graph in what I'm working on, we have a lineart shader that excludes line-art by the alpha channel of the surface

#

now we can't go and make all the grass transparent for performance reasons

#

But I was told in shader code I can make a grass shader that has an alpha of 0 passed through the color channel

gray imp
#

does anyone know of a shader for viewmodels for urp?

prime coyote
#

Problem is I need lighting on the grass

#

Is there a way I can make an unlit shader detect a shadow over top of it, and make the object darken in turn?

low lichen
prime coyote
#

I've asked a senior tech artist on the matter and he says it's likely it'll need code

low lichen
prime coyote
#

Trust me just shadow support will do

#

we need soft stylized grass that goes by a linier gradient

#

I've achieved this in an unlit shader in code already, basically all it needs is the ability to detect shadows and darken the whole object in turn

low lichen
#

The whole object? Are you referring to individual blades of grass?

prime coyote
#

basically yea, ideally precise shadows but the whole object would do too

#

basically all it needs is to draw a shadow on this unlit blue plane

low lichen
#

This is URP?

prime coyote
#

This is using URP yes

#

The reason I want it to just detect shadows is because this is being built for low spec hardware

low lichen
prime coyote
#

hmmmm idk what half of it does

low lichen
#

Can you post your unlit shader code?

prime coyote
#
{
    Properties
    {
        _Color("ColorA", color) = (1,0,0,0)
        _ColorB("ColorB", color) = (1,0,0,0)
        _Position("Position", Range(0.0, 1.0)) = 0.5

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

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

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

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

            float4 _Color;
            float4 _ColorB;
            float _Position;

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

            fixed4 frag (v2f i) : SV_Target
            {
                // Creating Gradient
                
                float4 col = lerp(_Color,_ColorB,i.uv.y * _Position);
                return col;
            }
            ENDCG
        }
    }
}```
#

Here you go :)

#

This one 100% works n stuff, just doesnt recieve shadows haha

low lichen
#

So, there can be a lot of added complexity when adding shadow support because of how many different options there are. Hard shadows, soft shadows, shadow cascades, screenspace shadows, shadows from additional lights.
You can simplify your shader if you don't need all those things.

prime coyote
#

Hard shadows is 100% fine

#

It only needs to be cast from a single directional light

low lichen
#

So I think all you need is to call TransformWorldToShadowCoord from Shadows.hlsl to get the shadow coord, and then pass that into MainLightRealtimeShadow. Then you'll get back a shadow attenuation number, 0 for full shadow, 1 for no shadow, which you can multiply with your col.

prime coyote
#

hm alright

#

I'm very new to shader code, most of my experience is using shader-graph, could you give me an example of how this would be done?

low lichen
#
Shader "Unlit/sdr_UnlitTest"
{
    Properties
    {
        _Color("ColorA", color) = (1,0,0,0)
        _ColorB("ColorB", color) = (1,0,0,0)
        _Position("Position", Range(0.0, 1.0)) = 0.5

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

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN

            #include "UnityCG.cginc"
            #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadows.hlsl"

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

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

            float4 _Color;
            float4 _ColorB;
            float _Position;

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

                o.shadowCoord = TransformWorldToShadowCoord(mul(unity_ObjectToWorld, v.vertex).xyz);

                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                // Creating Gradient
                
                float4 col = lerp(_Color,_ColorB,i.uv.y * _Position);

                float shadow = MainLightRealtimeShadow(i.shadowCoord);

                col.rgb *= shadow;

                return col;
            }
            ENDCG
        }
    }
}
prime coyote
#

Wow that's like magic

#

You can just call packages like that up at the top?

low lichen
#

*edited to add keywords that Shadows.hlsl expects the shader to define.

low lichen
prime coyote
#

Right I understand

low lichen
#

Also note that you've started with the legacy unlit shader template, that has a slightly different syntax than URP shaders use. But it should still work.

prime coyote
#

Just getting it copied in now to see it in action

low lichen
#

I haven't tested this. Very likely some issue with it. Just let me know.

prime coyote
#

It seems to be serving an error that it cant include file "Packages/com.unity.render-pipelines.core/ShaderLibrary/Shadows.hlsl"

#

Im guessing this is on my end

low lichen
#

No, that's my mistake. The path should be:
"Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"

prime coyote
#

Oh lemme give it a go then

#

Alrighty I put it in, it seems to recognise it but it spat out another error and about 5 warnings

low lichen
#

Let me see the error and warnings

prime coyote
low lichen
#

Ok, so now we're running into a problem with the legacy syntax conflicting with URP shader files. When you use CGPROGRAM, it automatically includes a bunch of legacy functions that are needed for legacy shaders. It must have its own function named PackHeightmap that conflicts with the one Common.hlsl defines.

prime coyote
#

Hmm alrighty

#

Does this template include shadow support?

low lichen
#

I'll leave it as an exercise for you to move the relevant code from your current shader to the new template.

#

No, this template is like the unlit shader template you started with.

prime coyote
#

Right I see

#

I'll try to get it working

sharp pagoda
#

Hello, someone can tell me how to add a Texture2DArray into a custom function please ?

I'm using :

    Texture2DArray TexArray,
    SamplerState Sampler,
    float2 uv)
{
      float3 uvw = float3(uv, 0);
      spectrum[0] = SubScenes.Sample(SamplerTexArray, uvw);
}

But I have the error :

'SelectViewDefault_float': cannot convert from 'struct UnityTexture2DArray' to 'Texture2DArray<float4>'

I can't find any tutorial or stuff on google

low lichen
prime coyote
#

Hmm alright, so I tried implementing your shadow solution with the template you gave me

#

and adding the lerp color thing

#

seems to be returning an error

sharp pagoda
low lichen
#

You might get an error in your IDE because it doesn't know this function will be within the context of a shader graph, where these types are defined

sharp pagoda
low lichen
prime coyote
#

Right, I see

low lichen
#

Try adding #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl" above the Shadows.hlsl include.

#

(hopefully this won't be a long rabbit hole of new errors and new include files)

prime coyote
#

It fixed it! One moment for me to fix another error I know I caused lmao

#

So I had a question, where do I actually put the o.uv = v.uv;

            o.shadowCoord = TransformWorldToShadowCoord(mul(unity_ObjectToWorld, v.vertex).xyz);
#

in this new template

#

Basically I cant define the UV or shadow coordinates for the final color stage

low lichen
#

You need to define the uv in the Attributes struct, which is the equivalent to the appdata struct in your first shader, then do the same in the Varyings, which is the same as v2f.

#

It's the exact same thing in fact, it's just a different naming convention that URP/HDRP started to use.

prime coyote
#

Right I see thank you

#

My apologies for all these issues

#

youve been a massive help so far in helping me understand this

low lichen
#

Don't worry, I fully expected this going into it. This is the normal workflow when working with shader code, especially SRPs. Resolving compile errors until things start working.

prime coyote
#

Right I understand, alrighty so I've attempted putting it into the attributes and varyings, it doesn't seem to like the o. structure on it

#

At least I think

low lichen
#

The vert function in the URP template decides to call its output variable OUT instead of o. Have you accounted for that? It can be named whatever you like, as long as its consistent.

prime coyote
#

It keeps throwing syntax errors so it must be how I'm writing it

prime coyote
#

I will fix that

#
            {
                // The positionOS variable contains the vertex positions in object
                // space.
                float4 positionOS   : POSITION;
                float2 OUT.uv = v.uv;
                float3 OUT.shadowCoord = TransformWorldToShadowCoord(mul(unity_ObjectToWorld, v.vertex).xyz);
            };

            struct Varyings
            {
                // The positions in this struct must have the SV_POSITION semantic.
                float4 positionHCS  : SV_POSITION;
                float2 OUT.uv = v.uv;
                float3 OUT.shadowCoord = TransformWorldToShadowCoord(mul(unity_ObjectToWorld, v.vertex).xyz);
            };```
#

This is how I've structured it

#

Seems to be throwing a syntax error at line 46 which is 'float2 OUT.uv = v.uv;' in the Attributes section

low lichen
#

If you look at the original shader you had, I think you'll notice a big difference in where the code is placed. Remember that Attributes is the same as appdata and Varyings the same as v2f.

prime coyote
#

will do

low lichen
#

There shouldn't be any massive structural changes between your original shader and this new one. Mostly just some renaming.

prime coyote
#

I see the difference

#
            {
                // The positionOS variable contains the vertex positions in object
                // space.
                float4 positionOS   : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct Varyings
            {
                // The positions in this struct must have the SV_POSITION semantic.
                float4 positionHCS  : SV_POSITION;
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
                float4 shadowCoord : TEXCOORD1;
            };```
#

this is the fixed version now

low lichen
#

This part looks good

prime coyote
#
            {
                // Declaring the output object (OUT) with the Varyings struct.
                Varyings OUT;
                OUT.uv = v.uv;
                OUT.shadowCoord = TransformWorldToShadowCoord(mul(unity_ObjectToWorld, v.vertex).xyz);
                // The TransformObjectToHClip function transforms vertex positions
                // from object space to homogenous clip space.
                OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
                // Returning the output.
                return OUT;
            }```
#

i've tried adding the final part into varyings vert

#

It says it cannot define v.uv, is there another way to write this in syntax much like o.uv

#

would it be VERT?

#

Definitely feels like we're super close haha

low lichen
#

The original shader was reading from a variable called v. That was a parameter into the vert function. Now, the parameter is called IN.

prime coyote
#

thank you

low lichen
#

Also note how the vertex variable that was in appdata has now been renamed to positionOS in Attributes.

prime coyote
#

Yes yes, fixing that now, seems to work

#
            half4 frag() : SV_Target
            {
                // Creating Gradient
                
                float4 col = lerp(_Color,_ColorB,IN.uv.y * _Position); //

                float shadow = MainLightRealtimeShadow(shadowCoord);

                col.rgba *= shadow;

                return col;
            }
            ENDHLSL
        }
    }
}
#

This is the last part

#

at line 82 float4 col = lerp(_Color,_ColorB,IN.uv.y * _Position); it's saying "undeclared definer IN"

#

Which I'd assume would be from the 'IN.uv.y'

low lichen
#

How was the original shader accessing the UV?

prime coyote
#

i.uv.y

low lichen
#

And where was i defined?

prime coyote
#

fixed4 frag (v2f i) : SV_Target I believe

low lichen
#

The template shader has not been very helpful here. Since it doesn't need anything from the vertex shader, it doesn't even bother to define the Varyings parameter in the function.

#

So the fix is
half4 frag(Varyings IN) : SV_Target

prime coyote
#

Right I see

#

Alrighty so now it looks like this

#
            half4 frag(Varyings IN) : SV_Target
            {
                // Creating Gradient
                
                float4 col = lerp(_Color,_ColorB,IN.uv.y * _Position); //

                float shadow = MainLightRealtimeShadow(shadowCoord);

                col.rgba *= shadow;

                return col;
            }
            ENDHLSL
        }
    }
}```
#

it's throwing this error now

#

Line 84 is float shadow = MainLightRealtimeShadow(shadowCoord);

low lichen
#

It might help to understand that we are calculating the shadowCoord value in the vert (vertex shader) function, putting that into the Varyings, which then gets passed into the frag (fragment/pixel shader).

#

Just like the uv, if you want to access the shadowCoord, you'll find it in the Varyings IN parameter you just added. IN.shadowCoord.

prime coyote
#

Alrighty, one moment :) lemme get that sorted

#

WOAH

#

IT WORKS

#

THANKS

#

DO YOU HAVE A VENMO

low lichen
#

Thanks is enough ๐Ÿ˜Œ

prime coyote
#

Well thank you very much, I've learnt alot about shader code tonight

#

my co-workers will be very happy to hear we've solved the grass issue

woeful ferry
#

I'm a total noob developer, and I'm using AI to build most of my game.. I got pretty far, but now i want to smash my head through a window... i'm using the built in/standard pipeline, and i want to create a little slime puddle on the floor, and i have this custom shader, but it just seems impossible to receive any shadows!.. I am also using free Unity.. can you please point me to a custom shader that has shadow receiving working so i can take that as a start and modify it to what i need rather than starting from scratch and now wanting to kill myself?

hardy juniper
sharp pagoda
#

Hi again... A simple question (I think I got tricked). Is it possible to send an "array" of RenderTexture to a shader? I have X camera filling X RenderTextures (I can have a max). My previous shader was asking for 13 Rendertextures as inputs, and I read something like I could use a Texture3D. Is that true ?
Or do I have to revert my changes and stay with a stupid huge code ? x)

frigid jay
sharp pagoda
#

Well it's limited to 8 on my side, and Keijiro sample don't use an array but several textures. So let's forget about it for now.

regal stag
# sharp pagoda Hi again... A simple question (I think I got tricked). Is it possible to send an...

RenderTexture can be a texture array if created through code, by setting it's .dimension to Tex2DArray. And volumeDepth would control the number of entries/slices.
In shader should be able to treat that the same as a Texture2DArray / UnityTexture2DArray in ShaderGraph.
But you'd probably need to change how you fill them. i.e. if using CommandBuffer.SetRenderTarget there's an overload with a depthSlice index.

sharp pagoda
prime coyote
#

Would you know what that means by any chance?

prime coyote
#

Thank you for responding nonetheless

slim venture
#

Any idea why my shaders look square?

#

Also everything looks kinda weird(the thing below the radio)

ebon basin
slim venture
#

Thanks, i'll try that when i get on my pc

sharp pagoda
woeful breach
#

Lets say i have a plane facing away from a lightsource placed inbetween a light source and the camera, can I invert the normals so that the plane is effected by the light behind it ?

kind juniper
#

Inverting the vertex normals would have the same effect

woeful breach
kind juniper
woeful breach
#

Thats too conplex for me, i didnt even manage to recreate the default urp simple lit shader

kind juniper
#

Well, what you're trying to do is quite far from common rendering techniques, so you need to have some experience in computer graphics to achieve the desired effect

hardy juniper
woeful breach
kind juniper
woeful breach
kind juniper
#

Lit. Was a typo

hardy juniper
#

@woeful breach I used these examples in the past but one needed a small fix to work:
https://github.com/Cyanilux/URP_ShaderCodeTemplates

For the rim lit parts i think you calculate the lit result for both sides and keep the brightest to achieve the effect you desire ๐Ÿค”

#

somehow unity themselves cannot provide a lit urp example

woeful breach
humble geyser
#

I'm trying to offset vertices of a high poly plane as terrain, and I want to have a camera render a heightmap of the scene (to the depth of a rendertexture) and I'm wondering how I could sample a depth-only rendertexture in shader graph, because if I use the red or alpha outputs of sample texture 2d lod, subtract it from the orthographic camera's height and use that as terrain height and transforming into object position the terrain is displaced uniformly and moves with the scene camera? (I'm using HDRP and I have tessellation maybe that's causing the issue.)

slim venture
ebon basin
slim venture
#

found it

swift hearth
#

i really really need help im following a brackeys tutorial and i did exactly what he did except for the fact that he has the fragment part with rgba unlike me with rgb only so i put the alpha in the other part. the outline looks like that tho and i have no idea why cause ive never worked with shaderss

hardy juniper
#

E.g. split rgba and take a -> output alpha

swift hearth
#

omg thank you so much

#

that was so stupid tbh

hardy juniper
#

It's easier in code but you know now you can split a vector into it's components!

primal spruce
#

Yo, I don't know if this problem has a solution but I have a paralax occlusion stone wall texture that I need to apply to some walls but am not about to handle UVs, so obv do triplanar but as far as I can tell you can't do both of them at the same time. Does anyone know how I can work around this issue? I am using unity version 2022 lts

#

I couldn't find anything online and what I did find said this wasn't possible

last eagle
#

Hello Unity gang, I am curious as to why I keep getting this issue.
Shader error in 'Shader Graphs/Lit': 'PBRDeferredFragment': cannot convert from 'struct v2f_surf' to 'struct SurfaceDescription' at V0.1/Library/PackageCache/com.unity.shadergraph@14.0.12/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/PBRDeferredPass.hlsl(145) (on gles3)

Theres another error to it but way too long to post the text.
I have tried to look through the graph inspector within the Lit shader and can not seem to figure out what it is.
Image

shadow locust
last eagle
#

yeah everything is up to date

shadow locust
#

no I don't mean major version upgrades.

#

just having the latest version of 2022.3 e.g.

last eagle
#

i believe i do have the most recent one

last eagle
humble geyser
humble geyser
humble geyser
cedar meadow
#

hey lads, before I finish this abomination, I just wanna know is there a way to replicate this effect on a curved surface using shaders?

hardy juniper
last eagle
#

Hello does anyone have an idea on how to fix this lit shader?

Shader error in 'Shader Graphs/Lit': 'PBRDeferredFragment': cannot convert from 'struct v2f_surf' to 'struct SurfaceDescription' at V0.1/Library/PackageCache/com.unity.shadergraph@14.0.12/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Includes/PBRDeferredPass.hlsl(145) (on gles3)

Theres another error to it but way too long to post the text.

What Iโ€™ve tried:
deleting and letting the library regenerate.
Looked around within the shader and can confirm the errors come from it but why? Unsure.

kind juniper
#

Though, it seems to be targeting the built-in rp, which I heard unity is phasing out from, so maybe upgrade to one of the scriptable render pipelines.

prime coyote
#

Then uv the low poly structure to use this new normal pattern

#

though I would personally reccomending using Substance 3D Designer and making the pattern as a procedural tileable material, then placing it onto your low-poly object to save texture memory, it also means you can re-use that tileable texture across other assets that look like that

cedar meadow
hardy juniper
#

blender can do normal map baking

prime coyote
hardy juniper
#

but yes its often best to use a normal where possible for extra detail and use geometry where needed.

prime coyote
#

I would still reccomend making a tileable normal map though as it saves texture memory in the long run if you have alot of different structures that would use that pattern

hardy juniper
cedar meadow
#

well, the game's in a confined space for repeated amounts of time so I guess I would go with which process is the shortest or easiest

prime coyote
#

and making a tileable texture requires learning a little bit of substance designer or a related program, which can also be tricky

hardy juniper
#

Tbh it doesn't look too bad detail wise. If lots could be rendered at once (e.g. overdraw) though then you may want to use LODS.

prime coyote
#

though truthfully, if your game is in confined spaces 99% of the time you could reduce the bricks to be seperate meshes on the same obj, then place them over the top to reduce the amount of polygons you're using, then just use the mesh like that ingame with LODs at long distance

#

you could probably get away with it if it's an important detail you'll be looking at up close, just be mindful of how many tris are being rendered at any given time

cedar meadow
#

got it

#

thanks alot lads

#

have a nice day

hardy juniper
#

occlusion culling is your friend

cedar meadow
#

ngl theres a lot of these stuffs I need to learn

prime coyote
cedar meadow
#

I couldnt keep up with probably 50% of the conversation lol

hardy juniper
#

If its indoor stuff that is all pre made then should be a good application

cedar meadow
#

it is!

cedar meadow
#

thank you!

prime coyote
cedar meadow
#

not quite, I usually do the codings and flows of the game

#

this is my first time doing textures for this team

#

so a junior on the VFX/Shaders the like

prime coyote
#

ah right, well I'm quite experienced in PBR textures and I have a fair bit of experience in unity shadergraph so feel free to ask questions anytime

cedar meadow
#

thank you mate

#

I will definitely return with more questions, so I appreciate your help

#

have a great day to you

prime coyote
#

you too

last eagle
primal spruce
prime coyote
#

Dm me what you're trying to achieve and ill take a look

primal spruce
#

Oh fair enough, thanks

steel notch
#

Hey guys is my subgraph too big?

last eagle
teal lynx
ebon basin
#

post your code to a paste site, but looks like you're messing with depth values

teal lynx
ebon basin
#

So you have additive blending and you don't write to depth, but I'm not too sure why additive wouldnt render over the skybox

teal lynx
#

Yeah that's what's confusing me

ebon basin
#

oh you're using blending with opaque

#

If you want transparency/blending then you want:
"RenderType"="Transparent"
ZWrite Off*

teal lynx
#

They don't seem to have the same issue as me though in the video

ebon basin
#

What does additive opaque even mean though. It's just overdrawing I would expect

teal lynx
#

I'm using URP

ebon basin
#

This is their video

#

Oh, you need to change the queue too

last eagle
hardy juniper
#

what unity version and is shader graph + urp up to date? What targets does your shader graph shader have?

teal lynx
hardy juniper
teal lynx
#

They had a different result compared to me

ebon basin
#

The only thing I can think of is at the bottom of the material you can override the queue

#

transparent I think is 3000

teal lynx
#

oh that worked LMAO

last eagle
hardy juniper
#

is the stack for this "value cannot be null" log from shadergraph?

teal lynx
#

@ebon basin Does the render queue in the inspector correspond to the queue tag?

last eagle
#

if i try to - it it does not allow me

ebon basin
teal lynx
hardy juniper
# last eagle

my last idea is to close proj, delete Library folder and re open (this makes everything re import)

last eagle
#

sadly

#

the only thing i can think is its something with the asset pack ive gotten this medival lowpoly one

hardy juniper
#

Is ShaderGraphs/Lit your own shader?

last eagle
#

it seems to occur when i add in stuff from that.

#

no

#

somehow just ended up with it from assets i assume or an asset is using it

teal lynx
#

Can I create new functions anywhere in the HLSL portion of the shader script?

last eagle
#

i did have to click URP 17 for this one asset pack

#

like import the asset pack, then click URP 17 then import that,

#

has to be this one using that

hardy juniper
#

If there is a shader called "Lit" delete it and see if thats the cause

last eagle
#

it is

#

but dont i need it?

#

it seems to look much better

hardy juniper
#

You can try re making it or replacing it with a normal urp shader

#

If the materials that used it are broken that is (if they are not i guess its all fine)

last eagle
#

i am trying a suggestion from Claude quickly.

#

Select your camera in the hierarchy
In the Inspector, find "Rendering Path"
Change it from "Deferred" to "Forward"

This works because shader graphs for the Built-in RP generally have better support for the forward rendering path.```
#

same issue :p

#

think im going to switch it to a standard one, but is it possible to come back to this and try and fix it down the line or something more urgent now?

hardy juniper
#

Ha its speaking absolute bullshit

last eagle
#

lol

hardy juniper
#

urp was gonna be forward by default so

last eagle
#

it had the exact directions right but i guess so lol

#

i think its my splines tbh

#

i see my splines using Shader Graphs/Lit

#

I found some ArnoldStandard ima try.

#

makes it look like a glass road but meh.

hardy juniper
#

The main URP shaders are Lit, Simple Lit and Complex Lit

#

still not great if one is broken as it should not be

last eagle
#

it built.

#

it works but my road looks like a mirror lols.

#

oddly builds and all physics work just the looks lol.

hardy juniper
#

those arnold shaders are not really good to use so you should still try to fix the issue/ swap to another urp shader

last eagle
#

okay gotcha

#

hey i really appreciate you helping tho g @hardy juniper

hardy juniper
#

np np

last eagle
#

that would be like the last thing id assume. i know i do with a few other things.

hardy juniper
#

samples? nah i see no reason you do with that error

last eagle
#

ahh okay. well ill try to keep looking for examples

#

okay well.. I have selected the URP / Terrain / Lit Shader and it seems to work, it looks different but its working and im still technically using Lit.

#

waiting for the build so not 100% on the working part.

#

works ๐Ÿ™‚ thanks

radiant meteor
#

how do I get the scene color in a fullscreen pass in shader graph in HDRP?

I tried using the HD SampleBuffer, the HD Scene Color and the Scene Color nodes. All of these return black. I also tried setting the target color buffer to 'Custom' and using these nodes, then reading from the custom buffer from a second shader and this does also not work.

robust brook
#

Does anybody know how to displace a texture so it has a wiggle effect on the uv?

kind juniper
radiant meteor
#

its a problem with the unity version, if i upgrade it works.

kind juniper
zinc ibex
#

Which shader is the best for performance on mobile in URP? (lit)

hardy juniper
#

there is also a specific shader for lightmap only lit stuff

hushed silo
#

I'm trying ot fake some planar reflections, where the boxes above ground are solid, they have a mirrored version beneath which is alpha tied to negative Y.Is there some way I can still deph test these so that I'm not seeing all of the resultant faces ut more of an actual reflection feel?

#

i've tried depth write on/off and different depth test modes (using shader graph)

hardy juniper
#

Tbh i feel like using a second camera to capture and render this would be easier. Otherwise you need the "floor" to be semi transparent and to perhaps use the stencil buffer to make the bottom objects only be visible through the floor.

serene condor
#

Letโ€™s talk workflow.

If I want to add something like a universal outline to all the player and enemy models,

Enemies can have an eye animation shader as well as a disintegration effect

Players have an animated effect of their own

Would it be better to

A). Create my own PBR sub shader, create the outline shader as a sub shader that also uses the PBR sub shader. Then create an enemy shader that can enable the eye animation feature variant or not, disintegration effect is built in for the death animations

Player shader would be a derivative of the outline shader with the LED pulse effect as a variant feature also

Or B). just make 2 shaders and copy paste the outline effect?

#

Feels like you have to recreate all the parameters in sub shaders anyway

hushed silo
hardy juniper
#

a second camera can be cheap if you render at a low resolution

hushed silo
#

I dont' know much about stencil buffer, could it be used to render them opaque, put them on top of floor and blend them out on height?

#

mmmm, in URP I've found any additional camera whatsoever adds at least 1ms, and that's just on cpu

hardy juniper
#

stencil buffer would be used to only make them draw where the floor had already drawn

hushed silo
#

like, as a way to put them on top? Sorry not sure what the stencil buffer would be doing here

hardy juniper
#

Just a way to make sure they only draw where the floor is (so they arent visible elsewhere)

#

You probably need a shader that will adjust the colour on the "reflected objects" to get more black the deeper it goes from the floor

hushed silo
#

to fade it out you mean, would there be a difference between going black and using additive vs using the alpha value

teal lynx
#

Can I use a c# method in a shaderlabs script?

#

eg this method.

low lichen
teal lynx
ebon basin
#

oh sorry thought you said shader graph

serene condor
#

i really cant have HDR color in a sub shader? so if i want emissive map i have to duplicate it in every shader graph?

cobalt idol
#

hi!

I have a flat shaded mesh that I displace with a height map. the base color is just flat white.. what are the dark spots I'm getting there? its like everything that's a bit lower is extremely dark from the Y 0 downward

what is that and how do I avoid it? (HDRP Lit)

cobalt idol
#

when I turn off AO it's just completely black below Y 0

cobalt idol
#

wth. when I place my object at 0, -255, 0 and add 255 to the displacement Y, the dark spots are gone. wth is this. when I get far enough away it disappears too

serene condor
#

would it be better to cram all my effects into standard shaders per model type and keep it all to one material, or add support shaders like "outline" as secondary materials?

ebon basin
#

not that you can't use multiple materials, with one for outline, but the inspector complains to you about it ;p

serene condor
#

and yeah i'm on BIRP

ebon basin
serene condor
#

thats the closest i can get it based on the URP methods

#

gets messy any larger than that

ebon basin
#

There shouldn't be any difference in the code to that of BIRP or URP. I would even expect the shader graph tutorials to work just fine too

serene condor
#

the cleanest looking one leveraged scriptable renderer stuff

#

looked like a URP only thing

ebon basin
#
tacit parcel
polar pasture
#

HDRP UV Light Reveal Effect โ€“ Help Needed

Hey, hey, and hey! peepoGlad ๐Ÿ–๐Ÿป

I have no idea why, but I feel like Iโ€™ve been struggling with a massive issue for a few days now.
Maybe itโ€™s super simple for some of you, but I just canโ€™t figure it out...

Goal:
How do you achieve an effect in Unity HDRP (yes, HDRP โ€“ not URP or Built-in!) where symbols or markings only appear under UV light, like a blacklight effect?

I've seen tons of tutorials for URP or legacy pipelines, but HDRP seems way less documented when it comes to this.

** What Iโ€™m aiming for:**
Iโ€™m trying to get an effect like this โ†’ (screen)
Basically, you shine a UV/spotlight and see hidden patterns or symbols appear only where the light hits.

** What I need:**
Any advice, Shader Graph tips, HLSL tricks, examples, or keywords I should search for.
Iโ€™m totally lost on how to make this work the HDRP way.

Prayge Iโ€™ll pay in prayers to the Great Gaben so your projects sell like crazy and never get review bombed.

Thanks from the mountain! hehe

hard moss
#

what kind of shader do i need to make a hole on a mesh?

strange prairie
polar pasture
#

"Using Light Colour"

strange prairie
#

Lol that's awful ๐Ÿ˜„

#

Yeah I'm sure you could read the light color in HDRP as well. Dunno if there's a convenient node for it

#

I'd probably do something with the stencil buffer instead but shader graph can't work with that

polar pasture
# strange prairie Lol that's awful ๐Ÿ˜„

Honestly, Iโ€™m pretty average when it comes to shaders โ€” this is actually the first time Iโ€™ve had to deal with them more seriously.

If you know how to do it, have the time, and are willing to help, could you maybe explain it a bit more?
If itโ€™s not too much to ask, maybe you could even show a simple prototype?

strange prairie
#

Most of my shader work is done in compute so I'm not too familiar with the specifics of this API either

#

That said I think the URP solution might just work. Have you tried following it?

polar pasture
strange prairie
#

Are you using deferred rendering?

polar pasture
strange prairie
#

In forward rendering you handle lighting in the fragment shader directly. In deferred rendering, the fragment shader writes its information to the G-buffer and there's a fullscreen pass that handles all the lighting in one go

#

So in forward you'd have access to all the lighting information in the fragment shader but not in deferred

polar pasture
strange prairie
#

Yeah I see no reason it can't be done, it's just API specifics unfortunately

#

(and there isn't much of an API for shaders)

polar pasture
kind juniper
polar pasture
#

/ By Light Rendering Layer
// e.g. only reveal decals with lights that have a specific Layer set under it's Rendering Layers
// note that new lights default to using all layers / "Everything" so need to remember to change it

#pragma multi_compile _ _LIGHT_LAYERS

void RevealUsingLayer_float(float3 WorldPosition, float UltravioletLayerIndex, out float Out){
half4 Shadowmask = half4(1,1,1,1);
float totalAtten = 0;
#ifndef SHADERGRAPH_PREVIEW
uint pixelLightCount = GetAdditionalLightsCount();
uint ultravioletLayerMask = 1 << int(UltravioletLayerIndex);

InputData inputData = (InputData)0;
float4 screenPos = ComputeScreenPos(TransformWorldToHClip(WorldPosition));
inputData.normalizedScreenSpaceUV = screenPos.xy / screenPos.w;
inputData.positionWS = WorldPosition;

LIGHT_LOOP_BEGIN(pixelLightCount)
    Light light = GetAdditionalLight(lightIndex, WorldPosition, Shadowmask);
#ifdef _LIGHT_LAYERS
    if (IsMatchingLightLayer(light.layerMask, ultravioletLayerMask))
#endif
    {
        float intensity = length(light.color.rgb);
        float atten = intensity * light.distanceAttenuation * light.shadowAttenuation;
        totalAtten += atten;
    }
LIGHT_LOOP_END

#endif
Out = totalAtten;
}

echo moatBOT
kind juniper
#

Hlsl might be quite different though. I was thinking shader graph. Assuming you have access to lights data in shader graph๐Ÿค”

kind juniper
#

Ah, it's a custom function node, ok

polar pasture
kind juniper
#

So, does it not compile?

polar pasture
kind juniper
#

Did you try looking at the errors then?

strange prairie
strange prairie
polar pasture
#

sory for copy and paste

kind juniper
echo moatBOT
polar pasture
#

this is not a code

kind juniper
#

Doesn't matter. Logs and other big text chunks follow the same rule.

polar pasture
#

Ok

hardy nimbus
#

Huh never thought I would see the day we get new built in material inspector types for Shader code.

#

Also we got dynamic branching for keywords.

strange prairie
#

This is 6.1?

hardy nimbus
#

6.2 alpha 10.

strange prairie
#

Ah

hardy nimbus
#

Came out this morning.

strange prairie
#

Vector4 still missing though

hardy nimbus
#

Vector4 was already possible actually.
Edit: Technically you just declare uppercase Vector and it sets it as Vector 4 and use Float for Vector one>
In HLSL though it declares a float1/float4 to be exact for mapping.

#

By the looks of it they have been refactoring some of the SRp and behind stuff for the core render libraries to add new features easier.
Guess it might be part of the ongoing improvements to shared render code between the pipelines.

#

Yep, Vector 4 is possible for a while...for some reason just missing Vector2/Vector3

strange prairie
#

It's not really relevant here but in compute, only float4 inputs are used for some obscure reason

hardy nimbus
#

Granted Material blocks are what creates the inspector fields for materials we can edit in editor.
Before we couldn't create a Vector/Vector3 Editor field only float and Vector 4.

strange mortar
#

is this a good asset? they say it could boost performance but im not sure abt it

strange prairie
strange mortar
#

i see then i should not use it?

strange prairie
#

The problem with rendering assets is that itโ€™s very fragile so thereโ€™s a lot of bugs from different configurations. If no support is offered those bugs are never fixed

strange mortar
#

i see im just trying to find a good tree asset been tryying to find one that is free and its been traumatizing me for 2 hours xd

serene condor
strange prairie
strange mortar
#

ig ill look into it

candid tree
#

guys, i need help.

Im really noob in programming and I have an Stardard Surface Shader, in 2019.4 unity.

Someone knows, how to make the sprite cast and receive shadows and lock the billboard in vertical?

The shader is based in doom sprites, but i cant make him cast/receive shadows, and lock billboard.

(Here is a video with the shader in unity)

SHADER:

Shader "UnityCoder/DoomSprite3"
{

Properties 
{
    _MainTex ("Base (RGB)", 2D) = "white" {}
    _Frames ("Frames", Float) = 8
}

SubShader 
{
    Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "DisableBatching"="True"}
    
    ZWrite Off
    Blend SrcAlpha OneMinusSrcAlpha        
    
    Pass 
    {
        CGPROGRAM

        #pragma vertex vert
        #pragma fragment frag
        #define PI 3.1415926535897932384626433832795
        #define RAD2DEG 57.2957795131
        #define SINGLEFRAMEANGLE (360/_Frames)
        #define UVOFFSETX (1/_Frames)
        #include "UnityCG.cginc"

        uniform sampler2D _MainTex;
        uniform float4 _MainTex_ST;

        struct appdata {
            float4 vertex : POSITION;
            float4 texcoord : TEXCOORD0;
        };

        struct v2f {
            float4 pos : SV_POSITION;
            half2 uv : TEXCOORD0;
        };

        // float4x4 _CameraToWorld;
        float _Frames;

        float atan2Approximation(float y, float x) // http://http.developer.nvidia.com/Cg/atan2.html
        {
            float t0, t1, t2, t3, t4;
            t3 = abs(x);
            t1 = abs(y);
            t0 = max(t3, t1);
            t1 = min(t3, t1);
            t3 = float(1) / t0;
            t3 = t1 * t3;
            t4 = t3 * t3;
            t0 =         - 0.013480470;
            t0 = t0 * t4 + 0.057477314;
            t0 = t0 * t4 - 0.121239071;
            t0 = t0 * t4 + 0.195635925;
            t0 = t0 * t4 - 0.332994597;
            t0 = t0 * t4 + 0.999995630;
            t3 = t0 * t3;
            t3 = (abs(y) > abs(x)) ? 1.570796327 - t3 : t3;
            t3 = (x < 0) ?  PI - t3 : t3;
            t3 = (y < 0) ? -t3 : t3;
            return t3;
        }

        v2f vert (appdata v) 
        {
            v2f o;
            o.pos = UnityObjectToClipPos (v.vertex);

            // object world position
               float3 objWorldPos=float3(unity_ObjectToWorld._m03,unity_ObjectToWorld._m13,unity_ObjectToWorld._m23);

            // get angle between object and camera
            float3 fromCameraToObject = normalize(objWorldPos - _WorldSpaceCameraPos.xyz);
            float angle = atan2Approximation(fromCameraToObject.z, fromCameraToObject.x)*RAD2DEG+180;

            // get current tilesheet frame and feed it to UV
            int index = angle/SINGLEFRAMEANGLE;
            o.uv = float2(v.texcoord.x*UVOFFSETX+UVOFFSETX*index,v.texcoord.y);
                      
           // billboard mesh towards camera
              float3 vpos=mul((float3x3)unity_ObjectToWorld, v.vertex.xyz);
             float4 worldCoord=float4(unity_ObjectToWorld._m03,unity_ObjectToWorld._m13,unity_ObjectToWorld._m23,1);
            float4 viewPos=mul(UNITY_MATRIX_V,worldCoord)+float4(vpos,0);
            float4 outPos=mul(UNITY_MATRIX_P,viewPos);
            
            o.pos = UnityPixelSnap(outPos); // uses pixelsnap
            
            return o;
        }

        fixed4 frag(v2f i) : SV_Target 
        {
            return tex2D(_MainTex,i.uv);
        }
        ENDCG
    }
}

}

echo moatBOT
strange prairie
#

Please. Makes it legible

#

Anyway it should be opaque / cutout. Transparent materials donโ€™t cast shadows

candid tree
candid tree
candid tree
ebon basin
#

"Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "DisableBatching"="True"}"

candid tree
#

where i put this?

#

srry, im new on unity

ebon basin
#
        Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "DisableBatching"="True"}

        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha

Check the docs what all this stuff is

#

If you want to alpha cut instead of transparency then it needs to be opaque, ZWrite, and without blending

#

oh, and in the fragment you need to compare alpha values and use the discard keyword when it's below (or above?) the threshold that you're clipping

candid tree
#

but how i do this?b_pensive

#

if i change Tags {"Queue"="Standard/cutout"

#

it will work?

#

or opaque/cutout

ebon basin
#
Tags {"Queue"="Geometry" "RenderType"="Opaque" "DisableBatching"="True"}
ZWrite On

I forget if the Queue requires AlphaTest so try both

candid tree
#

is correct?

ebon basin
#
fixed4 frag(v2f i) : SV_Target 
{
    float alpha =  tex2D(_MainTex,i.uv).a
    if (alpha < _Cutoff) discard;
    return tex2D(_MainTex,i.uv);
}```
#

and that's for the discard operation so you need a _Cuttoff property

candid tree
#

occured this

ebon basin
#

your tex2D returns the color values

#

And it does use AlphaTest

candid tree
#

the sprite continues not casting/receiving shadows

#

`Shader "UnityCoder/DoomSprite3_Cutout"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_Frames ("Frames", Float) = 8
_Cutoff ("Alpha Cutoff", Range(0,1)) = 0.5
}

SubShader 
{
    Tags { "Queue"="AlphaTest" "RenderType"="TransparentCutout" "IgnoreProjector"="True" "DisableBatching"="True" }
    ZWrite On
    Blend Off
    AlphaTest Greater [_Cutoff] // para compatibilidade extra com alguns pipelines

    Pass 
    {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"

        #define PI 3.1415926535897932384626433832795
        #define RAD2DEG 57.2957795131

        sampler2D _MainTex;
        float4 _MainTex_ST;
        float _Frames;
        float _Cutoff;

        #define SINGLEFRAMEANGLE (360/_Frames)
        #define UVOFFSETX (1/_Frames)

        struct appdata {
            float4 vertex : POSITION;
            float4 texcoord : TEXCOORD0;
        };

        struct v2f {
            float4 pos : SV_POSITION;
            half2 uv : TEXCOORD0;
        };

        float atan2Approximation(float y, float x)
        {
            float t0, t1, t2, t3, t4;
            t3 = abs(x);
            t1 = abs(y);
            t0 = max(t3, t1);
            t1 = min(t3, t1);
            t3 = 1.0 / t0;
            t3 = t1 * t3;
            t4 = t3 * t3;
            t0 =         - 0.013480470;
            t0 = t0 * t4 + 0.057477314;
            t0 = t0 * t4 - 0.121239071;
            t0 = t0 * t4 + 0.195635925;
            t0 = t0 * t4 - 0.332994597;
            t0 = t0 * t4 + 0.999995630;
            t3 = t0 * t3;
            t3 = (abs(y) > abs(x)) ? 1.570796327 - t3 : t3;
            t3 = (x < 0) ?  PI - t3 : t3;
            t3 = (y < 0) ? -t3 : t3;
            return t3;
        }

        v2f vert (appdata v) 
        {
            v2f o;
            float3 objWorldPos = float3(unity_ObjectToWorld._m03, unity_ObjectToWorld._m13, unity_ObjectToWorld._m23);
            float3 fromCameraToObject = normalize(objWorldPos - _WorldSpaceCameraPos.xyz);
            float angle = atan2Approximation(fromCameraToObject.z, fromCameraToObject.x) * RAD2DEG + 180;

            int index = angle / SINGLEFRAMEANGLE;
            o.uv = float2(v.texcoord.x * UVOFFSETX + UVOFFSETX * index, v.texcoord.y);

            float3 vpos = mul((float3x3)unity_ObjectToWorld, v.vertex.xyz);
            float4 worldCoord = float4(unity_ObjectToWorld._m03, unity_ObjectToWorld._m13, unity_ObjectToWorld._m23, 1);
            float4 viewPos = mul(UNITY_MATRIX_V, worldCoord) + float4(vpos, 0);
            float4 outPos = mul(UNITY_MATRIX_P, viewPos);
            o.pos = UnityPixelSnap(outPos);

            return o;
        }

        fixed4 frag(v2f i) : SV_Target 
        {
            fixed4 col = tex2D(_MainTex, i.uv);
            clip(col.a - _Cutoff); // recorte baseado em alpha
            return col;
        }
        ENDCG
    }
}

}`

#

the shader is like this

candid tree
#

i reaaly dont know how to put the sprite casting and receiving shadows

last eagle
#

Hello, has anyone had issues with URP / Lit shader? im trying to use it again to get a double sided road just shows white..

last eagle
#

here is an example

torpid vault
#

Hoi ho guys
Anybody here familiar with writing HLSL shaders?
I am reeeally stuck trying to convert some Shader Graph prototyping into HLSL

#

I'm just trying to output this, currently. The object position as a color. its driving me nuts.

karmic hatch
strange prairie
torpid vault
#

Thanks guys. I did get it figured out earlier.
I know colors are vectors, sorry I didnt get more specific. I meant I did not know how to access the object position data within the shader code to start manipulating it.

karmic hatch
keen relic
#

was thinking its lighting but when my scene was still day it didnt help anyway you can only see the blue of the water when u were right next to the railing and even then it was super faded

wise kraken
#

Hi guys, can anyone help me? I was playing around trying to swap my color in engine and I have the following issue:

When I wanna swap the blue with another color nothing happens, but when I pick white or black it swaps the color for the teeths and the background. Does anyone have an idea why it is not working?

wise kraken
slim venture
#

anyone know why light is leaking into the room?(there are no gaps)

slim venture
#

apparently i somehow fixed it?

gloomy fractal
#

someon know how to change the height of my grass randomly, shadergraph urp

#

rn all grass looks same, in wanted to add variation

violet shard
#

Hello! I'm having a strange issue, im following this tutorial making a simple shader and I get to the part where I use an add node to add 2 effects together, however one of the effects isnt applying?

#

the add node at the end is supposed to have a dark ring around the light green circle but its not applying?

kind juniper
#

Are you sure they're using and addition node?

violet shard
#

yeah, though I think their fresnel color is brighter in theirs

#

let me try tweaking the colors

#

pfft, yeah that was it

#

thank you so much! I was trying to figure this out for a silly amount of time

kind juniper
#

When blending between effects you'd usually multiply, average or lerp between them.

#

Addition would only work for specific outcomes and inputs.

violet shard
#

I did try multiply and blend, neither of those worked I think

#

though maybe tweaking the colors might fix it

#

I didnt try lerp, so ill try that one too!

kind juniper
#

I mean it depends on the specific use case. In your case the top node seems to have the same color across all pixels, so it would just act as the fresnel color below if you multiply it.

cobalt idol
#

hi! I displace a mesh but the shadows are still cast from the undisplaced mesh.. how do I fix this?

grizzled bolt
cobalt idol
last eagle
wise jasper
#

Hi guys, im trying to achive the "4 star filter" effect, has anyone tried doing that? or maybe someone saw asset doing that effect?

#

or is it just fancy lens flare?

wise jasper
#

uhh, the standard one, not the urp, not the hdrp, i forgot the name

grizzled bolt
last eagle
grizzled bolt
last eagle
# grizzled bolt Yes

thank you, is there an easy way of removing packages? i feel like they should of had a button to remove packages from project

#

within package manager

grizzled bolt
# last eagle within package manager

There should be an "uninstall" button for each pacakge
Anything you've imported as .unitypackage on the other hand can't be automatically uninstalled though

last eagle
#

thank you Spazi

wise jasper
#

@grizzled bolt Thanks bro

last eagle
#

spazi the masked hero

last eagle
#

i seem to be having occuring issues with the urp/lit shader for my spline roads, although its the only shader that has road elements.. any way to fix or that?

#

Id prefer to use the Lit shader as it is ready to go but when i build the roads just turn white

zenith aspen
#

Dose anyone know of a performant way to "add" shaders during runtime. just as a basic example i have a plane with a lightning bolt shader on it but i need it to shade differently in some areas (for example a black and white shader). Would it be possible to have an area bounded by an object "add" a shader to the parts of the other object (lighting bolt) in the bounded area. With the lighting bolt for example the parts of the bolt that pass through the shaded area would be back and white but the parts that are not in the bounded area would be the normal color. I was thinking of doing something like taking the output for the original shader and modifying in the shader that's adding but I dont know how to make that work on a localized area of the object. I would also like this system to work with shaders other than something that just makes everything black and white. for example using a shader that makes everything partially transparent. It would also be nice to have it work with multiple bounded object with diffrent shaders. For example on object is set to "add" a black and white shader while another is set to "add" a partly transparent shader and where the bounded objects overlap it dose both.

mortal sable
#

why can i see through the front faces? 2nd image is blender

#

im not sure if its a shading issue but cant find an appropriate channel to post

zenith aspen
mortal sable
#

no idea how this happened

#

thanks

rancid rune
#

So i have an outline shader that works by itself w/ a material, but whenever its applied to another shader as a material using a render objects it just makes the screen black, am i doing smth wrong lol?

kind juniper
rancid rune
kind juniper
rancid rune
kind juniper
#

Share your render feature setup.

rancid rune
kind juniper
#

In fact your enemy and friendly effects also seems to use full screen effects, so it's not gonna work with render objects.

rancid rune
kind juniper
#

Probably because enemy pass is set to be after post processing

#

And the outline is set to be after rendering.

rancid rune
kind juniper
#

Hard to say. I don't entirely understand what setup you have. What kind of materials are these.

#

Another thing is that the blit texture is just 16x16

#

So it's definitely not the render target that is rendered to previously.

rancid rune
kind juniper
#

If you are using it correctly, then the issue is likely with your VHS effect.

#

See if the outline works correctly without it.

kind juniper
# rancid rune

The _BlitTexture here is supposed to contain the color of whatever the draw call above it is rendering to.

rancid rune
#

time to use overlay camera fun

rancid rune
#

hoorah

golden copper
#

I'm a little stuck with something, I'm trying to use triplanar to add a grunge texture to my objects but I want it to ignore anything that's black on a set texture. I'm still new to shaders so any suggestions or pointing in the right direction would be amazing.

steel notch
#

Hey so I'm a little confused at this. I have a test graph here. My goal is to define some region as being holographic (red). For some reason this specific setup seems to produce a thin line between the holographic zone and the border. Any tips?

ebon basin
ebon basin
#

I can imagine it's something with the lerp as those other operations are pretty absolute

steel notch
ebon basin
#

Probably some boolean operation you can try

#

rather bitwise*
too much blender for me

humble geyser
#

I'm using HDRP shader graph, and I want to change the tessellation factor based on x and z position only, but when I tried editing the start fade distance and end fade distance to 0.01, 0.02 the line where it starts getting not tessellated and fades is no different from 6000 and 7000 fade distance, how do I make it not automatically calculate tessellation, and what is the start fade distance and end fade distance even used for?

hollow pond
#

Hello! Im using vegetation spawner to spawn grass and the grass is white, im using a 2d texture and HDRP. Can anybody help?

grizzled bolt
hollow pond
#

oh okay

#

do i delete this?

grizzled bolt
#

Best to delete the less relevant one, but at this point we don't know whether your main goal is to make shaders or just to get the tool working

hollow pond
#

It is more about shaders

grizzled bolt
hollow pond
#

i used a different tool and i got the same results

grizzled bolt
lucid dirge
#

why are these white and gray spots apear?

grizzled bolt
lucid dirge
#

How can I remove em

grizzled bolt
lucid dirge
steel notch
#

Let's say I have a material in Unity that controls the appearance of a card. Half of the material properties control elements of the cards position and some masks. The other half of the properties control a holographic effect. There are many different types of cards (so different positions and masks) and many different holo effects. How should I represent all of this in data?

last eagle
#

hello! I was having issues with Lit shader, found a reconstructed Lit Shader and i am trying to make my road non seethrough like i should not be able to see the road below when im on the road above. any fix is appreciated.

pure magnet
#

Hi guys total noob here, I am trying to make an outline shader material (URP) so I can assign it to meshes the player interacts with:
I followed this tutorial, its okayish but is pretty bad around straight edges as you can see from the pic

Could anyone give any insight on how to make it better

steel notch
#

Wait a second. If I am in URP, is it better to use MaterialPropertyBlocks, or just create new material instances?

grizzled bolt
#

Or enable material override so you can change that setting per material

grizzled bolt
eager folio
#

So how do you disable preserve specular in shadergraph?

steel notch
#

And then make sure to Destroy the created material on Object destruction?

grizzled bolt
eager folio
#

...not sure how I missed that. what I get for shader0ing at 4 am ๐Ÿ˜„

grizzled bolt
steel notch
#

Oh well

grizzled bolt
steel notch
grizzled bolt
#

As far as I know it's exactly the same material list you see in the inspector

steel notch
#

Alright so calling it just once does the same thing as material but for all of them.

grizzled bolt
#

Yes
You can copy the array without setting it, or assign your own materials to it without copying it first

#

Not that many situations where you'd want to modify the sharedMaterials so I understand why they replaced with the shorthand for creating instances

#

Or if you do need to modify the assets themselves for all users, it seems very unintuitive to me that you'd do it from an individual mesh renderer

last eagle
grizzled bolt
last eagle
#

Double checking now I believe so I always build to test after but does it not save before building

grizzled bolt
last eagle
#

Appreciate you spazi trying it shortly

last eagle
#

to be honest i just opened the scene up and its now showing okay

#

so it most likely was saving issue, they should make it so it auto ask that save or what not or maybe it just needed that? idk.

#

shows great now!

#

appreciate your help @grizzled bolt thank you again

sharp nymph
#

I feel ilke this is probably a shader question... when doing a ton, like literally 1000 lights at once in a UGC game like a city builder, what is the best way to shade emissive decals so they don't wipe out all the texture detail underneath

#

At least that's what it looks like games like cities skylines1 and Planet coaster 1 are doing

kind juniper
sharp nymph
#

do you think its just deferred rendering then?

kind juniper
# sharp nymph do you think its just deferred rendering then?

First, you'll need to rephrase your question/message such that it makes sense. Did you even try reading it after sending? Among other things, I've no clue what you mean by "wipe out all the texture detail underneath".

Assuming I understand you correctly, you're asking how the "lights" in the screenshots are rendered.
If so, I'd assume that it is either deferred rendering + some unlit materials, or baked lights.

sharp nymph
#

the screenshots are from the game directly as an example, wipe out/wash out texture detail is a relatively generic normal term. Basically im asking is there a blending mode like multiply that preserves more of the texture detail when the decal is applied over top as apposed to normal blending.

At distance, the game apperas to be using some kind of emissive decals but I was able to dig up an article since my original post that says they did also use deferred rendering. I can't share screenshots of what I'm working on.

#

it doesn't take a tremendous leap of logic to understand my question if you have ever worked with decals as a light source though so I don't understand how you are confused.

kind juniper
#

I don't think that the game is using "emissive decals". light via emisssion is a lot more expensive than some lights in deferred rendering.

kind juniper
#

Ok, I guess The first message kinda sounds like a question, although with terrible punctuation. But then the message with the screenshots implies something that is not explained anywhere.

#

Kinda like you forgot a sentence in between.

sharp nymph
#

ah so that's why there are 2 commas identifying the interrupter context, though granted the subject is inferred in the context which is a syle error. Not a grammar error.

#

but this is discord, not english class.

kind juniper
#

Anyways, it's really confusing and feels like there's lack of context.

kind juniper
karmic hatch
serene condor
#

can i actually utilize height maps from substance painter in unity? (Built in pipeline)

hardy juniper
#

nothing stopping you from doing some manual displacement in a shader using the height map

serene condor
#

yeah... how? lol

#

i mean, in shader graph its possible using some vertex position plugin?

hardy juniper
#

sample height map tex, use to move vert along its normal or some other dir, win

#

plugin?

serene condor
#

so sample height map -> mult with a float for scale/strength

#

the rest i dont quite follow

hardy juniper
#

a height map is 1d so to "displace" the vertex you need to know what direction to move it so you can use the vertex normal multiplied with the height value

serene condor
#

hm ok

#

normal from height (node)

#

oh, normal vector

serene condor
#

object space probably

hardy juniper
#

yes leave as the default

serene condor
#

default was world space

#

huh... thats weird.

#

it appears to be a vector3 output

#

wont allow it in

hardy juniper
#

I dont follow

serene condor
#

the input to the vertex position node is yellow (vector3?), and my output appears to be yellow (Vector3)?

#

it wont plug into it

#

oh hol up

#

no...

#

it dont like the sample texture node

serene condor
fluid crystal
#

what does this mean

#

im trying to make a ps1 style graphics

serene condor
#

means you have no camera

fluid crystal
#

too lazy to rewrite sorry i jus realised that i send the actual pic in the wrong chat\

fluid crystal
grizzled bolt
#

!collab

echo moatBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
โ€ข Collaboration & Jobs

visual lodge
#

my bad

serene condor
#

Soโ€ฆ because my models are super zoomed out, I need to make the normal map pretty huge to see things like panel lines in the texture from the distance the camera is at

For some scenes Iโ€™d want a closer view of the ship though, and it looks silly at close range. canโ€™t I do some LOD and switch normal maps based on camera distance?

tacit parcel
kind swallow
#

In the 2d light system, since all lighting is just rendered to a texture that is sampled, how does unity do the normalmap calculations? Is it possible to get out any light directionality in my own shader graph for custom calculations?

humble geyser
lapis roost
#

Hey everyone, Iโ€™m running into an issue with an asset pack I recently purchased.
I imported everything correctly from the POLYGON Nature โ€“ Low Poly 3D Art pack by Synty, but when I place trees in my scene (specifically the non-LOD versions), the trunks show up bright red and the leaves and grass look strangeโ€”nothing like the examples shown in the pack.

I also tried using the LOD versions of the trees, but those show up completely gray, like the textures arenโ€™t applying at all. I suspect both issues might be shader-related, but Iโ€™m not sure how to fix them.

I'm still very new to Unity and game development, so Iโ€™m struggling to understand whatโ€™s going wrong or how to resolve it.

If anyone is willing to hop into a voice call and help explain this stuff a bit, Iโ€™d really appreciate it. Iโ€™ve tried watching videos, but they havenโ€™t helped me grasp whatโ€™s going wrong or how to fix it.

strange prairie
lapis roost
#

Universal 3d Project

strange prairie
lapis roost
#

Yeah I noticed that if I am correct, But how would I add the URP then

strange prairie
#

Double click the package

lapis roost
#

I cant find the URP

eternal kestrel
#

I need some help fixing a visual bug in my shader, the shader is supposed to distort objects behind it but for some reason, some objects get reflected in it

#

I assume this is due to the fact that scene color is getting specifically what's rendered in my main camera

#

this being the relevant part of the shader for that

#

for the sake of context this is the full shader

#

the texture that gets sampled is what makes the waves below the player but that part is relatively irrelevant, how do I get the shader to stop reflecting objects on top of it?

kind juniper
#

If it's non opaque object, this might be difficult. In this case you'll need some kind of depth or stencil test.

eternal kestrel
#

I was hoping not to add another renderer feature on top of that growing list but it seems I may have to

#

that said, would it even be worth fixing?

#

I feel like with flatter objects it'd be much easier to get away with

kind juniper
kind juniper
eternal kestrel
#

I feel like that'd make the problem a lot less noticeable

kind juniper
#

Try it and see for yourself

eternal kestrel
#

I'll just leave it, I don't think it's enough of an eye sore to add yet another renderer feature

#

got enough of those frankly

steel notch
#

I have a script here whose job is to set the properties of a material. Aka a lot of the methods look like this.


    public void SetStone(Texture2D tex)
    {
        cardPlateMat.SetTexture("_StoneTex", tex);
    }

    public void SetCenterPoint(Vector2 center)
    {
        cardPlateMat.SetVector("_CenterPoint", center);
    }

    public void SetNameplateCutoff(Vector2 cutoff)
    {
        cardPlateMat.SetVector("_NameplateCutoff", cutoff);
    }

Should I expose the string values as fields to be able to tweak them in the editor?

steel notch
kind juniper
# steel notch ...that's fair I guess

If you only have a limited set of properties, you could define them in a scriptable object or a singleton/static class to avoid typing the same string everywhere and potentially making a human mistake.

strange basalt
vague delta
eternal kestrel
#

I've seen people create shaders that physically raise the mesh from the ground, considering I'm working with a quad so not many vertices to raise, how would I go about doing that?

#

one idea that just came to me was to create a plane with the same amount of vertices as pixels in my shader and use tiling to fix the uv scale being wrong

#

but considering my resolution for this is 1024x1024, I would like to find a better solution

eternal kestrel
bitter lintel
#

What's the equivalent to Mathf.Repeat in shadergraph?

eternal kestrel
#

kinda?

#

maybe? I'm not entirely sure

#

what do you need it for?

bitter lintel
#

Looping a value between 0 and 24

#

or 0-1

#

Depends on how i implement the code later

eternal kestrel
#

sample gradient, and hook it to a remap node maybe

#

then hook time up to whichever direction that gradient should go in

#

lemme see if I can find something better

#

I found something better

#

and depending on which part of that split node you hook it up to, the stripes go in different directions

#

unless I'm misunderstanding what you want that is

eternal kestrel
#

specifically on the ground

eternal kestrel
#

this one I'm not so sure of, I'm not entirely solid on how the normalize node works here

#

still all depends on what you're trying to achieve with that value

bitter lintel
#

i might be overthinking it honestly

#

Wanted to make a skybox

#

and change the color from the time of day

eternal kestrel
#

wouldn't you want to control that transition in a script?

bitter lintel
#

Yeah probably

#

Sending data to a shader isn't that expensive right?

eternal kestrel
#

not particularly

bitter lintel
#

Okay then i guess syncing time every second or maybe even less frequently should be fine

eternal kestrel
#

you could probably do it with a time of day float and let the shader handle itself based on that

eternal kestrel
bitter lintel
#

Wait why did i even want to loop the float

#

I can do that in C#

#

Well that makes everything easier

eternal kestrel
#

yeah you just send a float with the current time of day to the shader and let it do it's thing based on that

#

then update your time of day in script

bitter lintel
#

Man i always overcomplicate stuff

#

I should probably go eat

#

Thanks

eternal kestrel
#

I shoulda asked what you were tryina achieve straight off the bat my bad

#

kinda xy'd myself by mistake

turbid pivot
#

I've never really used shaders in the context of unity

#

how do I change vertex position in a shader that isn't a shader graph

stoic juniper
#

anyone got any suggestions on how to blend the lighting info and textures for my custom lighting shader better?

#

the lighting always comes out very gross, ive tried a few things and ive definitely narrowed it down to where I combine the light colour and base textures where I multiply them, but I cant figure out a different method to get better results

stoic juniper
#

at low intensity its fine but at high intensity it shifts green significantly

stoic juniper
#

i sorted it ๐Ÿ’ช thank you for rubber duckying

simple sail
#

hello, I am learning compute shaders rn, following a tutorial, and am confused on a few small things. Would appreciate if someone could point out where im getting something wrong here or clear up the questions i ask in the comments!

steel notch
#

How do you control a ShaderGraph enum field from C#?

kind juniper
echo moatBOT
kind juniper
#

In your shader you're using the IDs to write data to a texture, so you use the thread Id to specify what pixel of the texture to write to.

stray gorge
#

do u guys know why i get pink in the power node ?

#

when B of power is too high

kind juniper
kind juniper
#

If t of lerp is negative it can go negative I think

#

Try saturating the t before lerp

#

Or saturating the lerp output

#

The t parameter of lerp needs to be in 0-1 range for it to produce values in the a-b range

#

At which point your lerp is meaningless though

stray gorge
kind juniper
#

Honestly, I'm not sure what you're trying to do with it.

stray gorge
kind juniper
stray gorge
kind juniper
stray gorge
# kind juniper Why not?

the gradient doesn't expose on material properties when i add it, and i dont see the curve node, where can i find it ?

kind juniper
#

What node are you using?

kind juniper
stray gorge
kind juniper
stray gorge
kind juniper
#

Something like 32x1 texture. Then just sample the color like with lerp.

stray gorge
simple sail
# kind juniper In your shader you're using the IDs to write data to a texture, so you use the t...

is there a way for me to pass in info to the compute shader or update a struct array for the IDs to use? for example, if i had a 2d array of structs, each representing a pixel with its various data (ie color and ingame info) that would have its contents updated/changed, is there a way for me to update a matching array in the compute shader script/ or pass in an induvial struct instance for each ID of the texture?

kind juniper
#

Check the documentation on compute shaders and compute buffers.

simple sail
#

alright, ty

astral pecan
#

Is there a way to map square into circles?

strange prairie
grizzled bolt
unique kestrel
#

Ts channel is my brother

simple sail
#

If im using a compute/fragment shader to simulate the behavior of falling sand, would i not be able to use the traditional algorithm that relies on looping through the 2d array in reverse due to the fact that fundamentally all pixels would be updated in the same time and so could not iterated through like that? Am i misunderstanding how they work

astral pecan
#

Sadly not

grizzled bolt
astral pecan
#

I'm trying to map it to circle like this

low lichen
#

A GPU core is just a slower, less capable compute unit compared to a modern CPU core. The difference is while you may have 8-16 CPU cores in a modern desktop CPU, a modern GPU can have thousands. That's what make GPUs faster at certain tasks.

simple sail
#

Or would that still not be an effective use

grizzled bolt
low lichen
simple sail
#

If you iterate in (actually bottom left to top right, not reverse), you can use the last pixels updated info as to not attempt to occupy the same space

low lichen
grizzled bolt
#

Have you looked at examples of compute shader pixel sand simulations? I expect the techniques are different from doing it on the CPU

simple sail
astral pecan
#

Its color picker, but mapped into a circle

grizzled bolt
simple sail
#

Alright, ill do some more research ๐Ÿ‘

astral pecan
#

This one is easy, but mapping it into a circle is hard

grizzled bolt
grizzled bolt
#

Polar coordinates on the other hand do map textures to a circle, like the outer ring there

astral pecan
astral pecan
stray gorge
#

will material recalculated each update when i dont change it's properties at runtime ?

grizzled bolt
golden gust
#

disregard the message below. fixed using a canvas shader graph. sadge

can someone end my suffering please for the love of god
i have a simple problem that i just cant figure out

i have a 2 camera system in my game:
the WorldCamera outputs to a render texture called WorldView
the MainCamera looks at a canvas which is rendered behind all UI elements called WorldCameraView.

WorldCameraView has a Raw Image component that takes in the WorldView render texture, and a material generated by a shader graph called WorldViewShader. WorldViewShader has an input property called MainTex which references _MainTex. when removing the material on the Raw Image component by setting it to none, i can see the world camera view just fine. adding the material generated by the shader suddenly causes my whole screen to look like this:

steel notch
#

I have some sprites that I want to be reactive to 3D light.

#

I put together a simple transparent Lit Graph (not Sprite Lit) to do so, and am trying to get the SpriteRenderer controls to work with this shader.

#

How do I feed in the color? I keep reading that this is pushed in through Vertex Color, but I am not seeing anything happen.

kind juniper
astral pecan
astral pecan
#

This would've been perfect but its far beyond my level to implement.

heavy plover
#

Am I absolutely dumb or this should be making it transparent??? (3rd image is not transparent, it's just what happens having it on additive mode)

kind juniper
heavy plover
#

Cause it's on additive, not cause it's transparent

kind juniper
#

Additive is a mode of transparency

#

Besides, if it doesn't work in other modes, then you should be showing that instead.๐Ÿ˜…

heavy plover
#

It just works on additive, but not changing the texture alpha, the material alpha or the material color alpha does anything

#

But I cannot really control the transparency with that, I would need to modify the color tone, rather than the oppacity

kind juniper
heavy plover
#

I kinda figured it out. For some reason alpha channel does absolutely nothing when applying ig to a sprite while being a normal lit material

#

So I have to change to sprite, but shouldn't that work anyways? I mean, it's pretty much a texture

kind juniper
hardy juniper
#

I think sprites need pre multiplied alpha on the colour output ๐Ÿค”

grand jolt
#

If I wanr to apply a pixel shader to the game, but I dont want all the objects to have it. Only objects on the interactable layer