#archived-shaders

1 messages · Page 20 of 1

hallow plover
#

is there any way to remove srp batcher compatability without maoving around properties to not be in the cbuffer?

regal stag
hallow plover
regal stag
sacred patio
#

From which version is main light direction node available?

#

As it seems to be missing in the 2020.3 one

regal stag
sacred patio
haughty moat
#

Unity recommends not using cbuffer to declare constant buffers, but the macro they recommend doesn't work in compute shaders. Anyone would know which platform cbuffer would fail to compile for ?

broken hemlock
#

Can someone explain what shaders really do? I try and read up on Unity docs, like shaderbox and stuff, but I just don’t understand what it’s doing. Is it me calculating lighting and how the light bounces off objects or is that done internally by Unity? If it’s done internally, what are the points of all the pragmas and such? Is there a benefit to HLSL/ShaderLab vs Shader Graph (SRP)

#

I’ve written compute shaders and that makes a bit of sense, with the parallelism and stuff

kind juniper
broken hemlock
#

But when it comes to the render pipeline I get confused. Does the gpu automatically support things like drawing on the screen

broken hemlock
kind juniper
#

Light calculations are usually done in the shaders, yeah. Unity's standard shader.

#

Shaders are part of unity as well. You can't really separate them.

regal stag
kind juniper
#

Bad wording... Shaders are part of the rendering process.

broken hemlock
kind juniper
broken hemlock
#

Macros

kind juniper
kind juniper
# broken hemlock Macros

No. They're just a programming construct, kinda like functions but "evaluated" at compile time . You can do whatever you want with them.

#

There's really no magic about shaders. It's all just math and logic if you break it down.

broken hemlock
kind juniper
#

Yeah, I felt so too some time ago.

broken hemlock
kind juniper
#

Learning some C/C++ could be quite helpful. Especially with the macros.
I'll let Cyan add to that as he was trying to type something for some time. 😄

regal stag
# sacred patio Does this work both with deferred and forward lighting?

You can probably get the direction in either path. But custom lighting models are usually rendered in forward even in the deferred path. That's due to how deferred works - it uses a shader in screenspace to apply PBR lighting based on the gbuffers. There are ways to override that shader too, but it's separate from the shader applied to the actual mesh renderer and you probably wouldn't use shader graph for that.

broken hemlock
#

Like I’m not a professional at it

kind juniper
#

Oh, okay. Then you're settled there I guess.

broken hemlock
#

Yeah I just can’t tie the lighting part together

#

Compute shaders I can kinda understand

#

Where I split up processing power on the gpu between threads that are labeled by their index

kind juniper
#

Aside from that, it seems like you have some misunderstanding about the rendering pipeline. So maybe learn how modern computer graphics work.

broken hemlock
#

Yeah I never looked too much into that, you could be right

kind juniper
broken hemlock
#

I know basic stuff like normals, vertices, materials, stuff like that

kind juniper
broken hemlock
#

Ok let me watch it, one second

broken hemlock
kind juniper
#

Yes. Well, you need to understand that before getting into shaders, because that's what they do. Don't expect to understand everything from just one video though. I've been learning graphics related things for more than a year and there are still things I'm not sure about.

broken hemlock
kind juniper
broken hemlock
robust path
#

Hey, I'm trying to assign a texture to a computeshader, and I'm getting a weird error:

#
Property (targetTexture) at kernel index (1): Attempting to bind texture as UAV but the texture wasn't created with the UAV usage flag set!```
#

Which is weird, because it seems it's complaining that they're not readwrite, but I'm creating the textures in code, so they should be

#
_targetTexture = new Texture2D(_targetTextureSize.x, _targetTextureSize.y);
_shader.SetTexture(1, "targetTexture", _targetTexture);
#

does anyone have a clue what's going on?

#

in the shader, it's a RWTexture2D

kind juniper
#

From my understanding it has to be a RenderTexture. At least I didn't find a way to write to a regular Texture2D.

robust path
#

now I got another problem - I copied URP's SimpleLit shader, and I'm trying to add a Pass to it, but it doesn't seem to run at all
what I did, is in the first subshader, I added my own pass at the end, filled it with code, and I'm kind of expecting it to just apply after all the previous passes, but it doesn't seem to do that

#

what am I doing wrong here?

#

got some progress - it flashes the correct thing for a second, then returns to rendering the main texture

regal stag
robust path
#

how can I fix that?

#

I actually asked on code general about it

regal stag
#

That's weird, haven't seen that before. Do you have any C# scripts setting materials or something that might be overriding it?

robust path
#

nope, I don't, that's why it's so weird

robust path
#

oh wait, it's just a prefab actually, I don't know then

teal breach
teal breach
#

and now I'm trying to figure out what went wrong on the latest 2021, because it seems like something major changed behind the scenes on a minor URP change number, and I haven't figured out what yet but the SRPBatcher is really broken now 🥹

regal stag
teal breach
#

ahh yes, that's true!

#

apologies, I thought that was also true of built in?

regal stag
#

I think so yeah, but when you have passes without LightMode tag in built-in they get rendered automatically

#

While in URP that would break SRP Batcher compatibility as it doesn't like "multi-pass" shaders like that

teal breach
#

and hopefully I can figure out why it isn't working with the batcher now

robust path
teal breach
#

it's slightly tedious matching the CBUFFERs with the gibberish produced by shader graph, but it does draw everything in a single SRPBatch even for nonstandard light passes

robust path
robust path
#

but why...

onyx talon
#

I got some problems with my hdrp outline shader. The first image is when I turn on the fog, the second is when I turn it off, and the third one is my code. Is there anyone who can help me to fix this?

kind juniper
# robust path but why...

Static batches(combines) several meshes together and renders them as one object. It would usually batch renderers that use the same material, but perhaps it doesn't work as expected with several materials. Especially if a mesh only has one material slot.

civic lantern
#

I'm making a terrain shader with Shader Graph. How can I access more than the first 4 terrain layers/splat mask channels? I'm currently using _Control as the control texture.

#

Using HDRP and this is for the Terrain component.

tawny echo
#

How does one make a shader that encapsulates the entire area of inside a cube?

#

vs just the edges

#

IE:

#

shader looks like this from outside

#

This on inside

#

Ignore

#

changed to zwrite not equal

#

And it works

paper loom
#

Good day I'll just ask why my material is pink

#

I created a shader graph using steps above

kind juniper
paper loom
kind juniper
paper loom
#

sorry I'm not familiar with shader

kind juniper
#

You mean circle texture?

#

That doesn't matter the shader itself is broken/incompatible

#

Are you using URP as your render pipeline?

paper loom
kind juniper
paper loom
#

I'll google how to set URP properly

kind juniper
paper loom
#

Oh Thanks one more question if you don't mind

#

I'm creating a 2D circle but as can you see in the image it looks hexagonal so someone told me to use a sprite renderer shader as a solution

#

That's why I tried urp sprite renderer shader

kind juniper
paper loom
kind juniper
paper loom
kind juniper
#

That's not the pink circle though

#

I mean,can you select the pink circle and take a screenshot of it's inspector?

paper loom
kind juniper
# paper loom

I do t know what but there's something really wrong about that circle.

#

Can you give it a 1 1 1 scale?

vocal narwhal
#

The shader is not appropriate for sprites, as you can see by the warning it's completely ignoring the value

paper loom
#

so how can I make a shader appropriate for sprites?

#

2D sprites to be exact?

vocal narwhal
#

Use a Sprite shadergraph template if you have access to it, and make sure there is a _MainTex texture property that you use the RGB and A channels from

spare ermine
#

How do I make a texture tile nicely across all meshes, while keeping the texture the same size?
I managed to achieve this with boxes, but it screws up with other meshes, how would I manage to do this with shader graph?

chrome zinc
#

Anyone know of a way/shader to pixelate particle systems? Haven't found a pixelate shader that works, so I am currently rendering to a down-scaled render texture and overlaying with my main camera. The issue with this is it's not compatible with sorting layers, so all of my pixelated particles are on top of everything else, plus the second camera is a big hassle. (Example of what I currently have below, this is in URP. Been stuck on this for awhile with no luck /: )

spare ermine
#

i will try, thank you

#

nothing changed, the texture is still horribly stretched

#

maybe i'm using this in the wrong way?

ebon basin
#

Oh, why don't you try exposing a variable for the tiling input for the triplanar node there

ebon basin
karmic hatch
amber saffron
compact reef
#

You guys certainly know that there is a optional feature of standard shader which is "CrossFade animated transition" ....now the question is ..does this feature have a heavy performance impact if i enable it for a MOBILE project?

#

because, i dont want my LODs pop up like a weirdo....

kind juniper
kind juniper
#

If you're referring to lod groups transition mode, then I'm not sure how much it's related to shaders. It just renders both groups with different alpha.(the docs also mention dithering, but don't mention how it's implemented).

tardy solar
#

I have some interesting bug with render queue on android. Meanwhile it working on my emulator great.

#

Can somebody help me with it

wispy edge
#

How to keep Shadow Cascades in HDRP?When I press play they vanish

compact reef
paper loom
amber saffron
paper loom
amber saffron
# paper loom sorry which alpha?

One of those textures you're sampling probably has an alpha mask of the disk, no ?
Connect it to the alpha output of the master stack

paper loom
#

sorry is this the master stack?

#

is this the alpha mask?

buoyant spire
#

Is there any way to get color from sprite renderer when enabled gpu instancing?
It is vertex color and when enabled gpu instancing vertex color sets to white.
Build-in pipeline.
Pls don't suggest to get any srp.

regal stag
# paper loom

That is the master stack yes. You want to connect the A output from the Sample Texture 2D node (that is sampling the _MainTex) to the Alpha port on the stack as Remy mentioned.

lucid oriole
#

Hey, sorry I didnt answer before, but the school got the better of me.. The max and minimum values work, but I still cant figure out a way to calculate the actual fill value from the product amount expressed in grams. Could you help out a bit?

knotty juniper
#

in my script that is what is set as MaxNumber

#

and mind number is in my case 0

knotty juniper
#

i use this forumlar for calulating the fill value
shaderFloat = Mathf.InverseLerp(minNumber, MaxNumber, fluidFill);

in your case this would be
shaderFloat = Mathf.InverseLerp(0, 250, gramsFilled);

lucid oriole
#

oh, okay

knotty juniper
#

shaderFloat is then given to the shader as the fill value

lucid oriole
#

Works like a charm

#

thanks

#

And when I want to change the surface from transparent to opaque I need to make a new shader yes? I cant just set a boolean?

knotty juniper
#

you can make your transparent shader non transparent but it still has the shading issues that transparent shader have
only a opaque shader fixes that

lucid oriole
knotty juniper
#

the transparency is controlled via the alpha value of the albedo texture in most cases
if you do your own shader just set the alpha value to 1

