#archived-shaders

1 messages ยท Page 42 of 1

wicked prawn
#

hi guys, I need a bit of guidance

#

I have this scene in my unity

#

my character is a 3d model and ive set it to complete white

#

now I kind of want a environment which will have a texture on top of it like this

#

i want my camera to display first picture view, but the person will have this second picture thing masked on it as it walks like it will be present there but only visible on the person

#

can someone please help me with this?

#

Thanks in Advance!

tacit parcel
#

If the camera is movable, maybe you need to setup a camera with render texture

wicked prawn
#

camera is fixed

#

character will move

meager pelican
#

Set the sampler to point, in shader or in import settings.
Maybe try using tex2dlod to set the MIP level to 0 or something (might backfire).
Alpha cutoff is just that...a cutoff threshold. You're not going to get anti-aliasing or "non-rounding" from that, so you may need to edit the texture alpha to do what you want.

regal nacelle
#

Could someone point me in the right direction, i'm trying to use UNITY_MATRIX_VP and other Unity shader variables like _ScreenParams in a compute shader but i'm not having much luck, there is no compile error but the values are all 0

I do have #include "UnityShaderVariables.cginc" in my compute shader but i'm wondering if there's something wrong with simply including it in a compute shader too?

misty kite
#

Hi

#

How do I make a gradient texture

amber saffron
lunar valley
regal nacelle
# misty kite How do I make a gradient texture

Photoshop / .NET paint / Gimp etc
If you however need a gradient with a very specific set of values, i'd simply create it in C# and save to asset or set as shader property as appropriate

misty kite
#

Its ok i dont need it anymore

low lichen
regal nacelle
low lichen
regal nacelle
regal nacelle
low lichen
cosmic prairie
amber saffron
# regal nacelle That seems like a rather odd choice to not assign them if they're defined, consi...

Like it was mentioned, those variables are set up by the engine at the moment of rendering.
For ex, UNITY_MATRIX_VP depends on the camera, and it will change during on frame for each rendered camera.

You might however be able to access them, depending how your are executing your compute shader : if you as using a generic dispatch, that is executed during the update loop, it will probably not work, but if you are dispatching the compute in one of the camera's command buffer, the values might still be there.

nova needle
#

Hey, how can I evaluate the above texture at the below UV coorindates?

amber saffron
nova needle
#

the above already has an input UV

#

I use it to animate it

#

so now I have the voronoi diagram moving "upwards". I however want the circles to come from the center in a sense

#

my first "hack" was that I just want to change the coorindate system

amber saffron
#

The voronoi node is not a texture, and juste generates data from the UV input. If you warp the UV input, you will also warp the "texture"

nova needle
#

if x is seen as the angle and y is seen as the radius that would nearly do it (modulo some inconsistencies)

amber saffron
#

But it won't juste "move" the circles, it will fully distord the result

nova needle
#

Hmm, nice node, good to know, but it doesn't do what I need

#

basically I want to have the output of the voronoi node, lets call it voronoi(x, y)
and then evaluate it at voronoi(arctan(x/y), sqrt(x^2 + y^2))

#

don't know if that makes sense

#

so I want to send x, y to their polar coordinates (phi, radius) and then evaluate the voronoi there

#

or is there maybe a much easier way to do what I want (have the balls all come from the center instead of from one side)

regal nacelle
gloomy gust
#

Ah that's annoying, cus I know nothing about making shaders I was just following a tutorial about how to make a segmented health bar but they didn't use UI elements

amber saffron
teal breach
#

When using Fallback in a shader, should the fallback routine also use Unnamed passes?

nova needle
#

I think I am going to try to code the shader instead

#

Thank you!

naive shuttle
#

Does anyone know how I can make a shader graph that realistically resembles wet mud (see reference pics)? Im already familiar to how shader graphs work, and Im doing this in HDRP, though I need some help

#

Should I just use a seamless texture instead?

rare wren
#

Textures is probably the easiest. Otherwise you'd need yo work with some kind of noise textures probably to generate it, but that's quite hard

naive shuttle
#

Alright

teal breach
naive shuttle
#

Why does the texture on the object not change when I change tiling? The material changes but the object's texture remains the same. Does this have to do with uvs?

#

All the other settings on my shader do affect the object

amber saffron
tiny edge
amber saffron
tiny edge
amber saffron
#

I don't really see why the terrain grass / detail shader would overwrite the interpolation method set on the texture ๐Ÿค”

#

What version of unity are you using ? Built in pipeline or URP / HDRP ?

tight phoenix
#

is there any way to detect in a shader if a main light's ray has/would have passed through more than 2 faces?
it doesnt have to be very exact, a very rough approximation would be enough.
XY I am trying to mask out the area pictured where the body self shadows but the extended foot doesnt

#

I assume the answer is ray tracing, but that is nontrivial and costly(?)

amber saffron
tight phoenix
amber saffron
#

It can be rendered in a single pass with a shader that draws back & front faces, with an additive blending : Output a constant 0.1 for example, and if the "ray" from one pixel goes through 4 faces, the rendered final value will be 0.4

tight phoenix
wicked prawn
shrewd crag
#

there are lots of ways to achieve this. if you are in a modern unity, use shader graph, and instead of using uv coordinates from the object (the default), use uv coordinates that correspond to the screen

wicked prawn
#

i was doing shader earlier but that didnt work

shrewd crag
#

think about what the UV node is doing in shader graph

wicked prawn
#

but for shader graph i need to be in urp?

shrewd crag
#

it is saying "for the given pixel on screen, query the mesh for what coordinate in the texture should i sample"

#

yes.

#

URP or HDRP

#

if you haven't gotten very far

#

you should probably switch to URP now

wicked prawn
#

umm i havent done much with graphics

shrewd crag
#

it will be much easier in shader graph

tiny edge
amber saffron
shrewd crag
#

so the trick is the UV node. a pixel shader is about making decisions with what to draw pixel by pixel. so when it is deciding how to draw a pixel on your guy, it normally looks up a value on the mesh on that pixel (you can think of it as raycasting through the pixel onto the mesh)

#

but instead of using the value on the mesh

#

use some other uv coordinate. the uv coordinate is where on the texture to copy from

#

when it pastes onto the pixel it is trying to draw

#

you want the UV coordinate to be the same as the screen coordinate, instead of the coordinate from the mesh

#

@wicked prawn does that make sense?

tiny edge
shrewd crag
#

because that's like having a big rectangle across the screen, fit perfectly

wicked prawn
#

kind of

#

i just created a urp project

shrewd crag
#

okay well shader graph is fun

#

a lot of doing art in shaders is about UVs

#

it's very tricky

wicked prawn
#

my manager showed me this same effect in 3d max today, he simply created 2 cameras one was looking at character (white material) and black background, one was looking at that texture kind of thing, and it was only being projected on the character

shrewd crag
#

you can definitely achieve this with "compositing" and a lot of people do

#

compositing & masking

#

but doing unity stuff with multiple cameras

#

and messing around with the "z test" field in materials

#

it is buggy and gross

#

it isn't more esoteric than a UV, but you will have learned nothing lol

#

besides, making something in 3ds max... we call that "making a screenshot"

#

delivering a screenshot is easier than making it work in a game

wicked prawn
#

yeah he was confusing me

#

i knew it isnt achievable simply like that in unity

#

I'll go with UV

#

glad someone answered i have to get these done tonight

shrewd crag
#

okay here's what normally happens:

pixel shader(a screen position, mesh data) {
 i have a Texture
 i want to read the "right" pixel from the texture to draw on screen
 i ask mesh data
   mesh data.What position on the texture corresponds to the screen position on my mesh,
             given the way the camera is looking, what is in front of me, etc.)
 this is the uv coordinate sampled using the mesh
 query the texture at the uv coordinate. then return the color from the texture
}

and here is what you are trying to do:

 i have a Texture
 i want to read the "right" pixel from the texture to draw on screen
 i ask __SOMETHING ELSE__
   what position on the texture corresponds to the screen position i am drawing right now
   given the way that the camera is looking
   but also, i'm pretending that instead of a mesh, i'm using a big screen sized rectangle
   that is always pointing at the screen
 query the texture at the uv coordinate. then return the color from the texture
#

i guess what i would do is some arithmetic on the screen position directly

#

to get my uv coordinate

wicked prawn
#

hmmm

#

oh i also need to set opacity for my 3d gameobject

#

4 levels, 100percent, 80percent, 60percent, 40percent

#

oh and one more thing, when my character will stop it should stop too

nova needle
#

If I want my shaders to look a bit different (randomly, for example animation started at different offset), how do I go about that? Do I just make a field "offset" and sync that from the CPU?

#

Or is there a GPU-internal way to create random numbers like that

tight phoenix
amber saffron
#

Seems so

tight phoenix
#

I cant find the option to render the pass to a texture, or make use of the pass

#

The pass must exist somewhere but I can't find any sort of output to make use of it

amber saffron
tight phoenix
amber saffron
#

