#archived-shaders

1 messages · Page 192 of 1

regal stag
#

Yeah, might be that you can't mix fragment-only stuff into the subgraph if you plan on using it in the vertex stage.

midnight spade
#

I might just learn to write shader code itself

#

Not sure if the graph approach is actually faster for me. In addition to not knowing how to fix problems like this I loose so much time lining up my nodes haha

violet sage
#

how would i make this plane not render over itself? (The darker parts should not be seen)

spark merlin
#

Eck, I'm trying to add Specular to an existing Shader. It won't import into Shader Graph for some reason, just doesn't show up. It's obviously not as simple as adding

_Glossiness ("Smoothness", Range(0,1)) = 0.5
sampler2D _MetallicGlossMap;
o.Smoothness = _Glossiness;

SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}

Is there a writeup I can review, or anyone know why it won't compile the Glossiness?

Shader error in 'Diffuse-Hue-Normal-Test': invalid subscript 'Smoothness' at line 60 (on d3d11)

cursive wraith
#

Hey guys, im trying to fix this issue but i cant

#

I have a universal rp

solar sinew
#

Is there a pipeline asset assigned in your settings

#

@cursive wraith

cursive wraith
#

i fixed the issue thanks

fluid peak
#

@lusty badger any noise in UV space will have a seam unless you setup the uv map so that the texture coordinates of the uv’s on one side of the seam exactly match the texture coordinates of the other side of the seam, and the texture itself is tiling. The only other option is using either an object space or world space coordinate system as the uv input to your nodes. Look at the “position” node set to world or object, may help?

plucky sapphire
#

Fellas, does anyone can think of a reason why a shader would run laggy in Editor mode, but smooth in Playtime?

strange nymph
#

how to make water

wanton saddle
#

is there a way to offset a color channel with the shader graph?

grand jolt
#

is there any good videos for learning shaders

amber saffron
# strange nymph how to make water

In this video, we'll take a look at how we can use the Shader Graph feature in Universal Render Pipeline, or URP for short, with Unity to create a water shader! The water shader can be simple or complex, and include the features you desire. Let your imagination get wild in this tutorial, or simply follow step-by-step to get about the same result...

▶ Play video
strange nymph
#

i understand already

amber saffron
amber saffron
grand jolt
#

ok thanks

wanton saddle
#

that's what I've got so far, but when I apply the alpha channel it only draws the shape of the sprite when I want 3 copies of the sprite's color channels instead

amber saffron
#

Ok, so what you need to do to make this effect, is to sample the texture 3 times with different UVs, and then recombine one different channel of each texture into a color

amber saffron
wanton saddle
#

okay I'll try that

#

I get this

amber saffron
#

Well, it does look like a similar pattern is copied 3 times for opacity.
Can you show a screenshot of the graph ?

wanton saddle
amber saffron
#

Well, there is a bit too much nodes to my taste (the combine+split pairs are not necessary) but it looks ok to me.
Maybe double check the alpha channel of your sprite?

wanton saddle
#

what am I looking out for?

amber saffron
#

If the alpha is actually correct.
Maybe try previewing the alpha of one of the samples ?
Or look into the sprite preview in the inspector

wanton saddle
#

looks fine to me

amber saffron
#

and the preview after the second maximum node (could you post a screen with the preview visible ) ?

wanton saddle
amber saffron
#

Well, the alpha is correct

wanton saddle
#

problem with the color channels?

amber saffron
#

Nope, the also seem good

#

So, the problem here is that the logic is correct, for spliting and recombining the channel.
But it's not "great" visually.
You need to define what is the final result you want to achieve (maybe make a mockup in photoshop or something like that) and identify how to get there.
Maybe you want the alpha to be affected by the weight of each individual channel ?

#

You could try, for each sample : alpha = X (the channel you want) /( R+G+B)
And combine the alphas after with add nodes instead of maximm

wanton saddle
#

I'll try it

#

that didn't work

#

I made this to demonstrate what I want to do

amber saffron
#

Ok I think I got it

#

And multiply the alpha or each sample with the corresponding color channel.

#

^ This gives you the color value to combine. Keep the alpha unchanged for alpha combining

wanton saddle
#

keep the alpha as it is with the maximum nodes?

amber saffron
#

yes

wanton saddle
#

it's working perfectly, thanks a bunch

#

I added some divide nodes (on the R and B channels) just before adding the alpha channels to the maximum nodes so that the red and blue copies are slightly transparent

#

actually, one more thing: can I make the shader display things outside of the sprite's bounds? so it doesn't get cut off like this:

amber saffron
#

No, a shader only draws where the mesh is.
But you can extend the mesh by using the position input of the master node. If you do this you'll need to "compensate" by also scaling the UVs, else the whole sprite will stretch.

wanton saddle
#

how do I scale the UVs?

amber saffron
#

Use the tiling value of the tiling and offset node.

#

But I guess you want the sprite to stay centered on the mesh, So you'll also have to add something to the offset to compensate : the 0,0 coord of the UVs is at bottom left, and you want to stretch from 0.5,0.5

wanton saddle
#

the sprite just disappears?

amber saffron
#

You probably made something wrong, should not happen 😄

wanton saddle
#

probably

#

what do I put into the vertex position of the master node?

amber saffron
#

If the pivot is centered on the sprite, you can put vertex position * scale

wanton saddle
#

how do I get the vertex position?

amber saffron
#

position node 🙂

wanton saddle
#

like this?

amber saffron
#

Yes, but no need to multiply the components individually

#

Just multiply the position with your "bounds size"

wanton saddle
#

oh I didn't know it could do vectors lol

#

and is this how I'm supposed to do the uv tiling?

amber saffron
#

Sort of

wanton saddle
#

what's wrong with it

amber saffron
#

Did you try and see ? 🙂

wanton saddle
#

well it breaks the shader but I'm not sure why lol

#

you told me to add 0.5

#

I subtracted 0.5 instead and it works a bit better now

amber saffron
#

Let me try it quickly on my side, I was juste visualizin in my head til now.
But you should offset with half of the tiling to keep the sprite centered (+ the additional channel offset)

wanton saddle
#

oh okay

sacred patio
#

Oh wow you guys are still going. I really didn't want to interrupt but I need to ask maybe some of you have water shader experience and could explain this error?

#

It makes no sense to me because I uses DepthFade for water and it was alright until I tried to link the refractions part

amber saffron
#

IDK why, but it seems that it can't find the sub graph ? Try deleting and re-adding the node ?

nocturne herald
#

Is there a way to modify the generated shader code for VFX Shader graphs?
I want to remove this line 😦

amber saffron
amber saffron
hasty wing
#

Hello guys

#

I am kinda new here so sorry for being dumb

#

In urp

#

When I in project

#

Click create shader

nocturne herald
hasty wing
#

I can't find the pbr graph thing

amber saffron
hasty wing
#

I am using 2020.something

#

Please help

wanton saddle
#

maybe you haven't imported the vfx graph? I think it's a urp requirement but I dunno

#

shader graph I mean

wanton saddle
amber saffron
wanton saddle
#

that is with an offset of 0 btw

amber saffron
sacred patio
amber saffron
#

I wonder if it's because of the Scene Depth node maybe not beeing supported in vertex stage (vertex position)

amber saffron
wanton saddle
#

how do I fix that?

amber saffron
#

Let me just fini my graph and I can show you

#

will be easier

wanton saddle
#

okay

sacred patio
amber saffron
#

I don't really want to dig in the source code right now, but if under the hood the scene depth node uses a TextureSample, then it just can't be used connected to vertex position

regal stag
sacred patio
sacred patio
amber saffron
regal stag
#

You should also make sure your WaterDepth property isn't 0 too. Both in the graph and inspector on the material

regal stag
amber saffron
#

IDK, I didn't even think about this right now 😅

sacred patio
regal stag
#

You also need to change the Scene Depth node to Eye, not Linear01

amber saffron
#

Looks like you had some misses in with the colors

wanton saddle
#

oh, oops

amber saffron
#

For each of the sampler, multiply the alpha with the mask (output of the minimums), use it for the final alpha + multiply with the color channel for combine

regal stag
# sacred patio Nope :/

Since you are lerping between the scene color and water colour based on the water colour's alpha, you might want to check what the alpha is set to on those water colour properties. In the graph they are defaulting to 0/255, but it's important what they are on the material too.

#

If they're 0 there too, it's only always going to show the result of the scene color

wanton saddle
#

the spaghetti is working, hooray!

#

thanks a ton @amber saffron ❤️

regal stag
#

Yes, those black bars under the colours represent the alpha value. They are currently both 0 which results in the lerp node only using the A input.

#

If you open the colour picker you should see a fourth alpha slider. Try changing it and it should change what you see in the scene

sacred patio
regal stag
fickle obsidian
#