#

you can change between the opque and transparent master node when you select the master node

#

then you should see the options for the shader

#

(in shadergraph)

lucid oriole
#

yeah but I cant change it via code can I?

pure fulcrum
#

how can i get camera normal in a written shader? tried using unity_CameraToWorld but i just get an "undeclared identifier" error

pure fulcrum
grand jolt
#

i dont know much about shaders but i have this shader to make a filling effect for this dropper but the problem is, when i rotate the dropper the filling liqued start to disappear, and i dont want that, i need it to stay as it is only be able to change the filling volume

worldly crater
#

maybe its leaking 🤭

#

and i dont know much about shaders also, i mostly use nodes, play until i get answer

#

and my best guess would be that you need to take rotation into consideration also

#

like you have position

grand jolt
grand jolt
worldly crater
#

I would try recreating above node and just trial and error. Some YT stuff for inspiration but no, cant help. Didnt use shadergraph much

amber saffron
karmic hatch
#

So when it's 1, it'll be full, and 0 for empty

outer grove
#

Hey guys in the shader graph tool how do i add albedo to the fragments section?

outer grove
#

Ahh ok it just had a name change from the tutorial im watching

outer grove
regal stag
#

Typically the UV coordinates stored in the mesh is responsible for that

outer grove
#

Ahhh ok thank you!

outer grove
pure fulcrum
#

any way to get a full depth texture in shader graph? i need to use it in a for loop in a custom node so the uvs gonna be different for each iteration and i cant just use the scene depth node

outer grove
#

never mind i got it 😄

chrome zinc
#

(Shader)

digital ivy
#

Hi, not sure where to ask this, but is there anyway to replace the sun with a texture in your procedural sky (in URP)

ebon basin
regal stag
# chrome zinc Here is what I tried to use. The effect worked okayish for a standalone object (...

The artifacts would be due to jumps in the UV values, related to mipmaps too. Can either use Sample Texture 2D LOD or a custom function with SAMPLE_TEXTURE2D_GRAD(tex, sampler, uv, ddx(uv2), ddy(uv2)), where uv is your current UV, and uv2 is just the UV node without those jumps.
Some more info here : https://www.cyanilux.com/faq/#sg-pixellated-seams

As for why it doesn't work with particles, that's due to the Object node. Would need to get the particle scale from custom vertex streams as you mention which can then be accessed through the UV node.

river fern
#

Hi, is there any shader whizz in here who can answer my question?
I'm looking to get specular highlights on my materials in HDRP. This is obviously fine and easy to do, but I want to achieve specular highlights on my materials with baked lighting.
Could a shader possibly do something like that?
As soon as I bake my lights in Unity, I get no specular from my materials making them look very flat and low-quality.

Thanks

plain heron
#

anyone?

karmic hatch
#

I'm no expert but you could have an identical scene rendered with unlit glowing materials, and then overlay that onto everything else where the flashlight is shining

vocal yoke
#

Hi, I'm having some "problem". I wanted to insert that kind of circle on a plane, but my circle is in fact bigger than my plane. How can I fit the circle inside my plane?

#

I think it's my Fresnel Effect that's makes it weird

#

Oh well I found out a way without the Fresnel, but I was wondering if it's still possible flatten sphere effect

vocal yoke
#

Hello guys I'm having a question, how can I get an array of Color Values from a Shadergraph color? I don't need code, maybe just a hint would really help!
I'm thinking of dividing the searching points of color based on the length of my map

vocal yoke
#

Or something like making the resulat of a node into a texture2D

kind juniper
#

You can't. Each shader thread has access to one color that it samples. There are no arrays.

vocal yoke
#

That's really disappointing 😦 So there's no way I can read each of those thread? or any kind of conversion?

vocal yoke
kind juniper
#

You can't output the result of a node into a texture, but you can render into a texture with a shader. Or create it with a compute shader.

vocal yoke
#

I made this with my nodes in Shadergraph. I wished to be able to use it for spawning object in non-black areas made by the node. The white area is my map generated by a perlin. I want to spawn chest and other kinds of object in the white areas

vocal yoke
kind juniper
#

If you need to access your perlin noise map data in C#, you need to render it to a texture(or a 2d array) first. Then you can reuse that texture for whatever else you're using it in your shader.

grizzled bolt
#

Or if the pattern is kind of simple and doesn't need a visual to go with it, you could produce it entirely in C#

vocal yoke
vocal yoke
kind juniper
vocal yoke
#

Ok! thanks for all the help!

north wren
#

Hey there
I need an shader to use on quads with transparent textures (for watch hands) on mobile but I don't want it to be translucent (as in I only want the transparency applied where alpha is 0)
Currently I'm getting some clipping issues with Unity particle shaders and they're translucent too
Can anyone point me in the right direction so I Know what to look for?

amber saffron
proven copper
#

thank you so much for the detailed explanation! it was really helpful. What are the final nodes feeding into? Albedo, emission and alpha?

hallow plover
#

grettings. I am making a water shader which uses the vertex shader to create waves. I was wondering if there was a way to make other objects float on the waters surface. Aka to move up and down with the surface of the water.

robust path
hallow plover
robust path
undone anvil
#

can anyone tell me what is this pattern ? i always see in my broken shader

hushed vigil
#

Moiré

undone anvil
#

this is also moire ??

hushed vigil
#

probably

civic lantern
#

also, if youre using Shader Graph, make sure that your Sample Texture 2D node for your normal map, has Type set to Normal, not Default

grizzled bolt
vapid sparrow
#

hi
how can i make ztest only happen inside a object not behind it?
my shader is simple unlit with two pass one is ZTest Greater as red one and one is ZTest Less which is blue one.
how i can I achieve the right result?

low lichen
#

The only way to achieve what you want is to pass additional information into the rectangle shader about where the sphere is and what its radius is and use that to calculate which pixels are inside it.

vapid sparrow
#

imagine there's a room that if players enter it other player can see them but if somebody is out of the room they don't get seen pass through
is only way to pass extra information about the rooms? there are so many rooms in my game

low lichen
vapid sparrow
#

apex legends

low lichen
vapid sparrow
# low lichen I don't play it, so I don't know what to look for

Just imagine it like

  1. You are a sniper and watching over 3 houses in middle of a dessert which contain stuff like gun and health
  2. There are 5 other players in game which have to survive from getting killed by you
  3. You can't see them but you have a sensor in those 3 houses which if those 5 players step in, you can see them through walls
  4. But if they stay behind the room and not stepping in you are not able to see them through walls
kind juniper
#

Maybe add a trigger collider to the rooms/buildings. And when there's a collision, render the players with additional see-through shader?

vapid sparrow
#

Yes that would work but those houses are not box shaped they are spherical domes that makes it hard
there should be a way for this in shader like 3d modeling software when your model intersect another model it highlights the area

low lichen
#

What 3D modeling software has that feature (and can I see it?)

kind juniper
#

You could use convex mesh colliders for triggers too. Although not perfect, but I'm sure it's not a big deal if they don't match the mesh perfectly.

kind juniper
#

Basically, approximating with mesh colliders is gonna be 100 times easier and faster than any solution with shaders.

amber saffron
carmine ivy
#

Hello, I need a bit of help. I have some tiles with a black border made with a custom shader (im not using a texture because im adding moving stuff within the borders) but on some specific low resolutions the border dissapears. Is there a way to gaurantee that the border is at least 1 pixel wide? Heres images on how it should look vs how it sometimes looks. And each tiles is a seperate gameobject

vapid sparrow
amber saffron
# vapid sparrow oh thank god, can you explain more?

Hum, it's the matter of ordering the passes right.

  • Render the boxes
  • Render the sphere back faces with ztest and write into the stencil buffer : the stencil has now a mask of the sphere but box pixels are missing
  • Render the sphere front faces with ztest again, and invert the values of the stencil bit : the mask should now be only where the box is intersecting the sphere
  • Render the "inside" pass of the box
vapid sparrow
#

but stencils are off screen no?

amber saffron
vapid sparrow
amber saffron
vapid sparrow
#

Oh remy this is so complex, I need a separate shader for sphere? how can i access sphere stincel from boxes? and how can i Order this passes they are done by gpu as i know

pure fulcrum
#

how can i get a world to screen space position in a post processing shader?

amber saffron
vapid sparrow
#

is there any example of what i want somewhere?

amber saffron
#

I remember the doc had a very easy sample at some point, trying to find it again :/

vapid sparrow
#

thank you i'm struggling on this for a week :[

amber saffron
amber saffron
mental creek
#

Hello why is the following code not working in HLSL
uint ground = asuint(((noise(id.xz) * .5f) + .5f) * cakeSize);

pure fulcrum
amber saffron
amber saffron
mental creek
# amber saffron HLSL doesn't have a noise function anymore since SM2 😦

Thanks Remy.

I have one more question. I currently use the Unity CPU Procedural Mesh where I feed it vertices and triangles. I am wanting to do this on the GPU instead. Do you have any resource where I can see an example of that. I am just confused of the syntax in a Compute Buffer to do this.

pure fulcrum
#

do i need to add another include to the shader or something?

amber saffron
mental creek
amber saffron
#

I think UnityCG.cginc but I thought it was kind of included in the whole universe XD

pure fulcrum
#

only other one i have is #include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"

amber saffron
#

An include can itself include other files

#

So UnityCG is probably already there

pure fulcrum
#

why doesnt it have a definition for UNITY_MATRIX_VP then?

amber saffron
#

Maybe it's not including UnityCG, but other stuffs

#

Try to include UnityShaderVariables.cginc It's the one with this variable

pure fulcrum
#

similar errors

carmine ivy
amber saffron
pure fulcrum
#

looks like it has its own variable for matrixvp which i assume is the same thing

tawny echo
#

Are there volumetric shaders? One that would encapsulate entirety of pixels in a 3d object? IE a cube.

amber saffron
tawny echo
#

ah. dang

brisk lagoon
#

How do I get my shadergraph file to go from this blue graph icon to this rainbow s icon?

tawny echo
#

Any unity shader pros that wouldn't mind talking in private to possibly help me solve a problem. Easier to send pics/possibly teamview to show issue

vapid sparrow
#

@amber saffron why did you deleted your post? it was not possible?

amber saffron
vapid sparrow
sleek estuary
#

I'm working on a simulation for an upcoming event, and I need a water shader. I've found one and it looks/works perfectly in scene/game view, but as soon as I run it, it turns pink. I'm trying to use it with VR, and it seemed to work great up until I started incorporating VR elements. I'm not too well versed in shaders at all, so I don't even know where to begin on fixing this. I've been reading up on URP vs HDRP, and it seems vr and HDRP don't mix too well, so I've switched to URP. The shader looks fine when running through URP, just not inplay mode

#

Normal one is in game view, pink is in play mode

shadow locust
tough flower
#

