#archived-shaders

1 messages · Page 83 of 1

ruby sonnet
#

im using hlsl, beacuse URP only allows hlsl

#

maybe thats the problem

amber saffron
#

Ok, I found how to trigger the issue : is happens when the bool variable is declared outside of the fragment function in my case.
Before I was just declaring directly in the function

ruby sonnet
#

yea that fixed it, thanks!

amber saffron
#

I'm unsure about why it acts like this though.

storm gorge
#

Is there a simple way to clip pixels that are a certain color (red)?

rich wolf
#

Does anyone have suggestions on how to filter out a certain range of brightnesses? I'm trying to make this water have foam on it, but I feel like the shape of the voronoi texture is kind of detracting from it. I want to try filtering out all the bright whites or something (like set the alpha of the bright white to zero). I tried using the clamp node and the min/max node but it doesn't seem to work like i want it to

#

Or if I wanted to try filtering out all the more subtle greys and just leaving the bright whites, something like that

tacit parcel
rich wolf
#

ill give it a shot thx

mellow hare
#

In built in render pipeline spotlight goes through walls. In urp there's no problem. Any suggestions?

mellow hare
#

anyone knows whats upt with this? this is really stagnating my gamedev right now

grizzled bolt
mellow hare
#

i use legacy diffuse shaders and that doesnt help at all. i have shadows enabled.

civic sierra
#

how can I get a smooth fade between these 2 materials?

amber saffron
quasi zealot
#

is there a way to make "flat" shaders w. shadergraphs where the entire 3d model is rendered with no depth and is instead a flat color?

quasi zealot
#

The black part

regal stag
#

Yeah that would just be unlit - "depth" is still technically rendered or it probably wouldn't sort with other objects correctly

quasi zealot
#

Was also wondering how a different shader was applied based on a line on the screen

#

Screenspace shaders maybe?

regal stag
#

Could involve Stencils, or possibly just ZTest Greater if the red part is infront

quasi zealot
#

Red part is behind

#

the vertical line moves and changes some parts of the 3d model moving to have a white shader instead

civic sierra
amber saffron
quartz slate
#

I want to make an overlay on top of a texture with shader graph but I can't figure out how to do it because is I use add, it doesn't work because mjy overlay is black and same for multiply, can someone help me with this please?

quartz slate
#

I'll try it but how does it work?

quasi zealot
#

Where can I enable tweaking the variable values of the shader graph in the scene?

amber saffron
quasi zealot
#

Currently in my materials the option to change those base value numbers are grayed out

amber saffron
#

the "strength" and "size" ? I don't see them grayed ou in the screenshot ?

quasi zealot
amber saffron
#

Are you inspecting the material that is a sub-asset of the shadergraph ?
This is the "default material" bound to the graph, and is not editable.
You need to either create a new material using this shader, or a material variant of the default material

quasi zealot
#

Thank you!

quartz slate
amber saffron
quartz slate
#

and this is my overlay

amber saffron
#

The connections seems fine, and when you change the "Strength" value, the overlay doesn't show up ?

quartz slate
#

nop

#

I tried 0, 0.25, 0.5, 0.75, 1

#

none worked

#

is it because my overlay is black?

#

so it does like if it was not here?

amber saffron
#

No. If you set the B input to red, and T to 1, doesn't the lerp node display a red preview ?

quartz slate
amber saffron
#

Yep, so it works

civic sierra
amber saffron
# quartz slate

Could it be that the "Overlay" texture is set to the same brick as default in shadergraph ?

quartz slate
#

here's with a strengh of 1

amber saffron
quartz slate
#

so, what do I do now..

amber saffron
#

You need to take into account the alpha of your overlay in the lerp.
Multiply "strength" with the overlay alpha, and input it in T

quasi zealot
#

How do I use a dissolve shader to transition from one texture to the next? Is this possible?

quasi zealot
# quasi zealot Yes

What I'm trying to do is I have a semi-transparent sceneColor dependent green texture and an opaque texture, and I'd like to use a dissolving shader to transition in between them

#

Currently I've tried using multiple materials on the same renderer but that did not turn out well

karmic hatch
ornate crypt
#

Hey, i have a simple tile in 3D like the screenshot shows. I would like to have edges shown like selected effeect, using shader graphs. All of the tutorials are showing just the edge, but not the inner ones. I would like to have like the 2nd screenshot. Idk if it's possible

civic sierra
civic sierra
fading pebble
#

I'm running into an issue where my shader looks good when in scene mode but does not work once its game mode. I'm pretty new to shaders, so I'm not even sure how to debug them.

#

I'm aiming for an intersection shader to show the in-bounds area.

#

Oh boy, I just had to toggle post processing on the Camera object. Nevermind 😭

keen thorn
#

I was hoping to use shaders to create a linear "progress bar" effect. The method I'm using doesn't do what I have in mind (22 second video demonstrates what I mean). Is it a result of the gradient I'm using as the texture, or is it something else entirely?
in my shader I have properties:

Properties
{
    _Color ("Color", Color) = (1,1,1,1)
    _MainTex ("Texture", 2D) = "white" {}
    _Cutoff ("Cutoff", Range(0,1)) = 0.5
}

and in the subshader, I only changed frag to look like so:

fixed4 frag (v2f i) : SV_Target
{
    // sample the texture
    fixed4 col = tex2D(_MainTex, i.uv);
    clip(col.r - _Cutoff);
    // apply fog
    UNITY_APPLY_FOG(i.fogCoord, col);
    return _Color;
}

https://www.youtube.com/watch?v=Qag_wpg4Mfw

low lichen
keen thorn
waxen grove
#

Hi there, is there a way to fade my skybox detail from 1 near the sun, to 0 completely away from the sun? I am using a modified and custom version of the standard procedural skybox

half skyboxTime = _WorldSpaceLightPos0.y % 360; I am using this to calculate when it should appear, but I was thinking more like the diagram shown:
How I am applying it in my script
col += tex2D(_DayDetail, calcSphereUV(IN, float2(0, 0), 0.02)) * saturate((skyboxTime + 0.3) * saturate(_AtmosphereThickness));

#

(Orange ball is the sun position in the sky)

low lichen
waxen grove
#

Hmm, how could I calculate the uv?

#

Or, how could I get it?

low lichen
waxen grove
#

Thank you, I got it work how I wanted!

#

Although

#

Is there a way to do the same effect, but only on the vertical axis?

#

Wait

#

I'm stupid...

#

Nevermind, but thank you

timber zenith
#

hello, i am using polybrush and a slightly modified version of one of the HDRP sample shaders, im using the paint textures on mesh setting, but it is currently painting only individual faces on my mesh, whereas i was hoping for it to be a circular brush. What would the best way of going about this be?

#

this is the entire shader

arctic depot
#

