#archived-shaders

1 messages · Page 59 of 1

dim marsh
#

no idea how

umbral swallow
#

Not at all, that's why I posted it under graphics, and graphics cards are required to run unity last time I checked..

tame topaz
#

Your decision to buy or not buy a video card is not related to shaders.

glass coyote
#

hello!

#

is there a shader for UDIM in unity?

compact plume
#

I have sort of the same problem, except I need mine to work with Tilemap Renderer, not just Sprite Renderer. I can get it to work for a single sprite, but changing more than one tile at a time changes all other set tiles in the same map, rather than each having their own separate sprite.

glass coyote
pearl idol
#

can anyobdy help me with cam renderings

grizzled bolt
hidden kindle
#

@grizzled bolt thank you for telling me about the tiling and offset node, somehow i forgot about it 😄 I now have my desired effect but i dont quite understand why to be honest. I do feed the shader with 2 textures and get the matching piece of the tile by dividing it by the amount of cards displayed on the texture (my cards are 128x128, my card texture is 384x128 so i divide it by 3, my background card texture is 768x128 px so i divide it by 6) then i offset it depending on which card i want to display. Now my question is, how does it work if i only give the shader my background card texture and fetch the card texture by inserting it as the _MainTex. Since the card texture is only a piece of the whole texture using sprite mode multiple, somehow the scaling is now totally messed up.
Whats the difference between using the whole texture, dividing it and offsetting it, and the other approach of just giving the part of the texture into the shader (Tile mode multiple)?
I hope its not too confusing otherwise i can attach some images 😄

grizzled bolt
somber snow
#

When i do this, the whole object looks white

#

But with this, the texture appears

#

I'm seriously confused, doesn't the w component equates to the alpha channel?

frigid jay
somber snow
#

Thank you very much!

idle copper
#

Hello, I am having some issues trying to write a for loop in a custom fragment shader. I looked it up and this should be the right syntax but trying to save the shader throws an error.

(Unity version: 2021.3.3f1)
Here is the shader:

Shader "Hidden/NewImageEffectShader"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        // No culling or depth
        Cull Off ZWrite Off ZTest Always

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

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

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

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

            sampler2D _MainTex;

            fixed4 frag (v2f i) : SV_Target
            {
                for (int i = 0; i < 5; i++)
                {
                    //Do Something
                }
                fixed4 col = tex2D(_MainTex, i.uv);
                // just invert the colors
                col.rgb = 1 - col.rgb;
                return col;
            }
            ENDCG
        }
    }
}
#

And these are the errors:

#

Does anyone know what I might be doing wrong?

pale python
#

hi ,
I want to ask a technical question regarding optimization for shader codes.

I wanna add an if statement but i was told many times it's not preferred to use if statements in shaders, I thought of multipling the equation with a float where if float was zero the whole thing will drain.

so which is better an if statement or a float factor?

Option 1: float test = test + sin(30) * factor;
Option 2: if(factor !=0) test = test + sin(30);

weary dawn
pale python
idle copper
weary dawn
#

even if it's just break/continue

idle copper
#

Do you know if my syntax for the for For Loop is correct?

weary dawn
idle copper
weary dawn
#

are the errors the same if you paste it after the tex2d call etc

idle copper
#

no, the errors go away. I did some more testing and it seems any reference to i.uv after the for loop throws an error.

weary dawn
#

I know what it is

#

I'll give you a hint

#

v2f i

#

int i

#

I should've spotted that

idle copper
#

I'm going to go jump off a cliff now

weary dawn
#

pmsl

idle copper
#

Thanks for the help Lol

cobalt bolt
#

hey guys, is it possible to check the currently active color space (gamma or linear) with shader graph? Basically a node that outputs false if the current color space is gamma and true if it's linear, or vice versa

compact plume
# grizzled bolt A tilemap is basically just one big sprite renderer that repeats sprite textures...

I'm trying to use various forms of bitmasking, such that tiles calculate which sprite to select from an atlas for their albedo and then select which sprite to use from another atlas for their mask, or to do various blending. So that tiles will dynamically change based on their surrounding neighbors, like custom Rule Tiles (and there's a reason I'm not using the 2D Extensions for this).

If I only have one sprite in each atlas, the masking works. If I have multiple tiles, I can get the albedo to work but not with the masking. At least not in game, even though it works just fine in the Editor. As near as I can tell, this is because Unity expects an actual asset for the renderers rather than a dynamically-created value. However, saving potentially thousands of assets is untenable.

I have tried using Shader graph, and it works fine in the graph, but again not in game and I don't know how to get back out the final sprite on a per-tile basis.

#

This is what it's going, vs what I want it to do:

grizzled bolt
woven pagoda
#

Can someone help me figure out if I can use these assets

#

They are magenta

#

which must mean the shader is outdated I would think

#

but I'm very new and not seeing a solution

compact plume
# grizzled bolt Seems quite involved, not sure I totally understand Is this bitmasking and tile ...

You could say I'm trying to automate the process and make it more streamlined. I have scripts that aim to take an atlas or array of sprites and apply certain rules to them instead of starting with a bunch of sprites and applying rules to them with arrows and palettes. For instance, I have a modulo tile that allows repetition based on that tile's coordinates. That one works just fine. For anything that needs masking or blending, however, that's where the problem enters.

I don't know that just getting vertex colors will work since I don't want just colors, I want the entire sprite. By which I mean, I want that portion of the texture within the atlas.

Again, the thing that's holding me up is figuring out how to set individual tiles in the tilemap after applying a custom shader without having to save the result as a separate asset and without all tiles in the map displaying the same tile. Right now, I can do one or the other but not both.

hidden kindle
grizzled bolt
karmic hatch
# woven pagoda

if you are using URP/HDRP, make sure your materials use the appropriate shaders; I believe Standard is for BiRP

grizzled bolt
# compact plume You could say I'm trying to automate the process and make it more streamlined. ...

Vertex colors are just values stored in a vertex, they could be used exactly in the same way as UV coordinates
I expect you need a system to automate assigning the necessary coordinates via colors as required
Maybe there's a way to write custom vertex streams beyond colors but I don't recall exactly
If I were making such a system I think I'd prefer to look into how to generate rule tile sets automatically before making a new rule tiling system

rose shard
#

Have started to attempt to get into shaders and to do so I've picked up shader graph isntead of teaching myself HLSL. With that being said, I'm trying to make a shader that effects ONLY the deep (practically black) values of the players camera view and leave everythin else untouch. If you can imagine, I want the darkness of the game to be full of static while the rest is normal. Any documentation, forum posts, or instructions I could get to achieve this affect? Thank you!

lavish sierra
#

You might not even need a shader

compact plume
# grizzled bolt Vertex colors are just values stored in a vertex, they could be used exactly in ...

The issue isn't so much in creating the rules as it is combining sprites without saving extra assets. Let's just say for sake of argument I have a 16-bit mask that I want to apply to a repeating texture of 4x4 sprites per texture atlas. That's 256 assets I'd have to make per tile type, and presumably I'd have at least 10-20 such tile types that all need to be masked, let alone in combination with each other. So over 2500 assets minimum just for that system, let alone any other part of the game. Again, that's untennable. Yet I know for a fact other games implement something like this, I just don't know how they do it under the hood. If they just use straight meshes instead of built-in tilemaps or something.

Looking through the 2D Extensions, it seems like they are really only equipped to deal with single sprites rather than dynamically masked and blended sprites. That's the crux of my issue.

meager pelican
# compact plume The issue isn't so much in creating the rules as it is combining sprites without...

I'm not sure I'm following this at all, so 2cents, but one thing that came to mind is the unfortunate problems with Dependent Texture Reads and when/why you should avoid them when possible...if other solutions exist at all, that is. Varies by target platform and level too. So food for thought:
https://medium.com/@jasonbooth_86226/stalling-a-gpu-7faac66b11b9

I'd benchmark on various platforms.

thorn obsidian
#

Hey guys, anybody have a good turorial or advice on how to create a sniper rifle shot effect

#

llike widowmaker from overwatch

#

Ive created a line rendere and want to slowly decay a smoke shader along it

dusk sky
#

How to use custom shader in DOTS? My water shader should be like screenshot1, but it actually looks like in screenshot2. I followed the description in the exception and added

#pragma target 4.5
#pragma multi_compile _ DOTS_INSTANCING_ON

two lines in my shader

knotty portal
#

I want to do something but I don't know how to describe it. So the game view is all black, and behind the wall of black is a room that is unveiled whereever the player walks
if anyone knows what I'm talking about, could you send some links?

#

thats what im trying to do

compact plume
# meager pelican I'm not sure I'm following this at all, so 2cents, but one thing that came to mi...

So essentially, I'm trying to reverse engineer the way ONI does terrain tiles. From my research, I've deduced that it requires two things - modulo tiles to get the repeating texture - and a 2x2 bitmask to divide each tile up into four quadrants for handling border transitions. Each quadrant checks its neighbors for sameness like in a standard 3x3 Full Bitmask to determine which of 16 masks it should pull. Inside the mask, it applies itself. Outside the mask, it applies the neighbor, which could even be an empty tile. Effectively, this requires a compound texture created dynamically at runtime to constantly update as surrounding tiles change.

I can make this work in the Editor, but it's not persistent and thus doesn't transfer to in-game since - as far as I can tell - tilemap renderers and sprite renderers require actual asset references. I can make the modulo stuff work in game or I can make the bitmask work in game as a standalone sprite, but I can't get both to work at the same time because the result isn't saved as an asset.

I know Klei used Unity to create ONI and have actually made this work in practice, so I know it's technically possible. I just don't know what they did on the backend and no one seems to have any documentation online about it. I'm 99.99% sure they didn't save each individual combination as a separate asset, since consider how many unique elements there are in ONI. I could go through all the source code as a last resort to see what they actually did - if they used tilemaps or a custom mesh or custom shaders - but I feel like I know what the problem is, I just don't know how to solve the problem.

Moreover, I feel like this should be solvable in other contexts at a broader level of how to make masks and blending work with tilemaps without having to make a custom mesh. But I just don't know.

compact plume
knotty portal
#

Ye

#

I just learned that term

#

But I'm not sure what it is

#

Eaxctly

compact plume
#

Depends on what type of game your making and what sort of effect you want. Whether you want it around the player, based on tiles, or line of sight.

https://youtu.be/vUYZiQ3C4hU

Unity tutorial about making fog of war. Why is it different than other tutorials? Because everything is compressed to 60 seconds / 1 minute.

Project Files:
https://github.com/Keyiter/One-Minute-Unity/tree/%238-Fog-of-War

Outro music
Micro Fire - Silent Partner

▶ Play video
meager pelican
# compact plume So essentially, I'm trying to reverse engineer the way ONI does terrain tiles. ...

OK, so like what "Oxygen Not Included" did and how. This: https://store.steampowered.com/app/457140/Oxygen_Not_Included/
Maybe if you can show some shots of the types of tiles and changes you're talking about the group can chime in.

In the space-colony simulation game Oxygen Not Included you’ll find that scarcities of oxygen, warmth and sustenance are constant threats to your colony's survival. Guide colonists through the perils of subterranean asteroid living and watch as their population grows until they're not simply surviving, but thriving... Just make sure you don't fo...

Price

$24.99

Recommendations

97637

Metacritic

86

▶ Play video
#

At minimum I'd say they have "layers" logic, since they're carving away rock to get to things "underneath".

pseudo narwhal
karmic hatch
topaz grove
#

Trying to recreate a shader from blender to unity but the result is not that good

#

Here're the shaders inside blender and Unity

idle copper
weary dawn
#

I've heard parallax shaders are a lot more expensive on mobile than regular old geometry - is this true? Is it because the GPU power is less than the cpu power?

frosty linden
#

Hello. How can I reduce the dither effect when the camera is far away from the model (Hair)? She looks quite bald like this lol

hushed silo
#

Hi. I want to be able to take a greyscale map, and using a (for example 0-1 float) return a black and white (no greyscale) map where every pixel less x is black, and everything greater than x is white. What's the node(s) I'm looking for in shader graph? Thanks!

