#archived-shaders

1 messages Β· Page 39 of 1

regal stag
#

You need to connect the A output from the texture sample to the Alpha port in the Fragment stack
The spaces in the Transform node also seem reversed. Should be World->Object.

silk wharf
#

I am pretty sure your sprites are transparent, so make sure to connect the alpha node from your texture to the alpha of the fragment

zenith heron
#

Hello, I'm repeating the function by loop (120fps) below to make a rendertexture slowly fade (multi is between 0 and 1). When the slightly transparent rendertexture A is processed through material _Post with shader PostPen and then blitted onto B, it seems that B has some sort of black background or something, hard to explain. The video shows some colored strips, but they gain brightness=0 properties where alpha is considerably higher than 0.

#

as the Fade() function's "multi" decreases from 1, the blackness which can be seen in the strips approaches 0

#

probably since the strip's alpha reaches 0 in like a few repeats when multi=0.9

#

the video demonstrates multi=0.99

silk wharf
#

Hello there, not sure If I have to post this here, I want to enable the SRP batcher / GPU instancing for my project as I have many objects with the exact same mesh and material but it is just not working, I even followed the steps provided by unity for using it but no result. I'm using HDRP and I realized that enabling GPU instancing flag on the shader does not work because of the SRP batcher. does anybody know how to fix this

lunar valley
simple violet
#

He probably checked with frame debugger

lunar valley
#

"probably"

regal stag
# silk wharf Hello there, not sure If I have to post this here, I want to enable the SRP batc...

There's some info here about intentionally breaking the SRP-batcher compatibility for certain objects without needing to disable it entirely. https://docs.unity3d.com/Manual/SRPBatcher.html#intentionally-removing-compatibility
In short, use MaterialPropertyBlocks on renderer, or in shader declare a property not inside the PerMaterialBuffer. For graphs, I think you can do this with the "Override Property Declaration" setting on an property (e.g. set an exposed property to "global")

sharp tulip
#

Hello

#

How to make som silhouette outline shader?

digital gust
sharp tulip
#

Like COD Modern Warfare. Nothing complex, just a standard white line around the object.

digital gust
#

I dont know the games visuals. but did you google for outline tutorials on shadergraph? There are a trillion about it. Just pick the most recent

sharp tulip
#

Most of them is outlining all edges. I alredy managed to do this kind of shader.
I want something like the Unity Editor has. It outlines gameObject in oragnge if you click on it.

digital gust
regal stag
sharp tulip
#

Thank you, its a good resource. I'll try out some solutions and come back with more exact questions if I have.

rare wren
#

Does anyone know how to only call #pragma multi_compile _MAIN_LIGHT_SHADOWS_CASCADE when shadow cascades is enabled (>1) in the URP asset?
Currently my shader (graph) breaks when shadow cascades is at 1, while this pragma is there

regal stag
# rare wren Does anyone know how to only call `#pragma multi_compile _MAIN_LIGHT_SHADOWS_CAS...

It would already be doing that. The multi_compile pragma complies the shader into two versions/variants, with and without that keyword (and code it relies on).

Actually in v11+ the correct way to handle the shadow keywords is actually as an enum, like #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN, to avoid creating unnecessary variants.

If by "breaks" you're referring to an invalid "shadowCoord" error, then you can fix it by using #undef REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR in a custom function.

rare wren
random pond
#

Hi, I am really close to my desired effect with shaders, the glow part of my sword can be seen as transparent over the UI in low lighting, anybody know how to fix this?

#

as you can see, middle image is middle lighting level and the effect becomes a problem

#

this issue also occurs with floor tiles, but it is less noticeable as floor tiles are lighting dependent, whereas the UI is permanently 'lit'

#

With a little more thought: I think I'm looking to clear all alpha values underneath my glow material

#

problem solved

#

Anyone got any idea why this is? lol

tacit stream
#

So... Standard URP shader has Tiling settings.
Any idea what is name of that property? To set/get from material in runtime?

regal stag
tacit stream
#

I am doing entity material override, so no material helpers for me here

#

any idea which part of float4 though? πŸ˜…

regal stag
tacit stream
#

I see, thanks

tacit stream
#

I need direct reference of shader property

#

same as _BumpScale for example

regal stag
tacit stream
#

since there is no Material exposed

amber saffron
tacit stream
#

looking into MaterialOverrideAsset atm

#

but doesn't seem like it has it either

#

annoying

#

but I guess I can solve it with my own shader

#

Any tip how to implement tiling? πŸ˜…

#

turned out to be a node actually

silk wharf
zenith heron
#

Hello, I have an issue regarding Graphics.Blit, where if I blit a RenderTexture A onto a RenderTexture B through a material called Post, and the post-processing shader in Post makes A have some transparency, then B turns out different; instead of B having transparency as well, it inherits some black color. It seems like Graphics.Blit is putting A onto some black image and making that be B. I was wondering if I could avoid this in any way. Thank you very much for your time.

regal stag
zenith heron
zenith heron
#

basically this is what happens, and the latter demonstrates the use of Graphics.Blit
the shader itself is pretty simple, just changes the alpha of the source texture. There might be a simple workaround that I'm not considering

vivid fable
#

I need to recreate this shader in URP. I've got the Shader Graph Shader Editor window open, but can't find the equivalent properties from the left. Where are they!

woeful breach
#

how can i get the color wich an object is standing on ?

amber saffron
amber saffron
vivid fable
amber saffron
woeful breach
vivid fable
#

Stencil buffer. Need to recreate this shader in URP

amber saffron
dapper pollen
#

so i feel dumb but i cant connect some of my graph to the vertex(position) node in shadergraph. are there limitations here or is this a bug?

amber saffron
amber saffron
amber saffron
# woeful breach how can i get the color wich an object is standing on ?

Reformulating the need : what do you need ? A single color for the whole object ? What if the thing which your object is standing on has a texture ? Which color should you pick ? What about the lighting ? : If the object is on something, it blocks the light, so under it everything is dark

woeful breach
woeful breach
amber saffron
#

Oh, so you need to get the terrain color, for grass blending with the ground I guess

#

Tricky, but I think you can use a script to get the terrain basemap and use this as a rough terrain color

stiff furnace
#

hello i did atmosphere shader URP and it is not showing both side. i checked render face both, but not working. can you help me?

random stone
#

A shader I am using for trees to try and make them "wave" still has issues. 1. there seems to be a pause, they wave a little, return to the original "position" i guess, and then rest for a moment before moving again? and i dont know why. 2. there are artifacts of little white dots whenever it waves. The shader is being applied to Tilemaps, I will send a picture of the shader along with a video of what its currently doing

woven plover
#

Hey, i might be mistaken, but i think there was some kind of preview window for materials (shown as on a sphere), but no such preview pops up anymore.
Im on URP and unity 2021.3

#

is there a way to get a material preview?

lunar valley
fleet anvil
#

I downloaded a water asset but i dont know how to apply it can anyone help

regal stag
regal stag
fleet anvil
regal stag
#

Be aware that other shaders intended for the Built-in pipeline might not work if you switch to URP

charred hare
#

hey im wondering what block "divide" give as result from two arrays and how it works?

regal stag
fleet anvil
woven plover
regal stag
regal stag
# fleet anvil

The shader assigned to that material is still the Standard one. You can change the shader on that dropdown.
Though it'll likely appear as magenta error material, as the water one you downloaded is intended for URP not the Built-in pipeline.

fleet anvil
hollow wolf
#

I hear they make creating post processing easier for shader graph but only for unit 2023,any plan to make this doable for older unity version?

slender birch
#

I have a shader, where I multiply the cross of the object position, with another vector, to then use it as an axis for rotation (plant wind)

#

but it has a problem

#

when the position is the origin, 0, 0, 0

#

the cross product is 0

#

what can I do in that case?

#

I dont know how to solve this without using an "if"

fleet anvil
#

why is it pink

grizzled bolt
# fleet anvil

If URP shader appears magenta but standard shader doesn't, as in the previous picture, that suggests you didn't configure URP as per the instructions

grizzled bolt
fleet anvil
random stone
# random stone

for the shadergraph, i changed it from Sine Time to normal Time, but it didnt seem to change anything

fleet anvil
#

now this one is pink?

grizzled bolt
grizzled bolt
#

Instead of Standard shader you'd use URP's Lit shader

slender birch
#

how do shape keys/blend shapes work? like, how is the info passed from the cpu to the gpu
because it seems to be able to, have different materials, so its not a material property, and it isnt per vertex, so its not a vertex attribute
or skinned meshes
same deal, info being passed per mesh

#

I need a way to pass info per mesh, and I would rather not have to create a new material for each mesh

slender birch
#

also, the moment I set a property in a material, the updates to the sharedMaterial stop affecting the material, even if it isnt the property I updated

last vault
#

Any idea what's happening with my Shadergraph normals?
(Above: the ShaderGraph; Below: The shader applied to a sphere)

regal stag
last vault
#

Yep, looks like that was it: The Neutral tonemap looks bad on negative numbers.

random stone
#

shadergraph make me commit war crime mmmm, fun i am not having, commit a war crime, i will

random stone
grand jolt
#

I'm getting the following harmless error message quite frequently

Metal: Error creating pipeline state (Hidden/Universal Render Pipeline/CopyDepth): depthAttachmentPixelFormat is not valid and shader writes to depth
(null)

