#archived-shaders

1 messages · Page 46 of 1

lunar valley
#

well gj then

young fog
#

I did not expect having a pure black colour on the top there to just work

tender edge
#

only got 2 textures and seems to work so far, but how would i use the last vertex color channel?

#

i could add extra lerps for the base diffuse just offscreen to the top but i could only connect it to its own heightmap

tender edge
#

its basically just a shader to paint vertex colors, and use heightmaps for blending

lunar valley
lunar valley
#

tbh. I have never seen vertex color being transparent, why would that be something you want to add?

tender edge
#

polybrush uses the alpha channel aswell, its just another texture

lunar valley
tender edge
#

basically because i'm short 1 lerp node, the ones i have here are all used to lerp the textures together, and the heightmap gets added as a mask, but for 4 textures to lerp you only get 3 lerp nodes. so im unclear what to do for the base texture

#

(3 lerp for albedo, and 3 for normals)

#

i'm also unclear on what the normal and blend on the triplanar node are for, i couldnt connect my own normals to them

lunar valley
fringe badger
#

Short question, I've got a default Unity unlit shader, where everything's default, but the fragment shader outputs a color value:

            {
                return float4(0.1529412,0.07843138,0.08627451,1.0);
            }

As a result, this is the output:

#

However this is the color value for that code

tender edge
#

ahh, i already got a float connected to the masks. to controll all blends at once, im guessing i could use the blends on the triplanar node to blend individually

fringe badger
#

what's wrong?

lunar valley
fringe badger
#

Color picked from a palette

#

Oh also with GetPixels() from Texture2D for that matter

lunar valley
fringe badger
#

I did both GetPixel() and GetPixel32() (the latter for easy debugging)

#

If I make a simple shader with similar values in ShaderToy (GLSL) it does output the correct value

#

Ah, switching away from linear space to gamma space solves the issue in Unity

#

why is that?

lunar valley
#

ah well good old gamma correction

lunar valley
fringe badger
#

what do I read to understand what linear vs non linear means?

tender edge
fringe badger
#

hehe that was in regard to my own issue @tender edge 🙂

tender edge
fringe badger
#

awesome @lunar valley -- I'll read up on that

#

thanks

tight phoenix
#

what are possible causes why sampling the unity shadow texture has a weird bright spot that exists a certain distance away from the camera

#

i need this data to not have that weird spot in the middle

#

its ruining the entire shader and I have no idea how to prevent it or even find its origin

tight phoenix
#

Can you suggest somewhere else to ask for help? I feel like I reach so few ears here but I can't seem to reach ears anywhere no matter where I post

lunar valley
#

I am sorry to hear that, I haven't worked much with the shadow texture so I probably wouldn't be much of a help. You could always try asking on the forum

torpid plank
#

Not sure if someone can helpme, but I have a problem with PSXEffect shader texture, when using multiple rectangles as floor instead of a big one I have this problem (shadow on player becomes black), any one know how could i solve this?:

tight phoenix
pale python
#

hey which is more optimized approach? , Im trying to understand how shader/memory works

1 - make arrays from 2-10 in a shader and only pass the one I need to the function ?
2- just make 1 array of (10) items and pass it everytime even if only 2 items were occupied were the other 8 empty?

#

??

mental lake
#

I'm getting a shader error with a Blit shader:
'SampleBias': no matching 3 parameter intrinsic method...

For the line of code:
float center = SAMPLE_TEXTURE2D(_BlitTexture, sampler_BlitTexture, uv)

This error only occurs during the build process, and the shader (used in a renderer feature) does work in the editor

clever lynx
#

How would you split a texture red channel into 2 ranges? (range1 = 0-127, range2 = 128-255)
I'm using a Split node, then remap 0-0.5 as my range1, but I'm not getting the expected output ...

vocal narwhal
clever lynx
vocal narwhal
#

⚠️ When asking questions please include which render pipeline you are using ⚠️

🗃️ Documentation

Shader Graph
Surface Gradient Bump Mapping

📚 Resources

RenderDoc

HomepageUnity documentation

Tutorials

External resources: General

External resources: URP

External resources: Shader Graph

💬 Forums

Shader GraphShaders

🗺️ Roadmap

ShadergraphShader System

tame ingot
clever lynx
#

Thanks @vocal narwhal and @tame ingot both the step and comparison methods are working.

tardy crypt
#

Hi, I'm following a tutorial for learning some particle system type stuff with HDRP. The tutorial says to enable the Allow Material Override option but I don't seem to have that option anywhere on my Graph Inspector as the tutorial does.

#

Am I supposed to find this option somewhere else or how do I go about this then?

tiny hornet
#
[MaterialProperty("_Emission")]
public struct MaterialEmission : IComponentData
{
    public float3 Value;
}

Shader error in 'Master': 'LoadDOTSInstancedData_float3': no matching 2 parameter function at line 1021 (on d3d11)
Shader error in 'Master': undeclared identifier 'unity_DOTSInstancingF12_Metadata_Emission' at line 1021 (on d3d11)

https://media.discordapp.net/attachments/1064581837055348857/1105170509584404480/image.png

I created this thing, and set the shader graph property's override to Hybrid Per Instance, as well as Allow Material Override on the graph settings, however there are shader compiler errors. Not sure where to look.

tiny hornet
#

It was because the graph's precision was set to half , when set to Single it works fine 🤷

swift loom
#

I'm trying to find information about the structured buffer limitations for a compute shader but I can't really find anything. How many structured buffers can you have in one kernel for modern GPUs on Windows?

#

I have 10 structured buffers atm and it's starting to do some weird stuff, like crashing NVENC in OBS.

lunar valley
#

until memory runs out i guess 😛

calm citrus
#

So I have a sea shader in my game

#

But as soon as I move to the right, it goes invisible leaving a highlight around the objects its hitting

regal stag
calm citrus
#

Happens in editor and game view

lunar valley
swift loom
#

@regal stag do you think this limitation is still present in the experimental branch of DX12 in Unity? That's what I'm using atm.

calm citrus
swift loom
#

but 8 would track with my amounts where it started acting up

calm citrus
#

Just an shader graph

regal stag
#

Seems to be different tiers, 8, 64 or full heap

swift loom
#

Yeah I've found the tiers but I didn't quite understand what constitutes as a tier

#

i guess DX11 cards are tier 1

#

my card supports 12_1 and 12_0 so i guess that should put it in tier 2 resource binding

regal stag
# calm citrus

Are there multiple water planes here? It looks like two transparent planes not sorting correctly.

swift loom
#

Seems I had to manually set pragma target 6.0 maybe. Doesn't crash now but not sure if it works.

#

I guess Unity defaults to target 5.X for compute shaders

onyx talon
#

Can I use CGPROGRAM in shader graph?

regal stag
distant scarab
#

I am trying to create shader for my text box similar to this image. I can able create border and inner glow for square but not for rectangle any suggestion.
Thanks in advance

pale python
#

hey,
is it hard to get the vertexes of a shader shape? for example

#

is it possible to get the outline vertexes that makes those shapes ? if yes , how hard could it be ?

#

im currently learning shader and i wonder if there is a way to create an outline of any shape like the ones mentioned above and get the vertexes that creates the shape

pale python
#

for example for a cirlce , we just need the center and the radius and with a simple pi * (r*r) we could resemble the same shape, but for a complex shapes, i dont know what can be done

low lichen
#

Like in a script?

pale python
pale python
low lichen
#

It's probably easier to dilate/inflate the edge pixels with a custom shader.

pale python
low lichen
#

But this is particularly for wide outlines. For smaller 1px outlines, there are better approaches.

pale python
fair jackal
#

can someone help me reintroduce alpha-clipping shadows back into my shader similar to how shadows in URP lit shader works?

amber saffron
fair jackal
#

shader code I'm pastebinning it right now

regal stag
#

You either need to create your own fragment shader for the ShadowCaster pass, or use the keywords and properties names that it expects.

#

I think these properties would work

[Toggle(_ALPHATEST_ON)] _AlphaTestToggle ("Alpha Clipping", Float) = 0
_Cutoff ("Alpha Cutoff", Float) = 0.5
#

Might also be _BaseMap instead of _MainTex

#

Ah but it's a sprite shader too...

amber saffron
#

Or just use shadergraph ? 😅

regal stag
#

Yeah could be easier

fair jackal
#

alright I'll take a look at both, thanks!

fair jackal
#

pretty simple shader graph to get it working, now I'm just curious is there a way to get the cameras current x rotation with a graph node?

amber saffron
#

Or the camera forward with the Camera node

fair jackal
#

is there a way to output node values as numbers?

#

so I can visualize what their values are?

amber saffron
lunar valley
#

I wish there was a way to debug.log in shader blushie

amber saffron
#

Outputs a readable text, applied to the specified UVs

fair jackal
#

ooo that's pretty cool. Sometimes I just wanna see what numbers are as I have a better time grasping them

lunar valley
amber saffron
regal stag
#

It's important that any values being debugged that way are the same across those pixels though, right?

low lichen
#

Just read in between the garbled pixels to get all the values 🧠

grand jolt
#

My shader material wont show up in game but does in the scene view

proper ore
#

Does someone know how to support single pass stereo rendering for built-in render graph shaders?

#

I know that URP fixes this but I can't swap to it because it breaks all my materials and UI rendering

uneven jungle
#

A simple shader but it wont update on my material? What do i do?

Shader: Lit Shader Graph

regal stag
regal stag
uneven jungle
grand jolt
#

well, now it doesn't appear at all

proper ore
grand jolt
#

I have it set to screenspace camera and a blank image will appear but the material object still wont

regal stag
# grand jolt well, now it doesn't appear at all

If you changed the Canvas render mode it might be behind walls now since it puts it on a plane infront of the camera, at a default distance of 100. Can adjust the plane distance on the Canvas component but keep it within the near plane.
Or can overlay the UI using another camera which may clear depth. Might be more info here - https://www.cyanilux.com/faq/#sg-ui, (but the implementation varies between pipelines, I only really know URP)

grand jolt
#

im using URP

grand jolt
#

but the material one still wont

#

@regal stag im not sure why this happens?

regal stag
#

What type of graph is it?

grand jolt
#

idk if this helps

#

ive had it working before

#

then legit just stopped working at some point xd