compact plume
#

I can get the tile bitmasking logic to work and the modulo tiling to work on their own in the tilemap, but this by itself doesn't look like much. The edges are all square, not jagged like in ONI:

#

I can even get compositing to work in a custom Editor along with custom color blend modes. (Excuse the crappy quality of the test sprites.) The problem is, as you can see in the video, when I update the tilemap with the dynamically created composite, it turns all the tiles the same instead of retaining their individual sprites like in the above images.

compact plume
# regal stag Step

Oh, Cyan! Fancy seeing you here. I've seen some of your shader work in your blogs. Very much a fan. ❤️

#

Anyways, returning to my question, I know in theory how ONI does their edges, I just don't know in practice how they actually executed it.

hushed silo
warm pulsar
#

are the SpeedTree8 shader's many properties documented anywhere?

#

e.g. _ST_WindGlobal

#

I have a script that sets them, but the effect on my terrain trees is oscillating too fast. I'm messing with that script, but I don't really know what any of these vector4's mean

leaden flower
#

Hey there! I'm really really new to shaders and im having a little trouble finding resources to achieve my objective.
I'm trying to render the screen with a little water like distortion, but i can't find anything to do this (in 3d, in 2d there are lots of tutorials), for now i found how to do it using a sine wave, but i'd like to use noise to make it more natural (but if i can't find a way i'll probably go with the sine wave and leave it alone).

What i have right now is what you can see in the screenshot, i apply it to a plane and put it in front of the camera, the problem is that the object in scene is displaced too much and i can't understand why...

Does anyone have any resource where i could be guided in the proper direction or could just help me? I would be REALLY grateful... :,)

First image is my shader graph, second where it is rendered and third where it should be...

rugged pecan
#

Hi

#

I made a grid map using shader graph

#

There is a weird flickering on my grid map

#

Is this a kind of aliasing?

#

Please help me to remove this.

tacit parcel
frosty linden
grizzled bolt
karmic hatch
wet python
#

Hi everyone ,I read that unity documentation 2023.3 still not fully supported to XR graphic fully and i want to know what nodes are supported "(1) Although Shader Graph shaders can run in XR, Shader Graph doesn’t currently support the XR utility feature to create SPI-compatible shader input textures. Unity will expand support for Shader Graph functionality in future releases"https://docs.unity3d.com/2023.3/Documentation/Manual/xr-render-pipeline-compatibility.html

leaden flower
leaden flower
idle copper
#

Hello, I am using Graphics.Blit in OnRenderImage() to send the rendered image of a camera through a fragment shader to add some custom post-processing. Is there a way to access the LayerMask of a pixel in that shader? If not, is there some other value I can use to give information to the shader without changing anything else? I want some objects to be treated differently in how the post processing effects are applied.

sacred stratus
#

Do unity shaders support double pressision?
Eventtho the datatype double is avaliable in shaders, there are very little things you can do with it without writing your own math functions,
when you pass in a double for example into a

fract();

function you get a waring that you might loose presision meaning that the function internaly will just use single precision,
This is not really a problem for the fract function, but with operations like sin, cos where you would like to have double precision, I don t know how to get it to work

rose shard
unborn sigil
#

Hi devs, I need help with GPU Instancing with URP and Graphics.RenderMeshIndirect.
I followed quite the number of posts and implementations and the process to make it work seems to inject a HLSL file into a shadergraph shader + a custom function for the pragma. Well actually it works, I mean I render correctly meshes BUT the shader throw an error : undeclared identifier 'unity_ObjectToWorld'
Does anyone encountered this problem or have an idea on his origin (or know the resolution) ?

#

here is my HLSL file (reduced to the minimal code to make it works) :

#define SHADER_GRAPH_SUPPORT_H

#if UNITY_ANY_INSTANCING_ENABLED

struct InstanceData {
    float4x4 m;
};

StructuredBuffer<InstanceData> unity_InstanceData;

void SetUnityMatrices(uint instanceID, inout float4x4 objectToWorld, out float4x4 worldToObject) {
    InstanceData data = unity_InstanceData[instanceID];
    // objectToWorld and worldToObject definition...
}

#endif

void passthrough_float(in float3 In, out float3 Out)
{
    Out = In;
}

void setup()
{
#if UNITY_ANY_INSTANCING_ENABLED
    SetUnityMatrices(unity_InstanceID, unity_ObjectToWorld, unity_WorldToObject);
#endif
}

#endif```
#

and my Instancing subgraph for injection :

meager pelican
# idle copper Hello, I am using Graphics.Blit in OnRenderImage() to send the rendered image of...

Not unless you keep track of it yourself. You could check if ALL your desired target platforms support MRT...and create a render texture to hold more information, and return that information on a per-pixel basis, for example. And you'd probably pass that info into the shader too....for example what layer you're on would have to be passed in IIRC.

There are some built-in methods for differentiating pixels...the stencil buffer has several bits available depending on what your needs are. You could look into that too, but be aware that lighting calcs use it too.

Short of all that, after the shader is done, a pixel is just a pixel...color, depth, and optionally things like a normal or motion vector...all stored in screen-sized buffers.

frosty linden
#

Hello, is it normal for the Dither node to render 0 (black) color ? Shouldn't it only dither when it's above 0? If it's normal, how can I make it so 0 is invisible and it only starts dithering starting 0.01?

#

I've max my cut out value to 1, if I disable dither, the hair are correctly invisible. But dither do render it. Isn't it confusing?

toxic ore
#

Hi!
I found a screenspace outline shader online and what it does is that it creates an outline by essentially stretching the object towards the corners of the screen (if the thickness is high enough, you can begin to see 4 copies of the object). While I don't mind the 4 copies, I would like to know if there is a way to kind of blend/blur them, or at least just fill in the spaces between them so that you can't tell that there are 4 copies (as can be seen in my super artistic Paint diagram below).

#

(I think the part of the shader above is where that blur should go)

thin lintel
#

hey guys very basic waste of time question but which shader graph node would allow me to scale the image texture/UV by the world size of the polygon its being rendered on? like how probuilder scales textures but instead I want to input my own image

karmic hatch
thin lintel
#

I got it now tho thanks

eager ocean
#

Hi, I have a compute shader where I've defined a static global struct, I need the values to be kept at different dispatches, but for some weird reason they reset to the default value at every dispatch. This only happens with structs, while normal global variables keep their values through different dispatches. Anyone knows what could be the problem?

thin lintel
#

hey guys, my intention here is to have a shader that simply takes a texture, scales it to worldspace and scrolls it depending on an input variable, however I'm having trouble because for some reason only two sides/polygon directions of my object are being covered. Can anyone help me?

toxic ore
dim vortex
#

getting this error when i add this to a material that my strand hair uses. the hair simply disapears. im on mac if that has anything to do with it:

Metal: Vertex or Fragment Shader "Shader Graphs/Master" requires a ComputeBuffer at index 4 to be bound, but none provided. Skipping draw calls to avoid crashing.

steep oasis
#

Yo!
does anyone know how i could make a cool Pixelated Water shader, similar to celestes water, with physics

idle copper
#

Quick shader question. I'm writing a shader where I need to sample one of 4 textures depending on some factors. What's the most performant way to do this?
I tried using some if statements to set a sampler2D to the texture I want to sample (shown below), but Unity says that the "Sampler parameter must come from a literal expression."

sampler2D _TextureA;
sampler2D _TextureB;
sampler2D _TextureC;
sampler2D _TextureD;
sampler2D _SampleTexture;

fixed4 frag (v2f i) : SV_Target
{
    _SampleTexture = _TextureA;
    if(tex2D(_TextureB, i.uv).a > 0.01f) {
       _SampleTexture = _TextureB;
    }
    if(tex2D(_TextureC, i.uv).a > 0.01f) {
       _SampleTexture = _TextureC;
    }
    if(tex2D(_TextureD, i.uv).a > 0.01f) {
       _SampleTexture = _TextureD;
    }

    float4 color = tex2D(_SampleTexture, i.uv);
}
sonic heron
#

i tried making a shader but it doesnt display on the object but on the material prewiew it shows up

sonic heron
#

yes

grizzled bolt
#

Then the brightness of the scene is orders of magnitude different from the preview render after taking into account the exposure

#

So, increase the emission intensity by a big enough value that it shows up

sonic heron
#

now it glows but from the midle out and not from out into the middle

#

● Check out Bolt: http://ludiq.io/bolt/download

The time has come... Let's explore Unity's new Shader Graph!

♥ Support Brackeys on Patreon: http://patreon.com/brackeys/

····················································································

♥ Subscribe: http://bit.ly/1kMekJV

● Website: http://brackeys.com/
● Facebook: https://f...

▶ Play video
grizzled bolt
sonic heron
#

tried it it still does the same except its dark now

#

if i turn of the directinol light it looks right

#

can i somhow render the scene without the light on top of it and make everything black invisible so that you just see the outline?

grizzled bolt
grizzled bolt
karmic hatch
#

(Tiling and Offset is designed for UVs (hence why its input is called UV), not positions, which is why it works with Vector2s)

meager pelican
# toxic ore Hi! I found a screenspace outline shader online and what it does is that it crea...
Medium

An Exploration of GPU Silhouette Rendering

burnt crag
#

Hi there. I am not exactly sure if this is a shader question, or if I am making it too complex by using a shader. I have a shader that flashes between red and white, nothing complex. I have attached that to a material, and I want to use it on my player when they get hit. I have a 3D model from Blender that I am using, and want to apply it to my player mesh. My player mesh has 12 materials on it that came over with the FBX from Blender. I don't think that replacing all those materials during run-time when the player gets hit is the right way to do this. Something feels off about doing it that way.

Can you suggest a direction for me to do this? Or could you direct me to the correct channel to ask this question in?

ember robin
#

Anyone can help me with Shader Update.... i got an Sebastian Lague Shader Shader Graph, and it cant work on new version of unity, any tips to make it work ? or REwrite ?

pine elm
#

Hi.

Does anyone have any inspiration / tutorials of how to do water shaders for a top down tile base grid? Most google searches i find are for sidescrolling games.

So far i've been inspired by this https://www.youtube.com/watch?v=nG8OU1GwMtk But i wonder if anyone utilized some other cool effects?

I like to keep things simple - my water shader is just another tile in the tileset... with a little bit of jiggle.

#GodotEngine #GameDev #PixelArt

Join my Discord: https://nathanhoad.net/discord

▶ Play video
grand jolt
#

What the heck, I just found out shader functions can assign values to static variables and this value will persist for further function calls.

timid shell
#

Maybe someone can help me with this. I have a few diffrent meshes that are rendered using instances of the same material. Each material instance has it's own instance of the same _BaseMap texture. At runtime these textures are modified, but only using the model UVs as a mask. Now I want to combine the pixel data from all these textures into a single one, using the models UVs as masks. The end result should be that each model looks the same as before if used with the combined texture. How can I achieve this?

regal stag
dusk sky
#

Why my water surface shader doesn't work in subscene? The frame debugger shows that my shader is used when drawing transparent objects. Also, once I change the render queue in inspector, it appears. But if I enter play mode, or do something that let unity reload, it disappear again. Anyone know why?

#

Btw, if I put my camera inside the subscene, it seems that the camera just stops rendering.

viscid vector
#

I get this error what should I do?The Visual Effect Graph is supported in the High Definition Render Pipeline (HDRP) and the Universal Render Pipeline (URP). Please assign your chosen Render Pipeline Asset in the Graphics Settings to use it.

