#archived-shaders

1 messages ยท Page 29 of 1

regal stag
#

It was renamed to "Lit Graph"

grand jolt
#

damn

#

Im new to shaders so I just followed a guide and the guide used PBR graph and I did it in Lit Shader graph

regal stag
#

I would assume this is just due to the resolution of the texture. You could add a Tiling And Offset node to the UV port on your Moss texture sample to adjust the tiling/scale.

grand jolt
#

You think this is better?

wanton grove
#

So, this system essentially outputs the vertex positions using the UV node instead?

wanton grove
# regal stag Yeah

Ok, so when I'm making a shader that works with the system I just use the UV node instead of the position node? But normals and other data can still be used with the same nodes?

#

Pardon my lack of understanding lol

regal stag
# wanton grove Ok, so when I'm making a shader that works with the system I just use the UV nod...

No, Kinda. There's a Bake Shader Vertex Pos subgraph provided in the github repo that you'd attach to the Position port in the master stack (vertex stage).

But since we change that position, if the graph uses the Position node in the fragment stage it's now different. If you need the original position, you'd need to pass it through a Custom Interpolator. (See link above if you don't know what that is)

wanton grove
grand jolt
#

Does anyone know why my normal map is pink?

wanton grove
regal stag
wanton grove
wanton grove
grand jolt
#

cause its still pink

wanton grove
regal stag
# grand jolt

You'd also want Type : Normal on the node when sampling normal maps.

grand jolt
#

looks weird no?

wanton grove
regal stag
#

Pretty sure it's meant to look like that

grand jolt
#

not really

#

in the tutorial its like this, but its from 2019...

#

so might be outdated

regal stag
#

Well, the tutorial isn't sampling with Normal type, so it's wrong. Maybe they change it later.

wanton grove
#

@regal stag The shader bakes fine like this:

#

But not like this: (E: nevermind, I just wasn't baking using the renderer dropdown.)

wanton grove
lean lotus
#

Is there a way to force compile for at least d3d11.1 instead of d3d11?
I wanna get rid of these warnings

wanton grove
#

Using shader graph, how do I get the 2d position of the vertex position on a plane? A plane defined by origin and normal?

warped warren
#

How would I make a sprite/material that you can see through walls?
Like ESP in games or similar.

stark prairie
#

anyone

toxic flume
#

Is the world generator based on marching voxels?
Terra Nil

shadow tendon
#

hi how can i make a optimized stadium grass?

grizzled bolt
toxic flume
#

My voxel game is like minecraft. I have optimized it, combine faces if some conditions are satisfied

#

In the above, there is no optimization? only 3d voxel tile map and then combine them to get a chunk?

toxic flume
#

For example, if my land is flat, it has really less faces

#

Pure cubes. :/
If I want bending in edges

grizzled bolt
#

It looks like the example here doesn't have any volumetric information, so voxels or marching cubes would not be necessary
The terrain seems to have a ground type with height variants for each tile, and an object placed on top
A 3D tileset system matches terrain meshes so the tiles appear seamless
This is not related to shaders though

toxic flume
#

Each tile has 6 faces, 12 triangels

#

Only place them and then combine to one chunk or mesh?

cosmic prairie
toxic flume
#

OK, thanks

opaque cipher
#

anyone have any idea on how to change a custom cg shader to urp shader ?

#

Shader "Custom/Terrain" {
Properties{
testTexture("Texture", 2D) = "white"{}
testScale("Scale", Float) = 1

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

        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows

        // Use shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0

        const static int maxLayerCount = 8;
        const static float epsilon = 1E-4;

        int layerCount;
        float3 baseColours[maxLayerCount];
        float baseStartHeights[maxLayerCount];
        float baseBlends[maxLayerCount];
        float baseColourStrength[maxLayerCount];
        float baseTextureScales[maxLayerCount];

        float minHeight;
        float maxHeight;

        sampler2D testTexture;
        float testScale;

        UNITY_DECLARE_TEX2DARRAY(baseTextures);

        struct Input {
            float3 worldPos;
            float3 worldNormal;
        };

        float inverseLerp(float a, float b, float value) {
            return saturate((value - a) / (b - a));
        }

        float3 triplanar(float3 worldPos, float scale, float3 blendAxes, int textureIndex) {
            float3 scaledWorldPos = worldPos / scale;
            float3 xProjection = UNITY_SAMPLE_TEX2DARRAY(baseTextures, float3(scaledWorldPos.y, scaledWorldPos.z, textureIndex)) * blendAxes.x;
            float3 yProjection = UNITY_SAMPLE_TEX2DARRAY(baseTextures, float3(scaledWorldPos.x, scaledWorldPos.z, textureIndex)) * blendAxes.y;
            float3 zProjection = UNITY_SAMPLE_TEX2DARRAY(baseTextures, float3(scaledWorldPos.x, scaledWorldPos.y, textureIndex)) * blendAxes.z;
            return xProjection + yProjection + zProjection;
        }
#

void surf(Input IN, inout SurfaceOutputStandard o) {
float heightPercent = inverseLerp(minHeight,maxHeight, IN.worldPos.y);
float3 blendAxes = abs(IN.worldNormal);
blendAxes /= blendAxes.x + blendAxes.y + blendAxes.z;

            for (int i = 0; i < layerCount; i++) {
                float drawStrength = inverseLerp(-baseBlends[i] / 2 - epsilon, baseBlends[i] / 2, heightPercent - baseStartHeights[i]);

                float3 baseColour = baseColours[i] * baseColourStrength[i];
                float3 textureColour = triplanar(IN.worldPos, baseTextureScales[i], blendAxes, i) * (1 - baseColourStrength[i]);

                o.Albedo = o.Albedo * (1 - drawStrength) + (baseColour + textureColour) * drawStrength;
            }
        }


        ENDCG
    }
        FallBack "Diffuse"

}

#

here is my code

swift loom
#

Are structs with arrays not allowed in HLSL? It should be within the size limit but it still wont let me.

jade yoke
#

Hi everyone. I'm having an issue with my bg, some how the entire background of my game turn into this purple color, what was the cause of this?

low lichen
#

The Unity.Collections package also has special list types that are a fixed size

oak aspen
#

been banging my head at this problem for 2 days now and turns out, i have no clue what i'm doing lol. I'm trying to create a 3d noise based on a gradient that would wrap around (or triplanar) an object...as for the gradient, the whiter it gets, the less noise there is. Any ideas?

swift loom
#

@low lichen hmm alright. i guess if the buffer supports really high count values i could just store them as a 1D array and treat every 512 entries as the next array

oak aspen
#

this is what i have :/ essentially i would like to be the more shadow, the more noise there is i guess. If anyone can help maybe point me in the right direction. Thank you ๐Ÿ™‚

icy oriole
#

B E A N

low lichen
oak aspen
#

hmm even removing the NdotL portion still give me the same result

kindred vale
#

i get these 2 errors when trying to install the unity toon shader trough the package manager. any ideas on how to fix them?

prime shale
#

Based on what you said your looking for...

Lerp(noiseTerm, white, nDotL)

oak aspen
#

But I'll try it out ๐Ÿ™‚

prime shale
#

Lerp(a, b, t)

So basically lerp is a linear interpolation, it basically means that as T gets closer to either 0 or 1 it will fade to a or B

#

You use the NdotL shading gradient you currently have as your T term

#

So things that are in shadow are noisy

oak aspen
#

Lerp i get.. n dot l..no clue

#

Shouldn't have skipped math class (if this is even math) haha

prime shale
#

N dot L is your lighting gradient you curently have, its the dot product of your normal direction and your light direction. Its the light shading you have already on your cyllinder and sphere

oak aspen
#

I see...that makes sense

prime shale
#

You are already computing that in your shader graph, its your diffuse light group

oak aspen
#

So n is for normal and l is for lighting

#

Gotcha

#

Thank you for that explanation. Wish these tutorials just go over the basics rather than drag a bunch of nodes and magically things happen

karmic hatch
# oak aspen Thank you for that explanation. Wish these tutorials just go over the basics rat...

Today we are painting a landscape using mathematics.
Support this channel: https://www.patreon.com/inigoquilez
Buy this painting in a metal, canvas or photographic paper print: https://www.redbubble.com/shop/ap/39843511

This is the link to the real-time rendering code (that you can edit yourself live) for the painting: https://www.shadertoy.com...

โ–ถ Play video
meager pelican
swift loom
#

@meager pelican ๐Ÿ‘ yeah i tested it and they supported way big arrays. should be fine.

swift loom
oak aspen
wintry valley
#

Unsure if this is the right spot for this question, but when using the decal shaders in Unity URP, is there any possibility for forcing them to respect transparent geometry that came before it?

I have a decal sent to render on Transparency+1 (3001) and some water on Transparency(3000). In the water shader in shader graph, I enabled ForceDepthWrite on to write to the depth buffer, but the decal still is on the sand underneath the water. Upon googling it, I have found this https://forum.unity.com/threads/urp-decals-on-transparent-surfaces.1273913/ as a kind of hacky way to get it working, but is there anything I can use? I am using Unity 2022.2.1f1 with URP version 15.X

wanton grove
#

I'm trying to create a GPU based solution for modifying textures at runtime. My issue right now is that I want the shader to have access to mesh data like vertex position, normal, etc. whilst still working in texture space. So I suppose my question is, how would I convert texture coordinates to a mesh triangle index which I could use to interpolate UV values, normal values, vertex positions, etc.

E: One way I've seen people do it is by looping through all triangles in the mesh for each "texture sample point" and seeing if that point is within a UV triangle. I know it's being done on the GPU but I would love a more computationally cheap way than to iterate through thousands of vertices for millions of pixels.

low lichen
wanton grove
#

Actually let me send a picture

#

This is pre bake:

#

and this is after:

#

Also the solution I'm using right now which I didn't make, requires me to wait several seconds for some reason before baking, I can send a picture of what happens if I don't wait long enough (if you'd like)

low lichen
wanton grove
low lichen
#

Doubt it

low lichen
wanton grove
#

Also I'm still interested in exactly how the built in shaders convert 3d space to uv space or vice versa

wanton grove
# low lichen I don't know what that means.

Basically if I detect that a pixel is not within any triangles, I just get the closest point to the closest triangle, which would be an edge, and do my 3d-based calculations based off of that? It would be similar to the dilation thing but presumably more efficient, It would also ensure the dilations wouldn't overlap

low lichen
#

That would require a totally different approach than UV unwrapping

#

With the UV unwrapping approach, the pixels outside a triangle simply won't be drawn, so there's no shader being run on it.

wanton grove
wanton grove
wanton grove
low lichen
#

Unity is never calculating what triangle contains a UV coordinate. That doesn't even make sense because any number of triangles can contain the same UV coordinate.

wanton grove
wanton grove
#

I did read online that it actually starts with the 3D coordinate, and then converts that to screen space

low lichen
#

But by ignoring the 3D positions of the vertices and just placing each vertex by their UV coordinate, what you'll get is the same UV unwrapped view you'd see if you open the model in Blender.

wanton grove
wanton grove
low lichen
#

Which shader are you referring to?

wanton grove
#

I'm thinking I might implement my own form of rasterization, if necessary

low lichen
#

It sounds like you're missing some critical pieces of information about how 3D rendering works, which would make all of this a lot harder

wanton grove
# low lichen It sounds like you're missing some critical pieces of information about how 3D r...

You're probably right, but for starters, what if I just calculated the square bounds of each triangle, assigned each pixel within those square bounds a "triangle start index", then iterated through a collection of pixels, using their triangle start index to get all of the info I need. From my limited perspective, the only downside to this would be the inefficiency of using whole squares (which may overlap) to correlate the pixels to their respective triangles, it would also cause some duplicated effort on pixels which are within the same square bounds: but an article read or two should replace the missing knowledge there right, giving me a better solution rather than square bounds? I don't need to worry about lighting or anything like that as I'm only modifying the textures.

low lichen
# wanton grove You're probably right, but for starters, what if I just calculated the square bo...

I'm not sure how you would handle overlap between the square bounds. But you should understand that the UV unwrap method is basically no more expensive than rendering that mesh normally, which is super cheap because the GPU is hardware accelerated to handle triangles and rasterize them. Your method's performance will depend entirely on your implementation. It sounds like something that can be done with a compute shader, but is definitely going to be slower than the GPU's built-in rasterizer.

wanton grove
low lichen
wanton grove
# low lichen Before I answer that, could you give me a quick explanation of why you need text...

Sure, I want to have effects like blood splatter, dirt, rust, wetness, cuts, burns, pock marks, you name it. But this is all too much to do in a shader like in this video:
https://www.youtube.com/watch?v=A-P0llMckSw

So I thought I'd just have a standard lit shader, and modifying the texture inputs to generate the results I want.

Big systems require big explanations... I hope you've got a drink and a snack because this feature-length Development Log doesn't slow down!

In this video we take a look at my last month of work, creating a robust character customization system so that Prismatica can be full of unique and colourful characters. This system also allows for indivi...

โ–ถ Play video
#

Interesting looks like he does exactly what you're talking about in this video:
https://www.youtube.com/watch?v=yjki_Lr92Pg

Hello hello! In today's Prismatica DevLog we take a look at my latest experimentations for drawing damage and blood to characters! The way we do this is inspired by Ryan Brucks' world space unwrap method for skeletal meshes.

The reason I've gone with a Render Target approach as opposed to using decals is because performance with decals scales ...

โ–ถ Play video
low lichen
wanton grove
wanton grove
low lichen
#

Doing it in an asset importer is definitely cleaner, but also eliminates the possibility of loading models at runtime, unless you also include a runtime version of the preprocessor.

wanton grove
low lichen
#

When I say loading models at runtime, I'm talking about like modding support. Unity has an asset importer scripting API, which will let you automatically modify models after they have been imported by Unity, but that only works in the editor.

#

That's what I was talking about when I said "custom model importer"

wanton grove
wanton grove
low lichen
wanton grove
low lichen
# wanton grove Is there any built in way to gather edge vertices, otherwise I know a way I can ...

Not that I know of, but I've seen people here using C# libraries for that, like this one:
https://github.com/gradientspace/geometry3Sharp

GitHub

C# library for 2D/3D geometric computation, mesh algorithms, and so on. Boost license. - GitHub - gradientspace/geometry3Sharp: C# library for 2D/3D geometric computation, mesh algorithms, and so o...

wanton grove
low lichen
# wanton grove Thanks for all the info you've given so far, I think I only have one more questi...

If you have a reference to the Mesh the skinned mesh renderer is using, that will always be unmodified. You can get the positions there and upload to the GPU yourself, but you can also get a reference to the vertex buffer that is already uploaded to the GPU with Mesh.GetVertexBuffer. It's just a bit more difficult to read from, because it contains all vertex attributes, not just positions, so you need to know the memory layout to know where the positions are. The layout is accessible through Mesh.GetVertexAttributes.

wanton grove
leaden zinc
green peak
#

can you change the textures of a sprite?

#

in editor

copper falcon
grand jolt
#

My grass using a shader from the URP terrain demo does not show up in builds, only the editor. Any ideas? Uses Shader Graphs\TerrainGrass

green peak
wanton grove
wintry valley
green peak
wanton grove
green peak
#

one question though, i would need a seperate renderer for each texture then?

wanton grove
green peak
#

made a simple shader

wanton grove
# green peak

How does that shader turn the grass texture into a hexagon?

#

You're basically just sampling the same texture

green peak
#

yea

#

im trying to sample a texture onto a hex

wanton grove
#

So you don't have the hexagon shape yet?

green peak
#

Im using the default pointed top hex

wanton grove
# green peak Im using the default pointed top hex

I think your initial problem was that you were using the lit shader, I think there's some sort of built in sprite/2d shader. Your best bet to solve all of your problems would be to just quickly run through a tilemap tutorial, if you're using the builtin unity tools it should all be pretty easy, just make sure you're paying attention to what kind of shader you're using.

#

that should also allow you to use separate textures for separate tiles

green peak
#

here are all the sprite shaders

#

If i use the default unlit one

#

the texture is not applied

smoky vale
#

ok so i made like a small edit to my shader and it completely broke and it wont give me a single error hinting as to why

Shader "Lighting/Splatter"
{
    Properties
    {
        _Albedo("Albedo", 2D) = "white" {}
        _Color("Color",Color) = (1,1,1,1)
    }
        SubShader
        {
            Pass
            {
                CGPROGRAM
                #pragma exclude_renderers d3d11
                #pragma vertex vert
                #pragma fragment frag
                #include "UnityCG.cginc"
                struct appdata {
                    float4 vert : POSITION;
                    float2 uv : TEXCOORD0;
                    float3 norm : NORMAL;
                };
                struct v2f {
                    float4 vert : SV_POSITION;
                    float2 uv : TEXCOORD0;
                    float3 norm : NORMAL;
                };
                fixed4 _Color;
                sampler2D _Albedo;
                float random(float2 uv)
                {
                    return (sin((uv.y)*5000) - 0.5)/2;
                }
                v2f vert(appdata IN)
                {
                    v2f OUT;
                    OUT.vert = UnityObjectToClipPos(IN.vert);
                    OUT.uv = IN.uv;
                    OUT.norm = IN.norm;
                    return OUT;
                }
                fixed4 frag(v2f IN) : SV_Target
                {
                    fixed4 pixColor = tex2D(_Albedo, IN.uv);
                    float lightfactor = dot(float3(0,-1,0) * -1, UnityObjectToWorldNormal(IN.norm)) ;

                    return ((pixColor * _Color) * lightfactor) + random(IN.vert);
                }
                ENDCG
            }
        }
}
wanton grove
#

Sorry if that seems like a bit of an unhelpful response but it's the best I got (and will probably work)

green peak
#

You have been of great help, dont worry

#

As for the tutorial, you mean the one on unity.learn?

wanton grove
green peak
#

Ok, will try and find one, Thank you very much

wanton grove
#

np, good luck

green peak
wanton grove
green peak
#

Yea, I get that, but I was hoping you could just add a material to a sprite.
otherwise, you would have to manually draw a desired texture(terrain) for a sprite

wanton grove
green peak
wanton grove
wanton grove
green peak
#

Those tiles already have their terrain drawn onto them

#

What I am trying to do is add a texture to a blank sprite,

wanton grove
green peak
#

Better variety in sprites, it is easier to find 1000+ textures than it is to find a sprite with a specific texture

#

if you go on the asset store and look up 2d terrain sprites, not alot of options
but if you look up 2d textures --- WAYYYY MORE

wanton grove
#

You can make sprite assets and assign the 1000+ textures to them

green peak
#

cant seem to figure that out

wanton grove
green peak
#

no where to edit texture tho

wanton grove
# green peak

You're looking at the inspector for the texture not for the sprite

green peak
wanton grove
# green peak

my bad, it looks like it's even easier than I thought, simply change the texture type of your 1000+ textures to sprites

green peak
#

hmm

#

so I have set the texture to a sprite

#

How to outline it into a hex

green peak
#

nah not it

#

this is one is a square tho

wanton grove
# green peak this is one is a square tho

You should probably recreate your tilemap as a hexagonal tilemap if you haven't already, the only other potential useful thing I could mention that would help you down the line is a sprite atlas (which is one way to create a tileset). I think google or somebody else in this channel will probably help you more because tbh this is a bit out of my range of experience. ๐Ÿคทโ€โ™‚๏ธ

green peak
#

lol, yea, you helped me alot though

#

it seems if i want to create a hex sprite out of a texture

#

I was to manually outline the hex in the sprite editor

wanton grove
#

or just create a hexagonal tilemap, try doing that before converting all your sprites

green peak
#

The problem is, if the sprite isnt a hex

#

it wont matter

wanton grove
# green peak

I really think a hexagonal tilemap tutorial would be helpful, worst case scenario you just use the sprite editor and maybe use some sort of importer preset if necessary

green peak
#

ive seen those already

wanton grove
green peak
#

We are close, all that is needed now is to modify the texture into the shape we need

green peak
#

we can do that, ive tried it, but we have gonna have to do it manually

#

for every texture...

wanton grove
# green peak for every texture...

You could duplicate the sprite asset whenever you need to make a new one, then just override the image file in file explorer, that or look into some sort of asset post processor

#

Asset workflows and such are just as much of a problem to solve as making the game itself

green peak
#

indeed

green peak
#

smh

wanton grove
green peak
#

you create your own outline, but it wont be thesame across multiple sprites, since you cant copy and paste them

wanton grove
#

well like I said you can at least copy the assets

#

you could also try shift selecting and editing that way

green peak
#

each shape is tied to the texture and cant be edited or deleted

wanton grove
green peak
#

o

#

Well, thank you for your help @wanton grove gotta go now,
Best of luck soldier

prisma haven
#

Hello, i'm trying to figure out how to make a grayscale overlay for UI. Here is the shader graph.
So far i only managed to make a grayscale effect for an image itself, but that is not enough since i have other elements in the object like text with sprites (TMPro) and other images (example given). That's why i thought about having an overlay image that grayscales UI elements under it.
I'm pretty new to shaders, so i am at loss what to do. Does anyone know what am i missing?

charred dock
#

That way you can set specific colors to be used on the elements are disabled

#

and as I recall that works on TMP as well

#

As far as shaders are concerned making custom shaders for TMP is pretty hard as I recall.

#

But someone else might have better experience with that

#

I usually just avoid it when possible

prisma haven
#

@charred dock thank you for the answer, i am using canvas group, but intractable toggle effects only one image, if i'm not missing anything
meanwhile i have an object with multiple children that need to look grayscaled when disabled

charred dock
#

Ah, right it doesn't really become the same effect with colors anyway

#

That's a TMP shader that does the same as yours

#

Based on TMP_SDF-Mobile.shader

prisma haven
#

oh, thanks a lot!

charred dock
#

Put it in the same folder TextMesh Pro/Shaders

#

Basically the only thing that's changed is line 232

#

which does the same as your shader graph (I couldn't see exactly what you multiplied with for green so I set it as 1.2, feel free to change that)

#

c.rgb = (c.r * 0.39 + c.g * 1.2 + c.b * 0.10).xxx;

prisma haven
#

i'm just trying out different values
but thanks for the help

charred dock
#

If you are unfamiliar with shaders in code form what the last .xxx part means is take the same value and make it into a float 3 (just like the combine node in your shader)

prisma haven
#

ah, i see
yes, i have a very poor knowledge of coded shaders, mainly the reason why i'm using shader graph

charred dock
#

Yeah, it's really nice that shader graph makes it a lot more accessible

mental bone
prisma haven
mental bone
#

Nice! How did you do it ?

prisma haven
mental bone
#

Ah it uses a grabpass

prisma haven
#

ye

mental bone
#

Are you on urp or hdrp perhaps

prisma haven
#

urp

mental bone
#

Yeah grab pass doesnt really exist in the new srp's thats why it wont work

prisma haven
#

yes, i saw that in the comments, there is also an alternative solution posted there

mental bone
#

Unless you really need it to work as a dynamic mask I suggest simple exposing your parameters and setting them from script

prisma haven
#

yes, i was planning to try out your suggestion
thanks for the help!

swift loom
#

Am I completely wrong in how I multiply this direction by the camera matrix? I am inputting cam.cameraToWorldMatrix into _CameraMatrix

#

the results are so strange. Angles feel wrong and it's like things invert into themselves

#

in a compute shader

gusty horizon
#

I'd like to read more about the helper functions (ie UnityObjectToClipPos) available in Core.hlsl. Does anyone know where these are defined? I've had a look at Core.hlsl and Common.hlsl but can't seem to find much

low lichen
gusty horizon
novel wing
#

is there a way to assign a variable in shader graph and then reuse that same variable elsewhere with another node? like wireless nodes smil

low lichen
regal stag
novel wing
#

oo neat

gusty horizon
low lichen
gusty horizon
#

I'm trying to create a flicker effect, whereby the object "glitches" every set period of time. Currently I've got this:

float4 frag(const v2f i) : SV_TARGET
{
    float3 disp = SAMPLE_TEXTURE2D(_DisplaceTex, sampler_DisplaceTex, i.uv);
    disp = ((disp * 2) - 1) * _Magnitude * (round(_Time.y) % _Interval > 0 ? 0 : 1);

    half4 sample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv + disp);
    return sample;
}

The flicker is working fine, however there's no way to control how long it flickers for (it's always a second, because of my rounding of _Time), and it also relies on an ugly ternary. How could I improve this to have the flicker duration controlled by a property, and without using the ternary?