grand jolt
#

this is the mat the shader is applied to

regal stag
grand jolt
#

im not sure which one it is, how do I check

#

~<

regal stag
#

It's in the graph inspector/settings

#

Unless you're on really old versions, then it depends which "master node" you have

grand jolt
#

i dont have that open i dont think

#

i just have inspector occlusion and lighting

#

oh wait

#

im stupid

#

1 sec

#

yeah its Unlit

#

@regal stag it is Unlit

#

oh shit changed it to sprite and it worked

regal stag
#

Maybe try the Sprite Unlit, see if that makes it appear

grand jolt
#

yeah it worked

#

thanks

#

why the hell didnt that work

#

cuz it was working for awhile and then I added some stuff to the UI and it stopped working lol

regal stag
#

Yeah I've experienced the same thing in the past. I think it's better in newer versions, but still doesn't have proper support for UI

grand jolt
#

i think this is unity 2021

#

2022*

#

not too sure even tho its the top middle usually

#

ah 2020

lunar valley
#

I would like to make it so that everything that intersect with a transparent cube is going to be clipped and I can't get it quite to work...

violet parrot
#

hey all, I’m new to Shader Graph and I’m trying to create a new transparent material. I’m getting weird artifacts on the rendering which I thought forcing depth write should fix but it doesn’t seem to make a difference. Does anyone know how to solve this issue?

#

I want the material to ignore itself if it happens to overlap, so for example the tail above should not be visible behind the body

violet parrot
#

thanks! guess the solution wasn’t as simple as I thought 😅

#

got it working with the prepass shader, thanks again @regal stag!

tight phoenix
#

What's the difference between view direction and camera direction? (if any?)

lunar valley
# tight phoenix What's the difference between view direction and camera direction? (if any?)

I do not actually know, but if I would guess than its that the cameras direction is just literally the cameras forward direction. But the view Direction is the actual direction going out from each pixel, probably calculated with something similar to this cs float3 viewVector = mul(unity_CameraInvProjection, float4((o.screenPos.xy/o.screenPos.w) * 2 - 1, 0, -1)); o.viewVector = mul(unity_CameraToWorld, float4(viewVector,0));

tight phoenix
tender edge
#

any tips on how i could improve the blending of textures?

tender edge
#

i followed the technique as seen in this video from polytoots, but im guessing i cant get the same effect if my textures are so low res

grand jolt
#

How do you set target shader model in Compute Shaders?
I tried adding #pragma target 4.0 at the very top, but it returns Shader warning in 'test': 'target' : unknown pragma ignored at kernel CSMain at ...

#

Maybe shader models can't be set in compute shaders? I'm using bitwise operations (leftshift) and I'm afraid it doesn't work properly (didn't test thoroughly tho), in HLSL it is said that these operands are only supported in shader model 4.0 and above...

sudden dust
#

Hey Everyone, my Water Shader is splitting the object faces, something that I don't want to. Is there any way of keeping the faces together?

tardy crypt
#

I'm trying to learn shaders and using these as a starting point: https://youtu.be/KeOPgH-v-ts?t=631

When I'm working on this section of the video (10:30+), my shader graph shows that the texture should be scrolling downwards but when the shader graph gets applied to the cylinder it doesn't scroll at all, it simply rotates with the cylinder performing its rotation.

To try everything Brilliant has to offer—free—for a full 30 days, visit https://brilliant.org/GabrielAguiarProd/ The first 200 of you will get 20% off Brilliant’s annual premium subscription.

Now you can create intriguing portals for your Games!

00:00 Intro
01:32 VFX Graph - Plane and Cylinder
03:56 Blender - Modeling Cylinder
06:05 Shader Gra...

▶ Play video
#

I've closely looked at the shader graphs in the video and mine seem to match:

cobalt totem
#

If I apply this transform to go from World space to object space, how do I get the world space from the object space?
rayOrigin = mul(unity_WorldToObject, float4(rayOrigin.xyz, 1));

#

I've tried float3 worldPos = mul(unity_ObjectToWorld, float4(samplePos.xyz, 1)); but that doesn't seem to have the desired effect

rancid loom
#

so, im trying to use legacy shaders > particles > multiply, material on a UI element but im getting
"doesn't have _Stencil property" warning, can I disregard or is there a UI mat that has multiply somewhere ?

dense bane
#

when a game is playing on the monitor attached to the UHD 770, why is GPU usage near zero?

rare wren
dense bane
rare wren
#

Google 'windows run game on iGPU' @dense bane

dense bane
rare wren
#

No lmao
I don't know all the exact settings names, and couldn't bother.
I'm helping out in free time, so just take the advice

small elbow
#

Guys, I'm trying to create a custom shader using shader graph, in every other nodes, things are going fine, but scene color node is not outputting the output adding a screenshot for reference

#

am I doing something wrong here?

lunar valley
lunar valley
lunar valley
small elbow
#

@lunar valley , in that case I don't see a noticable change in the object

#

@everyone, a small suggestion, shall we just keep one topic specific discussion in corresponding threads? it will make the section less clumsier

regal stag
#

Check the value on the Material itself. If you saved the graph after creating the property, before changing the default value, it would have defaulted as 0

#

Could also try adding a Saturate node before the power. Maybe there's negative values messing with it?

dense bane
rare wren
# dense bane "google it up" is not an advise, you're wasting my time pretending to know and ...

As far as I know some motherboards allow output from the dedicated GPU via the iGPU. There can be a bios option, which if there is named differently per board vendor and not all boards have it.
If that's not found I don't think there is a way to force a display to run on iGPU

So the best solution is to force certain applications to use the iGPU if that's what you want, which is easy to do

swift loom
#

So I've ran into an issue using for loops in compute shaders and I'm not sure this issue is solvable or not. Basically if you assign a value to a global variable inside a nested for loop, and then attempt to read it outside of the for loop after breaking, it's like the variable becomes unusable and either returns garbage data or resets the GPU.

https://pastebin.com/sd0JUpqi

Are nested for loops that bad in compute shaders?

#

This code always returns 0

low lichen
#

I've never modified global variables like this, so I don't know if it's supposed to work

swift loom
#

i have not tried using inout, not sure how it works exactly. I've tried setting the variables as locals though but it doesn't seem to matter. right now i'm trying to write to a RWTexture2D instead but it doesn't seem to work either? The issue is that I can't carry a value out from the for loop to even return anything

#

it seems if you use a for loop as the outer loop and a while loop as the inner loop it might work. nested for loop is no go.

#

nope nvm, it worked in the test project but bluescreened my computer in my main project :)

swift loom
#

After bluescreening the code in my testproject that I linked works

#

?????

alpine island
#

hi, some one know wy my scan lines effect is not mixing with the scene?

regal stag
#

If it's the new fullscreen graph you probably want the URP Sample Buffer node instead

alpine island
regal stag
#

What pipeline are you using

alpine island
alpine island
regal stag
#

How are you applying the shader to the screen

#

UI Image? Blit feature? Fullscreen graph + feature?

alpine island
regal stag
#

Right, then you want to create a Texture2D property named MainTex and sample that to obtain the source texture.

alpine island
regal stag
alpine island
regal stag
#

Connect it to a Sample Texture 2D node first

alpine island
tight phoenix
#

how do I correcy these two errors?

#

What is cosTheta quivalent of?

#

there's no node for that

#

dot product maybe 🤔

#

Did I make a mistake in reproducing that formula? getting broken pink

#

dont know why it tried to sample a texture but neat

tight phoenix
#

frustrated by assumed knowledge that renders the entire tutorial worthless and useless 🔥

tardy crypt
#

I tried testing it on a different model (the built in sphere) since that is basically what the shader graph preview shows and the result is not the same as the shader graph preview.

lunar valley
tight phoenix
# lunar valley thats kinda cool

yeah I saw it do this unprompted in an earlier question and asked it 'draw an ascii diagram of the shadergraph nodes' to get that

lunar valley
#

neat

tight phoenix
#

neat 📸

#

still hammering away at this shadow map thing that ive been doing for like two weeks now

#

its SO close to being perfect

#

but the shadow cascade thing is ruining the entire effect

spring fox
#

what is this supposed to be? It looks really cool

tight phoenix
#

I need to 'solve' whatever tf the shadow cascades are causing this to fuck up but so far its been nothing but dead ends

tight phoenix
#

essentially this

#

where the light hits the mesh, distance from the fragment to the spot is zero

#

the further the fragment is from where the light hits the mesh in the direction of the main light, the larger the value

tight phoenix
# tight phoenix

the problem is something to do with shadow cascades however that causes this

#

I can't seem to find the exact point the problem occurs to correct it

#

I cant even properly debug it to tell you exactly WHAT the problem is, all I have is the fucked up output as shown

#

the problem occurs directly on the edges of the shadow cascades however so I am assuming its something to do with them

#

this is me scrubbing the shadow cascade value

spring fox
#

That’s wack

tight phoenix
#

Yeah, I need to solve it to not do this

#

but I cvan't figure it out 🤔

#

I have very little hope of solving it myself, I am not a shader wizard, I am a monkey with a typewriter

#

I have just been posting it constantly everywhere in hopes someone smarter than me will see and take pity on me, because thusfar all my own attempts to solve have failed

#

dont really have any prospects for a sollution otherwise, ive exhausted every doccumentation or other implimentation I could find

#

I think this is responsible in some way?

#

because shadow depth shows that exact weird wtf banding

#

but again, I have no answers or ability to debug this, all I have are outputs that I have zero comprehension why they do what they do

#

and attempts to trace it back to a source cause have been little more than flailing blind in a cave

#

do you see any obvious cause of my problem here?

#

I have been hammering at this for weeks and I cannot stress enough how I really really really need help with this

#

literally all I have is perseverance 🔥

#

the cutoffs happen at such exact regular intervals

#

maybe there is some way to subtract them out using some kind of space coordinate and a Fraction node

#

but Im too stupid to figure out how to do that

#

or where to even begin

#

yeah im starting to get distressed again

#

every single day for weeks now its wake up -> work on this stupid fucking POS shader -> fail to make any kind of progress -> turn to every forum I can find to beg for help -> radio silence -> collosal meltdown -> repeat

#

i have literally no other choice or option but to repeat the same thing every single day hoping something different will happen