this is probably a dumb question but how do i fix this? i didnt make the shader and i dont know shadergraph but this is the only good water shader i have :(

waxen grove
#

What's the code?

ornate crypt
broken thorn
#

heya, for some reason i get parts of the mesh rendered even though theyre behind alpha 1 faces, and it makes it look really weird, anyone got any idea why?

#

im guessing it has somethng to do with depth testing

#

this is just a simple test i made, and its all wonky

regal stag
broken thorn
#

okie thx alot!

uncut flicker
#

hi guys! sorry if this is not the right place to ask this but... I was wondering...
Is there a way of making a TilemapRenderer to act as a Sprite Mask?

I came across a thread in the forums from 2023, it said that it was not supported, but I was wondering if maybe, as of 2024, it is now achievable? (or maybe there is a way of doing this by using shader wizardry™)

#

as a side note, I could create a spriteshape that resembles my tilemap and then use it as a mask, but, in this occasion, I want the sprite to only be renderer over the white parts of the tilemap anyapeek

left lava
#

Hello! I am creating a shader that gives each object on the screen a separate color based on that object's transform.position coordinates to test using the feature, but it seems whatever I do, my objects all have the same color. There must be something I'm fundamentally misunderstanding about the object node, since I can't get differing colors from it:

regal stag
hearty obsidian
#

I want to sample a normal map on a custom lit shader graph.

This is used to render a plane mesh along the XY plane. The UVs are the XY world space position hooked to a tiling and offset node.

This works fine when sampling a regular texture, but when the same UVs are passed to a Normal From Texture node, I get erroneous results. Results are the screenshot attached. It should be a hex grid instead.

Any idea what step I am missing?

Edit: What is seen in the screenshot is the normals sampled hooked directly into the color output

left lava
regal stag
regal stag
left lava
#

Is there any way for me to get the transform position of the object connected to a vertex in fullscreen?

regal stag
#

You may want to look into custom renderer feature to render out a custom pass, assuming URP

left lava
#

yep I'm using urp and a custom render feature here

regal stag
#

Then should be able to use DrawRenderers / cmd.DrawRendererList to redraw objects into a custom RTHandle. With overrideMaterial set to shader using the Object node.
Then pass that RTHandle to global texture property and sample in your fullscreen shader/pass.

left lava
#

Alright thanks, I will look into that

regal stag
uncut flicker
heady pewter
#

so i've been trying to take my old surface shader and convert it over to URP via shadergraph. i got almost everything the way i want, but i got no idea how to get shadergraph to cast shadows on the 2d sprite without going through the inspector's Debug and manually turning it on.
i figured enabling the "cast shadows" on the surface options would take care of it. but it doesn't work, yet changing it in the debug does.

heady pewter
#

figured it out soon as i started complaining 🙃

left lava
burnt crown
#

hey, looking for a transparent shader that only lets one face rendered so that transparent faces dont stack

broken vigil
#

Is there a good way to flatten an object's normals, such that light reflects off of it as if it were "flatter" on the screen?

#

Preferably without using a Post-Process effect.

broken vigil
#

Nevermind, I figured it out.

civic sierra
#

I programmed this shader. It will take the vertex colors for the smooth fade of 2 materials. (Pic1)
After that I programmed normal/height/Occlusion etc. in it.
But now my textures always appear just white.
EDIT: I have to take out the Emission but the top doesn't get any light.

vital token
#

Hi! I've got a small problem. I have like 300 water tiles and I haven't had a problem with them until now to be totally honest. Something seemed to change and now I can very easily see the edges of the water tiles because of the light reflections just being completely cut off when they reach the edge of a water tile instead of seeming like the reflections is being shared between the tiles.
I show the ShaderGraph that I use, sadly it's a ShaderGraph/Material I got off of the Unity Asset Store. I've been able to decipher parts of what is happening in it, but I'm not quite sure what could fix my issue. I feel it's something to do with the Screen Position being plugged into the light reflection/Planar Reflection. But I honestly have no idea, and I really hope someone can help

civic sierra
vital token
#

Wait do you mean my WaveController script and not the shader?

civic sierra
#

Yes.

vital token
#

I have an offset and speed for two waves. It controls all the meshes and calculates the heights based on the two waves.
I made the speed and the offset of both the waves equal eachother but you could still see the sharp edges of the tiles

civic sierra
#

I can See you have some variables like Offset 1, Speed 1 etc.
Run the game and change the values. So you can see what exactly changes.

#

The Amplitude 1 is 0.43f in unity but is 0.4f in your Script. This can be the fault.

vital token
civic sierra
#

And the other values? Change them a bit, so you can See what happens.

vital token
#

Oh SHT, I'm stupid!
Omg thank you! XD
It's the Noise strength/noise scale that I added to add a tiny bit of randomness.
Welp. I gotta find a way to make the noise strength/noise not cause this problem. Fun times

#

I'm so thankful you actually got me to mess around with it, because I thought I knew what exactly it did, because I spent weeks on it. But nope, XD the newest feature to it is what caused the issue. lol

civic sierra
#

Thats mostly the first Thing I am doing everytime I messed up some graphics 😄

vital token
#

Jeez, and here I thought it was something Unity did because I just haven't noticed that issue until I downloaded the newest editor verision XD

#

Anddd I've already got a fix to smooth out the noise.
Thank you! ❤️

grizzled bolt
#

It does
for it you also need Screen Position: Default for the UV input, and the Type should be Default, not Normal
You also need to have a 2D renderer active so that 2D lights can be calculated

#

Not nearly

#

2D lights are a specific system that requires URP with the 2D renderer to be active

#

Using the 2D renderer locks you out of any 3D lighting in turn, though

#

Depends are you using URP to begin with
#archived-urp has pinned instructions for the setup process

#

It should, and it should also set the default material of sprite renderers to Sprite Lit which is required for lighting
You also must be using 2D light components, not the default 3D ones
You should be seeing the lights interact with your sprites before getting into custom shaders

#

Since your 2D lighting works, start by trying to output the sampled light texture directly, with the changes I mentioned

#

Custom Lit sprite graph only, afaik

#

Are you testing in scene or just looking at the SG preview

#

The issue may have been that you've been expecting the node preview to show the light texture accurately
I'm surprised it shows anything there

#

If the sprite looks "transparent" with the light texture plugged to fragment color, that may be working perfectly

#

Since all your sprites seem to be the same white color, each one of them can only get its appearance from lights

#

You could still test by outputting a one minus of the light texture

#

Then it would show the inverted color and you know for sure it works

#

One minus node, not multiply

#

You should make sure the sprite is not behind the other sprites

#

In position or sorting order

#

That can make it seem transparent also

#

One minus doesn't seem to work with the 2D light texture as I'd hoped

#

But the light texture alone should still appear to show the lighting as if lighting a white surface

#

For that reason you'd usually want to have more textured sprites near it to see the difference

grizzled bolt
#

The light values are not in 0 to 1 range, that's why one minus didn't work for inverting it

civic sierra
#

I programmed this shader. It will take the vertex colors for the smooth fade of 2 materials. (Pic1)
After that I programmed normal/height/Occlusion etc. in it.
But now my textures always appear just white.
EDIT: I have to take out the Emission but the top doesn't get any light.

quasi zealot
#

Is there a place to systematically learh what each component in the shader graph, roughly does?

#

So to speak*

quasi zealot
#

aboutta tryitandsee

grizzled bolt
# quasi zealot I have not thank you

In addition to docs there are some videos that go through all the nodes (at the time of recording) and some common use cases which can give another useful perspective

frail geyser
#

Hey guys, programmer here, shaders have always kinda escaped me, but I'm trying. Would this be the best place to ask questions about shaders?

amber saffron
#

Well ... here

frail geyser
#

Essentially I'm trying to make a reveal shader, and the axis it's revealed on would be based on the enum (x,y,z). Maybe this isnt the best way to do it - if not please let me know, but I'm a bit stuck here. Previously whe nit was just Y/Z it was easy - just use a branch. True = X, false = Y => pass that information, but the flow is kind of confusing to me

#

Left side: beginning of set up - right side, y/z previous set up (now changed to x/y/z)

#

it flows/works on the X/Y, just confused and could use a pointer on how to set this up, and gpt hasn't been helpful

#

GPT suggested this kind of thing

#

and if I do get it right, I'm still not entirely sure how to pass this positional logic t othe next section (where it was easy with a branch previously)

regal stag
#

You don't need Branch nodes, the keyword node kinda acts like the branch itself. You'd input the X Y and Z groups into it's input ports

frail geyser
#

Ohhhh

#

Great idea, so I could essentially just do position -> axis -> out?

regal stag
#

Yes thats how it should flow

frail geyser
#

like this

#

That makes so much sense, thank you 🙂

regal stag
#

Sure, though Z has a different space - I assume that isn't intentional.
If so, could also use the outputs from one Position & Split, no need for multiple

#

Changing the keyword entries to XYZ instead of ABC would also make sense

frail geyser
#

Haha yeah - I realized that immediately on test, fixed that as well. Thank you

#

And yeah, I had em as X/Y/Z but accidentally ctrl + z'd while outside of shadergraph, and it undid that history change

#

but thats sorted as well. Nice catch

#

all axis are working as intended, thank you!

#

Also, if anyone has any suggestions for courses on shadergraph, I'd definitely be open to that

neat meteor
#

Why cant I edit the material properties (I want to make the material unlit basicaly (so like the colors are not affected by the lights))

#

I figured it out

frail geyser
neat meteor
ionic ivy
#

Has anyone watched the cartoon 'Chowder'? How would you achieve in 3D how the characters move but the texture stays the same.

frail geyser
neat meteor
tender edge
#

is it possible to add depth to a plane through a shader? without adding extra geometry

#

or maybe the illussion of depth?

radiant meteor
#

Can I call HLSLPROGRAM code from ShaderLab? If so, how do I do it? If not, what's the point of HLSLPROGRAM?

wooden ermine
#

Is there a reason my particles, if set to lit in shader graph, have a light grey background? I'm using the default particle as a mask, which works in any other shader type, so its not an issue with my transparency, is there something specific about the specular when render particles? I think its something to do with specular (URP Unity 6 btw), since changing the specular color changes the color of the grey

civic sierra
narrow breach
#

yo guys, i did that shader. Do you think a yt video can be interesting or it's pointless bc it's too easy to reproduce ?

#

it's a reproduction of a shader whose inspiration comes from "don't starve"

rare wren
narrow breach
#

shader graph based 🥲

#

if you think it's interesting i'll try to make the video in english

flint yew
#

don’t worry about it being easy or not

#

there’s people who don’t even know what shaders are

narrow breach
#

the thing is that shader is not my job at all so I don't know if what I did is "good" or not

#

if you want to check how i did it

#

the image come from "don't starve" so i recommend you to not use it, but feel free to use my shader

left lava
#

Hello! I have an object shader that displays everything as orange here shown in the pic, but I want the shader to also draw stuff around this object shader, like a green ring for example. Is that possible with this setup? The step I am having issues with is getting the shader to draw outside the lines of the original object

wooden ermine
#

Oh I didn’t post it here

wooden ermine
minor bone
#

I am trying to recreate Brackey's Dissolve effect (https://www.youtube.com/watch?v=5dzGj9k8Qy8) and I am running into a problem with my walking and idle animations for the character.

The effect applies perfectly to a static sprite, but it applies terribly to the animations. I think it has something to do with the scale of the noise map on the animations? I can sort of "fix" it by setting the Position node (Object) attached to the Noise maps to World, but that's not the effect I want.

#

Image 1 is what it's supposed to look like (and what it looks like on a static sprite), Image 2 is what it looks like on the animations when the game is running

#

To me it looks like the noise map goes giant, but I don't understand why

copper falcon
#

is there a syntax to write comments in unity shaderlab?

grave vortex
lunar meadow
#

How can I make my shader graph compatible with terrain?

#

This is all the shader is right now, until I add the triplanar stuff

#

Ive tried researching to enable terrain compatiblity but nothing shows up for shader graphs

#

Im using URP btw

copper falcon
wheat quiver
#

Unity 2022.3.22f1
Built-in Render Pipeline
Asset Pack: Stylized Meadow by HarpetStudio on Unity Asset Store

I love the look of these trees from this pack, however I am seeing strange behavior with the shader.

There is an invisible line running down the scene and if I place a tree on one side of it everything looks fine, but if I place the tree just over that line you get a solid black tree.

snow depot
#

Does anyone know how to make textures that look less like a physical object and more like a window that isn't effected by the way you look at it? It's a bit hard to describe but the technique is usually used with like cosmic space textures. There a ghost in destiny 2 like that and I think some fortnite cosmetics do the same thing

#

It's hard to convey through a static picture but here's the ghost. Like as the camera moves the star pattern doesn't.

#

I think it's done via shader

low lichen
snow depot
#

View direction? OK I'll look up how to use that.

livid pewter
#

i am having a problem with the Unity Terrain - HDRP Demo Scene with the shaders
i am getting the error Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). at Assets/trees/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(12579) (on d3d11)

meager pelican
# snow depot I think it's done via shader

Like it is a portal of sorts? Fake interior views?
https://www.youtube.com/watch?v=rC4BHR-Cx0s

This Shader is available in Asset Store: https://bit.ly/lwrp-materials-3

A quick overview of how to achieve fake interior effect in Unity using Shader Graph

Forgot to talk about creating cube maps in Unity, you can create whatever room in a square shape and put a reflection probe in its center and then bake it to get a cube map !

Download the...

▶ Play video
left lava
#

If I have two shaders in the same render step, how can I control their ordering? These are both in "Before Rendering Post Processing" and I wanna change it so that one happens before the other

neat meteor
#

I want to make a glass material for my flask but its invisible the only answer I found is to set the rendering mode to forward and turn of depth priming but it was like that on default

hearty obsidian
#

When using the URP sample buffer node for fullscreen graphs, the source can be set to motion vectors.

Out of curiosity, what is typically done with those?

dim yoke
# hearty obsidian When using the URP sample buffer node for fullscreen graphs, the source can be s...

Motion vectors are used in effects that need to know where the objects on the screen are moving. The most common use of the motion vectors is motion blur which obviously needs some information about the movements of the objects to work. Temporal anti-aliasing also uses the motion vectors though I honestly have no clue how TAA works so can't explain why they are needed but if I had to guess, it might have something to do with the past frame blending. There are definitely ways to use the motion vectors in some cases but most of the times you don't use those when doing your own fullscreen effects

late solstice
late solstice
#

And how to fix standart textures? Because they are purple too

kind juniper
late solstice
#

if I have HDRP, and here is URP, then there is no way to fix it?

grizzled bolt
late solstice
#

Can you tell me how, please? 🙂

grizzled bolt
# late solstice Can you tell me how, please? 🙂

Select the affected material, change its shader via the inspector
If you are using external packages, you need to make sure they support HDRP and possibly re-import them if you've changed render pipelines
If the fog was using an URP particle shader, you'd swap it to HDRP particle shader, which you need to import separately from the HDRP package of the package manager under the Samples tab

late solstice
grizzled bolt
late solstice
#

HDRP fog... Are there any links?

copper falcon
trail adder
#

hheya!

#

why does it change the background to be black!

grizzled bolt
trail adder
grizzled bolt
#

If the fragment block has no alpha input, the shader does not support transparency from its settings

trail adder
#

wait so this sucks a lot

#

theres no way to change the alpha value?

grizzled bolt
trail adder
#

i cant find any? could you suggest one that could work for a sprite

#

WAIT

#

IM DUMB

#

IM STUPID

grizzled bolt
trail adder
#

I NEVER SAW THE ALPHA CAHNNEL

#

nkjANSD

#

SORRYY

broken valve
#