How do I make an item not have any shadows on it

sacred patio
#

This is what I am trying to achieve

#

Wait...

#

Lmao

regal stag
#

@sacred patio You might want to check the values of your other properties on the material. I think you have the refraction strength at 0

sacred patio
#

Oh my god thank you Cyan, seemed like such a big deal to such a simple solution

sacred patio
regal stag
sacred patio
violet sage
#

How would i make this reflect light like this?

#

i want each face to be visible and not like blended

onyx delta
#

hi im trying to get shader forge to work with unity 2018,4 but the window just instatly disepears when i try opening it. anyone know how to fix this?

#

pleas i just want to make cool shaders with node graphs for vr chat

tidal heron
#

What is a shader?

onyx delta
#

its like a texture but you can apply louds of difrent effects on it

#

for axemple: make your object see throu. or slighly move

tidal heron
#

Thanks wolf :D

regal stag
tidal heron
#

Cyan is probably typing a long text

regal stag
#

It's a link to a tutorial I wrote, explaining what a shader is in more detail. It's free to read, you're welcome to search online for others but you did ask a question.

grand jolt
#

Hey,
i'm trying to recreate a specific VFX from "Devil May Cry 5 Special Edition". I've been trying to get it done for months now but can't seem to get the hang of it. Are there any experts/tutors willing to help me out with this? I'm also willing to pay for the help/lesson(s). I also tried to reaching out to unitys 1:1 live help but my request doesn't get answered. I'm familiar with Shader Graph/Particle System/VFX Graph. The effect is AAA worthy so i really need an expert on this topic. If anyone is interested in this "job" feel free to dm me on discord.

Greets!

Ps.: I know this might not be the right place to ask for this but i've tried looking for tutors or alikes online and couldn't find anyone/anything besides the unity 1:1 help sessions and i'm really really desperate with this effect by now.

sacred patio
fickle obsidian
#

How do I make a shader with emission and have it not get any shadows on it from itself and / or from other objects, I have done the first part but how do I do the second part?

lapis hearth
#

Can I create this in shader graph?

#

This is what I was able to achieve so far

#

@grand jolt simply for visual

misty flame
#

How do I set up shader graphs with the normal 3D template? Every tutorial I've looked at has PBR shaders and their steps to get to PBR shader graphs don't work so I'm tryna setup an empty shader graph but how am I supposed to get a master? Idk how I'm even supposed to set up a shader when there's no Master node.

#

The PBR shader graphs seem really nice to use but I don't have them and I have no clue how these shaders work and I can't find a single tutorial on them

regal stag
misty flame
regal stag
misty flame
#

Oh my bad thanks sorry

grand jolt
#

Hello, how do you guys deal with making a path along a floor? Say it has grass texture all over. How do you use a BW mask in unity to tell it where to apply the path texture?

#

Unity terrain is not an option for me.

fickle obsidian
#

Is it possible to have an object without any shadows on it?

distant swan
#

yes
there's a "receive shadows" checkbox on the meshrenderer component, even (though it's disabled if you're using deferred pipeline)

fickle obsidian
distant swan
#

ah gotcha, not too familiar with hdrp

amber saffron
sacred patio
#

Why is there no ARGBHalf format in my Unity 2019.4.19f?
If I am asking this in the right channel

amber saffron
sacred patio
amber saffron
#

Yes, kind of. Now the texture color format dropdown is much bigger and the namings have changed.
Can't remember well when.

sacred patio
#

Well they sound like the most random names to change to x)

amber saffron
#

That's subjective. I find them pretty descriptive and precise.

shell thorn
#

maybe anyone know, is any plans to replace those weird references by more readable names?

regal stag
amber saffron
#

Where did you find that ?

#

(+1 for Cyan answer)

regal stag
#

In v10+ the field is in the Node Settings tab of the Graph Inspector, when the property is selected

shell thorn
#

And it will be error prone?

#

Just, what the reason of this?

#

I mean, why they generate Ids when they can use Name property?

#

Name collision avoidance?

regal stag
#

You might not necessarily want the reference to be the same as the name used for display purposes I guess

#

Typically you also make the reference begin with "_" as it'll help avoid problems with using keywords that are important for Shaderlab + HLSL

shell thorn
shell thorn
#

It looks more logical for me.

regal stag
#

I believe the newer versions automatically test for those keywords and append a "_" for you

shell thorn
#

anyway I understand it as - they try to make those things more stable because of non advanced user have no huge experience and simply don't know what is a reference and name collisions.

sacred patio
#

Do you guys know why the camera isn't outputting only the particles even if both the camera and particles are on the same layer? Or am I not looking at the correct preview? (excuse million tabs)

regal stag
sacred patio
#

And should I see the output in the camera preview on the right down corner?

#

I see the tutorial uses the previous versions so hard to tell which parts are supposed to be different

regal stag
#

I think that preview should show the result yeah, or look at the RippleRender (render texture object) in your assets

swift loom
#

quick simple question, in the shaders is a 0 y position the top or bottom of an object?

regal stag
amber saffron
#

0 in object space is at the pivot of the object, and in world space, it's at the origin of the scene

swift loom
#

it's a 2D sprite, so does that mean the value can be -1 too if the pivot is centered?

amber saffron
#

Yes

swift loom
#

hmm alright good to know

amber saffron
#

Maybe even less. Depends on the size of the sprite.

regal stag
#

Sprites also tend to be batched, so object space isn't always a thing

swift loom
#

maybe even less? what does that mean?

#

i thought object space was always 0-1 (or -1-1 i guess)

regal stag
#

Not that familiar with how the sprite mesh is generated. But for 3D objects it can certainly be outside that range depending on the scale it was modelled at

swift loom
#

hmm my brain UnityChanShocked just realized my pos is in clip space as well so i'll have to read about that. Haven't been having any issues so far with my logic but it's not working right now lol.

#

but say a sprite has a pivot point at the bottom, that would make that 0 and the top 1 no?

#

i'm just worried my math is inverted

regal stag
#

The pivot would be 0, but not sure what the exact value of the top of the sprite would be.

#

Should be able to test it though, if you output the position as the colour

swift loom
#

yeah i'll try that

regal stag
#

Oh wait, even pivot might not be 0 if they're batched :\

swift loom
#

I don't think they're being batched as "saved by batching" is at 0

#

well thanks, i'll see if i can solve this thing 😫

swift loom
#

my pos value is most definitely not acting like i had imagined 😅 thanks for the drawing color idea.

crisp vessel
#

Hello, folks! First time here, trying to learn a bit about shaders. I was following some toon shaders tutorials (like this one https://blogs.unity3d.com/2019/07/31/custom-lighting-in-shader-graph-expanding-your-graphs-in-2019/ ) and when trying to implement a custom node to get Main Light and shadows in a unlit shader I encountered some problems. I think it might be some URP version issue, I'm using URP 10.3.2 and it keeps complaining that TransformWorldToShadowCoord is an undeclared identifier. Was that function deprecated? Am I missing something?

regal stag
crisp vessel
#

Oh... of course!

#

Classic silly mistake, doing things in a hurry

#

thank you!!

regal stag
#

I've also got some custom lighting functions (and subgraphs) that I use here, if interested : https://github.com/Cyanilux/URP_ShaderGraphCustomLighting.

You may encounter some problems with shadows in an unlit graph, as URP uses some special keywords to handle shadows properly, and the unlit graph doesn't define them. While you can define them in the blackboard it causes an error if Shadow Cascades is set to None/1, which is annoying but currently there isn't really a good way around it.

crisp vessel
#

Yeah, I saw your repo and your function worked, which made me even more confused on why the tutorial one wasn't lol

#

Thanks for the help!

sacred patio
#

To slide in with a similar topic.. I'm being a copy cat with this code but I am not sure with what names should I exchange the _GlobalEffectRR, is it the name of my particles? And in what format should the camera size be inputed? I see that the compiler is not really recognizing orthographicSize or position though, or is it just a bug

regal stag
sacred patio
#

And the size is also supposed to from Rendered Texture?

regal stag
#

The size is obtaining the orthographic size from the camera component, again sending it into a global shader property so it can be accessed through _OrthographicCamSize on the shader side.

#

Also looks like your visual studio isn't recognising any Unity stuff. Not sure how to fix that though, try restarting maybe. Might have to ask in one of the coding channels for help with that.

sacred patio
#

This size should be put in somewhere?

#

Oh and I probably need to modify my Visual studio, thank you for the reminder

regal stag
#

The script is obtaining the value in that field. That's what GetComponent<Camera>().orthographicSize is doing. It's then sending that value of 8 into the shader property _OrthographicCamSize, so shaders know the size of the camera.

sacred patio
#

Ohh.. so I don't need to change those. Since they were in quotation marks I thought they are names of some files the tutorial creator wants us to change

regal stag
#

No, they're just strings. It's just important that the shader side matches the same reference, to obtain the correct value.

sacred patio
#

But just to make sure, was I correct in changing the _GlobalEffectRT name into how my Render texture is called?

regal stag
#

What the string is doesn't really matter. It can be called anything. As I said, the shader side just needs to match. If it's shader graph, the "Reference" field in the blackboard / node settings needs the same string.

scarlet pulsar
#

I have shader which is transparent and receive shadows. Its attach to gameobject which converting to entity and after this conversation this entity doesn't receive shadows. Also using URP 8

sacred patio
#

Okay okay. For interactive water I only use particle system and rendering textures so probably no need to dig nodes for.. now. But yeah anything now will give me errors until I fix my visual studio anyway so I will see where the real issues are lingering. Thank you for the guidance

spark escarp
#

Hey ! i have little bit problem about one script and as i m learning i don't understand why he didn't get the import

#

i made a mistake ?

low lichen
#

@spark escarp What HDRP shader files are you #include-ing?

spark escarp
#

Oh i need to include ok ok
including HD_SHADOW_ALGORITHMS_INCLUDED
so #include "path/file"
#include "HDShadowAlgorithms.hlsl"
?

#

normaly i don't need to include ? because it's in the pipe no ?

copper comet
#

I have a problem trying to implement Variance Shadowmaps : I'm plugging myself with a command buffer in the AfterShadowMap event and I copy the depth value in a RGFloat texture _VarianceMap with Depth,depth*depth as the two values. Then I sample the texture in my shader by taking the worldpos of the fragment, puting it in shadowspace with unity_worldtoshadow[0], and doing the VSM calculation with shadowfragment.xy as uv, and shadowfragment.z as the fragment depth in shadowspace
I have this implementation handy https://github.com/gkjohnson/unity-custom-shadow-experiments and it works well BUT they use a custom camera that has the WHOLE scene in its frustum for the light rendering, and I want to use unity's default shadowmap to benefit from unity's light frustum calculation and culling.

#

im starting to thinkg unity_worldtoshadow[0] is not what i think it is

spark escarp
#

@low lichen if you have idea i get it ahah x)