#

Trying to get into the habit of writing shaders without relying on conditional logic ๐Ÿ™‚

wanton grove
#

Why is render texture + raw image doing this?

quaint coyote
#

RT is not getting cleared

wanton grove
tacit parcel
#

check camera clear flags

wanton grove
tacit parcel
#

Yes

toxic flume
#

Is converting types (float to half, half to float, fixed to float, etc.) time consuming?

#

I mean is it worth storing some fields as half or fixed in input/output data while they are converted to float in codes?

shadow locust
#

saving data with smaller types can save significant memory

toxic flume
#

or the difference is negligible?

meager pelican
# toxic flume I mean is it worth storing some fields as half or fixed in input/output data whi...

Depends on the platform.
Desktop class GPUs pretty much convert everything to a float. lol. You don't know it, but it does that internally. Mobile, OTOH, will use smaller data sizes. One of the big concerns is memory bandwidth. You can get more data throughput by using smaller-sized variables, thus reducing total traffic on the memory bus. So it's not just storage (which matters too) but also throughput in bytes-per-second. And mobile platforms use shared memory with the rest of the device (and cached memory too, so smaller = more cached stuff).

So it's not only the amount of time it takes to convert a type, but also how much of that type your shoving across the bus. Use case, and the when-where-how matters as much as the need/no-need for conversion.