(small detail : the shader doesn't render depth at all, only "overlap")

prisma dagger
tight phoenix
tight phoenix
amber saffron
naive shuttle
#

Im pretty sure it has to do with the uvs

#

but idk what to do with them

amber saffron
naive shuttle
#

welp that's gonna take a while

nova needle
#

Does anyone know why the atan2 output looks like this (and doesn't seem to work for negeative x)?

#

copy and paste and then plot the angle component

#
void Unity_PolarCoordinates_float(float2 UV, out float2 Out)
{
    const float2 Center = float2(0.5, 0.5);
    const float twoPi = 2 * PI;
    float2 delta = UV - Center;
    float radius = length(delta);
    float angle = atan2(delta.x, delta.y) * 1.0/twoPi;
    Out = float2(radius, angle);
}

void WigglySphere_float(
    float2 uv, 
    float3 sourceColor, 
    out float3 color)
{
    float2 centred = uv - 0.5f;
    float2 polar;
    Unity_PolarCoordinates_float(uv, polar);

    color = polar.y;
}
#

ah

regal stag
nova needle
#

Yes, but atan2 should handle negative values as far as I know?

amber saffron
#

Think of it : how would you display something darker than black ?

nova needle
#

ah the angle is not normalized to 0-2pi but to -PI - +PI?

#

I get it

#

Thanks both of you!

#

yes makes sense thats how arctan is defined haha

prisma dagger
nova needle
#

And also a very noob question since I am new to shader programming: THere is no good way to get raw outputs etc for debugging right? I have to find some way to portray the result nicely as color so that I understand where the error is?

low lichen
wicked prawn
#

because im using a 3d gameobject?

shrewd crag
#

i mean you gotta try to grok what UVs are

wicked prawn
#

yeah

nova needle
#

Hello everyone, this is my first shader with a custom node (and in general), I wanted to make a small fireball for a 2D game. The custom nodes basically output a texture of float1 with 0s and 1s where of the yellow and orange shapes

#

I wanted to ask if anyone knows any obvious easier way to do this or if I made any mistakes in this setup

#

also, would this scale to 100s or 1000s of projectiles with this shader?

lucid arch
#

Hello.
I'm trying to set up a simple shader graph that creates a grayscale gradient between two input values.
To remove banding I would like to use the Dither node.

I'm struggling to get this set up.
Has anyone done this or knows a place where I can look it up?
Thanks!

rare wren
snow blaze
#

I am trying to turn off culling on a custom shader so that a player cape can be seen from both sides.
following the advice of this post (and the rest of the thread) https://forum.unity.com/threads/how-to-turn-off-back-face-culling.329744/#post-3182708,
i created a new custom shader by right-clicking in assets, and then added Cull Off to the subshader section, and to the pass section within the subshader section.
when i selected it as the shader for my material however, it did not change anything.

halcyon panther
#

I'm hitting a road block here (First time messing around in HLSL too).
I'm trying to write a new shader for RW since none of the current ones do what I want. I need to implement the base stuff that those ones already do though as well.
I'm getting caught up on the vertex shader bit atm. I need the base of the texture with said applied shader to essentially not move at all and the top most part of the texture should move the most. Think of a plant in real life, where the wind blows it back and forth and up and down but the trunk, base, roots, etc don't move. Video showing what it looks like now and current vertex shader below. (using hardcoded values for testing purposes)

            // vertex shader function, input vertex format as an argument
            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex); // transformed vertex position

                // calculate height of current vertex
                float height = (v.vertex.y + 1) / 2;

                // calculate sway strength based on height
                float swayStrength = 1 - height;

                // calculate sway frequency and direction
                float swayFrequency = 2 * 0.25; // 2 * _SwayHead;
                float3 swayDirection = float3(0, 1, 0);
                if (height > 0.1)
                {
                    swayDirection.xy = cos((1 - height) * 3.14 / 2);
                }

                // calculate sway offset based on height and wind speed
                float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
                float windStrength = pow(clamp(1.75, 0, 1), 2); // pow(clamp(_WindSpeed, 0, 1), 2)
                float3 swayOffset = float3(0, 0, 0);
                if (height > 0.1) 
                {
                    swayOffset = sin(worldPos * swayFrequency + _Time.y) * swayDirection * windStrength * swayStrength;
                    swayOffset.xy *= height;
                }

                o.vertex.xy += swayOffset;

                o.uv = TRANSFORM_TEX(v.uv * _MainTex_ST.xy + _MainTex_ST.zw, _MainTex);
                return o;
            }
ivory sun
#

Edit:not this channel

halcyon panther
#

Please don't cross-post.

meager pelican
# halcyon panther I'm hitting a road block here (First time messing around in HLSL too). I'm tryin...

I'm guessing there that you really don't want to modify the vertex after it has been transformed to clip space, which is what you're doing.

What you want to do, I think, is transform it to world space, modify it according to wind direction, and then transform it world-space==>clip-space.

That macro that you used at the start is an expedient way to transform an object-space point directly to clip-space, hiding the intermediate stage of view/world-space.

ANOTHER way to do it is transform your wind direction to object space somehow, then you can "just" apply that to the model (if it is unscaled) and then use the UnityObjectToClipPos() macro.

#

Now to find the code to do that (the first way using world space)...

#

worldSpacePos=mul(unity_ObjectToWorld, objSpacePos)Takes an object space point and transforms it to world space. This includes translate, rotation, scale of the object. The info you see in the inspector of the game object, relative to world space.

#

Now that you've done that, your vert is in world space positioned correctly, "in the world". But the camera may be looking anywhere, and further, the camera's 3D space (if the object is even in it) has to be "flattened" into the 2D screen with perspective applied.

So we first rotate the world to correspond to the camera! Think of you standing still and the world rotating under you, until it is position like the camera's view. Yeah, it's backwards from what you'd think. So we transform the world space points to view space...that's the camera's view. Still in 3D.
viewSpacePos=mul(UNITY_MATRIX_V, worldSpacePos);

#

Now that we have view space, we can "splat" that onto the 2D screen, with perspective applied such that the things farther away are "squished" toward the center of the screen giving us the "cone" shaped view frustum. This is something we set up for the next shader stage but we don't really apply it yet....so we need a special space called "clip space" that is a LOGICAL representation of the screen that clips to the view-frustum (it ranges from -1 to +1 in all three axis directions AFTER the perspective divide is done during rasterization...called NDC space...anything outside of that gets "clipped" hence the name). The GPU actually does that math for us later during rasterization. It does the "perspective divide" and divides the xyz values of a clip-space position by the .w "depth" of the point in the view frustum to squish it and give us the proper 3D perspective, unless we have an orthogonal camera setup, but we'll ignore that for now and assume 3D perspective.
clipSpacePos=mul(UNITY_MATRIX_P, viewSpacePos);

#

The Vert shader ALWAYS outputs clip space, it's a requirement of the stage, basically.

halcyon panther
#

Well well well, this is a lot to take in. ๐Ÿ˜„
It'll probably take me a full weekend to really understand everything you've said and put it into practice. But I think I get the gist of it, for now.

#

I unfortunately do need to get some rest before I go climbing tomorrow so I'll have another stab at this after that tomorrow.

meager pelican
#

But you get the idea, anyway. You have to decide where and when to apply your changes so that you get the object translation, rotation, and scale, apply the changes according to the scaled Y height in world space, and then complete the rest of the process to get to clip space that you have to output from the vert() stage.

Enjoy your climbing.

halcyon panther
#

Sounds good, thank you so much by the way!!

queen pendant
#

Folks, question:
I have this shader, from a package called flatkit, that looks normal on the editor, but on a platform build (PS5), it doesn't show... I had this same behavior on PS4 but fixed it by setting
#pragma target 4.5

But this one isn't working... anyone has a clue on why this might be?

#

nvm fixed it ๐Ÿ˜„

vernal grotto
#

do motion vectors just not work for single pass instanced xr? im sampling _CameraMotionVectorsTexture like i would any screen space texture but it seems like only the left eye slice has anything written into it

UNITY_DECLARE_SCREENSPACE_TEXTURE(_CameraMotionVectorsTexture);

fixed4 frag (v2f_img i) : SV_Target
{
    UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
    return UNITY_SAMPLE_SCREENSPACE_TEXTURE(_CameraMotionVectorsTexture);
}
wicked iris
#

Hi all, I'm new to shaders and trying to show a 2D image on a plane with some effects:

  • First of all, I need the transparent parts of the image to stay transparent
  • Second of all, I want a little cutout to where the player is

I achieved the first effect by just using the Unlit/Transparent Cutout shader. For the second effect I followed a cutout tutorial, and can now render a hole in the object based on the screenspace to show the player. However...
How do I combine these effects?
Logically I have two alpha channels, one from the image and one from the player cutout, so I need to combine them. I tried subtracting the player cutout from the original image's alpha, but that only works for the main image and not the transparent edges... Any help would be very much welcome!

Images for context:
First image looks good!

Second image doesn't...

Third is the current ShaderGraph

amber saffron
#

What are the "transaprent edges" you are talking about ?

wicked iris
amber saffron
lucid arch
#

What part specifically are you getting

meager tulip
#

anyone know why the time value of this shader graph is not showing in scene view? (It moves how I want it to in the graph editor but whenever I play the effect and yes it has been connected, it doesnt move with the motion in the graph)

#

btw im in hdrp

meager pelican
# vernal grotto do motion vectors just not work for single pass instanced xr? im sampling `_Came...

Well, I'm guessing here. But since you're using single-pass instancing, there's only one texture, and it is the one for the left eye.
So you'll have to compute the right eye's perspective 'manually' like you compute the right eye manually. (single pass outputs both eyes in one pass, right? Gives you two inputs, camera view data for each eye, writes MRT).

As to how to do that, IDK, I don't do xr.

amber saffron
meager tulip
#

ooooh thanks for telling me, it turns out i need to select "always refresh" as animated materials is not a setting in hdrp i think

#

all good now ty

finite tree
#

can i make an exposed slider from shader graph?

cosmic prairie
sacred stratus
#

How do you write shaders(with code) in the unity hdrp?

amber saffron
sacred stratus
#

so it s not possible?

amber saffron
#

Not impossible, but very hard

#

It's way easier to user shadergraph as the "holder" of your code, managing all the complex boilerplate code, and encapsulate your code in one or multiple hlsl files, references in custom function nodes

sacred stratus
#

alr I'll try that

#

what s wrong about this?

amber saffron
#

Bu basically, you didn't write the code as expected

#

Shadergraph will generate itself the function bloc, you need to only write the content

#

And it doesn't return anything, it's a void function, you need to set the output values

#

in your case OUTMAIN = 1-inputColor;

nova needle
#

Does anyone know any good page explaining what "Override Property Declaration" actually does? I can't find anything, neither in the official unity docs nor outside

sacred stratus
#

alr that makes sense, so the function will create a struct, and inside the function I have to set the values to it, but I do not have to refference the struct
Is that correct?

amber saffron
nova needle
# sacred stratus alr that makes sense, so the function will create a struct, and inside the funct...
#

This helped me to get setup yesterday

amber saffron
#

Taking your example again, it would be something like :
void InverseColor (float4 inputColor, out float4 OUTMAIN){....}

sacred stratus
#

okay seems logical

amber saffron
nova needle
#

the shader stays the same, all the "data intensive inputs" like meshes or textures stay the same, I only change the smallest input

amber saffron
#

I don't have deep knowledge in this, but afaik the input for a shader are send as a whole, you need to change "everything" when switching the setup, not only the color.
With the exception of the constant buffers, that allow to store all the data for a single batch containing multiple materials, and uses pointers instead.

nova needle
#

Oh ok, do you know the keywords that I should search for to understand these topics more deeply?

#