im trying to make a raymarching shader and im passing these to shaders

Ray firstRay = cam.ScreenPointToRay(Vector3.zero);
Ray secondRay = cam.ScreenPointToRay(new Vector3(
    Screen.width-1,
    Screen.height-1
));
mat.SetVector("_Origin1", firstRay.origin);
mat.SetVector("_Origin2", secondRay.origin);
mat.SetVector("_Direction1", firstRay.direction);
mat.SetVector("_Direction2", secondRay.direction);

but it starts to break as i rotate the camera

#

how do i fix this?

#

the fragment shader:```glsl
fixed4 frag (v2f i) : SV_Target{
float2 uv = i.uv;
float3 origin = _Origin1;;
origin.x = lerp(_Origin1.x, _Origin2.x, uv.x);
origin.y = lerp(_Origin1.y, _Origin2.y, uv.y);
float3 direction = _Direction1;
direction.x = lerp(_Direction1.x, _Direction2.x, uv.x);
direction.y = lerp(_Direction1.y, _Direction2.y, uv.y);

float3 position = origin;
float totalDistance = 0;
float lastDist = -10;
for (int i = 0; i < _MaxSteps; i++){
    float dist1 = distance(position,_CirclePos)-_CircleRadius;
    float dist2 = distance(position,_CirclePos2)-_CircleRadius2;
    float dist = smoothMin(dist1, dist2, _Smoothing);
    totalDistance += dist;
    position += direction*dist;
    if (dist <= 0.01) {
            
        float t = smoothstep(dist1,dist2,dist);
        float3 col = lerp(
            _Color,
            _Color2,
            t
        );
        float3 normal = lerp(
            normalCircle(_CirclePos, position),
            normalCircle(_CirclePos2, position),
            t
        );
        
        float3 result = col * (dot(normal, -_Light));
        return float4(result,1.0);
    }


    if (lastDist == -10){
        lastDist = dist;
        continue;
    }
    if (dist > lastDist && lastDist < _OutlineTreshold){
        return fixed4(0.0, 0.0, 0.0, 1.0);
    }
    lastDist = dist;
}
return tex2D(_MainTex, uv);

}

royal vector
#

how do i add shaders to my game

low lichen
broken valve
#

yes im switching to use camera frustum and camera to world matrix

vague pilot
#

Hey do you know if its possible to create a shadergraph shader for creating a material that i pass to a custom renderer feature and blit the cameracolortarget texture onto a temporary texture and use this exact material for image effect stuff because atm im creating an unlit shadergraph -material and passing it to my renderer feature but it doesn't work at all (shows a black screen)

vague pilot
#

after 45 minutes i discovered fullscreen shaders that seem to work

drowsy abyss
#

Hey everyone! Here is a subshader that I use to get some useful information which I then use to work with other triplanar projection stuff. I was hoping to add some ability to define either an "up" vector or pass in some rotation information so that the values of "Triplanar_Mask" and "Sign" can be aligned with respect to that. I'm drawing a blank at the moment about how to take two vectors and produce a rotation between them.... can someone give me a hint?
Edit: I also realize the title "Space UV" is a bit misleading about what this function does, but I just kind of threw that out as a WIP. 😄

#

Some extra info for context: Switch 4 Vector 3 is a simple subgraph that contains a bunch of branches and mimics a switch statement.

#

An example of what I would like a default version of the node with unaltered output to look like which hopefully explains what I am trying to add.

snow depot
# meager pelican Like it is a portal of sorts? Fake interior views? https://www.youtube.com/wa...

Sorry bout the music I was playing while recording. I tried this out and messed about a bit and like I didn't get what I wanted but when I cranked down the depth to an insane degree I got closer. The way the texture doesn't move with the camera is what I'm looking for but it forms like this god ray pattern when the depth is super low and the texture still looks diffrent on diffrent sized and angled bits, for example on the rifle. I'm trying to get everything with this texture to look like I sliced out that bit of the screen and the texture is just behind it sitting statically.

tacit parcel
snow depot
#

I'll try looking up how to do that

broken valve
#

this is the result if i do length(position-worldPositionOfObject)-.5f
and this is how its supposed to be

#

but if i pass the worldToLocalMatrix and do length(mul(positionMatrix,position))-.5f of the objects renderer it breaks

broken valve
#

shouldnt it be the same thing tho?

#

since the rotations and scales of the objects are default?

#

it was with the logic nvrmnd

split hound
#

What would be a better approach for a province system akin to an paradox strategy games

A: one material that samples a big color texture, updating the pixels on the cpu when a provinces owner changes

B: having hundreds of materials stacked on top of eachother, one material per province, sampling a color property on the gpu, then updating that material property on the cpu when the province owner changes

C: some third way (tell me)

warm moss
split hound
#

so youd have one sphere with 1000s of materials

#

ive already tried approach A, setting the pixels and applying to update the texture is expensive

#

so ill probably experiment and try B

warm moss
split hound
warm moss
#

Because if each province is a separate mesh that covers only the province area, they get frustum culled separately and you clip a minimal amount of pixels in the shader just on the border of each mesh. You don't get any of those benefits if you're drawing an entire planet and then clipping most of it in the pixel shader for each province.

split hound
#

i see

#

well i dont have province meshes

#

so im not sure how to approach that

#

i only have image data

warm moss
#

If you have the original vector files for the map, you can find some vector file import library to load it in Unity, then for each region shape you can use LibTessDotNet to create a mesh and save it to your project.

split hound
#

Nope, dont. just a png

#

i dont want the provinces to be meshes anyways

#

they need to follow the geometry of the object theyre mounted to

cloud orchid
#

How can I disable dynamic batching on mesh renderers or shaders? Is this possible?

warm pulsar
#

Is it not possible to animate stencil properties?

#
[IntRange] _StencilRef ("Stencil Ref", Range(0,255)) = 0
Stencil
{
    Ref [_StencilRef]
    ReadMask [_StencilRef]
    Comp [_StencilCompareFunction]
    WriteMask 32
    Pass Replace
}
#

If I modify "Stencil Ref" in the inspector, it works exactly as expected

#

the animations change the properties in the inspector

#

But nothing happens

warm pulsar
#

(this isn't UI-related, by the way -- this is on a skinned mesh renderer)

#

ah, it sounds like I can't do that

edgy sluice
#

How do I make a plane render on both sides while keeping its material's transparency ?
Just adding "Cull Off" in a shader file removes the ability to set a material to a transparent option (even in the shader file)

low lichen
warm pulsar
#

Just the editor, yes

#

But things usually break outside of the editor 😉

flint yew
#

get the "screen UV" of the fragment and use that to sample the texture

snow depot
#

Yeah after I got that advice I looked it up and found out what I was looking for was called screenspace textures and I found some stuff for how to make those

#

Works fine now. I kinda cheated the unlit bit by setting the emission to the color then turned off all ambient lighting but hey if it works.

flint yew
#

looks cool.

#

albeit disorienting

warm pulsar
#

I got footgunned by this interesting shader problem just now

#
forward = normalize(forward);
view = normalize(view);

float dotted = dot(forward, view);
float angle = acos(dotted) * 360 / UNITY_TWO_PI;
#

angle is NaN

#

I solved this by clamping dotted to -1..1

#

But that's...alarming!

proper rivet
#

I am trying to make a volumetric indicator for loot object

#

This is close, but I want to make it look more volumetric, so it fades around the edges

#

Help, please

low lichen
warm pulsar
#

Nope -- dotted was not NaN, and neither vector was a zero vector

#

It occurred when the vectors were perfectly aligned. In this case, I was setting both of their Y components to zero, so it blew up along the XZ plane

tacit parcel
warm pulsar
#

That’s what I’m figuring

mental bone
#

Does anyone know how the texture scaling on the terrain shader works ? I'm trying to re-create the splat functionality in a shadergraph and I'm getting very different results. For example increasing the Size property of the Tilling settings of the terrain layer seems to make the texture bigger. In the original terrain the size is 8-8, in my shaderhrapg I have to put the tilling up to 128-128 in order to get close and it is not the same.

#

I tried looking at the actual terrain shader code but they dont do anything with the _DiffuseRemapScale0 variable for example

broken valve
#

why does the cubes look glitchy probably the normals are broken but idk what i did wrong

float3 normalBox(float3 localPosition) {
    float3 p = abs(localPosition);

    if (p.x <= .5 && p.y <= .5){
        return float3(0,0,sign(localPosition.z));
    }

    if (p.y <= .5&&p.z <= .5){
        return float3(sign(localPosition.x),0,0);
    }

    if (p.x <= .5 && p.z <= .5){
        return float3(0,sign(localPosition.y),0);
    }

    return normalize(float3(
        sign(localPosition.x),
        sign(localPosition.y),
        sign(localPosition.z)
    ));
}

float SDFBox(float3 localPosition) {
    float3 p = abs(localPosition);

    if (p.x <= .5 && p.y <= .5){
        return p.z-.5;
    }

    if (p.y <= .5&&p.z <= .5){
        return p.x-.5;
    }

    if (p.x <= .5 && p.z <= .5){
        return p.y-.5;
    }

    return length(float3(p.x-.5, p.y-.5,p.z-.5));
}
broken valve
#

comparing 2 floats gives wrong result

#
float getDistance(float3 position, float type){
    if (CIRCLE==type) return SDFCircle(position);
    if (BOX == type) return SDFBox(position);
    return SDFDonut(position);
}
float3 getDistance(float3 position, float4x4 mat, float type){
    return getDistance(mul(mat,float4(position,1)), type);
}
#
const float CIRCLE = 0.0;
const float BOX = 1;
const float DONUT = 2.0;
#
 HitInfo getHitInfo(float3 position){
     HitInfo info;
     float dist = getDistance(position,positions[0], types[0]);                
     float3 col = colors[0];
     float3 totalCol = float3(0,0,0);
     float3 normal = getNormal(position,positions[0],types[0]);
     float totalWeight = 0;
     for (int i = 1; i < objectCount; i++){
         float dist1 = dist;
         float dist2 = getDistance(position,positions[i],types[i]);
         //i call it ^^^^^
         if (dist2 == -500)continue;
         float3 nextCol = colors[i];
         float3 nextNormal = getNormal(position,positions[i],types[i]);
         dist = smoothMin(dist1,dist2,_Smoothing);
         float t = smoothstep(dist1,dist2, dist);
         float weight1 = abs(dist2-t)/_Smoothing;
         float weight2 = abs(dist1-t)/_Smoothing;
         totalCol += col * abs(weight1-weight2);
         totalCol += nextCol * abs(weight2-weight1);
         totalWeight += abs(weight1-weight2)+abs(weight2-weight1);
         col = lerp(col, nextCol, t);
         normal = lerp(normal,nextNormal,t);
     }
     info.dist = dist;
     info.col = totalCol/totalWeight;
     info.normal = normal;
     info.hit = dist <= .01;
     return info;
 }
#

it is weird

#

if i do if 1 == type it works

dim dawn
#

I finally figured out how to color the dark part of a BW texture 🥳

jovial moon
#

Help me please. Can not understand how to create Hlsl code shader for Full Screen Render Feature in URP. What specific must be there? (Want to have like full screen shaderGraph but with hlsl code)

idle wraith
#

How do i get a shader to render overtop of everything?

chilly portal
#

Guys my default material is pink and i can't change his shader. Its shader in this moment is Hidden/InternalErrorShader because i installed hdrp and then removed it

grizzled bolt
chilly portal
#

like the Default-Material is pink after removing hdrp

tacit parcel
grizzled bolt
#

Or if it's one of unity's default read-only materials

#

In that case I know there's an upgrade option for them to HDRP but not from HDRP
Uninstalling HDRP is not really supported

#

There may be some way to convert back the read-only materials but even if not, you can simply make a new material with a functioning shader and assign it to the mesh renderer

chilly portal
worthy copper
#

anybody know how to convert a vector3 to a vector2 😐

#

I cant find anything to do this

#

(im trying to convert the vertex shader's Position(3) to a Vector(2) or to just get the vector components to be used in stuff like sine)

worthy copper
#

Currently, im just using gradient noise as an input to everything but I don't think its a very good solution

idle wraith
tacit parcel
steel notch
#

Question about vertex displacement shaders.

#

Lets say I have a plane that's supposed to represent the surface of water or some force field.

#

I want objects to impact the surface, which causes a circular wave to expand out from the hit point, and then dissipate over time.

#

I want to be able to handle many different waves, each with different starting positions.

#

How do I best handle this?

tacit parcel
late solstice
#

Somebody can help me? I don't know how it is hard... I want to make it so that when there are particles (there are already rain particles), then water flows down on the objects. Example from this video

tardy agate
#

Hi all! I want to hide the part of objects that end up out of a certain region. Basically I want fragments outside of a certain range of X world position to be invisible.I'm doing stuff with camera stacking, and I've managed to get things working

#

ok with ortho cameras, but not with perspective.

#

What I've tried so far wipes out the wrong stuff on screen; things are erased if they overlap in screen space, ignoring depth.

#

What's the best way to go about this, anybody know? Cheers

#

Getting things working on a single camera, ignoring stacking, will do for the moment.

tacit parcel
# late solstice Somebody can help me? I don't know how it is hard... I want to make it so that w...

In this video we will show you how to create raindrops effect using Shader Graph in Unity Engine based on the Universal RP.
Download project files (Patrons only): https://www.patreon.com/BinaryLunar

00:00 Intro
01:00 Creating raindrops texture in Photoshop.
03:50 Creating unity URP project.
05:14 Creating simple texture scrolling Shader Graph....

▶ Play video
broken valve
#

and can i fix it?

amber saffron
broken valve
broken valve
#

i get it now

#

but i dont know how to fix it

amber saffron
#

Hum, I'm unsure about the source of the issue.

broken valve
#

i reset the position of the ray by getting the modulo and i believe it resets on one and doesnt on other pixel and the object is close to getting reseted

#

thats probably why

#

but idk if its possible to fix that

#

it also happens when i have scale smaller than 1?

amber saffron
#

could be worth trying this one

broken valve
#

i replaced it with that but im getting the same result

#

i dont hink SDF is the cause because it happens with all the other shapes too

#

this is really weird :/

amber saffron
#

Try his repeat function ?

broken valve
#

its not with the repeat function either cuz it still appears if i dont use it

#

i used the Renderer.worldToLocalMatrix this time because it is what they said in the Transform.worldToLocalMatrix docs but still broken

#

its not with the normal either

#

😭 why does this occur

amber saffron
#

I don't understand this line :
float3 pos = mul(positions[index],float4(position, 1));
Multiply the evaluating world position, with the shape's position ?

broken valve
#

i get the shapes local position for the SDF's

#

positions array contains the worldToLocalMatrices

amber saffron
#

Oh, right, so it's matrices, not only positions 😄

broken valve
#

yes

#

sorry for the name lol

amber saffron
#

Hum, I'm not totally sure, but maybe there's something going there : you are transforming the position into the "local" space of the shape, including the scale. That means that the returned evaluated distance is also in the local space of the shape 🤔

broken valve
#

because of that i dont use the scale info while using the SDF i just use 1 as scale

#

and the scales >= 1 works fine

broken valve
#

i still have no idea on why this happens

late solstice
cosmic prairie
#

it is possible to do what u want

#

but very not begginer effect

#

you need to write the splashes into a rendertexture

#

the rendertexture is processed by a compute shader to make it flow

#

and you sample that rendertexture in your objects to check where is water

#

or

#

another method is a custom decal

#

but that needs to be fine tuned a lot if u want good performance

#

it will also probably look a bit worse and unrealistic

#

but maybe a bit more begginer friendly

#

you can spawn decals with a vfx graph on impact

#

I'd recommend looking into that

paper sand
#

Using stencil buffer to cut out two different planes

late solstice
frail echo
#

In terms of optimization what is best, do a shader with Shadergraph (node) or with Shader Code(HLSL)?

cosmic prairie
late solstice
cosmic prairie
late solstice
#

Okay... Maybe I'll ask you something else, thanks in advance

#

🙂

cosmic prairie
# late solstice Okay... Maybe I'll ask you something else, thanks in advance

no problem, here is a link to get started btw https://youtu.be/nqhkB8CG8pc?si=tdVB1fR9E5FFpUyR

See how to make use of decals in VFX Graph to create thousands of dynamic, splattering balls of green goo. This video shows how to use the camera depth buffer to calculate the normals for the decals’ projection of the splatter graphics. The demo uses the portal assets from the free Visual Effect Graph Samples. Download it here: https://on.unity....

▶ Play video
#

very similar, just instead of wetness it's slime

late solstice
#

Okay, thanks for helping 🙂

frail echo
# cosmic prairie depends, how well can u write hlsl

Well the point is about learning shader code to optimize shader graph. Im working on a game and i'm at the point where i need to optimize things, besides, code, assets textures etc, since i used a lot of shader graph effects i want to see if there is an optimize way to do that, and i thought doing in shader code it coudl be better, but not sure, this is why i'm asking

cosmic prairie
#

very rarely there will be some equations that maybe you could write faster versions in hlsl but u can use a custom hlsl block for that

#

thing is the shader compiler is very smart

#

it can optimize shader graph code just as well as normal hlsl given you want to do the same thing in each

amber saffron
frail echo
#

@cosmic prairie @amber saffron ty both

amber saffron
#

IMHO, I'd just use shadergraph though 😄

cosmic prairie
#

I think the right wording would be to close it all down, both can be slower or faster. Both use the same compiler, so if both shaders are identical both will be equally fast. Shader graph's template has been optimized by the Unity devs, so you get a head start there if you don't know much about shader optimization. If you go the hlsl route you will be able to customize the whole shader to your very specific needs, and perhaps even eliminate some unused features put in there by the default template. Be wary, that not all features are always used. Shaders use keywords to completely toggle on/off specific features, so you may not even gain anything by removing something that you did not use in the first place.

wispy elbow
#

Does anyone know how to make rounded corners in Unity URP with shader graph for UIs? The corners I want is something similar to Roblox's corners.

#

I'm a bit new to Unity.

copper falcon
# wispy elbow Does anyone know how to make rounded corners in Unity URP with shader graph for ...

Ben Cloward released a video about shadergraph and buttons just 3 hours ago.
Usually, he provides great value. Maybe youre lucky https://www.youtube.com/watch?v=6UYqtdRoKQ4

In this tutorial, we create a simple button UI element in Unreal and Unity using the Rectangle SDF node we created last week. The shader includes standard, pressed, active, and moused-over states. The tutorial also includes the creation of a scale node to add to our library.


Here's last week's video that s...

▶ Play video
wispy elbow
#

Oh wow, that’s awesome! Thank you so much!

#

It seems like a really complicated graph, but the node "rectangle" he used in the video shown was created in another video. Here: https://www.youtube.com/watch?v=fDjEq30dwNM&t=278s if anyone's also interested in procedural shapes

In this video, I show how to create a full-featured rectangle signed distance field node. The node includes fill, stoke, SDF, and Stroke SDF outputs and has lots of controls to change the size and shape of the rectangle - including rounding the corners.


Here's last week's video that show how to create a cir...

▶ Play video
wispy elbow
#

I'm almost getting the results that I want, but I seem to be unable to fix this, I belive it's a UV issue.

odd hedge
#

I installed the ShaderlabVS extension for Visual Studio, but the shader files dont open anymore. When I deactivate the extension, the shader files can be opened normally again. I am using VS 2022 and URP, both should be supported by the extension. Error:

#

Anyone know how to fix

grizzled bolt
#

As well as any corner decorations

elfin token
#

I wanted to know how to make
2.5 water where the side facing the camera (like in Rayman Legends or Ori) seem a bit transparent and there is water distortion effect and waves

#

Asking a lot yeah sorry haha... built in please, not urp or hdrp

radiant meteor
#

Anyone else having the problem of the object position node being wrong when multiple objects with the same shader are on the screen at one time?

grizzled bolt
radiant meteor
#

how do I disable batching? I don't seem to have an option for my sprite shader.

grizzled bolt
radiant meteor
#

Ok, I think I can get around it using a canvas renderer instead with multiple world canvases. I don't see the material block property warning when doing it like this.

grizzled bolt
radiant meteor
#

I think I got around the sprite renderer batching by using world canvases and canvas renderers instead via images.

wispy elbow
heady pewter
#

ok so.. converting my surface shaders to fragment to make them work with URP... is very complicated... or i have just not found the correct information so im goign to ask here incase of a point in the correct direction...

i'm looking to create a simple fragment shader that behaves the same as a standard surface shader. react to lights, have a normal map, and can cast shadows. anywhere i can go to learn this? im open to mess around with shadergraph, but with what im trying to do with it i cant seem to do it in shadergraph as i can write it in a fixed4 frag

rare wren
rare wren
#

Any idea how to handle soft shadows in a custom lighting (unlit) shader?

The SOFT_SHADOWS keyword works until 2021, then 2022lts introduces the shadow tiers (SOFT_SHADOW_LOW _MEDIUM _HIGH), but using SOFT SHADOWS still works, and Unity 6 just breaks in builds but not in editor

#

I am working on an asset and would prefer to use 1 shader for all editor versions if possible

vapid flint
#

Does somebody know how to make a water shader using the built in render pipeline?

jolly adder
#

Hey,
I have a model which uses a texture atlas and that texture atlas contains different gradients and colors. So based on the model UV it has different colors for different parts of the model.
Now I want to use this model to have different set of colors. I can have multiple instances of same model with different UV but I want to know if it is possible to have just one model with different UV and texture atlas works on it ?

grizzled bolt
jolly adder
# grizzled bolt I don't very clearly understand what's the difference between "have multiple ins...

I mean I don't want to have multiple duplicates of the same model which their difference is their UV maps.
I want to have just one model which contains multiple UV maps and I can use my texture atlas on them which makes them different in set of gradients and colors.
Though I'm not sure if it is a right approach at all. Mostly I want to know what is the way to achieve have one model which can have different set of colors and gradients based on the texture atlas.

grizzled bolt
#

You could instead have a material property that adds an offset to sampling of the palette texture, so each material can sample a different row or column of the palette

jolly adder
jolly adder
grizzled bolt
jolly adder
grizzled bolt
#

Drawbacks of swappable UVs are that every mesh will have to store more data per vertex, and since shaders rarely do branching I expect that every material would repeat the sampling for each UV set, even when they're not in use

kind juniper
#

If you intend to have many objects with the same meshes but needing different textures, it might be better to have 1 custom mesh that allows you to offset the uvs.

jolly adder
grizzled bolt
# jolly adder Thanks a lot

There's a lot of ways to go about it, but how the shader is set up can have a lot of implications for batching performance
Which also depends a lot on what render pipeline you're using

jolly adder
grizzled bolt
#

That particular way might be hard to control, but still enables a whole another dimension of per-vertex information

#

Extra UV channels can be used for any similar purpose
But in my opinion the strength of the vertex data channels is when you read them all at once for a specific purpose, rather than trying to select between them

jolly adder
#

What do you mean by UV channels ?

kind juniper
grizzled bolt
#

I don't think Unity calls them "channels" very often, usually UV0, UV1, UV2 and so on

jolly adder
#

Thanks

mental bone
#

Anyone familiar with SpeedTree and URP ? We are trying to export SpeedTrees with the new Games wind to Unity 6, but when we enable the wind in the SpeedTree9_URP shader the whole tree breaks and deforms. If we export with legacy wind and use the ver 8 shader it all works...

late solstice
warm moss
grizzled bolt
warm moss
#

It'd be creating 2 shader variants but 2 batches isn't a lot.

grizzled bolt
warm moss
#

It'd be the same.

grizzled bolt
left lava
#

Hello! I made a simple ViewSpaceNormals shader, but it seems to draw things to the texture even if they are hidden behind other things. for example, the spider's abdomen should be hidden behind the legs here, and the whole thing should be hidden behind a plane I placed in front of it for testing. I am calling the viewspacenormals shader as a material in a render feature here:

CommandBuffer t_cmd = CommandBufferPool.Get();
            _context.ExecuteCommandBuffer(t_cmd);
            t_cmd.Clear();

            // Normals
            DrawingSettings t_drawSettings = CreateDrawingSettings(m_shaderTagIdList, ref _renderingData, _renderingData.cameraData.defaultOpaqueSortFlags);
            t_drawSettings.perObjectData = m_settings.perObjectData;
            t_drawSettings.enableDynamicBatching = m_settings.enableDynamicBatching;
            t_drawSettings.enableInstancing = m_settings.enableInstancing;
            t_drawSettings.overrideMaterial = m_normalsMaterial;

            t_cmd.SetRenderTarget(m_normals);
            t_cmd.ClearRenderTarget(true, true, m_settings.backgroundColor);
RendererListParams t_normalsRenderersParams = new RendererListParams(_renderingData.cullResults, t_drawSettings, m_filteringSettings);
            m_normalsRenderersList = _context.CreateRendererList(ref t_normalsRenderersParams);
            t_cmd.DrawRendererList(m_normalsRenderersList);

            // Pass in RT for Outlines shader
            t_cmd.SetGlobalTexture(Shader.PropertyToID("_SceneViewSpaceNormals"), m_normals.rt);

Thanks in advance!

#

I think it is something to do with setting up and using a depth buffer in my rendering feature

warm moss
#

@left lava instead of using SetRenderTarget, call ConfigureTarget(someCustomRTHandleInColorFormat, someCustomRTHandleInDepthFormat) from your pass's Configure.

#

Also make sure your shader has ZTest LEqual, ZWrite On.

#

The first handle is what you're later going to pass as a normal map and the second handle will be a depth texture.

#

Do not try to allocate an RTHandle that has both a color format and non zero depth bits, the RTHandle will be depth only if you do that.

grand jolt
#

~~does someone know why the shader of my material doesn't work? I haven't started coding yet but its the default "Image Effect Shader" and yet it doesn't do anything.

But for some reason it DOES work with shader graph, Is there something i gotta do to make my shader/material work as a full screen pass render feature?~~

#

wait i just realized that the image effect shader affects a texture2d

#

im dumb

reef grove
#

I want to have a texture mapped in screen space but its all distorted

#

wait I think I mightve figured it out

#

yup

#

you gotta multiply by screenPos.w

#

for whatever reason

quasi zealot
#

How do I get the stencil property working in shader graph? Do I add these as properties in shaderGraph and then it'll magically start working?

#

For context I'm trying to write a gradient color shader for UI images so I can mask TMP over this image with the Mask component

#

Ping me if you reply thanks!

low lichen
quasi zealot
steel notch
tardy agate
#

Hi guys. Is it feasible to add fragment-discarding into the URP lit shader, or would it make more sense to find another shader with the other needed features in it? I'm currently using base, height, normal, metallic and occlusion maps, but I can try to cut down on my needs if necessary

alpine turret
#

I got this texture with shader graph, and I'd like to export it as an image file. Is there a way to do so?

rare wren
#

Is there a way to add the REQUIRE_OPAQUE_TEXTURE define in shader graph with a custom node?
So far I have been unable to. It needs the scene color node to be in the graph somewhere in order to work, while I need to sample the scene color in a custom node instead

#

Nvm fixed it with a keyword :P

bitter blaze
#

How can I make it so that on the back side it is not transparent but also a normal color?

tender edge
#

i have made a seperate flowmap for each Y of my 3d grid. but am currently a bit lost on how i could use this in a shader for uv scrolling. could i set the flowmaps through script to a shadergraph texture2d array and then select the correct one based on world pos. or would i need seperate meshes for each Y aswell?

rare wren
#

I do not think so (and cannot measure so), but is it faster to have a for loop in shaders with an iterator being a power of 2?
So that 8 iterations could be faster than 7

quasi zealot
#

What would I write in a shader so that it samples the color provided in editor and relays tht into color's alpha?

#

I've written a custom gradient shader that takes two colors and would like to add the ability to sample from the Color's alpha. I can already sample the actual color but not the alpha

vague pilot
#

Hey, is this the same under the hood or is the upper version more performant?

warm moss
warm pulsar
#

I'm trying to figure out how to compute a world-space view direction (the direction a pixel is facing in the world, not the camera forward vector) in a hand-written shader

#

The Shader Graph has a "View Direction" node, but it's...inscrutable. It looks like this just causes the data to magically get passed to the shader??

#

(this is not a surface shader, and it's in the BiRP)

#

The goal here is to compute an angle between a specific direction and the direction that the pixel faces in

#

i noticed that this node implements IMayRequireViewDirection. I imagine this prompts the render pipeline to provide this information?

regal stag
warm pulsar
#

what is positionOS here?

#

still learning the wacky acronyms (:

#

oh, an object-space position?

regal stag
#

vertex positions

#

POSITION semantic in vertex input struct

warm pulsar
#

ah, so i'd need to do this in the vertex stage

regal stag
#

Typically yeah

warm pulsar
#

the bonus gotcha is that this is a full-screen image effect, so the original vertex positions are meaningless -- I'm just doing this to compute the clip-space vertex positions

#
                o.vertex.xy = v.uv - 0.5;
                o.vertex.xy *= 2;
                o.vertex.z = 0;
                o.vertex.w = 1;
regal stag
#

Right, yeah that complicates things

warm pulsar
#

I don't see any way to get back to object space once I'm in clip space

#

I wonder if I can calculate the world-space position for a specific position on the near clip plane

#

(i mean, that's basically just a clip-space to world-space transformation..)

#

oh my god I just realized I actually wanted the camera view direcetion

#

However, this did work!

#

I had to do it in the vertex stage, so it's a bit chunky

#

(i'm using a 10x10 plane or something like that)

mild burrow
#

hihi, is there any way with shader graph to make two translucent things of the same material not accumulate? Ex. below; notice how the alpha values accumulate in the overlap section. I'm tryna get rid of that.

#

Tried setting blending mode to premultiply but that didnt work unfortunately

kind juniper
mild burrow
kind juniper
#

The cause is that each individual draw call doesn't know anything about the preceding draw calls, it just adds to the color of the render target.

mild burrow
#

makes sense makes sense. I've actually been working on learning the ins and outs of 3D Graphics so I appreciate that insight

turbid mortar
#

Does anybody know why the lighting on my gerstner waves are wrong?

#

I looked on catlike coding's website and they said that it was something to do with adding a pragma? I'm very new to shaders and I'm jsut using the shader graph so iI'm not really sure how to translate this

#

also, I'm using URP

neat hamlet
#

that article is using surface shaders, those dont exist in URP

#

the equivalent would just be to turn on shadow casting and receiving in the graph settings

turbid mortar
#

would it be the normals actually?

#

or does unity automatically recalculate normals after moving a vertex via shader graph

regal stag
turbid mortar
#

This worked, tysm

paper sand
#

I got a texture-mask that I wanted to subtract. And does work perfectly until I add transparency. Somehow it gets a blueish value instead of being fully transparent, as you can see on the right. Why does that happen, is the alpha value negative and because of that it prints the color in its negative?

regal stag
broken thorn
#

heya, im trying to make a shader where the back faces are rendered first, then the front for transparency reasons, so at first i thought multiple passes but from what i understand urp is single pass, also multiple subshaders didn't work, is there any other this could be done?
right now a hacky solution i found was to have one material render the front faces and one material render the back with a lower sorting priority, but this seems kinda wasteful and hard to edit

broken valve
#

does unity shaders has a method like Matrix4x4.TRS?

dim yoke
broken valve
#

yes

dim yoke
broken valve
#

construct

dim yoke
#

From which values?

broken valve
#

translation, rotation, scale?

#

nevermind

dim yoke
# broken valve translation, rotation, scale?

If you look up TRS matrices, you can construct them manually since they simply consist of the position in the last column and the world space directions of the local axes X, Y and Z (which magnitude is the scale along that axis) in the columns from left to right. Why do you need to do that though?

#

nevermind

neon gale
#

Is there such a thing as ShaderGraph 'Reroute Nodes' as there are in Unreal? it is just a way to 'wirelessly' connect things

turbid mortar
#

Has anybody here had experience making gerstner waves in the URP shader graph? If so, could I see you graph please? My gerstner waves only travel along the x axis - regardless of the parameters for some reason

regal stag
neon gale
winter gate
#

I forgot to do a round() call in my shader.

regal stag
neon gale
warm moss
bold turtle
#

its because the object is a canvas element?

grizzled bolt
bold turtle
#

how to set canvas graph?

bold turtle
#

ah. i use 2022

grizzled bolt
#

Shader graph is not officially supported without it but there may be some ways to get it to work anyway

bold turtle
#

how and should i?

grizzled bolt
# bold turtle how and should i?

I don't know personally, but it's something to look into
You could also make a test project in Unity 6 to see if the graph you have would work as a canvas graph if you want to verify that there's nothing technically wrong with it otherwise

bold turtle
#

eh. i set it to sprite unlit

#

kinda work

desert void
#

I'm playing around with shaders for the first time, and I just can't understand what's causing these giant black areas on my fish textures:

#

if I turn Off the Animator, then I get what I expect: a very thin, black outline along the front edges of the fish:

#

I don't think I'm doing anything differently that what everyone else does. I'm using a UV to offset my sprite, then subtracting the offset'd sprite from the original to find the edge. The only difference on mine, is that I need to use a Step to in the middle because I have some areas of slight Alpha, that I need to account for:

#

the goal is to put an outline around the fish. In this example, I'm just putting the outline along the front edges of the fish -- but i'm getting the weird black "blobs" when the Animator is on

desert void
#

Additionally -- i've adjusted the thickness of the outline (by changing the x-value on the Offset), and now I'm getting some fish which go completely Black on certain animation frames. Really not sure what's going on:

iron rain
#

Hey, so for some reason my URP shaders are pink when builded, but not in editor

iron rain
#

found the issue

#

no render pipeline in the targetted quality

broken vigil
#

Is there any reason whatsoever that one Custom Function Node would ignore Point Lights, while another, identical Custom Function Node running pretty much an exact copy of that function uses point lights correctly?

#

This is driving me insane.

mental bone
#

Anyone done a custom terrain shader in shadergraph? How did you handle tilling and offset ? I keep looking at the code of the urp terrain shader. I found how they sample the control, but I cant find what they do with the ST's for the different splats. For example the size property of the terrain layer is 8-8 but putting that value as the tile of the texture in shadergraph does not give the same result.

mental bone
#

so turns out there is probably a bit more work to get terrain instanced renmdering working with a shader graph

#

Has anyone done this ?

regal stag
mental bone
#

hmmm ```void TerrainInstancing_float(float3 posOS,out float3 vertOS, out float3 normal, out float2 uv)
{
#ifdef SHADERGRAPH_PREVIEW
uv=float2(0,0);
normal=float3(0,0,0);
vertOS=float3(0,0,0);
#else

#ifdef UNITY_INSTANCING_ENABLED
//vertOS = float3(0,0,0);
float2 patchVertex = posOS.xy;
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP(Terrain, _TerrainPatchInstanceData);

float2 sampleCoords = (patchVertex.xy + instanceData.xy) * instanceData.z; // (xy + float2(xBase,yBase)) * skipScale
float height = UnpackHeightmap(_TerrainHeightmapTexture.Load(int3(sampleCoords, 0)));

vertOS.xz = sampleCoords * _TerrainHeightmapScale.xz;
vertOS.y = height * _TerrainHeightmapScale.y;

#ifdef ENABLE_TERRAIN_PERPIXEL_NORMAL
normal = float3(0, 1, 0);
#else
normal = _TerrainNormalmapTexture.Load(int3(sampleCoords, 0)).rgb * 2 - 1;
#endif
uv = sampleCoords * _TerrainHeightmapRecipSize.zw;
#endif
#endif
}I'm getting a'TerrainInstancing_float': output parameter 'vertOS' not completely initialized ``` error from this custom function. What gives ? I'm not seeing anything wrong.