someone have a good video-tutorial to learn shaders?

pure fulcrum
#

not sure how to debug with shaders but i did try setting the color to mul(_SunPosition, unity_MatrixVP); and it seems to be displaying a random color on the entire screen, not lerping between values or anything as id expect it to do

sleek estuary
shadow locust
sleek estuary
#

Got ya! I’ll try that. Thanks!

karmic hatch
ashen linden
#

Need help here, Just finished the following tutorial https://www.youtube.com/watch?v=RC91uxRTId8&list=LL&index=12 but the material keeps only creating shadows but not receiving, I try doing the thing I found on the commentary that said to put the Keycodes on the SubGraphs, but still do not work.
YouTube
Ned Makes Games
Toon Shader in Unity Using a Shader Graph with Custom Lighting!
the version is 2021.3.8f1
also did the debug thing but the keycodes were already in there

✔️ Works in 2020.1 ➕ 2020.2 ➕ 2020.3 🩹 For 2020.2 and .3:
► When you create a shader graph, set the material setting to "Unlit"
► The gear menu on Custom Function nodes is now in the graph inspector
► Editing properties must be done in the graph inspector instead of the blackboard
► In Lighting.hlsl, change the line "if SHADERGRAPH_PREVIEW" to "...

▶ Play video
#

Anyone knows the problem?

regal stag
olive hinge
#

I'm working on a custom unlit shadergraph function, im getting the following error. Shader error in 'Shader Graphs/fogged-lighting': undeclared identifier 'GetMeshRenderingLayer' at Assets/hlsl/CustomLighting.hlsl(60) (on d3d11)

olive hinge
regal stag
ashen linden
worldly crater
#

I have a question. Was following code monkey tutorial for dissolve shader
His version for some reason doesnt work for me
there is no red outline from bottom row

#

managed to make it work with adding 2 alpha layers before and again after

#

but makes no sense

#

so i have to add 2 alpha channels (yellow) and then AGAIN add them together (red) to make it wok

#

shouldnt red node do the all work?

#

this is result without yellow node

regal stag
#

I think it's because you're using the wrong Step node in what goes into the alpha. The red part is being made transparent. Should use the one at the bottom with more white, multiplied with the A output from tex sample, into A on Combine.
But tbh I wouldn't even bother with the Combine & Split, just keep the RGB and Alpha separate, it's usually easier.

rocky robin
#

hello hello, is there a way to change a color emissive by script? I'm using shader labs

regal stag
# rocky robin

You'd need to use that Color_b9cc627... as the string in the SetColor call. The "Color Emissive" is just for display purposes. (Ideally the property name wouldn't be named so random, I guess it was generated from a shader graph or something. Could go through all of the code and change it to _EmissiveColor or something)

rocky robin
#

well so it's fine if i rename it?

#