Like what of this is just GPUs, what is bad design of unity, and how is unity designed etc

amber saffron
#

Look for the different overrides names

rare wren
#

@nova needle@amber saffron
Using PropertyBlocks would be the best way to do this, right?
This way dynamic batching can still work on the objects

sacred stratus
nova needle
regal stag
sacred stratus
#

bruh thanks

nova needle
#

If I have an x offset in tiling an offset of -0.5, and plug that into SimpleNoise, why isn't, what was before at the right border (with offset 0) now in the middle?

#

Or to ask differently, what are the dimensions of the simple noise?

regal stag
# nova needle Does anyone know any good page explaining what "Override Property Declaration" a...

Can kinda ignore it. You always want to use the Exposed tickbox instead to define if a property should be Per-Material (set via material inspector or material.SetX functions) or Global (set via Shader.SetGlobalX functions).

The only exception, is a Matrix4x4 property, as they are always defined Per-Material by default, but cannot be exposed on the material. If you need to set a global matrix, you'd need to use the Override Property Declaration to force it to Global, or it'll lead to glitchy/garbage values.

You can also use it to intentionally break the SRP Batcher compatibility for the shader, (e.g. define an exposed property as "global" - which really just moves it out of the PerMaterial cbuffer - or vice versa)

It can also be used to switch properties to Instanced for the DOTS Hybrid Renderer too, but I don't know anything about that.

regal stag
nova needle
#

the tutorials tell me to tick it

regal stag
nova needle
#

Yeah, I would just really like to understand this rendering stuff, at least at a high level

regal stag
nova needle
#

But I don't know where to start

sacred stratus
regal stag
#

Functions should also be void and have out parameters, as I think Remy already explained earlier

sacred stratus
#

yes sorry I forgot to update that but, how comes the function always needs to have _float as a suffix?

regal stag
#

You can also have both, the node can be set to "inherit" the precision of it's inputs. Hence the suffix is required

sacred stratus
#

thanks for the great explanations, really makes sense

nova needle
#

And now with -0.5 offset:

#

see how it moved exactly half, scale is at 8 though

#

but if I do a very similar experiment in game, this behaves differently

#

wait what are the UV coordinates of the default Plane mesh?

regal stag
#

Hmm weird, should be the same in scene/game too.

amber saffron
regal stag
amber saffron
#

But what do you mean by "very similar experiment in game" ?
The offset value is not exposed as a property here

nova needle
#

Its not exposed because I deleted the exposure for the pictures

#

normally it is

#

Basically I have something like a parallax background, but at 0 distance, so it should just move exactly as quickly as the player (basically I have a static mesh that moves with the player and just want to change its offset so that it displays the right background)

#

If thats really dumb please tell me haha

#

And I am trying to get the background to move at the right speed, which in my thought should be
-PlayerPosition / SizeOfBackgroundInWorldCoordinates

#

yeah ok the uvs are indeed 1-10. I just thought that might be it because I was surprised that the plane itself has measurements 10x10, that cost me a few hours to notice today already haha

#

Ok but seems to work now lol, no idea what I changed

#

Ok, I think I found out how I should have been doing this

#

How do I manage to get the UVs in world coordinates?

#

So I want the UVs of my mesh to be their world coordinate position

amber saffron
regal stag
nova needle
#

hahaha, thanks both of you!

#

the solution was so easy all along

dense bane
#

does sampler state work in webgl?

sacred stratus
#

how would you go about reading the world space normals inside a hdrp shadergraph so they can be read as a vector3?

lavish kernel
#

new to shaders, trying to make water shader but it doesnt apply, im using URP, created shader and then material out of it.

warm pulsar
#

does it stay purple if you delete the link to Base Color?

#

so that it's just a constant color input

lavish kernel
#

all time purple

warm pulsar
#

scroll up in the graph inspector and look at the list of targets

#

I do see Universal in there

lavish kernel
warm pulsar
#

if you create a new URP lit shader graph, is the preview also purple?

lavish kernel
#

i imported the package from the manager

#

do i need to do more to make it work?

#

changing "Shader" does nothing

regal stag
lavish kernel
#

just remade project with template, works fine now

#

ty

rain parrot
#

I'm having an issue with shaders not consistently working in my unity project. Here is an example of a shader that flickers on and off. The view is Scene view but the issue persists in game view. This issue is not solely occurring with screen edge but it is easier to show off the issue with screen edge. Is it possible my project isn't setup correctly?

#

The position variable is from an Object node's position

meager pelican
sour dust
#

I'm not sure if this is the right place to ask but I'm trying to make a model and export it using an addon named Vrm but it gives me this error and when I export it the model's material looks wrong

grizzled bolt
sour dust
#

Oh, well thanks anyways!

finite tree
#

so i guess a fullscreen shader is always on top, then whats the best way to make a background, custom skybox or just a big quad behind/under everything facing the camera or something else? (just need something behind the board, the camera will not move or rotate and i want the background to feel 2D so if it was a quad it would face the camera)

lunar valley
finite tree
meager pelican
sacred stratus
#

is there a way unity lets you,
1.Allocate the MeshDataArray on the gpu
2. Get a native Ptr to that and then edit it in a computeshader?

rain parrot
grizzled bolt
regal stag
#

Yeah if they are sprites that's probably the case. Might be better to tint based on Vertex Color instead (or at least as the seed for the random number gen)

rain parrot
#

The trees are prefabs with a child object sprite renderer in which the shader is applied.

rain parrot
sacred stratus
#

does someone know how you can make a mesh that runs completely on the gpu?
like I would like to
Reserve some storage on the Gpu,
then start a Compute Shader and write to it.

regal stag
autumn sigil
#

Anyone know how to get baked lighting to work with Shader Graph shaders, which my projects is heavily dependent on?

sturdy edge
#

Is there anyone who knows how to work in a outline shader for 2D post processing?
Iโ€™m trying different YT tutorials but most of them are for 3D, and Iโ€™m working with a 2D game.
I am in dire need of help to create a separate post processing camera, and blend that with the main camera so that I can have different layers for outline objects.
I did try a material shader, but since it requires two passes it can not be batched, so thatโ€™s why I started looking into a post process alternative.

#

I recently tried the YT tutorial called: โ€œcreating an outline effect as a post process in unityโ€ and afaik this should work with the build in render pipeline which I use, but is aimed at 3D.
If anyone could help me adjust it for 2D it would be lovely!

cosmic sphinx
sturdy edge
umbral trench
#

Hey guys, if I wanted to make a BIRP shader that turns everything into pixel art, where would I start? Is that possible in BIRP?

#

I've done a couple shaders so far but nothing really like this.

#

Well jeez there is an asset just for this haha "Pixelation"

abstract yoke
rain parrot
#

So, I've simplified the shader I was using (it works as intended), and now I've imported it into a brand new project to see if I can isolate the shader flickering issue. But, now my shader isn't working as intended. It defaults to a position of (0,0) for every object.
The objects with this material/shader are objects with a sprite renderer on them, and nothing else.
Any help identifying why the Object node is outputting a position of (0,0) (red) regardless of the objects position?

umbral trench
#

Toon shading is from another shader.

abstract yoke
umbral trench
#

Thanks you as well

tacit parcel
meager pelican
# rain parrot Removing Random.Range did not fix the flickering issue, and Object node does not...

That's why we test, so we eliminate things. So good, and what @grizzled bolt and @regal stag said about batching makes sense.
But to answer one of your other questions, you don't use the object node you use the position node:
https://docs.unity3d.com/Packages/com.unity.shadergraph@7.1/manual/Position-Node.html

Still, static batching will mess that up. As stated above. So you'd want instancing rather than batching, I assume. But URP batcher works differently than BiRP batching, so I'm not sure what you get (I think instancing)...and if you based it off world position with instancing happening, it might work. Or you could create, say, 50 material variants and assign them to object instances based on world pos in C#, then no shader magic is even required, and SRP would batch them up.

rain parrot
# meager pelican That's why we test, so we eliminate things. So good, and what <@166982635950702...

Position node makes the shader useless. I'm assuming its because each sprite renderer is a child of a prefab object and therefore in the same local location. Regardless, the result is that every object is the same color. The object node seems to provide a more accurate world-object position.
edit - Actually I have no idea what position node does, but it does break the shader. No matter what gradient I use the shader is unapplied to the trees, so i assume its breaking my shadergraph.

Having multiple materials is pointless as I'm trying to make a single prefab have variations. Unless, theres a way to have the materials randomly selected.

I know next to nothing about batching, so you lost me on that part.

I'll be honest, at this point i'm thinking of giving up on shadergraph. I've always tried to use them through lots of different tutorials for the simplest thing, but they've always broken in some way. It just seems like a broken feature in unity, and yet i see lots of people using them in their games.

regal stag
# rain parrot Position node makes the shader useless. I'm assuming its because each sprite ren...

I would try multiple materials, but have a C# script assign a random one out of a list at runtime. Should be able to ask in a scripting channel if you're unsure how to do that. But be careful, as different materials means those sprites no longer batch and increases draw calls. It may hurt performance if you use too many materials.

Afaik the "Color" field on the sprite renderer should also already apply a tint to the whole sprite? You could randomise that a little through the script too.

rain parrot
bright cave
#

Hey ya'll first post in this channel. I'm having an issue where my game objects using a shader are invisible. When I fidget with the settings in the inspector(see video) my game object will suddenly appear. The really weird thing is this will sometimes be a fix for an hour or so. I found this which could potentially be referencing the same issue but I can't follow the context. https://issuetracker.unity3d.com/issues/urp-gameobject-shader-is-invisible-in-scene-slash-game-view-until-shader-property-panel-window-is-expanded

sturdy edge
sweet burrow
#

In HLSL is there any way to access a texture as if it was a regular array of color/float4?

nova needle
#

Before SRP times: When would I not want to use GPU instancing on a given property of a material?
Lets say I have a color property in my shader
If I do not add the property to UNITY_INSTANCING_BUFFER, then, if I understand correctly, if I change the color two blue for one of my objects and red for the other one, then unity would now upload two different materials to the GPU, one blue and one red (say they have id 0 and 1), and afterwards always say: Draw this object with this mesh and material 0, this object with same mesh but material 1

#

Whereas if I instance it, then the color would needed to be uploaded every frame, right? So I only want to instance properties that change frequently or where I have so many different values that I do not want to have a single material for all of them in the persistent GPU memory