#

and so far failed every single day, every single second of every single hour

#

and its utterly destroying my mental health to fail this frequently

#

I am begging you to help me solve this

#

I am well aware that desperation is utterly repulsive

#

but I have no other recourse

#

im well aware of how incredibly worthless and pathetic this makes me

#

im going into crisis now so here's the relvent assets while I give up as the worthless POS not deserving of help that I am

#

if someone could tell me what I have to say or do to deserve to get some help that'd be great

#

thanks

#

its so close to done

#

but no one will help me bridge the last 1%

#

and its so incredibly frustrating and I dont know why I don't deserve help, can't get any help

#

I'm sorry i should shut up im obviously losing my shit

low lichen
#

I'm looking at your problem and there's nothing that screams out to me as wrong. That's why I'm not responding; because I have no notes.

tight phoenix
#

thats fair and appreciated, being acknowledged that I am even talking or exist is appreciated

#

its so hard to be a developer and mentally insane

#

its so incredibly frustrating to be the person who drops everything the instant anyone asks me for help, but I don't get the same treatment in kind
I know that isnt a reasonable expectation, that its an unhealthy standard, but its so fucking frustrating to be raised on promises of 'work hard and youll succeed' when its all bullshit and nepotism

low lichen
#

My guess was that the shadow depths were being encoded differently for each cascade and needed additional processing to extract the correct values, but looking at the URP source, I can't see that as the case.

tight phoenix
#

i noticed the problem only really 'happens' after the values get adjusted

#

when its just the raw data it looks right

#

but I need a looooooong range of 0 to 1

#

and when you do that, the cascade lines show up

#

all of my attempts to rescale the values before or after the magic black box that just makes it go havent resolved this problem

low lichen
#

I'm guessing it's not an option for you to just disable shadow cascades?

tight phoenix
#

maybe there is some way to only sample one cascade instead of all of them??

grand jolt
#

What does a HLSL matrix (say, int4x3) translate to in C#? I'm using a RWStructuredBuffer with a struct that contains such matrix, and I'm wondering what kind of field the equivalent would be in the C# equivalent of the struct.

tight phoenix
#

but to my knowledge doing that wouldnt work beyond the first cascade since there'd be no data

grand jolt
# grand jolt What does a HLSL matrix (say, ``int4x3``) translate to in C#? I'm using a ``RWSt...

For example:
HLSL:

struct MyStruct {
  int3x4 matrix;
};

C#:

struct MyStruct {
  ??? matrix;
}

This is needed because I'm passing data from a compute shader to the CPU through a RWStructuredBuffer<T> with T being MyStruct. Both the C# script and the compute shader need to have the same struct with the same elements, each element having the same stride -> they have to be virtually identical types, no tricks with arrays or so.

tight phoenix
#

im goign to step out for a walk for my own sanity's sake, back in a bit

low lichen
grand jolt
#

If it has some other auxiliary fields or so it won't work

grand jolt
#

I've read a bit, it seems Unity.Mathematics is exactly made to work with HLSL, or generally shader languages

grand jolt
#

Hm, I'll use it, but pretty annoying if I have another possible space to debug if that doesn't actually work

#

Thanks for the info ^^

real nacelle
#

Hey, i think i saw an option to automatically fix shaders for URP in the project, but now i can't find that anymore. Somebody knows where that is, or was it maybe part of some plugin i had?

low lichen
swift loom
#

Any clue what might be causing these artifacts to appear when I render a sprite to a render texture using a compute shader? It still works fine because the alpha on the non-character pixels are all 0 but if possible I'd like to avoid these stretched out pixels around the object.

#

All my render textures are created with these settings