regal stag
#

All code paths need to set them

regal stag
mental bone
mental bone
#

Looking on the net I saw something that it should be 1/tilling to match the original terrain but I cant confirm that

#

so I need to provide my own tilling values as exposed params from the graph

regal stag
#

Isn't it just UV * Tiling? Or is original terrain doing something weird

mental bone
#

it's doing somethig wierd. the size value of the layer is 8-8 if I put that in the Tilling and offset node

#

the result is not even close

regal stag
#

Oh right UV would be the whole terrain, not per unit

mental bone
#

it gets close if I put 128-128 in the tilling node

#

but it is not the same

regal stag
#

Hmm, I think I usually use worldspace position rather than the actual UV

broken thorn
#

Is there a way to make sure back faces render before front in urp?

#

From what I got there can only be one pass per shader

dim yoke
broken thorn
#

yeah that's what i have rn, just feels wasteful to render both faces twice and just discard half the work and i wondered if there was a better way

tender edge
#

im trying to make my flowmap shader work with different heights, but im lost on how to achieve that. right now im storing my flowmaps both as a 3d texture and as an array of flowmaps stacked on top of eachother, how could i use one of those to assign the correct values for different heights?

smoky widget
#

What's the best way to set a flag in a compute shader?

#

I want to know if any of the threads encounter one specific value, and if so, rise a flag for later on the CPU do something