You have to test it out, benchmark it. Every use case is different.

meager pelican
gusty horizon
meager pelican
#

The reason is that due to how GPU's work, there's multiple processors running in parallel all executing the same code in LOCK STEP.

So if some "pixels" are one condition (true side) and some are the other (false side) they ALL have to step through BOTH SIDES...each are masked off where they don't apply.

So "more complicated logic" = more time to do BOTH SIDES.

Basically with a conditional you get the performance hit of BOTH SIDES unless the condition is the same for all cases, like when you pass in a bool-flag for the entire shader. If they can ALL skip over it, they generally will.

#

But the cost of doing both (var =1 and var = 0) is insignificant.

toxic flume
#

Genrally, it is better to use a texture for random noise or implement it with sin, dot,frac?
What about if it is perlin noise not a simplex noise?

#

I converted it to lerp

buoyant oriole
#

Just wondering, how would i set variables defined in a custom function .cginc file on a shader graph? Thanks

gusty horizon
rapid galleon
#

Hello, anyone know if there's a way to disable support for light probe proxy volumes in shaders on built-in RP (Unity 2021.3.16)? It introduces an unwanted extra sampler in almost all shader variants. It seems to be controlled by a keyword set from the Graphics Tier, but I don't want to disable it project-wide, just for this shader. I've found some threads indicating there should be keywords to exclude it, but none of them seem to have an effect.

quaint coyote
# rapid galleon Hello, anyone know if there's a way to disable support for light probe proxy vol...

To answer in short: nope(IMO). Because if you are using unity's shaders, the calculation will be done for GI. Now you need to find where that hlsl/cginc file is and then find the keyword. Even if you find the keyword and you disable it, it will be disabled for all the shaders using that HLSL/CGINC. But, if you are keen on writing your own derivation of the BIRP shader there's a tutorial by catlike-coding. Its on SRP. It has a GI topic. You can use that and while calculating GI, just dont take into account the LPPVs

rapid galleon
#

Buttt... I don't seem to be able to leverage that keyword even by explicitly undefining it. Might be something else going on indeed.

quaint coyote
#

you are using BIRP right? @rapid galleon

rapid galleon
#

Yup, BiRP. The keyword definition is explained on line 290 in the code there.

quaint coyote
rapid galleon
#

So it's defined "from tier settings", but "may be also disabled with nolppv pragma", though doesn't seem to actually work.

#

I'm assuming it's actually the UNITY_NO_LPPV a little ways down.

quaint coyote
#

usually you can enable or disable the keyword using material.setkeyword

#

I am looking for the post/comment/chat that I wrote when someone came up with a question on enabling/disabling keywords. 1 min

rapid galleon
#

Cool, thanks.

quaint coyote
#

assuming that the GPU stateblock will be set with the current shader itself for rendering certain meshes, it might not affect other meshes/materials

rapid galleon
#

Mmm, yeah, I suppose I could disable the keyword at runtime, though that would only allow picking the "right" one at runtime, not prevent it from generating in the first place.

#

I'll keep looking around, thanks for the input!

quaint coyote
#

you could just make a script and enable or disable it whenever required on whichever objects. hope that works ๐Ÿ™‚

rapid galleon
#

Jesus that was obscure

quaint coyote
#

hahhah! you got it man ๐Ÿ‘

grand jolt
#

https://youtu.be/VQxubpLxEqU i copied this shader into a cone mesh which worked but is it possible to make a certain vertex not get affected by the shader?

Unity Shader Graph - Vertex Animation of a Goldfish Tutorial

We are going to see how to make this cute little goldfish wobble and wiggle with Shader Graph. This shader will be mostly focused on Vertex Animation.

Goldfish: https://www.blendswap.com/blends/view/90712

Hey I'm making a game, check it out: https://store.steampowered.com/app/176386...

โ–ถ Play video
amber saffron
grand jolt
#

How do i do it? Im not too experienced with shaders

amber saffron
ashen mesa
#

Hi all ๐Ÿ‘‹

I was wondering if anyone here can try to assist me?
We have a project which is currently using Unity 2020.3.22f1 and been trying to upgrade it to 2021.3 for the past couple of months. currently we're trying to upgrade to 2021.3.16f1.

Now, while the upgrade process went smoothly and we have upgraded a few of our packages and libraries along the way we have encountered a very strange issue that seem to occur when building via Command Line.

We have a CI/CD jenkins process that automates our build pipeline.

Whenever we make a build locally from the machine, everything is fine, but whenever we use command line it seems like our shader's emission / lighting gets messed up.

See character A vs B...
Any idea what could be the issue?

I think I have literally tried everything up untill this point.

grand jolt
amber saffron
compact willow
#

I could use i little help, Im looking to make it so the user can toggle between Opaque and Transparent (Premultiplied) in the inspector however whenever i set up the enum i get an error

shrewd geode
#

Which one of these two billboard shaders seem more efficient to you guys?

sturdy hawk
midnight lily
#

How do I conditionally add alphatest:_Cutout addshadow?

#

I have a shader on which I can remove it's shadow casting in my game options

#

when it has alphatest:_Cutout addshadow, it runs about 20% slower

#

but if I don't have alphatest:_Cutout, then, when casting shadows, it runs over 20x slower

#

so what I need is a way to conditionally add "addshadow" to my shader depending on whenever I am or not casting shadows

#

I've tried multicompile but it does not work with pragmas

gusty horizon
#

I've got a couple different issues on some exercises I'd like some advice on:

I'm trying to create a simple outline shader, but can't figure out how to go about affecting the pixels next to the edge of a texture, based on a thickness property. My first attempt was to offset the UV coordinates in the vertex function, but of course this affects the whole texture and defo seems like I'm going about it wrong.

I'm also trying to create a 3d-style mask, in which the texture will be offset some distance to the right and coloured red, and the same to the left but coloured blue. Similar to above, any time I mess with the UV coordinates however, it changes the position of the whole texture and the mask just sits on top. In addition to this, when trying to multiply the texture color to both mask colors, I get black (attached).

I appreciate these are v basic q's ๐Ÿ˜ฆ

#

Here's what it looks like with one mask activated, compared to both.

waxen grove
#

Hi, I'm trying to use a decal with the standard shader, but it's seemingly MUTLIPLYING the colors of the standard shader

#

What I want is similar to the legacy decal shader, but I want to use the Standard Shader, as I don't want vertex-lit lights

#

Here's what I have in the inspector

bronze wraith
#

how can i made srp custom shader not pink anymore in urp
just delete or replace some thing in hlsl?
or solve the yellow error to make it not pink?

shrewd geode
#

Is there any way for me to achieve a more comparable level of performance when rendering lots of foliage via tilemaps vs via gameobject + sprite renderers?

With a tilemap I'm getting >100fps, and with the latter option I only get around 8 for the same setup.

I cannot use tilemaps because I need my sprites to billboard (rotate towards the camera), and AFAIK you can't do that on a tilemap because it's counted as one large thing.

#

Tilemap version

#

Billboard version

rare wren
shrewd geode
rare wren
#

Shouldnt be too hard to set up luckily

shrewd geode
# rare wren Shouldnt be too hard to set up luckily

I've ticked the "SRP Batcher" and the performance is no different. I've made sure my shader supports SRP batching as well. As for the sprite atlas, how exactly do I use it? I've created it, and added my sprites in Objects for Packing. Is there anything else I need to do, or is everything else handled automatically?

rare wren
shrewd geode
#

The performance with atlas + batching is identical

rare wren
#

Are the batches saved at least lower?

#

You want to get the setpass calls down

shrewd geode
#

setpass calls are the same

#

I'm not sure if there is anything I can do in this situation...

#

I don't think any game would perform well with >30000 gameobjects with sprite renderers and each of them running a billboard shader

#

I also had to do the following trick to get billboarding to work:

material = new Material(material);
spriteRenderer.material = material;
#