preRenderTexture = new RenderTexture((int)robRend.sprite.rect.width, (int)robRend.sprite.rect.height, 1, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
preRenderTexture.enableRandomWrite = true;
preRenderTexture.filterMode = FilterMode.Point;
preRenderTexture.wrapMode = TextureWrapMode.Clamp;
preRenderTexture.Create();

regal stag
swift loom
#

hmmm. alright. maybe i'll leave it in. i was going to use the textures as masks for shadowcasting but since the alpha is generally accurate i'll just use that channel.

regal stag
#

Guess it depends what the result is used for. If you don't want the colours stretching out you can just multiply by RGB by the alpha channel.

swift loom
#

oh that's what that is for

#

yeah makes sense now

tight phoenix
#

does anyone know what these errors are or how to solve them

#

the lines and words its referencing dont exist:

#

"SurfaceDescription" doesnt exist anywhere

regal stag
#

You're missing some semicolons

tight phoenix
#

oh yeah 🤔 there are none

regal stag
tight phoenix
#

thats what I get for blindly trusting in gpt awkwardsweat looking at that now

prime shale
#

yeah

#

in my experience if your expecting good results from GPT you need to really guide it

#

and know the fundamentals of what your asking it to do (not saying you dont know)

fringe badger
lunar valley
lunar valley
fringe badger
#

is the formula not the ^2.2 ?

#

for the entire color float?

lunar valley
fringe badger
# lunar valley yeah

Power of 2.2 gives a different output. Or did you mean to say the formula is something different?

pale python
#

hi , could someone explain to me what does it mean to do return a float.xxx
for exxample

 fixed4 frag(v2f i) : SV_Target
 {
    float f = 0.1;
    return float4(f.xxx,1);
}

when its ok to do f.xxx and when f.rgb ?

#

does f.xxx = float3(0.1,0.1.0.1); ?

#

also what is f.xyz or f.zyx ? they didnt work in my example but i saw some functions that has them so I guess , in certain conditions , they're acceptable, but what is it ?

#

im still learning shaders and almost everywhere ppl are using those symbols without any explanations, when I tried to google it , other things poped out.
how do I google it ? what does it called?

kind juniper
#
f.xxx would be the same as float3(f.x, f.x, f.x)
f.zyx == float3(f.z, f.y, f.x)
kind juniper
#

Swizzling is very common in shader code. It's like the hlsl sugar.

pale python
flat hedge
#

Hi, I've been struggling to delete this node from a shader graph but I can't

#

it happened because I was copying a graph from another project and even tho I copied the subgraph first it just messed up completely

#

I've been trying everything and when I simply delete it this happens:

#

as you can see, there is no * to save anything but if I try pressing save this happens:

#

I even tried finding a method with this name and ID in the generated code but there is no such thing:

#

I would really appreciate your help because I am quite in a hurry

#

one more thing that I forgot to mention is the following error when deleting the node:

regal stag
# flat hedge I've been trying everything and when I simply delete it this happens:

I also get problems like this in 2022, it's very annoying. If you aren't already could try updating to the newest possible minor version in the hope it's fixed.
If the validation is the problem, you could try creating a Sub Graph Asset, then edit the GUID in the meta file to match that string. Then try deleting the node when the validation is fixed and delete the SubGraph asset after.

flat hedge
regal stag
zenith stirrup
#

!code

echo moatBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

distant scarab
#

Hi, I created this simple shader which keeps the border size as it is irrespective of object scale. it is working fine in 3d objects but not in the UI elements such as panel.
any help. thanks in advance.

distant scarab
regal stag
distant scarab
distant scarab
clever lynx
#

Is there a way to have the top half of the skybox UVs flat on the UV space instead of having the entire sphere cut on the side?

grizzled bolt
clever lynx
clever lynx
grizzled bolt
#

In SG you can project a texture from above in object space with UVs like this

#

The offset is for centering a texture in one by one unit scale

clever lynx
waxen ridge
#

I have an EditorWindow that helps me build houses from prefabs such as floors, walls etc (not in game view, but scene view). I want certain parts of my floor / wall prefabs to be red instead of their usual material (only parts, not the entire thing) if they are behind some collider such as the terrain collider for example.
How would I achieve this? I imagine with shaders. Could anyone point me in the right direction on what to read up on? Thanks (rendering pipeline is URP)

regal stag
# waxen ridge I have an EditorWindow that helps me build houses from prefabs such as floors, w...

You can use a shader with ZTest Greater to only render fragments/pixels if their depth is higher than the depth buffer.
There's a similar example in the docs using the RenderObjects feature overrides - https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@16.0/manual/containers/how-to-custom-effect-render-objects.html
Those would make it appear behind all opaque objects though, not just specific ones like terrain. If that's important you'd probably have to render the terrain depth into a custom buffer, sample it in the shader with ZTest Always, compare depth and clip/discard pixels manually.

waxen ridge
south oar
warm pulsar
#

i am going slightly insane: if i name a property _EmissionPower and have a float variable named _EmissionPower, it's always zero. if i name it anything else, it works fine.

this is for a VRChat avatar, so it's the core renderer in 2019.4. baffled!

#

my workaround is to not name it that, but...it's very strange

#

the compiled code seems identical, save for the different name

regal stag
warm pulsar
#

nah, i can set the parameter without it getting overwritten

#

although, I could still believe an animator is somehow messing it up...

regal stag
#

Yeah might be fine on the material but edited through a MaterialPropertyBlock or something

warm pulsar
#

oh, bah, that's what it was 🤦

#

i guess the animator is using a property block?

#

thanks :p

regal stag
warm pulsar
#

the property used to be very badly named (it was called "emission power" but was actually albedo)

#

so i fixed that and added an actual emission power property, and... oops!

#

i just realized that the new albedo color is actually also emission, because I forgot to multiply by the light color...

teal hornet
#

So I want to replace every grayscale with a set color which I will do by sampling a gradient texture but right now I'm doing it by copy pasting a bunch, there must be a better way right?

#

The value of the gray is a consisten increase of 2 in HSV if that helps in any way

regal stag
teal hornet
#

It's still 1 at a time though, can I make it go from 1-30 at the same time?

pale python
#

hey,
is it possible to turn shader into an image ?

#

and i mean a jpg or png formate image

teal hornet
#

wdym shader to image?

#

What does your shader do?

pale python
#

like drawing and saving files ?

#

that make more sense

teal hornet
#

If your shader has an effect on your entire scene you apply the shader to a sphere and place your camera in the sphere, that camera can output to a render texture, then you can use EncodeToPNG

pale python
#

i have another question as well , i asked yesterday but no one replied to it.
if I need to pass an array of floats to a function with length between (1 to 10 items )
I learned that shader only accept fixed array and it doesnt have option for dynamic array.

how do I solve this ?
A - make 10 functions 1 for each possible number of items float arr[1] , ... float arr[2] ..., float arr [10]
B - Make 1 function with the highiest possible number of items 10 and just pass to it empty values for the items we are not using

meager pelican
# pale python i have another question as well , i asked yesterday but no one replied to it. if...

IMO (B), but remember that everything in shaders is passed BY VALUE. If you do (A), how do you end up deciding on what function to call of the 10 possible functions? That decision logic will PROBABLY be just as expensive if not more than the overhead of the extra bytes passed.

But maybe even better is to assign the values to a global array, if setting them is something you can deal with without multiple threads clobbering stuff.

pale python
mental bone
#

The answer is b

#

The extra memory cost is negligible compared to the branching cost

meager pelican
pale python
meager pelican
#

So set from C#?

pale python
pale python
meager pelican
#

Why pass them at all?
It's a uniform file-scope variable

#

So before your first function, declare the array, do the sets in C#, and "just use" the values.
You'll probably want another variable to indicate the # of elements.

#
uniform numFloats;```
(the keyword 'uniform' isn't really necessary.)
pale python
meager pelican
#

NO I think a uniform is the way to go. That's (C) 😉
So you don't have to pass anything at all to the function.

pale python
#

any chance you could give me an example, ?
i certainly know how to write in c# and lately "c" as well

#

im learning shader for the first time btw, im a complete noob

teal hornet
meager pelican
#

I just gave you an example.
Do this:

uniform numFloats;```
at file-scope inside the pass. 

so ```pass {
blah, blah, blah...

uniform float myDataArray[10];
uniform numFloats;

blah, blah, blah

v2f vert() {
v2f o;
...
return o;}

half4 frag(v2f in) {
...
  for (i=0; i<numFloats; i++) {
     <do something with myDataArray[i]>
  }
}```
#

So when you set that in C# on the material, that material has ONE array of 10 floats, that gets shared across all threads invoked on that shader/material, and all threads get read access to that one array of floats.

#

The uniform keyword means that the values is/are the same across all thread invocations in that draw call. It is the default for things at file-scope. So it's unnecessary but helps for clarity.

#

All this assumes that the values are READ-ONLY for the shader. In other words, the shader code isn't changing the array's values in the various running threads.

pale python
#

is that a deal breaker for this concept?

alpine lark
#

Anyone know why my refraction is creating this weird line across the screen? If i rotate the cam it moves with the camera but stays the same length. Turning off refraction is so far my only fix. Even if i put the strength to 0.1 its still there

agile token
#

Hello everyone,
I'm having trouble with a billboard shader that I'm trying to make in Shader Graph

#

Please take a look at the video.

#

As you can see, sometimes the render order for the billboards is correct and sometimes it's not.

#

Here's my Shader Graph

#

and here's the material

#

I think the problem has something todo with the how I'm facing the billboards at the camera, and that is somehow causing the wrong render order, but I'm pretty green with shader graph (and shaders in general) so if anyone can point me in the right direction, I'd sure appreciate it

broken vigil
#

how do I use sprites in shadergraph?

#

or is there not a way? I'm noticing with some annoyance that it doesn't let you use Sprites from a sprite-sheet as texture inputs in a shadergraph's standard image input

amber saffron
lunar valley
meager pelican
tacit parcel
agile token
regal stag
#

Something like this then yes there s 30

tender edge
#

can anyone tell me why my shader material suddenly looks like this?. the meshes look fine with different materials

#

nvm i found it. apparantly i changed the allow material override

proper ore
#

Is there a market or contact-place from Unity that I can use to commission shaders?

grizzled bolt
grizzled bolt
echo moatBOT
proper ore
#

The Unity Manual mentions that shaders have an appdata and v2f struct, and a vert method, but the shaders that are generated from the shadergraph have no such sections. If I wanted to add stuff to the aforementioned structs/method in the code generated by shadergraph, where would I have to do so?

low lichen
#

I don't know what names Shader Graph uses, but it's probably similar to what I just posted.

untold blade
#

How can I solve this problem?

#

I cant delete the keyword in my code, or even change it

regal stag
tight phoenix
#

Debug question: Is there a way to anchor a shader to the game main camera but not to the scene camera?
Use case would be to inspect a shader effect from another perspective without altering how the shader is rendering it (since its based on the camera)

#

afaik this camera node treats the scene viewport like the camera just as much as game treats main camera as the camera

#

I am thinking the brute force-est way would be to completely rebuild the shader to replace the view point with a position and direction, but something tells me there's more to the camera than that and probably wouldnt work even if I got it working right

grizzled bolt
tight phoenix
grizzled bolt
#

I agree not worth for just testing purposes

#

I assume trying to do it for shadow cascades or SSAO or other such complex features would get incredibly difficult

fair jackal
#

is there an easy way to do a full screen shader in URP yet or do you still need to use a custom renderer?

regal stag
fair jackal
silk wharf
#

Hello there, is there a way to use the stencil buffer in shadergraph? I need it to modify a sprite mask material and give it a color on the spot it is masking

#

An example, here is my sprite mask, and it is showing a sprite that is behind the black sprite; what I want to do is being able to read that hole information in a shadergraph and add my own color for example to that spot, instead of modifying the gray sprite color itself

#

Or maybe is there a way to use a sprite renderer instead to work as a sprite mask? like rendering one part and ignoring another?

#

I need to do the same affect as a mask but the result is always drawing the full sprite instead of drawing the half that is inside

regal stag
regal stag
silk wharf
silk wharf
#

the masked result does not give me a detailed interior as using a sprite (second image shows the sprite)

#

Now that you mentioned it, shouldn't render objects feature work on 2D? I mean, the sorting layer of sprites should override that making it almost unusable right?

regal stag
silk wharf
#

I currently have the ground with visible sprite mask

#

and the interior (gray part) as visible inside mask

regal stag
silk wharf
#

So sprites would be considered as transparent instead of opaque?

regal stag
silk wharf
#

thank you so much for your time

rapid terrace
#

hi i am pretty new to unity and i'm looking at tutorials on how to make shaders in vfx shadergraph, but i'm assuming shadergraph stuff is extremely resource intensive for mobile. So i was wondering, is the proper workflow for mobile supposed to be to create the shader, then bake that into a texture for the model? if so how do i do it, and is it possible to bake animations created using nodes in shader graph too

lunar valley
regal stag
#

You can bake the shader result to a texture (e.g. https://github.com/Cyanilux/BakeShader) but you'd still need another shader to render that. Could be cheaper, but that won't work if anything is animated.
Also always good to actually test/profile before trying to optimise.

rapid terrace
#

right, but i'm not supposed to have a bunch of different shaders in a scene right? so i should have everything rendered with one shader? the shader i am using currently mostly just changes colors.

#

well more importantly i want to know if its possible to grab the animation i generated using noise

regal stag
rapid terrace
#

i see, yea but these are mostly for spell effects so i can see there being a lot of them if i don't figure out a proper workflow early on

regal stag
rapid terrace
#

im not sure if its vertex displacement but i assume it is, the effect was made using time, noise, sine, and vertex? nodes

regal stag
#

If it's connected to the Position port then yes.
There still may be ways to make that displacement cheaper. Like if it's using Simple/Gradient Noise nodes those are procedural (created via math), but a seamless noise texture (sampled with Sample Texture 2D LOD node) could be cheaper on mobile.

rapid terrace
#

its connected to that

#

so theres no way to like, "record" the animation somehow and iono turn that into a static animation thats not attached to the shader? not sure if im wording my question properly >.<

regal stag
low lichen
#

Vertex animation exists, and is usually encoded into textures that can be sampled in a shader. But that's usually reserved for complicated simulations that couldn't reasonably be done in real-time, like liquid simulations.

rapid terrace
#

wait, so do you mean that the animations that are created using shaders on the fly takes less system resources than say a static animation that i imported in from blender? or am i overthinking it and something simple like pieces of the mesh moving around via noise nodes, doesn't take enough resources for me to need to consider this at all

regal stag
rapid terrace
#

ok so basically i cant turn the shader generated animation into a keyframe animation

toxic flume
#

Is it logical to implement mesh generation for my voxel game in compute shader instead of C# script?
Greedy mesh generation to combine same adjacent voxels
set vertices, triangles (faces), uvs for each voxel segment

// loop

for (var j = 0; j < 4; j++)
                {
                    _uvs.Add(faceDef.HasTexture ? uv : Vector2.zero);
                    _tileData.Add(tileData);
                    var pos = (Vector3)faceData.Vertices[j];
                    var vertex = pos.Multiply(voxelSize) + (Vector3)chunkRealPosition;
                    _vertices.Add(vertex);
                    var color = faceDef.HasColor ? faceDef.Color : Color.white;
                    color.a = voxel.AlphaValue;
                    _colors.Add(color);
                }

                for (var j = 0; j < 6; j++)
                {
                    _triangles.Add(currentVertexIndex + IndexOrderList[j]);
                }
rapid terrace
rapid terrace
#

anyone know what this node is?

pliant pond
#

I'm working on a (relatively) simple stencil setup that basically has a camera filtered with a stencil setup in front of it. The stencil "cuts" out the player character and renders it to a RenderTexture – so that only the character is in the final render texture image. The stencil successfully cuts out objects, but I realized now, if an object is either (1) in front of or (2) intersecting the player character, the data of the character is cutoff. Is there any easy solution to this problem? (sorry im a bit of a noob at stencilling)

regal stag
# rapid terrace

It's a SubGraph. At a guess, I'd say it's multiplying the Scroll property by the Time output from the Time node.

regal stag
pliant pond
#

have access to stencils but not camera layers

untold blade
pale python
#

hey,
how to right an array of floats in shader ?
somefloats[4]("description ...", Float) = 0 ?

prime shale
pale python
prime shale
#

Should be a float array api?

#

For the material class

#

Not on my PC atm

#

But if there isnt one the closest you'll get would be vectors or matricies

pale python
#

@prime shale thanks , but I couldnt get it to work

pale python
#

im trying to have a float array in shader to be able to use it later using setglobalvariable , and I read online that i need to mention the array in shader
_floatArray("Array", float) = (1.0, 2.0, 3.0, 1.0, 1.0, 2.0, 3.0, 1.0, 1.0, 2.0)

prime shale
#

wronggg

#

again

pale python
#

the problem is if the array is bigger than 4 it fails

prime shale
#

can't do arrays in the material property block

pale python
#

ahh

prime shale
#

if you want to pass an array of floats it will have to be through c#

#

by material property block I mean the inspector values that you get exposed to you, when you mess with the material that has your shader

pale python
#

and how would I mention it in the frag function for example ?

prime shale
#

float _X[250];

#

or float _x[]

#

then in C# it'd be material.SetFloatArray("_x", xFloatArray);

pale python
#

ohh !! and if i wrote on c# Material.SetFloatArray("_X", array); <--- that would be the value of _X in shader?

prime shale
#

you'd be setting the values of the float array _X in the shader yes

pale python
#

Thank you ❤️

prime shale
#

jk, your welcome

deft frost
#
SubShader
    {
        UsePass "ShaderPath/FORWARD"
        UsePass "ShaderPath/DEFERRED"
        
        Tags {"RenderType"="Opaque" }
 
        CGPROGRAM
        #pragma target 3.0
        #pragma surface surf Standard fullforwardshadows addshadow
        #include "UnityCG.cginc"

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

        sampler2D _MainTex;
   
        UNITY_INSTANCING_BUFFER_START(Props)
        UNITY_INSTANCING_BUFFER_END(Props)

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
             fixed4 p = tex2D (_Pupil, IN.uv_Pupil);             
            clip((c.a)-0.2);  //Clip the previous passes?

        }
        ENDCG        
    }
    FallBack "Diffuse"

How do I make it so that I can discard pixels from a previous pass? Like, if the previous shader is opaque, but this shader, using the previous shader's pass, is trying to discard pixels from the previous passes? How do I do that?

Trying to do a dissolve effect.

soft harness
#

how could i do this kinda thing?

deft frost
#

I kinda want to try a shader where it renders triangles like this depending on their proximity to a vertex

#

This is how I want it to look

#

Is there any way to render a cube like this?

sterile kestrel
#

if i have 10 enemies with same material one of die and active a dissolve effect for one who die, so the alive enemy will also change with dissolve effect how to fix

#

anyone ?? how to manage material saperatly

sharp tendon
#

Hello! In UE I used this curved world shader for an art piece, and I'm looking to convert it to Unity. For some reason I can't seem to get it to work though, and I'm not exactly sure why? I made sure to adjust the values to what they'd be with Unity's measurement system. Would anyone be able to tell me what I've done wrong?

cosmic sphinx
#

I'm creating an outline for selected GameObjects. So far all tutorials use one of the following methods:

  • a material attached to the renderer that bases the outline on vertices positions (like the one in the screenshot)
  • a post-process that creates an outline with a constant width around all the renderers from the particular layer
    Have you encountered any other notable approaches for this topic?
stray moat
#

@fervent kiln Change this to the correct on in the prefab

regal stag
deft frost
#

I found a way by using GrabPass

regal stag
#

Hmm okay, I assume grabbing the screen before any of the passes are rendered and the last pass layers that ontop. Not ideal for overdraw, but works I guess.

regal stag
regal stag
lunar valley
regal stag
#

Or for Built-in RP, set a MaterialPropertyBlock on the renderer.

#

Instancing grass blades is also an option, but wouldn't say that's what is in the image specifically. And vertex displacement would require the plane mesh to have a lot of vertices, or also have tessellation hull/domain shaders.

regal stag
regal stag
cosmic sphinx
lunar valley
sharp tendon
# regal stag The Position port values need to be in Object space, so you should use a Transfo...

Ty! I tried that, and it didn't seem to give better results. I also initially tried following a tutorial before attempting to convert the UE version, but I couldn't manage to figure out how to get the functionality I was after. I'd like to offset the falloff of the curve. I tried adjusting the power, but whenever I tried with the version in this screenshot it didn't work. I've attached a graph of the type of falloff offset I mean!
I tried doing quite a bit of other things (Like clamping before the power), but it keeps seeming to break, and I'm also not super sure how to debug in shadergraph just yet.

sudden vale
#

Does someone tried to make a blur (kawase, gaussian) effect for Fullscreen mode (compatibile with Render Features) in Shader Graph?

#

I don't know how to get a Texel Size and Tiling (to recreate the effect found on the internet) properties in Fullscreen mode from URP Sample Buffer.
Screenshot is from the shader graph I try to recreate, they use MainTex.

regal stag
sudden vale
#

Should I use it when I got URP Sample Buffer node? Hah

regal stag
sudden vale
regal stag
#

Technically it is meant to be defined as a TEXTURE2D_X to work with XR. Defining it as a regular Texture2D would likely break that, so using the URP Sample Buffer or defining the texture in a custom function would be better.

#

Yeah that might work

sudden vale
#

However, I don't know how replicate this

#

With URP Sample Buffer

regal stag
sudden vale
regal stag
#

Ty I tried that and it didn t seem to

sudden vale
#

It's not as good as in the showcase I found

#

As he descirbes it's a box blur algorithm btw

regal stag
sudden vale
sudden vale
#

I found this in sticky notes now 😄

#

Hmm, I need to think how I can do this like him. Should I use some RTHandle with scale parameter to Blit into? (In Renderer Feature)

#

Btw I also found that SSAO built-in Render Feature is using a blurring effect (Bilateral, Gaussian, Kawase), so probably I will also copy-paste this into my Renderer Feature

stray stag
#

Hello, my shader graph auto generates stars in the background using high scale simple noise and a very low step node. For me it works well but when I sent my friends the same build I played on, the stars were all weird and repeating, anyone know how to fix this?

#

Seed is a random Float from -100 to 100

#

Normal stars

#

Their stars

#

I'd understand if Simple Noise was just broken but why does it work for me on the same build?

teal hornet
#

Is it possible to have 2 shaders on one sprite and then use a mask to reveal the other shader?

#

Maybe something like using 2 subshaders in one shader?

lunar valley
teal hornet
lunar valley
teal hornet
lunar valley
#

ok

teal hornet
#

This is not particularly helpful...

lunar valley
#

and I am also not quite sure what you want to do and what making own shadows by masking correct colors should mean

barren stratus
#

Have a question

#

So I want to learn how to dissolve an object by passing another over it

#

Don't know how to even start. Does the object getting scaled hold the shader material? Does each object getting dissolved hold the shader material? How they affect each other? Help

#

For the time being I'll just look into Boolean

forest wave
#

Ah, it took a while, but I finally tried it and I realized I was apparently just using the built in pipeline and the shader was incompatible with it 🤦‍♂️Well thanks anyway, maybe ill have a use for it in future projects :) ill have to find some other way now if there is one