tender edge
#

i honestly can't find anything about how to use a 3d texture for this. should i make a seperate mesh for each y level instead and give each their own flowmap?

amber saffron
tender edge
#

i tried replacing the 2d texture with the 3d here but can't get it to work

amber saffron
tender edge
amber saffron
tender edge
amber saffron
#

Are you generating this mesh from script ? You could as well store the flow direction in the vertices, through a color or UV value. And this for all the "stack" of water

tender edge
amber saffron
#

Of course, if you go for volumetric rendering, that won't do

tender edge
#

it spreads from wherever i place the source

amber saffron
#

I really don't get the idea with the different flows at different ys. Or how you would want to show this with the current meshes

tender edge
#

there its possible to have different water streams on top of one another

amber saffron
#

Well, like I proposed, store the flow with the liquid mesh vertex data, don't bother with a texture

#

You won't have to mess with changing texture size based on the mesh change, no 3d / array of texture ...

tender edge
round relic
#

i need help. i'm not sure if this is the right place but i imported the BoTD assets and the colours on these prefabs are pink

amber saffron
amber saffron
round relic
#

how do i do that?

tender edge
amber saffron
# round relic how do i do that?

Look at the material, note the diffusion profile assigned. Find the global volume of the scene or create a new one. Assign the diffusion profile in the diffusion profile list override