#

Do I understand this right?

low lichen
# nova needle Do I understand this right?

The default batcher isn't smart enough to recognize when only instanced properties are different between materials and combines those into instanced draws. To change instanced properties, you have to use MaterialPropertyBlock through script. That way, the same material is used, but instanced properties are overridden on each renderer.

#

So there's no benefit in making your properties instanced unless you also use MaterialPropertyBlock to set them.

nova needle
#

@low lichen Ok, thank you! But my general understanding is right? So the non-instances properties of a material are just in persistent GPU memory all the time, so the reason not just instance everything (+ use MaterialPropertyBlock) is because you want the other variables to be fixed and not updated every frame?

low lichen
nova needle
#

Even the mesh?

low lichen
#

No, the mesh is not part of the material

nova needle
#

As in, does the default renderer even reupload the meshes every call?

#

Ok

#

So meshes have always been persistent, since obviously they are quite large

#

And now the SRP batcher came along and thought maybe we should also persist other stuff?

#

But somehow then the tutorials on GPU instancing say that the SRP renderer does not work with GPU instancing at all anymore

#

thanks by the way for answering all these noob questions! haha

low lichen
#

That's true, SRP Batcher is not compatible with GPU instancing.

nova needle
#

But couldn't they have done something in between? Like vs Original: Upload everything every frame and now: upload only once?

#

The straight way forward would have been to make the non-instanced properties persistent and then reupload the instanced ones?

#

It just seems like a huge step backwards to me like this haha

low lichen
#

I think they decided to prioritize optimizing the draw call performance of unchanging materials, since that's 99% of draw calls in most games.

#

And it makes it more user friendly, since you don't have to worry as much about the number of materials in your scene, or use workarounds like MaterialPropertyBlock.

#

Also, GPU instancing is more limited. It can only batch the same mesh. For cases where you still want to use GPU instancing, you can use it manually with Graphics.DrawMeshInstanced.

nova needle
#

So, the story is like this:

  1. Totally unoptimized: Upload every mesh, all material properties (transform, scale, color, custom properties) every frame, for every object
  2. Old Renderer: Make meshes persistent, but upload all material properties every frame (This is where the old renderer was) for every object
  3. Old Renderer + GPU Instancing: Make meshes persistent, but notice than many object will have mostly the same material properties, so only use one draw call for them (where you send the properties, and for the instanced properties you just send a list or something)
  4. SRP: Make meshes and Materials properties persistent, and basically just drawCall(MeshID, MaterialID,) - but some properties still have to be instanced here too (at least position etc) - Why don't they give us the allowance to add our own instanced properties
sturdy edge
#

is there any post processing shader expert that could help with a 2d outline effect that can be used with a camera for selected layers and output to a render texture and combined with the main camera? (NOTE, 2D only)

tranquil wolf
#

trying to layer a texture img on top of a gradient I created, but for some reason it's whitening the texture img a lot- any ideas as to why?

amber saffron
nova needle
#

Does anyone know why this might be happening?

#

These are all just quad meshes that render the texture in transparent mode. Their z coordinate is set to equal their y coordinate
so it should be clear for the camera which one has to go in front or not? Since the one with lower z coordinate are closer

keen cloud
#

change the sprite depth based on the y coord

nova needle
#

@keen cloud I don't think I am using a 2D Camera. I am using a normal 3D project (I am doing this hack since DOTS doesn't support 2D yet)

#

so these are really all just planes that render a small texture

keen cloud
#

interesting

#

how far away is the camera?

#

because it could be zdepth overlapping

#

if it's far away, the difference becomes too small

nova needle
#

what I did change is that the far clipping plane is at 1 000 000 or so

#

so that I can freely change the z values without worrying things go out of sight

keen cloud
#

yea that will most definetelly be the issue

#

change it to something sane like 100

#

and just map the z values to a max of 100

#

or even a 1000 is just fine

nova needle
#

hmm

keen cloud
#

they are planes? not sprites?

nova needle
#

This is how it looks in the scene view

#

game view (as above with the flickering)

nova needle
keen cloud
#

and you are sure that the Z changes?

keen cloud
#

sprite shader ignores zdepth

nova needle
#

I am using a standard unlit shader created by the shader graph @keen cloud

#

I just called it SpriteShader

#

But I think it should not ignore anything

regal stag
# nova needle

Transparent surface mode would mean it doesn't write to the depth buffer by default. You likely want Opaque surface mode but enable Alpha Clipping instead.

nova needle
#

Aha!

#

@regal stag majestic save, thank you!

#

@keen cloud also thanks for all the help! ๐Ÿ™‚

keen cloud
#

I'm trying to make a pixelization shader

#

does anyone know what the logic behind getting clean object edges would be?

#

I don't want it to look antialiased

#

like this for example

#

also by observing the UV, I noticed this happening

sudden portal
#

sorry, missclick

keen cloud
#

ah, well first, yes, wrong place to ask, I feel like this is more a thing for #โ›ฐ๏ธโ”ƒterrain-3d
secondly, yes you could use raymarching to blend these two meshes, idk how to implement it in the best way possible tho

sudden portal
#

oh okay, thanks I will move my message so.

meager pelican
keen cloud
#

funny

nova needle
#

Does anyone know why this animation is really laggy in the editor window?

#

I just want the ghost to move up and down slowly while moving

regal stag
nova needle
#

I guess it should not be that laggy?

nova needle
#

also, is there some sane way to get an object into the right kind of orientation when exporting from blender to unity?

regal stag
#

If that doesn't work, I imagine other channels can help further with that

heavy stirrup
#

Hey guys ^^

Would there be an easy way to add a shader effect to all of your shaders? (not post processing). What I want to do is Tonemapping but during the forward pass and not as a postprocess

nova needle
tidal swan
#

is this the right place to ask about shadergraph?

regal stag
heavy stirrup
#

yuppp, VR

#

I'll just write a shaderinc and copy pasta it everywhere lol

#

most of my shaders are written in HLSL so thank god for that lol

regal stag
#

I'm also not sure if applying the tonemapping before will work exactly the same with transparent objects. Might blend differently

nova needle
#

One more question. Most of my animations will be really simple (like just a bit of hopping from left to right for "walking" while moving in the direction). I want to do all of this completly in-shader and either just have different shaders or one shader with flags for walking, idle etc.
Is this

  1. The preferred / best practice way to do it?
  2. for some reason a bad way to do it?

I am asking since the normally you could animate this on the CPU with the tools and then it would just animate the specific properties. But I don't know if this is done for convenience or because my idea is bad for some reason

regal stag
tidal swan
#

Am I doing something wrong? For some reason my preview isn't working. I'm on 2021.3.23f1

heavy stirrup
#

I think most high quality Quest 2 games are doing some type of forward pass Tonemapping from what I've seen so I'll just have to live with it lol

grand jolt
#

Hey im sorry for asking a really noobish question as its my first time learning about shaders. Unity uses HLSL for its shaders right? But i thought it was for Directx only not metal or vulkan so how does this shader language work on Linux,mac and Windows

regal stag
# nova needle One more question. Most of my animations will be really simple (like just a bit ...

Probably not the usual way to handle animations but should be okay? Be aware that changing vertices on the GPU means :

  • does not automatically recalculate normals (so if you do any rotations, would need to calculate those too, if shading is important)
  • does not update colliders, so physics system won't act to any changes in vertex positions
  • does not update renderer bounds. If the camera goes outside the original bounds, the renderer will be culled. So try not to offset vertices too far.

If you're looking to avoid CPU animations to be able to animate lots of meshes, and want more complicated animations than a sine movement, you may want to look into "Vertex Animation Textures". The idea there is to bake the animation (vertex positions, normals, etc) to a texture, then read that in the vertex shader.

amber saffron
nova needle
#

so the first few points are all fine

grand jolt
#

ahh i see remy thank u so much thats what i figured have a good day

#

we love unity cuz it does the hard work cmd

tidal swan
amber saffron
tidal swan
#

ill try putting it on an object and see what happens

#

it works when I put it on an object

#

only the preview is not working

amber saffron
#

๐Ÿคทโ€โ™‚๏ธ

dim yoke
# tidal swan only the preview is not working

Id try to close and open the preview window, change the preview mesh and close and open the whole shader graph window, its most likely a bug and it might reset to normal by doing something like that

tidal swan
#

when I changed it from opaque to transparent it started working

regal stag
tidal swan
#

I think it just needed something changed to recompile

nova needle
#

Hey so I just watched a really nice tutorial on how to create trees in blender, where they basically just make a path and then use a skin modifier.
Could one also do something like that on a GPU?

#

Or say on the CPU create the tree as a very simple tree (graph), just the as path

#

and then the GPU just makes this a mesh with something like a skin modifier etc? That would make procedual generation of these meshes really easy

sturdy edge
#

Is it ok to post a link to a YT tutorial I want to refer to?
I have a question regarding the tutorials implementation of a post process effect it does.

#

Alright, here goes nothing:
This YouTube video shows a tutorial on how to add a post process effect (outline) to your 3D project.

https://youtu.be/ehyMwVnnnTg

Now to the question:
I am wondering if this implementation would work for a 2D project?
Or can it be adapted to work on a 2D project, and if so, how?

Outlines can be tricky to do in a mesh shader. So, let's do it in post instead...

Want to support the channel?

โ–ถ๏ธ Help fund new episodes by joining the Patreon - http://www.patreon.com/GameDevGuide

๐Ÿ›’Get GameDevGuide Merch! - http://www.gamedevguide.store

๐Ÿ’ก Get O...

โ–ถ Play video
lunar valley
nova needle
#

But I thought geometry shaders are kind of outdated since so expensive?

#

So probably doing this is then quite expensive?

#

Does anyonw know what the simplest way is to make the noise function periodic in shader graph?

lunar valley
nova needle
#

does anyone know why it does not allow me to output the RGB of this combine to the vertex position?

#