This is equivalent to doing "DisableBatching" = "True" in .shader

#

oh wait... that might be why batching doesn't work

#

but I need it disabled for the shader to work

#

fuuuuck

rare wren
#

But yes, that breaks batching haha

shrewd geode
#

I believe there is no easy way out of this

rare wren
#

maybe dont use that shader?

shrewd geode
#

the whole game concept just flops

#

the point is that I can swap from top-down to 2.5D at any time

rare wren
#

Either scope down the game or use another shader. I did not say dont use billboarding

#

Or rotate the sprites from code (probably best using the jobs system with this many sprites)

shrewd geode
#

I believe all billboarding shaders are like this. I've tried 4 of them so far, all of them rely on having batching disabled

rare wren
#

Can you link some?

shrewd geode
#

If you google "unity billboarding shader", you'll come across these (don't have links atm):

rare wren
#

Not URP compatible, but speedtree billboards have the option to enable dynamic batching

shrewd geode
#
Shader "Unlit/RucniShader"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {

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

        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

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

            struct v2f
            {
                float2 uv : TEXCOORD0;
                UNITY_FOG_COORDS(1)
                float4 pos : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;

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

                // 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 = outPos;

                UNITY_TRANSFER_FOG(o,o.pos);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                // sample the texture
                fixed4 col = tex2D(_MainTex, i.uv);
                // apply fog
                UNITY_APPLY_FOG(i.fogCoord, col);
                return col;
            }
            ENDCG
        }
    }
}```
shrewd geode
rare wren
#

Not sure about the text shader (not a hero with hlsl), but with shader graph shaders you can check 'use GPU instancing' to enable dynamic batching afaik

rare wren
wicked niche
#

I have 2 transparent materials, at the intersections the colors overlap each other very much and overexposure occurs, how can I control such a moment?

#

with the intersection of not so bright colors, it is not so noticeable, but still

next sky
#

how can i solve this problem with vertex color interpolation?

thin crater
#

Hi! I created a toon shader that suits most of my gameObjects. This is a transparent shader which uses alpha as a transparency. I cloned it and used a slightly different version for a particle system material, but transparency doesn't work!

#

I've got color over lifetime in the particle system and with an urp/lit it works pretty well, but with my shader it doesn't. What could be the problem?

#

That's the setting in the shader graph

#

And that's where the alpha comes from

#

it seems like it becomes totally transparent after alpha reaches values under <0.1, which should not be allowed since I've disabled alpha clipping, or maybe I'm wrong

regal stag
thin crater
#

That's still not workin

#

Nevermind now it's working

#

closed and reopened the project fixed it ahah

#

thanks โค๏ธ

thin crater
#

I've got thousands of objects that needs to be loaded in my scene, the problem is that they use a custom transparent shader and even with dynamic occlusion and 30/40 drawed in the camera the framerate drops a lot. Is it possible to enable and disable transparency via script?

#

Theoretically I only need transparency when the object is between the player and the camera, otherwise it can be completely opaque (and it is, 99% of the time, completely opaque)

shrewd geode
#

Is there any way to emulate an if statement in shadergraph? Specifically, I have to combine wind sway and billboard shaders in one shader graph. I want to have an external boolean called EnableBillboard, and based on that disable only the billboard portion of the shader. How can I do this? What nodes should I use?

shrewd geode
#

so in true and false I put values I want

#

if the predicate is true?

#

and then on out it goes out?

karmic hatch
shrewd geode
#

can I use position as an output?

#

oh yeah, that works

#

thank you!

karmic hatch
#

np

shrewd geode
# karmic hatch np

Is there a way to prevent the shader from doing calculation if it's early on prevented by an if statement?

#

Sort of like an early return in programming

karmic hatch
shrewd geode
karmic hatch
#

In HLSL

shrewd geode
#

oh...

#

yeah I'm pretty reliant on shader graph

#

interestingly, chatgpt says:

#

Yes, it is possible to do "early exit" in Unity's Shader Graph by using the "Discard" node. The Discard node can be used to prematurely exit a fragment (pixel) shader, effectively discarding the fragment and not writing it to the framebuffer.

#

but the Discard node doesn't exist ๐Ÿ˜„

grizzled bolt
#

Wrong answers confidently and convincingly

gusty horizon
simple violet
fresh basin
#

Hey everyone, I'm relatively new to shader graph and looking for some pointers/ideas on how to achieve an effect.

I've been trying to display a moving sin line. What I managed to do so far is a time + sin effect to display a red-coloured wave with some distance interpolation for pixel colour. Video below, and the shader graph image:

YouTube video of what my end goal is, a moving sin line:
https://www.youtube.com/watch?v=oeO-0CQCyfw

How can I start adapting this for a thin line that moves like a sin? The intended use for this shader is a static UI panel(think of a main menu background or something).

#

(changed video format to .mp4 so it embeds)

regal stag
amber saffron
amber saffron
copper falcon
# wicked niche I have 2 transparent materials, at the intersections the colors overlap each oth...

That's additive blending. Your texture is probably colorful beams on black background and since it's additive, it can not darken the background and even glows nicely on black backgrounds, but the colors also add up to 1.0, which is what you see.
You can try to blend the colors differently, more like this
https://en.wikipedia.org/wiki/Alpha_compositing

In computer graphics, alpha compositing or alpha blending is the process of combining one image with a background to create the appearance of partial or full transparency. It is often useful to render picture elements (pixels) in separate passes or layers and then combine the resulting 2D images into a single, final image called the composite. C...

wicked niche
copper falcon
stray loom
#

So if make a unity project that defaults in auto graphics for win/mac/Linux and changed it to use Vulcan then tried opengl, removed them and went back to dx in auto, does unity delete or what ever shader keywords? Before trying diffrent systems had no errors now has errors of exceeding 256 shader keywords trying to find how to fix

#

Standard built in rp, we was working with global snow had some issues was checking how it worked in other graphics setups

#

Not sure if unity creating copies of shader for dx opengl and Vulcan or how to see if duplicates

simple oak
#

anyone know why those loudspeakers are red colored? In blender they are not.

fresh basin
# amber saffron Use UV.x as input for the sin node. Subtract UV.y -> it should give you a sin sh...

Thanks a lot, I fiddled around with it and removed some nodes that are now unnecessary, works just as intended.

However, to make my function 'thinner' and use up less space on the object plane I used the Tiling and Offset node which works but feels like there might be a more elegant way to handle this. Other than that I'm gonna toy around with combining some trig functions to make more interesting patterns and a timer multiplication for faster movement.

Results attached, if anyone's interested

amber saffron
amber saffron
simple oak
#

im completly new to this stuff Xd

amber saffron
#

Just select the object and look at the material in the inspector.

simple oak
#

theres a red one, but i dont know how i can remove it

amber saffron
# simple oak

The material is grayed out, meaning it is a locked material that was generated when importing the model.
Unity tries to interpred the blender material settings to match it, but can fail if you are using nodes for the material, or some fancy setup.
You might want to extract the materials from the model in order to tweak and correct them in unity : https://docs.unity3d.com/Manual/FBXImporter-Materials.html

shrewd geode
#

I wanna toggle a boolean and have an entire part of a shader stop evaluating

amber saffron
#

If you go for the boolean keyword method, you have to ... change the keyword at runtime (using Material.SetKeyword). But this requires to be sure that the needed variant is compiled.

But if you use a regular bool input with a branch node, logically the unused part of the shader is not evaluated.

shrewd geode
#

or is that something that is defined once and cannot be changed without swapping out materials

amber saffron
#

Why would you want to disable batching ?

shrewd geode
#

atleast not the pre-made ones I'm using without all sort of custom shader writing and trickery

amber saffron
#

I guess the issue here is static batching. Can't you simply not flag them a static ?

shrewd geode
#

Umm I haven't really tackled shader graph much, would you be so kind to elaborate a bit more? How can I do that?

amber saffron
#

Basically, static batching merges meshes together, resulting in a modified pivot point, that is probably the cause of the billboard not working

shrewd geode
#

if I do this

#

GameObjectUtility.SetStaticEditorFlags(treeGo, StaticEditorFlags.BatchingStatic);

#

does that enable or disable it?

amber saffron
#

It enables it

regal stag
#

I think the problem is more dynamic batching as they're using sprites

#

I don't know of a way to disable it from ShaderGraph though

shrewd geode
#

in the original .shader file, this had to be defined: "DisableBatching" = "True"

#

otherwise it wouldn't work

#

and this obviously sinks performance

#

because I have 20000-30000 objects not being batched

regal stag
#

I'd probably look into GPU instancing

shrewd geode
#

using a tilemap instead of sprite renderer increased my performance greatly, but you can't billboard a tilemap

#

GPU instancing seems extremely manual and sadly I just don't know what I'm doing

#

so I'm looking for any workarounds

regal stag
shrewd geode
#

I kind of need colliders as well for shadowcasting

#

so pretty sure I need gameobjects

low lichen
#

Particles can cast shadows, you don't need a collider to cast shadows.

regal stag
#

I think particles can cast shadows too

shrewd geode
#

yeah but I'm using SmartLighting2D so idk how it interacts with that

low lichen
#

Yeah, that probably doesn't work

shrewd geode
#

So yeah the bool flag might work great because I could (at runtime) disable and enable billboarding for certain chunks that are out of the camera's view. The issue is that I need my plants to be billboarded and have wind sway, which means I have to combine 2 shaders into one

#

And since billboarding requires disabled batching and my wind sway shader is in the same place, it won't benefit from the performance gains of enabled batching

#

so I can only really switch materials at runtime which feels like it could be really slow

#

:/

low lichen
#

Is this for some 2D/3D mixed game? Why do you need billboarding in 2D? How does that work with a 2D lighting system?

shrewd geode
#

It is a game where mostly you'll be in top-down (like Rimworld), but as you zoom in close to the ground the camera will angle itself to make the game 2.5D (think Don't starve)

#

2D lighting will always be flat and look to you exactly how it would from the top-down perspective

#

you can think of it like this

#

How fast is it to swap out materials at runtime?

#

just by doing spriteRenderer.material = newMaterial;

low lichen
shrewd geode
#

I mean, what are the differences of it vs setting regular material

low lichen
#

sharedMaterial is what you think "material" is. "material" is a special property that automatically duplicates the material to ensure just that renderer is changed if the properties of the material are changed.

shrewd geode
#

But I need it to be duplicated anyhow, right?

#

Since I can't use batching

#

so I might want to use .material anyway?

low lichen
shrewd geode
#

I jsut wanna swap materials quickly

#

so that I can swap between:

  1. Billboarding + wind sway
  2. Wind sway only
low lichen
#

Then there's no reason why you'd want 100 copies of the same material if you have 100 renderers all using that material. That will happen if you use .material.

shrewd geode
#

doesn't that depend whether or not the plant is in camera view or not?

#

imagine the red rectangle is what the player can see on screen

#

so I need 3 materials (nothing, windsway + billboarding, windsway only). And every single instance of a plant (trees, grass), has a sprite renderer which needs to adapt based on these requirements

low lichen
#

I might be wrong about this, because I haven't used the setter of material often, but if you do something like this:

public void SetMaterial(Material material)
{
    foreach (var renderer in renderers)
    {
        renderer.material = material;
    }
}

This will duplicate material however many times you have renderers, because material ensures each renderer has its own instance of the material so if you modify properties on it, it only affects that renderer.

shrewd geode
#

The only reason I don't think that works is because if I did it that way, billboarding didn't work

#

which lead me to believe doing = new Material(material) was doing what you described above

#

I might be completely wrong

#

I will try it out though and see

#

only in the case of using windsway only (which supports batching) do I want them to share the material

mental bone
#

Unity does frustum culling for you so there is no nees to set a "nothing" material for out of view objects

low lichen
#

Yes, only in that case is it necessary that they share the material. But just because it isn't necessary in the other cases doesn't mean you shouldn't. If you don't need to have separate instances per renderer, then it's better to have them shared. Uses less memory, less time spent duplicating the material whenever you assign it. You asked how fast swapping out materials is at runtime. Using .material is more expensive than setting .sharedMaterial.

#

Setting sharedMaterial is the equivalent of assigning a material in the inspector.

shrewd geode
#

So to conclude... for everything that is out of view, I don't care about setting any materials.

For what is in view and zoomed out, I want to make sure I use .sharedMaterial so the wind sway shader can utilize it.

Finally, when I am in view and zoomed in, I want to use .material = new Material(material) so that I can get billboarding + wind sway to work

low lichen
#

I still don't understand why you need to duplicate the material. You said you don't need different property values for each renderer.

#

Are you assuming if it isn't duplicated, then all the renderers would be swaying or not swaying?

gusty horizon
shrewd geode
#

That's the only reason

#

billboarding is tricky with sprite renderers

gusty horizon
# gusty horizon I've got a couple different issues on some exercises I'd like some advice on: I...

Continuing with this:
I've made a little progress and now am a little closer to what I was trying to achieve (attached is what it currently looks like). However, I'm really struggling to avoid branching. At the moment, the fragment function looks like this:

float4 frag(const v2f i) : SV_TARGET
{
// Gets the position of the sprite, and its position offset to the left and right
half4 sample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
half4 sample2 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uvUpperMask);
half4 sample3 = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uvLowerMask);

// This color will either be transparent (if the pixel on the texture is transparent), or the tint color
half4 upperTint = sample2.a > 0 ? _UpperTint : sample2;
half4 lowerTint = sample3.a > 0 ? _LowerTint : sample3;

// Where the texture is visible, returns the texture. Otherwise, where the UpperMask/LowerMask is visible, return the upperTint/LowerTint color
if (sample.a > 0) return sample;
if (sample2.a > 0) return upperTint;
if (sample3.a > 0) return lowerTint;

return sample;
}

I feel like there must be a more effective way to mask, or perform calculations based on whether or not you're working with a transparent part of a texture. Would love some thoughts ๐Ÿ™‚

worldly terrace
#

could i use shaders to create a nintendo64 / ps1 graphic type style look on unity for my 3d game?

shadow locust
#

shaders would be one part of it, sure

graceful cypress
#

so this is a basic material related thing, i'm new to unity so this is probably a really easy fix but how do I fix the blurry line in the distance and even when im looking directly down on it, it's not just a sharp white line its got some blur

glass helm
gusty horizon
graceful cypress
graceful cypress
shadow locust
#

check filter mode, compression, etc...

gusty horizon
graceful cypress
#

so this is the texture import

#

i did try make it point filter mode which made the lines very distinct and sharp but the blurring in the distance was very pixelated

gusty horizon
graceful cypress
#

well just checking it now it does appear so when zooming it in to a realistic level of the way the player sees, which explains the blurriness close by which can be fixed then, thanks
but more annoying the blur in the distance is very distinct which is unrelated to the texture, how would I fix that

low lichen
gusty horizon
#

here comes the wizard you were wishing for ๐Ÿ˜‚

graceful cypress
low lichen
low lichen
# graceful cypress it's on forceenable

I linked you to the scripting API, but actually it's usually changed in the editor in Project Settings > Quality. Make sure the quality you have currently selected has it enabled.

#

If that doesn't work, it's possible for shaders to override these texture settings, but very few do. What shader are you using?

graceful cypress
#

should've mentioned but yes it is on here as well

low lichen
graceful cypress
#

standard

low lichen
gusty horizon
graceful cypress
#

yes

#

i do get this warning but i dont think it changes anything right?

low lichen
#

What Unity version are you using?

graceful cypress
#

2021.3.16f1

low lichen
#

And what build platform do you currently have selected in the Build Settings?

graceful cypress
#

just windows,mac,linux

low lichen
#

@graceful cypress Do you see this with all the textures in the texture pack, like if you open the demo scene that is included?

graceful cypress
#

huh yeah the demo scene has it to a significantly lesser extent

#

so yeah it practically doesnt have that issue on the demo scene

gusty horizon
#

if you made a new blank scene and copy/pasted from the demo scene, does it appear the same as in the demo scene?

#

if so, then thereโ€™s something in that specific scene affecting it, or something on the GO itโ€™s attached to

amber kindle
#

hi, i'm trying to use shadergraph to make a simple slash animation, but after plugging in my texture into the colour and alpha nodes it looks really different already https://i.imgur.com/aBj6fwi.png

#

(i'm using a sprite unlit graph with urp on v2021.3.0f1)

graceful cypress
#

just some odd thing with the scene then yeah

gusty horizon
#

@graceful cypress did you figure it out? ๐Ÿ™‚

gusty horizon
graceful cypress
#

thanks for all that helped though, i appreciate it. hope your problem gets solved @gusty horizon , looking at it that is way out of my knowledge hahah

karmic hatch
lean lotus
#

why does it take less time for a compute shader to read from a texture2d than it does for it to read from a rendertexture

gusty horizon
# karmic hatch If the texture alpha is always 1 or 0, you could lerp things together and it'd a...

so this was harder than it seemed. Currently how I'm actually getting the outline:

// Where the texture is visible, returns the texture. Otherwise, where the UpperMask/LowerMask is visible, return the upperTint/LowerTint color
if (sample.a > 0) return sample;
if (sample2.a > 0) return upperTint;
if (sample3.a > 0) return lowerTint;

The problem is lerping still doesn't determine (and subsequently exit early) whether or not I'm dealing with a transparent pixel before returning any of the tint colors. Because I can't return early, the samples end up manipulating the colour where the texture exists (which I don't want it to, I want it to do nothing if the texture exists)

#

Similar issue with the other outline exercise I'm working on, except repeated 4 ways:

half4 sample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
half4 leftSample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uvLeft);
half4 rightSample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uvRight);
half4 upSample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uvUp);
half4 downSample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uvDown);

if (sample.a > 0) return sample;
if (any(half4(leftSample.a, rightSample.a, upSample.a, downSample.a))) return _OutlineColor;
return sample;
karmic hatch
gusty horizon
karmic hatch
#

since the texture is pixellated (so you don't need to deal with unwanted colors seeping in) you could paint e.g. red where you want the outline to be, and black everywhere else, and then lerp again using that input

gusty horizon
karmic hatch
#

the texture

gusty horizon
# karmic hatch the texture

ay yeah, we're on the same page, just wrong terminology. that would work, but i'd ideally want a solution a little more flexible than that - incase I want to swap between shaders in realtime

#

baring in mind this is not for any project, just trying to get my head around shaders ๐Ÿฅฒ

karmic hatch
#

you could sample the texture four times, each offset by one pixel, and then saturate the sum of the alphas which should be 1 where there should be outline and zero otherwise

gusty horizon
#

whenever i watch vids and view the code for other people's work, they have such an intricate understanding of the maths that powers shaders & can pull off awesome effects with very minimal branching. my maths is pretty damn limited I'm still having to google what a sin wave is. wish i paid more attention in school aha

gusty horizon
#

there must be some magical way to do this without branching haha

karmic hatch
gusty horizon
#

oh my god

#

that's it

#

AHH

#

(ignore the funky pixels, its changing with time)

#

thank you so much @karmic hatch

karmic hatch
gusty horizon
#

starting to realise more and more shaders is defo one of those "just write shit and figure it out" kind of things

sonic jungle
#

Hey. Is anyone familiar on how to pass a single int32 into an unlit shader's vertex input (i.e.):

struct appdata_custom {
  int data : ???; // Which semantic should I use? POSITION?
}

v2f vert (appdata_custom v) { ... }

Currently data is the compressed position, normal, uv for a voxel. I was hoping I can cut down on the memory footprint by reconstructing the position, normal, uv on the GPU from data. Any ideas or thoughts are welcome.

gusty horizon
# sonic jungle Hey. Is anyone familiar on how to pass a single int32 into an unlit shader's ver...

any semantic you add will be automatically fed in to the vertex shader by unity. The only real way I can think of to achieve something like this would be to have an Integer property that you set elsewhere, and use that in the vertex shader. Out of curiousity, how have you compressed this data per-vertex? I'd be interested to know.

PS: I'm very new to shaders so there is almost certainly a better way, I just don't know it

#

also, I'm curious as to how much more memory efficient this would be once you've had a chance to perf test it

low lichen
sonic jungle
# gusty horizon any semantic you add will be automatically fed in to the vertex shader by unity....

any semantic you add will be automatically fed in to the vertex shader by unity.
Should the semantic match the data type? At least thats what I got from https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-semantics, so in my case I think BLENDINDICES0 since its the only int type.

Out of curiousity, how have you compressed this data per-vertex? I'd be interested to know.

The compression is common with axis-aligned voxel engines, I believe, where each voxel contains its position in its chunk, normal index, color index:
Position is usually [0, ..., 15] for each of the x/y/z components => needs 4 bits for each (12 bits total)
Normals for axis-aligned cubes are limited to 6 (up/down/left/right/front/back), so you only need 3 bits to store the normal index, and do a lookup on the gpu float3 normal = NORMAL_LOOKUP[normalIndex]
Similarly, color uses a 256 array lookup to figure out the voxel's color.
All in all, its 12 bits (position) + 3 bits (normal index) + 8 bits (color index) = 23 bits, with room for future expansion.
Idk if this is any good, but I thought I'd give it a try.

sonic jungle
low lichen
sonic jungle
#

As far as I know the semantics are

uncut verge
#

Hello friends! Hopefully this is the right channel for this question.

I'm upgrading a webgl project from Unity 2020.3.38f1 to Unity 2022.2.1f1...

I'm getting the following error in 2022.2.1f1 (works fine in 2020.3.38f1).

I'm having a number of issues related to shaders (BIRP, Post Processing Package v3.2.2 <- have a different issue with this posted in that channel, not sure if related to these issues or not). Trying not to cross post but the post processing issue is here: #๐Ÿ’ฅโ”ƒpost-processing message

Not sure what I'm really looking for so any advice would be appreciated... not sure if there is a setting I'm missing? If there is more info I should provide, please let me know.

First issue is with the Standard shader oddly enough... you can see it is now grey (?!) but should be white.

uncut verge
grand jolt
#

Guys how can I practice adding shaders to existing assets? These shaders would alter the look of the asset and adding details on existing materials

#

Does anyone have any good guides that show this instead of adding shaders to shapes?

quaint coyote
#

hello everyone, I recently implemented a fractal dust from shadertoy, but its creating artefacts like below:

#

any idea/suggestions what causes such geometrical pieces/artefacts?

shadow locust
quaint coyote
trail nymph
#

I'm having some troubles using the Scene Depth node in Graph Editor with Isometric view. There was a bug report a while back and it was marked as resolved, but maybe it's a problem with my graph.

It works and looks fine in Perspective, but the second I switch to Isometric it just flat out disappears

#

It sorta kinda does something when I change the Offset to a higher negative number (in this case -16)

#

Running URP with Depth and Opaque texture enabled in the Pipeline Asset

rapid galleon
#

Anyone have an idea what controls the inclusion of these two textures (OpenGLCore) in my shader? They are used for rendering glossy reflections blended from two reflection probes. Oddly, UnityShaderVariables.cginc seems to always include them (no preprocessors/keyword), but nonetheless in my list of shader variants, there are variants that do and do not include them.

#

The only thing that seems to control anything is a setting in Graphics Tiers, but that only controls whether reflection probe *blending * is performed. But oddly, the declaration of those two textures is independent from whether they're actually both needed. (I.e., unity_SpecCube1 is still included, just not used.)

#

Texture samplers for lightmaps similarly seem to be "magically" included or not included in separate variants, without me seeing any logic what actually controls that.

trail nymph
celest steppe
#

Hey guys I need help, Im creating a tree and I want that my leaf texture use a second color as a variation (some leaves should have color 1 and some color 2). Is there a way to random mix between 2 color nodes?

trail nymph
karmic hatch
#

(could also use simple/gradient noise as the input)

trail nymph
#

Oh wait they want two use either one, not a mix

trail nymph
celest steppe
regal stag
# trail nymph I'm having some troubles using the Scene Depth node in Graph Editor with Isometr...

The isometric view uses an orthographic projection, where depth works differently. (I've got a full post about depth here : https://www.cyanilux.com/tutorials/depth/)

If this is only an editor issue and you don't need orthographic views in-game it's easiest to just ignore this.
If your game uses orthographic only you can switch out the Subract node inputs. The image below shows the orthographic counterparts.
If you need to support both projections you can use your current inputs and the ones below with a couple Branch nodes, using a Comparison & the Orthographic output from the Camera node (returns 1 if ortho, 0 otherwise).

trail nymph
#

My game works in Orthographic, tysm I'll try it out in just a second <3

trail nymph
#

@regal stag works like a charm!! will absolutely have to go through that post as well, massive thanks

forest depot
#

Hello! Does anyone have an idea why my portal is able to display our camera when it's target platform is windows but not android?

narrow iron
#

how do i get a pixel from a texture2d in a compute shader? im trying to make a terrain generation shader and im not really sure how to get data from the heightmap.

shadow locust
shadow locust
forest depot
shadow locust
#

based on his video

forest depot
#

Yes, i think the script is called portal.shader

novel wing
#

what should i be using to make a skybox shader?

mental bone
novel wing
#

can anyone explain this

#

voronoi refuses to be rounded but if i pass it through another node first it works

toxic flume
#

Can't we pass struct array data to shader?
I have to implement something like it?

ublic class VoxelTextureController : MonoBehaviour
{
    [SerializeField] private Material _voxelMaterial;
    [SerializeField] private TextureDefinitionCollection _textureDefinitionCollection;
    private static readonly int TextureDataID = Shader.PropertyToID("TextureData");

    private void Start()
    {
        var textureDefinitions = _textureDefinitionCollection.Textures;
        var textures= textureDefinitions
            .Select(t => new Vector4(t.UVCoordinateIndex.x, t.UVCoordinateIndex.y, t.Resolution))
            .ToArray();

        _voxelMaterial.SetVectorArray(TextureDataID, textures);
    }
}

or use compute shader?
I would like to pass texture data array to shader

low lichen
toxic flume
#

My way is OK? instead of sending duplicated data for each vertex, I send that data array once and read it in the shader based on array index.
Vertices only send that index

#
  var textures = textureDefinitions
            .Select(t => new TextureData { UVCoordinateIndex = t.UVCoordinateIndex, Resolution = t.Resolution })
            .ToArray();

        var size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(TextureData));
        var buffer = new ComputeBuffer(256, size, ComputeBufferType.Default);
        buffer.SetData(textures);
        _voxelMaterial.SetBuffer(TextureDataID, buffer);
regal stag
# novel wing can anyone explain this

Possibly a bug. I've also had strange behaviour with the Voronoi node in the past (specifically when using Posterize node - in previews it would look fine but not in scene/game). I think it may be caused due to the loops used in the generated code but not exactly sure why.

forest depot
toxic flume
#

Can I compress texture 2d array? I have created a texture 2d array by script. It says, does not support compression format.

#

Any better way to create a texture 2d array (compressed) and use it in a shader?
File size is 56 MB for only two textures 2048,2048

knotty juniper
#

how are you putting the data into the texture array?

#

what format are the textures before you put them there?

fervent garnet
#

Hi, is there anyway to change to UV of only part of a texture? I'm trying to make an effect that will only affect the pixels inside a mask

knotty juniper
fervent garnet
#

@knotty juniper that sounds like what I need, can you explain how I would go around doing that?

#

I have the mask as a color that I create in the shader and not as a texture

knotty juniper
#

use one channel of that color in a lerp to blend between the non offset / modifyed UV's and the modifyed UV's for the main texture

#

@fervent garnet

fervent garnet
#

@knotty juniper I like that idea, thanks i'l give a try

#

@knotty juniper for some reason I cant connect a Color mask (vector1) to a the time port of the lerp? I tried to make it into a float4 instead but it wont connect, any idea?

knotty juniper
fervent garnet
#

Thanks @knotty juniper your question helped me figure it out ^^, it works, thanks for teaching me something new ๐Ÿ™‚

toxic flume
# knotty juniper what format are the textures before you put them there?
   Texture2D sample = textures[0];
            Texture2DArray textureArray = new Texture2DArray(sample.width, sample.height, textures.Count, sample.format, false);
            textureArray.filterMode = FilterMode.Trilinear;
            textureArray.wrapMode = TextureWrapMode.Repeat;

            for (int i = 0; i < textures.Count; i++)
            {
                Texture2D tex = textures[i];
                textureArray.SetPixels(tex.GetPixels(0), i, 0);
            }
            textureArray.Apply();
            
            string uri = path + filename+".asset";
            AssetDatabase.CreateAsset(textureArray, uri);
#

RGB24 is OK

knotty juniper
toxic flume
#

RGB24 takes 16 MB with respect to 2.7MB

knotty juniper
#

(not tested on my end ^^)

toxic flume
#

How should I use?

textureArray.SetPixels(tex.GetPixels(0), i, 0);
#

The only api to set pixels in tex2d array is SetPixels. I cannot find SetTexture

thorn snow
#

hello there, how do I make a new shader in a way it uses the spritedefault shader as a "base"? i have the problem that my shader is not lit.

shadow locust
thorn snow
#

or does somebody have good resource to learn this stuff

toxic flume
#

How can I assign that texture to texture 2d array?

dapper heath
#

Hey, would anyone mind explaining some stuff about custom render textures to me? As far as I can tell, trying to update it via code will "overwrite" the last update. Is it possible to preserve consecutive update results?

f.ex, if I have an update zone in one corner of the CRT to turn it blue, update, then do the same in another corner to turn that corner red, the blue corner will revert to the original texture.

shadow locust
#

maybe share the code you're using?

dapper heath
#

i actually figured out the issue, it was because i was calling the CRT.Update() in a for loop

#

i dropped it into a coroutine and it's working now, but it has a visible... "speed" if that makes sense

#

not 100% sure how to fix that?

#

    public void UpdateCRT() {
        atlas = atlasAsset.GetAtlas();
        StopAllCoroutines();
        StartCoroutine(ProgressList());
    }

    IEnumerator ProgressList() {
        for (int r = 0; r < targetRegions.Count; r++) {
            AtlasRegion region = atlas.FindRegion(targetRegions[r]);
            if (region != null) Debug.Log(region.name + ": " + region.x + " " + region.y + " " + region.width + " " + region.height);
            else Debug.Log("Null region.");

            CustomRenderTextureUpdateZone[] crtZones = new CustomRenderTextureUpdateZone[1];
            CustomRenderTextureUpdateZone crtZone = new CustomRenderTextureUpdateZone();
            crtZone.updateZoneCenter = new Vector3(region.x + region.width / 2, region.y + region.height / 2, 0);
            crtZone.updateZoneSize = new Vector3(region.width, region.height, 0);
            //crtZone.needSwap = true;
            crtZones[0] = crtZone;
            crt.SetUpdateZones(crtZones);
            crtMat.SetColor("_Red", targetColors[r]);
            crt.Update();
            yield return null;
        }
    }```