amber saffron
tender edge
amber saffron
round relic
#

also, i don't know if this is related to shaders but when i try to extract textures of a model i get these errors

tender edge
# amber saffron You already have the shader no ? It's just the matter off using the vertex color...

the shader only works on 2d planes so far, https://youtu.be/SA6Y3L-X0Po?si=K_y-NNgSdF3TvxWw i recreated this one from polytoots but some stuff in it is going right over my head

I really need to learn how to make better thumbnails, but for now It's another flow map tutorial, and this time using Unity's shader graph. We first take a lovely node setup that was made in Amplify (from the amazing Gooseman) and then convert it into a sub-graph, so we can more easily hook it up to different outputs.

You can make your own flow...

▶ Play video
#

theres also the issue of not having any vertices on the middle of the quads

inland ibex
#

Hey everyone,

I'm fairly new to shaders, but I'm trying to create a cloud effect for my game using shader graph and I've hit a bit of a roadblock.

Attached is a video where the first half shows the effect I'm aiming for, and the second half shows what I've managed to create so far.
I've used a Voronoi and a gradient noise to get some movement on the screen, but the effect isn't quite what I was hoping for. Since this is my first time working with shaders, I'm feeling a bit stuck.

I'd really appreciate any advice or help from someone with more experience. I can share my shader graph with what I have so far if needed. 🙇‍♂️

https://streamable.com/x6xkco

Watch "shader" on Streamable.

▶ Play video
chilly robin
#

I'm using Shader Graph to make an eye occlusion shader for URP. The problem I'm having is that the occlusion mesh clips into the eyeball.

#

I believe the way to fix this is to apply some kind of depth offset? So that the occlusion mesh is drawn in front of the eye. But this does not seem possible in URP shader graph from what I can tell. What are my options here?

mental bone
#

In URP when doing depth priming we use the the depth only pass from the shader correct ? So the only way to optimise this pass is to reduce the vertex count of the objects ?

tender edge
# amber saffron Well, like I proposed, store the flow with the liquid mesh vertex data, don't bo...

i gave the method you suggested some thought, but considering i make my resistance field and vector field after i make the mesh i dont think it fits for me, theres also the issues of not having a central vertex to store the data on and that i update the mesh everytime it changes and the vectorfield only once and that im not sure on how to find the correct vertex after the mesh has already been created

amber saffron
tender edge
#

biggest issue would be that i create the res. field and vector field after generating the fluid mesh tiles, once a plateau has been completed

jolly adder
#

Hey guys,
How can I have metal surfaces in toon shading ? What is the approach ?
Also I want to have metal surfaces on specific parts of the model

grizzled bolt
#

Old games used matcap shading or similar texture projection techniques to fake specularity of glossy and metallic materials
But on the far other end of the technology spectrum it's also possible to turn metallic PBR shading into toon shading

jolly adder
grizzled bolt
#

There's countless different ways to do "gold"

jolly adder
jolly adder
#

For instance, specular reflection and highlight are the technique to achieve metallic surfaces ?

grizzled bolt
# jolly adder I noticed MatCap is more like projecting texture with metal look, that's right ?

Yes, it mimics reflections which usually most of what gives a shiny metal object its signature look
Most toon shading techniques you might find don't make much of a difference between specular and diffuse lighting, and rarely support reflections
As they're kinda hard to make look "toony"
I don't know if it's the case for all PBR implementations but you might notice that metallic materials in unity only receive specular highlights and reflections, no diffuse lighting at all

#

But since toon shading mimics drawn styles there are no rules or much even in the way of guidelines of how materials should look

#

Hi-Fi Rush has metallic materials but as far as I can tell they use the same toon shading as everything else and they look fine
But hair in that game has some of the kind of fake specularity that could be useful for metals too on a second look the specularity is faked with physical geometry

jolly adder
#

Hmm, I don't have that much experience in graphics and shader stuff so I don't get much from your messages 😄
I'm searching based on the terms you used in your messages and trying to find out what should I do on my side.

So what is the simplest way to achieve metal surface ?
Also what is your opinion about using gradient which looks like metal surface in the texture ? Instead of using specular highlight or other techniques.

#

I want to know if I want to have metal surface on specific parts of model can I use texture map or something ? Or I have to assign another material ?
Sorry for asking too many questions

smoky widget
#

What's better
A

LocalKeyword crossFade = new LocalKeyword(instanced.shader, "_CROSS_FADE_LOD_DITHER");
instanced.SetKeyword(crossFade, config.CrossFadeDithering);

or B

if (config.CrossFadeDithering)                
    instanced.EnableKeyword("_CROSS_FADE_LOD_DITHER");
else
    instanced.DisableKeyword("_CROSS_FADE_LOD_DITHER");
regal stag
smoky widget
#

Mmm, im a bit annoyed I need to provide the shader because then I need to create many of those local keywords

regal stag
#

I imagine the advantage of the first is probably that you can cache the LocalKeyword if it's being set per frame

smoky widget
#

That's true, I just noticed that it also validates if the keyword is on the material

marble anchor
#

In my game, I have a shop with skins. The skin contains colors (Color1, Color2) which are then placed as values of a material. I want to show the skins in the shop. Question about optimization: if I have multiple skins in the shop should I use MPB and run it for each skin or create material individually? I'm planning to add 50+ skins in the game.

kindred matrix
#

Hello, I am experiencing an issue with an assets pack, they show up just fine in the Unity Editor but they turn pink when I build my project as a WebGl. I downloaded a separate shader pack which the assets are dependent on, and have selected the URP_Package and URP_WEBGLFIX options however they do not seem to have fixed this issue. What should I do to resolve this???

tired verge
#

Hi all!
If I have a unity build on mobile or on pc, how I can access the spir-v shaders? Is it possible at all?

neat stirrup
#

is it possible to use per pixel tesselation in shader graph?

tight phoenix
#

I have a vertex displacement shader that affects vertexes in Object Space coordinates, however the scale and magnitude of the deformation changes when I scale a mesh affected by it down
How can I counteract / negate this scale issue?

#

I want the effect to be consistent irregardless of the object's scale, which is why I used Object Space instead of World Space for the vertex deformation

#