tame topaz
#
  1. Choose a pipeline you want to use (research the difference between URP and HDRP)

  2. Set up that pipeline (guides are pinned in #archived-hdrp and #archived-urp )

  3. You can now use VFX Graph

viscid vector
#

thanks 😀

olive brook
#

hey. how do I change normal intensity? I know we can use UnpackScaleNormal and pass in the normal intensity directly, but my question is how to do it manually. just wanted to learn is all

#

any link etc is also very appreciated

karmic hatch
olive brook
#

ah, thanks!

karmic hatch
#

i think if your normals are based on a heightmap, that's mathematically equivalent to stretching or squeezing it

olive brook
#

I see. I think these normals are indeed based on hightmap. not sure though. will try the formula

#

worked like a charm

#

thanks again ❣️🙏

vestal hearth
#

hey, is it possible to reference properties inside subgraphs? id like to avoid duplicating the same property in multiple shaders that use the same subgraph

karmic hatch
elder pivot
#

was looking at acerola video about water and see that on the top it looks like great water...however on the underside its just "blank"

#

how would you "show" the water on the bottom-side also?

#

is it even possible to show on both sides of a mesh?

elder pivot
#

(pretty new to anything 3d and things like this so sorry if dumb Q)

regal stag
regal stag
elder pivot
regal stag
# elder pivot

It goes under the Pass, not Properties. The link provides some example code

elder pivot
elder pivot
#

but just putting it under "subshader" worked

#

why would it error when under pass?

#

(I see both used in the example code)

regal stag
#

It should work under either. When under SubShader it sets the culling for all passes. While under Pass it's just for that particular pass.

elder pivot
#

interesting...thanks!

viscid vector
#

I changed to hdrp and my skybox gone black how can I get it back?

knotty bough
#

Anyone here interested in taking a quick one off task to help us convert a simple Unlit Sprite Shader Graph shader, to a UI compatible, maskable, HLSL shader? Compensation available at standard US rates.

lunar valley
#

no

echo moatBOT
devout coral
#

whats up with the stretching object position node plugged into gradient noise uv and result into base color why that results in this

karmic hatch
devout coral
#

can I avoid this?

karmic hatch
#

You can download an add-on to get 3D noise (e.g here)

devout coral
karmic hatch
#

yep

steady lintel
#

Anyone wanna try to take a crack at this?

honest bison
#

How do I include random tree color in a custom shader?

#

I have a URP shader with _TreeInstanceColor input

#

Do I need to do more?

final frigate
#

Hi,

I have the following shader graph which is generating me a deformation on a sphere.

The issue im seeing is that some of the edges in the sphere are coming up, I think its something to do with normals and nearest neighbours that I can adjust and average out but im currently running blank.

anyone able to point me in the right direction for this.

simple galleon
#

i made outline shader graph, but my problem is like it. how can i solve it?

regal stag
# simple galleon i made outline shader graph, but my problem is like it. how can i solve it?

There isn't a way to fix this in the shader. Inverted-hull outlines requires the mesh to have smoothed normals rather than flat.

Or at least provide smooth normals in an unused UV channel / vertex color if you still want flat for shading. Might be able to handle that in modelling software, or can calculate from C#, probably using an AssetPostprocessor like this https://gist.github.com/runevision/6fd7cc8d841245a53df5d09ccf6b47ff but swap mesh.normals out for mesh.SetUV 🤷

simple galleon
#

and swap mesh.normals to mesh.SetUVs(0, normals);

regal stag
simple galleon
daring aurora
#

what "LinearEyeDepth" function does in shader?

karmic hatch
karmic hatch
final frigate
karmic hatch
#

If so, you might need to manually recalculate the vertex normals and tangents

daring aurora
#

Is the function part of UnityCG.cginc?

#

I tried searching online, couldn't find any answer.

sly breach
#

anyone knows any good tutorials / resources about CommandBuffer and custom shaders to paint on textures ?

clear fossil
#

Does anyone know if there is a way to get Unity's UI to render at a specific depth? The Internal-UIRDefault.shader has ZTest GEqual. This causes problems when I disable depth clear on the Panel Settings, I cannot have the depth cleared and need UI to render on top of the world regardless of depth

dim marsh
#

hey so i made this shader that like, fixes alpha blending (Check image for explanation). I didn't add support for using sprites to alter the "shape" of the object (check other pic) when i made the shader which resulted in the object taking the shape of its collider, but I need to add this now. I tried to implement it by simply multiplying the output by MainTex.a, but that results in some weird transparency glitches that neither I nor chatGPT know how to fix. Please help me.

#

holy shit that's a wall of code

#

let me fix that

#

there

grizzled bolt
regal stag
# dim marsh

Stencils will write based on all fragments/pixels produced by the mesh. If you want to exclude the fully transparent parts of the sprite texture you could use alpha clipping. e.g. clip(col.a - 0.01);

regal stag
clear fossil
ruby bolt
#

Hey, I have a question. I'm trying to make a shader, that would make everything behind a plane slowly fade. This is what I've achieved so far, but I have a question, is it somehow possible to make it nicely blend with the skybox, and not a pre-set color? If yes, how would I do that?

grizzled bolt
ruby bolt
#

hm. And how should I sample it? From the cubemap or somehow else?

#

not gonna lie, shaders are still kinda black magic for me

rain parrot
#

I'm trying to make a shader to simulate water depth based off of the distance from a ruletile's edge.
My current approach is to use a custom Gaussian Blur subgraph to blur the white edge of the water's sprite and use that as the lerp value between two colors. However the blur subgraph doesn't work well past the first tile in a tilemap. It results in hard edges.
Any thoughts on an alternate approach?
Gaussian Subgraph - https://forum.unity.com/threads/urp-sprite-gaussian-blur-customer-subshadergraph.1327968/

ruby bolt
# ruby bolt Hey, I have a question. I'm trying to make a shader, that would make everything ...

thinking of it, would it be possible to somehow override the alpha value of whatever is rendered beyond the plane? Like, whatever is showing up as black here - make it have alpha = 0, and similarly for the gradient. Not sure if what I'm saying makes sense, but what I'm thinking of, is that this could make things slowly fade until they completely disappear.
Ofc I don't mean a transparent material, I mean making a shader that affects whatever else is visible beyond it.

tacit parcel
# ruby bolt thinking of it, would it be possible to somehow override the alpha value of what...

This would be complicated since skybox usually drawn after opaque
But maybe you can render a skybox using second camera into a texture and draw it as background image then, when drawing the opaques, use a grab pass and blend the grabbed pixel with the road pixel. Complicated and unnecessarily heavy when simply blending opaque and skybox in one pass as mentioned above would do just fine.

I mean making a shader that affects whatever else is visible beyond it.
btw, this basically what transparent means

dim marsh
#

would that just go inside of the fragment shader? or

grizzled bolt
ruby bolt
ruby bolt
grizzled bolt
#

If your sky is a procedural shader, you can make it a subgraph in place of sampling the skybox texture

#

Either way it simply outputs a color for doing whatever you need with it

#

Using the reflection probe node is simpler but it prefers reflections over the sky which doesn't look right if you have probes, and isn't as high resolution as the real sky

spiral bay
#

Guys is there a way with ShaderGraph to disregard the UV of a mesh?

#

I have this model, here and a section of it is using a grid shader I made. Except it's moving in different ways.

civic dune
spiral bay
#

See the arrows. The top one is moving away from the screen, Z+. The bottom one is moving top-to-bottom, Y-

#

I want them to move at the same direction, and more so, these are blocks that will make corridors (I'm going to combine them at runtime), so I want them all to match.

civic dune
#

Ah, and you cant just fix the direction of the uv's on the mesh itself?

spiral bay
#

Well I could, but the generator might rotate them.

#

What I want is basically the shader to take the whole space and do its work, no textures, no UVs

civic dune
#

you could use a triplanar node and rotate the uv's 45 degrees in the z axis so you dont get a blend

spiral bay
#

Let me see if that works. I don't know what that is, but I'm gonna check.

grizzled bolt
#

Ensuring the UVs are right in the first place is by far the simplest option

civic dune
#

yeah, I agree wuth Spazi, if they need to flow better you need to control how the meshes are oriented when generating, or create variants maybe?

spiral bay
#

I guess that's what I'm going to have to do, then. Because I can't seem to fit TriPlanar, since I'm using a generated texture

civic dune
#

why are you avoiding sampling a low res grid texture, will be cheaper than generating one usually

ruby bolt
grizzled bolt
spiral bay
#

And have all the generated textures fit nicely and seamlessly

grizzled bolt
ivory cobalt
#

I'm using the following in my shader: ```
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"

...

uint meshRenderingLayers = GetMeshRenderingLightLayer();

and getting the following: ```
undeclared identifier 'GetMeshRenderingLightLayer' 

It worked fine in an older project, but here the function seems to be missing. Was it moved/removed?

#

It used to be defined in RealtimeLights.hlsl

#

oh I just found this

dim marsh
sly breach
#

anyone knows about command buffers ?

#

what does DrawRenderer do ?

low lichen
dim marsh
#

Even when alpha is 1

#

NVM this no longer happens

sly breach
# low lichen Draws the renderer mesh with the transform and material of that renderer.

I'm trying to understand what stages actually move the texture data , for example i have the following

maskRenderTexture = new RenderTexture( texIndex.width , texIndex.height , 0);
maskRenderTexture.filterMode = FilterMode.Bilinear;

Graphics.Blit( texture_from_material , maskRenderTexture);

paintMaterial.SetVector(positionID, pos);
paintMaterial.SetFloat(hardnessID, hardness);
paintMaterial.SetFloat(strengthID, strength);
paintMaterial.SetFloat(radiusID, radius);

command.SetRenderTarget( maskRenderTexture );
command.DrawRenderer( rend , paintMaterial , 0 );

command.SetRenderTarget( rendTex1 );
command.Blit( maskRenderTexture, rendTex1 );
#

can i add another command of rendTex2 directly below ?

#
command.SetRenderTarget( rendTex2 );
command.Blit( maskRenderTexture, rendTex2 );
low lichen
# sly breach can i add another command of rendTex2 directly below ?

You're adding these commands into a queue, and they will be executed in the order you add them. maskRenderTexture will have been drawn to by the DrawRenderer command by the time another command after it is executed. Whether any pixels are actually written to depends on your vertex shader.

dim marsh
#

Here is the shader:

ivory cobalt
#

Playing with deferred rendering and getting these weird artifacts. Any ideas? It seems to be caused by the ShadowCaster pass so I'm guessing the mesh casts these weird shadows on itself

amber saffron
#

You can probably fix this by tweak the shadow biases on the light

ivory cobalt
pastel nebula
#

I made this with shader graph. I want to animate the level value. ANy help?

lunar valley
pastel nebula
#

I want the green color to increase with animation as the level value rises

lunar valley
ivory cobalt
#

Is there a way to create custom deferred shading models in URP without modifying the StencilDeferred shader in URP's source code?

past root
#

Can shader graphs be exported to older versions of unity from before shadergraph?

ivory cobalt
regal stag
regal stag
past root
#

Dang okay

#

Thanks for the info

ivory cobalt
dim marsh
dim marsh
#

I would, but the shader already has a stencil, and i can't give the outline its own pass because it needs to work in URP

#

And URP doesn't support multipass shaders for whatever reason, so I can't add another stencil operation

full tapir
#

only two tho, no more from what i heard

dim marsh
#

How do i do that?

full tapir
#

this is not mine, just searched google

#

explain a bit about lightmode

dim marsh
#

This did not work sadly

#

I've just found another issue which makes everything even worse, because for some reason using stencils in a shader seems to break SpriteMasks

#

As you can see the sprite masked apple is rendering through the outlined object (Which is not supposed to happen at all)

#

And the sprite mask also seems to affect the outlined object itself

#

This is weird

pale python
#

Hi ,
i'm trying to make gradient noise using fragment shader and I kinda did, it's kinda working but I can see the UV squares on the shader, is that normal ?

#

I'm new to shader in general but is it normal to see those uv squares along the shader ?

#

the pattern is a bit clear, i dont know if u can see it or not so i've highlighted them

lunar valley
pale python
#

nvm I think I fixed it

sterile rain
#

yo guys. does anyone know a good guide on how to make cel shading

#

i don't know nothing at all about dealing with shaders.

grizzled bolt
sterile rain
#

i'm really looking forward to know unity system as much as i can

sterile rain
grizzled bolt
grizzled bolt
# sterile rain also, can you give me a video or something to teach me something about it?

If you work with URP and like to learn by making stuff, I'd say look for Shader Graph beginner tutorials and get cracking until the system starts making sense
If you want deeper and more theoretical understanding of what's going on and aren't afraid of studying, try these:
https://halisavakis.com/shaderquest-part-1-graphics-concepts/
https://youtu.be/kfM-yu0iQBk
They go through the same stuff but one's in blog format, another as VoD

sterile rain
#

damn bro 3 hours 💀

#

i'll try to watch it lol

devout coral
#

https://www.youtube.com/watch?v=7qtrJBG-KOs is this same shader technique repeated and blended over and over? If so anyone got a very rough guess of how its made? Especially how all this noise is perfectly mapped onto a sphere

pale python
#

Hi,
is it possible in anyway to save the "add operator(+)","subtract operator(-)" & "multiplier operator(*)" in a variable ?
I wanna make dynamic shader without adding branches.

for example Lets say we have 2 output of 2 different functions A and B , and lets say the add & subtract operator, are the result of function called op(float x ) , where if x was bigger than 0.5 the results is ADD else SUBTRACT , and the results is safed on var C

I wanna be easily right code like float final = A * C * B >> if C was ADD then the result would be A+B , else A-B

is it possible to do something like that ?

daring aurora
#

Is there any way to preview screenspace shader on scene view? (not using post processing stack)

grave vortex
drifting osprey
#

Okay guys, I hope someone has tried this before in the core pipeline; I've spent way too many hours in trying to create the perfect exhaust heat effect, which thankfully has been made easier by a distortion shader being introduced in the default unity particle shader options. the effect is near perfect except for one missing detail that would make it complete. does anybody know if it is possibly to add a blur effect to refraction shaders in the Core pipeline of Unity? the distortion looks nice, but usually there's a blur within the hottest of the heat distortion particles. I know it's possible to add that blur in HDRP, however can I apply whatever shader coding enables the blur also in a non-HDRP particle effect? on the right is an example of the blur I used in HDRP that I wish to concert into NON-HDRP to the left. if anyone of you can help me, please ping/reply/DM me! thank you.

#

this is the current setup of the particle shader

pale python
#

hi ,
i wanna ask about how things work , what is the right approach to do things.

lets say I have a function that creates a white ring at the distance of my choice ( alpha ring )
how do I (add) rbg ring to a float4 color(1,1,1,1);?

#

is it float4 fin = color.rbga + ring.rbga; ? would that results 1 color overlapping the other since one alpha is just a ring ?

regal stag
#

Assuming the shader is transparent so the alpha output is used

daring aurora
#

Btw I found the solution.

#

Adding the attribute [ImageEffectAllowedInSceneView] above the class fixed the problem

idle copper
#

I'm writing a shader where I need to sample one of 4 textures depending on some calculations. What's the most performant way to do this?

I know I could use if statements, but I'm not sure if this would be very performant as I need to sample the textures many times. Here is a simplified example:

sampler2D _TextureA;
sampler2D _TextureB;
sampler2D _TextureC;
sampler2D _TextureD;

fixed4 frag (v2f i) : SV_Target
{
    float4 color;
    if(someValue > 0.03f) {
       color = tex2D(_TextureA, i.uv); //Do this a lot
    } else if(someValue > 0.02f) {
       color = tex2D(_TextureB, i.uv); //Do this a lot
    } else if(someValue  > 0.01f) {
       color = tex2D(_TextureC, i.uv); //Do this a lot
    } else {
       color = tex2D(_TextureD, i.uv); //Do this a lot
    }

    return color;
}
pale python
tender edge
#

is there an easy way to get rid of those weird backgrounds?

regal stag
# pale python hi, thanks for responding , but that's not what I meant , the end result is supp...

You'd likely use two circle SDF functions to make this. e.g. step(0, distance(uv, float2(0.5,0.5)) - radius) (or possibly with step params swapped or 1-result if it's inverted)
Use a circle with a larger radius as the alpha output to make the outer part transparent.
And use a smaller circle as the t input of a lerp to create a white circle on a red background.
e.g.

float4 color = lerp(red, white, innerCircle.xxxx);
return float4(color.rgb, outerCircle);
regal stag
tender edge
pale python
hollow wolf
#

anyone know how to masking using 2 position of gameobject?

simple galleon
#

In 2D, how do I hide areas of Sprite where the brightness is below a certain level? I mean... Just like Among Us' vision system. I want to solve this using 2D Light & Shader Graph.

white swan
#

hi,
does anyone knows how combine two shapes while keeping both of their color and alpha properties ?

#

lets say
shape1 : is a ring ( outter circle ) color is yellow
shape2 : is a solid circle ( inner circle ) color is white

how do I tell shader to return both properties without mixing them ?
i tried shape1+shape2 but i ended up with a larger circle instead of a white circle with a yellow edge

regal stag
regal stag
grizzled bolt
#

Just be sure to use Screen Position UVs when sampling it

grand jolt
#

Hi there! I need help I want to show two or more textures in one object like upper area has one texture than lower area has another texture in pattern idk how to do it pls help

#

bassically something like this, do I need two materials for this or two shader for this idk

simple galleon
grizzled bolt
simple galleon
#

defalut result is same

#

it still seem circle

simple galleon
grizzled bolt
#

I feel like the UV coordinates for 2D Light Texture may have changed at some point since I vaguely recall not having to use the Screen Position node long ago

#

But 2021.3. is already old

simple galleon
grizzled bolt
simple galleon
#

2022.3.8f1

grizzled bolt
simple galleon
drifting osprey
toxic ore
#

Hi! I am passing a texture through a Sample Texture 2D LOD node and then through a Step node. I want to add a bit of noise to the result but I am not sure how to change its UV since it's an RGBA and not a texture. Is there any node for that?

nimble dirge
#

I created this shader and now when i start the game, itfreezes for a bit then plays as normal, is there a way i can bake it like in blender so that it reduces load time?

regal stag
spring fox
#

anyone else having these issues with cyan's shadergraph custom lighting? when i try to add the _LIGHT_COOKIES keyword and enable it, it doesnt work at all and these errors start showing up

regal stag
nimble dirge
#

i read somewhere that voronoi is expensive so i assumed it was having an effect on my game

spring fox
regal stag
spring fox
#

Ive tried that already

#

it might be directx

#

d3d11 showing up in the console alot

#

nope

#

same error

#

augh it was working before sorta

#

i had cookies working on one material

#

now it doesnt work on any

#

i got it working !!

#

there was a duplicate keyword for light cookies that was messing it up

toxic ore
#

On another note, is there any way to get more lighting information other than the direction on Shader Graph such as the light's intensity? Or should I make a property for it and update it through code?

devout coral
#

is it possible to feather out random intermediate node like this one like where white meets black it would bleed into it

karmic hatch
#

but the easier way is to build it into the function that gives you your pattern

lean lotus
#

hey is there any way I can do an InterlockedOr in a fragment shader on a RWTexture3D<uint4>?

white swan
#

what is the equivalent to shader graph's (Normal vector) and (Normalize) node in fragment shader unity ?

white swan
#

is there is any shader graph to fragment shader converter ?

grizzled bolt
white swan
tacit parcel
regal stag
# white swan i do understand that , but im not sure what is the equivalent to shader graph's ...

You obtain the normal vector using a variable with the NORMAL semantic in the vertex input struct (usually Attributes/appdata).
That'll be in object space. If you need other spaces there's functions to convert it. Depends a bit on the pipeline. e.g. URP/HDRP there is float3 normalWS = TransformObjectToWorldNormal(normalOS);.
To normalize, can use normalize(vector) (though if you use the above function it'll also normalise for you)

regal stag
grand jolt
toxic ore
karmic hatch
tight phoenix
#

how can I hide obvious color banding in my shader gradients? the net says 'Blue Noise' but when I try to implement blue noise it just looks like muddy pixelated garbage

#

my eyes are picking up very clear banding rings in this, especially at the outer most edge, I want to hide that banding

grizzled bolt
tight phoenix
grizzled bolt
tight phoenix
grizzled bolt
#

Shader generated gradient here

#

It also uses rapidly animated blue noise from the looks of it

tight phoenix
#

Hm yeah for you I can't see the banding on on the right, but for me in game view, game is playing, dither set to On, the banding is still pretty noticable

#

aproximately

#

is it maybe my shader is the problem?

karmic hatch
vast pumice
#

Hi, I am making a marble texture for my video game map. How would I make a procedural texture in the unity URP shader graph like this texture? I have inverted the Voronoi texture and added a simple noise texture but I have not gotten the look I want.

karmic hatch
plain urchin
#

Hi all
I have a typical leaf card cutout texture, and model of trees with many of these leaf cards
Is there a way for the entire vertex of a single leaf card mesh to know where the "leaf branch pivot vertex" world position lies?

vast pumice
visual parrot
# karmic hatch

Woah, I’m gonna use that tool in the future. Thanks for the link!

vast pumice
# karmic hatch

Yeah problem is im only comfortable with shader graph really im animator not a coder I can change the values at the top but doesnt give me enough to work with

vast pumice
austere pier
#

playing with outlines on my models. Hoping to figure out a way to get a cool rim lighting effect like vagrant story. Is this possible?

latent hound
#

How bad of an idea is it to have a water shader output it's height and normal values into a render texture and then sample single pixels with AsyncGpuReadbackRequests for things that should swim? 😅

radiant bobcat
#

Does anyone know how to fix the problem, that only on mobile devices, some shaders/materials appear black?

vernal idol
#

Found their concept

austere pier
#

I might try that for fun, what's the best way to do that within Unity?

toxic ore
meager pelican
# austere pier playing with outlines on my models. Hoping to figure out a way to get a cool rim...

✔️ Works in 2020.1 ➕ 2020.2 ➕ 2020.3

Rim lighting is a shading technique that highlights the edges of a model. It's useful to add a moody atmosphere or help an object stand out from a dark background. This effect gets the main light in a custom function node to emphasize the shadowed side of a model.

👋 Subscribe for weekly game development vid...

▶ Play video
vivid wing
noble wave
#

does anyone have an idea how to fix the behaviour I'm struggling with the shader I coded? I'm not using a pipeline/using the default. I was trying to make an outline shader, but for some reason, when I apply it, it overrides everything and sits in front of other sprites. On top of that, it also drags a transparent shadow over the other sprites

vocal narwhal
#

You should modify the sprites-default shader (or use Shader Graph), not make one from scratch. You can find the Built-in Shaders in the downloads dropdown for your release https://unity.com/releases/editor/archive

wicked niche
#

Hello, please tell me, what should I add so that the texture that I apply can be tiled?

#

The problem is that in the UnitySprites.cginc file in the v2f structure there is no uv field

wicked niche
regal stag
# wicked niche

You want to use o.texcoord rather than uv. (It's the TEXCOORD0 variable that's used to sample the main texture, can be named whatever, but I imagine the fragment shader here expects texcoord)

Also make sure the Wrap Mode is set to Repeat in the texture import settings, or it'll just stretch the edges of the texture.

regal stag
wicked niche
regal stag
# wicked niche why do need to use texcoord0 instead of uv coordinates?

texcoord and uv are just variable names, they can be named anything but as you're using the SpriteFrag fragment shader from UnitySprites.cginc, that is written to expect IN.texcoord.

You must use TEXCOORD0 in the vertex input struct (appdata) to obtain the first uv coordinates channel of the mesh. If you use TEXCOORD1, that's the second uv channel (which sprites usually don't have afaik)

royal pier
#

I have a shader where I put on a specular,normal and diffuse to have a metal plate with holes. Also an y cutoff alpha. I found some random textures which suited it. I have never created tga files myself. How should you edit these tga files so the cutouts are circles instead of squares?

#

I tried photoshopping the squares to circles, but it didn't work 🙃

regal stag
royal pier
#

That explains why it looked so odd

#

I guess maybe I should just try to find a new material with circles. Hope it works if I overwrite the textures

drifting osprey
regal stag
royal pier
#

I tried that, but only with like 5 circles. Maybe I should edit them all and then try again

regal stag
# drifting osprey Please refer to the post that this is a reply to... I found both the HDRP shader...

That shader file on the right is already compiled. You probably want the source itself. e.g. https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/DefaultResourcesExtra/Particle Standard Unlit.shader (or download the built-in shaders from Unity's site, see #archived-shaders message)

Even with the source it'll probably be difficult as HDRP has a different core ShaderLibrary so most of the functions won't be available. You'd need to find wherever they are and copy them.

I think it would be easier to find a built-in rp example of blurring. It typically requires sampling a texture multiple times with some offsets, then averaging (or using a specific convolution)

drifting osprey
regal stag
drifting osprey
#

okay, but where am I supposed to plunk it wthin the shader code?

karmic hatch
regal stag
drifting osprey
#

also how do I copypaste a built-in unity shader?

regal stag
regal stag
drifting osprey
#

ah my bad

#

misread that

drifting osprey
#

because if so it is only used by the player, meaning it's almost unlikely that anything besides objects that the player uses, also uses that effect

regal stag
# drifting osprey expensive as in render heavy?

Yea I was referring to performance wise / longer to render frames (mostly gpu side).
The grabpasses have a cost as well as the overdraw from two additional passes (is drawing those pixels again). One of the passes could probably be merged into the main pass of the particle shader but that'll require shader coding knowledge.

drifting osprey
#

welp, I clearly did something not entirely according to plan.

#

lighting effects start causing this visual artifacting

#

we're getting somewhere

#

okay so something is likely set up wrong in how the code is layered.

royal pier
pine elm
#

Hi. I've made a wind shader following this: https://www.youtube.com/watch?v=Ctbqax1XRiE I do not use the External Influence part since i'm using the shader on trees. I have a weird issue with some of my sprites. The animation Jumps based on world position.

Now my initial thourght was it had something to do with the offset we use to vary the animation based on its world position. But if i remove that node from my shadergraph it still persists. Does anyone have an idea what the issue might be?

Join our Discord Community! - https://discord.com/invite/aHjTSBz3jH
Show your Support & Get Exclusive Benefits on Patreon (Including Access to this project's Source Files + Code) - https://www.patreon.com/sasquatchbgames
Wishlist Veil of Maia! - https://store.steampowered.com/app/1948230/Veil_of_Maia/
Wishlist Samurado!
https://store.steampowere...

▶ Play video
#

Interactive Wind Shader for your Foliage...

ancient cradle
#

hi all, can anyone help me pls? why scenecolor node on URP 2022.3 on unlit base color show me grey texture? Depth and opaque texture settings are active

regal stag
# ancient cradle

Is this with 2D Renderer? I'm not sure it creates the opaque texture (as sprites tend to be in transparent queue anyway)

#

Might be able to use a custom renderer feature to blit the screen to your own target & set _CameraOpaqueTexture. But then any shaders that sample it needs to be rendered after that feature executes.

warm raptor
#

Hello!! is it possible to combine Occlusion shader from VR with dissolve shader? (URP)

brittle cipher
#

im trying to make water but neither transparency nor refractions seem to work the way anyone is showing, despite the graphs looking pretty much identical to others, is there anything blatantly simple im doing wrong and am big dumb dumb? (2022.3.9f1) (URP)

lunar valley
brittle cipher
lunar valley
brittle cipher
lunar valley
#

ok good, I guess can I see the shader then?

brittle cipher
# lunar valley ok good, I guess can I see the shader then?

well im planning on basing it on binarylunar's water shader (wont be able to ask that creator for help since he doesnt seem to reply to questions) so these two are lerped together with the foam (which seems to be the only part that fully works atm)

#

trying to reverse engineer it but idk, doesnt seem like it is an issue with version either since i loaded another project in unity 2021 instead of 2022 and it didnt work properly either there

heady obsidian
#

what are yall using for an ide for hlsl

regal stag
fossil cloak
#

Hey all,
i want to create some kind of "Hologram" Effect in Unity.
I want to add several geometric Objects and only render there contour.
Does anyone done this? I was thinking about using a Linerenderer for this, or a shader that only renders the contour. But im not sure if this is usefull / possible.

brittle cipher
fossil cloak
#

Hey all

warm raptor
#

Hello, im trying to create a portal opening like effect. so for this i need 2 things occlusion to hide the front of the portal & 2nd a dissolve effect that fades out from center to outwards. So far i am able to get achieve both but separately for occlusion im using VR's occlusion shader but i dont know how to connect the dissolve effect to occlusion.

what i want is the occlusion dissolves from center & spread outwards

lunar valley
drifting osprey
toxic ore
#

Hi!
I made a render pass that takes a render texture of the screen and passes it through a shader. It works mostly fine but the first thing the texture goes through is a couple of Sample Texture LOD nodes and changing their LOD value makes no change on the scene but it does in the shader graph. How is that possible? What might be going wrong?

cosmic prairie
#

might wanna call GenerateMips manualy when you render the pass

#

also, this doesn't work on all platforms, you might wanna downscale the texture manually depending on platform

pale python
#

hi , what is the function for Shader graph's "view_direction_node" ?

pale python
#

also what is the equivalent for those in fragment shader ?

karmic hatch
pale python
karmic hatch
median siren
#

How do I learn fragment/vertex shaders? Either I'm googling wrong or there's very little information/documentation on it, I went through the basics here https://docs.unity3d.com/Manual/SL-VertexFragmentShaderExamples.html but it's still really confusing. I tried making a face flattening shader but that didn't work unfortunately. What should I do?

pale python
cosmic prairie
leaden echo
#

Hiyo everyone! Just joined this server, and I'm excited to be here 😄 That being said, I have a question about programmatically adding shaders to a game object - I am checking if the renderer.materials list contains a material of a particular name, and if it doesn't exist, then to add that material. The issue is, once the material is added, it's name changes from DepthOcclusionShader to DepthOcclusionShader - Instance. Does anyone have any suggestions as to how to go about assigning a material to gameobjects that don't already have them at runtime? (also, if I'm asking this question in the wrong place, please point me to the right spot ^_^)

cosmic prairie
leaden echo
#

Thank youuuu!

cosmic prairie
#

Also make sure that you don't change material values in edit mode as that could create instances too 😄 instead use a material variant that you can check against in the script 🙂

leaden echo
#

🤯 so much to learn - thank you for pointing me in the right direction!

cosmic prairie
#

no problem! 🙂

toxic ore
#

Is there any way to ignore the camera background on Render Textures? Or maybe manipulate the shader to remove the background (solid color)?

pale python
#

hi ,
im getting "undeclared identifier 'TransformWorldToObject'" , not sure what i need to include in the fragment shader to use the function ?

#
#include "HLSLSupport.cginc" 
#include "UnityCG.cginc"

I already have both of them , do i need to pass the function somewhere ??

toxic ore
#

I don't know much about writing shaders but for some reasons Unity gives tons of errors when writing shaders (in HLSL at least) even when everything is ok so it might be because of that. If the shader works, you can ignore the errors.

pale python
#

I've also commented out HLSL and the error didnt change at all

#

something is not right

#

here , someone test it out please

Shader "test/simple" {
    Properties{
    _Color("Color", Color) = (1,1,1,1)
    }
        SubShader{
        Tags { "RenderType" = "Opaque" }
        LOD 200
        Pass {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag

        #include "UnityCG.cginc"

        struct vertIn {
        float4 vertex : POSITION;
        };

        struct fragOut {
        float4 color : SV_Target;
        };

        float3 normalWorld;
        float3 normalObject;

        void vert(in vertIn v, out fragOut o) {
            o.color = float4(0, 0, 0, 0);
            normalWorld = normalize(cross(float3(1,0,0), float3(0,1,0)));
            normalObject = TransformWorldToObject(normalWorld); //undeclared identifier 'TransformWorldToObject' at line 29 (on d3d11)
        }

        void frag(in fragOut i) {
            
            }
            ENDCG
            }
    }
        FallBack "Diffuse"
}
#

||undeclared identifier 'TransformWorldToObject' at line 29 (on d3d11)||

#

I'm using URP , is it not available for this pipline ?

cosmic prairie
#

URP functions are separated over many files now sadly and it's tedious to find where each and every thing is

#

most things you'll need will be in Packages/com.unity.render-pipelines.core/ShaderLibrary
and in Packages/com.unity.render-pipelines.universal/ShaderLibrary
I think

#

And you'd probably wanna get rid of UnityCG.cginc include

#

If I remember correctly that's no longer used

#

see what and how it works

#

it's really hard to customize some parts currently, they are working on block shaders which should make it easier in the future

#

if you need a simple unlit shader it's way easier

#

you'd still wanna dig around in includes of includes tho, they do this silly thing where they separate the passes into includes #include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitForwardPass.hlsl"

#

I don't even know how they write these things

cosmic prairie
#

What's your overall end-goal? 😄 There may be a simpler way to achieve

toxic ore
#

There is a single, opaque object in the scene, on its own layer. There is a Render Feature on the URP Asset which does 3 custom passes. The last pass is the one which I mentioned earlier which goes through an LOD texture and the color of the background is interfering with the shader effect as, after the LOD node I have a step node, and if the background is light enough, it is considered by the step node, causing the whole screen to take the effect that I want to apply just to the object.

split rain
#

is there a way to clamp shader properties between specific values?

tardy crypt
#

Hi, I had a question about a specific tutorial and wanted to see what my options were. I was wanting to find a nice stylized looking cloud flooring for a part of a project and came upon this tutorial: https://www.youtube.com/watch?v=Y7r5n5TsX_E

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
#

But he makes a mesh with 100,000 polygons and that sounds extremely expensive?

#

I was curious about what a feasible polygon count I should be looking for is or if I should be looking at other options, etc.

#

Like, what's the best way to optimize this into a feasible option?

grand jolt
#

Hey everyone im new to shaders in unity! And i was wondering why my material has this weird grey tint

toxic ore
royal pier
#

Does anyone know if there is a simple way to make sure the top has a layer as well? It is happening because of an y cutoff which is requried for this. Should I just place a plate on top of it?

karmic hatch
karmic hatch
grand jolt
#

That's what I figured @karmic hatch after messing with alot of the HDRP settings I've come to the conclusion it's something to do with the material unfortunately the textures that were included with the model didn't have a normal map so I'll have to produce one then test it. Thank you!!

white swan
#

hi ,
i was told that shader graph creates a fragment shader file, is this true ? can I see it ?

regal stag
white swan
#

hi, I'm trying to follow this tutorial , which at this time i should be able to see some results but in my case i got nothing at all , even though I did the same thing https://youtu.be/Uyw5yBFEoXo?t=265

Let's see how we can make an object glow when intersecting geometry around it. Very useful technique for shields, barriers, force fields, among other effects!

00:00 Intro
00:37 URP Setup
01:00 Scene Depth
02:26 Screen Position
03:40 Intersection
04:50 Color
06:42 Render Face
07:11 Intersection Shader - Noise Example
07:34 Intersection Example ...

▶ Play video
#

here is my shader graph

#

and here is the ones that was used in the tutorial

#

it worked for him like this

#

yet mine had noo effect or whatsoever

#

does anyone know why it didnt work for me ? is it a hardwear issue ?

regal stag
white swan
#

the tutorial mentioned it at the beginning

#

I'm doing that on an older pc with intel graphic card , could that be the reason ? although it handles lots of graphics.

regal stag
white swan
regal stag
#

What material is the cube using? Is it an opaque one

regal stag
#

Surface Type : Opaque?

white swan
regal stag
#

Hmm, did you save the graph? (Save Asset button in top left)

white swan
regal stag
#

I don't need it, just trying to cover all possibilities. Not sure what else could be the problem

white swan
#

i cant think of anything

#

nope :/

karmic hatch
white swan
#

I can see the effect on the object when it hit the camera though and only on the camera view

karmic hatch
white swan
#

if anyone got the time you could just recreate it and test it out and if it worked maybe share the whole project with me to test it on my side and compare it with the one I already have because Im out of options :S

#

i used the URP 3d template for this project

latent hound
#

How bad of an idea is it to have a water

wicked niche
#

How to get Tilling variable from MainTex?

split rain
karmic hatch
karmic hatch
# split rain ?

The graph inspector; click on the property in the blackboard and open up the graph inspector and you'll be able to edit the default value of the property and make it a slider and so on

split rain
#

thank you bro sorry I'm stupid 😭

karmic hatch
#

Na it's a bit hidden

#

not easy to find if you don't know where to look

tight phoenix
#

given that transparency culling and sorting is non-trivial, how would you fake this appearance? UnityChanThink
I could slice the upper triangle off at the edge of at the wall but that wouldn't work as soon as the camera moved

#

another obvious option would be 'don't make it transparent' UnityChanThink which might be viable

#

if both meshes were part of the same object I could cull it from self-shadowing by first doing a depth writing pass, but that introduces new issues of having one single mesh be the whole thing

#

if I removed its back face you'd still see some of the transparency here

#

oh and on top as well since it doesnt line up 1:1

karmic hatch
#

if the ordering was reliable and one of your meshes would always appear on top of everything else, you could use the opaque texture to generate the color (so set alpha=1 and color=lerp(mesh color, opaque texture, fake alpha))

tight phoenix
twin totem
#

Anyone comfortable with geometry shaders or gpu instancing?
(cause I don't know my exact problem :>)

I'm working on geometry grass and I got following "pipeline":

  • C# manager script (shader dispatching, compute buffers, settings, grass blade mesh ref, etc.)
  • Compute Shader (populates compute buffers with: grass blade positions, rotations, heights & sway(it samples a noise texture))
  • <Insert_Problem_Here>

IDK what's next.
As far as I know, I can pass the buffers to surface shaders but they cant create geometry.
How do I use the data in those buffers to gpu instance a mesh?

And im not talking about instancing game objects with a material that supports gpu instancing.
I cant do this with 7 million grass blades...

regal stag
# twin totem Anyone comfortable with **geometry shaders** or **gpu instancing**? (cause I do...

Might want to look into Graphics.DrawMeshInstanceIndirect (or the newer Graphics.RenderMeshIndirect, same sort of thing).
This is a fairly good example I'm aware of : https://github.com/ColinLeung-NiloCat/UnityURP-MobileDrawMeshInstancedIndirectExample

I personally wouldn't go the geometry shader route as I've heard they are slow and aren't well supported. But afaik you can also generate geometry (vertices, etc) buffers in compute shaders. I think you then draw that with Graphics.DrawProcedural (or newer Graphics.RenderPrimitives?)
Those are the kinds of functions to look into at least, maybe others can help further as they might be more familiar than I am.

NedMakesGames also has a bunch of tutorials with various methods, could be good to watch some of those : https://www.youtube.com/playlist?list=PLAUha41PUKAaCr_ExiPJtpDHmAK6H7Ss9

twin totem
#

Thx for the resources gonna take a look at em

lone crow
#

Hey There! I am trying to replicate this grass sway shader. I am made the part where the blade move periodically but I want them to move based on the noise for more random look. All I want is a way to move the grass blade based on the gradient noise, like when the value is white there is full displacement and when its black there is no displacement or something like that.

regal stag
#

Though I think a more usual thing is to use some scrolling noise as the displacement itself.

twin totem
#

Basically you give the lower vertices of your mesh a displacement value of 0 and the higher a value of 1. (This can be achieved through a gradient)
When you multiply this by the noise value of a noise texture (that you sampled for you XY world pos) you get a new "vertex_displacement" value.

Then you will be able to multiply the vertex positions * a direction vector (of your wind) * the vertex_displacement you just calculated.

#

To then animate it, just move the noise texture!
Its quite simple once you get the hang of it

lone crow
regal stag
# lone crow Yeah I tried that but the way I am currently doing it isn't supporting it. What ...

Your noise is currently mapped to the model UV0. As Remilia also mentioned above you likely want to "project" the noise down over the grass using the world position.
In terms of shader graph, use a Position node set to World space -> Swizzle (with "xz" in field) and connect that to the UV port on a Tiling And Offset then to the Gradient Noise.
And connect a Time node to the Offset port to scroll it

#

Heading off for now, so hope that helps

lone crow
hushed silo
#

Is there a way to project a planar map over geometry in shader graph? For example, if I have a sphere, and I want to map an image on it from one particular direction. If I could just use a transform/orientation to project a planar map through the center of the object that would be perfect

pale python
twin totem
# regal stag Might want to look into `Graphics.DrawMeshInstanceIndirect` (or the newer `Graph...

Hey, so I looked into it and I'm surprised the implementation looks so straight forward.

Still I have my doubts on which one to use.
Do you know what the difference between Graphics.RenderMeshIndirect & Graphics.RenderPrimitivesIndexed is or do you think one will generaly perform better then the other?
(I figured you maybe know a bit more then me)

Graphics.RenderMeshIndirect: Is like how I imagined it to work.
I dont understand what CommandBuffers of Graphics.RenderPrimitivesIndexed though.

#

They look pretty similar tho?

#

Looks like a difference in how data is handled. But I cant figure out how Graphics.RenderPrimitivesIndexed works.

night steppe
#

Why can't I connect this to the vertex position?

grizzled bolt
fluid summit
#

Hey all, am I setting the value of a shader input via script incorrectly? For some reason, the values of the material instance don't seem to change, neither does the fragment output

#
Shader"Custom/FadeShader"
{
   Properties
    {
        _Color ("Tint", Color) = (0, 0, 0, 1)
        _MainTex ("Texture", 2D) = "white" {}
        _PlayerPosWorld ("PlayerPosWorld", Vector) = (.25, .5, .5)
        _ObjPosWorld ("ObjPosWorld", Vector) = (.25, .5, .5)     
        _DistanceModifier ("DistanceModifier", Float) = 10
    }

    SubShader
    {
        Tags
        { 
            "RenderType"="Transparent" 
            "Queue"="Transparent"
        }

        Blend SrcAlpha OneMinusSrcAlpha

        ZWrite off
        Cull off

        Pass
        {

            CGPROGRAM

            #include "UnityCG.cginc"

            #pragma enable_d3d11_debug_symbols

            #pragma vertex vert
            #pragma fragment frag

            sampler2D _MainTex;
            float4 _MainTex_ST;

            fixed4 _Color;
            fixed4 _PlayerPosWorld;
            fixed4 _ObjPosWorld;
            float _DistanceModifier;

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


            struct v2f
            {
                float4 position : SV_POSITION;
                float2 uv : TEXCOORD0;
                fixed4 color : COLOR;
            };

            v2f vert(appdata v)
            {
                v2f o;
                o.position = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                o.color = v.color;
                return o;
            }

            fixed4 frag(v2f i) : SV_TARGET
            {
                fixed4 col = tex2D(_MainTex, i.uv);
                
                float dist = distance(_ObjPosWorld, _PlayerPosWorld);
    
                _Color.a = dist * _DistanceModifier;
    
                col *= _Color;
                col *= i.color;
                return col;
            }

            ENDCG
        }
    }
}
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FadeScript : MonoBehaviour
{

    [SerializeField] GameObject player;

    Material material;

    void Awake()
    {
        material = GetComponent<SpriteRenderer>().material;
    }

    void Update()
    {
        material.SetVector("PlayerPosWorld", player.transform.position);
        material.SetVector("ObjPosWorld",    transform.position);
    }
}
#

I've not used the unity shaders before so figured this would be a simple enough test

#

I figure this is a unity thing as the shader seems to work when manually changing values ... would rather not have to dig through renderdoc

regal stag
fluid summit
#

ahhh ok cheers
EDIT: yup that did it

regal stag
fluid summit
#

hmm actually that makes no sense

#

It's because I'm using the obj position rather than the pixel position

#

Comparing the world position of a player to a pixel screen position is a little more complex I suppose

hushed silo
regal stag
fluid summit
#

yeah makes sense

#

is that unity_ObjectToWorld built in?

regal stag
#

Yep

fluid summit
#

very nice
the last time I was writing shaders it was raw GLSL and I had to do all the projection and space transformation myself so that helps a lot

regal stag
hushed silo
#

sorry, I don't want it on eg X axis, I want it projected through a rotational transform

#

vector 3 or whatever (gulp quarternion)

regal stag
tacit hearth
#

Here I have a transparent material on a tent roof, the lantern glass is also fully transparent with distortion

does anyone know what i need to do to have this roof render behind it? can't seem to figure out what i'm missing.....as you can see you can see inside the tent through the lantern glass

grand jolt
regal stag
#

Maybe also change the Tiling on that material to 1 on the Y first too.

grand jolt
#

thanks!

grand jolt
#

Flipping them either via spriterenderer flip or transform scale also makes them invisible

low lichen
grand jolt
#

lemmesi

grand jolt
low lichen
#

It defaults to Cull Back.

grand jolt
#

cool stuffs, shaders are a whole new world with new meanings

#

anyways thanks again, ig i can sleep now UnityChanWIP

charred canopy
#

Not really sure if I should put it here since it's about draw calls and not really about shaders? But I believed that draw calls would allow up to 1023 instances no matter the amount of vertices and shader complexity.
It's not a LOD so why are these 2 different draw calls?

#

they have 8 and 15 instances respectively

#

(Built-in render pipeline btw)

wicked niche
solar pecan
#

Hey!

Does anyone know how i can get main light position, or main light direction in shader graph using 2d renderer? main light direction node isnt working, or maybe i'm using it wrong

leaden echo
#

Hello again! - I have a shader that is reading depth information from a depthTexture and is performing pixel discarding actions in order to simulate occlusion. The issue I'm having is, is that the shader I have is attached to a separate material than what is natively on the game objects. How can I get the shaders that are already on the game objects to respect the pixel discard logic defined in my occlusion shader?

rigid spade
#

Not sure if this is the place to ask but I am looking for advice on how to create a non-interactive wire grid to show the galactic plane with my local stars similar to the blue polar coordinate grid here:

sacred stratus
#

So just a round grid?

#

in that case for the circular lines you modolo the distance to the center and for the straight lines you modolo the angle

rigid spade
#

In a shader? I have yet to learn those and reluctant to invest time in the wrong direction

karmic hatch
#

(N is an integer and R/2 is the number of rings)

dusty creek
#

I was thinking about how a glint looks like the area between y = 1/x and y = - 1/x so now I want to make a shadergraph using this but I'm not sure how to do it. anyone got any ideas?

#

I want this to be based on the math instead of using a texture

dusty creek
languid radish
#

I'm working on a game in which i have 2d items in a 3d enviorment that you can pick up. I'm using a basic billboarding (aka the transform.lookat to look at the camera) script
The items are really difficult to see, so i want to make it so that the item grows in size when you move away until a certain point. basically that the item stays the same size compared to the screen.
The reason why the items are difficult to see is because they are beneath water, so you have reduced vision.

I was send here because apparently it's something you do with shaders. i have 0 exprience with shaders and I have no idea where to start.

#

example of from farther away, i willl reduce the underwater effect, but it is still difficult to see after removing the effect.

subtle dagger
#

Hey y'all, anyone know why this might be happening to me? Trying to add a keyword to my material so my shader can work, but I can't add it!

frigid pond
#

did anyone have any luck with writing a custom forward+ lit shader that won't crash the Editor in 2022.3? (Trying to write a stylized shader for Entities Graphics)

frail prairie
#

Heyo! I was curious if I could drive emissions on an object by a point light?

I.E: The same area that the point light affects (with the falloff), can I use that to drive the emission?

cosmic prairie
cold ermine
#

I'm trying to create a fog effect in my game. I want the borders of my level to have fog, obscuring the edge of my world. I do like the fog effect from Unitys lighting settings, but its based on camera position and not placed in world space. How can I achieve this?

Edit: To clarify, this is a top-down game

dusty creek
mental canopy
#

I just realised the shader was under "Failed to compile/Toon", no idea why

hushed silo
#

Hello wonderful peoples. If I wanted to draw a cone using a position, orientation and degrees, what would be the nodes to look into in shader graph? Thanks!

amber saffron
hushed silo
#

So actually, I want to get a world space / 3D cone in order to simulate a flashlight without using actual lights

#

So use this cone to lerp between a colour texture and black, for example

#

I figure this cone could be mathematically derived

amber saffron
hushed silo
#

Interesting. This is a good If headache place to start 😌. Would be nice if there was an asset of collections of primitive shapes subgraphs that I could shamelessly steal, because I’m lazy

#

Thanks!

amber saffron
#

But for your flashlight simulation, you could go away with more simple maths :

  • Transform the world position into your "flashlight space" (you can pass a matrix through script)
  • Length of XY + Z * factor will give you a cone shape
hushed silo
#

Can I rely on your patience and ask you to explain that a little more fully so my childlike brain can understand it?
By pass a matrix by a Script you mean..? I have a script that updates a vector3 position and orientation I was hoping to use within the shader. Do you mean something else?

#

Long time since I studied matrix math 😅

amber saffron
#

The shader will be in charge of displaying, but you need to pass the "light" information to it in some way.
A position and orientation could be enough, but my example involves to transform the world pixel coordinates in the "light space" coordinates.
Matrices are very good for this, so you script could update a transformation matrix instead of position & rotation.

#

It's a simple one liner :

Shader.SetGlobalMatrix( "_LightMatrix", transform.worldToLocalMatrix );
#

In shadergraph, you create a matrix property with the same name, and multiply the world position by the matrix to transform it.

hushed silo
#

Ah ok cool, somehow never saw matrix in the graph options. Is a matrix 4 like a vector3 position and quaternion rotation mashed together

#

I should probably do the reading instead of asking, thanks very much!

amber saffron
hushed silo
#

Figures 🙈

amber saffron
hushed silo
#

Yeah I just saw that, funny how my brain can ignore things I don’t understand, I swear matrix was never in shadergraph until now

tight phoenix
#

crude sketch on left of what I am refering to

#

cleaner example

frigid leaf
#

Hey everyone. I want to make sort of a progress bar in a unit icon. Like this:

#

It's sort of a cooldown feature. The shader takes a sprite image, messes around with its color and then draws a line that shows the current progress. The line is slowly crawling up.

What I need is to make sure that the line is always the same pixel size, no matter the texture size. Right now the line is drawn by the rectangle but its width is set up as a fraction of an output picture. I need it to always be the same size in pixels.

Can I set it's size in pixels? Or failing that, is there a way to get pixel size of a texture I'm using?

hollow temple
#

Would it be possible to use an Unlit Sprite Shader for a UI object with an Image? I have selected "Use Sprite Mesh" and the object shows, but the alpha clipping isn't being observed in the Game view. It looks correct in Scene...

regal stag
hollow temple
#

So for doing things like outlines on UI elements, would post-processing be the way to go?

#

or is there an easier way

#

oh let me try the outline component

#

derp

regal stag
#

Could have a separate image for the outline to overlay on top. But that means making an outline texture too

hollow temple
#

i guess that wouldnt be so bad

#

i guess another option is to use Sprite Renderer and not use UI?

regal stag
regal stag
glossy pulsar
#

so I have this really nice skybox pack that looks like this

#

but the moment I change the shader it completely breaks

#

any ideas how to fix? I need to use a specific shader to use it in a game but right now I can't use anything but default

vocal narwhal
vocal narwhal
tight phoenix
vocal narwhal
#

You are not looking at a rounded box there, why would you expect it to be smooth?

woven trellis
#

Hey I'm trying to code an unlit shader in HDRP and need the equivalent of a GrabPass in URP for a false transparency without using a render texture outside of the shader. Is there like a camera buffer or something that I can access?

woven trellis
#

Does something like _CameraOpaqueTexture work in HDRP?

vocal narwhal
#

Sorry, I was confused whether you were talking about URP or HDRP, as URP does not support grabpass either, perhaps you meant to say BiRP (the built-in render pipeline)

#

If you're using shadergraph I believe the Scene Color node returns the opaque scene during the transparency pass, you can look at how they implement if if you want to do it custom

woven trellis
#

I'm trying to modify a raindrop shader to use what would be the equivalent of shadergraph's HDSceneColor node. Here's the shader - it's based on a YT tutorial:

#

I've tried to build it in shadergraph but I'm not a shader engineer so not getting very far

vocal narwhal
#

you can look at the compiled shader from a shader graph and see what HDSceneColor does

woven trellis
#

how do you look into a compiled shader? Is it in the material?

vocal narwhal
woven trellis
#

Hahaha, I was looking everywhere but in the obvious place

#

I'll check it out

woven trellis
#

Yeah nah, that's like a 5000 line shader. And I don't really know what I'm looking for.

vocal narwhal
#

If I've used Lerp or Saturate for example, they're just there as functions

woven trellis
#

This is the only reference to an actual HDSceneColor in the compiled shader:
SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
{
SurfaceDescription surface = (SurfaceDescription)0;
float3 _HDSceneColor_7d30baade8ad4f6baa2f179fb49ccb23_Output_2_Vector3 = Unity_HDRP_SampleSceneColor_float(float4(IN.NDCPosition.xy, 0, 0).xy, 0, GetInverseCurrentExposureMultiplier());
surface.BaseColor = _HDSceneColor_7d30baade8ad4f6baa2f179fb49ccb23_Output_2_Vector3;
surface.Emission = float3(0, 0, 0);
surface.Alpha = 1;
return surface;
}

#

Would it need any special pragmas? How would you insert it into the shader above?

woven trellis
#

The SampleCameraColor in the first one is unrecognised so needs some sort of import (tbh shader coding is beyond me). But I haven't tried getting the Sameple_Tex 2D directly. That might work.
The only other option I can think of is to somehow use custom functions in the shader graph with the returns of the shader and blend the uv's of the scene color. Probably the longest way around 😄

#

Thanks though, that was really helpful

#

I've seen this sort of effect work in HDRP before, but it's hard to tell what method people are using to get it. I'm hesitantat to use a render texture as it's really expensive and my draw calls/framerate is already punished enough. Worse case I can do it though. Then there's the custom pass volume that could work but haven't looked into how that works, and I'm not sure if it's any better than the render texture. Shadergraph is an option but the effect on the uv's is all in mathmatica code so yeah. Then of course there is gettin gthe actual shader to work. I'm a mess atm to say the least.

onyx cliff
#

Hi guys, when I zoom it shows like this how can I fix it?

#

ping me on reply pls

hushed vigil
#

What is "this" and what does it have to do with shaders?

vocal narwhal
onyx cliff
#

There are too much channels, what's the category of this type of question?

vocal narwhal
onyx cliff
#

Ok, thank you

analog solstice
#

Hi friends , what did the Shader>unlit Graph in unity 2019 has changed to in 2022? i cant find.(URP)

grizzled bolt
ember robin
#

Gnight all, anyone can help me with correct way to do something like a atmosphere... i have an game with some planets, and while i go inside any of these planets i need an atmosphere ... and while im inside these can i see planets outside like moon or any other planets in range... but i want to do some sky effect on it

#

Anyone can help me with some ideias on how to do this ?

grizzled bolt
ember robin
#

and I couldn't replicate water shader too... Sebastian lague shader is really really beutiful...

fiery moth
#

I am a newbie to shaders and I am writing my first shader. I want to write a colored dithering shader. I already have the one-bit dithering working, so my grayscale image is dithered into black and white using a noise texture. However, now I want to work on colored dithering, where the final image has a limited color palette (posterization), with dithering to prevent color banding. Right now I don't need code help, I just need help understanding conceptually how this is supposed to work, because I can't find a solid explanation online. The one-bit dithering conceptually makes sense: given the uv of the pixel, sample the noise texture at the same uv, and then use that as a threshold to determine the output value of black or white. And even color posterization makes sense conceptually: given the color of the pixel, find the nearest color in your palette, and then output that. However, I cannot understand how to combine these two effects. Once the color is posterized, how should you sample the noise texture exactly to create the dither effect? Thanks.

frosty linden
#

Hello, what happens when I connect a Vector3 output to a float input? Does Unity takes the x (being the first) or does it average the 3 components of the vector to get the average float?

karmic hatch
robust stone
#

I'm trying to make Kelvin van Hoorn's black hole shader work in my vr game using single-pass, because now It's only rendering in the left eye. Now, I followed the documentation https://docs.unity3d.com/Manual/SinglePassInstancing.html but I get an error with the UNITY_INITIALIZE_OUTPUT:

*Shader error in 'Unlit/Blackhole': undeclared identifier 'UNITY_INITIALIZE_OUTPUT' at line 60 (on d3d11)

Compiling Subshader: 0, Pass: <Unnamed Pass 0>, Vertex program with <no keywords>
Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING
*
Anybody here that knows what is going on?
(I'm on URP btw)

meager pelican
#

undeclared identifier means that the macro is not defined.

robust stone
#

v2f vert(Attributes IN, appdata v)
{

                v2f OUT = (v2f)0;

                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_INITIALIZE_OUTPUT(v2f,OUT);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

                VertexPositionInputs vertexInput = GetVertexPositionInputs(IN.posOS.xyz);

                OUT.posCS = vertexInput.positionCS;
                OUT.posWS = vertexInput.positionWS;

                // Object information, based upon Unity's shadergraph library functions
                OUT.centre = UNITY_MATRIX_M._m03_m13_m23;
                OUT.objectScale = float3(length(float3(UNITY_MATRIX_M[0].x, UNITY_MATRIX_M[1].x, UNITY_MATRIX_M[2].x)),
                             length(float3(UNITY_MATRIX_M[0].y, UNITY_MATRIX_M[1].y, UNITY_MATRIX_M[2].y)),
                             length(float3(UNITY_MATRIX_M[0].z, UNITY_MATRIX_M[1].z, UNITY_MATRIX_M[2].z)));

                return OUT;
            }

This is the vert, can I also ask what Includes I can try to add?

#

I also tried UNITY_INITIALIZE_OUTPUT(v2f,o) like in the documentation

#

I'm very new to hlsl and shader writing so I don't know half of the stuff I'm doing

#

Oh and i see i also tried adding appdata v to the v2f vert thing up top

#

but I don't know if that is correct

meager pelican
#

The UNITY_INITIALIZE_OUTPUT macro is just basically doing what you already did in your fist line...it's casting a zero to a v2f struct type and filling the struct with zeroes. You could replace it with your code like
OUT = (v2f) 0;

#

Although since "out" is a reserved keyword, I wouldn't use it for a variable name, btw. Just to avoid problems if you forget to upper case it.

robust stone
#

So I should just remove the OUT = (v2f) 0;

#

Yeah I'm just editing a shader I found online so the whole shader relies on the variable name

robust stone
meager pelican
#

lol, the dangers of the internet!

#

Or just remove the macro line since you've already zeroed it.

#

Try commenting out the UNITY_INITIALIZE_OUTPUT.

#

I would think a local variable declaration like that with an initializer would work without needing the extra code line.

robust stone
#

Okay I'm sorry I don't know what you mean by that lol

#

Leme try what you said first

robust stone
#

Should I also mention it's a raymarching shader?

#

Does that change anything?

meager pelican
#

The pink error color? Did you get another compile error?

robust stone
#

No no compile error

#

Does it have to do with the URP?

#

oh yeah now i get an error with the variable "o" in this line: UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

meager pelican
#

Well, that's progress of sorts.
IDK, doubt it. URP supports it.

#

The struct is named OUT not o.

robust stone
#

do i miss an include?

#

aah so i input the struct there okay

meager pelican
#

Yeah, it's a macro and needs the name of the struct you're operating on.

robust stone
#

Yesss It's working

#

thank you VERY much

robust stone
meager pelican
#

Nah, I don't do VR (although I've messed with it a bit). Maybe someone else will chime in.
The summary is that (as you know) you generate TWO images in the same pass...one for each eye. So if it works in mono, IDK why it's not working in stereo unless one of your eye-specific calcs is off kilter.

#

@robust stone

fiery moth
#

I am debugging some distortion in my dithering shader, so I tried painting a checkerboard onto the texture (if the x and y of the uv are both odd, fill the fragment in with black, otherwise fill it in with white). The code to compute the fragment color looks like this:

float checkerboard = floor(fragment.uv.y * MainTex_TexelSize.zw.y) % 2 == 1 && floor(fragment.uv.x * _MainTex_TexelSize.zw.x) % 2 == 1 ? 0.0f : 1.0f;

return float4(checkerboard, checkerboard, checkerboard, 1.0f);

What I am seeing is the attached image, which clearly shows distortion. Either my code is wrong, and it is painting multiple pixels, or the texture/camera really is distorted. What could be causing distortion like this? Thanks.

ember robin
still acorn
#

So let's say I want to make foot prints on sand, snow or mud. How? Any leads on this?

signal spear
#

Does anyone know why my grid shader causes this weird ghosting affect when I hover a gameobject over it?
I have no experience with shaders so this is utterly confusing.
Oddly enough, the ghosting only shows in the play mode window not the editor window...

tender edge
#

i think i'm doing something wrong with the alpha in my shader 1st picture is how it currently looks ( you can see the background through the sprite) and the second is when i don't connect the alpha. ( cant see the background and colors are normal )

#

im currently adding the alpha's together to get the correct shape ( bottom - right node )

#

another question, can anyone tell me what is causing those white lines around my sprite?

green peak
#

I am drawing meshes using render mesh instanced,

accordingly to frame debugger, the max instances per draw call instance in 511?
Although unity states its 1023, why is that?

#

it took me 50+ hours to realize this

#

but the reason why shader wasnt working was because, I was account for a 1023 limit meanwhile the shader had a 511 instance limit

hardy dust
#

hey

#

any of u guys use after effects for mesh shaders?

amber saffron
tender edge
#

fixed some of the earlier problems with my shader, but now im trying to add the normals. its a lit shader but it does not seem to interact with light at all

ebon basin
#

Sprite renderer has some extra lighting/shadow options when you turn on its debug I believe so might want to make sure that's all enabled

tender edge
ebon basin
#

Ugh, one of the drop downs should say debug on it on there

#

Your character in the back there does receive light though, no?

tender edge
#

i found the extra debug options but dont see anything that could help me

ebon basin
#

I'm not too sure about shader graph, but I've had problems getting shadows/light to work in hlsl with urp, and usually it's because of some named attributes did not work with spriterenderer.

ebon basin
tender edge
tender edge
#

finally got it working after reverting to an earlier save and building it again as a lit shader. but the lighting seems reversed somehow 🤔 @ebon basin

ebon basin
#

Interesting. Not too sure about that one. I believe I had to break batching on some my sprite shaders for reasons involving some clipping and lighting issues.

#

actually I believe the issue was more that I was doing the billboarding logic inside of the shader itself.

#

anyway, if you're not running into performance issues, you can probably ignore it for now.

noble wedge
#

is it possible to use a texture atlas (color map) with transparent areas? would unity recognize the transparent areas as transparent?

grizzled bolt
#

Because of this you'd prefer to use alpha blended materials only with specific meshes that don't need precise depth sorting

tight phoenix
#

weird question, I don't like how the bands briefly double up double thick when they meet at the center
is it even physically possible to prevent that though?

#

I would want it to.. never? double up? But I can't even picture what that would look like

#

the intersection point just feels discontinuous and sticks out like a sore thumb but I cannot begin to picture what it would even look like 'corrected'

#

they have to meet at somepoint, right? So maybe its just not possible to prevent it from briefly doubling up every cycle?

#

could they somehow meet.. without doubling up?

noble wedge
white swan
#

hi , i'm trying to understand what this function represents

#

this is the function of the raw option for screenposition node ( shader graph)

#

what does IN means ?

#

is it frag in fixed4 frag(v2f frag) : SV_Target {} ?

grizzled bolt
grizzled bolt
white swan
#

which unity fragment shader function that return 0 if input is less than a certain value (ex. 0.9)

#

im trying to count on math instead of if stataments

fallow pivot
#

Hi I have a shadergraph for mixing textures (triplanar) and if I make hole edges are totally broken
Blend I have set to 5, 5+ do nothing

grizzled bolt
fallow pivot
grizzled bolt
fallow pivot
grizzled bolt
#

I'd try making the edges softer
If you want harsh cliffs it's better to use cliff meshes placed over the terrain than to try to make them with brushes, as the terrain component cannot represent vertical detail

#

If it has to be editable at runtime you may have to implement some forced geometry smoothing onto the deform operations

fallow pivot
#

I don't like to hear that. I will not affect how the player will deform. When excavating the hole, I count on rounding, but when the hole is made in one place, these sharp edges can occur.
Is there no other solution?

grizzled bolt
fallow pivot
#

Nope nothing change

grizzled bolt
#

There's some ways to modify and recalculate normals using shaders per-fragment, but I don't know what kind of calcuation could help here

#

The terrain already attempts to smooth out its normals but they are per vertex so distortion occurs at drastic angles

fallow pivot
#

I understand that, but it would like a solution. I thought of converting it purely to Sample texture, maybe that could help

grizzled bolt
fallow pivot
#

We'll see, I'll try to redo it, I already had it done on the sample texture (I migrated from URP) and minor deformation was visible there, but it wasn't as terrible as with the triplanar.

fallow pivot
white swan
#

is there is an easy way to convert surface shader to fragment shader ??
im trying to write depth function in fragment shader similar to depth node in shader graph with eye mod selected, not sure why its so hard but there sooo much difference between the fragment shader and the generated code of shader graph

muted pond
#

When using URP - do I have to stick with URP shaders or is it ok to use other ones?
A friend of mine is using some kind of Blender Addon to map Blender shaders to Unity with a custom shader.
I just wonder if this will block URP from working as intended?

muted pond
fallow pivot
dawn remnant
#

Hey, folk. Still really trying to get this fixed. I am using a package called Stylized Water 2. I am using the mobile water prefab. I have been waiting for a response on their forum for a while but no luck. Some people are saying the shader calculations are dependent on the z depth of the camera. I couldn't find anything in the shader file, but I am also not very familiar with shaders yet. Any help isgreatly appreciated. The only solution we have right now is to have a static camera.
But as you can see, the edge of the water where it meets the land is glitching when moving the camera suddenly.

signal spear
grand jolt
#

Hey guys, I'm having some issues with 2D shaders, I never created shaders so I decided following some tutorials, but the issue is that even by following tutorials I never get the same result as the video.
I just need a simple shader for an outline, but I don't understand how to create it.

#

I tried following different tutorials, but I am never able to get the result that I want

grave wave
#

is it possible to access the SurfaceDescriptionInputs in a shadergraph Custom Function? I really would prefer not having to have a bunch of spurious inputs for things like screen position etc

white swan
#

how to get the screenPosition raw using fragment shader ....????
does anyone know this ? i have been looking for weeks for this

#

has everyone left unity already ?

toxic ore
frigid jay
#

Pseudocode

white swan
#

i have to mention im new to shader, i some but not everything

frigid jay
#

you are specifying it in shader source like:

#pragma fragment PixelShader
white swan
#

syntax error: unexpected token 'PixelShader'

frigid jay
white swan
frigid jay
#

This is what screenUV variable will contain in my code snippet.

white swan
crimson merlin
#

any idea why ANY of the shaders i use created in shader graph have red background where alpha is 0? using same shader in different project - all fine..

tranquil jackal
#

why small shader like this tooks up 3.5 mb of memory in runtime? is there a way how to reduce and strip not needed shader variants from it?

grand jolt
#

Hi how can i fix the problem , is somebody have tutorial or how can i solve the problem?

#

I had a obj file i was covering fbx and when i wasmaking couple and when i came on unity it happened

shadow kraken
grizzled bolt
tranquil jackal
brazen furnace
#

Why is the material black? I am following a youtube tut but on their video it is very bright. I tried two different scenes but same result in both

grizzled bolt
brazen furnace
#

Omg lol how could I miss that

#

Thank you

#

Is there a good way to "increase" the ambient occlusion beyond 1? Because my skybox is pitch black (space game) and the light source I have isn't strong enough to light up the material enough, but I wanna make the metal look brighter than it physically should

#

Or rather, increase the reflectance value

#

Lowering the smoothness to 0.5 does this, but then I lose out on the shininess I want

amber saffron
#

That way the objects will be lit with a brighter ambiant sky, but the camera background sky will still be the almost black space

grizzled bolt
#

That'd have to affect all materials, but I expect is the easiest one

amber saffron
#

Well, indeed. Else you start to dive into the custom lighting route 😅

grizzled bolt
#

Could also add an intensified reflection probe or a different cubemap into emission, but it's unwieldy if it needs to be added in a PBR way

#

I think block shaders in the future should be able to make this kind of thing easier?

amber saffron
#

In theory, yes

brazen furnace
#

Thanks, I'll check out your suggestions

#

I figured out a big problem, I hadn't done any uv-unwrapping on my blender model so that's why it was so extremely dark!

#

I keep forgetting these basic things 😂

grand jolt
grizzled bolt
grand jolt
#

I don't know much about Unity, so I often have to get it done by others.

quaint grotto
#

Can vertex shaders manipulate vertices only in a specific submesh or do they not have a way to determine the submesh

amber saffron
quaint grotto
#

Okay I'll look into colours

white swan
#

hi,
if I have the equivalent to (shader graph: spaceposition-default node) in fragment code
what i need to do to get the same results as spaceposition-raw

regal stag
crimson merlin
#

Material 'upheavtt Material' with Shader 'Shader Graphs/TextShader' doesn't have a float or range property '_CullMode'

#

how can i fix this?

#

it appears when destroying object

white swan
#

left is screenPos / screenPos.w , right is shader graph - screenposition(RAW)

quaint grotto
#

how do we put a subgraph into a submenu in the context menu option

#

of our own choosing

#

eg SubGraph > Math Nodes >

#

i want to create the math node submenu

regal stag
quaint grotto
#

can we put them in the pre-existing categories or will they always have to be Sub Graphs/... ?

regal stag
#

You can create your own categories too

quaint grotto
#

ah nice

#

that was not easy to find in docs 😄

#

unless they never even mentioned it

#

kinda wish we could use hlsl files and make them into subgraphs

#

rather than use custom code nodes

#

why is it expecting _half for my function and not _float

vocal narwhal
#

It's not expecting it, it's not expecting that, it's undeclared

quaint grotto
#

i have a function DepthToWorldPos_float

#

so why is it not finding _half which i didnt even want

#

kinda confusing

regal stag
#

You can set the precision under the Node Settings. By default it inherits based on inputs.

quaint grotto
#

so are these inputs all halfs then ?

#

bit odd if camera position isnt using full float precision

regal stag
#

Idk, if you use one of the colour modes it would tell you. Might also just be the precision set by the whole graph (under Graph Settings)

quaint grotto
#

oh so i presume green colour means half

regal stag
#

Green means "switchable", so it can be either. The custom function node might be expecting both _float and _half to be defined (when set to inherit)

quaint grotto
#

i see - seems switchable makes it work

#

never knew about these colour modes

#

very helpful!

quaint grotto
#

any one know of any scripts out there to support exposing colour gradients in inspector for shadergraph

#

seems its the only field that unity doesn't expose in the inspector

grand jolt
#

How to make this water thingy more interesting visually?

#

what topic can make a shader animate it waterlike

amber saffron
acoustic widget
#

Hi, I am looking into creating a 2D glow shader for a material. I want it to support GPU Instancing. The reason behind it is that as far as I am aware, GPU Instancing allows you to have the same material on different objects with different parameters. Is this possible and how would I go ahead with it?

low lichen
# acoustic widget Hi, I am looking into creating a 2D glow shader for a material. I want it to sup...

GPU instancing is a way to tell the GPU to draw a mesh many times in a single command. This in itself isn't very useful if the mesh is drawn multiple times in the same position, so that's where shaders with instancing support come in. The shader can ask for its instance number, which is unique to each instance, and use that to affect how it's drawn. For example, you could use the ID as an index to an array that's passed to the shader. That's how the built-in properties like transform matrix are handled. Alternatively, you could use the ID as a random seed to generate unique(ish) data for each instance.