anyone know how to get rid of this? I'm using URP 14

lavish tinsel
#

Hi guys, I found a shader for a Holosight that involves stencil buffers but the shader was not for HDRP, can someone be kind enough to help me convert both shaders 😦

feral mist
#

In urp, how can I compile a shader for fog_exp2 only?

grand jolt
#

Hello I am having problems with my terrain shader graph.
When I make a float in shadergraph, It automatically makes the float work on the X axis. I want to make a float that is on the Y axis

#

how do i do that

civic lantern
#

Make a Vector node and connect the float to the y component

grand jolt
#

oh okay

#

let me try, Thank you though

civic lantern
#

If you need XYZ then yes

grand jolt
#

ah okay

#

thank you

grand jolt
#

it did not work

#

do you want the shader to check it?

#

please help

#

i am a newbie sorry

civic lantern
#

What didnt work

#

Maybe look at some tutorials

grand jolt
civic lantern
#

Because the B vector is zero I suppose

#

AKA Sand height is 0

grand jolt
#

this is a terrain shader for procedural map generation, and when you apply the shader the terrain looks like this:

#

i want it to apply on y axis, instead it is applying on the x axis

grand jolt
#

0.3

civic lantern
grand jolt
#

water is 0
sand is 0.3
grass is 0.6
rocks is 0.8
and snow is 1

#

@civic lantern

lavish tinsel
#

Hey guys Im having and issue with a StencilMask shader for my Holosight
Basically I want the crosshair to be visible only while looking through the glass of the holo
But for some reason I cant figure out how to make it render behind the skybox while not seen through the glass

Here is a video showcasing my problem:

https://streamable.com/ykworj

mint berry
#

does the shader graph not support tessellation in version 2020

mint berry
#

well no

fleet anvil
#

what is the best way to make water. I cant find any tutorial that goes in to details and how to set everything up

civic lantern
#

Normal maps, scrolling textures

#

Theres some keywords for you

swift loom
#

Semi-vague question but I've made a relatively large function in a compute shader and call it in 3-4 places in the shader. This has however made the shader take like 30 seconds to bake every time I edit it. Any idea what might be causing this? Is it because I have a lot of return points in the method, or maybe just because it contains a for loop?

fleet anvil
#

how do i make the noise move?

amber saffron
fleet anvil
distant dirge
#

a time node probably

#

and a tiling and offset node

#

i forgor about that

fleet anvil
#

its just blinking

distant dirge
#

well not directly a time node

#

pull in tiling and offset

regal stag
#

I'd use Time node into a Vector2 node (to select which axis it should scroll on), into offset of Tiling And Offset.
There should also be tutorials that you can find that include stuff like this.

fleet anvil
distant dirge
regal stag
#

Yeah that would work too

fleet anvil
distant dirge
#

ok now my question, is it possible to write my own post processing effects using shader graph without using a blit render feature in URP? or am i pretty much doomed if i want to have a brighter camera

distant dirge
#

but maybe someone here knows

distant dirge
regal stag
regal stag
distant dirge
regal stag
#

You could adjust the exposure amount from a C# script at runtime, depending if it's day/night

fleet anvil
#

I have been trying to find a tutorial but everyone just shows the final result and dosent go in to detail about anything

civic lantern
distant dirge
regal stag
#

Can't you use a spot light?

distant dirge
#

so if i want the minimap to look bright, i have to also make the flashlight look EXTREMELY bright and overexposed

#

but then that ruins night time

#

i have not figured out how to render a light on only one camera at least

fleet anvil
distant dirge
distant dirge
civic lantern
#

From height is kinda pixelated IIRC but you can try it

#

Best to use an actual normal map

fleet anvil
civic lantern
#

Download one or create it in photoshop or gimp or some browser tool for example

#

Try the Normal from height/texture nodes first πŸ€”

#

With a basic noise texture like the one in your screenshot

civic lantern
distant dirge
#

but not the other

civic lantern
#

In HDRP you can render a light on certain cameras only, I think its similiar on URP

distant dirge
#

HOW tho, everything ive found says you cant

#

maybe i just havent looked enough? ive been trying to solve this problem for a while

fleet anvil
#

like this

woven plover
#

theres a unity tutorial on youtube for that

distant dirge
#

you pass simple noise directly into that blue node

#

and you also pass it into the normalf from height

woven plover
distant dirge
#

then you pass normal from height into the normal output of your shader

distant dirge
#

already tried it

woven plover
#

does for me on URP

distant dirge
#

what am i doing wrong then what

woven plover
#

ah right, the light has a culling mask too

#

not sure which one does what, i just set them both to the layer they should render/illuminate

fleet anvil
distant dirge
#

the one you tried attaching your normal to

#

disconnect normal

#

connect the same way you had before

#

and then connect normal to your normal map output on the right hand side of your shader

civic lantern
#

But its really hard to test because light layers dont get updated when I change the values, its pretty buggy for me

#

Couldve sworn that was a feature πŸ€”

#

You could probably work around it by changing the terrain's layer just before the camera renders

fleet anvil
distant dirge
distant dirge
fleet anvil
distant dirge
#

Normals dont need colors

#

Thats not how they work

civic lantern
#

Or ask. Its just to fake some surface detail without adding extra geometry

fleet anvil
distant dirge
#

Yeah

#

The normal map should be connected to the "normal" output of your shader

#

NOT base color

tame swan
#

Apologies for my naivety but why is this happening?

distant dirge
#

Whats wrong

tame swan
#

I'm expecting the triangle to be added to the hollow circle

#

My understanding is extremely limited

fleet anvil
#

how do i apply a shader to a object

distant dirge
#

Is there some negative values @tame swan

tame swan
#

actually, i indend to subtract the triangle fromt he hollow circle

distant dirge
tame swan
amber saffron
#

@tame swan You can easilly fix out of 0-1 range value with saturate node

#

(before the add/mult)

amber saffron
tame swan
#

perfect

#

Is this what you meant?

distant dirge
#

Nice

amber saffron
#

Now, like I said, you have negative values in the result

distant dirge
#

Ah thats why you use min max

amber saffron
#

But if you used the minimum node with the circle and the balck triangle, it would do the same shape at the end, while staying in the 0-1 range

distant dirge
#

Ahhhh makes sense

#

Im not even the asker but i love learning lol

amber saffron
#

It's the basic operation for signed distance shapes combination : min for intersection, max for union

#

combine with negate or one minus (depends if you workd with real sdf, or black/white shapes), you can do :
min( 1-A, B) -> subtract shape A from B

distant dirge
#

Oo fun question i have
How do I map a texture onto a white spot in a shader graph

tame swan
distant dirge
#

I have a sun/moon shader, and i would like to map a texture onto my moon, so i need to know how

amber saffron
distant dirge
#

Yeah

tame swan
#

Ahhh I see

distant dirge
#

Hmmm not sure what you mean

#

Ik what lerp is

amber saffron
#

Lerp
A = base
B = new value
T = mask

Output is A if T = 0, B if T=1, and a mix between A & B in between

#

So, take whatever your base is for A, the texture for B, and the white moon mask for T

distant dirge
#

Wouldnt i have to scale it with UV?

#

And rotate?

#

The texture i mean

amber saffron
#

That's up to you on how you want to map the texture

distant dirge
#

The moon moves through the sky so if the moon moves the texture would change since its just a mask

amber saffron
#

Yep

distant dirge
#

Ill try and figure it out i guess

amber saffron
#

At some point, why not do this with objects instead of trying to do everything in a single shader ?

distant dirge
#

Not sure what you mean

fleet anvil
distant dirge
#

Um no clue

#

Is new shader graph the water graph

fleet anvil
amber saffron
amber saffron
fleet anvil
woven plover
amber saffron
woven plover
distant dirge
#

But how do i make my moon/sun fade behind clouds? Do i need physically based clouds? Is there a good guide for this

woven plover
#

if its on a skybox, everything is rendered in front of it

#

or make the cloud shader render after the sun shader so it overlays

tropic verge
#

unity keeps putting these weird spots on my build once I generate the lightmap and bake the lights, anyone has a idea how this could be? I'm really lost at this point.

nimble otter
tropic verge
#

something tells me that the "red" isn't exactly good lmao

#

so, uhh, to fix that πŸ˜…
is that a issue with the 3D model of the "building" itself or a lighting issue

nimble otter
tropic verge
#

Yeah my dad needs to look into this πŸ’€
(he makes the 3D model, I do the lighting.)

#

What the hell

#

all I did was add three light sources

#

good news! I fixed it!
bad news! I have no clue how πŸ’€

nimble otter
#

Still kinda sus

tropic verge
#

It seems to be that way yea haha

#

Thank you, for your help. I appreciate the quick response !

fleet anvil
#

how do i make it more transparent

distant dirge
distant dirge
wraith wing
#