the deformation in question

#

Was I mistaken thinking that object space coordinates don't change with object scale? Does anything keep that size?

tight phoenix
#

I was hoping for scale to not affect this part of the shader

regal stag
reef grove
#

hey guys, I'm looking to make a shader with an outline, is there any way to do it in one surface shader? basically id want to render the object once using the outline effect, and then again using the regular part

#

would it be easier to have a script that creates a new mesh renderer with the materials

#

(im doing a version of the outline where I render the object inside out and slightly bigger)

kind juniper
reef grove
#

how do passes work?

tacit parcel
tacit parcel
reef grove
#

the idea is that i wanna do that automatically

#

but i found a fine solution

#

where i just duplicate the mesh

#

and use a different material

tacit parcel
#

that could work, but if the object is animated, you'll need to animate both I guess

copper falcon
# reef grove where i just duplicate the mesh

You may want to test that with different meshes, this way is very very limited. Shaders that do create the outline by pushing vertices outside by their normal can/will leave gaps and ways of creating more fitting normals or the model may influence shading. This is particularly important if the outline is combine with cell shading where the face normals are sometimes used for artistic effects.

grizzled bolt
brazen prism
#

hey guys, super new to shader graph, just made this outline and im wondering why the outline in-editor is all funked up aftwards

desert orbit
#

Make sure sprite asset shape setup. Default one is not good enough usually you need to tweak it.

brazen prism
#

i see, ill look into that.

#

this might be getting out of the scope of this channel, but what benefit would i actually be getting for tweaking that sprite shape?

#

considering i dont plan on stretching/deforming this sprite

desert orbit
#

It depends on what you are doing, could affect it.

#

Also picture looks like maybe it's a pixel perfect resolution issue.

#

If you want to verify it's not something shader does, post the thing (shader graph pictures) in #archived-urp channel for someone to check

rapid marsh
#

guys, I've downloaded these custom shader nodes and put them in my assets:

#

but when I do a search for them in the shader graph they won't appear

#

ah it's because I have to insert the file in a custom function node

grizzled bolt
tender edge
#

i got my flowmap texture mapped correctly by fiddling with the offset and scale variables. but it breaks if i change my mapsize. ( the flowmap should overlay the map 1:1 ), how can i set the scaling correctly?

ornate barn
#

how do i fix this?

reef grove
#

it doesnt rly explain how the get a re-rendered copy

amber saffron
ornate barn
amber saffron
#

Or, generate proper UVs directly on the mesh 🤷‍♂️

amber saffron
reef grove
#

rerender the mesh

#

render it twice

#

once as the outline once as the normal mesh

amber saffron
#

Well, you can do it as an other pass in the shader.

tender edge
reef grove
#

so i can just have 2 passes

#

ok

amber saffron
reef grove
#

when i looked it up ppl said i cant do that

#

ill try it

amber saffron
ornate barn
amber saffron
ornate barn
amber saffron
#

(unless it's unity < 2021.3 iirc)

ornate barn
#

so this?

amber saffron
grizzled bolt
#

Doesn't even need a special shader and works with weights
But it's a limited method in other ways

amber saffron
amber saffron
tender edge
#

it is after the flowmap gets sampled though

#

not sure how that affects it

amber saffron
# tender edge

It's not on the UV output, and not for the flow map sampling, so it's not the issue.

tender edge
#
    {
        completeMap = new Texture2D(textureWidth, textureDepth, TextureFormat.RG16, false);
        completeMap.wrapMode = TextureWrapMode.Clamp;
        completeMap.filterMode = FilterMode.Point;
        completeMap.anisoLevel = 1;``` part of the method where i initialize the texture
amber saffron
#

Else, like I said, you could force the sampler state in shadergraph

tender edge
#

also set the sampler state and it keeps repeating

#

but because i couldnt get it to work i was looking into projecting in worldspace. but even after finding the correct values i'm not even sure what they scale off

#

alternatively, what if i would spread the uv's of the fluidmesh to stretch over the entire map?🤔

ornate barn
#

remy how do i get something like this

amber saffron
ornate barn
tender edge
amber saffron
ornate barn
#

soupost to look like that..

amber saffron
ornate barn
#

it will work on a cube perfictly but not on my model

amber saffron
# ornate barn

Wait, so you want lighting to spread our of the mace model ?

amber saffron
ornate barn
#

or how do i recrate this

ornate barn
amber saffron
tender edge
#

@amber saffron mapping the uvs over the entire mesh did the trick, ty

sullen mauve
#

would anyone know how to fix this? i am getting a couple of weird pixels in the seam. i am not seeing any seam in shader graph anywhere, only in the material. this is using poolar coordinates and is placed in a quad

#

as you can see it looks good in the graph

sullen mauve
#

thank you

gilded ridge
#

anyone knows how can i achieve a water-like uv distortion effect? like i already have a water texture and i wanna apply the disortion to it, i dont wanna create the water using noise and stuff

low lichen
radiant meteor
#

Does this meen that there's no way to access screen resolution from HDRP, or just not this way?

radiant meteor
#

why

open orbit
#

Ill help

radiant meteor
#

sus behavior

open orbit
#

Just screenshare

thick fog
#

Hi I want to ask, how can I have a subgraph have more than one output? I've tried just adding another input to the output node but when I look at the node it only shows one of the outputs.

thick fog
#

I have a function that generates a vector in which vertices at x and z position will have a color value of y, but I'm not so sure how I can make it like that. Is anyone willing to help me with this?

elder gale
#

hi together,
now that I'm working a bit with URP and Shader Graph, I've noticed that even with simple shaders, the display is laggy and doesn't really run smoothly.
Also in playmode it works just fine.
Unless I hold Pan clicked, then it runs as expected
Are there ways to improve the scene performance?

amber saffron
amber saffron
thick fog
#

yup that was the problem, turns out i was saving by ctrl s instead of clicking save asset lol

amber saffron
elder gale
neat hamlet
elder gale
mental bone
#

Anyone familiar with reading shader code and perf from a Xcode metal gpu capture? I’m seeing this branch take 3% of the whole fragment shader. However I’m building to ios I am not doing anything with foveates rendering or vr.

#

Like does the 3% pie chart mean that this branch was actually hit and executed ?

low lichen
vague pilot
radiant meteor
regal stag
hexed sorrel
#

is this a known issue with custom renderer features? I've noticed that when using multi-pass renderer features, when clearing a render texture I seem to get the same color I cleared to replacing my entire top bar. Only the scene tab has this issue, when clicking the approximate region of another tab it reappears only to be set back to black when returning to scene view.

hexed sorrel
mental bone
#

That entire top if with the keyword should not be true. There is no foveated rendering on iOS

#

What I am asking is if it is showing a pie chart did that actually happen or is it like a estimation ?

civic sierra
#

how can i get the same shading in all numbers? I imported the numbers from blender but just one has something black in it.

grand lodge
#

Hey I have a bit of an issue I was hoping someone would be able to help out with. I'm finding in shadergraph that using the Blend node and blending 2 textures together using the HARDLIGHT mode is giving me different results from if i do the same operation in Photoshop. anyone else had issues with this before? you can see in the pic the target texture(top right) which is slightly different to the result of using HARDLIGHT in shadergraph. the textures come out looking dirtier and desaturated compared to photoshop. any ideas? thanks.

civic sierra
amber saffron
grand lodge
# amber saffron iirc, the maths behind the blend node is a direct copy of photoshop. What might ...

Hey , thanks for the reply. We've tried all sorts of srgb linear conversions and toggling the srgb off on texture import and stuff like that be we still can't get a 1 to 1 comparison with photoshop. This is as close as we can get with the one on the left being the result we get and the one on the right is the one that is combined in photoshop. losing quite a bit of vibrancy in the colours and the edge highlights are lost somewhat. 😦

amber saffron
kind juniper
amber saffron
# grand lodge there you go

Didn't you do something more in photoshop ?
If I take those texture, and blend the greyscale to the colour one, using hard light, there is difference with the target 🤔

#

Oh, I got it, you inverted the base and blend in the unity setup. Or swith to overlay blending (which is the inverse of hard light) 🙂

#

Some colorspace conversion still needs to be done to get close to PS result though, and it is still a bit different :

grand lodge
amber saffron
grand lodge
amber saffron
civic sierra
halcyon plank
#

Well im slightly confused how do i get Triplanar to work with Tesselation???

mighty pivot
#

does muck use custom shaders? cause my chest (image2) looks really flat and bad

mighty pivot
#

what is the cause for the quality difference then?

#

cant figure it out

halcyon plank
#

The artist, simply not as much detail in that texture vs the other

#

and lighting has a big effect too, i can see your trying to make the thing gold, but your seeming to really only use albedo vs using albedo, normal, and smoothness maps

#

and if you want metals on your chest, then any metal should be 100% metallic and you change the smoothness for that metal

mighty pivot
halcyon plank
mighty pivot
#

I also use URP

#

but I cant get rid of this standard bad lighting unity look

halcyon plank
# mighty pivot I also use URP

The grass below is super bright green while his is a darker green, contrast between color and objects really make the difference

#

And your sunlight is too bright

mighty pivot
halcyon plank
#

Turn your sunlight down a bit, use materalize for your textures to get the normal and smoothness you want

#

and your colors are bright

#

use a darker blue, and when changing the mettalic and smoothness of the gold metal, will fix its color

mighty pivot
#

alright thank you a lot man, I will rework the stuff, appreciate it a lot!

halcyon plank
#

no problem

wispy elbow
#

Does anyone know how to mask a custom material from the mask component for UIs? I'm running URP Shader graph. I made a list of items, and they're not clipping the content's descendants.

halcyon plank
wispy elbow
#

What I mean by masking UI is this. The top item is clipped and is invisible once it's off the scroll view. The item at the bottom is my custom material made in URP shader graph. I'd like it to behave like the top item where it would clip off once it's off the scroll view.

regal stag
wispy elbow
#

Do I need to update?

#

It's up to date.

#

No wait. I read it wrong, I'm using Unity 2022.3.20f. I'll update! Thanks!

wispy elbow
#

I just updated, changed to canvas graph type, and it works well now. Thank you so much, Cyan!

radiant meteor
#

Why do the shadows do this? I feel like they're wrong.

#

Here is the vertex portion of my shader graph and the "quantize3" subgraph:

#

I've tried running that same string of nodes into normal and tangent (with appropriate things changed, like using normal vector and transform mode to normal), but it doesn't change much and it doesn't solve the shadow problem.

#

I've also tried changing the shadow depth/normal bias, but also cannot fix it that way.

#

To me it looks like the shadow is appearing in places that should not be in shadow. At first I thought this might be because multiple vertices are stacking on top of each other/multiple edges on top of each other as a result of the snapping, but looking at wireframe mode that doesn't happen unless I push values really low.

rich tiger
#

Hey all, I am trying to understand how the LODGroup component does it's thing, in terms of what shader values it manipulates to perform LOD Crossfade animations, so that I can manually perform LOD transitions.

I know for LOD crossfading there is the LOD_FADE_CROSSFADE keyword, and the built in unity variable unity_LODFade. For some shaders, enabling this keyword and then setting the unity_LODFade property (which is a Vector4) works. However for other shaders it does not, even though those shaders do work with the built in LODGroup component.

I have tried to do some debugging via the following:

  1. Placing the inspector in debug mode so that I can see the enabled keywords on the material. LOD_FADE_CROSSFADE is never enabled when using the LODGroup component.

  2. Using MaterialPropertyBlock.HasVector("unity_LODFade") - This always returns false, even though I can see the crossfade transitions working properly at runtime!

  3. Checking Shader.IsKeywordEnabled("LOD_FADE_CROSSFADE"), which always returns false.

So, I am bit confused how the LODGroup component can be working when it doesn't seem to be enabling the LOD_FADE_CROSSFADE keyword or using unity_LODFade. Does anyone have any insights?

#

The really strange thing is that for one of the shaders I am using, I can inspect the shader code and see that it is using both LOD_FADE_CROSSFADE and unity_LODFade. Yet still somehow my debugging fails (LOD_FADE_CROSSFADE is always disabled and the MaterialPropertyBlock returns false for HasVector("unity_LODFade"). Again, this is despite the shader in question working properly with LODGroup's.

#

The shader in question uses the shader graph, plus some custom functions (which is where the LOD_FADE_CROSSFADE and unity_LODFade use is).

vague pilot
#

Hey im currently trying to create a water shader. For the refraction im using a simple noise, that "swaps" the scene color this works almost perfect but theres one problem which is that this refraction also happens if an object is infron of the water plane which results in a weird look

radiant meteor
prime coyote
#

hiya everyone, was looking for some feedback on a hologram shader i made!

#

it has a slight glitchy effect as well that adjusts position maps and the scanlines scroll down

#

as well as some grain

amber saffron
# halcyon plank Well im slightly confused how do i get Triplanar to work with Tesselation???

The provided triplanar node can only work in the fragment output, as it uses regular texture samples that require derivatives to calculate the mip level.
You can either build your own triplanr logic using SampleLOD nodes, or you can find some pre made ones in my library : https://github.com/RemyUnity/sg-node-library/blob/master/Documentation~/images/nodes/triplanar/samples.png

GitHub

Node library for ShaderGraph. Contribute to RemyUnity/sg-node-library development by creating an account on GitHub.

amber saffron
# radiant meteor Why do the shadows do this? I feel like they're wrong.

You are quatizing the view space position. So, when the enging does the shadow map pass, it is also quatized, but based on the light "view", yielding in different results.
You can try to add a small c# script that saves a global shader variables with the world to camera matrix, and the inverse, and use them for the transformation.

amber saffron
halcyon plank
sacred yew
#

Simple quick question for URP
Does anybody know why this is only outputting blue? I would expect it to output the screen UVs into the red and green channels too, I'm very new to working with HLSL though so i must be missing something obvious or just fundamentally mistunderstanding

Shader "Hidden/TestSimpleShader"
{
    HLSLINCLUDE
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
        #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
    
        float4 Test (Varyings input) : SV_Target
        {
            return float4(input.texcoord.x, input.texcoord.y, 1, 0);
        }
    
    ENDHLSL
    
    SubShader
    {
        Tags { "RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline"}
        LOD 100
        Cull Off ZWrite Off ZTest Always
        Pass
        {
            Name "DrawWhite"

            HLSLPROGRAM
            
            #pragma vertex Vert
            #pragma fragment Test
            
            ENDHLSL
        }
    }
}```
sacred yew
#

here's the janky render feature code too in case it's the culprit here

public class TestSimpleShaderRenderFeature : ScriptableRendererFeature
{
    public Shader shader;
    private Material m_passMaterial;
    private TestSimpleShaderPass _pass;
    public override void Create()
    {
        m_passMaterial = CoreUtils.CreateEngineMaterial(shader);
        _pass = new(name);
    }
    protected override void Dispose(bool disposing)
    {
        CoreUtils.Destroy(m_passMaterial);
    }
    public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (renderingData.cameraData.cameraType == CameraType.Preview
            || renderingData.cameraData.cameraType == CameraType.Reflection
            || UniversalRenderer.IsOffscreenDepthTexture(ref renderingData.cameraData))
            return;

        if (shader == null) return;

        _pass.renderPassEvent = RenderPassEvent.AfterRenderingOpaques;
        _pass.SetupMembers(m_passMaterial);
        _pass.requiresIntermediateTexture = false;

        renderer.EnqueuePass(_pass);
    }
    internal class TestSimpleShaderPass : ScriptableRenderPass
    {
        private Material m_Material;
        public TestSimpleShaderPass(string passName)
        {
            profilingSampler = new ProfilingSampler(passName);
        }
        public void SetupMembers(Material material)
        {
            m_Material = material;
        }
        public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
        {
            UniversalCameraData cameraData = frameData.Get<UniversalCameraData>();

            UniversalResourceData resourcesData = frameData.Get<UniversalResourceData>();

            using (var builder = renderGraph.AddRasterRenderPass<PassData>("Test Shader Pass", out var passData, profilingSampler))
            {
                passData.material = m_Material;

                builder.SetRenderAttachment(resourcesData.activeColorTexture, 0, AccessFlags.Write);
                builder.SetRenderAttachmentDepth(resourcesData.activeDepthTexture, AccessFlags.Write);

                builder.SetRenderFunc((PassData data, RasterGraphContext rgContext) => rgContext.cmd.DrawProcedural(Matrix4x4.identity, data.material, 0, MeshTopology.Triangles, 3, 1));
            }
        }
        private class PassData
        {
            internal Material material;
            internal UniversalCameraData cameraData;
        }
    }
}```
shell wadi
tacit parcel
pseudo wagon
#

If there a list somewhere of the color heatmap they added to Unity 6 ?

#

ie a list of each node => their color / cost

sacred yew
sacred yew
#

i can try what you suggested though, just a moment

#

yeah it doesnt even render

shell wadi
sacred yew
#

oh yeah oops

#

no change

#

im not convinced this is an effective way of debugging this im going to be honest

#

because when I attatch the render feature

#

the game outputs blue

#

so its definitely doing something

#

its just that the UVs arent working for some reason

broken thorn
#

heya, im abit confused as wether to use SV_IsFrontFace or VFace to determine if a face is front facing? from what i understand it depends on the shader model, but how do i know what it is?

#

because neither seem to be working for me

#

this is my varyings struct:

                float4 positionCS     : SV_POSITION;
                float2 uv            : TEXCOORD0;
                float progress        : TEXCOORD1;
                bool is_front        : SV_IsFrontFace;
                //or:
                float is_front         : VFace;
                
            };```
cerulean frost
#

hey, i have been trying to blend two textures for 2 days straight and it just isnt working... i got it working for 2 textures, but as soon as i introduce multiple textures, everything just goes out the window and i dont know what to do.... can anyone help?

#

first screenshot: i am getting the y-position of my mesh and also the "steepness", then the following 4 images are basically just modules for each texture i want to use, they are all the same apart from what texture2d lod they use. it is working lovely, just as intended, but the only issue i am having is that the borders between textures is so rough. i want the textures to transition into eachother (apart from water), and not have such clear-cut borders...

woeful trail
#

hello,

how do get this

#

Anyone know how to fix this ?

URP-HighFidelity-Renderer is missing RendererFeatures
This could be due to missing scripts or compile error.
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:203)