#

i took a video of the process in question

#

it's not slow persay but it's slower than it could be- if there was a callback for when update() finished f.ex it'd probably be nearly instant instead of one frame per slot

toxic flume
#

Can I pass custom struct data in input/output structs (vert/frag struct data)? or the only type if float2/float3/float4 and primitive types

float2 Something2:TEXCOORD2;
float3 Something3:TEXCOORD3;
toxic flume
#

I pass int index for each vertex to a shader using SetUVs. There is precision problem that results in texture distortion/ clutter
It was not resolved, even by adding round() to convert float to int : TEXCOORD.
The only way it works is when I define TEXCOORD float for input data but int for output data

   struct appdata
            {
                float4 vertex : POSITION;
                float3 normal : NORMAL;
                float4 uv : TEXCOORD0;
                float4 tileData : TEXCOORD1;
                fixed4 color : COLOR;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct v2f
            {
                float4 uv : TEXCOORD0;
                SHADOW_COORDS(1) // put shadows data into TEXCOORD1
                fixed3 diff : COLOR0;
                fixed3 ambient : COLOR1;
                fixed3 color : COLOR2;
                float4 pos : SV_POSITION;
                int4 tileData : TEXCOORD1;
                float3 worldPos : TEXCOORD2;
                half3 worldNormal : TEXCOORD3;
            };
smoky vale
#

fyi: returning any simple float works fine, so this line is likely the problem

#

even replacing uv.y with a simple float returns an error

#

so im assuming its the noise function

brazen nimbus
#

Hello there ! I'm working with HDRP shadergraph and I wanted to know if there was any way to blend the materials of the intersection between 2 objects ? Kinda like Virtual Textures on unreal

wicked niche
#

How to create this mask shader for progress, I want to create 3d filler for my game with gray empti color and texture fill color

#

but my shader not working

#

i want to fill from bottom to top

gusty horizon
regal stag
wicked niche
#

Why my alpha is not changed

regal stag
wicked niche
regal stag
wicked niche
#

and one more little question
it won't let me use half2 uv_MainTex_2 : TEXCOORD1;

supple linden
#

Beginner question here: do normal maps have to be images, or is there a way to do it via Shaders (e.g using the Noise node to create a normal map)

tidal iris
# supple linden Beginner question here: do normal maps have to be images, or is there a way to d...

You can kind of do it via shaders. Especially in Shader Graph, there's a node "Normals from Height" that generates a normal map from a height map. Depending on what you want to achieve, texture normals don't make much sense, like for example procedural water using scrolling noise layers.
However generating Normals for complex textures like, i dunno, circuits or something, is easier to do with textures than through calculation I think.

karmic hatch
#

^

#

fundamentally it would just be derivatives of some height function, and for some types of noise you can calculate analytic derivatives at every point

supple linden
#

Okay great thanks. I was worried that importing so many images/maps might be resource-heavy for the user and that using Shaders might be a lightweight way of doing it. Would that be right?

tidal iris
dry solar
#

why do I not have a transparent option in my shader? every tutorial there is has one by default and i can find anything online about it.

tidal iris
tidal iris
dry solar
#

Ahhhh thank you, that makes sence!

tidal iris
#

Hi all, I also basically joined due to a question:
Does anyone have an Idea on how to get a Shader Graph Material to be used as the Update Material to a Custom Render Texture?
When I configure it like this, it just won't update. No matter whether I do an OnDemand Update or Realtime...
It just won't update with a Shadergraph Material.

supple linden
amber saffron
amber saffron
regal stag
#

Oh nice, I had no idea that was added

amber saffron
#

Note that if you want your CRT to be an input of the shader (some sort of update loop for simulation ?), you'll need double buffered CRT, as it is not possible to read and write at the same time

sleek kite
#

Can tilemaps not act as shadow casters?

sleek kite
#

Nevermind, got it to work ๐Ÿ‘

dry solar
#

I'd like to create a simple atmpsphere for tiny walkable planets in my game (basically a foggy sphere) but it still has to look like for when your inside of the object with the shader so like its a volumetric. Is that possiple with shader graph? Or will I have to.... code?

swift loom
#

Does anyone know if you can do this in HLSL?

(float) !mask.x

to get a 0 from a true boolean

tight phoenix
#

How do I "offset" Time in a shadergraph?
example - Sine Time happens from 0 to 1, but how do I make two Sine times reach 0 and 1 at a different point in time?

#

adding to the value doesnt offset it, neither does multiplying or dividing

#

in an if statement, when sine is 1, I want it to be, say, 0.2, but still to oscillate 0 to 1 just at an offset time does that make sense?

#

I cant find the words to describe what I mean

sleek kite
#

You'd modify the time value in some way I assume. e.g. adding time would "start" the object in the future, if that makes sense

#

Since these are shaders though, they'd all execute the same code and it wouldn't really change anything

#

I assume you want each instance of an object to have a differently offset time

ionic hornet
#

how could I recreate the look of a crt display? i am looking to use a movie texture to play a video on an in-game crt and i wan the screen to have the crt look

tight phoenix
#

I want to have sine times that are not hitting 0 and 1 at the exact same moment

tight phoenix
#

I still want peaks and valleys of 0 to 1, I just want sines to not all hit 1 at the same time

sleek kite
#

Since Sine Time is just Sine(Time), you could add a value to time, like I mentioned. If you want each object to have a different time value, the offset would need to be unique. You'd have to pass each instance using the material a unique value. The easiest would probably be a MaterialPropertyBlock, but those can have issues with batching

tight phoenix
#

This is one single shader

sleek kite
#

Yes, and I assume you have many objects that use this shader, correct?

#

And you want each object to have a unique time offset

tight phoenix
#

Im asking what math do i do to grab one of those sines and slide it left and right, not scale up and down, not translate up and down

sleek kite
#

You add to time.

tight phoenix
#

Adding to it doesnt work

#

that slides it up and down

toxic flume
#

Do you think water mesh (material) has been separated from others? or all have shared material and inside the shader it handles which tile is water and should be animated

sleek kite
#

You need to add to the time, not the output of the sine value

#

e.g. Sine(time + 0.5)

tight phoenix
#

How do I add to time?

#

I don't have that output

sleek kite
#

Use a sine node

#

e.g.
Time -> Add -> Sine
0.5 ->

tight phoenix
#

OH you meant take the sine of time

#

and not sine time

#

Okay now that's clear, I understand what you meant now. Thank you ๐Ÿ‘

slender wren
#

Hello, could someone help me? I am trying to make a toon shader through following several tutorials, but I have come across the problem that I can't get shadows cast on my object

#

here is my function

#

I tried connecting it directly and some other variations, but no matter what I do shadows aren't cast onto it

#

here is the code

regal stag
slender wren
smoky vale
#

so im fairly new to writing shaders, and i was wondering two things, firstly, how can i make a low-res pixel art style, and secondly, how can i apply a hard black outline in a cartoonish style to the low-res look

#

my best guess for #1 would be taking every pixel and applying its color to the next pixel over, then skipping the pixel that the color was applied to, and repeating, but im not sure that shaders work in that sort of iterative fashion, because from what i gather all code written in a shader is applied to each pixel indevidually

dry solar
#

hey, how do I make an object transparent on one side but not transparent on the other with a smooth transition using unity shader graph? The image is an example of what i want in blender if the object with the shader was a sphere

karmic hatch
dry solar
#

ill try that thanks

plucky hazel
#

Hi guys! I need to make flat transparency effect for my UI elements, which doesn't stack on top like the circles on the left. Is that possible? And if it is how can I implement it?

#

And this is the in-game UI concept

merry oak
#

for cg coding, is there a built in way to convert rgb to hsv and vice versa, or do I need to create my own script for that?

#

nvm, I found a script that someone else already made for it

karmic hatch
#

Could also look into using a UI mask, or a texture that's the right shape if it's a permanent feature

ionic hornet
#

how could I recreate the look of a crt display? i am looking to use a movie texture to play a video on an in-game crt and i wan the screen to have the crt look

knotty juniper
obsidian wasp
#

Anyone have a clue as to why a toon shader is causing shadows to have an antialiased/transparent edges effect, and why point lights would be amplified within shadows?

#

Followed this https://www.youtube.com/watch?v=RC91uxRTId8 for the shader.

โœ”๏ธ Works in 2020.1 โž• 2020.2 โž• 2020.3 ๐Ÿฉน For 2020.2 and .3:
โ–บ When you create a shader graph, set the material setting to "Unlit"
โ–บ The gear menu on Custom Function nodes is now in the graph inspector
โ–บ Editing properties must be done in the graph inspector instead of the blackboard
โ–บ In Lighting.hlsl, change the line "if SHADERGRAPH_PREVIEW" to "...

โ–ถ Play video
simple spade
#

it may have to do with the amount of lights you have in your scene

#

i think theres a setting to adjust it

ember scaffold
#

Anyone know why the outline seems to be disconnected? Using unity toon shader on URP

#

This is another model using the same material

#

lmao nvm it was shadesmooth

onyx talon
#

Firstly, you should know how the outline shader works. Then you will know the answer.

cobalt hazel
#

I'm planning to change my hologram shader to show the bottom half of the mesh as solid.
But, the % solid may vary per object, could I pass that extra data to the shader?

#

I guess a lame way would be to give each object their own custom instance of the material with a different parameter, but I'm using a render feature to replace their normal materials so I would very much prefer sticking to one material

dim yoke
cobalt hazel
#

how do I use that?

#

or where is it?

#

ill back up

cobalt hazel
# cobalt hazel

I am looking to create an effect where I can materialize objects. Specifically, show part of the mesh with the normal "solid" materials and the other part of the mesh with my hologram shader. I also need a way to control what % of the mesh belongs to which shader. And each mesh may have their own %.
Any ideas welcome

So far I've been able to get the shaders to stack properly using render features in the URP asset

cobalt hazel
dim yoke
regal stag
#

It would also break the SRP Batching that URP uses. Whether that's a problem really depends on how many objects are being drawn like this

simple spade
#

anyone know how I can make a shader like this?

regal stag
# simple spade anyone know how I can make a shader like this?

Can look up toon/cel shading tutorials to get the colour-banding like that.
For the pixellation could render using a camera with target set to a Render Texture at a smaller resolution than the screen. Then find a way to draw that texture to the main camera. (e.g. Quad mesh, Raw Image UI, Blit to screen)

meager pelican
# cobalt hazel I am looking to create an effect where I can materialize objects. Specifically, ...

Any ideas?

Well, there's "other" ways. The idea(s) mention by @dim yoke and @regal stag are more traditional, if you don't want to use separate materials, which would be the easiest.

But if you don't want to use MPB's, you could use different meshes for each object (dynamically create the mesh instance for each one) and THEN you could stuff an instance index/ID of some sort into one of the mesh attributes, say vert color or one of the UV channels. If I went this route, I'd copy the mesh data from some template mesh into a cached list of dynamic meshes, and mark the cache entry as in-use or available. Then I'd romp through the mesh and update things.

Your shader could then have some kind of array/buffer passed for each object. And each object's entry would contain the % materialized/full.

That's all a bit hacky and a lot of work for what would otherwise be separate material instances. The main problem is that you/we don't have a user-definable mesh-instance attribute that unity passes directly....one for each mesh. Say a float. So you have to set this dang value on all verts of the mesh.

If anyone knows of a better way to link a mesh instance to a structured buffer via user-managed C# code, I'd like to know about it. I mean, unity does it when it does MPBs and GPU instancing. But we don't have an attribute we can use for our own data mapping a mesh to a c-buffer or other UAV.

cunning geyser
#

heey i just started working with a sonar shader but it effects the whole mesh(terrain) and its repetetive, it uses a sin wave, but i want to make it that the sonar effect waves appear on button press in a radius, 3 button presses 3 waves after eachother, how can i achieve this? or this is even possible?

slow socket
#

any idea why the projector is creating such a huge effect?

swift loom
#

I dunno if there are any raytracing pros here but. I'm doing DDA raytracing (https://www.shadertoy.com/view/4dX3zl) and it works just fine, but I'm trying to skip empty space by implementing brickmaps (8x8x8 voxel volume), and to me the logic is perfectly sound, but does this math not make sense??
I increment the lowest value sideDist by adding the deltaDist (ray distance needed to increment axis index) to it. This works fine, but once I start trying to approximate this while skipping space with a brick it breaks.

Basically we can check every step which direction we need to go using the DDA, so I keep track of when I enter a new brick, and when I do I increment a separate brickSideDist to keep it in sync. Once we enter a space we need to skip I increment the brickSideDist first of all, then I get the brickIndex by taking our voxelIndex and dividing it by 8, then I add 1 to it in the axis we traversed, then I multiply it up again by 8 and add the voxelIndex with modulo 8 so we have the right index when we're casting a negative ray.

Then I subtract the old index from the new index to get a distance, then I multiply it by our deltaDist to get a total distance travelled along the ray in that axis. After that I divide our calculated distance by all three of our deltaDist axes, floor them, and that should tell me how many steps of each were traversed. Then I simply add this multiplied by the deltaDist to the sideDist, and the same to the voxelIndex multiplied by sign(rayDir).

Maybe i'm using too many variable names here but am I missing something here? It all checks out to me but I can't get this logic to work in practice. The rays seem to bend all over the place.

cobalt totem
#

I'm trying to use shader graph to create some post-processing effects, I've created a custom render texture, set a camera to render to that texture, created a canvas with a RawImage, which I've applied the texture to, then set the material for the texture to my shadergraph material. However it doesn't appear that anything I do in shadergraph has any effect

smoky vale
#

so apparently i should use a render texture to lower resolution, but i dont know how to use them in combination with my already made shader

smoky vale
#

i think im figuring it out

smoky vale
# dim yoke What shaders?

ok well i got a vert frag shader and im struggling to find how to lower resolution to create a pixelated effect from the current visuals i have

#

i think i managed to get the render texture sort of working kinda

#

i assigned it to the camera, then made a rawimage element and put it in there

#

and it displays visuals, just not properly, ill record a gif

#

hold on..

#

ok i fixed the issue

cobalt totem
#

How did you fix it? I either get output but no shader effects, or just a solid colour

smoky vale
#

assigned the render texture to it

#

assigned that material to a ui element

#

made the material an unlit texture material so you dont get lighting interferance

#

then i made sure the render texture was in the correct aspect ratio

#

and that it was assigned to the main camera

#

thats about it

cobalt totem
#

If I put some screenshots on here can you see if I've gone wrong somewhere? Right now I've just set the shader to output a solid colour

#

Here is my material:

smoky vale
#

oh i dont know much about the shader graph

#

i just wrote my own shader, you are sorta on your own there

#

but i do have a new issue..

#

how can i get the render texture to maintain a consistant look of an object whilst still bieng pixelated

#

let me set up an example..

cobalt totem
#

Ah I figured it out!

#

I had to set an additional shader channel:

toxic flume
#

To define const verctors, we should define static const?
#define works only for single primitive types like float?

static const float4 vec = float4(0.0,0.0,0.0,0.0)
#define PI 3.1415
low lichen
#

So typing VEC is the same as typing float4(0.0, 0.0, 0.0, 0.0)

cobalt hazel
#

Any ideas

quaint coyote
#

noise nodes in unity shadergraph arent quite sharp, any workaround for the same?

cobalt hazel
#

simple gradient shader

#

if the object position goes from -1 to 1 always, then the full gradient should be applied to every object no matter their size or geometry

#

instead, some objects are able to reach higher parts of the gradient somehow.

#

any hints appreciated

quaint coyote
# cobalt hazel

check the pivot in object/local space in the editor? maybt its a bit off?

cobalt hazel
#

its as if the capsule is longer geometrically

quaint coyote
#

simple gradient shader

last wolf
#

Does anyone know of anywhere to get Unity Technologies depreciated assets?
I'm looking for the Blacksmith Environment asset - https://www.assetstore.unity3d.com/en/#!/content/39948 - or is there anyone who has it in their assets who would be willing to upload it somewhere for me?

echo lily
#

Is there a way to disable Unity shader compiler optimizations, so unused variables are not scraped out from the shader output ?

lost coyote
#

is there a way to export this shader node to unity? I was trying to make a clawhost-like weapon, but its a "plungershot". Thing is i didnt found any rope texture that fit, so i hand made one, is there a way to export it to unity?

karmic hatch
#

(spheres too)

#

Also iirc the preview objects in shader graph might be slightly different from their unity primitive counterparts, e.g. the preview sphere is a UV sphere while the Unity primitive is a cube-sphere and the preview one might go from -1 to 1 in object/world space too

sacred patio
#

Hello, is it possible to create a texture like this in a shader procedurally? I guess the grid is easy but is there math that pinches it like this?

low lichen
#

If you can control the width of the area the lines are in, you can change it based on the Y position.

sacred patio
#

Wait, is there a VectorToRadialValue alternative in Unity? Or should it be built from scratch

wicked niche
#

please tell me how to invert the value of fill amunt so that the filling remains the same (transparent from below, filled from above), but the value on the progress bar was not 0.8 but 0.2

knotty juniper
vague wolf
#

Hello. My shader has in input a float3 variable named _PositionToDraw, which is a position in world space coordinates and I would like to color the matching and closest pixel.
I saw that i.worldPos and _PositionToDraw has both correct values. How can I calculate if the pixel is to be colored or not? Thank you!

low lichen
#

It's not trivial to figure out which pixel is closest. That requires comparing all the pixels with each other to see which is closest.

#

Unless the shape you're working with is something that's simple to define in math, like a sphere or capsule.

vague wolf
simple spade
#

How can I achieve a similar effect to these glitch artifacts in shadergraph?

#

In my shader currently I have a main texture, and the glitch texture which is used for the artifacts

#

I don't know how to overlay the artifact texture in this blocky like formation

toxic flume
sleek kite
#

Is it possible to only pixelize the rendered object using a shader? (i.e. not a post-processing effect)

tight phoenix
#

Is there a way to make Color be a color swatch and not a vector4?

tight phoenix
#

is there a less dumb way to get a binary white/black to fill a progress bar with

tight phoenix
tight phoenix
#

is there an easy way to convert this into a Sawtooth wave?

#

I googled it and the net said to use modulo on the sine to make it sawtooth

#

but that did not make the gradient sawtoothed

#

I want the gradient falloff to be in a single direction, not both

#

There used to be one single node that would just loop anything plugged into it

#

but now I can't seem to find that

#

I google things like loop, repeat, but no results

#

Fraction, that was it

visual pier
#

Hello all - I'm looking for a way to setup a shader in Unity with the following parameters:

The shader is supposed to utilise the R G and B values of a texture map, in order to change any corresponding element to whatever color necessary. For example, the torso armor would be red and would be effected by any red part of the mask map. The legs armor would be in blue. The trim of the armor in green, etc. Then a color could be picked for anything corresponding to said R G and B values...
are there any resources showing how to set up a shader like this? thanks!

spare ermine
#

I'll set up a quick example in shader graph

spare ermine
toxic flume
#

Isn't there light dir in shader graph ?! (unity 2021)

toxic flume
regal stag
toxic flume
#

but it is weird really, it is a basic node

#

Put a package in repo while it does not contain basic nodes

regal stag
# visual pier Hello all - I'm looking for a way to setup a shader in Unity with the following ...

Should be able to sample the mask map, and multiply each channel by a color property, then add together. e.g. for Shader Graph would be similar to this : https://www.youtube.com/watch?v=4dAGUxvsD24

karmic hatch
#

What you want to do is generate the lines as a function of (x-0.5) (maybe using a sine() or something; the 0.5 is so that it's centered), and then you can pinch it by replacing (x-0.5) with (x-0.5)/y

toxic flume
#

After removing Library and reimporting, again it does not work

Shader error in 'Shader Graphs/water': Couldn't open include file 'Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl'. at /Library/PackageCache/com.cyanilux.shadergraph-customlighting@73ccdd474a/CustomLighting.hlsl(60)
solar musk
#

is there a way to create a shader that applies a uniform size border directly to a mesh face? I have lot of rectangular platforms and I'd like to achieve something like what a hat in time does with these platforms. I'm also using probuilder meshes if that changes anything

#

not planning to do anything like the crystals here if that simplifies things

inner coral
#

Somehow it detects these red things on my texture.
Attached the image used as well as the meta

Unity version: 2022.2.2f1
URP Version: 14.0.4
Shader Graph Version: 14.0.4

There should be no things there

eager folio
amber saffron
grizzled bolt
#

I think most likely they selected the faces in a modeling program and did an inset operation
If it needs to happen at runtime it might be worth looking into making a similar inset operation within Unity procedurally
Just some options before you decide to go with shaders

cosmic prairie
cosmic prairie
#

this is ofc only one color mixing mode

#

it chooses the final color based on a weighted average

#

you can also just add them like

#

finalcolor = R*redChannelReplaceColor + G*greenChannelReplaceColor + B*blueChannelReplaceColor

#

this will increase the brightness of your final look tho where R G and B overlap

#

if you can choose because colors never overlap, I'd recommend the additive mixing, it's a cheaper effect, division is expensive

cosmic prairie
#

but the compiler might already do it for you idk

#

best to be sure

gray panther
#

How to fix this, my project uses VRchat settings if this will help.

regal stag
# gray panther

Older unity versions only support Shader Graph in the Scriptable Render Pipelines (URP/HDRP), but I'd assume VRchat requires the Built-in pipeline so you can't fix this.
Either switch to writing shaders via code, or look into alternative node editors such as Amplify Shader Editor or Shader Forge.

celest steppe
#

Hey, I need some help. Is there a "easy" way to add that my planes are always facing the camera?

gray panther
#

In the tutorial I watch, guy has HDRP pipeline.

#

And we both use almost the same version of Unity.

#

But I donโ€™t. have hdrp shader option for some reason

#

Sign up via my link will get two FREE months of Skillshare Premium https://skl.sh/romanpapush
โ€”โ€”โ€”โ€”โ€”
#Update: Blender 2.8 is out! https://www.blender.org/
โ€”โ€”โ€”โ€”โ€”
Heyo my dudes!
I really hope you will enjoy this advanced tutorial for complete beginners!
By the end of this video you will master the Air-Bending techniques of the ancients and will le...

โ–ถ Play video
#

The tutorial I follow.

thin lintel
#

probably an easy fix and a dumb question but I cant see any of the properties options under "surface options" for my shader material. I'm trying to get the material to stretch to cover the entire surface or even just access the tiling, and also rotate it by 90*

amber saffron
celest steppe
#

Hi guys. I created a leaf foliage shader and would like to add a second leaf texture and color for more variation. Is this possible?

visual pier
#

thank you for everyone who replied to my shader q - was off sick so didn't have a chance to respond

amber saffron
brazen nimbus
#

Ey ey ey, I'm looking for a shader blend material for... details mesh (grass on a landscape). Does someone has ever heared about that ? Or have any idea to create a well blend between my landscape texture and my grass details one ? I've already tried to do it with an alpha but don't have a good result. Getting the ground color and doing a gradient from bottom isnt possible because I have 2 different textures (Green and brown). Thanks in advance :)

sacred patio
quick flax
#

I'm making my own lit shader and everything is working fine but I'm having one issue. When I have the exact same properties and texture maps on my material, on my own shader it's more glossy than on the Unity lit shader. Does unity do something with the calculations of the smoothness value and the metallic map or something?

#

This is unity version

#

This is my version

#

Exactly the same properties and values but my 'smoothness' is much more visible

#

my smoothness is directly attached to the smoothness of the root node so I don't calculate anything

#

I have my shader set to the same values as the rest: metallic, opaque, front faces,...

low lichen
quick flax
#

I was just about to try this

low lichen
#

That's what this means. Smoothness is read from Metallic Alpha, but multiplied by 0.5

quick flax
#

perfect!

#

Thanks again

sacred patio
#

Is it possible to add an animated noise distortion to a cube map?

pure fulcrum
#

im using the built-in render pipeline and am trying to add a the option for a specular texture to my shader graph. enabling "allow material override" unlocks the specular output in shader graph, but there is no option to change it to a specular material like there is in urp

toxic flume
#

I want glow water effect like Terra Nil.
My try
I do not know why the color of the uploaded video has changed

#

Any suggestion to improve it? better noise textures, tune params, etc.?

#

imo, one improvement, adding a mask texture because now, glow effect has spread out everywhere on the water.

solar musk
#

thank you for the input on my question!

solar musk
acoustic agate
#

Hi everyone,

I am kind of new in writing shaders and I am trying to achieve a slider effect on my world-space objects. So, to achieve this, at the end of the shader I am checking whether the alpha value of a given reference texture is above the fillrate variable. If it is, consequently, setting the alpha value to zero.

As a result, I have achieved what I wanted as in attached gif, but I am not sure, whether this is the most performant and best way to do it.

Is there any other way to achieve similar behavior, without using if statements? Or is this a valid and proper approach to get this kind of slider effect? https://codeshare.io/yoybdq

shadow locust