lunar valley
barren stratus
#

I'll look up stencil shader

#

Or u can give a run down on what it does

#

Oh saw a video. Thanks

barren stratus
#

Ok I get how stencil works but what about the glow at the edge

#

Also it from what I can see it stops rendering places the cube is touching or renders only places the cube is touching. What is I want to use something like a plane and render it hasn't passed yet not rendering places it has passed till it passes it again

#

One sec

#

Something like this. So I can just slide the glowy plane pass all the robot for them not to render then aas I slide them back they start showing. Can stencil also do that?

#

God that was hard to read but hope u understand my question

regal stag
# barren stratus Don't know how to even start. Does the object getting scaled hold the shader mat...

The shader/material on the spheres is likely taking the box's world->object/local transformation matrix in (passed manually through Shader.SetGlobalMatrix or material.SetMatrix)
The world space positions in the shader are transformed into the boxes coordinate system using that, they're then relative to that box. The glow and clipping would be based on whether those coordinates are smaller than -1 or greater than 1. Glow would be something similar... probably absolute(posRelativeToBox)-1 and min (maybe max) to combine the axis. Bit off the top of my head so calculations could be wrong.
Could also look into a box signed distance field which would be similar. https://www.youtube.com/watch?v=62-pRVZuS5c

If you just want a plane, should be able to subtract a position that lies on the plane then dot product with it's normal iirc. If the plane is aligned to a specific axis (i.e. X axis), can just do step(planePosX, worldPos.x)

rich roost
#

Hello, does anyone know why I have all OToon materials transparent?

barren stratus
#

I'll first watch the video then try again

barren stratus
#

I understand the plane own better though that seams easier plus it's what I wanted to go for anyways. It'll be similar to how I do normal dissolve from what I can tell

dusty creek
#

I am trying to come up with a shader graph that takes in a texture and is able to seperate all the colors so I can recolor the texture using this graph, I can't really think of a way to do it that is not limited to the RGB channels though. does anyone have any information on this?

regal stag
dusty creek
#

it's for character models

#

RGB channels would be plenty for hair colors but when I want to customize the color of an outfit I would only be able to use 3 colors

regal stag
# dusty creek it's for character models

If there's a single colour per face could make a palette texture, and UV map each section of the model to it. Then generate the palette at runtime in a C# script from a bunch of colour fields.

dusty creek
#

if Unity would load I could make a quick shader of what I want to expand on

#

I want to be able to do this but with more colors

#

if it's not possible I will simply have to make sure all textures only contain 3 colors sadly

regal stag
#

Does the input texture always have full brightness colours? Like, this works with darker versions of the red/green/blue, is that important?

dusty creek
#

yea that is important

#

though that gives me an idea, is it possible to take a texture and a color as input, and then have it output a grayscale result of everything in that color?

#

I guess that would conflict with other colors though

regal stag
# dusty creek yea that is important

One method I've used in the past is something like this. Specific red values are used as UV coordinates to sample a horizontal palette. That doesn't really allow for darkening the colours, but since the green channel is unused you could maybe store a brightness in that.. UnityChanThink

dusty creek
#

that sounds like what I want. but how would I do that? xD I'm not sure I even understand this version

#

what is the palette_space texture?

#

also does this still allow me to use alpha for transparency?

regal stag
#

It's a 5x1 texture with pixels containing the colours

dusty creek
#

ah ok

#

how does it know what color to place where

regal stag
#

Yeah the regular texture can still have an alpha channel

regal stag
#

It is somewhat of a complicated setup, hence why I've only really used it for pixel art stuff

dusty creek
#