(I know I should add the positions first, but it also doesn't work then - I guess there is some data type thats wrong, maybe the texture somehow has the wrong format?)

grizzled bolt
nova needle
#

Thanks!

tranquil wolf
#

so when I try to Lerp a texture with a sample gradient node it doesnt work

#

it does work with a makeshift gradient but...

lunar valley
abstract yoke
#

question, could you use urp's camera stacking and have a camera be looking at a quad that has a shader that gives a psx pixelate effect and have that overlay on the main camera with camera stacking, it works with dithering but i wonder if it's possible to do it with effects like i described. take this image for example, everything behind the glass appears fuzzy and distorted

lunar valley
abstract yoke
#

yea i'm not the best at wording stuff, but thanks, i'm hoping it's true cause this method is a lot easier than others i've seen

tranquil wolf
lunar valley
latent flame
#

How would I achieve what they said in this video about culling the cards

#

24:15

tranquil wolf
lunar valley
tranquil wolf
#

So is there another node I should use or a way to convert sample gradient to be compatible?

#

Really my goal is to be able to dynamically make gradients I can slap textures on top of

lunar valley
lunar valley
regal stag
lunar valley
#

ups pinged wrong guy

lunar valley
latent flame
lunar valley
lunar valley
# latent flame

but tbh. shadergraf should have an option for backface culling so you shouldn't need to do it yourself

shell fable
latent flame
lunar valley
lunar valley
latent flame
#

Like such in the video, any vertex normal facing the camera, it'll clip the normal resulting in a more smooth look

#

I got it though, thanks anyway

lunar valley
rain parrot
#

Anyone know why I'm getting this error: "Type mismatch between conditional values"?

#

The custom function is displayed in the bottom left
Out = (Bool) ? A : B

#

My best guess is that in 2020.3 's custom function doesn't support gradient, but I just want to be sure.

regal stag
rain parrot
#

I used the same ternary operator but had it output floats instead

#

error: "unexpected token '}'"

regal stag
rain parrot
regal stag
quartz bronze
#

Is this the correct place to ask for help about compute shaders?

rain parrot
regal stag
regal stag
quartz bronze
#

thanks

regal stag
#

If it's a big question that's probably a good idea ๐Ÿ˜„

quartz bronze
#

lol yea

rain parrot
quartz bronze
#

Creating a texture from one kernel, but then editing it from another

quartz bronze
#

If anyone starts answering in ^, try pinging me if I don't respond because I'm going to spend some more time banging my head against this wall

halcyon panther
finite tree
#

hello, could anyone explain what technique i would have to use for a shader like this
for an object to be rendered differently if behind a wall
camera casting rays? some screen/depth magic? ...

lunar valley
last sable
# finite tree hello, could anyone explain what technique i would have to use for a shader like...

If you're using URP, something like this?

https://youtu.be/NXXc9xXzqnk

Lets look at occluding objects behind walls, this is a great way to create a gameplay scenario where you can scan for loot, enemies or other things that maybe behind walls. This could help you create an outline or transparent materials. This could work in Unity URP or HDRP.

๐ŸŽ Get OVER 185+ Scripts, Projects and premium content on my PATREON HER...

โ–ถ Play video
finite tree
#

yep, thanks guys UnityChanThumbsUp

cerulean agate
#

I want to be able to have it semi-transparent outside the mask and fully opaque inside the mask; but i can't seem to access the sprite mask texture inside shader graph

acoustic agate
#

Hi everyone, I am just getting huge waitForGfx latency when I use the following line in my shader. Basicaly, I want a logo to appear on the sails like a decal. But it creates huge lag. Anyway to optimize this kind of operation? o.Albedo.rgb = tex2D(_SailTexture, uv_SailTexture).rgb * (1 - decal.a) + decal.rgb * decal.a;

lunar valley
distant dirge
#

are you sure there arent other lines in your shader that are contributing @acoustic agate

acoustic agate
acoustic agate
distant dirge
#

even 2k should be perfectly fine, i have multiple 2k objects running in my scene very close to the player and its still 130 fps

acoustic agate
#

I have also tried step function but it also creates issues. tex2DNode85.rgb = step(tex2DNode85.a, 0.01f) * _LogoTint.rgb;
o.Albedo.rgb = tex2D(_SailTexture, uv_SailTexture).rgb * (1 - tex2DNode85.a) + tex2DNode85.rgb * tex2DNode85.a;

#

Is there a more easy way for me to print logos on the sails of my ships?

#

Or is it better to use custom different textures for each logo?

distant dirge
#

ngl that looks very gvery simple

#

it should just work

#

have you tried doing the same thing in shader graph?

acoustic agate
#

Not really

#

I can give a try

distant dirge
#

yeah try that then maybe

#

no idea if it will work but its worth a try

acoustic agate
#

Ok, thanks

lunar valley
#

Is there a way I can output a color into a texture inside a shader. Or said differently can I change a texture inside of a unlit shader which sits on a regular gameObject. I know that there is graphics.blit for something like that but it needs to be inside of an unlit shader which sits on an object, because I am calculating its normals proccedually inside a shader but I want to save it in a texture, so I can then use it on another shader

regal stag
# lunar valley Is there a way I can output a color into a texture inside a shader. Or said diff...

There are other functions in the Graphics API that lets you draw meshes/renderers to the current render target (set by Graphics.SetRenderTarget). But you'd need the vertex shader to use UV coordinates rather than the usual vertex positions.
e.g. https://github.com/Cyanilux/BakeShader (specifically : https://github.com/Cyanilux/BakeShader/blob/d5cc76125efeb0bec575961f6a16e0143704d8b1/Editor/BakeShader.cs#L220)
(I set this up for editor use only, but may be able to copy the functions for runtime use as well - not too sure if it'll work the same though, as it delays the renderer bake call to rely on Unity loading the material variant)

lunar valley
regal stag
lunar valley
regal stag
#

Are you editing those vertex positions in the shader too?

lunar valley
# regal stag Are you editing those vertex positions in the shader too?

yes, but the change of the vertex position doesn't matter, if I were not to change the vertex positions inside the shader the normals would still be correct. Well it would look wrong for the player because there is no actual displacement, but changing the vertecies inside the shader doesn't affect the normal calculation

lunar valley
#

I have got another problem (damn), so I have made a decal shader and it works fine, until I set the far clipping planes of the camera higher. ( like 10x) Then I am for some reason getting some streaks in my projection. I have a feeling that this is a precision issue, but I am not sure. any ideas? ```cs
//unstretch screenspace uv and get uvs from function
float2 screenUv = i.screenPos.xy / i.screenPos.w;

            //read depthnormal
            float4 depthnormal = tex2D(_CameraDepthNormalsTexture, screenUv);

            //decode depthnormal
            float3 normal;
            float depth;
            DecodeDepthNormal(depthnormal, depth, normal);
            //get depth as distance from camera in units 
            depth = depth * _ProjectionParams.z;
            normal = normal = mul((float3x3)VIEW_TO_WORLD, normal);

            // Get ProjectedObjectPos
            float3 uv = getProjectedObjectPos(i.ray, depth).xyz;

            //read the texture color at the uv coordinate
            fixed4 Top1col = tex2D(_MainTex, uv.xz * 10);
            return Top1col;```
#
            float3 getProjectedObjectPos(float3 worldRay, float depth) {
                //get a ray thats 1 long on the axis from the camera away (because thats how depth is defined)
                worldRay = normalize(worldRay);
                //the 3rd row of the view matrix has the camera forward vector encoded, so a dot product with that will give the inverse distance in that direction
                worldRay /= dot(worldRay, -UNITY_MATRIX_V[2].xyz);
                //with that reconstruct world and object space positions
                float3 worldPos = _WorldSpaceCameraPos + worldRay * depth;
                float3 objectPos = mul(unity_WorldToObject, float4(worldPos, 1)).xyz;
                //discard pixels where any component is beyond +-0.5
                clip(0.5 - abs(objectPos));
                //get -0.5|0.5 space to 0|1 for nice texture stuff if thats what we want
                objectPos += 0.5;
                return objectPos;
            }```
hasty nacelle
#

hello i am new to unity how can i rotate a image texture?

lunar valley
clever vessel
#

hey guys one question
In shader graph I am not able to see the preview when my surface type is Opaque.
Any suggestions on how can I fix this ?

clever vessel
clever vessel
vocal narwhal
hasty nacelle
vocal narwhal
lunar valley
clever vessel
lunar valley
clever vessel
clever vessel
lunar valley
# clever vessel

but in the screenshots you sent it isn't blank once it is just set to 2D and once to 3D preview

meager pelican
#

@lunar valleyLast question first, it's likely a precision issue as you say. I'm not sure what I'm looking at in that pic though, and am a bit confused as to what getProjectedObjectPos is doing internally....the right hand pic is the "jittering" that you're NOT expecting? Looks like precision to me. Guessing though.

As to your earlier question, if you want to modify a texture like you and Cyan were talking about, you'd have to either:
(1) output to the texture as a render target. If you're drawing the "other" object at the same time, you'd need to use MRT and output TWO values...one for the object, the other for the texture.
(2) Try and get RWTexture2D to work in a normal shader (pixel/vert). This maps the texture as a UAV rather than the usual SRV. It works for compute shaders, but IDK about pixel shaders.

dark garden
#

can anyone help me with an issue i have with post processing?

clever vessel
lunar valley
# meager pelican <@806100611979804733>Last question first, it's likely a precision issue as you s...

thank you for your respons <3 really appreciate that. My "pressicion issue" not sure tho, is more urgent so I would like to talk about that. It is a decal shader and what you can imagine is that essentially I am projecting a texture from a cube onto the geometry below. Like a decal shader would do. the getProjectedPos function is a function that calculates the projected uv coordinates nessesary to sample the texture. Internally it essentailly reverses everything back from screen space to object space which then at the end our objectPos ranges from 0-1. with that we can then sample the texture, but it seams that with high far clipping planes things start to break

#

I am wrapping a texture onto the surface below, from a transparent cube above

meager pelican
#

Are you in URP or what?

lunar valley
lunar valley
meager pelican
#

URP is an SRP

#

You mean built in?

lunar valley
#

ah sorry built in

meager pelican
#

OK ๐Ÿ˜‰

lunar valley
#

bruh confused things

meager pelican
#

too many acronyms and abbreviations

#

lol

#

OK

#

OK, so the cube is the SOURCE of the decal?

#

Usually it's a destination area...

lunar valley
meager pelican
#
lunar valley
#

tbh. exactly like that

meager pelican
#

maybe that will give you a start. Precision, though, IDK what to tell you. I mean, there's no magic that I know of. How big is your far plane value?

#

There are techniques for "large worlds" where you remap the 0,0,0 point to some other area in world-space as you move.

lunar valley
meager pelican
#

Hmmm. Found this: https://forum.unity.com/threads/is-there-a-hard-maximum-far-near-clip-plane-ratio.1377387/
Counterintuitively it appears that if you can increase the value of the NEAR clipping plane, that will help you set a larger far plane. This is due to the ratio of the two, and how they encode the depth values IIUC.

dark garden
lunar valley
lunar valley
dark garden
#

oh alr

lunar valley
# dark garden this

i do not know what you did or what you want to do or what the problem is, I cannot read minds

dark garden
#

Version: 2021.3.14f1
Pipeline: none
post processing settings: bloom and vigentte
xr version: 1.5.3
Device, oculus quest 2

lunar valley
#

I am not familiar with vr, maybe someone else can help you

dark garden
#

gn

desert orbit
#

@dark garden Stop cross-posting. Keep to one channel

pliant star
#

I picked up the Unity Shaders Bible recently and am currently going through it, but I got an issue, is this a good place to ask about it?

lunar valley
pliant star
#

The part I'm at is going through functions in HLSL, and the examples it gives look like this

// create function
void FakeLight_float (in float3 Normal, out float3 Out)
{
  float[n] operation = Normal;
  Out = operation;
}
half4 frag (v2f i) : SV_Target
{
  // declare normals.
  float3 n = i.normal;
  // declare the output.
  float3 col = 0;
  // pass both values as arguments.
  FakeLight_float (n, col);
  return float4(col.rgb, 1);
}

I'm getting an error at the "float[n] line" inside FakeLight_float, so I thought I would change it to float3 instead to try to fix the error. But when I do that it gives me another error about an invalid subscript "normal" on the "float3 n = i.normal;" line inside frag. I'm not sure if it's meant to be like that

lunar valley
pliant star
#

I'm not sure either

#

And it's not really explaining that part at all

lunar valley
pliant star
#

Yeah, tried that

lunar valley
#

and?

pliant star
#

Referring to this line

float3 n = i.normal;

inside frag

lunar valley
#

how are you passing that over?

lunar valley
pliant star
#

Right, makes sense

deft frost
#

Hey, I'm trying to do UV displacement on a UI image, but when it displaces too far, it seems to hit the image border even though it's within the image boundaries. Does that make sense?

finite tree
#

was animal crossing your inspiration for that bubble? UnityChanThink

lunar valley
# meager pelican Hmmm. Found this: https://forum.unity.com/threads/is-there-a-hard-maximum-far-n...

Ok I found the issue to my problem, I do not really understand why it's the way it is, but for some reason when I am sampling _CameraDepthNormal texture and retrieving the depth like that, the thing happens. But if I sample _CameraDepthTexture with SAMPLE_DEPTH_TEXTURE the problem dissapears and it work no matter of the far clipping plane. Could it be that SAMPLE_DEPTH_TEXTURE does something special in the background to sample the depth non linearly so the precision issue doesn't occur. Because I have found a formula on openGl website to sample the depth texture in a way that fixes precision issues and zfighting (which happens because of the precision issues). But I really do not exactly know whats going on here, what do you think?

lofty orbit
#

hi (again yes lot of issues) happens that my my bubble shader are pretty and all but i cannot use the PBR ! it is not compatible for my projet and could only realised at the end so am trying with some listed shader that are mentionned compatible on the doccumentation but am not sure how to use them, ichoose the unlit and a warning on the main node tell me i need a render pipeline but i dont know how to get it

distant dirge
#

We need more info, what do you mean you cant use the PBR? What does 'using the PBR' mean? How is it not compatible? What listed shader are you talking about? Can you show what you mean by the main node warning?
@lofty orbit

lofty orbit
amber saffron
#

Basically, you need to stick with the provided shaders, you can't do you own

lofty orbit
amber saffron
#

Yes

lofty orbit
#

ha..well thats pretty annoying for what i needed, at least i know im wasting time with the shader graph, thanks

floral arrow
#

I have a Sprite as a background and I want to make a shader that makes a watertrail like a boat whenever the mouse passes on the background.
Any suggestions on how to make that thing?

hollow pond
#

why is'n't my material showing the same on other building

cosmic sphinx
hollow pond
cosmic sphinx
hollow pond
vivid marten
#

are there any updated tutorials about shader graph for unity 2022?
I'm just trying to make a simple shader that I can put on a 2d sprite

regal stag
timid shell
#

Does anyone know if it's possible to have a pair of connected nodes, one that has a dynamic vector input and one that has a dynamic vector output, where the output of the second node is the input of the first node, but without any wires/edges connecting these nodes?

amber saffron
timid shell
amber saffron
#

AFAIK, yes, this will basically be variables store / load

cosmic sphinx
regal stag
#

(It's two subgraphs and the script makes the connections invisible)

amber saffron
#

Haha, Cyan for the help, I was searching for this, thought it was one of needle's work ^^

hollow pond
cosmic sphinx
regal stag
#

The model would actually be in the MeshFilter component, but same idea.

dapper pollen
#

if I make a build and it compiles all shader variants, I go and remove some features to reduce variants, does unity count this as a new shader, so it will rebuild all variants again or will the cached shaders stick around?

sweet burrow
#

Is there a way to declare arrays or something like that in Shadergraph?
I have a shader that will use GPU skinning (via BatchRendererGroup) and I really don't look forward having to name 64*3 Vector4.

amber saffron
prime shale
prime shale
#

caching I suppose would be nice but no way to really know what variants you previously compiled you would need so might as well rebuild the variants that you supposedly need again

sweet burrow
amber saffron
#

Can't you use BRG macros also in your hlsl file ?

sweet burrow
#

... what do you mean exactly by that? I just started experimenting with BRG - I got it to work with custom color/smooth/etc, but I'm still a beginner.

amber saffron
#

I haven't worked with BRG in particular myself, so I don't really know if it requires some definition macro like cbuffers do ๐Ÿ˜…

lunar valley
#

I have found another problem with my custom decal shader (hopfully the last one) and thats if I put my camera inside of the decal projector object, my projected texture dissapears. I have found that setting Cull front and Ztesting to Always "fixes" this issue, but that comes with its own set of problems as well. If anyone has an idea just ping me.

vivid marten
#

this is all I've done so far. I have just guessed what to do lol

regal stag
#

Maybe you need to right-click the property in Blackboard and "Set as main texture". Also make sure the material assigned to the SpriteRenderer is actually using the shader graph. If that's the case not sure why the warning is still there.

I don't tend to work with the Built-in target either, it might not really have support for sprites.

vivid marten
#

should I send a short video of me doing it so you can see what's going on? Cuz I've done that already

#

it says Clear main texture when I right click on it

#

so I've done it I think

regal stag
#

I don't need to see a video, If you say you've done it I believe you ๐Ÿ˜…

vivid marten
#

lol maybe I might be missing something tho

#

that's why I thought a video could solve it

regal stag
#

Did you check the material is using the graph as it's shader, rather than a different one?

vivid marten
#

I think so ๐Ÿค”

#

wait what

regal stag
#

The reference here is _Texture2D rather than _MainTex, that might be why. Though earlier you did also have that.

vivid marten
#

I thought I set it to _MainTex

#

YO! The name has to be _MainTex and not just the reference

#

that's weird

#

oh well ty for your time ๐Ÿ™‚

regal stag
#

Well when you change the name it automatically changes the reference to match usually. But you should be able to override the reference itself too.

civic onyx
#

Hi Guys, is there any way to merge two different materials in Unity using some custom shader?

#

i want to achieve this kind of effect but using custom materials or shader in Unity

#

So that my Texture quality doesnt get disturb.

amber hollow
#

its the same as mix in blender

civic onyx
#

does this blend node works in standard Unity or URP only?

amber hollow
#

it works with urp and hdrp

#

if you want to make custom shaders in node editor in standard render pipeline you need some 3rd party tool

civic onyx
#

Thanks alot, i am not developer, so do i have to get coding knowledge or it is built in feature?

civic onyx
#

my major aim is to integrate custom shaders in mobile games so that the textures dont lose their quality.

amber hollow
# civic onyx lets say, i use 3rd party tool to design a custom shader, will it be able to be ...

yes it would work fine on all platforms, but i've checked and it seems like unity added shader graph for standard render pipeline a while ago
https://www.youtube.com/watch?v=E5qu-v5XkK4

I go over some of the updates that came from Unity 2021.2 In particular the ability to use Shader Graph in the Built in pipeline

(ใฅ๏ฟฃ ยณ๏ฟฃ)ใฅ ~(ห˜โ–พห˜~)

TWITCH ( อกยฐ อœส– อกยฐ)
https://www.twitch.tv/PabloMakes

TWITTER (เฒฅ๏นเฒฅ)
https://twitter.com/PabloMakes

โ‚ช โ‚ช Time Stamps โ‚ช โ‚ช
00:00 - Intro
00:53 - How To
03:47 - Shader Graph Categories
04:19 - O...

โ–ถ Play video
civic onyx
#

Thats Awesome, let me check this out, i will update my results here then.

deft frost
# deft frost

Can someone help me with this? Itโ€™s driving me crazy

low lichen
deft frost
#

Ah. That might be it! Iโ€™ll try it and see what happens

#

It worked! Thanks @low lichen

leaden radish
#

hey was wondering if i add a shader to one sprite from a spritesheet does it effect all sprites in the spritesheet?

#

like example my sprite sheet

#

now i just want to add a shader to the leaf or something to have an effect after slicing the sprite sheet

deft frost
meager pelican
north bolt
#

Hello! I am very new to writing shaders and am having an issue when using StructuredBuffers. In c#, I have this code inside OnRenderImage

float[] testData = { 3 };
ComputeBuffer testbuffer = new ComputeBuffer(1, sizeof(float), ComputeBufferType.Default);
testbuffer.SetData(testData);

material.SetBuffer("test", testbuffer);
testbuffer.Dispose();
Graphics.Blit(null, dest, material);

In the shader, I have the buffer defined as
StructuredBuffer<float> test;

And inside frag, i have
float4 col;
if (test[0] != 0) col = float4(1, 1, 1, 1);
return col;

#

All of my code works if I use material.SetFloat(), but not with buffers

storm cipher
#

Heya I am completely new to shaders and such if anyone could help that'd be fantastic. How would I go about making an edge detection or edge drawing shader effect, cause my goal is to have all the edges of my objects and my normal map edges to be a certain colour.

lunar valley
lunar valley
storm cipher
#

I can make that emissive yeah?

#

cause thats probably far simpler than i thought it'd be

lunar valley
lunar valley
storm cipher
#

ah, I see, do you know of any resources I could use to learn how to do that, cause I don't know where to look, I am 100% new to this, All I have done so far in unity is the very basic starter stuff and some basic texturing prior.

lunar valley
# storm cipher ah, I see, do you know of any resources I could use to learn how to do that, cau...

Idk. starting right with a edge detection shader for the first time might not be that smart, outlines can be far more complicated then you first expect them to be especialy one that works on all scenarios. If you want to make any effect which is applied to the screen you can use graphics.blit function. If I were to start with shaders with no prior experience, I would start by watching the shader videos from freya holmer, I find them pretty good. They are not about making a post processing shader or about outlines but they teach you about shaders.

storm cipher
vivid marten
#

Does the fresnell effect only work for 3d objects?

#

the 2d sprites to the right are sprites without my shader and the sprites to the left are with my shader

#

the sphere with a red outline is a 3d object

lunar valley
vivid marten
#

oh

#

I'm trying to make a glow effect for 2d sprites but I have no idea what I'm doing ๐Ÿ˜›

vivid marten
#

like a static line that looks like laser

#

Imagine these white lines being lasers instead

#

I guess the first step is to make blurred edges

cosmic prairie
#

so like on a 0-1 scale

#

and apply a glow based on that texture in the shader

#

OR generate a map like that using some king of SDF generator

vivid marten
#

so the further it is to the edge, the more transparent it will be

cosmic prairie
#

or less intense the glow

#

yes

vivid marten
#

idk how to do that, this is my first time trying out shaders lul

cosmic prairie
#

First you'd need a texture for it anyways

#

which you have to do by hand

vivid marten
#

so I can't just go with the Square texture that's inbuilt in unity?

cosmic prairie
#

if you have photoshop your could probably do a quick job with like an outline and blur tool

cosmic prairie
#

Ah for the buttons or those milestones?

vivid marten
cosmic prairie
#

the robot thingy

vivid marten
#

oh wait, can I multiply two textures to make blurred edges?

cosmic prairie
#

not rly

vivid marten
#

hmm

cosmic prairie
#

well depending on what you call blurring

#

if you are referring to fading

#

yes

vivid marten
#

ye

cosmic prairie
#

if actual blur

lunar valley
#

if you want to blur edges you can use box blur gaussian blur...

cosmic prairie
#

no

vivid marten
#

yes no yes no ๐Ÿ˜‚

cosmic prairie
#

so, to fade your texture all you need is to multiply your alpha in your shader graph by the value of your fade map, or the 1-x of that

vivid marten
#

oh

lunar valley
#

damn were about to say that

vivid marten
#

and the fade map is another texture I guess?

cosmic prairie
#

it could be

#

how are the lines rendered? those are what you want to add lasers to right now?

vivid marten
#

they are just 2d sprites

#

yes

cosmic prairie
#

you could then also use your UV I think to create a blurred line

vivid marten
#

Could I multiply the alpha with these colors so the white makes it more transparent?

cosmic prairie
vivid marten
#

wdym 1-x?

cosmic prairie
#

x is your color you get by sampling this texture

vivid marten
#

oh

cosmic prairie
#

cause white is 1, and your alpha should be 1 where it is opaque and 0 where fully transparent

vivid marten
#

oh right if I multiply my texture by 0 it will be completely transparent so it should be inverted

cosmic prairie
#

yea

#

this new texture map will need to go in the material itself, you wont be able to apply it in the sprite renderer

vivid marten
#

so it will be the MainTex texture?

cosmic prairie
#

or if you won't be using the sprite for anything, then I guess you could plug it in there too ๐Ÿค”

#

tbh, if you don't need an actual texture for it, then it could be named anything

vivid marten
#

hmm

#

uh this didn't work ๐Ÿค”

lunar valley
vivid marten
#

idk how do I check that

lunar valley
#

in the graf settings

vivid marten
lunar valley
vivid marten
#

it should be on transparent?

lunar valley
vivid marten
#

blending mode should be multiply I guess

#

but when I do that it still looks weird

lunar valley
#

ok

vivid marten
#

it doesn't agree with the preview

lunar valley
#

I thought the shader was for a line?

vivid marten
#

yee I somehow just tested it with a sphere ๐Ÿคท

#

but with this it makes no difference

lunar valley
#

try putting you gradient texture into the color do you then see anything or will it still be white?

vivid marten
#

I thought I should try it without color first to keep it simple

lunar valley
#

we are debbuging right now put your texture into the color

vivid marten
#

and another thing I noticed is that my sprites that has my custom material draws behind everything else no matter the Order in layer

#

you mean like this?

lunar valley
#

no your gradient texture

cosmic prairie
vivid marten
#

I'm confused

cosmic prairie
#

click on your material in the assets

#

check inspector

mental bone
#

I just learned that godot has different shapes for their volumetric fog volumes. I can do this with sdf functions and volumetric materials in shadegraph but it would be nice to have something out of the box. Any plans for this or other aproaches?

vivid marten
cosmic prairie
#

not your object

#

assets doldrr

#

foldrr

cosmic prairie
vivid marten
cosmic prairie
#

yes

cosmic prairie
vivid marten
#

but I thought the MainTex is automatically referring to the material that spriterenderer is using

cosmic prairie
vivid marten
#

still no difference ๐Ÿค”

cosmic prairie
#

surface type

#

opaque -> transparent

vivid marten
#

oooh

#

YO IT WORKS

cosmic prairie
#

yey

vivid marten
#

why do I have to change it there and in the shader?

cosmic prairie
#

same goes for textures and everything

vivid marten
#

oh so if I make a new material it and attatch the shader to it I don't need to change it again

cosmic prairie
#

that should be correct, yes

vivid marten
#

ok

#

ty for your help! ๐Ÿ˜„

#

oh wrong emote

cosmic prairie
#

no problem! ๐Ÿ™‚

vivid marten
#

but is it possible to do this without a map?

#

it looks good tho

cosmic prairie
vivid marten
#

ah, so maps are a common way to do it

cosmic prairie
#

if you were to avoid that you would use the UV directly and a gradient, but gradients are more expensive I think

vivid marten
#

expensive as in more processing power?

cosmic prairie
#

gpus should be really good with sampling textures

cosmic prairie
vivid marten
#

aha

#

then I will stick to this method

cosmic prairie
#

allright

vivid marten
#

it's looking a bit more funny now ๐Ÿ˜›

vivid marten
#

๐Ÿค”

lunar valley
#

looks cool

vivid marten
#

now I just need the texture to scroll

#

but maybe chains will look better

limpid rivet
limpid rivet
# limpid rivet

I imported this through sketchfab to unity, looks like the material didn't apply correctly,
but the textures are still available,
how can I manually apply the textures to this one?
Do I create a new material?

or should I try to download this into Blender and then load it from blender into Unity?

#

I think I may have figured it out

lunar valley
# limpid rivet

if its pink then it means that there are shader compile errors, whatever material/shader you are using is probably not compatible with you render pipeline

limpid rivet
#

ah

#

that makes sense

#

making new materials worked,
but then I went back instead and tried changing the shader to Universal Render Pipeline / Lit and it worked

#

thank you!

lunar valley
#

np

vivid marten
#

It looked better when OuterStrength was negative value but that doesn't make sense to the user interface ๐Ÿค”

#

I'm trying to get the same effect but with a positive value and without getting the opposite color

mental bone
#

Anyone knows if a pre-build library of SDF sub graphs for shadergraph exists ? My google fu is failing me

vivid marten
#

(the video is frozen in the beginning)

#

now I just need to animate the background somehow

cosmic prairie
vivid marten
#

๐Ÿ™‚

cosmic prairie
vivid marten
#

it was hard to make the texture seamless tho lul

cosmic prairie
#

What do you use to edit it?

vivid marten
#

Gimp

cosmic prairie
#

Krita has a seamless toggle

#

you can paint seamlessly there, not sure about gimp

vivid marten
#

hmm

#

what I tried to do was copy the top and flip it vertically lul

cosmic prairie
#

yea, but that adds like a mirrored effect

#

which you can already do in the texture's asset settings

vivid marten
#

oh

cosmic prairie
#

coincidentally I'm working on an image editor that can also do seamless textures for my Uni thesis, but it's not done yet lul

vivid marten
#

you making your own image editor? ๐Ÿ‘€

cosmic prairie
#

yea

vivid marten
#

pog

cosmic prairie
#

in Unity

#

xD

#

easy access to compute shaders

vivid marten
#

hehe

cosmic prairie
#

Probably not doable in shader graphs if you want something as performant

amber saffron
mental bone
#

I mean it's pretty damn easy to do with the volumetric materials

vestal trout
#

why cant i edit anything here?

#

im on version 2022.2.6f1

grizzled bolt
vestal trout
#

i have my own material

#

still not able to edit it either

regal stag
#

Maybe try editing the Material asset itself rather than this dropdown on the gameobject/renderer

vestal trout
#

well, i want to edit the property just for this object

#

not all of them

#

it seems that just isnt possible for textures?

regal stag
vestal trout
#

for example in shader graph

regal stag
#

The texture property needs to use the same reference

vestal trout
#

oh nvm

#

i got it

#

thx!

#

thats actually pretty usefull to know:)

junior widget
#

Hi everyone, I'm trying to use a shader using the stencil buffer to create a effect of 3D collection card but after looking multiple video about it and trying them all, its look like I'm missing something because it should be simple.

I made 2 different shader (code in screenshot) one for the object I want to hide and the other for a quad that will act like the filter (view on the card that will see the 3D object) I created after 2 material for each of them and applied the correct one for each.

When I apply it, I should be able to see the tilling texture of the hiddenObject (the sphere) only throught the quad but it look like I can't see it and after trying to watch those video, I wasn't able to fix the issue. Each video use different method but still pretty similar :
https://www.youtube.com/watch?v=AATjjduNUAU&t
https://www.youtube.com/watch?v=9wv7-XY2tp8&t
https://www.youtube.com/watch?v=EzM8LGzMjmc&t
https://www.youtube.com/watch?v=-NB2TR8IjE8&t

low lichen
junior widget
#

2000

#

I tried to put it both 2000 or switch to the mask having the 2001

regal stag
#

I think the Queue in the shader is reversed. You want the mask to render before the object, so you'd usually use "Geometry-1" in the mask shader.
Even if you're overriding it on materials (would want mask to 1999), still a good idea to change it.

#

Also is this URP?

junior widget
#

I just tried and nothing really changed

#

yess

regal stag
#

In the URP template I think it now has the "Depth Priming" enabled (or at least set to Auto) by default on the Universal Renderer asset. That means any shaders that don't have a "DepthOnly" pass will be invisible, which may be interfering.
Can either disable DepthPriming, or use a shader that is more suitable for URP, e.g. https://github.com/Cyanilux/URP_ShaderCodeTemplates/blob/main/URP_Unlit%2BTemplate.shader
Or could use the RenderObjects feature to apply stencil overrides to existing URP materials, or materials using shader graphs.

junior widget
#

OMG YESS

#

Thanks you!!!!!

spiral tendon
#

Thanks to NVIDIA for sponsoring!
Learn more about NVIDIA Studioโ–บ https://nvda.ws/38AaA8K
Razer Blade Studio laptopsโ–บ https://www.razer.com/studio

In this video we create outline effect using 2D Shader Graph!

โ— Learn more about 2D Shader Graph: https://youtu.be/5dzGj9k8Qy8
โ— 2D Glow Tutorial: https://youtu.be/WiDVoj5VQ4c

โ— Get Gothicvania Ch...

โ–ถ Play video
#

I need an outline for my 2d sprites, but they need to be soft to cheat shadows

lunar valley
spiral tendon
#

yeah

spiral tendon
#

or completely soft

lunar valley
finite tree
#

is there a way of having an array stored somewhere, and use it from shader graph/custom function node?
like for example if i had an array of points (red on image) and would want to render a quad with different color by "distance" (black)
it would be just vector2s with values from 0,0 to 1,1 and be local to the quad
the array wouldnt be constant, its size and data inside would get changed by a c# script

well, can a custom function even access other variables than its input?
or is there a better approach for this kind of thing?

i guess i could just spawn smaller quads from that c# script on their location, with their own shader on top of the base one
but i would like to try to keep it to just one quad using that data, if possible

hearty obsidian
#

Any idea why reading from a global color yields a brighter color than a local color?

lusty sundial
north bolt
lusty sundial
#

oh weird, maybe try the worse buffer extension?

#

thatโ€™s weird

north bolt
#

Iโ€™ve heard bad things about itโ€ฆ

lusty sundial
#

it does some bad thingsโ€ฆ

north bolt
#

@lusty sundial the better was buffering but then it worked before it bettered

regal stag
lusty sundial
#

@north bolt I think you need to buffer before bettering, I havenโ€™t better buffered in a bit so Iโ€™m not positive about that though

hearty obsidian
#

@regal stag You absolute unit, thanks

lusty sundial
regal stag
#

Would also avoid using != to compare floats

lusty sundial
#

yeah, just like i suggested

#

thanks

#

i really appreciate your help

minor remnant
#

Im trying out shader graph in URP in a new project and for some reason I get these weird lines with the normal vector?

#

disabling scene lighting in the viewport fixes it but lights shouldnt affect unlit shaders??

regal stag
minor remnant
regal stag
#

If it's for debug purposes, you may also want to disable post processing temporarily so you can check colours accurately.

warm pulsar
#

i guess this is basically a texture

warm pulsar
#

ah, but you can just do arrays straight-up; nice!

wraith bison
#

anyone know why voronoi and noise shader graph nodes aren't showing their previews? I'm on 2022.2.15

normal cape
#

I don't know whether compute shader talk belongs in this chat, but is there a way to pass a dictionary into one? I am making a game like teardown and minecraft combined and I currently need a raycast function, but it was too slow on the cpu so i am trying to move it to the gpu.

#

basically what i need for the shader is a way to look up voxels by position without having to loop through the millions of voxels i have

spiral tendon
wraith bison
# spiral tendon maybe attach a preview to it?

I tried outputting it to a preview node but nothing showed. Seems like none of the procedural nodes worked, they were all blank. The effect is definitely applied to the material though.

spiral tendon
#

then it might be a bug, have you tried using a lts version of unity?

regal stag
#

Probably a bug. Haven't seen that one before. Seems to be a few graph issues in 2022 versions. I also get errors when deleting nodes.

wraith bison
#

yeah.. just recreated the project with 2021.3.1 (lts), the nodes appear to work again.

grizzled bolt
wraith bison
ripe dew
#

Hey so i was following a tutorial for a clipping plane shader so I can hide an object on the other side of a portal. But the tutorial was for Standard shaders. Is there any way to convert this for URP?

#

Shader "ankyusie/ClippingPlane" {
Properties {
_Color ("Tint", Color) = (0, 0, 0, 1)
_MainTex ("Texture", 2D) = "white" {}
_Smoothness ("Smoothness", Range(0, 1)) = 0
_Metallic ("Metalness", Range(0, 1)) = 0
[HDR] _Emission ("Emission", color) = (0,0,0)
}
SubShader {
Tags{ "RenderType"="Opaque" "Queue"="Geometry"}

    CGPROGRAM

    #pragma surface surf Standard fullforwardshadows
    #pragma target 3.0

    sampler2D _MainTex;
    fixed4 _Color;

    half _Smoothness;
    half _Metallic;
    half3 _Emission;

    struct Input {
        float2 uv_MainTex;
    };

    void surf (Input i, inout SurfaceOutputStandard o) {
        fixed4 col = tex2D(_MainTex, i.uv_MainTex);
        col *= _Color;
        o.Albedo = col.rgb;
        o.Metallic = _Metallic;
        o.Smoothness = _Smoothness;
        o.Emission = _Emission;
    }
    ENDCG
}
FallBack "Standard"

}

#

Or does URP not support stuff like this anymore?

regal stag
rugged relic
#

I have a material with a shader I made with shadergraph attatched to it, and it requires a texture as an input. I need to use this shader on most of my gameobjects in my scene, but if i change the texture input on the material, it changes all of the other gameobjects' material. Is there a way for me to apply this change to each gameobject individually?

ripe dew
ripe dew
north bolt
violet pebble
#

Hi, i'm trying to write a shader that will unwrap an object's uv map and draw it to a flat texture. I'm very new to shaders and materials, and don't know how to draw a shader to a texture, and then also how to view the texture like in the inspector or on a plane etc. Any help or tips or links would be greatly appreciated!

#

Here is my hlsl file: ```#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes {
float3 positionOS : POSITION;
float2 uv : TEXCOORD0;
};

struct Interpolators {
// Although this is clip space, it will be populated by UV position, leading to texture map effect
float4 positionCS : SV_POSITION;

float3 positionWS : TEXCOORD0;
float2 uv : TEXCOORD1;

};

float4 _PaintColor;
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
float4 _MainTex_ST; // Auto set by unity to Tiling and Offset values. Used in TRANSFORM_TEX to apply uv tiling

Interpolators Vertex(Attributes input) {
Interpolators output;

VertexPositionInputs posnInputs = GetVertexPositionInputs(input.positionOS);

float2 uv = TRANSFORM_TEX(input.uv, _MainTex);
output.uv = uv;
output.positionWS = posnInputs.positionWS;

output.positionCS = float4(0, 0, 0, 1);
output.positionCS.xy = float2(1, _ProjectionParams.x) * (uv.xy * float2(2, 2) - float2(1, 1));

return output;

}

float4 Fragment(Interpolators input) : SV_TARGET{

float2 uv = input.uv;

float4 colorSample = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
 
return colorSample;

}```

amber saffron
violet pebble
#

oh sorry i should have been more clear. this is a first step in my attempt making a system for painting objects in a scene, similar to Splatoon. I want to have a c# script running that uses this shader to draw pixels onto a texture that matches the uvs of my mesh, and then I can put the texture into a shader to display the paint if that makes sense.

#

so the goal architecture i'm thinking of is:

Paint() gets called on object that is paintable
Paint calls the shader, giving it a position and radius for the paint splat,
Shader uses world position to calculate if fragment should be shaded, and then colors in the corresponding pixel(s) on a texture, in location that matches the uv map
Paint Texture is blended on top of normal texture in a shader graph material, so final output would be the object with paint on it in the spot i want

amber saffron
#

I think Andrรฉ will explain it better than me here ๐Ÿ™‚ : https://www.youtube.com/watch?v=FR618z5xEiM

This project is a take on the Ink System from one of my favorite games: Splatoon! Letโ€™s explore game dev techniques and try to achieve a similar effect!

Check out @TNTCProject 's complementary video: https://youtu.be/YUWfHX_ZNCw

PROJECT REPOSITORY

https://github.com/mixandjam/Splatoon-Ink

REFERENCES
-----...

โ–ถ Play video
violet pebble
#

๐Ÿ˜ฎ I was actually already watching and basing my architecture off that video! haha

#

I wanted to build my own version from the ground up though, which proves difficult since I don't know much about renderers, textures, and shaders. I have been following some basic shader tutorials recently though

#

I just have trouble understanding certain parts of Andre's code, mostly the command buffer stuff like:

        command.SetRenderTarget(mask);
        command.DrawRenderer(rend, paintMaterial, 0);```
amber saffron
#

All the painting on object part is done is the attached video here : https://www.youtube.com/watch?v=YUWfHX_ZNCw&t=0s

Painting in video games is a very common practice, more than one might think.
It's often used to paint or interact with the environment,
but also it is used to dirt the player and create consistency between him and the game world.
Today we'll recreate this effect on Unity.

@mixandjam video:
https://youtu.be/FR618z5xEiM

Our sound designer and...

โ–ถ Play video
violet pebble
#

I think i've watched this too but i'll give it another shot, thank you

soft harness
#

is there a way to hijack the Standard lighting model to set the output to always be greyscale?

vivid marten
#

uhm why does my texture look so weird?

soft harness
#

wym by "look so weird"

vivid marten
#

don't you see the difference?

#

the edges are weird on the first image

#

compared to the second

cosmic sphinx
vivid marten
#

oh ๐Ÿค”

lunar valley
soft harness
lunar valley
soft harness
#

I'm aware, that's what i'm asking

#

how i'd do it

lunar valley
soft harness
#

i make the albedo greyscale but the light color tints the albedo and i'd like that to stop

vivid marten
#

any idea why the water looks a bit darker here?