spark escarp
#

I did that but no again

sacred patio
#

To which 2 nodes do you guys think this graph leads to x)

spark escarp
#

i don't know, need to learn ahah xD

#

btw you don't have idea for my problem ?

copper comet
#

if its unity internal cginc you might not need to give the full path no ?

#

just include lighting.hlsl ?

spark escarp
#

i m going to try it

#

😢

dusty creek
#

what?

spark escarp
#

?

dusty creek
#

what is wrong

spark escarp
#

after i found this

#

he find the HDShadowData

#

Actual Error

copper comet
#

you tried this : #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"

spark escarp
#

nop i m going

#

No don't find it

copper comet
#

wait its normal

spark escarp
#

ok

copper comet
#

same but "Packages/YOURRENDERPIPELINEVERSION/ShaderLibrary/Lighting.hlsl"

#

so com.unity.render-pipelin etc etc for your renderpipeline version

spark escarp
#

com.unity.render-pipelines.high-definition@10.2.2

#

?

copper comet
#

yeah

spark escarp
#

not work

copper comet
#

god

spark escarp
#

exactly god why its just a include xD

copper comet
#

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl ?

spark escarp
#

again not found it

copper comet
#

im at a loss

spark escarp
#

me in packages i have nothing np np its same for other people look (wait)

copper comet
#

you got all the RP files etc ?

spark escarp
#

look last 2 like and no response

#

yeah yeah its new HDRP project

#

btw thks for tried to help its cool 😄

spark escarp
#

GUYS ? 😢 😢

willow pike
#

Anyone know of a good way to create planar water reflections for orthographic cameras? I’m in urp.

alpine goblet
#

hey guys for some reason unity wont let me connect these 2 nodes, any help?

vocal narwhal
#

you're probably using one for fragment and one for vertex and it won't let you cross the line between the two. The top one is for the vertex shader I think you need to make a different sampler - maybe using Sample Tex2D Lod?

alpine goblet
#

Yeah it worked out as you said

#

thanks alot

spark escarp
viscid sandal
#

visual effect i am getting such a problem, what is the reason?

swift loom
#

How worried do I need to be about these? I'm doing some [loop] for-loops for raycasting in the shader but it runs fine right now at least.

wheat quail
#

Not sure whats changed but I started getting this error yesterday. Everything works fine but I'm not sure if I should be concerned.

alpine goblet
#

Is there anything close to a opacity mask in urp?

grand jolt
#

i kinda want to learn universal shader pipeline and start my game over uwu

swift loom
#

Are normal map Secondary Textures usable only in the URP??

midnight spade
#

Hey all, I have a mesh for a hex grid that should render certain hexes as transparent:

#

It works in general but does this when I look at it from an angle

#

I imagine that this has to do with the zbuffer drawing the lower tiles over the upper tiles but I don't know why it would do that

#

It doesn't do it when the shader is opaque. Why would it do this for a transparent shader?

#

apparently there is no depth buffer when you render transparent objects. This would explain it. Looking for a way to change that now.

thick fulcrum
#

the same technique can be applied to built in render

midnight spade
#

I could do that yeah

#

I'm also okay with just using multiply for the blend mode though

onyx veldt
midnight spade
#

I just don't see why I'd have to from a technical point of view. Why can't unity just render front faces on top of back faces like it does with opaque stuff?

onyx veldt
#

can i get help?

onyx veldt
#

hello?

bitter elm
#

Sorry for pinging you, but since you've helped me quite effectively last time I was hoping you might be able to get me out of trouble once more:

I am still using the same shader (this one: https://github.com/Unity-Technologies/ShaderGraph-Custom-Lighting/blob/master/Assets/Includes/CustomLighting.hlsl) but I upgraded the project version to 2020.2.6f1 and now the exact same node is giving me an error, therefore not rendering any lights. Is there a specific change I need to make in the setup or are there functions in the code that were somehow changed?

#

It says there's an invalid conditional expression in line 5 which is empty except an opening curly bracket, so I guess that's not where the problem lies...

onyx veldt
solar sinew
#

anyone running into this error?

Function `064e9950b72bcff44ab50bdd9291c87c` has varying implementations:

// dd2ed37648007a3f3fa75f3cceeca645
#include "Assets/Shaders/CustomHLSL/CustomLighting.hlsl"


UnityEditor.ShaderGraph.FunctionSource
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
#

the only mentions I see of this error are for much older versions of shader graph. I am using 10.2.2

regal stag
bitter elm
solar sinew
onyx veldt
regal stag
bitter elm
onyx veldt
#

how would i do that?

bitter elm
#

I don't know, but there are myriads of tutorials out there, it's a technique commonly used for ice shaders as well, so maybe google for that.

#

What's also a bit of an issue with your portals is that their brightness is much lower than it should be on the scene behind, maybe they're receiving shadows?

bitter elm
bitter elm
onyx veldt
bitter elm
#

I had apparently replaced one of the #ifndef, too

bitter elm
# onyx veldt i havn't been able to find a good one, can you link me one?

Here's a nice example: https://www.artstation.com/artwork/ngGlX
This one seems helpful (it has English subtitles in case you don't speak... I think it's Spanish? Portuguese?): https://youtu.be/_dZthyScKF8

ArtStation

Gumroad link: https://gum.co/dspvY
Slightly stylised ice shader i've done as a parallax practice. Textures created with Substance Designer, shader setup done in Unreal Engine 4.

Que tal JetGuys ! Somos Jettelly y en este capítulo crearemos un efecto hielo quebrado en Unity, utilizando HLSL y Unity URP (shader unity, vfx unity).

📁Descarga los archivos del proyecto: https://www.patreon.com/posts/unity-shader-ice-44742647

Te invitamos a nuestro Discord en donde podrás compartir con más desarrolladores sobre VFX, Shaders ...

▶ Play video
#

But there'S little other than googling like a maniac to find more

#

You can btw also look for Unreal-tutorials, since the logic in these shaders is quite similar. You will however have to adapt a little bit if the same nodes aren't available out of the box.

regal stag
bitter elm
#

Okay, will do!

bitter elm
# onyx veldt i havn't been able to find a good one, can you link me one?

This one might also be interesting, but I think he uses a couple of custom functions: https://www.youtube.com/watch?v=LKhGqKYOmbo&t=159s

This is a tutorial on using the Parallax Mapping in Unity Shader Graph

Checkout my new Floating Islands Asset:
https://bit.ly/lwrp-floating-insland

Checkout my assets if you want more Tuts!
LWRP Material Pack Vol 1: https://bit.ly/lwrp-materials
LWRP Material Pack Vol 2: https://bit.ly/lwrp-materials-2
LWRP Material Pack Vol 3: https://bit.ly/...

▶ Play video
onyx veldt
#

kk

bitter elm
#

One more question tho: How come I sometimes can and sometimes can't plug the output of one node into another node, even if their format seems to be identical (both for example being Vector3)?

#

It seems a bit like the tool is trying to tell me something but doesn't say it out loud in a rather passive aggressive way^^

regal stag
bitter elm
#

So it's really just about which output they go to eventually?

regal stag
#

Yeah, that should be the only reason why two nodes of the same data type won't connect.

solar sinew
# onyx veldt kk

I'm pretty positive there are built-in parallax mapping nodes now

bitter elm
#

Could someone explain how this happens and how to fix it? MAthematically I'm pretty sure it makes sense and it's probably easy enough to fix if you know how to, but I can't figure it out rn.

What I'm intending to do is using a normal map on a toon shader to add more surface detail, nothing particularly special, I guess, but the result there is kinda inverted, direction wise, and I don't think rotating the whole thing would really help me to any degree...

#

Nevermind, adding instead of multiplying seems to be the solution...

regal stag
#

Well, that's assuming it's a proper normal map, not too sure looking at the preview

bitter elm
#

It's a normal map, setting the texture sample settings to Normals makes the hue go really blue for some reason.

solar sinew
bitter elm
#

Nope it wasn't, but that didn't make any visible changes. However I do really like the effect I'm getting now, so no problem.

bitter elm
#

What is kind of a problem is that the shadow attenuation in the custom function doesn't seem to do its job... I am getting a solid white out of it, not exactly what I'd call a drop shadow^^''

wheat quail
#

does this error make sense to anyone? clicking on it bring me to the universal render pipeline script.

grand jolt
#

does anyone know what this shader is from?

#

Decal/particle decalsilent

mossy cobalt
#

Hey shader n00b here. How might one go about making an unlit shader that inherits brightness/color from lights? Currently, too bright looks odd in the dark and vice versa. Basically the subject will be moving in and out of well-lit and shadowy locations and it should match the surroundings, but I don't know how I might execute that.

mossy cobalt
#

From looking into it this seems to be a genuinely difficult thing to accomplish

#

Would looking into particle shaders be the correct route?

shadow locust
reef glacier
#

having some very strange results here - not sure if this belongs in #archived-shaders or in #archived-hdrp

regardless, I am attempting to do what I know would be quite simple if I was just using raw OpenGL, so the struggles are perplexing, to say the least.

I want to use vertex colors, rather than textures - my understanding is that the particle shaders are the two shaders that support this. however, if I attempt to use the lit variant, rather than the unlit one, it falls apart, even in circumstances where a regular, non-vertex-color rendering shader works without issue. in this shot, for example, you can see the directional light, the correctly shaded object, and the failing shader in question - i have however, found a fix. (cont)

#

this setting lets me tweak it to look as intended - that said, i don't understand why it is functionining in this way

#

the asset in question looks like this when i tweak that HDR button

#

what I would like to learn is what is actually happening under the hood, and if the shader is at fault because I am using it wrong - i can't find any information about vertex coloration, since it is apparently quite uncommon to use it. advice?

#

i presume the answer is that I should be using a custom shader, but I don't actually know shader code, so i haven't had much success writing such a shader

#

(also, even now im pretty sure its not working correctly, it is partially transparent, or at the very least, blending with the background, seen here - the skybox is painting the color of the tower)

spark escarp
grand jolt
#

@onyx veldt are you using shader graph?

onyx veldt
#

no

grand jolt
#

ok, nvm then, I had a subgraph for parallaxing

#

unless you want it so you can rip the code out of it

#

@onyx veldt

patent goblet
teal breach
#

Hey @patent goblet , in what way doesn't it work? what do you see versus what do you expect?

patent goblet
#

i see a fully opaque shape

#

it should be translucent

teal breach
#

I see the shader specifies the transparent queue, is that also how the material is set up?

patent goblet
#

yup

teal breach
#

I got a clip space question for ortho versus perspective - I understand both projections use different values for depth in the depth buffer, eg perspective is logarithmic and ortho is linear depth (between near and far planes). Is that also the case in clip space? or is the transformation made at some intermediate step?

#

to rephrase - if I have my world space -> clip space transform for ortho and perspective, and I multiple a world space vector, what value should I expect in the transformed z?

#

@patent goblet what are you testing that it blends with? an opaque object?

patent goblet
teal breach
#

When you test to see if it is opaque or transparent, you must be rendering it in a scene with some other stuff - what is that other stuff? eg, render it next to a sphere with an opaque material

patent goblet
mossy cobalt
#

Every spot on the subject relieves the same amount of light.

#

The way it's done in this image is to use volumes, but I'm wondering if this is possible to do with actual lighting

peak gyro
#

Hey guys any idea how to have a rounded rectangle mask that scales itself with the object? Right tnow the x and y part of the rounded corners are different because my quad is scaled in X.

teal breach
#

I think you want something like 'nine slicing'

peak gyro
#

I can't use sprites tho :/

fickle obsidian
#

Is it possible to create a shader in PBR graph that has sand ripples on it as a 3D thing not just as a ripple texture on the shader?

hushed sluice
#

why is my paint texture painting in pixels?

somber bolt
#
Udemy

Learn to program the graphics pipeline in Unity for creating unique visual surfaces for game objects.

Udemy

Harness the power of the GPU

Udemy

Make your game look unique through image effects, shaders and custom lighting by learning Unity's ShaderLab language.

Udemy

A complete guide to Unity ShaderLab and the Cg Shading Language

Udemy

Shader Graph or: How I Learned to Stop Worrying and Create Stunning Visual Effects in Unity3D

distant pawn
#

I am trying to connect the node arrangement bellow into the Master node's normal input but it isn't letting me. I assume it has something to do with the coord space I am using, so I've tried setting all the node's Space enums to Object but that doesn't work. What is the correct way of doing this?

regal stag
distant pawn
#

was wondering what that did. thanks o7

alpine goblet
#

Hey guys i need some help, trying to do some basic reflections, so far it does a static reflection but not like how a mirror would work (when i move or look in another direction).

toxic anvil
#

nice!!

thick fulcrum
thick fulcrum
# alpine goblet Hey guys i need some help, trying to do some basic reflections, so far it does ...

if you looking for mirror type of reflections (flat surface, water / floor) then you need to lookup planar reflections there are a few examples around. Basically it's using another camera to render the reflected direction, so hence is costly. While you can sacrifice quality for speed it will never be as cheap as a cubemap pre-baked reflections, which are ideal for non-flat complicated surfaces imo.

grave valve
#

hey guys can anybody help me work out why my camera is having this kind of clipping effect when close to my water shader? image 1 is how it should look all the time and image 2 shows clipping

dim island
#

Guys,
Can you please help to understand the changes between 2020.1.1f1 version and latest 2020.2f7 ?
I just upgraded my project and colors changed.. please advise where to dig to revert the changes using newest version?
Please look on these screenshots before (dark) and after (a lot of blue).

echo solstice
#

What's wrong with this?

thick fulcrum
#

no one in their right mind is going to download that to look, use pastbin site or similar to show code

echo solstice
#

Ooooooooo

#

It's too huge

#

30MB

thick fulcrum
#

then just describe what is wrong / relevant error's etc. perhaps someone can assist

alpine goblet
signal rapids
#

Hey! I'm trying out the new hair shader. It has something called Light Facing Normal, which makes the normals of the mesh face the light at all times. But what light? The main directional light, like in URP? Or is it somehow facing all the lights?

Also, is this a feature that exists in other engines, say Unreal, if I'd want to recreate the shader there?

somber bolt
signal rapids
heavy pebble
#

Trying to clip part of an object based on position by computing the dot product, but this doesn't seem to do anything. Can anyone explain why?

regal stag
proper cradle
#

hello , i want share an uv map for multiples GameObject

#

i do this but its a little weird

#

so i figure out , the issue is the uv rotation

#

so i solve this

#

now its like this

#

its my shader

#

the top is for turning the gameObject

#

and the bottom is for resize the uv for each cube i have

#

but i have some cube with bad color

#

if you look, the green should not be there

#

Some one can explain why ?

#

I think it because of the Tile variable

#

but i dont know why ^^

#

help me to figure out please

#

Or just explain me how the flipbook node work

#

but please help haha

proper cradle
#

Someone can explain me the tile Input

regal stag
# proper cradle Or just explain me how the flipbook node work

The Flipbook nodes selects a portion of the UVs. I think it's mainly intended for things like sprite sheets, where you store multiple frames of a animation in each tile of a texture and use the flipbook to play through that animation by increasing the Tile input.

uncut flicker
#

hi! sorry for asking such a trivial question but I've been struggling with this all the morning >__<' I am creating an unlit sprite shader, and I want to create a nice color gradient, but I can't figure out how to know the position of the pixel that is currently being rendered D: I've tried everything T_T, in this case, I'll get this error: undeclared identifier 'screenPos' at line 895, so I guess I can't use screenPos there... but then, how? plz halp @.@

proper cradle
#

Yeah... But that can help me to make a animated floor in a grid based game

#

I can make that if i want

#

but its broke at some part

regal stag
uncut flicker
#

thanks for the help! but I got this error now invalid subscript 'ScreenPosition' at line 895 it seems like SurfaceDescriptionInputs doesn't have that info... I tried using the graph and I managed to get the gradient with this 4 bad boys... but then I wanted to input a different gradient color for the bottom, and another different gradient color for the top (it's hard to explain... but basically I want to be able to make a sky in which, when it's 6AM, it dawns with a red->orange color, but in the top blueish... and then it switches to full blue)

#

so I switched to code to have a better control... but I can't find the documentation of SurfaceDescriptionInputs ^^' and I found several ways on accessing the position of the pixel, but none of those work... probably because I am writing my code on SurfaceDescription and not on "frag"... but, as you can see, I am totally lost by now hahaha

#

oh sorry, didn't answer the first question... yeah, it's generated from this one

regal stag
# uncut flicker thanks for the help! but I got this error now `invalid subscript 'ScreenPosition...

Right okay. I'm finding it a little strange to use the Position node here, and by taking the yellow (3) output and putting it into the Time (1) input it's truncating the vector value, which means it's only taking the X axis into account here. I'm not sure if that's what you intended or not, but a Split node could be obtained to get a different axis. G being the vertical part.

Personally with sprites I'd suggest using the UVs / texture coordinates instead, unless you're using multiple sprites for this sky perhaps?
Again they can be split to obtain each axis. (only R and G is really used). If you just need a two-colour gradient, you could also use a Lerp node to interpolate between two colours, e.g.

#

If you changed those Color nodes for properties you could also control them from a C# script to animate the day-night cycle

uncut flicker
#

omg, that's awesome... and for the gradient on the bottom, I could use that SampleGradient node... I didn't know about that Split node hahaha thanks a million times! I am going to try to implement it that way

uncut flicker
uncut flicker
#

it worked like a charm, thanks a lot! one more thing... do you know how to get this properties from script? I read on the forums that you have to write Vector1_1efaa5c...... is there a way to write it just like Daytime?

regal stag
uncut flicker
#

thanks a lot! my code looks cleaner now

grand jolt
#

Is it possible to get the average color of a texture using a shader, and expose it as a read only property to unity scripts?

stark condor
#

This shader shows up as the bright pink "Error Shader" whenever I use, does anyone know why?

fickle obsidian
#

Can I have a hdrp/lit and PBR graph at the same time, I'm trying to make a materialized texture shader, but I don't know where I can change the transparency of the shader

grand jolt
#

I'm trying to get Shader Graph to work in VFX Graph as a Lit Particle, but I keep getting this error. But ever sense they changed Shader Graph the Lit VFX Master node no longer exists, so I assume it has to deal with switching it to Lit in the material type in Graph inspector. But I can't seem to get it to work.

cinder forge
#

I am using stencil in shaders to draw a road on top of a terrain but now I have this issue :
A road behind a hill will be drawn on top of (i.e. show through) the hill.
How to prevent that ? 🤔

regal stag
grand jolt
#

Ahh yeah hitting save made it work 🙂 Ty 😄

#

Hmm. I wonder why they removed distortion from Shader Graph for VFX Graph. I used it in the past, hmmm.

#

Even as a regular HDRP Shader it's just grayed out. Can't click and drag to create a node for it, etc.

regal stag
#

Oh, and I don't think Shader Graph had distortion for VFX Graph. VFX Graph just has an Output Distortion block that you might have used previously.

fickle obsidian
#

Is it possible to put noise texture and height texture into pbr graph

#

and make the shader look more realistic

grand jolt
#

FOUND IT

regal stag
# fickle obsidian Is it possible to put noise texture and height texture into pbr graph

Heightmaps use parallax mapping, which offsets the UV coordinates. If you're in Shader Graph v10.1+ there's a Parallax Mapping node. Whenever you use a Sample Texture 2D you'd use the UVs from that node.
Or there's Parallax Occlusion Mapping which is more expensive.
You can also sample noise textures but it's up to you how you combine it into the other inputs like albedo/base colour, metallic, smoothness etc.

grand jolt
#

Thank you @regal stag

fickle obsidian
#

Thank you

mossy cobalt
#

can anyone give me some direction on how I'd change a custom shader from blended alpha to cutout/clip alpha?

#

The character's hair shouldn't be translucent, just opaque with some regions of clipped transparency

#

The code isn't crazy long, but I still can't really decipher what I should be changing -- I've looked around on the internet for the last hour or so but I can't figure it out

#

I've messed around with alpha:fade changing it to alphatest:something but Unity's documentation isn't exactly clear on what exactly goes after the colon

#

Well, to be more precise, I don't really know how to do what Unity suggests I do, haha

outer shuttle
#

Guys, i have a simple waves shader that moves vertex (made in Shader Graph, i'm quite new to shaders actually). Now, i have a C# script that needs to know the y position of the wave at a certain world position. Is there any way to do that?

fickle obsidian
#

How do I fix this?

#

When you have a solution or overall something to say to me the @ me

lapis grove
#

@regal stag I've been bookmarking your tutorials because I read the "Intro to Shaders" one and thought it was well written, and Shaders are the next thing I plan to start learning in the near future. But, I'm just noticing most of your posts are tagged URP. Are they still going to be applicable to me if I'm using HDRP?

swift loom
#

Any way I can copy a nearby already altered pixels values into the current one in the shader? I don't think just tex2D _MainTex works?

#

maybe i can pass it to the next pixel via property? 🤔

regal stag
# lapis grove <@!357936113983291393> I've been bookmarking your tutorials because I read the "...

They should still be useful but some things may need changing slightly for HDRP. Shader Graph has a few differences in HDRP, like the View Direction node is normalised automatically, and World space is relative to the camera position (https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@10.3/manual/Camera-Relative-Rendering.html). Any custom lighting functions I use won't work in HDRP too.

lapis grove
#

Ok, so it sounds like they'll mostly be applicable.

#

I'm particularly interested in the force field one because I have a character that uses one 🙂

eager folio
hushed sluice
#

guys why is the height map not really showing? it's just creating an illusion within the object

amber saffron
hexed surge
#

I'm making a map mesh generator that won't need elevation for the gameplay. So the ground is just a flat grid. But I do need to render bodies of water so they look nice.
I'm a total noob when it comes to shaders, is it possible to make a flat mesh look like pretty lakes with shaders ? Specifically to make it look like it has depth, with coasts going down and disappearing in water and waves hitting the coast.

#

Or will it be easier to just generate mesh that has "seabeds" ?

amber saffron
#

It's possible with a flat plane an purely in shader, but it will be way easier with a "ground" mesh + water plane.

hexed surge
#

thank you 👍

lapis hearth
fallen cypress
#

Can someone convert this CG shder to URP

lapis hearth
#

@fallen cypress wait can you convert shaders?

fallen cypress
#

es

#

yes

#

but idk how the manual tool doesn't work it's not compilcated shadrt it won't take time

lapis hearth
#

@fallen cypress do you know how I can create a urp shader?

fallen cypress
#

you mean shadergaph ?

lapis hearth
#

no the custom ones

fallen cypress
#

shadergraph can generate shader which is basically the standard shaders ( HSLS) idk if unity cg is compatible or not but some people convert it easily , i'm not pro at shaders but some basic stuff

#

I think the automatic upgrading doesn't work sometomes because some snippet of the codes use unity.cg light model but you can replace it

#

i'm trying this but it doesn't work

regal stag
#

The automatic converting only works on upgrading unity's built in materials/shaders. e.g. the Standard shader to the URP/Lit shader. It doesn't convert custom shaders.

fallen cypress
#

I just want this Silhouette-Outlined shader lul

regal stag
amber saffron
lapis hearth
#

I followed a tutorial and ended up with this

#

the bad thing is that is looks like shit

#

@amber saffron will try it

amber saffron
cinder forge
#

I am using stencils in shaders to prevent terrain from poking through roads, but now I have this issue :
A road behind a hill will be drawn on top of (i.e. show through) the hill.
How to prevent that ? 🤔

lapis hearth
#

Can I make a terrain material using shader graph

lapis hearth
#

@amber saffron How would I affect the tiling size?

#

oh nvm

violet sage
#

Why wont this change the color of the texture

fickle obsidian
#

Is it impossible to make a toon shader with only a PBR graph and textures?

thick fulcrum
fickle obsidian
thick fulcrum
#

but that's not to say there are not things which can be done

#

🤔 I more think of URP when considering toon type of styling, HDRP lends itself to be more photorealistic

fickle obsidian
thick fulcrum
#

while there is some steps towards making it easier to have a project which could use both, practically the two are still miles apart. espeically when it comes to lighting and setting up of the scene.
I suspect it would be a lot of work to do both, but if you have a capable team go for it. However I would try to make the core of the game work in one before looking to develop the other.

fickle obsidian
#

got it, I'll try the toon in the future then, when I have finished my first project

amber saffron
# thick fulcrum 🤔 I more think of URP when considering toon type of styling, HDRP lends itself ...

@fickle obsidian Toon and HDRP can live together : https://www.youtube.com/watch?v=WAIqvnaV3uI

This is the improved one and rendered at 8k UHD at 24 FPS.
The whole scene or project is in HDRP - DXR/Ray Tracing mode.
The environment and the character uses RealToon HDRP.
All are real time, not bake.

This is fully Ray Traced GI, Shadow and Reflection at Quality mode.

The character and some objects on the scene uses the upcoming Screen Spac...

▶ Play video
keen anvil
#

I made this water shader in shader graph

#

It has procedural refractions

#

you can edit every property of the shader within the material

#

and each setting is per material

#

so you can use it for any liquid without editing the actual shader

#

It runs on the universal render pipeline

violet sage
#

how should i make the white dot more transparent without the background turning wierdly red like the subtract thing i tried earlier

#

i wanna make it more see through

#

please help

regal stag
violet sage
#

i just subtracted and clamped it

#

because Biiiiig brain

glossy matrix
#

whats the inverse of this node?

#

cant seem to find it ;-;

regal stag
glossy matrix
#

oh i looked at split -- thought it was for vector4

#

thx!

glossy matrix
#

so i have this basic node setup for trying to recreate the transform gizmo -- essentially when looking directly it becomes transparent.

it works to some extent, only in one direction of the axis (so for x axis, it will only work when looking in direction X, not (negative) -X)

low lichen
#

I'd use a Dot for this. Get the X direction of the object by transforming the vector (1, 0, 0) from object to world space, get the dot product of that and the direction from the camera to the object, get the Absolute value of that, One Minus to invert it and use that as the alpha.

glossy matrix
#

sorry back -- took a lil break and remembered came across a similar issue in my program, so i take the same val and clamp it to get a -1 or 1,

then multiply that back in

glossy matrix
#

came across a bit of an issue -- how would i get that alpha data and pass it into c#?
lets say i dont want my gizmo to be intractable below 0.25 alpha val. .

simple violet
#

I heard using setfloat() is slow. Is that true?
Like if I want a value to change should I not do it through script and instead use sine waves?

grand jolt
#

I think this is where I should be with help.

#

I'm using free tecture packer.

#

This is what my texture project looks like.

#

These are the settings.

#

My unity project is in 2D, but there's no 2D option.

#

The marbles spawn in with a few missing in empty cells, and when they do spawn they have all this digital chaff around them.

#

Any idea on how to fix this?

#

The animation sheet comes in like this on unity.

somber bolt
grand jolt
#

I'll be back after dinner, @ me.

solar sinew
glossy matrix
#

ah thx -- also i did try getting it from the material, but that seems to return the alpha val i set to the color property, which doesnt correlate to any changes made by the shader

#

(my other option would be to try and perform the same calculations as the shader in a c# script, and pass the alpha val into a dumb shader -- that way i can retain the end copy on the cpu

from my research, it is possible to transfer data back to the cpu, but its quiet slow. . for what ever thats worth)

solar sinew
#

have you tried setting the material as addressable?

glossy matrix
solar sinew
#

wait hold on

#

also just checking but did you try material.color? Also if you didn't know, you can rename the color property to something easier to remember in the blackboard or property inspector depending on the version of sg you are using

glossy matrix
grand jolt
#

Am I in the right channel for my issue?

solar sinew
#

By default, Unity considers a color with the property name name "_Color" to be the main color. Use the [MainColor] ShaderLab Properties attribute to make Unity consider a color with a different property name to be the main color.

This is the same as calling GetColor or SetColor with the property name of the main color as a parameter.

glossy matrix
#

ah i see, adding [MainColor] to the name would let unity think its the main color. .

solar sinew
#

it's just semantics since it does the same as GetColor and SetColor but useful to know

glossy matrix
#

mhm,

glossy matrix
#

well, no idea if it works -- that should do everything the shader graph did as c# code welp -- guess theres only one way to find out. . .

glossy matrix
#

thx for the help! everything seems to be working as i had wanted with the c# variant of the script, (realised I can use maths.sign instead of clamp)

simple violet
#

I heard using setfloat() is slow. Is that true?
Like if I want a value to change should I not do it through script and instead use sine waves?

mental lake
#

This Z-test used to work until I updated to URP 10.2.2. It doesn't seem to do anything anymore. Does anyone know why?

eager folio
#

@mental lake you're using a camera with depth enabled?

mental lake
#

Yeah depth is enabled

waxen wind
#

this might be a bit of a stretch, but doesn't anyone know of a Triplanar shader which supports vertex color height blending

loud remnant
#

Any good free shaders/examples? I want to have some example shaders for realistic graphics and limited hardware.

regal gorge
#

How I can write custom shader for Terrain and still have texture painting functionality?

I managed to create Holes, but I dont understand how layers work. I created simple nodes to handle 4 layers, but how introduce more?

#

I have only _Splat0, to _Splat3 available.

#

So I dont understand how I can add 5 layer.

light belfry
#

Can somebody help me how to make my 3d materials not stretch when I scale the object?

desert orbit
#

That would be possible only with world space projection. Or you'd have to compensate UV detecting specific direction.

light belfry
#

umm... ok

#

thanks

turbid holly
#

@light belfry The thing is: "what does it mean to not stretch?" For a cube with a repeating texture, I can think of an answer. But a textured sphere, like an earth globe, what does 'not stretching' mean?

light belfry
#

yes I want to make a repeating texture

turbid holly
#

For cubes, or things that roughly look like a cube, you could look up a tutorial on triplanar mapping/projection in Unity

light belfry
#

ok thank you @turbid holly

stark condor
#

Quick question, is the best way to reference a shader graph shader to turn it into code and use shader reference?

#

Or just use Shader.Find

keen anvil
#

Does anyone know how to fix the inside of the object with the shader being opaque

#

it's a double sided transparent shader

#

in shader graph

#

URP

regal stag
# keen anvil

You are using Fresnel Effect right? It returns 1 as those faces have normals facing away from the view dir. You can use a Is Front Face node a Branch to set the values to 0 for back faces to fix that.

sly breach
#

how can i partially scale a range ?

#

for example

#

that left portion i want to change its value so it would go like 0 to 0.8 and because its already tiled it would go [ 0 -> 0.8 ] towards 50% ( since its 2x tiled ) and from 50% to 100% it would go zero to 0.8 again

#

any ideas ?

cunning remnant
#

✔️ Works in 2020.1 ➕ 2020.2 🩹 Fixes for 2020.2:
► When you create a shader graph, set the material setting in the graph inspector to "Lit"
► "Albedo" has been renamed "base color" in the master stack
► Editing properties must be done in the graph inspector instead of the blackboard

Grass rendering is a challenging problem in many games. One way...

▶ Play video
#

I want to follow the tutorial but for HDRP. But Instead of placing it randomly, I want to place it randomly on a splat map. Do you know how this could be accomplished?

sly breach
#

ok nvm i found it

#

there is that node called fraction

dull lintel
#

Hey everyone. I've got a lot of sprites drawn on very simple 2-triangle planes that I generate procedurally to the dimensions of the sprite and reuse wherever possible (so multiple instances of the same sprite use the same once-generated mesh). I'd like to dynamically recolor these sprites using a shader and a mask texture, say for team colors. So far I have two options:

  1. I can set vertex colors on the generated meshes, which are then read by the material rendering the sprite on the plane. This means less mesh reuse, especially with lots of different recoloring options, but the material properties are unchanged when setting the pass.

  2. I can set a MaterialPropertyBlock for the material with the picked colors I want (red helmet, blue shield, etc.) on that particular sprite, and all of those like it.

Anyone have any thoughts on which of the two would be better and more performant? Any advice if I go down one route or the other? If it matters, this is with the #archived-dots HybridRenderer, which is also why I'm not using much of Unity's 2d tools.

keen anvil
regal stag
lost kernel
#

anyone has an idea how i can find out if the normal of an direction faces directly to the camera ? i think it's the dot product but how do i get the camera direction vector?

#

oh maybe i just found, float3 viewDir = UNITY_MATRIX_IT_MV[2].xyz; , trying

grand jolt
#

Alright are there any shader gurus on that could perhaps help me out in solving something?

#

I am challenging myself to make a pixelated custom lighting shader, such that lights attenuate in a pixelated style like this:

#

I have the basic custom lighting shader set up, but I have no idea how I would approach this

#

I've done tons of research and there seems to not be very much documentation on this specific problem

#

The image I posted above is faked using a light cookie, but the thread I found it in said it should be more than possible to create this with a shader

#

I also did find something similar on Twitter here:

#

I did notice the "pixels" distorting at weird angles in this example, but regardless it's still a really cool effect

#

I'd love to try and figure it out if anyone wouldn't mind giving me some pointers

#

And here's another example from the same person

#

Most custom lighting shaders just seem to be generic toon shaders but I want to try my hands at something more complicated

low lichen
#

@grand jolt I'm trying to make sense of what space those pixels are in in those gifs. They seem weirdly both UV and screen space.

grand jolt
#

The buoy one kind of throws me for a loop

#

tbh I'd be fine even getting the first pic I sent

#

I'm not sure what I should be trying to mess with, my first thought would be the lighting attenuation

#

but it seems like all my results of messing around with it have just yielding either changing its color or falloff intensity

#

I also use Amplify to create my shaders but the logic would still be the same

lost kernel
#

guys ... what do i have to do to pass an float variable from geometry to frag in urp?

regal stag
grand jolt
#

Hold on lemme check it out

#

ohh huh

#

okay I'm going to need a bit

#

That additional lights is a custom function right?

#

Amplify doesn't seem to have anything like that to my knowledge

regal stag
#

Yeah, it was taken directly from the article

#

I think amplify has "custom expression" or something. That function code will only function in URP though.

grand jolt
#

Oh really?

#

hmm

#

Why would this not work in other pipelines?

#

I'm on LWRP pretty sure

#

I forget how to check

#

But I know I am not on HDRP and SRP

regal stag
#

Should be able to check which pipeline you're on via Edit > Project Settings

#

Under the Graphics tab

#

If you're on LWRP that should be fine too. LWRP was renamed to URP, they are the same

grand jolt
#

O.o

#

I feel like that shouldn't be empty lol

regal stag
#

If no asset is assigned, it should be the Built-in RP

grand jolt
#

Is that not URP?

#

or is it the same thing

#

Sorry there's so many pipelines and I keep getting them mixed up

regal stag
#

No, Built-in RP is like what Unity was before the additional pipelines was introduced. LWRP/URP is different.

grand jolt
#

Oh damn

#

I still feel like I should be able to replicate this with Amplify

#

don't know why I wouldn't be able to

#

This is the gist of the shader so far

#

very basic

#

I'm wondering if I'd just replace the Light Attenuation node with the logic you posted earlier

#

Oh wait

#

no

#

hold on

#

Let me try something

regal stag
#

Hmm I imagine you'd have to replicate what the light attenuation node does... I'm not too sure on the exact function used though

grand jolt
#

Yeah there's no documentation on it

grand jolt
#

Well

#

I did read that

#

but I meant the documentation is sparse

#

sorry

low lichen
#

Looks like it's just the thing that calculates the NdotL lambert lighting

#

And also the distance and shadow falloff

somber bolt
#

Any shadergraph users find that double clicking the .shadergraph files sometimes doesn't open the shader editor? The only solution I've found was to use Package Manage t completely uninstall both URP and Shadergraph, then reinstall both. PITA!

grand jolt
#

Just for testing's sake

#

i tried swapping this out

#

So normally it looks like this

#

with that swap

#

it goes to this

#

Which is kind of the pixelated look i want but obviously its not fully correct

low lichen
#

Directional lights don't use the object's position at all

#

It's the dot product of the light direction and the normal of the object

grand jolt
#

Ohh

low lichen
#

I guess you could try rounding the normal direction, but I don't know if that will give you square pixels

grand jolt
#

interesting

#

lets see if my gif loads

#

I can't tell if this is correct or not lol

#

There's some weird banding

#

You do have the exact same banding in your image too though

#

hmm

regal stag
regal stag
regal stag
low lichen
#

I was thinking you could round some triplanar UVs maybe

grand jolt
#

Ohhh

grand jolt
#

Look at the way it kind of bends

#

would that be some sort of triplanar shenanigans?

regal stag
#

Triplanar wouldn't really bend, I don't know how Lettier is doing their effect

grand jolt
#

Hmm

#

I'm also trying to get point lights to work with this effect still

regal stag
#

Actually, I think Lettier might just be doing the rounding thing on the normal vector

grand jolt
#

The normal vector?

regal stag
grand jolt
#

That looks familiar

#

What does it looks like on a sphere or cylinder?

#

Also thank you for helping me out

regal stag
#

This is the graph, It's the N Dot L that's used for directional lighting but the normal vector is rounded, similar to before

grand jolt
#

Does this work with point lights?

#

or just directional

low lichen
#

It should work. It's the same logic for point lights, except the direction is the direction from the light to the fragment position and you also apply a distance falloff

grand jolt
#

That vec3 at the bottom is confusing me

#

what is it exactly?

low lichen
#

Though I'm not sure if you can round the distance falloff in exactly the same way

grand jolt
#

It looks like just a bunch of random numbers

regal stag
#

It's the light dir, I just hardcoded it sorry

grand jolt
#

Oh LOL

#

oh ok

regal stag
#

Just easier to test with numbers in the graph 😛

grand jolt
#

Isnt this the same?

#

(my world space light dir is normalized, its an option in the node)

regal stag
#

Looks the same yeah

grand jolt
#

Weird

#

I dont get that result

regal stag
#

The cube mesh I was using also has smoothed normals which seems to be a requirement for this method

grand jolt
#

ohh

#

that would make a huge difference

#

Should polygonal density affect the amount of pixels you see on the shader?

regal stag
#

Don't think so, just the normals are important

grand jolt
#

Alright

#

Okay so in that case, all I need to figure out is how to get this working with point lights

#

what I've tried so far hasn't worked

#

I'd just have to recreate the light attenuation node manually and round it as well correct?

regal stag
#

Well idk, this rounded N Dot L might work for point lights too. As MentallyStable mentioned they use it too, it's just the light direction is based on the fragment position too.

low lichen
#

But it will be harder to pixelate the distance attenuation. That just uses position, not normal. Rounding that won't lead to the same pixels in the same place

#

So you'd get faintly overlapping pixels in different spaces

grand jolt
#

Which would probably look offputting

low lichen
#

But you might not have to

regal stag
#

Hmm yeah, maybe it would look okay without the distance attenuation rounded

#

And just the normal rounded part

grand jolt
#

So how do you calculate light attenuation normal if I weren't to do any of this rounding stuff?

#

Is it world normal • world space light pos?

low lichen
#

No, world normal • direction from light pos to fragment pos

grand jolt
#

Uhh hmm

low lichen
#

(fragment pos - light pos) normalized

grand jolt
#

Lemme google how to actually calculate the second part of that in amplify

#

because theres no fragment pos in amplify

low lichen
#

It's probably just called Position, same as Shader Graph

grand jolt
#

world position?

low lichen
#

Yes

grand jolt
#

oh

#

yea the def exists

regal stag
#

Hmm, this is what it looks like with a point light

grand jolt
#

Is the ground plane using the same shader?

#

cause shouldnt there be a pixelated fall off

low lichen
#

The normals are all the same on the ground, and since you're only pixelating that, they end up the same color

grand jolt
#

oh jeez

low lichen
#

And so you're only seeing the distance falloff, which we intentionally didn't pixelate

regal stag
#

And as you mentioned, pixellating the distance atten leads to overlapping because they aren't the same

grand jolt
#

Oh yeah that's really jarring

#

What if you pixelate the distance fall off and not the other?

#

What kind of result does that give you?

#

Perhaps having a regular directional light but having the pixelated attenuation might stylistically look nice

regal stag
#

That's what I began with earlier

grand jolt
#

Hmm i see

#

Wow this is difficult

#

If you wanted it to actually look proper would you just have to use cookies?

low lichen
#

@grand jolt Does the light cookie approach work for directional lights?

grand jolt
#

Haven't tested yet

low lichen
#

I'd imagine you wouldn't get nice pixels on the sides of objects

#

The projection would stretch

grand jolt
#

but I got it looking correct with spot lights

#

For point lights, I couldnt figure out how to properly make the cookie

#

sec

low lichen
#

Imagine this, but with a more grid-like pixel pattern

#

The scene without the dithering looks like this

grand jolt
#

Yea that makes sense

#

Yeah I can't get the cookie to actually make it look right for point lights

#

Cause I can't actually control the attenuation with a cookie

#

A cookie is basically just a mask

#

this is me just using a soft circle set to 32x32 with point filtering

#

Hmm this is kind of challenging

grand jolt
#

wrong chat lmao

grand jolt
#

Hey @regal stag is it alright if I DM you?

#

Or @low lichen if you are available too

#

Apparently this is a common issue but I cannot for the life of me use the attenuation formula without getting massive squares

#

It's driving me crazy .-.

grand jolt
#

this is all i am doing btw

#

If anyone knows or could help me out, it would be massive appreciated

mossy cobalt
#

simple question maybe

#

But why doesn't my shader graph have a blackboard?

#

I can't rename any of the nodes

#

Oh, never mind.

#

I reloaded the graph and it appeared

copper monolith
#

Anyone know how to get lighting data for a 2D shader graph?

chilly ocean
#

Hey, does anyone know if there's a vertex shader version of the standard URP shader somewhere?

errant atlas
#

Is there any reason why the URP lit shader master stack would have the alpha node missing? I can manually add it and connect a node to it but it has no effect and is grayed out

shadow locust
#

In its URP examples/additional Assets

#

Forget what it's called. There's some button in ProBuilder to import it

mossy cobalt
#

Hey, so, tell me if this is horrible or good, I really can't decide

#

I made a water shader that is entirely tileable, injecting the position into the voronoi UV's

#

The desired effect is perfect

#

However, I don't know if I can do anything else with this

#

I feel like it's magic that this even works

#

It totally falls apart when you actually rotate the object

#

But otherwise, it looks perfect

violet sage
#

how would i offset this multiply node with a tiling and offset node

thick fulcrum
mossy cobalt
#

How would I extract just X and Z from the position node?

thick fulcrum
#

send it to a split node

mossy cobalt
#

Oh wow, nice, that works like a dream

#

Thank you!

thick fulcrum
#

welcome 👍

simple violet
#

what's the equivalent of WorldSpaceViewDir() for URP?

regal stag
simple violet
#

i keep getting undeclared identifier when i use getworldviewdir

regal stag
regal stag
# simple violet i keep getting undeclared identifier when i use getworldviewdir

It's GetWorldSpaceViewDir, not getworldviewdir. Make sure you are passing in the world space position as a parameter. If it's still undeclared, you probably aren't including the URP ShaderLibrary files. e.g. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" should also include the ShaderVariablesFunctions file that contains that function.

simple violet
#

something has to be bugged cause it's not working

#

is it bcus my shader library doesn't contain shadervariablesfuntion.hlsl?

regal stag
#

Maybe the function didn't exist in the version you're using

#

Try just GetCameraPositionWS() - positionWS

simple violet
#

different kind of error

regal stag
#

Okay... _WorldSpaceCameraPos - positionWS then

simple violet
#

without paramerters

#

oh wait

#

i changed my out.view to a float 3 and_WorldSpaceCameraPos - positionWS

#

worked

#

thank you

#

where were those variables located

regal stag
#

GetCameraPositionWS() is in the ShaderVariablesFunctions.hlsl now, but prior to v10 it was in Core.hlsl. It just returns _WorldSpaceCameraPos though currently.

#

You can switch the branch/tag on the github to view a specific version

simple violet
#

ok thank u

simple violet
#

@regal stag i think your way of getting view direction is buggy

#

do you know any other way to get view direction cause my specular is all messed up

regal stag
thick fulcrum
#

there is a safenormalize function I believe as my code uses this at top V = SafeNormalize(V); //WorldView
also may want to ensure normals are normalized too

simple violet
#

yup, the specular spot stayed in the middle if I didn'tnormalize thank you

violet sage
#

how would i offset the alpha in the right way

amber saffron
#

If it's from a texture, add an other sampler with the offseted uvs.

timid minnow
#

Can you just not stack transparency shaders in URP?

amber saffron
timid minnow
#

Interesting... so distortion effects are going to be severely limited since that buffer can only really be used once without causing artifacts like seen in the vid

errant atlas
violet sage
#

i just wanna move it sideways

#

but i dont have a texture

#

its a render texture with added dirt texture

amber saffron
#

re-sample the same texture with offseted uvs, and only use the alpha from there

spark escarp
#

guys little help please.

#

why my texture is black ?

#

else main preview it's done ?

#

when i multiply with MainColor he failed look

#

i remove it

#

he is working

#

but i need to multiply it with mainColor

amber saffron
#

Is main color black by any accident ?

spark escarp
#

ahah no it's white 😉

amber saffron
#

And on the material ?

spark escarp
spark escarp
amber saffron
#

And on the material ?

spark escarp
#

OH

#

By default it's black

#

right right !

#

Yeah +1 done my boys

#

btw remy what is punctual shadow filter ?

#

if you know

amber saffron
#

Where did you see that ? But from the name, it's the filtering settings for point light shadows (you know, hard/soft ...)

heavy pebble
#

I'm going crazy here. I've got this shader to "clip" parts of an object that have already crossed the plane. Somehow, this is currently dependant on where I'm viewing it from ???
The object is visible if I'm (the camera) behind the plane, whereas its not visible when the camera is in front?

I have no code dependant on the camera, the section point and plane is just the normal of the plane and the plane position. So I come to the conclusion that something is wrong with my shader

lost kernel
#

i read a lot yesterday about unity and shaders, the lag of geometry and tesselation shaders and so on ... some say it will never come, because more and more hardware drops support for them and with compute shaders they aren't needed anyways, i can't see how compute shaders will help and im wondering if it makes sense to write geometry/tesselation shaders for urp

#

what do you guys think about that? let's say "simple" grass shader what are my options ?

#

i tryed a grass shader, it worked and i added support for normal direction (i need fur) but i don't wanna waste time with something thats deprecated anyways, should i be worried about that or not? is there a simple solution i don't see, is it maybe even possible with shadergraph and i just don't know how?

low lichen
spark escarp
#

@amber saffron before do this shaders in URP i tried it in hdrp but failed because i have undefined ponctual shadow filter but it's wrong i have ..

lost kernel
#

thanks for your opinion @low lichen , i also think it is not wasted, if you read to much you sometimes get unsure about what you do

#

but im really wondering why they don't add support, it's over 2 years now

#

a simple thing like grass, and i can't do it with the onboard tools

#

i will read a bit into compute shaders also

lost kernel
#

@heavy pebble sectionpoint is the normal?

heavy pebble
#

SectionPoint is the plane position, SectionPlane is the plane normal

lost kernel
#

ok then im not sure, but shouldn't it be world space if you check if it's opposite? also the dot product is 0 only when complete opposite, so maybe the normal is not completly opposite? if you raise x on the comparison node?

heavy pebble
#

I tried both world and object space, to get pretty much the same result

#

sec, I'll try and grab whats happening currently

#

and as for the normal part, I want it to clip as soon as it changes from pos to negative, so that comparison part should be fine I think?

lost kernel
#

im just trying to check if it's really -1 to 1 or 0 to 1

#

im not sure about that

#

no -1 you are right sorry

#

i think you must also normalize the positions, and both in world space @heavy pebble

#

but it should work then

heavy pebble
#

that makes sense, yeah

#

I'll try normalizing them

#

a lot going on in that video, but focus on 0:13 to 0:20

lost kernel
#

that's strange if you subtract them and normalize the result and compare it with the normal of the plan it should work, doesn't matter where the camera is

#

if you send it i can try also if you want

#

we need the experts! 😅

heavy pebble
regal stag
#

@heavy pebble Have you tried Absolute World space, on your original graph that is

lost kernel
#

dumb question you tried in game view also from the other side ?

heavy pebble
heavy pebble
#

interesting, absolute world space seems to work

lost kernel
#

if you didn't try absolute world space, it will fix it i guess

heavy pebble
#

there's stuttering, but it works

lost kernel
#

yeah my fault i forget to mention the "absolute" 😀

spark escarp
#

😄

heavy pebble
#
The Position Node provides drop-down options for both World and Absolute World space positions. The Absolute World option always returns the absolute world position of the object in the Scene for all Scriptable Render Pipelines. The World option returns the default world space of the selected Scriptable Render Pipeline.```
what does this even mean
regal stag
lost kernel
#

thats what they should add there 😄

regal stag
#

Yeah that documentation isn't clear. It's not helpful to say absolute world space returns the absolute world space position and world returns the world position.

heavy pebble
#

lol yeah, thats not helpful at all

#

thanks a ton btw @lost kernel @regal stag

untold shard
#

hi everyone. I'm currently trying to make my custom shader graph to work for my UI. Problem is, adjusting it via script doesn't work. What should I do?

lost kernel
#

looks great @spark escarp

sacred patio
#

Does anybody know where does this shader supposed to lead to? I am following a tutorial on water refraction

lost kernel
#

ok i give up, can anyone tell me how i get the object space position in geometry shader in URP ?

shrewd crag
lost kernel
#

the cginc is not really working on urp but i found one: float3 positionOS = TransformWorldToObject(input[0].positionWS); but it doesn't work