so if I were to have a clothing texture with 7 colors that all have different shading,
I have to:

  1. store the different colors as different shades of red
  2. store the grayscale in greenscale
  3. create a texture of 7x1 and input colors into it
#

but then I'm back at the issue of how I set the colors in that texture from shadergraph

regal stag
dusty creek
#

how

#

is this just a script?

regal stag
#

Yes you'd use a C# script

dusty creek
#

I'm not sure how you'd make such a script

regal stag
# dusty creek I'm not sure how you'd make such a script

I think it could be something like

public Color[] colors;

void Start(){
  Texture2D paletteTex = new Texture2D(7, 1, TextureFormat.RGBA32, 0);
  paletteTex.SetPixels(colors);
  paletteTex.Apply();
}

Then pass the texture to shader. Either using Shader.SetGlobalTexture or material.SetTexture

dusty creek
#

does this need to be on a Game Object?

regal stag
#

Yes

dusty creek
#

I'll see what I can figure out, thanks alot :D

fleet olive
#

im getting this weird issue with my shader

#

i dont see anything wrong with it

#

it worked before, i didnt change anything

brittle schooner
#

Yo!
I got a problem with character dither dissolve. It supposed to dissolve but it's not. Why?
This used to work. Now it doesn't

regal stag
brittle schooner
#

bruh

#

seriously

#

that was the problem

#

thanks

grand jolt
#

any way to make a water shader like this on URP?

grand jolt
# lunar valley yes

how because I tried a few times and got stuck at trying to get refraction and reflection to coexist

#

or getting reflections at all

regal stag
lunar valley
# grand jolt or getting reflections at all

well there are multiple ways, you can get reflections going, there is planar reflection looks very crisp and good but costly, then there is reflection probes, then there is screen space reflections SSR, and then there is raytracing ^^

#

there is not a single method that is 100% perfect you will just need to choose what you need

grand jolt
#

planar reflections required having to manually setup a camera and it worked but only for one water body, as another made it be underground, reflections probes look shitty, and ssr stops reflecting things after a certain point

#

so

lunar valley
grand jolt
#

in urp

lunar valley
# grand jolt how do I do ray tracing then?

Well... I wouldn't know how I would implement a raytracing system into unity while also having rasterization going.. For making raytracing in general you will find a lot online. You essentially want to trace some rays with low resolution and then denoise the shit out of it.

grand jolt
#

hmm

#

I mean ssr does use raymarching

#

but

spring fox
#

raytracing generally isnt the way to go

#

its way too difficult to optimize

prime shale
#

^^^

#

the best current solution that rasterized has at the moment

#

is using parallax corrected cubemaps (or reflection probes)

#

and then ontop of that is SSR

#

that is the best you'll get unless if you switch to dedicated raytracing

#

planar reflections would be more what you'd expect, but as you seem to recognize that obviously has the downside of needing to render the game world again, and also that if you have multiple in a scene it would just look wrong

lunar valley
#

I mean unreal managed to merge it, so theoretically you could do it too ^^

#

if you should do that is debatable

deft frost
#

Can someone help me out with this one? If you need me to send shader code, I can DM you.

barren stratus
#

did what I wanted thanks a lot cyan. turned out to be easy after trying what u said

raw ruin
#

I have an issue as well that might be simple. Some of my materials say that

"Material x doesn't have meta pass - maps are taken by name"

barren stratus
#

U will probably have to wait for cyan to come online I haven't seen that. though curious about it and the fix

raw ruin
#

Same, I'm not sure why it'd occur. My project has had many breakdowns due to working on a world for VRChat specifically, and I guess things still don't work too well together at all times.

#

I've had to delete the Library several times by now for randomly broken scripts and shaders to compile.

barren stratus
#

that sounds like a big problem your tested scripts randomly break?

raw ruin
#

But this has been recurring even after Library delete.

barren stratus
#

like after u confirm they work?

raw ruin
#

Yup, same with shaders

#

Randomly, I get an error that some texture or another isn't correct, so a shader fails to compile. I delete the library, error is gone, shader works.

barren stratus
#

the texture library?

#

U know what? we've typed a lot, repeat the question so he sees it

raw ruin
#

I'm not sure I have a screenshot, but the console would pop up with a random shader saying that something assigned to a shader is incorrect. It was some UV texture written in code for the shader before, that was gotten from Unity itself.

#

Either way, that's not the current issue anyway, those can be fixed by the Library folder being deleted

#

Project rebuilds, it's all fine

raw ruin
#

Everything seems to be fine, but it'd be a pain to realize that something was actually broken all this time

#

Using Unity 2019 is definitely a hassle, despite being LTS, specifically most likely because of VRChat's weird integration

deft frost
regal stag
regal stag
regal stag
deft frost
raw ruin
deft frost
meager pelican
grizzled meadow
#

any way i could get this type of effect in urp shader graph? theres 8 lights around an object with 0 metallic and 0 roughness on 814W

lunar valley
lunar valley
#

you will probably only be able to do this if its per object based

cosmic sphinx
#

You could store the thickness info somewhere inside vertex data, e.g. by modifying vertex color or normals, but it creates new restrictions.

Perhaps other people here will have better ideas.

onyx talon
#

I write a custom outline shader pass in hdrp, it looks perfect if I disable the fog. However, after I enable the fog, the outline will disappear. Looks like the fog on top of the outline.

#

Is there anyone know how to fix it?

meager pelican
#

The outline looks to be outside of the object itself (external outline, rather than internal outline).

#

Maybe you could try writing the outline to the depth buffer.

#

Just rambling.

onyx talon
meager pelican
#

If it's a pass of the mesh, perhaps extruded, just make sure zwrite is on.

onyx talon
meager pelican
#

Then IDK, it should already be updating the depth buffer. IDK why fog doesn't take that depth of the outline into account.

#

Maybe it's a fog problem, not a mesh/outline problem per se.

#

Others may know.

lunar valley
#

implement your own fog :3

meager pelican
#

For debugging purposes, you could try to output depth as a color and make sure the depth of the outline is the same color as the edges of the mesh, just to prove to yourself it is writing the proper depth value. You'd do that on both the normal mesh and the outline mesh.

#

Also I think you can view the depth buffer in unity's editor (Window/Analysis/Rendering Debugger--->map overlay = depth

meager pelican
#

If so, it should write to depth.

#

But note that things that are closer to the camera than the outline will occlude it.

#