does time counted for how long the scene "played" (eg: the trigger was activated in 50 second of game, unity count from there (50, 51, and so on))
or when it triggered? (eg: I trigger the animation at 50 second unity count 1 from there (so in 51 second it's 1 second, 52 it's 2, and so on)

wraith wing
#

let's say it's 50 second when triggered

amber saffron
#

I was no asking, but answering πŸ™‚

wraith wing
#

ah yeah my bad

amber saffron
#

The time value is the time in seconds elapsed since the scene started (It might even be since you've entered play mode)

wraith wing
#

is there's any way to reset it to 0?

amber saffron
#

Not that I know of.
But from script you can get Time.time that is the same value, pass it to you material through a property, and do a subtract to "offset" it.

Or you could just use a custom time variable updated from script

wraith wing
#

so basically the time node in shader mostly used for something continuously repeating rather than in given time frame right?

amber saffron
#

Yep

fleet anvil
#

https://youtu.be/1yevpCAA_rU on 7:35 how do I get those purple ball texture

Bring your game to life with this stunning crystal clear stylized water Shader Graph.
Download project files (Patrons only): https://www.patreon.com/BinaryLunar

This tutorial will cover creating the following features for your water Shader Graph:
1- Depth fade with deep and shallow colors.
2- Refraction
3- Foam
4- Waves
5- Smoothness
In additio...

β–Ά Play video
amber saffron
#

But previewed in 3D and not 2D

fleet anvil
#

How do I do that

amber saffron
#

Grab a normal map texture representing waves, add a Texture property in the blackboard, drag the property in the graph, and connect it to a sample node

#

If you are asking questions like that while trying to follow a water tutorial, I recommend that you start with a more beginner friendly tutorial , probably searching for "introduction to shadergraph"

fleet anvil
fleet anvil
amber saffron
#

Obviously, changing the texture will change the look of your material

slim ginkgo
#

For scrolling/offset-time noise shaders... Whats a good way to avoid seams like these?

lunar valley
slim ginkgo
lunar valley
random stone
timid minnow
#

What is a non-naΓ―ve way of handling character blinking, ala Smash Bros, or any game where player takes hits, or has invincibility frames?

#

Is this best handled at the shader level with a property?

#

dang, this is weird, I need it to behave more like an unlit shader during the blinking

civic lantern
#

But if you use a single shader, maybe slight emission could help in making it look "unlit"?

timid minnow
civic lantern
#

I wouldnt say its terrible. Having a single more complex shader would have its own performance costs too, though probably neglible.

#

I wouldnt worry about it

timid minnow
#

πŸ‘ Thanks, I'll go that route

grizzled bolt
random stone
timid minnow
grizzled bolt
timid minnow
#

(but I can't be entirely sure... so hard to analyze crappy compressed YouTube frames, haha)

grizzled bolt
# timid minnow Your recommendation in this case might be separate materials representing the di...

I think the way to do it is to use a script to loop through all mesh renderers and their materials, store those in an array in order, replace them with the bright material when flicker on, and when flicker off loop again and replace them with the previous materials from the array
Or use a shader that can lerp the base color and/or emission color to white based on a property controlled via scripts
Both of them seem valid approaches

timid minnow
#

I'm in a somewhat performance critical situation since I'll be trying to support 4 player splitscreen (cameras), so little performance optimizations along the way could help because a mistake could be 4 times as expensive as a single player game

#

(in HDRP... good luck to me...)

grizzled bolt
#

HDRP is kind of the worst fit for that due to the overhead cost of the cameras, as I'm sure you've noticed
There's the Frame Settings which could be helpful to cut down noncritical rendering features

timid minnow
#

Yup, many many features have been significantly degraded/axed

#

Still, I get decent performance. ~60-70 FPS currently 4 player splitscreen 5120x1440 on a 2070 Super

#

can't ask for much better from HDRP at this time...

random stone
#

A URP shader I am using for trees to try and make them "wave" still has issues. 1. there seems to be a pause, they wave a little, return to the original "position" i guess, and then rest for a moment before moving again? and i dont know why. 2. there are artifacts of little white dots whenever it waves. The shader is being applied to Tilemaps, I will send a picture of the shadergraph. along with a video of what its currently doing.

random stone
#

Ok so the "white dots" from the second problem is because the shader is being applied to each tile individually (I think), and when one tile moves beyond its 1x1 limit it wraps around to the other side (I think) (major thinkage) (still don't know how to fix that).

random stone
#

I cranked up the values of the material to make the issues more clear and visible (white dots inbetween tiles) (waving seems to stop when the values for WindSpeed get high enough i think)

grand jolt
#

How do I make it so that the snow (white stuff) is on the top of the mountain, Followed by rocks, grass, sand and water respectivly

#

I think it is because of the water height, sand height etc floats, but these floats are values for x axis, i dont know how to make the floats that represent values for Y axis

fleet anvil
amber saffron
fleet anvil
fleet anvil
amber saffron
#

Nothing on top of my head

fleet anvil
amber saffron
fleet anvil
amber saffron
#

What part ?

fleet anvil
amber saffron
#

Well ... you won't have normal maps, and the surface won't profit from detailed lighting

civic lantern
#

If you dont have photoshop or anything

fleet anvil
civic lantern
#

Probably PNG

#

Or TIFF, I rarely use that format but it should be decent quality

fleet anvil
# civic lantern Or TIFF, I rarely use that format but it should be decent quality

it dosent look the same as in the video https://www.youtube.com/watch?v=1yevpCAA_rU&t=455s

Bring your game to life with this stunning crystal clear stylized water Shader Graph.
Download project files (Patrons only): https://www.patreon.com/BinaryLunar

This tutorial will cover creating the following features for your water Shader Graph:
1- Depth fade with deep and shallow colors.
2- Refraction
3- Foam
4- Waves
5- Smoothness
In additio...

β–Ά Play video
#

7:35

amber saffron
#

Note that you need to import the texture as "normal map" and not "default texture" in the texture import settings

spring owl
#

Hi! I finally managed to get that shader for the water, but I have a little problem... As you can see, in the scene view, the water looks perfect with that foam on it, but once I switch to the game view, the foam isn't on the water at all (the one at the edges)... Any idea what's going on here?

amber saffron
regal stag
# spring owl

Looks like the depth effects aren't working. Is the Depth Texture enabled? If it's URP, would be on the URP Asset.

spring owl
regal stag
stiff furnace
#

how to make planet atmosphere?

grand jolt
#

im a newbie sorry ;;-;

regal stag
grand jolt
#

oh okay

hollow wolf
fleet anvil
grand jolt
#

Hey, I'm trying to translate a parallelizable algorithm to HLSL as a compute shader. In the original code, I was using rather big constant lookup tables, which often were in the shape of nested arrays.

#

As far as I understand, cbuffers are good for constants. However, matrices and vectors don't support some of the sizes of the lookup tables, for example an array of 8 vector3 fields.

#

Is it stupid to just split up the matrices into smaller ones (for example matrixA holding the first 4 and matrixB holding the second 4 fields, and then in code conditionally selecting the matrix if the index is for matrixA or B)?

#

Or is it a legitimate thing to do?

distant dirge
civic lantern
distant dirge
#

there is an option under filter>generic for normal maps

civic lantern
#

Oh nice

distant dirge
#

well i was asking if it works well lol

#

dunno if anyone else knows

#

it seems fine to me but im not a normal map expert

civic lantern
#

It seems good enough for most purposes

#

@distant dirge Seems like you have to use Flip Y so it's in the correct format for Unity

distant dirge
#

ok good to know

#

its looks fine for me

#

maybe im dum lol

civic lantern
#

The difference is not too noticeable for some patterns

distant dirge
#

i mean my test is snow soooo

civic lantern
#

Yeah that might look good with Flip Y off too

distant dirge
#

damn looks much better with flip y

#

thank you

covert pecan
#

How can i get rid of shaders?

dim yoke
grizzled bolt
#

Disabling all scene cameras could do the trick UnityChanLOL

sleek granite
#

I'd prefer that over constant buffers.

tacit stream
#

Is there any reference how to make a shader compatible with SpriteRenderer?

#

property names and etc

#

for URP

#

in particular interested for Tiling and Offset

grand jolt
grand jolt
#

I passed an array of integers from Unity C# into an HLSL shader's StructuredBuffer, but all of a sudden that array's contents seem to be persisting between Play sessions. No matter how much I randomize that array of int, the running game proves that the same sequence of integers is still being passed into the shader

#

Basically, no matter how many times I restart Play, the same pattern of Beige and Orange (pulling in data from the array of integers) happen. I've confirmed that the RNG is working properly, but passing in new sequences of integers still doesn't change the StructuredBuffer

tight phoenix
#

What methods exist to supply random data to a single shader/material? Specifically not based on it's world position.
Example of what I mean: 100 of the same shader/material on objects, each object doing sine time different from a different 'moment' so they dont all pulse identically

#

the reason not based on world position is because the thing has to also move, and it will flicker wildly if it moves and its based on world pos

#

visual example of what I mean

#

is there a way to supply random data so that all of those can have random colors, but not based on world pos

sweet burrow
#

Is there a function to just ask for a specific pixel instead of having to convert into UV and use a texture sampler?
I want to store a whole bunch of non-color data in a fake texture, but extracting them back in a custom node is awkward.

dim yoke
tight phoenix
dim yoke
dim yoke
white cypress
dim yoke
#

If the objects use the same mesh and otherwise same material, sure

slim yew
#

is there a way to color a sprite in the UI based on the color behind it?

#

for things like a aiming reticle to make it negative or compliment the color of what ever is behind it

tender marsh
#

Hey! Anyone able to give me a hand? Trying to create a shader that limits colours to a palette and pixelises the texture but it seems to just make the material brown

       fixed4 frag (v2f i) : SV_Target
          {
                half dx = _PixelWidth * (1. / _ScreenWidth);
                half dy = _PixelHeight * (1. / _ScreenHeight);
                half2 coord = half2(dx*floor(i.uv.x / dx), dy * floor(i.uv.y / dy));

            float4 baseCol = tex2D(_MainTex, coord);
            float4 palCol = tex2D(_PalTex, 0);
            float palDiff = 1000;

            for (int p = 0; p < 37; p++) {
                float baseColDiff = abs(tex2D(_PalTex, p).r - baseCol.r) + abs(tex2D(_PalTex, p).g - baseCol.g) + abs(tex2D(_PalTex, p).b - baseCol.b);
                palDiff = min(palDiff, baseColDiff);
                palCol = (abs(palDiff - baseColDiff) < 0.001) ? tex2D(_PalTex, p) : palCol;
            }

              
                // sample the texture
                float4 col = tex2D(_MainTex, palCol);
                // apply fog
                UNITY_APPLY_FOG(i.fogCoord, col);
                return col;
        }
        ENDCG
    }
#

Ignore the colour 1,2,3,4 I gotta remove that lol

slim yew
#

try color distance instead of difference

tender marsh
#

So sorry I'm really new at this what exactly would I be swapping out? I thought difference here was all self-made variables

slim yew
#

gimme a second

tender marsh
#

Really appreciate it thank you!!

slim yew
#
fixed3 baseCol = tex2D (_MainTex, coord).rgb;

fixed4 col = fixed4 (0,0,0,0);
fixed dist = 10000000.0; // for prosperety

for (int i = 0; i < _ColorCount; i++) {
    fixed4 c = tex2D(_PalTex, 0);
    fixed d = distance(baseCol, c);

    if (d < dist) {
        dist = d;
        col = c;
    }
}
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
#

try this

tender marsh
#

Should I be declaring original somewhere?

slim yew
#

sorry got it confused, should be baseCol

tender marsh
#

Sweet!!

#

So sorry to keep bothering you!! Just wondering why this error is now popping up?

#

This is everything I've got


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

           fixed4 frag (v2f i) : SV_Target
          {
                half dx = _PixelWidth * (1. / _ScreenWidth);
                half dy = _PixelHeight * (1. / _ScreenHeight);
                half2 coord = half2(dx*floor(i.uv.x / dx), dy * floor(i.uv.y / dy));

                fixed3 baseCol = tex2D (_MainTex, coord).rgb;

                fixed4 col = fixed4 (0,0,0,0);
                fixed dist = 10000000.0; // for prosperety

                for (int i = 0; i < _ColorCount; i++) {
                    fixed4 c = tex2D(_PalTex, 0);
                    fixed d = distance(baseCol, c);

                    if (d < dist) {
                        dist = d;
                        col = c;
                    }
                  UNITY_APPLY_FOG(i.fogCoord, col);
                  return col;
}

        }
        ENDCG
slim yew
#

you're not returning correctly

tender marsh
#

Oops my bad

slim yew
#

return after finishing the for loop

tender marsh
#

Is it not already returning then?

slim yew
#
   v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                UNITY_TRANSFER_FOG(o,o.vertex);
                return o;
            }

           fixed4 frag (v2f i) : SV_Target
          {
                half dx = _PixelWidth * (1. / _ScreenWidth);
                half dy = _PixelHeight * (1. / _ScreenHeight);
                half2 coord = half2(dx*floor(i.uv.x / dx), dy * floor(i.uv.y / dy));

                fixed3 baseCol = tex2D (_MainTex, coord).rgb;

                fixed4 col = fixed4 (0,0,0,0);
                fixed dist = 10000000.0; // for prosperety

                for (int i = 0; i < _ColorCount; i++) {
                    fixed4 c = tex2D(_PalTex, 0);
                    fixed d = distance(baseCol, c);

                    if (d < dist) {
                        dist = d;
                        col = c;
                    }
                  }
UNITY_APPLY_FOG(i.fogCoord, col);
                  return col;


        }
        ENDCG```
tender marsh
#

Perfect!! Thank you so much!!

slim yew
#

does it work?

tender marsh
#

It's taking the colours from the palette now but seemingly only applies 1 colour no matter how high I set the colour count

slim yew
#

you're using _ColorCount right?

tender marsh
#

Sure am

#

I defined it as a float

slim yew
#

it should be an int

tender marsh
#

Ah I see my bad my bad

slim yew
#

that shouldn't matter tho

tender marsh
#

Same error even with int unfortunately

#

Setting it to 0 affects it though so it definitely is doing something

#

Now that i think of it it may be worth me reversing the order of operations so it remaps the colours THEN pixelises it

slim yew
#

idk kid

#

keep at it

tender marsh
#

Appreciate all your help anyway!

lament scarab
#

ey, hopefully quick shadow question this time, I have the following stencil shader but it seems to either catch or cast shadows as you can see in this screenshot. How could I avoid this? It shouldn't render at all unless it's in the card art "window" but itseems to happen with some effects and shadows where you can see a transparent thing in the shape of the sprite that should be hidden.

https://hastebin.com/share/iqiyeduceh.csharp

As you can see the shader code is rather simple too, thanks!

bold breach
tranquil cipher
#

Hello, any one did a cartoon-like metal stripe shaders before?
https://www.youtube.com/watch?v=6iDN7ynzals
Basically I use the tangent vector to use as UV for the stripe, at some angle it's very beautiful (see video), but for some angle it does not appear at all.
I think it is something with the fact that the tangent vector is 3d, while UV is 2d.
How do we got consistent showing of stripe?

I made Bor's new hammer and test in game.

⭐️Support my works
https://www.patreon.com/spikebor
https://www.ko-fi.com/spikebor

♦♦♦♦♦ My links ♦♦♦♦♦
Website https://www.spikebor.com
⭐️Follow me
Twitter and IG @iamspikebor

πŸ“— Read my series Happy Meow Cafe on webtoons
https://www.webtoons.com/en/challenge/happy-meow-cafe/list?title_no=387086
or We...

β–Ά Play video
#

especially the angle at the end of video, there is no stripe shown at all

#

around 0:03-0:05 of video, it's most beautiful

sweet burrow
#

Is there a way to get the triangle's ID in ShaderGraph?
From what I see HLSL language has "SV_PrimitiveID" for that, but ShaderGraph doesn't recognize it in my custom node.

onyx cargo
#

does anyone find they need to boost the metallic on non-metallic materials to get realistic reflections?

#

and its very shiny but the metalness in the metalness map is black and it barely produces any reflections. IRL my hardwood floors are reflective af.

stiff furnace
#

How to make atmosphere scattering?

#

For planet

sweet burrow
#

@onyx cargo Hardwood and material like that need a shader with "coat"-style reflection.

sweet burrow
#

It's a shader property in URP/HDRP, not sure how exactly to code it in Legacy.
It's made specifically to simulate coating reflections like varnished wood, car paint and the likes - as cranking up Metallic&Smoothness doesn't really give the proper effect.

silk sky
#

I'm following a guide to recreate a stencil shader to render some objects only through a quad, so far seems pretty simple but I noticed that my opaque object for some reasong has details of thinks behind it

#

Games like Antichamber feature impossible geometry where multiple objects seemingly inhabit the same physical space, but only appear when viewed from certain angles. We can recreate the effect in Unity using stencil shaders and Universal Render Pipeline's special Renderer Features functionality!

πŸ‘‡ Download the project on GitHub: htt...

β–Ά Play video
lunar valley
# stiff furnace How to make atmosphere scattering?

Sir, we are not a search engine. But here you go https://www.youtube.com/watch?v=DxfEbulyFcY&t=139s

The planets in my solar system project are looking a bit hostile and uninviting, so in this video I'll be attempting to add some cozy atmospheres around them.

Watch the previous solar system video: here: https://youtu.be/lctXaT9pxA0

Some notes:
β€’ I made a little build where you can play with the atmosphere settings yourself, which you can find...

β–Ά Play video
regal stag
regal stag
silk sky
#

Oh I see, the SSAO is another "stack" that gets added to the base render, so the stencil gets exclude from that calculation right?

silk sky
sweet burrow
#

@regal stag It look like Amplify Shader Editor has it actually. Will try to rebuild my prototype with them and see if it work.

regal stag
silk sky
#

This is the current render setting

#

The base opaque layer mask renders everything except "layer 1" which is the only thing that the override renders

regal stag
#

Exactly, so that layer 1 likely isn't rendered into the camera depth and normals textures, so the SSAO feature doesn't know about them

silk sky
#

I found out that a simple solution seems to just set ambient occlusion in UPR Renderer Settings to After Opaque

#

still have to find it tho

#

oh it was just a toggle in the SSAO render, seems it fixed it well

#

Now last thing to consider is if and how much this render thing has impact on performances

stiff furnace
lunar valley
#

If taking samples is not so much your thing, then you can fake some atmosphere scattering with some hacks that look about right

stiff furnace
lunar valley
#

cool

stiff furnace
#

it is visible from space but from earth it is not visible (

lunar valley
stiff furnace
#

i dont know :d can you help me?

lunar valley
#

possibly yes

stiff furnace
#

how?

lunar valley
# stiff furnace how?

What about elaborating what you have done, sending the main part of your code and what do you want to change

stiff furnace
#

here or pm?

lunar valley
#

if you do it here, other people might also be able to help

stiff furnace
#

create sphere from sphere. create material from this shadergraph and assign it sphere

lunar valley
# stiff furnace

I cannot open this right now, send it in a form of a screenshot

stiff furnace
#

it is urp

lunar valley
stiff furnace
#

i want to be visible on both sides

lunar valley
stiff furnace
devout pawn
#

You could try changing Render Face from Front to Both

regal stag
#

If you want the fresnel to work on back faces, you'll also need to flip the normal vector. Something like this

stiff furnace
#

i tried both but not working

lunar valley
# stiff furnace

If I where to make an atmosphere shader, I would do it using a post prossesing shader

versed python
#

im trying to make some visual effects to use on this 2d mesh im procedurally generating, i made a mockup in photoshop of roughly what i want to get it looking like, any idea how to do something like this?

#

from the googling i did it seems like doing outlines like this on 2d meshes is impossible for a shader to do? is there something else i would need to use for that

lunar valley
regal stag
versed python
#

not really sure what that means can you elaborate, i just started learning shaders

regal stag
#

Well this is more changing the mesh generation. There's not much on the shader side.

versed python
#

yeah what is the vertex color i mean how do i edit that

regal stag
#

It would store a colour value per-vertex, which gets interpolated in the shader

versed python
#

alright thanks ill give that a try

#

editing the mesh like that might be tricky, its generated by sampling along a grid so making them scale out like that would have to go off the grid

#

ill see how it looks just using the mesh i have now first

#

as for the transparency in the middle im sure thats a lot simpler but when i tried to make it the transparency was only either fully opaque or invisible is there a setting i need to enable to get partial transparency

dim sedge
#

I'm sorry if this is a stupid question, how do I set up a public variable in HLSL?

stiff furnace
dim sedge
#

I tried doing js Shader "Assets/PlayerVision" { _MainTex ("Texture", 2D) = "white" {} but got the error, "Shader error in '': Parse error: syntax error, unexpected TVAL_ID at line 3"

versed python
#

using vertex color with the unmodified mesh, progress at least!

dim sedge
#

Thank you

stiff furnace
#

i want like this

#

now it is

#

i want transparent fade out color

vernal coyote
#

Hey, I'm sampling a cubemap and rotating it in a shader, but there's a weird effect that happens:
It seems to have these random blue and reddish squares on it, but when I put it onto a cube or a sphere the issue isn't there

#

Here is my graph:

#

I'm trying to set this as the skybox material, and it appears fine but the reflections have a weird blue tint as a result of (I'm assuming) the big blue squares

#

Oh actually nvm, it does't appear properly, it appears like this:

vernal coyote
#

ok I think i've fixed it by setting the material type to transparent

versed python
#

how do i pick a mesh to use in the preview here

#

clicking it just gives me this error

grizzled bolt
thorn hull
#

which shader node do I use to mirror a texture?

simple violet
#

One minus the uv coord and place into texture 2d sampler uv property

#

I think

meager pelican
# thorn hull which shader node do I use to mirror a texture?

You could also set the sampler state to mirror the texture, or the import settings on the texture to mirror. UV values outside of 0-1 will mirror.
There's a text version of an explaination here:
https://docs.unity3d.com/Manual/SL-SamplerStates.html

    Wrap modes can be specified per-axis (UVW), e.g. β€œClampU_RepeatV”.```
As far as SG and nodes, there's a sampler-state node that should help you.
https://docs.unity3d.com/Packages/com.unity.shadergraph@16.0/manual/Sampler-State-Node.html
clever mango
#

I had a question but after spending 30 minutes to write it correctly, I found the solution, so thanks you blushie

hollow wolf
#

hi, so i know we can make a heat distortion effect using scene color node in shadergraph, but let's say instead of distort it i want to make it more clearer, how do i achieved it?

hollow wolf
lunar valley
#

I guess this could work for you🀷

hollow wolf
stiff furnace
rare wren
#

@stiff furnace
Probably a mix of (1 or 2) fresnels with different intensity, and (smooth)step

stiff furnace
#

i did but it is not visible both side

rare wren
#

Hmm never used the blackbody node.
I'd try with 1 regular fresnel and a one minus fresnel and then maybe use (smooth)step on it

burnt crown
#

how do i make part of a material unlit?

#

but only parts of it

lunar valley
burnt crown
#

oops caps

#

sorry

lunar valley
burnt crown
#

here i'll show you

#

i want the neon colors to glow

lunar valley
#

oh I read mesh instead of material, sorry

burnt crown
#

all good

lunar valley
#

you can go into blender for example and assign the material only on parts of the mesh

burnt crown
#

what I cant use gifs?

#

dang

lunar valley
#

but if you tell me what you want to create I might be able to give you a better solution which only needs one material

burnt crown
#

the neon colors glow

#

thats it

#

am i able to mask it with an emission?

lunar valley
#

In this case it has nothing to do with the shader being unlit or not

cerulean imp
#

I made a script that only is able to place objects on a plane if it is at least 20cm away from the edge. Now I want to show this area in the mesh renderer. I am using the standard PlaneMat from the template. I want to show the area where the user can place objects in green and the rest in red. Anyone managed to do something like this?

lunar valley
stiff furnace
rare wren
#

Something like this?

#

And then tweak the values

stiff furnace
#

it is visible both side but it is not good result

rare wren
#

What?

#

If you want something be very specific

#

We dont see what you see

#

@stiff furnace

stiff furnace
#

similar this edges are transparent

cosmic prairie
#

@tight phoenix sorry for the ping, but I got curious, I see you hacking away at something cool each day here, do you happen to have a collection of these effects somewhere, where people can check these out? or are they for private projects? πŸ˜„

silk sky
#

Back to the stencil shader I was working few days ago, the last thing I need to fix is the fact that the camera renders object outside the stencil layer, as you can see the sphere on the botton should be cut once it gets inside the render plane, how I should exclude objects from different layers from being rendered above??

regal gorge
#

Unity again break skyboxes.. Previously I could just simply make Shader named Skybox Shader and material named Skybox Material and it was working but now? This happens, any possible ideas what is going on?

#

Standard Unlit shader works fine.

silk sky
#

This is the result I'm trying to achieve

tight phoenix
silk sky
#

In this example I've already done the stencil part but from the plane with the selected render layer I want to exclude the inner cube

regal gorge
#

So you need set of N cameras and each need render your desired dimension.

#

So for each dimension you need camera.

#

That render this dimension on render texture.

#

And then you need map result on face with correct aspect.

silk sky
#

Yeah that was plan b but the the render texture will be flat

regal gorge
#

It does not matter.

silk sky
#

what do you mean?

regal gorge
#

Then you use this.

#

As UV.

silk sky
#

so it will distort based on camera position?

regal gorge
#

But there is some limitations.

#

Render texture need to have same aspect ratio as your "game".

silk sky
#

yeh for sure the render texture is one of them, I don't want to have 1 camera for each of these windows

regal gorge
#

its cannot be different.

#

Yeah.

#

Its pretty sick.

cosmic prairie
tight phoenix
#

I will have more to show in the future πŸ‘

#

Ill try to put together a showcase if the stars align

merry oak
#

I don't really know if this is a shader question, but is there a way to set the value of the depth buffer over the entire screen?

cosmic prairie
sweet burrow
#

GPU question - technically for Unity but I don't think it's engine-specific:
Do textures get loaded in-GPU as float3, float4, or is it flexible and follow whatever format it had CPU-side?
Asking because I'm using textures to transmit non-texture data to my shader.
Most of it is float3, and I want to know if it can optimize it by setting the texture as 24bits format, or if the alpha channel is going to be there anyway and I should use it to cram more data.

merry oak
wild marlin
#

I have a kawase blur when my UI is open but it doesnt always work with other shaders (water and glass shader here) at a certain distance and i dont know why

heady horizon
#

Just getting started with writing shaders, and I'm getting the pink error material on my sphere, where I'm expecting to see some lighting and an actual color applied. I've rewritten my code maybe a million times but I have no idea why this is happening. Here is my code: https://pastebin.com/XjQTLUaR

lunar valley
#

what does this mean: cs use PGM to create an input mesh for ocean wave modeling. Here, PGM is a good choice as the moving ocean surface hides the morphing vertices its in the context of oceans waves on spheres

#

What is PGM?

#

Also second question (lol), I am trying to make some gerstner waves on a sphere, so I wanted to ask if I managed to successfully convert this math talk into code? ```cs
//WorldSpacePos is in my case the position of the sphere gameObject
float3 o = normalize(v.vertex - WorldSpacePos);
float3 vec = normalize(v.vertex);
float3 dir = cross(vec, cross((vec - o), vec));

        float r = _Radius;
        float li = acos(dot(vec, o)) * r;

        v.vertex.xyz = vec * r + vec * (_Amplitude * sin(_Frequency * li + _WaveSpeed * _Time.y)) + (_WaveSteepness * _Amplitude * cos(_Frequency * li + _WaveSpeed * _Time.y) * dir);
lyric vortex
#

Hello, I have a gameobject using shader "Universal Render Pipeline/Lit". Could you please tell me how to set it "transparent" at runtime using C# script ?
Currently I try this:

GameObject go = GameObject.FindGameObjectWithTag("MyTag");
Material m = flagStick.GetComponent<Renderer>().material;
m.SetFloat("_Surface", 1.0f);
m.color = new Color(m.color.r, m.color.g, m.color.b, 0.3f);

I can see in the editor that the Surface and Color values are correctly changed, but in game the gameobject is always opaque.

lunar valley
clever mango
#

Hi, I try to achieve a rat ondulation
But it looks like that, can you figure out what I miss to join all the vertex?

clever mango
#

@hot kelp I found my error, thanks πŸ™‚

tacit parcel
fossil fossil
#

hi, sorry for asking. may i know is there any method to replace alpha in the sprite to white color by using shader graph?

tacit parcel
fossil fossil
#

basically add a white background to the current texture that has transparency

tacit parcel
lunar valley
tender marsh
#

Desperately need help on seeing why I'm getting errors here

#
          struct appdata {
                float4 vertex : POSITION;
                float2 texcoord : TEXCOORD0;

            };

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

            sampler2D _MainTex;
            sampler2D _PalTex;

            sampler2D _Palette;
            float4 _MainTex_ST;

            
            uniform int _ColorCount;
            uniform fixed4 _Colors[256];

            half _PixelWidth;
            half _PixelHeight;
            half _ScreenWidth;
            half _ScreenHeight;

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

            fixed4 frag(v2f i) : SV_Target
            {
                  half dx = _PixelWidth * (1. / _ScreenWidth);
                  half dy = _PixelHeight * (1. / _ScreenHeight);
                  half2 coord = half2(dx * floor(i.uv.x / dx), dy * floor(i.uv.y / dy));

                  fixed3 baseCol = tex2D(_MainTex, coord).rgb;

                  fixed4 col = fixed4(0,0,0,0);
                  fixed dist = 10000000.0; // for prosperety

                  for (int i = 0; i < _ColorCount; i++) {
                      fixed4 c = tex2D(_PalTex, 0);
                      fixed d = distance(baseCol, c);

                      if (d < dist) {
                          dist = d;
                          col = c;
                      }
                    }
  UNITY_APPLY_FOG(i.fogCoord, col);
                    return col;


            }
                ENDCG
    }
}
}```
#

"Shader error in 'Unlit/GB-Unlit': invalid subscript 'vertex' at line 66 (on d3d11)"

tacit parcel
rare wren
north raven
#

Is there a way to make a 2D shader consider only a single sprite and not the take the entire spritesheet with it ?

I'm talking about these types of spritesheets :

amber saffron
bitter forge
#

Hello everyone, I have a little problem: I have a Sphere and I want to have something which is working like an outline shader. I am working in AR, and when I am looking at a sphere I want to see the circle, which is like the outline of the sphere from the current position I am standing at. This is kinda working right now with fresnel effect (+step & lerp), but when I am streaming the video of the view to another device, the circle is filled black and not transparent so I don’t see the content which is behind the black filling of the circle – the content which should be circled... I have already adjusted a few settings (surface type, transparency-value), but I was not able to get the result I am looking for. I would be glad if anyone could help.

mystic wagon
#

Does anyone have a link to a good outline package on asset store? Or is there a pre existing unity solution to produce an outline?
I'd like a blurred outline on 3d objects

crimson knot
#

Is it possible to get a normal map that is stored as a secondary texture with 3D lights? I only see it mentioned with 2D lights

#

Ive setup my secondary texture as suggested but I dont seem to get any effect

simple violet
#

Thats only for 2d lights

regal stag
# crimson knot

Is this still on a SpriteRenderer? I'm not sure secondary textures get used otherwise.
Also what shader is being used? If it's something like Standard / Lit, the normal map property name is usually _BumpMap

regal stag
crimson knot
#

@regal stag This is what im currently using on my tilemap renderer

regal stag
regal stag
crimson knot
#

@regal stag Sadly no dice:

regal stag
#

That's the base map, try assigning one here?

#

My hope is that'll keep the keyword enabled so it uses the correct shader variant, and the Tilemap renderer will override the texture to the secondary one. But just guessing here.

crimson knot
#

This has an effect but not quite intended:

#

It doesnt seem to map to the correct tiles

regal stag
#

No idea then, sorry

crimson knot
#

Ah no problem thanks for trying. This is what I get for trying to use 2d tools inside of 3d πŸ™‚

#

@regal stag I may have actually figured it out

#

I think you are right its just the other tiles in my sets dont already have a normal map setup so its applying the default

#

Also I know my normal map is borked just testing

regal stag
crimson knot
#

The path tile and the grass are separate sprite sheets so now I have a normal map for each it seems to work

#

Thanks for the nudge in the right direction regardless ❀️

split light
vague pilot
#

hey im a unity beginner (i hope this is the right channel) and currently trying to create a tree now i want to create the leaves using as less triangles as possible but if i do it like that (image) you can see the single planes is there a way to avoid this effect? (heard sth. about depth / z- buffers)

split light
#

from something i wrote

split light
shy fiber
#

does anyone knows how to create this kind of outline on shader?

vale estuary
#

Does any one know if there is a urp shader for TMP or Super Text Mesh, that is lit? I am using STM right now and it seems to only have unlit shaders.

silk sky
#

Ive made a simple shader to make a texture visible in 3D space by applying the material to a quad. Now is it possible to give the said quad some depth thickness based of what is not alpha on the texture?

tender marsh
dim yoke
silk sky
civic lantern
#

Maybe just vertex displacement based on the texture alpha?

sturdy bloom
#

hi guys, how do we use GPU instancing on shader that created with shadergraph? I'm on unity 2021.3 and trying to make a custom 2D shader that will replace pixel color

silk sky
regal stag
brazen nimbus
#

Hello ! Just wanted to know if it was possible to use a smoothness texture (or an entire material) in a VFX shader graph ? The only things I see about that are these float πŸ€”

regal stag
dim yoke
brazen nimbus
karmic hatch
jade briar
#

Hello, I have a dog model that I want to make it look like a ghost and follow you around. How can I remove this effect that I see here on my object? (marked with red)

#

The transparency adds up, i can't find anywhere how i can fix this to show only the mesh that you see, without the parts in the background

neat hamlet
#
            Name "Empty"
             ZWrite On
            ColorMask 0
        }```
jade briar
#

I am using ShaderGraph since the project is in URP

neat hamlet
#

oh, I dont think its possible with only shader graph

#

I dont know if colormask is available to set via shader graph, but you can add a second material with a code shader that just does that pass

#

make sure the empty pass material is first in the material list though

jade briar
#

okay thanks, that worked

jade briar
#

works like a charm πŸ˜„

neat hamlet
#

awesome πŸ˜„

silk sky
dim yoke
lime vector
#

Hi, I'm new to shaders.
Is there a way to have these cubes make parts of the purple mesh fully transparent?
I want to make a fog-of-war type thing

#

Forgot to mention It's in URP

vague pilot
#

hey so i want to learn shader graph but every tutorial i am watching shows me the nodes or how to create a specific shader now the question: how do you know which node to use when? (please send me some useful tutorials)

amber saffron
rare wren
#

@lime vector could you explain what you want to do again?

Do you mean like the purple ground having transparent 'holes' in it?

cosmic prairie
shy fiber
cosmic prairie
#

no, I tried searching for it haha

cosmic prairie
#

that way you can wrap a gradient all over it to your liking

#

SDF is your keyword, but I got no idea if any tools exist, sorry.

regal stag
#

Can also search for "jump flood algorithm" implementations in unity, as that can be used to generate an SDF afaik.

cosmic prairie
#

here it's described, but I was hoping an artist tool would have this implemented by now

#

it's not that uncommon

regal stag
cosmic prairie
#

I would imagine it's hand painted, usually you would want more control. If you layer noise you also kinda lose that distance field-iness the more you layer it

cosmic prairie
#

would do the job

shy fiber
#

navmesh -> mesh

#

then draw from top with a ortographic camera

leaden shuttle
#

is there to make a portion of a shader lit and another be unlit?

tacit parcel
leaden shuttle
#

how?

tacit parcel
leaden shuttle
#

is there a way to do this in shader graph? i havent really started learning how to make proper shaders

tacit parcel
#

that is something I'm not sure
well maybe you can use an unlit shader as a base, and add some manual lighting calculation, then interpolate between them using a texture mask

leaden shuttle
#

i think in that case I might just use 2 sprite renderers and have 1 that uses the shader material as that seems more simple. maybe one day ill learn how to actually code shaders

lime vector
dark nymph
#

I want to make a cel-shaded game (I had a look at this effect https://www.youtube.com/watch?v=lUmRJRrZfGc) but with that simplistic colour-only style seen in killer7 where everything has a gradient, rather than using textures

dark nymph
#

i want it to look exactly like in that video, but all the tutorials and code I find online are doing a more BOTW approach to cel shading without the gradient

tacit parcel
#

because it's not cell-shaded (except for the characters), it more looks like screen space gradient

dark nymph
#

how do I achieve that effect in shader graph?

#

I want cel shaded characters and screen space gradients for the geometry

#

ideally also those hard shadows

dark nymph
#

if anyone can help me create my shader it would be cool to hop in voice chat and do it together if anyone is down for that

#

idk if anyone on this server does collaborative work like that but hmu if so

regal stag
# dark nymph how do I achieve that effect in shader graph?

Can make the screen space gradient by using the Screen Position node, Split and take the G output (Y axis). I'd put that into an Inverse Lerp to remap it, then Saturate. That gives you where the colours should transition, as in the video I think the gradient itself is only really in the center of the screen - the top third is solid colour at least? (a little hard to tell with the compression)

For applying colours, can put it into T of a Lerp, with A and B set to color nodes/properties. e.g. https://www.cyanilux.com/tutorials/color-swap/#lerp

For the toon/cel-shaded part, if you use URP you should be able to find shader graph tutorials for that, but you'll need custom functions to obtain lighting info. e.g. https://github.com/Cyanilux/URP_ShaderGraphCustomLighting

#

Should be the Transformation Matrix node, with View on dropdown

dark nymph
dark nymph
#

it seems to work!

#

I just messed with the value on the lerp

#

this isn't quite producing the effect i wanted however - it's not "looking" at the camera

#

meaning the effect breaks when the player looks around

hushed rune
#

why my material is not shown up in Unity (i used alpha textures)

amber saffron
amber saffron
dark nymph
#

like how old games would do skyboxes, where the texture is the same no matter the orientation of the camera (or the end gateways/portals from minecraft for example)

amber saffron
#

So, wasn't clear to me, is something not working as expected with your setup ?

dark nymph
#

I also saw a post about adding persona 5 style "dithering" effects which looks neat so there's always that to try out too

sweet burrow
#

The new dots rendering system need to be provided 4x3 matrices for each mesh Scale/position/rotation.
I know 4x4 have Matrix4x4.TRS to generate them, but I can't find an equivalent for 4x3. And I can't find documentation on this either (even Unity's own sample project just manually fill the matrix but that only work with non-scaled, non-rotated objects).
Anyone know?

pliant pond
#

trying to convert an existing shader to work in single pass instanced xr environments, but for some reason my object's position (works fine normally and is defined as o.pos = UnityViewToClipPos(UnityObjectToViewPos(v.vertex));) seems to cause bytecode errors from the shader compiler whenever used (ex. o.perspective.x = 1.0f / o.pos.w). The strangest part is that it works fine without accounting for single passed instanced rendering, but while that could be excused as differences in environments or available data, it works when I try and use o.pos.w in calculations in the fragment shader, but when i pass it into a function (ex. myFunc(o.pos.w), it's when I get the bytecode errors. I am legitimately confused.

grand jolt
#

So I am making a low poly planet and I was wondering if I can just create a sphere that goes into the deep areas of the map that have the water shader. And then I wanna take that and make code that makes the sphere like buoyant or whatever. Is that possible?

crystal pulsar
#

Hey folks. I'm pretty new to shaders, but I'd like to find some performant way to make ghibli / botw grass in unity. Any advice? I know a decent bit of code so I'm down to write shaders, but I could use a tutorial or something of the like to start. Using URP. Any advice?

tacit parcel
#

Any advice?
Don't use URP, not yet

static forum
#

I have this shader
It's supposed to make text scroll like this

#

It works on my windows PC, in editor and build. But it doesn't work on other windows PCs

#

Please anyone able to help?

distant dirge
#

Custom functions

wraith wing
#

if I want to have dot following the normal face of the line, do I need to use normal or tangent vector?

wraith wing
#

something like this the green triangle is direction following the local face space of mesh

hollow wolf
#

hi, why did my sprite lit shader preview come up different when in game mode

amber saffron
amber saffron
amber saffron
#

Probably because they are also facing the light when rendering into the shadowmap

#

You're doing the billboard effect in the vertex shader by using view vector / direction I guess ?

Instead, calculate the same vector by subtracting the camera position (camera node) to the vertex position (might need to normalize).
That way, it will always face the camera, including during the shadowmap pass

#

Imagine the shadowmap pass as "render the depth of the scene from the light point of view".
Well, in that case, using view direction/vector gives you values like if the light was the camera

#

Using the camera node, which contains the camera informations used for a full frame rendering, and calculating those vectors yourself, you force it to be in the camera view space

tacit parcel
sly breach
#

is there a way to debug shader variables on the CPU ?

#

for example how would i log input.worldPos.x

#

can i write it to some sort of global var and then use mat read vec ?

tacit parcel
# sly breach for example how would i log ` input.worldPos.x `

I think it would be hard to log since shader works in vertex and fragment/pixel
imagine a model with 5000 vertices, with a 512x512 texture, it could dump a lot of log lines
I usually 'log' them by outputting it to the mesh color, where I can inspect it visually

tawdry otter
#

Hello, how do I displace the outer ring of a circle mesh using shader graph?

amber saffron
tawdry otter
amber saffron
reef mirage
#

Hey Guys how to create TextMeshPro "fontAssetType=1"

surreal locust
#

How to have different compiled shader with only one .shader file?

#

for some object i haven't normal.
for some object i haven't metallic.

#

I wont duplicate code

regal stag
surreal locust
#

where i set the value of this keywords? like if I have the metallic texture in the shader property I want the shader_feature on

regal stag
surreal locust
#

It works like a charm!

wispy salmon
#

hello I'm trying to add this shader to unity but its entirely pink and I don't know what to do. https://www.youtube.com/watch?v=mWg4CE6ybKE&t=112s&ab_channel=SpeedTutor

Ever wanted a FREE water shader for URP and Unity, Including: Reflection, customisation and simple parameters for Unity? Well, here is an in-depth look at the features of the Simple Water Shader for URP & HDRP by IgniteCoders.

➑️Simple Water Shader Asset: https://assetstore.unity.com/packages/2d/textures-materials/water/simple-water-shader-urp-...

β–Ά Play video
karmic hatch
#

was there ever a main light node? iirc you can make a custom node to show it; it's a pretty obvious thing they should add though.

regal stag
#

There is a Main Light Direction in 2022.1+
But if you're using URP, I've also got https://github.com/Cyanilux/URP_ShaderGraphCustomLighting
Which has access to light colour, distance atten (which stores if the light appears in the culling mask iirc). Can also sample shadowmap via Main Light Shadows subgraph.

regal stag
#

If it's a Shader Graph you may also be able to change target under the Graph Settings to make it compatible with other pipelines.

wispy salmon
#

ok, I'll try that, thanks πŸ‘

winter palm
#

Hi I am having a problem with the lines of the other side of my box showing through the cube, I have this shader graph attached to my cube is this reason why it looks like this?

#

it also renders through walls

#

this is what its supposed to look like

regal stag
grim cedar
#

is it a known limitation of material variants that I am unable to lock Vector2 properties on a material?

hollow knot
#

Hey guys i got this shader on built-in rendering pipeline, its a shader that fades things when the camera colides with them, but with this magnets stickers of the fridge they get not to have transparency info cutout, im trying to make a cutout +fade to transparency, although idk if its possible to have cutout + fade?

sacred stratus
#

Is there a computebuffer that has an extendable size?

low lichen
sacred stratus
#

so is there a better option than having an array of ComputeBuffers, and then setting them when you need them, while doubeling the size each time?

grand jolt
#

I'm having issues with my custom shadergraph, depending on the rotation of the object, the mesh gets colored differently

#

No clue why this is happening, whether its the fragment or vertex

#

It's based off a tutorial for a waving grass shader

#

Without the vertex shader part, which waves the grass, it doesn't change when rotating, but some parts of the mesh are darker then the rest:

#

Depends on the viewing angle

grizzled bolt
# grand jolt

The most likely reason might be that the meshes are one-sided with the shader rendering both front and backfaces
Despite this only front faces get lighting which is duplicated on the backface, so if the front face is facing away from the light both sides appear dark

#

If it's not that it could also be just the lit surface reflecting different amounts of light by angle

grand jolt
#

I think its one sided yeah

#

How can I fix that?

#

Do I just need a different mesh?

grizzled bolt
grand jolt
#

The fragment, or vertex normal?

#

Vertex I assume?

grizzled bolt
#

Though there's probably more than one way

grand jolt
#

Okay, that helped tremendously

#

But not completely, some angles still have very dark areas

grand jolt
#

I multiplied the normal map by the normal vector, and the results are great!

#

The side not facing the light source is pretty dark, but i have no clue how to fix that

regal stag
#

If you're using a normal map, you would replace the Normal Vector node in their example with the Sample Texture 2D, rather than multiplying them together

grand jolt
#

I tried that, and the results were worse

regal stag
#

Some faces may still be dark though as they would be facing away from the light source

grand jolt
#

before, and after

regal stag
#

I think a typical way to avoid that is to make the normals match the terrain or point directly upwards instead - which you could do by switching the normal output space to World in Graph Settings and using a Vector3 of (0, 1, 0)

#

May also be able to keep the normal map, but Transform to World space, add an amount to the Y axis and Normalise to get a similar result.

grand jolt
#

In which case I don't need a normal map at all lol

#

Ah

regal stag
#

Yeah, I'm not sure if the normal map is adding much detail here. Can try both and see what works

grand jolt
#

It looks a bit more fake without it, because it doesn't look lit at all

#

i'll try both

#

World space is second image

#

looks better

vestal ice
#

im trying to find a good shader graph tutorial and alot of them use the old pbr shader graph and im wondering if there is anything else to use (im new to using shader graphs)

vestal ice
#

ok thanks

patent chasm
#

why does the particle system has this black shadow and how do I get rid of it

grizzled bolt
winter palm
#

Hi I am having a problem with the lines of the other side of my box showing through the cube, I have this shader graph (https://i.imgur.com/c1ZPmnF.png) attached to my cube what is the reason why it looks like this?

#

why does it also render through walls

#

here are my graph settings too

regal stag
# winter palm here are my graph settings too

Hmm, you have Allow Material Override ticked, so maybe the surface type on the material is transparent? (This kind of thing happens with transparent objects as they don't write to the depth buffer. But if you're doing dissolve you can still do that with opaque + alpha clipping)

winter palm
#

thanks

sacred stratus
#

are there functions that allow you to directly copy from computeBuffer A to computeBuffer B in unity?

vivid fable
#

Anyone got any ideas why this shader (https://www.youtube.com/watch?v=EzM8LGzMjmc) no longer works on PC?

In Unity 2021.3.16 (probably just 2021.3..?) and URP 12.1.8 the stencil no longer works when the platform is set to Windows/ PC/ Mac. Swap to Android or iOS and it works again.

grizzled bolt
vivid fable
#

Oh, that's good to know - I'll try updating to the latest 2021.3

#

Nope, still not working in 2021.3.22 / URP 12.1.10 on PC

grizzled bolt
vivid fable
#

each time I've done it it's been in new projects

#

Just now though, on 2021.3.22 I had missed something.. sorted it now

#

It's working on PC

#

Cheers Spazi

grand jolt
#

I can't seem to figure out where to mess with shadows, to me, these are to dark, where should I mess with this? The Directional Light settings? Shader Graph?

#

(Behind the directional light here btw)

tough slate
#

So, not sure where to post this, but I'm trying to move creating a texture rendering some mesh using a custom shader from using a custom camera to a pure CommandBuffer approach.
This is in the context of modding, so a limitation is that I don't have access to the shader source, but what the shader does is :

  • Outputting the normals in the red channel
  • Outputting the depth in the green channel (with inversed values compared to the raw depth)
    Example :
#

The is the result when using CommandBuffer.DrawRenderer(renderer, material) and then calling

camera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, cameraCommandBuffer);
camera.Render();
#

However, if I try to do the same thing with a camera, but setting a command buffer view/projection matrices, setting the target with CommandBuffer.SetRenderTarget(someARGB32RenderTexture) and finally Graphics.ExecuteCommandBuffer(myCommandBuffer), normals are going to the red channel as expected, but the green channel (depth) is empty :

#

Complete code :

CommandBuffer manualCommandBuffer = new CommandBuffer();
manualCommandBuffer.name = "manualDragCubeRender";

Matrix4x4 projectionMatrix = Matrix4x4.Ortho(-cameraSize, cameraSize, -cameraSize, cameraSize, 0f, farClipPlane);
Matrix4x4 viewMatrix = Matrix4x4.TRS(cameraPosition, cameraRotation, Vector3.one);
Matrix4x4 scaleMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(1, 1, -1));
manualCommandBuffer.SetViewProjectionMatrices(scaleMatrix * viewMatrix.inverse, projectionMatrix);
manualCommandBuffer.SetRenderTarget(manualRenderTexture);
manualCommandBuffer.ClearRenderTarget(true, true, Color.clear);

CommandBuffer cameraCommandBuffer = new CommandBuffer();
cameraCommandBuffer.name = "cameraDragCubeRender";

transform.position = cameraPosition;
transform.rotation = cameraRotation;
camera.orthographicSize = cameraSize;
camera.farClipPlane = farClipPlane; // nearClipPlane is set to zero

foreach (Renderer renderer in part.GetPartRenderers())
{
    Material material = new Material(dgs.dragShader);
    manualCommandBuffer.DrawRenderer(renderer, material);
    cameraCommandBuffer.DrawRenderer(renderer, material);
}

Graphics.ExecuteCommandBuffer(manualCommandBuffer);

camera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, cameraCommandBuffer);
camera.Render(); // camera.targetTexture is set to a RenderTexture
camera.RemoveAllCommandBuffers();
#

The RenderTexture are created as follow :

new RenderTexture(textureSize, textureSize, 16, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default)
{
    antiAliasing = 1,
    filterMode = FilterMode.Point,
    autoGenerateMips = false
};
slim yew
#

is there a way to get the world position of additional lights?

#

I'm trying to fake volumetric lighting and need to do some ray casting

#

looking through HLSL or CG includes lights don't have that luxury

#

but, I can get an approximate position using the direction and the square inverse of the distance attenuation

#

since it is 1/d^2

sullen gale
#

What's the functional difference between _ScreenParams.xy & _MainTex.xy on image shaders?

last vault
#

Working on an effect using multi-channel shadow maps... I think it's turning out nicely.

distant dirge
hushed cairn
#

using a shader i got from the asset store and it is just not working and really not sure why because i got it working before rather easily... god my brain hurts

pseudo narwhal
# grand jolt I can't seem to figure out where to mess with shadows, to me, these are to dark,...

you'd tweak your ambient light contribution, possibly GI (if you use it), maybe custom post processing that isn't using ACES tonemapping, maybe overall increased exposure (also via postprocessing). ugly shadows on billboard-style grass cards can be fixed by making a shader that overrides the mesh normals to be perpendicular to the terrain (point up), alternatively you could rotate them in your 3d software.

grand jolt
#

Thanks for the response, and you reminded me this server exists!
New question!
I can't use the GPU Instancing with the game I'm modding this map in for some reason, the grass refuses to render in game if I use it on the grass for some reason. What could possibly conflict with it? And if I just can't use it, how does the Vertex Lit and Grass mode work? It just renders the mesh vertices in Vertex Lit unless I use URP/Lit.

#

Before I was using a ton of grass prefabs, but that's laggy as shit, so I'm trying to use the unity terrain system

#

the reason there was a ton of prefabs is because I was using Vegetation Studio, and the game doesn't support it, because it doesn't allow scripts in maps unless they are DLLs, no clue why.

#

so it was difficult to get around it, and I baked the grass into the scene as prefabs

#

that makes it difficult for performance, so I scratched all that, and here I am lol

last vault
#

Any idea why my depth texture seems to be disappearing?
I am using a custom scriptable render pipeline and the PostFX post processing stack. Is there anything unique I need to do to preserve (or create..?) _CameraDepthTexture?

#

for now, I'm working around it by defining a separate depth target called _CameraDepthMap, but I found that it doesn't work if I do the same but using the ID of _CameraDepthTexture.

agile horizon
#

Is this the place to talk about compute shaders?

arctic flame
#

why can't i connect these? they're both real number pins, right?

#

im really confused about where exactly the nodes are in shader graph to cast to different vectors, wherever they are they aren't named such that i can find them with searching o_o

mental bone
#

You should be able to connect the individual rgb components to the ports of the vector3

mental bone
#

That is strange to say the least

arctic flame
#

oh wtf

#

@mental bone so that specific node was broken i guess? look at the screen closely and you'll see one accepts and the other doesn't

#

wtf πŸ₯΄

mental bone
#

Im not sure what is going on but it justworks for me

arctic flame
#

ok so what's happening i think is that the output types are different in an invisible way

#

i got the left side connected and the output is not compatible with Normal

#

so i guess that Normal is not actually a vector and is something else (idk what)

mental bone
#

Its a vector for sure

arctic flame
#

i think i understand the problem

#

i think the issue is that philosophically it doesn't make sense for a vertex normal to be sampling the texture, i suppose? but i don't know what else to make it.

#

okay, i'm gonna ask a new question and outline the issue:

#

hi! so i'm trying to make a retro-reflection shader, and the way to do this is to make the normal of the object always face towards the camera. I'm doing that successfully.

my next goal is to make it so that this black and white reference texture is used to control the amount of reflection. so i'm lerping between the default normal and the modified normal using that texture.

My expected result is that each pixel gets rendered with a normal that's affected by this texture.

#

i'm not sure how to achieve this in shader graph though. vertex normals only affect vertexes after all but the fragment normals are all in tangent space so don't seem suitable for this purpose either.

mental bone
#

Oh I think I know whats the issue. You cant use SampleTexture2D in the vertex stage you have to use SampleTexture2DLOD and provide the lod level yourself

arctic flame
#

alright, i'll try that. what's the difference between the nodes?

#

this might seem like a dumb question on the surface but... i don't use LOD management in my project yet.

#

unless LOD refers to something else

mental bone
#

In this case lod refers to the mip level of the texture

#

Its just how textures are sampled in the vertex stage you have to manually fetch the desired mip level

arctic flame
#

is it easy to make it use the mip level it was always going to use in that situation anyway?

mental bone
#

I dont get the question. You have to manually provide the mip because at the vertex stage the system does not yet know what mip to use

arctic flame
#

oh, darn.

#

i was really hoping i could leave mip controlled by the engine. so i have to essentially re-implement mip mapping again in my shader?

#

i guess i lost mipping when i made a new empty shader

#

ok wait hold on

mental bone
#

You haven’t lost anything

arctic flame
#

i'm going about this the wrong way