it was generated by the Shader Lab (i used to do shader files by hand, so idk if it's ok)

worldly crater
#

but shouldnt this last ADD node do the same job? cause below its the same thing as above, well it should be

regal stag
rocky robin
#

it has 5.7k lines

worldly crater
regal stag
worldly crater
#

@regal stag thanks man

#

this is bit harder to debug than code

rocky robin
#

might be because of the dependencies

ashen linden
#

I will try remaking the shader with a newer version of the tutorial but I still would like to know what in the hell is wrong in there

#

I will dowload your version in the github and see the diferences, If I find the problem I will be back

#

Okay, I manage to fix by using the subgraph you used on your toon shader, thanks for the help

rigid garden
#

Question, I've found out recently how to implement dithered transparency for objects (or screen door transparency) - but I am having trouble figuring out how to apply dithering to shadows, or better put as a question - "how can I dither shadows?"

#

If someone had a link to some reading materials I could read on it, preferably compatible with URP, that would be awesome

celest quartz
#

Hii does anyone know how to put a shader to the whole camera? In using urp

#

I'm *

#

(I'm currently working for a vr project and I have to add the shader so it affects the whole scene)

ebon basin
#

Probably ideal to research it yourself, then ask questions when you're having problems implementing it all.

celest quartz
#

I spent three days researching nothing works heh

#

Most things work with srp

kind juniper
shadow locust
kind juniper
#

Assuming you mean scriptable render pipeline, which srp is the common abbreviation for.

latent frigate
#

Hey, There!

Is there a HDRP/Lit shader that uses world space texture coordinates instead of local ones?

shadow locust
latent frigate
mental bone
#

You dont want world space texture coords for moving objects since well they move in the world

shadow locust
hallow plover
#

looks like the texutre is sampled in world space uvs. I assume you want the texture to move with the tank and in that case it needs to be sampled in object space uvs.

mild cobalt
#

I have a (hopefully not silly) question. I have a branch that I would like to use as a mask. Is there a way to blur/smooth the hard black and white edges that I get from the branch?

compact reef
#

how to replace alpha blended rendering instead of cutoff in a shader script?

#

i've a grass sway shader that uses cutoff....but it looks edgy and disappear away over distance

#

just want to make it look like mobile/particle/alpha blended type of soft-edged

#

any way?

amber saffron
tawny echo
#
Object A -         
Stencil
{
  Ref 220
  Comp Always
  Pass Keep
}

Object B - 
Stencil
{
  Ref 220
  Comp NotEqual
  Pass Keep
}
#

Shouldn't this draw object A where it is supposed to be, and then when object B renders, it not draw where object A is?

mystic hornet
#

Hello! I may be a bit dumb, but how do I get the texture of an object? i'm trying to make an animated shader, but I can't seem to understand what I need to reference in the texture 2D asset.

cosmic prairie
#

The texture file

#

What do you mean "get" the texture of an object

#

How does the object "have" textures

#

Renderer componets reference materials and meshes, materials reference shaders and textures to populate properties exposed by the shader, you are making a shader, you do not have any exposed properties, you are about to hard-code a texture into the shader, on the bottom-left panel click "+" and add a texture property. Switch out "Texture 2D Asset" with the created property.

mystic hornet
#

I don't really now a lot about textures, but don't objects have textures?
What should I put inside that created property?

abstract adder
tawny echo
#

Object A is just a cull. It's not really doing anything

#

It's just transparent object that is keeping normal background stuff

karmic hatch
haughty moat
#

Hello 🙂 Anyone would know what a U at the end of an integer literal means in HLSL ? example: '3U'

tawny echo
#

Unsigned Int I believe

mystic hornet
karmic hatch
#

(Brackeys has a good tutorial on making a dissolve effect)

mystic hornet
karmic hatch
mystic hornet
sleek estuary
#

I'm really having issues getting this shader to work in VR. It renders just fine in edit/game view, but goes pink in play mode. Additionally, with the headset, the pink shader is only rendering in one eye (the left) the right eye completely hides the object. I'm using URP. Is there a way to convert a shader to work with VR? I'm not too versed in shaders.

sleek estuary
#

Both eyes as seen in VR and what it looks like when not in play mode.

lime viper
sleek estuary
#

It's an asset from the store, though it seems to be handwritten.

lime viper
#

I'd try adding support for single pass instancing to it first then

#

if you wanted to test quickly you could try changing the stereo rendering method to multi-pass to see if that works, but you should not really use that for a VR game if possible

olive hinge
#

im writing a shader that limits the maximum light radiance that certain materials can receive (working of fog of war) but my method for doing so seems to remove details from the normal map, can anyone suggest a better way to limit the radiance or fix the normal issue? You can see the normals look good on the outer edge of the lit area (where radianceMax has not been exceeded) but disappear in the center. Other than radianceMax part, this is a copy of the LightingPhysicallyBased from urp source

half NdotL = saturate(dot(normalWS, lightDirectionWS));
    half3 radiance = lightColor * (lightAttenuation * NdotL);
    
    // attempt to set a maximum radiance for light received by fog of war materials
    float3 radianceMax = normalize(lightColor * (lightAttenuation * NdotL)) * 0.75;
    if (radiance.y > radianceMax.y || radiance.x > radianceMax.x || radiance.z > radianceMax.z)
    {
        radiance = radianceMax;
    }
lime viper
olive hinge
#

that looks better

ashen linden
#

Any idea what is making this happen?
https://www.youtube.com/watch?v=GQyCPaThQnA used this tutorial

✔️ Tested in 2020.3 & 2021.1

Do you have a material that doesn't look quite right in Unity's URP lit shader graph? Or would you like to experiment with stylized art styles with the convenience of the shader graph? In this tutorial, I show how to implement custom lighting, allowing you to solve both those problems. Afterwards, you could extend t...

▶ Play video
#

the problem is definitly on the following code.
float diffuse = saturate(dot(d.normalWS, light.direction));

float specularDot = saturate(dot(d.normalWS, normalize(light.direction + d.viewDirectionWS)));

float specular = pow(specularDot, GetSmoothnessPower(d.smoothness)) * diffuse;

float3 color = d.albedo * radiance * (diffuse + specular);
latent frigate
#

@civic lantern
Thanks for the help where would the output go?

civic lantern
#

but you also need to declare the texture property

#

and then drag that texture to the Triplanar's texture input

latent frigate
civic lantern
#

maybe you need to add a Tiling float property and plug it into the Triplanar node's Tile input

#

and if you want options like in HDRP/Lit (normal map, mask map, remapping...), you need to add them to the shader yourself, or find an existing shader graph

lime viper
#

You may also want to correct for object scaling, you can use the object node and the scale value there to multiply the position input before sending it

civic lantern
#

oh also you want to plug in the local normal too:

#

@latent frigate

latent frigate
civic lantern
#

It's a bit weird though, how Unity doesn't ship with a Shader Graph that works like HDRP/Lit

#

so we have to replicate it ourselves

latent frigate
#

Btw this does this which is not correct.

civic lantern
civic lantern
#

you should test how it works with primitive shapes too.

#

maybe your tank mesh is somehow messed up

#

@latent frigate btw make sure your texture's Wrap Mode is set to Repeat

latent frigate
civic lantern
#

your tank mesh's normals/tangents are probably somehow messed up

latent frigate
#

I made the model in Blender and uv unwrapped it there.

civic lantern
#

select all vertices in blender, hit Shift+N, and save

#

to recalculate normals

#

maybe that helps.. hard to tell whats wrong here

#

also UV's shouldnt matter here because we aren't using them

#

and what is the scale of that tank object and its parts? 🤔

latent frigate
lime viper
#

so this is the setup I'd recommend:

civic lantern
#

oh hes back

latent frigate
civic lantern
#

its 2 nodes from what you have now

lime viper
#

all you need is the multiply and the object node, I also threw it together with URP so I'm not sure it will work in HDRP

civic lantern
#

it's nearly identical in HDRP (no bounds in Object node in HDRP)

lime viper
#

I meant WRT to just passing the file

latent frigate
#

@civic lantern , @lime viper
Hey, Thanks!

It looks like that the new shader you guys made fixes the tiling issue!
Just one more question.
How can I expose the texture and tiling so that I can change them in the editor?

lime viper
latent frigate
civic lantern
#

camoflaged objects is a good use case for this type of shader 😁

rare charm
#

Is there a performance hit for using double-sided shaders?

lime viper
#

Slightly longer version: Turning it on for a large number of unique materials/shaders will increase your draw calls and the amount of geometry drawn each frame. On the other hand if you are making something that is best served having two sided e.g. you would otherwise duplicate geometry and flip normals, or cause you to have to draw more complex geometry you are probably going to see a benefit.

grizzled bolt
scarlet crater
#

does anyone know a potential solution to the white borders around each "cell" here?

#

the coordinates are generated using frac(uv * resolution) and then used to sample a spritesheet of the characters

#

i initially thought it might be because the frac function returns a value in [0,1) range rather than [0,1] , but i tried messing with that and it didnt appear to make a difference

#

I also have my textures wrap mode to clamp, which lessened the issue but didn't solve it

tropic quartz
#

is there a way to slowly move one color in the sample gradient node?

regal stag
scarlet crater
#

thank you so much

cosmic prairie
#

Anyone knows a good hlsl syntax highlighter that is compatible with Unity, and how it's file system is set up? I currently use the HLSL tools for Visual Studio plugin, but any shader include is not recognized, as the paths refer to the local path in the assets, and also the local path that refers to unity package cache for like URP shader includes

#

Or even a way to set up the plugin to work with Unity would be great, I'm just not really experienced with vs plugins. I did check if the plugin has any options to set folders to look inside for includes, but it seems like there is no option

regal stag
cosmic prairie
tropic quartz
slow chasm
#

Is there any way to get a noise gradient from a shader into a c# script? I want to make buoyancy for my water but I need my gradient noise for that, and when I use the shader code in the documentation I don't get the same pattern

ashen linden
regal stag
ashen linden
#

okay, thank you, found your tutorials and I will be using them, you got yourself a new follower

rare charm
cloud orchid
#

Is is possible to do parallax scrolling on a plane using only a shader?

rigid sandal
grizzled bolt
rare charm
#

Oh yeah duh. I was thinking about a plane and missed that.

lime viper
copper zealot
#

What component will let me render in 2d based only off some virtual UVs? I.e. without a texture or mesh required? Just pure shader?

shadow locust
copper zealot
#

I guess, or a sprite renderer with a blank texture -- but is there really no way to just render based off UVs scaled to the object size?

shadow locust
#

Ultimately GPUs work with meshes (triangles and vertices)

#

just in a different way

copper zealot
#

I don't know that that is true -- thousands of shader examples out there rendering solely in the screen space UVs.

Is Shaderforge and OBS "instantiating a quad" so it can render a shader that only takes in the UVs?

You can call UVs mesh data if you like, but I don't see any reason why you can't just define the UVs without a fake quad in the background. It's just a coordinate system.

shadow locust
#

the UV values themselves are just numbers 0-1

#

the position in the uv array corresponds to a vertex

copper zealot
#

I'm well aware what UVs are but they're just a coordinate system that is mapped onto vertices in the context of meshes. In a texture or on a screen space or in a box or a window, the UVs are just the relevant coordinate space.

shadow locust
copper zealot
#

There is no really a reason for it to be connected to the concept of 'vertices' even if you need a start and end point for the range.

shadow locust
#

the positions are verticees

#

that's all vertices are

copper zealot
#

You can call them that.

shadow locust
#

it's just vertex data in the GPU memory

#

"Mesh" is a Unity concept but ultimately you need to put vertex data into the GPU for your UVs to refer to

#

so yes OBS and Shaderforge are putting vertex data into the gpu

#

This seems like a semantic argument

copper zealot
#

I misspoke, meant Shadertoy.

#

Maybe it's semantic but there is extra overhead to instantiating quads and all the associated data beyond literally just the UVs.

shadow locust
#

instantiating quads
This is a loaded term

#

you don't need a GameObject

#

Is that what you're asking about?

#

I already pointed you at one example way to do it without a GameObject

#

Yes you need more data beyond just the UVs, you also need the vertex and triangle data.

copper zealot
#

No, I'm saying that a quad mesh comes with a lot of associated overheads (like vertex indices, rotation, and other bookkeeping stuff) that are completely irrelevant to defining a UV space (such as in screen space). And I'm just wondering why there doesn't seem to be a way to define that very basically (and trivially) defined UV space without rendering a mesh.

shadow locust
#

Those applications are uploading that data to the GPU behind the scenes

copper zealot
#

You can call the coordinates that define the extent of the space 'the vertices' if you want. But there is a difference between providing coordinate pairs as bare numbers and providing a quad mesh.

copper zealot
shadow locust
#

Under the hood it's doing the same thing, but you get to provide screen space coordinates instead of 3D coordinates

#

As I said - lots of goodies in the Graphics class.

copper zealot
#

That does seem useful for screen space stuff. Is there a similar one one for world space too?

But you're saying that under the hood that would be loading in a 'mesh', including all the extra irrelevant data?

shadow locust
#

That's how GPUs render stuff so yes

#

or at least how the graphics APIs (Vulkan, DirectX etc) work

#

If you want world space, you're providing a mesh

#

That's how you define the world space object shape to render

copper zealot
#

Well I guess I have no expertise in that but it seems to me pretty ridiculous that anyone would design it that way. Edge and face sets (etc) are completely irrelevant to the kind of thing I want to render. But I guess I'll have to accept that overhead.

shadow locust
#

it's just vertices, triangles, and UVs

copper zealot
#

Yes, triangles, as in the sets that define the connected vertex graph and the faces (tris, if you want to call them that).

shadow locust
#

and they are relevant because otherwise it has no idea where and how to draw each pixel

#

Have you actually tried this and found that there's some level of unacceptable overhead here?

copper zealot
#

The only numbers I need to render 2d screen or world space UV based effects are the 4 vec2 pairs that shape the box (or even the just 1 coordinate + 2 extent values).

shadow locust
#

use DrawTexture then. I'm just telling you under the hood any application that does things that way has to convert that to vertices and triangles to get the GPU to draw it.

copper zealot
#

Oh I accept that you're right, I am just baffled by it.

shadow locust
#

these are 3D graphics apis

#

they're optimized towards drawing 3d objects

#

drawing 2D things is just bolted on

#

There are 2D drawing APIs like Skia: https://skia.org/

But even those use the 3D apis like OpenGL or Vulkan under the hood

copper zealot
#

I guess the whole system is rather inflexible. I just see no reason why it ever had to be that way given that the calculations would be identical in every way? I guess it was 'good enough' for this use case so no reason to make it any more optimal. The story of all technological development.

lime viper
#

So you can apply a fragment shader to the whole screen and only use the intrinsics related to screen space. This workflow is not super easy to use, so you may want to consider just putting a quad in front of the camera, you can still use screen space based intrinsics it just doesn't require you to dive into the blit system.

If you still want to start looking at the blit system you could start with the Unity Documentation: https://docs.unity3d.com/ScriptReference/Graphics.Blit.html

Or if you like I believe this might be a bit less involved
https://github.com/Cyanilux/URP_BlitRenderFeature

As to why it isn't a well supported workflow, screen ratio and resolution can vary drastically between users and platforms, it is better to instead have a layer of abstraction that lets you have absolute measures that are then pushed through to the screen.
Imagine if you will having a character jump, with the abstraction you can say the jump height will be 1 meter and the general process that presents it to the screen will solve all that for you.
However when working in screen space you need to go backwards to figure out what 1 meter is in the current screen context, is 1 meter .25 of the screen? what if the screen ratio is wider? Is the camera distance fixed?

copper zealot
#

Thanks for those docs, I'll have a look at them.

That said I do understand why you wouldn't use screen space coordinates to render world space objects.

What I don't quite get (other than "it's the way things are") is why, in 2d, whether screen or world space, you'd need to provide 4 vertices + the adjacency graph and face presence data (i.e. a mesh) to define the UV mapping which is already uniquely and completely specified by 1 float vec2 coordinate + 2x float width and height, (or potentially all ints in pixel space).

But this isn't my expertise, my expertise is optimising scientific code for HPCs. So perhaps there is some good reason for it, beyond lack of willpower to implement it.

lime viper
#

So what you are taking about are the screen space intrinsics, not sure if you are looking to do this with HLSL or in shader graph but the screen coordinates are readily available in either, they will present a 0-1 2D space that represents the screen, often they will also provide the depth information of the screen as well in the Z component.

#

Shadergraph also has the Screen node which has the width and height in pixels. That data could also just be passed directly via the material if you want to use HLSL

meager pelican
# copper zealot Thanks for those docs, I'll have a look at them. That said I do understand why ...

GPU's are designed to be fast polygon rendering machines, massively multi-parallel rendering of millions of polygons. Polygons are composed of 3 verts each, ultimately. Even "larger" polygons (say quads) are broken down into triangles.

The pipeline is designed to take 3 points (verts) and output them into 2D screen space-ish....it's actually called clip space.

Clip space is a -1 to 1 space with (0,0) at the center, and most of the 3D work done to "splat" the 2D or 3D scene onto that flat LOGICAL plane. The physical plan isn't being dealt with yet...it's all just math.

You don't really need more than 3 verts to map and entire view screen into this process. Research "full screen triangle GPU" for some fun. But regardless of how you do it, with 4 verts or 3 verts, you're mapping a logical mathematical space called clip space over the screen. For a triangle at the center of the screen it's not a full screen quad. For a full screen tri/quad...it just happens to neatly cover the whole screen.

THEN....The magic happens IN HARDWARE. The vertex stage is the stage that set it all up...into clip space. The RASTERIZER then maps the results of the polygon's verts onto pixels of the logical screen (which often maps to physical screen size but I supposed doesn't have to). During rasterization, there's a perspective divide that happens where the depth information is taken into account for 3D screens and the farther things are away the more they're divided such that they move toward that (0,0) point.

THEN (and only then) can you get into screen space. Because all the math before that is in LOGICAL SPACE, not physical device space.

#

Anyway, all you need to do screen space mapping is 3 verts, submitted somehow to the programmable vert stage. AND THAT's IT. No extra overhead is needed, but the GPU has to do its job of mapping the logical space to the physical pixels so it can call the fragment stage shader for each pixel in the resulting polygon...be it some arbitrary area of the screen, or the entire screen. That rasterization is hardware and not programmable. But the input to it (vert stage) is programmable, and the frag processing is programmable.

copper zealot
#

I see, so it's solely a contrivance to deal with the hardware side rasterisation? I know and could tell anyone the entire space (whether it be clip or screen) with a coordinate, width and height. But, we need to convert that into a set of vertices solely so the hardware can undo that conversion and get back to the mapping which we already knew (thanks to the peculiar constraints and symmetries in this specific calculation) and theoretically could have provided to the GPU were the hardware able accept it.

meager pelican
#

I suppose so.
But think of it this way...what API isn't a "contrivance" and abstraction? Isn't that in effect the entire idea behind an API to begin with?

I mean, there is some physical memory on the GPU that maps (probably double buffered) to the physical screen and is output at every frame to the hardware. I suppose we could just write bits to that like in the old days of the most simple "
"graphics cards".

The first graphics cards, beyond just memory-mapped-to-monitor contained some sets of utility functions. Like blits, and fills but the real "GPU"s contained higher level functions that let programmers exploit dedicated hardware. And we moved quickly in the PC realm from 2D to 3D cards, because filling lots of polygons fast is really cool graphics, and all we really could afford with the speeds-feeds of the time. Ray tracing was WAY WAY WAY out of that league and still is mostly....RTX technology is just beginning to appear now.

#

There are other aspects to consider, like parallelization and math, that are best done on a GPU...so a math-space to device-space construct is needed.

#

The fragment/pixel shader stage (the meat of screen-space calcs) must be called for each pixel. You can do that in a compute shader too I suppose. Just tell it to run for width x height itterations.

copper zealot
#

Sure, I suppose. But it just seems like there is a whole step you can skip in these specific cases.

There is the projection of the polygon into the flat space (which seems like the computationally intensive part to me) then there is the actual drawing.

Maybe there isn't as much to gain by skipping that first step as I expect there would be... and I get that we, collectively, as a culture, became kind of obsessed with 3d.

But there are still a lot of 2d games out there, (maybe even ones that would even appreciate being able to render a billion more particles, not to mention other more philosophical concerns) so I guess to me it seems like it would be valuable to haver a higher level function to skip that first step and just tell the GPU "here is the mapping, don't worry about it".

meager pelican
#

The vert stage and rasterization is minimal.

#

But you can use compute shaders.

#

With them you can write directly to RenderTexture[x, y]

#

But somehow you have to tell the GPU how to allocate all of those processing units and in what "waves"....so there's still an API for that.

lime viper
#

Modern GPU's don't see much of a difference between vertices or pixels, processing 3-4 vertices to make a full screen quad is a tiny fraction compared to processing 8.3 million pixels

meager pelican
#

Another thing I should mention is that each processor core has interpolators associated with them. So you can set 3 verts in logical space and have the interpolators compute screen space coordinates, or other data FOR YOU, during processing/rasterization, device independent...basically FOR FREE, or at least at a performance level in silicon that is above what you'd get if you were doing it manually in the fragment stage.

lime viper
#

Also GPU's in theory are stateless, that is to say every frame they are given fresh data with no knowledge of what data made up the previous frame, this is less true nowadays where previous data can be carried over, but it is largely in a different format than what the CPU passes in

#

This ties into the idea that the GPU is about being extremely focused on processing many tiny chunks of data in parallel their programming structure is designed to maximize that vs. the more general programming you would find for CPU based languages

copper zealot
# lime viper Modern GPU's don't see much of a difference between vertices or pixels, processi...

Sure but not every object in 2d world space (or screen space) is going to cover 8.3 million pixels and you may very well have thousands, or hundreds of thousands (or whatever you can push the system to) of objects whose polys need to be projected into the flat space.

3 verts rather than 1 coordinate and 2 extents is already 50% more memory per space that needs defining and no idea how much CPU time in the transfer to the GPU. And for whatever is 'free' I suspect we mean in calculation time rather than say, energy cost.

I get that what we have already works well enough for this situation. And of course from the viewpoint of productivity there is no point in optimising before you need to.

But there is also the question of basic competency and arbitrarily doing inefficient things (like say, copying a whole array into a function's memory rather than the 1 value you need from it) just doesn't make sense.

I assumed that since you clearly don't need 'verts' or a 'mesh' as a whole data structure to define the space (mathematically) there would be a clear and obvious way to skip that. I guess not. Or there is in Compute Shaders?

Either way an interesting discussion.

lime viper
#

The whole screen at 4k is ~8.3 million pixels, they all have to be drawn at least once

#

per frame

meager pelican
#

It is interesting. 🙂
But somehow, unless you have dedicated/known hardware, you have to map logical space to physical-device.

That's rasterization. 2D or 3D, mesh or no mesh, it has to be done.

The center of the screen at offset (widht/2, height/2) isn't a constant. It varies by device that it is executed on.

Whereas in clip space, (0,0) is the center, regardless.

And then there's interpolation in silicon....FAST. A big performance boost.

As to your example of data storage, you could create a buffer of x/y location and 2 extents and the vert stage could use that to output logical math-space info to be rasterized. So really it's already possible to do that. It is done, in fact, for situations where geometry is generateed (procedural geometry can come from anything)

#

Somehow you have to be able to write to abstract-space and end up in concrete-space.

copper zealot
# lime viper The whole screen at 4k is ~8.3 million pixels, they all have to be drawn at leas...

Yeah, but that is always happening and the relative computational time spent on the pixels vs the projection into the flat space will depend on the number of local spaces that need projecting.

0 objects, then 100% of compute time is spent on the pixel loop. A billion objects each with their own local space that needs to be projected into the flat space? Who knows.

In 3d that projection is complex and it makes sense there is highly optimised hardware to do that.

In 2d all subspaces are simple translations.

meager pelican
#

You can write a software based rasterizer on the CPU, but that's slow. And rasterization in a GPU is per the api.

meager pelican
copper zealot
#

Well what I mean is from local to world to screen, for example.

#

I get that the logical space differs from the pixel space since there is no way to know a priori how the discretisation grid aligns with the logical space.

lime viper
#

So the other problem is that GPU's want to be given a simple program to run, and they want to run it on every pixel, so if you want to put X number of sprites on screen what happens is that it does a logic check on every pixel to see if X sprite should appear there

copper zealot
#

Yeah, there are many other optimisation issues to be able to put a billion things on screen -- for sure.

lime viper
#

Yeah but by implementing them you are essentially re-implementing the vertex/triangle stage

meager pelican
#

Let's say you want to "smear" a gradient across the screen.

If you do that in a compute shader, where you're in 2D and you pass in the width/height and then calc the value for each pixel at (x, y) and shove the color into the pixel....you can do that.

It's slow.

The faster way is to let the rasterization process smear the colors for you in a device independent way as it is rasterizing anyway. The vertex stage outputs color at each of the 3 verts, let's call it pixelColor.

So in that case, your frag function doesn't even care what its location is, and it can simply return the result from the interpolators. The frag function would just return
return pixelColor;
and pixelColor would be calculated by hardware interpolators in silicon that end up having to dispatch the frag calls anyway.
That's the lowest overhead, and it works on any resolution of device without YOUR program having to know anything because the GPU already knows what to do.

copper zealot
# lime viper Yeah but by implementing them you are essentially re-implementing the vertex/tri...

Well the kind of sorting you need to do in 3d is just far far more complex than what you need to do in 2d due to the constraints afforded you by the lack of a 3rd dimension.

In 2d you only need to know the order, but in 3d you need to worry about the extent of the polygon which may intersect other polygons in a way that a single polygon-space requires two orderings (one in front and one behind a separate polygon-space).

#

Or even more orderings, potentially.

lime viper
#

So you can totally do them in order in a painters algorithm, but even more efficient is to write out the color and the depth information, then you can skip drawing things that have a lower depth value

copper zealot
#

As many vertices that would be required to approximate the function with lerp or smoothstep or whatever it uses.

lime viper
#

Assuming you have a good 0-1 mapping you can just remap those values as needed

meager pelican
#

I'm using a simple example.
But anything can be "smeared" by interpolators...colors, screen-space coordinates, whatever.

And of course, if your pixel's result is a function f(x), you can still write and call f(x) to set the color. You don't HAVE to interpolate everything. But it is really handy for device-resolution independence of anything that is convenient.

copper zealot
lime viper
#

What is the sort order except a 3rd dimension?

copper zealot
#

In a way it is a third dimension but the constraints on the situation make it far easier to compute what to render. They're all parallel, don't intersect, can't be both in front and behind at the same time, so you can simply take the top item (and then deal with transparencies).

In 3d, as far as I know, rendering engines usually do a lot of other clever things to correctly order objects because of exactly those things? Feel free to tell me I'm wrong though.

lime viper
#

So in general that is how 3D works as well, things will be sorted back to front from the camera and each submitted to the GPU, by writing out the depth information into a depth buffer shaders have an early out. but the GPU wants floats. Also you have to remember too a CPU tops out at like 16 cores, GPU's are 1000+ each able to process these things far faster than a CPU

copper zealot
#

Sure but the difference with 3d is you don't know the sorting a priori. You have to calculate the sorting because the projection isn't orthographic, the camera can move in 3d, and the objects can move in front and behind each other, or have extents that go in front and behind another object simultaneously.

In 2d you know the sorting a priori because you set which layer the sprite was on and that doesn't (usually) change. (and even if it does change it changes because you told it to, so you still know what the sorting is without calculating it).

The camera also can't move in a way that changes the ordering.

So you don't even need to do 'sorting' in 2d. You can just 'index' the objects instead, no calculations needed.

lime viper
#

Why wouldn't the projection be orthographic?

kind juniper
#

I'm pretty sure it's a hardware level thing though, so I'm not sure if you're gonna get any boost in performance at all.

copper zealot
#

Not sure what your point is? I'm just pointing out that the constraints of 2d necessarily open up opportunities for far more efficient calculations (whether measured by memory, time, or energy). I don't know whether or not GPUs actually have the hardware to take advantage of that fact or not.

kind juniper
#

Okay..? Perhaps you're right, eo what are you gonna do about it?

copper zealot
#

People usually keep depth sorting on because turning it off often ends up with undesired effects in the rendering because of the problems I mentioned. Those problems don't exist in 2d (or anything parallel to a plane and constrained to move parallel to that plane, and viewed from a camera normal to that plane).

lime viper
#

So most GPUs work with Vec4s in either Single, Half, or Fixed* precision, even if you pass it a vec2 it treats it as vec4

#

*fixed is rarely used now adays

copper zealot
meager pelican
#

The depth sorting is done at the engine, not at the GPU.
That's probably why Unity has a different 2d system than the 3D system.

#

By the time it gets to the GPU, like @lime viper just said, there's not much difference between a 2D vector and a 3D vector for performance.

copper zealot
#

Makes sense.

meager pelican
#

Of course there's other factors, but that's programmable BY YOU in your shader.

kind juniper
#

Okay. Well, the reality is that 3d is way more resource-demanding than 2d, so the industry, hardware and graphics apis evolved to make 3d as performant as possible. As a side effect it made any rendering(wether 2d or 3d) faster. You can do almost anything with 2d now a days without experiencing performance issues. Optimizing for 2d is simply irrelevant in most cases.

kind juniper
meager pelican
#

Sure is.

#

But it's optional, as you mentioned.

lime viper
copper zealot
#

Trying to imagine the workflow/tools they would have made to work like that. I guess you gotta do what you gotta do though.

kind juniper
#

It's actually pretty common in 2d games I think.

#

In the simplest form, just have some utility script that places the sprites at certain z pos based on something(layer?)

lime viper
#

it's probably not bad to automate away with a tool, just do the illustrator style move forwared/move backward, and keep it at units of 1 for each move

ebon basin
#

superliminal was made in unity and that's a large premise to the game

copper zealot
#

Yeah I can see an advantage in being able to use the perspective view to just grab and reorder things in complex scenes like this.

median kiln
#

In 3d, how do I use shaders to render a character's eyes over their hair without then being able to see their eyes through their head when you turn them around? I tried messing with the draw order but realised if I put the eyes on top they'd just show through the head entirely

karmic hatch
median kiln
#

thank you!!!

lament scarab
#

does anyone know where this background texture comes from in this example?
https://programmer.ink/think/unity-shader-restore-csgo-holographic-sticker-effect.html

there's only two input images, when you look at everything he posted, they are in the green one.. but it doesn't seem to be used in the code, what am i missing?

acoustic flame
#

is there a way to not render vfx particles in certain areas?

#

I need to use a vfx graph for the snow for performance, but they also can't have collisions, so they show up in interiors

#

can I somehow have a volume where they don't render?

acoustic flame
#

oh cool we have a detective

#

i made a mistake, good job

slender swan
#

Hey, not positive if this is the right chanel to ask this, but I'm having an issue with getting a texture to look correct in unity, when I render it in blender my corners look like this

#

but in unity they look like this and all the tinkering in my mind hasn't gotten it to look right

#

I haven't done a lot with texture mapping vefore so I could be totally off on something but I figured I'd see if anyone recognized the issue right away, I can get a similar issue in blender by changing my interpolation mode to linear rather than closest but can't find a similar setting in unity

slender swan
#

Closest thing I've found is changing the filter mode on the texture from bilinear (default) to point (no filter)

#

but then it introduces these weird lines

#

artifact of aa maybe?

karmic hatch
#

actually what do the UVs look like? Is the texture a cube net which it then folds onto the mesh?

slender swan
#

yeah this is the UV I was using

#

I swapped over to a spritemap that I'm using a script to apply at runtime and this works though

karmic hatch
# slender swan

If you just fill all the transparent areas with black, it should work

slender swan
#

sometimes

#

I'm just not half there

#

to be clear that was the perfect solution thanks

flat hedge
#

Hi, could somebody please recommend me a decent directional fade shader video please?
I've tried to ind one my self but wasn't really successful when it comes to 3D.
What I am looking for is an object going from completely visible to transparent top to bottom.

karmic hatch
#

(would be useful to use a remap if the mesh's top and bottom aren't at y=0 and 1)

#

(also good practice to saturate anything going into alpha)

flat hedge
#

ok, I'll take a look into that, thanks!

quartz wasp
#

does the shader graph tool have a way to "shave" off a collection of floats, like turning RGBA into RGB? Been using split and combine, but I feel like there has to be a better way

sick pulsar
#

is there a way to make fullscreen shaders using the shader graph

regal stag
regal stag
# sick pulsar is there a way to make fullscreen shaders using the shader graph

There's going to be a proper Fullscreen graph target in 2022.2+ I believe, but that's an alpha version of Unity at the moment.
As for current solutions, you can use graphs with a Graphics.Blit / cmd.Blit (e.g. for URP : https://github.com/Cyanilux/URP_BlitRenderFeature/, use _MainTex to get source texture).
Or can set view/projection matrices to Identity then use DrawMesh/DrawProcedural/etc to draw a fullscreen quad.

sick pulsar
#

ight

dense bane
#

Unity is about to mess up again with their new Block Shader, if you don't want another SRP nightmware, I strongly encourage everyone to go support jbooth https://forum.unity.com/threads/block-shaders-surface-shaders-for-srps-and-more-public-demo-now-available.1350497/page-2#post-8528396

oak ingot
#

can I assign any float to the uvs of the mesh, outside 0 and 1, then read that data with a custom node in shader graph?

oak ingot
#

thanks

cedar meadow
#

guys can you help me with this one

#

so i created a shader and assigned the material to it, then I put the material into the object

#

after finishing the shader (which, in its preview, is clearly moving), the object doesnt seem to change, it still has the material's base colour, the material as well seems to be unaffected even though the assigned shader is clearly moving

#

am I missing something>?

#

nevermind, I slapped a bunch of buttons and got it fixed (somehow)

sharp arrow
#

Dose anyone have a mirror shader I can use that works instead of using renders because it’s very tedious

thorny owl
#
Library\PackageCache\com.unity.shadergraph@13.1.8\Editor\Generation\Targets\BuiltIn\Editor\ShaderGraph\Targets\BuiltInSubTarget.cs(33,28): error CS0246: The type or namespace name 'BuiltInShaderGraphSaveContext' could not be found (are you missing a using directive or an assembly reference?)

I updated to 2022.1.21 today and keep getting this.deeted libraryfolder and rebuilt it,still same error, any tips?

scenic agate
#

can you split a model so every part has its own matirial

tame topaz
#

Yes, open it in a modeling program and assign materials to the different faces.

sinful ermine
#

hi,
suppose i have a gameobject A that stores a reference to a compute shader.
i have other gameobjects B that access A, in order to assign inputs to the shader then dispatch it

#

should each gameobject B have its own reference to the compute shader, or does it not matter?

mossy sun
#

Im using Universal renderpipeline and i want to set a texture/sprite onto my mesh. However its... just... transparent for some damn reason, no matter what properties i set. Why ?

#

I need to use the "Sprite-Lit-Default" shader... however its just transparent, why ?

sinful ermine
#

are the normals in the right direction?

mossy sun
#

I assume so, in 2020 with URP it worked... now 2021 and URP and its just transparent for some damn reason

sinful ermine
#

ah, well, i dont think "sprite" materials are gonna work with meshes

#

strong emphasis on "Think" though

mossy sun
#

What other shaders might work than ? ^^
It basically downloads an image and should put it onto the 3D plane to display the image... thats the "goal"

sinful ermine
#

try the standard lit ones that come with urp, im not sure if they use texturesamplers or not

shadow locust
sharp arrow
#

Some people use camera and a render texture I’m looking for an actual mirror texture

kind juniper
#

Well, that's how mirrors work. They reflect the view from the perspective of the mirror. There's no more "real" way to do mirrors.

sharp arrow
#

Ok

kind juniper
#

There's no "magic" shader that can reflect the whole scene view without the help of an additional camera.

#

There are screen reflections and stuff, but they're not perfect.

sharp arrow
#

I know vrchat has it but I’m not finna steal it

kind juniper
#

has what?

sharp arrow
#

Has mirror shader and I think it’s called render too for it

kind juniper
#

There's no magic shader that could just make reflections work without additional setup from C#/Cameras/Render textures.

#

It's simply physically impossible.

sharp arrow
#

Ok

shadow locust
#

The only way to get "free" reflections is to use raytracing

lament scarab
mystic hornet
#

Hello! Could anyone help me using the Fresnel effect? I'm trying to make it so that the outline is black, but the inside is colored, but when I multiply it with a black color, and plug it into the emission it doesn't change anything.

karmic hatch
#

Sounds like you're taking the Fresnel node output, multiplying it by zero, and then plugging it into emission - which by default is zero - so it comes out looking the same

#

assuming your object has some base color, you want to multiply the base color by (1 - fresnel) since fresnel goes between 0 and 1

#

(note that it'll be grey on the edges, not perfectly black, because a lit material with a black base color will still reflect some light. If you want it to be perfectly black, you need to do an unlit graph and do all the lighting yourself)

grizzled bolt
karmic hatch
#

You can actually have negative emission

#

(though it probably wouldn't play nice with fog/post processing)

civic lantern
#

How do I access all of the Terrain layers from Shader Graph?

#

I only managed to find the first 4. How does unity pack the rest?

mystic hornet
#

So I should substract after the multiply?

#

If I explained incorrectly, I want the orange to be inside, and the black to be the outer color

grizzled bolt
mystic hornet
#

I'll give it a try thx!

meager pelican
#

The hard way? Temp use a surface shader, generate output and view generated source. Go through the source, figure out all the calls it is doing, all the passes, and you can duplicate the lighting and BRDF functionality for PBR. There's many variants but you only need one, really, and all passes including shadow receiving code in the main part and shadow caster pass, reflection code, color calcs, etc.

lament scarab
#

And how would you go about it?

#

I'm still quite intimiated by shaders in general haha.. especially when I can't use Amplify Shaders

subtle cove
#

Hey guys, does anyone know how to convert a shader (.shader file) to a lit shader graph (for Universal Render Pipeline)?

meager pelican
# lament scarab I'm still quite intimiated by shaders in general haha.. especially when I can't ...

https://docs.unity3d.com/Manual/SL-SurfaceShaderExamples.html

Mostly you'll just do the same things, with a custom vert and custom frag. You'll want a custom vert stage because you pass the original object position (called localPosition) in your fraginput struct.
In the frag you'll do the same calcs and assign the result to the .albedo member. You'll want to set the normal vector, and if using PBR lighting...the metallic and smoothness values even if you just hard code some of them.

With a surface shader, lighting/shadows get auto-generated...it will make all the necessary passes for you.

#

You could try Shader Graph, it has limited support for the BiRP from what I understand. IDK if it will work though, nor do I know what Unity version you are on. I'm not too familiar with BiRP and SG interop.

compact reef
#

hey....how to have movement shader based on interaction?

#

like in case of foliages...if u go through it, it will move on interaction

#

possible by shader script?

#

and is it expensive for mobile? just to guess...

kind juniper
kind juniper
steel notch
#

So how do you go about stacking materials/shaders onto something? Like for example imagine you have a shader that makes the object glow, and you have another shader that makes an object dissolve away. How do you make it so you can have the glowing object dissolve away?
Does this require multiple passes? I'm pretty sure URP has trouble with that.
Do I just slap both materials on, with the dissolve after the glow so its effect takes priority?
Is it that simple?

karmic hatch
grizzled bolt
cerulean agate
#

I'm trying to make a Shader Graph that works as a drop in replacement for URP Lit shader. But I can't figure out what I need to name my Shader Graph parameters. For example URP Lit has a Base Map for the texture. What should I name my texture parameter in Shader graph?

regal stag
# cerulean agate I'm trying to make a Shader Graph that works as a drop in replacement for URP Li...

Can see the property names the URP/Lit shader uses by looking at the shader file in the inspector, or opening it in a code editor. Or use https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader
So for the Base Map / Albedo texture it's _BaseMap
But to clarify, It's not really about the name of the property, It's the reference field in the property settings you want to match.

cerulean agate
#

So this line [MainTexture] _BaseMap("Albedo", 2D) = "white" {} means the parameter name is _BaseMap?

#

I mean parameter Reference?

regal stag
#

Yes

cerulean agate
#

Thanks

#

Is it possible to change the Graph Inspector parameters from input parameters? For example Workflow Mode Render Face etc...or you'd have to make a separate graph with these different optinos?

acoustic mirage
#

Hey, anyone know, what happens here or how i can fix it.

#

After import this Asset Pack i only have these Pink Shaders. Im using URP

grizzled bolt
#

Make new materials for them, or if you have ASE you might be able to compile them again for URP

acoustic mirage
#

Ah okay sorry. Thanks

near crater
#

Hello!
I have a question on shader graph, as I now am able to get into it as the technical artist on a project.
I have a custom shader master flow from the blank shader template, which includes both metallic and specular color. This is due to stuff I was experimenting with in Blender.
Although I am seeing no change when using the specular color value even when metallic is at 0.
Is their something I am missing or can both not be in the same shader, causing metallic to override specular color?

#

..or does it require me to go the color and metallic to dielectric spec route to be able to have both values workable at once?

#

If it is:
Metallic ( black and white map ) - connect to your metallic output
Specular ( greyscale or color ) - for greyscale that will need some extra stuff, but for color that go into the specular color output.
Roughness / Glossiness - a greyscale map you need to connect to the smoothness output
Emission ( black/white or color ) - a black/white mask or color map , with the mask multiplied by a color, with either connecting to the emission output.

#

Ah, so unlike Blender's supershader or Unreals color/metallic to specular, Unity can not do either at the same time, got it.

#

I would ask for you if your reflections are based on math values or a mapped image?

#

From what I have seen in Amplify before, and presumably the same can be said for Shader Graph, if your doing skybox stuff, the skybox math / texture needs to be connected at the end to emission.

#

Also real quick, if I am using the built-in renderer as my target, will shader graph support metallic and specular, or just metallic.
..or would I need URP entirely to use either master stack outputs?

#

Ah okay, it just doesn't let me switch to either on the fly like URP, I would have to add in say metallic or spec manually?

#

For that, I would still connect it to emission from my knowledge.

#

I would agree, given the game we are bringing to a new engine, ala Unity, used specular, but we have had problems getting the same look in Specular workflow, as we were given only the compiled assets, meaning we can get textures and models all working, but we have none of the shader code.
Ala none of the master files, so until I can get the shader code, reason I am trying to figure out this out by guesswork.

#

I mean that is easily gotten around by just pointing a texture's correct channel to the right master stack input.
The part were having an issue with is reflections.
In metallic workflow it looks right, but that makes no sense since they did the same thing in specular workflow.
I have been unable to get that color to black reflectivity in specular mode.

#

Well color to darkened color reflectivity in specular mode anyway.

hallow plover
#

is tessellation possible in shader graph?

grand jolt
near crater
#

So I started from scratch on all this, and okay, built in render pipeline, added specular color to the stack, it is greyed out, does anyone know why?

#

I do not have URP installed for reference.

deep otter
#

Quick question, if I have a voronoi node in my shader graph, no time or anything to change it

#

Is it calculated every single frame?

regal stag
near crater
#

It exists outside URP, so that tells me it can use specular color, but I do not know how.

regal stag
#

I guess the Built-in Lit graph is Metallic-workflow only then

near crater
#

Then why is specular color there without URP then?

#

If it wasn't supported or there in code, then it shouldn't even exist in the menu.

regal stag
# near crater Then why is specular color there without URP then?

It might also be used in HDRP? idk
Looked at the Built-in target source and found references to the workflow mode (as it's likely just copied from URP) but the UI hides it as the shader generation code probably doesn't properly support it yet. https://github.com/Unity-Technologies/Graphics/blob/4ccc5351ef4d264e7cf5d4cdab0024770dbc3740/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Targets/BuiltInLitSubTarget.cs#L138
It does mention "Temporarily"... but given how long it took the Built-in target to even be introduced into shader graph, I wouldn't really expect it soon.

near crater
regal stag
# deep otter Is it calculated every single frame?

Yes, Voronoi (and other noise nodes) are based on maths calculated per-frame.
But shaders are usually pretty good with that so it may not be an issue. Unless you're targeting mobile maybe, then swapping it out for a texture may be more performant.

deep otter
#

Yikes I am trying to use that on shadergraphs and they appear everywhere

#

So probably ill just bake it?

deep otter
desert sluice
#

So i seem to have narrowed the issue down to compatibility with URP, now i just need to translate it to the URP shader language. Does anyone mind helping me with it?

visual basin
#

Is it possible to make a unity surface/texture that can have arbitrary data on it, like if I wanted to make it show my desktop?

near crater
#

So I have an issue, so in shader graph, I have the base color texture going into base color, but it looks nothing like the texture I have to the right.
Yet, metallic is a 0 without any of my math put in, and smoothness is at .5.
Metallic at 0 should be fully showing the base color no problem...yet it doesn't.
Thoughts?

#

I'm using this image as the 'cubemap' for reference.

#

It is called a reflection map, but I am unsure how this would be a smoothness map at that point.

karmic hatch
#

If you're using a custom thing, i would say yes put it in emission

slim steppe
#

I have to convert screen uvs to world positions inside a compute shader, whats the best way to do that?

#

Should I just lerp between the Frustum Corner?

swift loom
#
    float4 vertex : POSITION;
    float4 color : COLOR;
    float4 uv : TEXCOORD0;
    float3 normal : NORMAL;
};

struct v2f {
    float4 pos : SV_POSITION;
    fixed4 color : COLOR0;
    float2 uv : TEXCOORD0;
    float4 screenPos : TEXCOORD1; 
    float4 worldPos : TEXCOORD2;
};```

I want to be able to access the edges of the mesh of an object with this, but I can't seem to do it other than using uv, but that only works on single image objects.
#

I was thinking I would just use the vertex value but how do I just get that?

#
{
    v2f o;
    o.color = v.color;
    o.pos = UnityObjectToClipPos(v.vertex);
    o.screenPos = ComputeScreenPos(o.pos);
    o.worldPos = mul(unity_ObjectToWorld, v.vertex); 
    o.uv = v.uv.xy;

    return o;
}```
Can I add another position/texcoord channel and just do o.vertexPos = v.vertex; or something?
#

i still don't understand the channels at all tbqh

quartz flint
#

I assume this channel is also for asking questions with shaders made with shadergraph?

grand jolt
#

I just solved a problem I had with a vertex color shader, that was missing shadows, by putting addshadow to the end of the #pragma line but I have no idea what I did besides enable shadows.

quartz flint
#

I'm trying to make a shader that will let me do a texture across multiple planes in world space, if that makes sense? I'm not good at shaders at all, so I have basically no idea what I'm doing half the time. I tried to follow some Unity forum posts on how to achieve what I wanted to do but I can't really get there. The Texture seems fine on the preview, but the result is not at all like that.

#

This is what I want (I made it in paint quickly)

#

This is what I get in Unity

#

This is my graph

full zephyr
#

you dont need to triplanar map it

#

you can just use a repeating texture with tiling and offset, with an additional vec2 for adjusting the uv scale

#

and with the world object position added to the offset

quartz flint
#

I'd love to know how to do that.
So I remove the triplanar node, I keep the Position node on world (?), I keep the tiling/offset node and then you say add another Vec2 for offset somewhere?

full zephyr
#

i'll see if i can show you something when i have access to my laptop 🙂

quartz flint
#

Ah. I can show you how I interpreted it, might be close?

full zephyr
#

ahh, world pos to the offset of the tiling and offset node

#

something like that, make sure your texture import settings has wrap mode to repeat, else set the sampler state to repeat

regal stag
# quartz flint

The Position node would need to be Split so you can access the two axis you need for the planar texture projection. Probably XZ/RB in this case.
It would also go into the UV port on the Tiling And Offset as you want to replace the UVs, not offset them.
Something like this

quartz flint
#

This leaves me with an entirely one-color texture

#

I assume I'm doing something wrong

regal stag
# quartz flint

The Main Preview quad is probably aligned to a different axis. Try testing it in the scene instead.

quartz flint
#

It's also completely yellow in the scene

deep otter
#

Can't you do like a tile map and just adjust the size?

quartz flint
#

I have 4 separate meshes that need to line up

deep otter
#

Thats alright as long as you adjust the size of the uv

regal stag
deep otter
#

If you need anything 3d then a triplanar is probably the way

#

If only vertical or horizontal then tile map should do the trick

#

With world pos

quartz flint
#

I tried triplanar at the start but was advised that I didn't need it for what I tried to achieve.

#

It should also be said that I don't really know what I'm doing in regards to shaders. They are black magic to me.

full zephyr
#

if you can have the uvs setup correctly, triplanar isn't really needed, else triplanar is also an option

deep otter
#

If not then theres probably a lot of math needed, or a projected uv which i forgot how to do, but its called projected something

full zephyr
#

i think you mean uv camera mapping

deep otter
#

Or a decal, and let it appear only above a certain layrr

#

Idk

quartz flint
#

I gave up and instead just tried to eyeball it.
It's not perfect, but it's good enough for the purporse

#

Thanks for trying to help me @full zephyr @regal stag and @deep otter

deep otter
#

Glad it worked out

full zephyr
#

just a bit more tweaking needed

full zephyr
#

yeah... honestly just set your uvs correctly and tile them

quartz flint
#

Lol

#

Was it too much?

full zephyr
#

the other option is triplanar

quartz flint
#

Right

full zephyr
#

because this isn't working

quartz flint
#

I know that, like, in Unreal for example, you can click an option that tries to line up materials using triplanar. I always thought that was magical. Though I don't know how to replicate that in Unity.

full zephyr
#

let me see if that's possible

quartz flint
#

I guess this is exactly what we are trying to do here; https://youtu.be/MfJ_1LWe2Q4

In this episode of 5-Minute Materials we look at the World Aligned Texture node! This Material Function allows you to create seamlessly tiling textures across multiple objects by using tri-planar projection to avoid needing proper UV's on your objects! It can save hours of extra work if you know what you're doing, as well allow completely differ...

▶ Play video
swift loom
#

to attempt rephrasing, how do i get the edges of a 2D objects mesh on an object using a slice from a sprite sheet? on a single sprite object you can just use UV but in a sheet the UV and texelsizes don't represent the size of the mesh.

I can get the SV_Position output which is -0.5 to 0.5, which is semi-usable, but I have no data to translate this into on screen pixels using texture sizes or anything, for example making a 2 pixel wide outline.

deep otter
#

Depth cel shading is usually good enough for that, or bake a 2pixel wide outline in your sprite to begin with

full zephyr
#

oh wow it was really simple @quartz flint

quartz flint
#

oh

#

Yeah that is simple

#

What type of graph is it?

full zephyr
#

that's... shadergraph, the same as yours

quartz flint
#

unlit, pbr, etc...what type?

full zephyr
#

i'm using unlit for experimental purposes

quartz flint
#

Alright

full zephyr
#

you just need a seamless texture is all

#

and wow, this node is useful, i'll tile all my greyboxes with this from now

quartz flint
#

This is Triplanar Mapping btw, if you ever need to do environments and whatnot.
I used a single texture to try and do what you have achieved now, but normally you'd use three different textures so you can make a landscape and whatnot.

full zephyr
#

yep, the built in node just samples the same texture thrice

quartz flint
#

Yea

#

But at least with the above you have control, I guess

#

But yeah that kind of texturing is super useful

#

Especially for procgen UVs

#

How'd you make the texture @full zephyr ?
Did you make it square where one half is white the other black?

full zephyr
#

rotated rectangle on background, seamless modifier applied

quartz flint
#

Ah cool. I'm terrible at making textures

#

Lol

#

Thank you

#

Been a big help today

desert sluice
#

https://pastebin.com/SfYGF4YM I'm working on a masking shader for a holographic effect in my game, but i believe the tutorial i followed to help make it isn't for URP. Is there a way I can convert this to be compatible with URP, so I can use it for my project? I have the shader script in the linked paste.

digital pelican
#

The only thing that would require custom editor node is stencil.
This would be best solution in my opinion since it's quite easy starting point, and it should be editor update-proof.

slim steppe
#

How could I convert this to URP?```cs
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
_computeShader.SetTexture(0, "Result", _renderTexture);
_computeShader.SetVector("Resolution", new Vector4(_renderTexture.width, _renderTexture.height));
_computeShader.SetVectorArray("Corners", _corners);

    _computeShader.Dispatch(0, _renderTexture.width / 8, _renderTexture.height / 8, 1);

    Graphics.Blit(_renderTexture, destination);
}```
#

Or do something similar?

knotty juniper
#

OnRenderImage does not work in urp

#

do you want to have a custom post effect?

#

@slim steppe

slim steppe
#

yep

knotty juniper
slim steppe
#

thanks

desert sluice
# digital pelican URP uses ShaderLab with HLSL, this should help https://blog.unity.com/technology...

This is getting me closer to what I need, but it's giving me an error when I manually changed it from CG to HLSL:
Shader error in 'Custom/redDot01': Unexpected identifier "fixed4". Expected one of: typedef const void inline uniform nointerpolation extern shared static volatile row_major column_major struct sampler or a user-defined type at UnityLightingCommon.cginc(4)
I can't seem to find a solution on my own or online. Do you have any ideas on how I could fix this?

digital pelican
#

I think HLSL used float4 instead of fixed4

karmic hatch
#

I've used a fixed4 in hlsl before though (iirc)

#

"unexpected identifier fixed4" makes me think there's a semicolon or similar missing somewhere

shadow locust
#

(I don't know enough about shaders to know if that makes sense 😆)

tropic sluice
#

6ri9cty7uo bj0l.

worldly crater
#

this is my image, UI image (without text)
Made burnt effect shader but problem is its not scaling or respecting aspect ratio
iam not really sure what to google as shader scale and aspect ratio dont give info about it

#

this is with shader

#

can i just "apply shader" to not be stretched

#

ignore alpha difference, resolved that

ebon basin
#

To preserve the aspect ratios I usually just contain my element and use the full screen stretch anchor presets

worldly crater
#

You mean UI element? Well that banner is much slimmer, i resized it for visual effect but would like for shader to be independant if thats possible

#

to be like "overlay"

#

i guess here shader is applied to image and then image is stretched so shader is too

ebon basin
#

Yeah, exactly. Not too sure how you can produce that information back to the shader automatically, you're just stretching the UVs this anyway, but can probably adjust them yourself by changing it in the shader and using fields.

#

otherwise what you'd probably want to do is encapsulate, use the full image stretch pivot/anchor, then reduce the size to where you want it using content resize elements

#

Width resize anchors I think would distort it

worldly crater
#

can i make shader certain aspect ratio?

harsh oracle
#

I want to use the Standard shader but just add the noambient pragma to it so it ignores ambient light. is there an easy way to do this?

#

(I'm using the built-in render pipeline)

worldly crater
#

@ebon basin that is input node, just as Texel Size which gives height and width

#

nothing to make shader "wide"

worldly crater
#

this actually makes it work, but my shader graph version is 10.x while there is object node and with 14.0 version you get objects renderer size which would make this process automatic and not hardcoded. why is my shadergraph 4 versions behind? package manager has no answers

#

oh nvm its part of unity version 2022

ebon basin
#

Texel gives you height and width, but you want the aspect ratio of it

worldly crater
#

Texel gives you size of texture i think which is 1313x111

#

image is 500x100 on screen

ebon basin
#

The idea is you want your shader to adjust as you change the aspect ratio, which if you're using tiling, you'll have to use that information to change those values

#

I'm not too sure, but I think that's the idea of it all

#

Probably some basic arithmetic

#

You can test this by changing the ratios, and seeing the tiling of the shader being warped with different resolutions

worldly crater
#

yeah, thats what iam saying

#

this is with texture size

#

looks bad

#

because sprite is 1313x111

#

it would work if image in scene was same aspect

#

dont think i can make it automatic without unity version 2022.2

#

with hardcoded aspect ratio, looks nice

ebon basin
#

Yeah, that's what I do. I'm curious now and will probably look into doing it later

#

probably already solved somewhere on the forums though

worldly crater
#

combined with some other google results

#

hard to find if you dont know what to look for hahahahah

#

but thanks man, you really helped guide me to solution

#

iam stupid, i can set aspect ratio as variable and set it from script...

analog karma
#

why do the gradient noise has these pink spots?

harsh oracle
#

how do I remove ambient/environment light from the Standard shader?

forest sail
analog karma
#

its a simple blood pool shader

deep otter
#

Try normalize it?

#

Ops saturate, or clamp

digital kelp
#

Anyone know how to make this type of glow around a transparent layer in phototshop?

grizzled bolt
digital kelp
digital kelp
grizzled bolt
digital kelp
grizzled bolt
#

I believe that is what defringe is for
If it doesn't work you'll have to do a similar process manually as I described

digital kelp
digital kelp
ebon basin
#

Ah, I think I've done this before with some blur tool but I cant recall

#

basically need to bleed the blur out, but not affect the picture layer

digital kelp
ebon basin
#

could be one of photoshops billion filters

digital kelp
grizzled bolt
#

The addon is probably not necessary in the modern age since there's the ability to do dilation per-channel

digital kelp
#

Thank you!

grizzled bolt
hallow plover
#

what is the difference between eye space depths texture and raw depths texture?

torpid void
#

I have this shader which stops rendering, but how can I apply a mask to this shader? Such that it only applies blend zero one based on the alpha value of a mask texture?

Shader "Custom/Mask"
{
    Properties
    {
    }
    SubShader
    {
        Tags { "RenderType" = "Opaque" "Queue" = "Geometry-1" }

        Blend Zero One

        Pass
        {

        }
    }
}
regal stag
hallow plover
sinful anchor
#

How do I make two transparent tiles/sprites overlap without any overlapping areas becoming more opaque like in the red square below?

regal stag
torpid void
regal stag
torpid void
#

thanks bud

regal stag
teal compass
#

hey all, im following this tutorial where ill be able to make speedboard shader
but when i apply shader to material, surface input options where i can insert 2d texture arent showing up

where im doing wrong , can someone point out? Im new to shaders

grizzled bolt
compact reef
#

what will be the most performant alpha for mobile?

#

alpha blend vs alpha fade vs alpha cutoff vs src alpha?

#

@digital kelp would these be still edgy(zigzag) when inserting in Cutout instead of alpha blend...?

grizzled bolt
compact reef
#

when i am using lambert alpha blending instead of alpha cutout ...it is giving poor performance by a weird spike called Gfx.wait for present

#

i am not even turned v sync on

#

idk...but this thing is utterly killing my whole project when i using alpha

grizzled bolt
compact reef
#

any alternate solution for this since decades?

grizzled bolt
# compact reef any alternate solution for this since decades?

Not many that I know of
On mobile hardware especially you need to keep a track of how many layers of overdraw are on each given pixel, it's probably doable to have some transparency if you avoid such surfaces overlapping
With modern rendering transparency isn't getting any better, and with many technologies it's getting harder, which is why even desktop games often use dithered alpha clipping to replace it, though it won't really look transparent

compact reef
#

what should i do then?

grizzled bolt
#

Hard to say

#

@compact reef Probably the best option at this point for your sanity is to use opaque effects only, like most mobile games
Or study mobile optimization more until you have a grasp of the options and can decide which one is the most appropriate for your project's specific needs

compact reef
#

im curious how those games like pubg...renders trees they r supposed to using alpha

#

i have applied This on my 37 foliages

#

on First LOD it is Cutout on the second LOD it is Alpha blended(which makes it looks better and smooth)

#

and Got 29 fps on my mobile

#

Samsung A10

#

with bloom and Tonemapping post processing effect

#

i was thinking to make more performance out of it

#

am i supposed to hope for more performance?

#

@grizzled bolt...

grizzled bolt
compact reef
#

poor game

#

but why so famous

slim steppe
#

How can I check if the stencil value is even?

regal stag
slim steppe
#

Thanks!

slim steppe
#

Would ref 1 check if its not even?

desert sluice
#

I keep getting this error with a custom shader I used for a red dot sight I made, and can't seem to find any solution for it online. I've checked, and I'm not referencing cginc in my shader. I had manually converted it from CG to HLSL, and I haven't gotten any errors other than this. Does anyone have an idea as to how i could fix this?

Shader error in 'Custom/RDS01': Unexpected identifier "fixed4". Expected one of: typedef const void inline uniform nointerpolation extern shared static volatile row_major column_major struct sampler or a user-defined type at UnityLightingCommon.cginc(4)

wintry valley
#

Is there anything specific that needs to be done for debugging shaders with renderdoc? I was following the documentation for Unity and included the line #pragma enable_d3d11_debug_symbols into the CGPROGRAM block of the shader, but when opening RenderDoc I am unable to find any specifics on this shader. I was needing to debug a variable, as it seems its not being set but I am unable to do that currently.

compact reef
#

is shader graph good for mobile devices?

#

We all know that now
built in RP supports shader graph too....so...will that be a good choice using in mobile project?

tame topaz
#

It has nothing to do with performance, it's just generating shader code for you.