Also note that fog implementations vary. So objects (let's say mid-way into the scene) can have some depth-based fog occluding them. Your outline could have the same thing, depending on if it is implemented as a post process or done when writing the pixels the first time.

#

All these things have to work together.

humble robin
#
 public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer commandBuffer = CommandBufferPool.Get();
            
            commandBuffer.GetTemporaryRT(tempHandler.id, renderingData.cameraData.cameraTargetDescriptor);

            commandBuffer.Blit(source, tempHandler.Identifier(), material);
            commandBuffer.Blit(tempHandler.Identifier(), source);
            commandBuffer.Blit(source, tempHandler.Identifier(), material2);
            commandBuffer.Blit(tempHandler.Identifier(), source);


            context.ExecuteCommandBuffer(commandBuffer);

            CommandBufferPool.Release(commandBuffer);
        }```

I am trying to pass the modified depth texture (that i modified with ```commandBuffer.Blit(source, tempHandler.Identifier(), material);```) to material2, how can i do this?
#

using the _CameraDepthTexture returns the unmodified version

#

i output SV_DEPTH on the first one

#

i have no idea if i am completely offtrack or not, i just need to get the depth i modified using material1 and give it as an input to material2

buoyant geyser
#

Trying to write a surface shader to apply a color ramp to lit 3D models

#

Im applying the color ramp in the FinalColor part of the shader

#

for some reason, when multiple lights are applied to my model, the finalcolor changes unexpectedly

#

to debug this, im currently setting the color to a fixed value of 0.5, 0.5, 0.5, 1

#

but the color brightens to pure white when a second light interacts with the model

#

what causes this?

#

I see people suggesting to enclose the finalcolor function in #ifndef UNITY_PASS_FORWARDADD, and this kind of solves the issue, but then the additional additive passes just don't have the desired effect, they use normal surface shading

#

what i need is for the very last final color to use this function, after all of the lights have been added

buoyant geyser
#

im pretty sure the issue is that the finalcolors are being combined together with additive blending, can i change the blend mode of the light passes?

dry hull
#

How would one go about making a screen ripple distortion effect?

#

in unity 3D URP

low lichen
# buoyant geyser im pretty sure the issue is that the finalcolors are being combined together wit...

The finalcolor modifier is not additively blended, but the Forward Add pass is. The problem here is that the built-in render pipeline in Unity uses additive passes for additional lights in forward rendering. There's no way to change that. Even if you could change the blending mode of the pass, it wouldn't help because the base light pass and additional light passes would still be separate and there would be no way to do a final composite of them like you're trying to do.

#

You have a few options to get around this.

  1. Only pixel lights use the Forward Add pass. Vertex lights are performed in the base pass. If you force all lights to be vertex lights (by setting them all to "non-important" or by setting the max pixel light count to 1 in Quality settings), then all the additional lighting calculations will be performed in the base pass and you can calculate your color ramp correctly. The downsides here are you're limited to 4 lights per object and they will be lower quality than pixel lights, but the second problem can be avoided with custom lighting that processes vertex lights as if they are pixel lights.
  2. Completely avoid Unity's lighting system and make your own, by calculating what lights need to be passed to what objects and processing them in your own shader.
  3. Don't use the Built-in render pipeline and use something like URP, which doesn't have an ancient forward rendering path and instead does everything in a single pass.
buoyant geyser
#

I’ve been avoiding changing pipelines because from what I can tell, shaders aren’t compatible between them and you need to use shader graphs or whatever for the other pipelines

low lichen
buoyant geyser
#

Well what about multiple passes

#

Could I calculate the base lighting in one pass and then apply the color clamping to the resulting color

low lichen
#

You won't be able to read the pixels from previous passes, so no.

buoyant geyser
#

Man that’s annoying

#

I might try the vertex lighting idea in my case, I’m implementing this for a pixel art styled game so there aren’t often going to be a lot of lights at once

#

One other thing I was experimenting as a hacky workaround was just subtracting the previous light pass’ color from the current one but that didn’t work as expected either

#

That should work since the light passes are additive though, right?

low lichen
#

You were returning a negative value in the Forward Add pass?

buoyant geyser
#

No, at the end of each pass I would store the previous pass color, and subtract that from the current pass

#

I’ll post the code shortly

low lichen
#

That doesn't sound right, because you can't pass information between passes.

#

Unless you're writing it to a separate texture or buffer object

buoyant geyser
#

Outside of the function I had a fixed3 _prevCol, which was assigned to the finalcolor at the end of each lighting pass

#

And then on additive passes I was subtracting that from the finalcolor

#

Would _prevCol not persist between those lighting passes?

buoyant geyser
#

Well shit, is there no way to do something like that? Store a variable between functions?

low lichen
#

Well you're not just talking about a variable. Every pixel needs to store it's own color. So what you're talking about there is a texture.

#

I should clarify that there is no special relationship between multi-pass shaders and any other shader. Sure, they are each drawn in sequence, and they are each part of the same shader and same renderer, but to the GPU, they are completely different draw calls.

buoyant geyser
#

Does that refer to lighting passes too? I’m talking about the additive lighting thing

low lichen
#

The GPU doesn't have the same concept of a "multi-pass" shader as Unity does. It's just separate shaders that are drawn right after one another.

#

Yes, it applies to lighting passes too.

buoyant geyser
#

Is there anything you’d personally recommend here? The effect I’m trying to achieve is pretty simple I’m just running into a bunch of annoying technical issues, all I’m trying to do is take the resulting brightness of the lighting and set the color of the pixel to a corresponding value in a color ramp

#

Since I’m doing the color ramp on the finalcolor function here it’s being basically doubled for every light

low lichen
#

The simplest way is probably to do it as a post processing step. Draw everything with normal lighting, and then with a post processing shader, apply the color ramp to each pixel.

#

The downsides to that are that it isn't as mobile friendly and you can't do per-object color ramps as easily.

buoyant geyser
#

Per object would be necessary in my case

#

It wouldn’t be possible for a second pass to read the color of the lit pixel, would it?

low lichen
#

It's possible to pass a RWTexture2D to a material/shader, which you can then read and write to from a shader.

#

I don't think I've ever seen an implementation that does that, so I'm not certain of the performance you could expect from that, but I'm fairly confident that it works. But it's a relatively recent feature in GPUs, so low-end hardware may not support it, mostly old mobile phones.

#

You would need to create a RenderTexture in script with the same dimensions as the screen and then bind it globally with Shader.SetGlobalTexture.

#

Then in the shader, you can define it as a global variable RWTexture2D<float3> _MyTexture; (float3 for RGB), and read and write to it like a two dimensional array:

int2 pixelCoords = // you will have to calculate the pixel screen position;
_MyTexture[pixelCoords] = color.rgb;
// Read from it the same way:
int2 pixelCoords = ...;
float3 prevColor = _MyTexture[pixelCoords];
#

You will also need to define #pragma target 4.5 to set the minimum shader target version to be able to use this feature.

buoyant geyser
#

back at my pc now, i'll post the shader rq

low lichen
#

I won't need to see it unless you're expecting me to write the implementation for you. The specifics of the shader doesn't change how this would be implemented into it.

buoyant geyser
#

im not expecting that, just figured i'd share so the issue is a little more clear

#

single light

#

2 lights

#

since the base color of the ramp isn't black, even parts without any actual light touching them basically double in brightness between each pass

low lichen
#

I wish there was an easier solution I could give you, but this is ultimately the limitation of the forward add pass. The solutions I've given you so far are all to avoid the additive pass, because no matter what you do (unless you force vertex lighting), additional lights will always be added with additive blending.

#

Even if you use the RWTexture2D solution to pass data from the base pass to the additive pass, it will still be pretty hacky because you will need to return a value from the additive pass which when added to the base pass with additive blending, will result in the color you want.

buoyant geyser
#

is there something im missing here?

#

the red and green material both use the same exact shader

low lichen
#

The directional light should always be important. Just the additional lights should be vertex lights.

buoyant geyser
#

they have the same issue though, they don't light up the green material, only the red one

#

is there some technical detail im missing about vertex lights or something that could cause that?

low lichen
#

Are those submeshes that are part of the same renderer?

buoyant geyser
#

yes

low lichen
# buoyant geyser yes

I could imagine that being the cause, but I don't know why it wouldn't work. I don't know how Unity handles vertex lighting with submeshes.

buoyant geyser
#

i think what i'll do is just make additive light passes reduce the color count of the light instead of applying the color ramp to every pass

#

at least this way i can draw colored lights a little better

#

as long as i reduce the color count enough it will avoid the issue of making sprites look super muddy

grand jolt
#

Im having trouble changing my shader can anyone help me out?

lunar valley
#

yes thats what this channel is for

#

for shaders

grand jolt
#

can anyone help me change my shaders on the model

tame topaz
buoyant geyser
#

ok now i just feel like a complete idiot, can someone help me wrap my head around this

#

trying to make a scrolling reflection texture for a 2D surface

#

I need to sample a reflection texture based on screen space, but offset that screen space coordinate based on a scrolling speed multiplier

#

i can't figure out how to increase the speed of the scrolling without scaling the texture im sampling

#
void surf (Input IN, inout SurfaceOutput o)
{
    fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    o.Normal = tex2D (_NormMap, IN.uv_MainTex);

    o.Albedo = c.rgb;
    o.Alpha = c.a;

    fixed4 refl = tex2D(_ReflTex, (IN.screenPos.xy / IN.screenPos.w) * _ReflScroll) * tex2D(_ReflMap, IN.uv_MainTex).a;
    o.Albedo += refl;
}
#

This is what im doing now, i just take the screenPos and multiply it by a scrolling speed

#

but doing this also scales up the texture im sampling

#

mathematically, what can i do to multiply the offset without scaling the reflection texture?

forest wave
#

Yo, is it possible to render both low quality and high quality things in the same game view? Basically, I have like an overlay that covers the screen. It displays by having a certain script on the main camera which controls a shader that creates this overlay. I want that overlay to be high quality. But then I also have the game itself, and I want that to be really low quality. Is there any way to achieve this?

Currently I have 2 cameras with one having a low quality render texture, but they only work individually, not together.

Basically imagine you are looking at your monitor and are playing a low res game. Your monitor is high quality because ofc it is, its in real life, but the game is low quality because its on your screen.

In my case, the shader is kinda like the look of the monitor, with the edges and overlay and stuff

I'm using the in-built pipeline too so yeah 😐

Idk if that makes sense

Thanks.

meager pelican
buoyant geyser
#

yes, to achieve a 'pixel art' downscaling effect on my 3D models, im using a color ramp to limit parts of the model to color ramps based on their brightness

#

i ended up working something out though

meager pelican
# forest wave Yo, is it possible to render both low quality and high quality things in the sam...

Well, you can render to a low res texture like I think you're doing.
I have NO IDEA what you mean by "Currently I have 2 cameras with one having a low quality render texture, but they only work individually, not together." I mean, cameras stack, so the 2nd camera should render over the first one. If it is high-res for the UI, what isn't working?

Another way would be to render everything normally and do a post processing pass to reduce the screen to a pixelated look. Then apply the UI.

#

Pixel art based stuff can be tricky.

#

You might need to do a blit between the two cameras to a higher res render texture used for the 2nd camera.

round mist
#

Wondering if anyone can point me in the right direction here, I don't have much shader knowledge at all, however I'd like to create a shader which takes the lighting of an object and simplifies it into either black or white. If the lighting is below a certain brightness it becomes black and then the opposite is true for white. I'm trying to use shadergraph with URP and am pretty stuck on what the best way to accomplish this would be, any guidance would be appreciated!

hybrid cosmos
#

Hi all, I was just watching this video, https://www.youtube.com/watch?v=KXykryML824, it looks like it has some sort of pixelated sahder/post processing on top of some basic shapes to create a cool pixel art effect. Does anyone know how to achieve this look? Thanks in advance

For the Brackeys Game Jam, I recreated Ape Out's design, colourful style and smash 'em up combat. In Synthetic you can use a grappling hook-style tentacle to grab enemies and slingshot yourself across the level. Made with Unity :)

// PLAY: https://dawnosaur.itch.io/synthetic
// JOIN THE DISCORD: https://discord.gg/W5vE5WKXYH

COSMOS: https://st...

▶ Play video
#

from some of the comments he mentioned "Pixel Camera", are we looking at the 2D pixel perfect camera and somehow achieve this?

cosmic sphinx
# hybrid cosmos Hi all, I was just watching this video, https://www.youtube.com/watch?v=KXykryML...

Such effect can be achieved with postprocessing. The solution will differ depending on the rendering pipeline you're using. Here is an example video:
https://www.youtube.com/watch?v=5Jl-40B5mtk
Alternatively you can just reduce the game resolution to some small value via Screen.SetResolution. It's much less flexible, but much simpler and more performant.

lunar valley
#

you need to use the Unpack function to properly be able to use a normal map

#

but thats generally the case, its gonna unpack your normals correctly

#

can you show me what you are doing

#
  1. it would be way easier to debug, if you would output the normal map 2) the normals are still in tangent space
#

in the fragment part, return it as color so that we can see how it looks like anyway you still will need to transform it to world space your normals

#

ye, I doubt that your normal map looks like that, does your mesh have uvs?

#

you want to transform your normal from tangent to world

#

not object

#

watch freyas shader video I think in part 2 or 3 she explains how to use normal maps. But if you want a quick explenation using a 3x3 rotation matrix containing the tangent normal and bitangents

sharp hinge
#

Hi, I have this simple shader in URP:

Shader "Custom/MyLit"
{
    Properties
    {
        [Header(Surface options)]
        [MainTexture] _ColorMap("Color", 2D) = "white" {}
        [MainColor] _ColorTint("Tint", Color) = (1, 1, 1, 1)
    }

    SubShader
    {
        Tags { "RenderPipeline" = "UniversalPipeline" }

        Pass
        {
            Name "ForwardLit" // For debugging
            Tags { "LightMode" = "UniversalForward" }

            HLSLPROGRAM

            #pragma vertex Vertex
            #pragma fragment Fragment

            
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"


            float4 _ColorTint;

            TEXTURE2D(_ColorMap);
            SAMPLER(sampler_ColorMap);
            float4 _ColorMap_ST;


            struct Attributes
            {
                float3 positionOS : POSITION;
                float3 normalOS : NORMAL;
                float2 uv : TEXCOORD0;
            };

            struct Interpolators
            {
                float4 positionCS : SV_POSITION;
                float2 uv : TEXCOORD0;
            };


            Interpolators Vertex(Attributes input)
            {
                Interpolators output;
    
                VertexPositionInputs posnInputs = GetVertexPositionInputs(input.positionOS);
    
                output.positionCS = posnInputs.positionCS;
                output.uv = TRANSFORM_TEX(input.uv, _ColorMap);

                return output;
            }

            float4 Fragment(Interpolators input) : SV_TARGET
            {
                float2 uv = input.uv;
                float4 colorSample = SAMPLE_TEXTURE2D(_ColorMap, sampler_ColorMap, uv);

                return colorSample * _ColorTint;
            }

            ENDHLSL
        }
    }
}

And my problem is that I cant see mesh that have this shader assigned, its completely invisible

regal stag
# sharp hinge Hi, I have this simple shader in URP: ``` Shader "Custom/MyLit" { Propertie...

Newer versions of URP have "Depth Priming" on the Universal Renderer. The shader needs to have a DepthOnly pass (and DepthNormals if using SSAO as well) to be able to prime the depth buffer correctly. e.g. https://github.com/Cyanilux/URP_ShaderCodeTemplates/blob/main/URP_Unlit%2BTemplate.shader
Could instead disable the depth priming, which will make the object visible, but it still may not appear in the Depth Texture / Scene Depth node.

sharp hinge
#

I pasted following pass:

Pass {
    Name "DepthOnly"
    Tags { "LightMode"="DepthOnly" }

    ColorMask 0
    ZWrite On
    ZTest LEqual

    HLSLPROGRAM
    #pragma vertex DepthOnlyVertex
    #pragma fragment DepthOnlyFragment

    // Material Keywords
    #pragma shader_feature _ALPHATEST_ON
    #pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A

    // GPU Instancing
    #pragma multi_compile_instancing
    // #pragma multi_compile _ DOTS_INSTANCING_ON

    #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
    #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
    #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
    ENDHLSL
}

But now I have a weird error:

Shader error in 'Custom/MyLit': unrecognized identifier 'real' at URP/Library/PackageCache/com.unity.render-pipelines.core@12.1.7/ShaderLibrary/CommonMaterial.hlsl(29) (on d3d11)

regal stag
# sharp hinge I pasted following pass: ``` Pass { Name "DepthOnly" Tags { "LightMode"...

Also see the HLSLINCLUDE section in my example - that gets included in all passes. It has the Core.hlsl include which should fix that error.
You may also want to set up the UnityPerMaterial cbuffer. You would want to put any shader properties excluding textures (i.e. _ColorTint, _ColorMap_ST) inside that so that the shader supports the SRP Batcher.
(It needs to be the same in all passes, hence putting it in HLSLINCLUDE is more convenient than copy-pasting it)

fast lark
#

and it only happens in the build

sharp hinge
regal stag
regal stag
fast lark
#

the URP lit shader

regal stag
fast lark
#

in the scene i only have a directional light in realtime

#

this is the material

sharp hinge
#

@regal stag Thats my current code

And thats the error:
Shader error in 'Custom/MyLit': undeclared identifier '_BaseMap_ST' at URP/Library/PackageCache/com.unity.render-pipelines.universal@12.1.7/Shaders/DepthOnlyPass.hlsl(27) (on d3d11)

regal stag
# fast lark this is the material

Any renderer features that could be affecting it? Not too sure what else to suggest.
I'd maybe test it in a new project. If it happens there still you may want to report it as a bug and try other versions. 🤷

regal stag
# sharp hinge <@357936113983291393> Thats my current code And thats the error: Shader error i...

Oh right, DepthOnlyPass.hlsl is expecting that texture to exist, along with _BaseColor and _Cutoff. So you either need to have those properties, or make your own DepthOnlyPass.hlsl (can copy and edit it - https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl). Then change your shader to include your version rather than the urp package one.

#

I imagine it's easier to just rename your properties to the expected names though, like in the example

_BaseMap ("Example Texture", 2D) = "white" {}
_BaseColor ("Example Colour", Color) = (0, 0.66, 0.73, 1)
[Toggle(_ALPHATEST_ON)] _AlphaTestToggle ("Alpha Clipping", Float) = 0
_Cutoff ("Alpha Cutoff", Float) = 0.5
sharp hinge
#

Alright I renamed them:

                [Header(Surface options)]
        [MainTexture] _BaseMap ("Texture", 2D) = "white" {}
        [MainColor] _BaseColor ("Color", Color) = (0, 0.66, 0.73, 1)
        _Cutoff ("Alpha Cutoff", Float) = 0.5

and I dont have any errors right now, but still I cant see my mesh :<

#

Oh I added the DepthNormals as well, which you mentioned before, it is visible now. Too bad I have no idea what is already going on in my shader

#

@regal stag Thanx for help anyways :>

fast lark
civic shore
#

can someone pls tell which texture goes to which map on the material

shadow kraken
civic shore
#

ok

cedar hull
#

Is it possible to create an instance renderer that doesnt take a full matrix but instead a buffer of 2d positions? (Using a custom shader offcourse.)
If yes, does anyone have an example in code of this, I can only find how to do it with full 4x4 matrices and not using custom data

Thanks guys

sleek granite
#

you would need to issue a draw call using Graphics.DrawMeshInstancedIndirect and then bind your buffer with instance data to the instance material.

quiet silo
#

Im trying to use a consume buffer in a compute shader but it doesnt matter what I do the vaule consumed is always 0. What am I missing? The docs https://docs.unity3d.com/ScriptReference/ComputeBufferType.Append.html also say that I should use the append type

hlsl code:

    ConsumeStructuredBuffer<int> consumeValue;
    RWStructuredBuffer<int> appendValue;
     
    [numthreads(1,1,1)]
    void test (uint3 id : SV_DispatchThreadID)
    {
        appendValue[id.x] = (consumeValue.Consume());
    }

c# code

        ComputeBuffer append = new ComputeBuffer(10, sizeof(int), ComputeBufferType.Structured);
        ComputeBuffer consume = new ComputeBuffer(10, sizeof(int), ComputeBufferType.Append);
        append.SetCounterValue(0);
        consume.SetCounterValue(0);
     
        consume.SetData(new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
     
        vectorFieldShader.SetBuffer(0, "appendValue", append);
        vectorFieldShader.SetBuffer(0, "consumeValue", consume);
     
        vectorFieldShader.Dispatch(0, 10, 1, 1);
     
        int[] intArray = new int[10];
        append.GetData(intArray);
        int[] intArray2 = new int[10];
        consume.GetData(intArray2);
low lichen
quiet silo
#

yes you are right also just found that out after going insane

#

thanks anyway!

buoyant geyser
#

Trying to write a shader to scroll a ‘reflection’ image across a surface based on the position of the camera, right now I’m doing this by directly passing the camera’s position to the shader via a script, is there a more elegant way to accomplish that?

low lichen
buoyant geyser
#

Oh sweet

#

I’ve been looking for a page like that, didn’t know what to search to find it

tender edge
#

i made a vertex color blending shader in standard pipeline. can i easily convert it to use in urp or do i need to make one from scratch?

#

for referance, this is what it looks like now

amber saffron
amber saffron
#

Then good news : just add URP as shader target in the graph settings 😄

tender edge
#

this didnt seem to help though. or do you mean something different?

amber saffron
#

Wait ... you said that you made the shader for the standard (built in) pipeline. But it's not there as target. I don't get it.

tender edge
#

i changed it already

#

it originally said built in

#

its also giving me these errors

amber saffron
# tender edge

You are sampling a lot of textures ?
Try to share sampler states between the sample nodes to avoid exceeding the allowed number of samplers

tender edge
amber saffron
#

No, if they don't end up connected to the output stack, they are not compiled

tender edge
#

from what is connected, i have 4 textures. each with a normal and heightmap connected to a triplanar node

amber saffron
# tender edge

If I'm not wrong, you have 12 connected sample texture nodes to the output ?

tender edge
#

here an example of 1 texture, i have 4 of these

amber saffron
#

Unity will also add samplers automatically for lightmaps and stuff, that's probably why you hit the limit

#

Like I mentioned, try to add some sampler object and share them between the sample texture nodes

tender edge
amber saffron
#

Descriptor strucs for sampling. With pixel interpolation mode, and wrap mode

#

Connects to the Sampler(SS) inputs

tender edge
tender edge
amber saffron
#

I think you can connected them all to the same one

#

You normally always want wrap-repeat for triplanar, and pixel or linear interpolation depends on the art style but will probably be the same for all the textures

grizzled bolt
#

I wonder how feasible or possible it might be to implement more types of texture filtering
Like the 3-point texture filtering of N64

amber saffron
tender edge
#

not sure if its connected or a urp thing, but my wireframe keeps showing even if not selected. looked fine in game though

tender edge
tough glade
#

@brisk condor do you know any good free light cookies? I dont have unity assets set up for purchase yet

brisk condor
tough glade
#

yes so sorry

#

um

brisk condor
#

No worrieess

tough glade
#

this is awkward

#

carry on

neat idol
#

Has anyone here worked with water before on Unity...

lunar valley
lunar valley
minor remnant
#

is there any way I could use noise textures for Parallax Mapping in shader graph?

#

like using voronoi as a displacement map rather than a texture2d

civic lantern
minor remnant
#

How would I go about it? i'm trying to use the float output as a sort of heightmap

regal stag
minor remnant
#

thank you! unfortunately I know next to nothing about hlsl

#

I assume i'd make a custom node using this hlsl file as a base?

regal stag
#

You could create a custom function that includes that file and calls the ParallaxOffset1Step function.
But it might also be easier to just replicate it in nodes.

minor remnant
#

Is float2 uv like the equivalent of like float uv[2] (in C++/#?

#

like is it a vector with 2 entries

#

just trying to read this properly, not familliar with hlsl like at all

regal stag
#

@minor remnant Here's the Parallax Mapping replicated in nodes.