quaint grotto
#

does unity provide a stochastic texture shader in any of the pipelines? i dont know how to write my own

#

im 71% sure i saw unity talk about it at one point moons ago

steep valve
#

hi,i'm making a block shader to make some like terraria light and ilumintation, but when i try to make the system this happens,

#

and depeding on my position in the spector the lights and blocks are reacting

#

i dont know why

#

and my pixel perfect camera dont show me this objects

radiant meteor
#

Can anyone help me refresh on what the depth texture is?

When reading from the scene depth in the linear01 mode, 0 is camera near clip plane and 1 is camera far clip plane right?

quaint grotto
#

yes

radiant meteor
#

cool

median gull
# sacred yew Simple quick question for URP Does anybody know why this is only outputting blue...

Can you try this shader: ```Shader "Unlit/DebugGl"
{
SubShader
{
Pass
{
ZTest Off
Cull Off
Blend One Zero

        HLSLPROGRAM
        #pragma vertex fullUv
        #pragma fragment frag

        #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"

        struct fuUv
        {
            float4 vertex : SV_POSITION;
            float2 uv : TEXCOORD0;
        };
        
        void fullUv(const uint vertexID : SV_VertexID, out fuUv o)
        {
            o.vertex = GetFullScreenTriangleVertexPosition(vertexID, 0);
            o.uv = GetFullScreenTriangleTexCoord(vertexID);
        }

        float4 frag(const fuUv i) : SV_Target
        {
            return float4(i.uv, 0, 1);
        }
        ENDHLSL
    }
}

}```

sacred yew
#

oh crazy timing, i just made a post on unity forums

#

ill do that right now

#

woah! its working

#

what was wrong about what I had written that meant it wasnt working but this is

#

this is the post i made by the way, i've just updated it so no one else dedicates time to trying to solve an issue that just got resolved

#

it must've had something to do with the Blit.hlsl that the example shader code in the documentation uses

#

because if I copy the logic from that file into my own shader code

#

and take this out because I 1. cant find what hlsl file it orginates from and 2. dont know what it does

#

my original code starts working too

#

alright i guess ill update my post

median gull
#

Huh, yeah. Dynamic scaling is something I haven't touched personally. I get why it exists but the bugs it causes are annoying.

#

I personally don't recommend using the blit library. Code the shaders yourself. Use only methods provided by unity that are less than 5 lines long.

radiant meteor
#

How do I use a material for blitting? What keyword does it need to have? Because I have _MainTex and it doesn't seem to be working.

median gull
radiant meteor
median gull
#

If you're using command buffer, it should just be cmd.Blit(sourceTex, destinationTex)

radiant meteor
#

I'm using Blitter.BlitCameraTexture with the command buffer passed in:

#
Blitter.BlitCameraTexture(cmd, _src, _quantized, _mat, 0);
Blitter.BlitCameraTexture(cmd, _quantized, _src);
#

and one of the parameters is a material, so I'm wondering how that works?

median gull
#

Thats if you want to use a custom shader pass during the rendering. Without a material, then it's a default copy, paste.

radiant meteor
#

yes I do want to do that

#

I have a fullscreen shader, I think that's the right type of shader to use?

median gull
radiant meteor
#

hmm still nothing, problem must be elsewhere

#

well now I have it making a black screen so at least something is happening lol

burnt frigate
#

does anyone know how to fix the line renderer from becoming distorted in corners?

#

been trying to fix it for a while and its annoying 😭

#

i need to it stay the consistent square shape across the whole line. Works fine straight but becomes all crap in a 90 degree turn

radiant meteor
median gull
radiant meteor
#

twice like I do before?

median gull
# radiant meteor twice like I do before?

This is the bare minimum to blit a texture. To dispatch a manual blit:

cmd.SetGlobalTexture(ShaderID.SrcTex, sourceTex);
cmd.DrawProcedural(Matrix4x4.identity, shaderMaterial, 0, 0, 3);```
#

And the vertex is just this:

viscid knoll
waxen merlin
#

Do we have access to wave intrinsics for compute shaders in Unity, like WaveAnyTrue, WaveAllTrue etc... or equivalent?