#archived-shaders

1 messages Β· Page 90 of 1

glass apex
#

I have narrowed down the problem to Object Scale

#

if I use a constant vector 3 instead of the object scale, the rendering is completely fine

#

how am I supposed to know its scale if I cant use this tho

kind juniper
glass apex
#

I mean this isnt changing

#

I just set some random numbers for the scale

#

but they are not invalid numbers

#

and I cant really see how else I could do what I wanted without getting the scale. The goal of the shader was to create a fade which took place over a set world distance of say like 5 units, removing itself from the scale of the object

#

the only way I know how to do that would be to get the scale and sort of undo it from there

#

which I got to work, except apparently having 2 objects is a big no no

#

yep

#

just wrote up a quick test shader

#

its really dumb, but the instant I duplicate the object, both things stop rendering correctly

#

im like 90% sure this is a bug in urp or shader graph

#

although tbf I am on 2021.3.19f1

kind juniper
#

Material instances

glass apex
#

thank you unity discord, anyway, can you actually duplictae materials at run time?

#

if so that might solve it

kind juniper
#

Yes. It would get instantiated automatically if you use the renderer material property. Or you can Instantiate it manually.

#

I'd suggest defining a custom property in the shader(and use that instead of scale) and assigning it manually in update or something. That would guarantee a new material instance is created.

glass apex
#

ima go write a thing and see if material duplication solves this

#

if so then thank you

kind juniper
#

I'd also check if you're using static batching on the object, as that could mess up shader properties like that as well

glass apex
#

idk what that is, but I just made a new object through 2D Objects > Sprites > Square, so if that has static batching by default then it could be

kind juniper
glass apex
#

just tried duplicating the object's material using instances

#

that worked

#

thank you kind sir

#

have the blessing of the worst testing code I have ever written

grizzled bolt
#

Shader Graph for 2021.3. doesn't support Canvas images

#

It has all kinds of unpredictable behaviour even if it sorta works

glass apex
#

not using a canvas

#

just sprite renderers

#

but I have got the problem fixed with material instancing

#

thanks to dlich

native jacinth
#

is there a web or something i can use to code hlsl

#

mines is still not resolved for no reason

kind juniper
kind juniper
native jacinth
#

the hlsl file

#

visual studio does not read the file

#

the file extension is .shader however for some reason its just not reading it

#

im quite new to hlsl and i wanted to learn about it, its just not effective because i have to compile it from unity as i cant depend on the visual studio

#

@kind juniper

#

i want to try things out, sadly its too slow for me to try out

kind juniper
#

The intellisense doesn't work you mean?

native jacinth
kind juniper
#
  1. You can install the hlsl extension in vs.
  2. Get used to it. Real shader programmers don't rely on intellisense.πŸ’ͺ
native jacinth
#

thats fair, but i want to learn effectively
im totally new to the language, the compilers not helping me identify errors so i cant really just test things out

kind juniper
#

And whatever that second(first if ignoring the comment) line of code is, it doesn't seem correct no matter what language it is.

native jacinth
#

it does help but not in this state as of right now

#

and i do already have the hlsl extension im kinda confused

kind juniper
native jacinth
#

its not the intellisense that kinda in the case of finding the keywords if thats what u meant
i just want to know the errors

kind juniper
native jacinth
#

yea unity console did compile it but not directly from the visual studio

#

its not that effective if i have to save, wait unity to compile and see the errors uk

kind juniper
kind juniper
native jacinth
#

alrighty then

dim yoke
#

that's the place people code shaders online and share with others

manic niche
#

are these 3 just templates for the same thing or does unity treat my shader differently depending on what I chose here?

subtle obsidian
#

Hello. I need some help, terribly. I'm working on a shader for use in a scene with only point lights, but I get a square point light shape. They are very annoying and causing some delays in my work. Does anyone have a way to get around this? Please πŸ™

subtle obsidian
#

I'm using Amplify Shader Editor, btw.

warm moss
#

@subtle obsidian what do you mean by square light shape?

#

It looks like your lighting looks fine, looks like you implemented stylized lighting ramping.

#

Or did you do that accidentally?

subtle obsidian
#

If you look at the image. There is a nice circular falloff from the point light. But if you look at the top right corner, you will see the top right corner of a square, and outside that square is unlit.

subtle obsidian
#

maybe this shows it more clearly

warm moss
#

I guess you broke the light distance attenuation curve and now it doesn't go down to 0.

subtle obsidian
#

well I don't want it to. because I don't want black outside the falloff radius.

warm moss
#

Are you extracting the light positions and using them with your own attenuation curve?

subtle obsidian
#

This is what I use for light attenuation. It looks like a nice curve shape. But again, I don't want a black unlit color, and anytime I try to increase or remap these values to anything above 0 (black) the square comes back.

#

Also.. I don't think OneMinus works properly in this instance. In ShaderGraph, I would just OneMinus the light attenuation to invert this gradient, and use that as a mask to multiply a base color. But in Amplify it does not work as expected. If I use OneMinus on this output, I will get all White (1) which makes no sense to me

#

So I feel like I need another way

warm moss
#

Well, think about it this way. If an object is outside of the bounding box of any light, what's going to make it match to the darkest color of a lit object? I think you need to have attenuation that goes down to 0 and add a constant ambient color to raise the floor. This way both lit and unlit objects will have the same lightness floor value.

#

I really dislike debugging visual shader graphs so that's as much rubber duck debugging I can do at a glance πŸ˜†

subtle obsidian
#

the area outside the circular falloff seems to get more added to it.

warm moss
#

That's kinda odd, can you post the generated text shader? Though if it's not for HDRP or URP I'm a bit rusty, been ages since I looked at builtin rp shader code.

subtle obsidian
#

Also, its additive with multiple point lights

warm moss
#

Ah. Birp does this outdated approach I think where it invokes a shader pass for each 4 lights?

subtle obsidian
#

I think Ive read something like that. each pointlight is a new pass through the logic

warm moss
#

Maybe your custom lighting is going into that additive pass instead of the base pass.

subtle obsidian
#

i would love to learn more about not doing that

warm moss
#

Could always write the shader by hand πŸ˜†

subtle obsidian
#

XD ohboy.

#

never done that

#

but I learned theres a Custom Expression node in ASE that can support code

subtle obsidian
warm moss
#

Well, you can at least check the source code for the generated shsder and see in which pass your ambient color gets added.

warm moss
#

Oh, also try adding the ambient to the albedo instead.

subtle obsidian
warm moss
#

No, I mean plugging a Color node to the Albedo slot. At some point you'll add colors to your shader and then you'll instead plug color + constant custom ambient color to the albedo slot.

#

And by plus I mean adding those two colors.

#

Albedo = mainColor + ambientColor

subtle obsidian
#

Ok. I tried this. Nothing changed. I have had issues with the albedo channel before. Just doesn't work. Emission works but it doesnt help me

#

Do you maybe know why the albedo channel does nothing?

subtle obsidian
subtle obsidian
#

Ok I've looked at the shader code. If I understand correctly....
I see this LightingStandardCustomLighting get a +=

its in a function that starts like this

// fragment shader
fixed4 frag_surf (v2f_surf IN) : SV_Target {
subtle obsidian
grizzled bolt
#

@subtle obsidian Use ambient lighting for the light color outside of any lights
It doesn't make sense that individual lights could control the lighting of objects outside of their influence

subtle obsidian
#

Unless you know a way to do what you suggest without producing the square.

#

I don't necessarily want the point lights to light anything outside because so far as I know, it's additive and will lighten in an undesirable way

elder plover
tacit parcel
kind juniper
echo moatBOT
naive arrow
#

hey yall on this shader this color isnt solid and its making it near impossible to make a hue shifter how would i make it so its a solid color?
and i also tried changing the A and it doesnt effect it its still a weird gradient. any ideas?

amber saffron
supple kayak
#

Not sure if I should put this in the shader chat or coding chat but I am basically creating a mesh from c# and I want to have my triangles a singular color(for the low poly effect). Now I am guessing the way to achieve this is making sure three vertices that make up the triangle all have the same color but the result is not what I really hoped for.
My guess is the shared vertices that the triangles have, and that might be whats causing the issue but I have no idea on how to solve it πŸ˜”

amber saffron
grizzled bolt
raw cliff
#

Any idea why this shader is affecting the pivot position? It suposse to be a grass-like movement

grizzled bolt
raw cliff
lament karma
#

Is there a way to isolate only the objects behind a shader using depth?
I know I can compare depth values from whatever the screen is seeing with Scene Depth node, but I'm not getting the depth of the shader I'm doing the calculations on. The shader itself is transparent, and not included in the depth texture.

#

I'm trying to make a distortion-type portal, but I only want the stuff behind the portal to be distorted.

#

My idea is to use a branch and just take normal scene color instead of the distorted one if the depth is below the position of the portal-shader.

#

But my issue is to get the actual portal-shader fragment depth...

#

any ideas?

regal stag
# lament karma But my issue is to get the actual portal-shader fragment depth...

Either of these get the depth to the fragment being rendered
Position node View space -> Split/Swizzle "B" -> Negate or Absolute node
or
Screen Position node set to Raw mode -> Split/Swizzle "A" (though this one only works for perspective projections)
(in world/eye units, so would use Eye mode on Scene Depth when doing comparison)

lament karma
#

well not the same way - but they yield the same result?

regal stag
#

Assuming perspective projection yes. The latter one using screen position is more commonly used, but is always 1 for orthographic cameras.

supple kayak
# amber saffron You guessed right, if you share the vertices between the triangles you can't sep...

hmm do you maybe know on how I can duplicate the vertices? I have spent some time now and I cant figure out a "algorithm" on creating the vertices that way and then sucessfully setting the triangles with the duplicated vertices. Dont know if you maybe have some experience with this
the code for the mesh https://pastebin.com/Kr4TeM7c

thin lintel
#

hey guys, I'm quite new to shaders, but I was wondering if anyone could tell me how to turn my fullscreen shader into an overlay? preferably with the ability to set its "alpha" to a value for different parts of the image?

#

I'm creating a blur shader, but what I would want to do is make it so only dark parts of the image are blurry

#

meaning basically the alpha in the blur overlay would be lower in brighter parts of the image

amber saffron
# supple kayak hmm do you maybe know on how I can duplicate the vertices? I have spent some tim...

Well, you need to rethink your mesh generation logic.
You are doing a grid where each cell is two triangles. But share the triangles vertices.
Currently the vertex count is (density+1)Β² and triangles count is densityΒ² * 6 (number of triangles * 3)
Well, have as many vertices as triangles indices, and give each triangles unique vertices.
The end algorithm isn't that much different than what you already have, just have more vertices and some will have the same position as they are at the same grid position, but relate to different triangles.

supple kayak
amber saffron
# supple kayak So vertexCount would be the same as triangleCount? I am sorry, I am kinda lost h...

Figure out a quad, made of two triangles, and 4 corners.
The triangle index array will be 6, 2 triangles * 3.
And because you want to have an uniform color over each triangles, you can't share vertices, so you need 6 vertices, 3 unique ones for each triangle.

So yes, on any mesh that is flat shaded or where you would paint vertex color by triangles, the vertex array will be the same size as the triangle indices array.

amber saffron
supple kayak
#

yeah you are definetly right, i should probably simplify my problem before I start dealing with thousands of vertices. I am gonna make the quad manually and from that figure out getting loops into . Thanks for your help!

halcyon hawk
#

How can i set #pragma target 5.0 for custom function in shader graph?

silk seal
#

Is there a way you can get the additional light info in the shader code and do something with intensity and the texture2d? (2D sprite in 3D URP). Wait does it matter if I'm using 2D sprite or not?

amber saffron
thin lintel
amber saffron
muted laurel
#

I'm getting these glitches here and there, and the whole shader looks pretty uncomfortable and scratchy when the camera moves - and these artifacts between texels appear frequently

#

I'm guessing it's a floating point error thing?

dim yoke
#

often happens for specific row of pixels with same uv value for example

steel notch
#

Looking to try my hand at recreating this type of effect. How do you do this sort of layered 3D rendering? Stencil buffer shenanigans?

regal stag
steel notch
lament karma
regal stag
dim yoke
#

Id say it would be easiest to just use parallax for the offsets. Only seems to be two layers in this case so shouldn't be too hard to use different depths for different parts

#

I mean parallax with the character seemingly in front and background behind the card. The text and such seems to just be slapped on top of the card separately

#

With actually different depths and stencils you may run into problems if you need multiple cards on top of each other

nocturne hill
#

I am trying to follow a tutorial to fix my water refraction issue. They are using Amplify and some of the nodes are not in normal Shader Graph.
What is the Shader Graph equivalent to Amplifys Surface Depth node?

elder plover
kind juniper
elder plover
kind juniper
steel notch
#

Looks sort of particle-like.

steel notch
#

Also parts of the body don't even seem to be on the same layer.

#

Tail is under the border while wings are above.

tacit parcel
elder plover
little adder
#

Hey guys I have a shader and i want to Include options to enable or disable the effect for different sprite states (e.g., hover, selected).What is a good way to do that?

strong tinsel
#

I am working on a game, this bullet has a shader assigned to it, there are no light sources in the game , compute shader is used for that, now i want to add glow to the bullet as if its glowing when its dark can this be achieved solely with shaders without light sources, I am using built in rendering pipeline, if yes then can someone guide me where i should start

amber saffron
# strong tinsel I am working on a game, this bullet has a shader assigned to it, there are no li...
  1. You need to understand how glow usually works : Glow in the general use case is a post process that "bleeds" pixels of high intensity to their surroundings. So it is not somethings that individual object do, but an overall screen effect. Most of the time this is done using the emission property of lit shaders, or by having a high color value (higher than 1) on unlit shaders.
  2. In some cases, you can fake glow by using some transparent object with an additive shader
  3. Glow never lights other objects. That's what lights are for. For high intensity objects to actually light their surroundings, you need global illuminations. Baked for static objects, or realtime (SSGI, Raytraced GI) for moving objects like your bullets.

So, in the context of the built-in pipeline :
Simple solution : add emission to the shader or increase the output color value, and add a glow post process effect
If you want them to light other objects : add an animate a lights source, or use realtime GI.

steel notch
#

So I have an issue. I'm trying to create a sense of parallax. The problem is that when I set the offset to be "closer" to the camera, the texture suffers from distortion if the camera physically gets close enough.
Parallax when farther from camera.

#

This is the shader logic.

#

I'd obviously like there to be no distortion, but I'd also like it if the texture suffered no change in apparent size.
The goal is to create a faux parallax, something similar to this.

amber saffron
steel notch
#

I'm assuming this distortion occurs because the view direction operates on a per-fragment basis, and the angle across the image gets bigger as you get closer.

steel notch
#

Is there a way to prevent it from changing apparent size?

#

Noticing some oddities around steep angles. Makes sense why that'd happen.

amber saffron
#

You coudl also try the "Parallax Mapping" node πŸ˜„

steel notch
#

I saw that node.

#

I am scared of that node.

steel notch
amber saffron
steel notch
#

oh, hmm

steel notch
amber saffron
#

The direction is in world space.
So you need to transform from "World" to "Tangent" and indeed set the type to "Direction"

amber saffron
#

Yup

steel notch
#

Wish I knew exactly why this worked though.

amber saffron
# steel notch Wish I knew exactly why this worked though.

When using the "view direction" node, as you've mentioned, the value is per pixel (it is camera position - pixel position, normalized). So when looking from close up, the vector goes away from the center of the screen, resulting in a zooming effect.
But the camera direction vector is a constant vector over the whole screen (it is the camera transform forward vector), so it uniformly shifts the UVs.

steel notch
amber saffron
steel notch
#

At any given frame, we use the camera direction vector to get a new point along this unit sphere, which is then projected back on the XY plane because we ignore the Z.

#

Offset is used to modify the radius of this unit sphere and simulate farther distances.

#

Right?

#

Ooooh and we switch to Tangent space so this XY contribution aligns with the UVs.

#

Fucking shaders bro.

#

It's just linear algebra and trig all the way down.

amber saffron
#

Yep, always πŸ™‚

steel notch
#

Does this type of parallax have a name even?

amber saffron
#

Probably, but I don't know it :p

steel notch
amber saffron
#

πŸ€·β€β™‚οΈ

dim yoke
#

This seems to work nicely at first but it's hard for me to believe this would be the mathematically correct way to simulate it as if the texture was at different distance. Especially when you are close to the quad and rotate the camera (without moving), the texture seems to move a lot even though it should stay at the middle of the quad

#

I think you should actually use the view direction in tangent space and do some simple math to calculate the right uv shift

hushed silo
#

I have a bunch of shader properties in groups on my blackboard that I want to copy into another shaders blackboard... Is there a way to do this?

steel notch
dim yoke
#

let me show you

hushed silo
# amber saffron Copy/paste should work

thanks for this. On my end it seems what's happening is that the copy and paste will fail (do nothing) if there's a category in it. but I guess I can just recategorize them

amber saffron
hushed silo
#

that's not working either on 2022.3 but I'm close enough thanks again

dim yoke
#

@steel notch @amber saffron I miraculously got my maths spot on the first try too πŸŽ‰ . Let me show how mine works. I also added an actual sprite that I enable in the video to show that it matches exactly what it is supposed to look like if it was a sprite behind the quad (also works for negative distances meaning it would be in front). The math also simplifies to only couple very cheap nodes too.

steel notch
dim yoke
amber saffron
dim yoke
#

it would. Still the apparent size would slightly differ but that's what's supposed to happen in parallax mapping

steel notch
dim yoke
#

I think it is very slightly in front though

#

And if it was in front, it should scale larger when you move closer no?

#

This method shows the image exactly like with the stencil method discussed earlier

#

With the character only slightly above the card surface it would likely look very similar to the example provided

steel notch
#

The View Direction solution seems to not like it when you get too close πŸ˜›

dim yoke
amber saffron
# steel notch

That is when the camera goes under the "virtual plane" where the iamge is projected.

steel notch
#

Assuming something flips when the camera distance becomes smaller than the simulated distance.

#

Ya.

dim yoke
#

You can just make sure it hides the texture when the distance is smaller but I don't think you want to go that close to the cards anyways. The character seems to be very slightly in front of the card in the example footage, not like one card length away like in this one, more like 0.1 card lengths

steel notch
#

If you want to change the parallax you gotta mess with the tiling this way.

dim yoke
#

There could also be some middle ground between these two

mental bone
#

Anyone know why my Graphics buffer does not show up in renderdoc ?

low lichen
mental bone
low lichen
mental bone
#

Hmm a shader does use it. But the resources inspector does not change between events…

low lichen
uncut sonnet
#

How could I get the pixels behind a mesh in HDRP, like how grab pass works in BiRP, I need it for an atmosphere shader

mental bone
mental bone
mental bone
uncut sonnet
#

yeah IK, but it doesn't exist in shaderlab, and I need it there

mental bone
#

Just look at what the shadergraph compiles to. I don’t remember how to sample the color buffer unfortunately.

uncut sonnet
#

so I could just call shadergraph_HDSampleSceneColor to get the same effect?

regal stag
#

If you use that include, or could copy the function/body

peak marlin
#

Hello, I am having a little trouble with a vertex shader I made for an ocean. Specifically I am having trouble with the normal map displaying correctly compared to the video I am using as a starting point. I have deliberated for a day trying to figure out why it's broken and I can't figure it out. I am using URP on unity 2022.3.47f1
I can show the video, what it's supposed to look like, and what's wrong if anyone can help

grizzled bolt
peak marlin
# grizzled bolt Yes, that is information we would require

Should look somewhat at least like this, but instead looks like this. I know my planes have less vertices than his, but I don't think it would cause this
Here is the video I was following:
https://youtu.be/QAH1Kep3zRM?si=PNqoz0UCw_9Y9x9w
around 26:46 is where I am, I have some normal maps I'm using for noise across the surface but I cannot get the basic part figured out so I turned it down

I've been experimenting with shaders a bunch recently, and wanted to showcase some of the techniques I used in this ocean shader. It's my first tutorial, please be gentle.

00:00:00 intro
00:02:01 shader setup
00:03:17 wave generation
00:15:44 secondary sine wave
00:20:14 normals
00:28:00 edge foam
00:42:57 wave crest foam
00:45:40 desmos graph
...

β–Ά Play video
#

this would be the part I am having trouble with atm, even if I pull from what I put into that vector3's y value instead of what I currently have it still does the same thing

#

by that I mean this, it hasn't made any difference

#

it is probably something stupid that I just don't know yet as I am learning unity, but if anyone needs more info I can provide it

tired skiff
#

hey did you find a solution for this ?

#

or for this. I have the same problem

#

Looking for a impact collision shader on sphere with a wave or custom noised dissoleved effect on it. What i find around is kjust a simple circle on collision.

steel notch
#

Having an issue where when I blend a texture, I get these dark regions at the border.

#

I assume I'm fucking up the alpha

sharp frost
#

Is all node correct for the mobile?

#

Sometimes in mobile fps getting dropped.

dim yoke
# sharp frost Sometimes in mobile fps getting dropped.

Could be caused by many other things too. All basic arithmetic is pretty fast on GPUs, I don't think any of the nodes are particularly expensive, the most expensive would be texture samples which aren't really that expensive either

sharp frost
#

Thanks.

Texture samples in terms off? Could you please explain more about it?

#

will the sampler state work?

dim yoke
sharp frost
#

oh! got it.

#

I understand something else, I got your point. I think I have to add one more node that is sampler state.

#

maybe that will work.

dim yoke
#

The texture import settings are used if no sampler state is defined

sharp frost
#

I have already sated textures setting as per the mobile.

kind juniper
sharp frost
kind juniper
amber saffron
sharp frost
sudden lake
#

any one how how to make cross section shader graph

sharp frost
#

Yes

sudden lake
sharp frost
sharp frost
sudden lake
#

bro this is not working i tried

sharp frost
#

for me its working

sudden lake
# sharp frost

bro what i want is i want expose inner texture as well so that it look like a solide mesh

#

it is currintly hollo mesh i want this type of behavior

dense patio
#

Has anybody have a shader or does anybody know how I would create a "censored" / "pixelated" local shader which I could attach to a plane or other 3d object to pixelate everything behind it? Ideally in shadergraph and HDRP.

sudden lake
dim yoke
# sudden lake it is currintly hollo mesh i want this type of behavior

I think that's usually done by rendering the back faces as if they were flat at the intersection. With shader graph though you will run into problems with shadows/reflections/lighting/SSAO/you name it because you can't change the apparent pixel positions in fragment shder. Now that I think about it, there might be a way to actually project the backfaces into the intersection plane in the vertex shader and keep only the relevant parts in the pixel shader but I'm not yet sure how exactly that would be done

dim yoke
#

With custom interpolators at least you should be able to keep track of the original position before projection to the intersection plane and use that to cull the pixels based on depth

regal stag
woeful knot
#

Hello, How can i add a normal map to this shader ?

dim yoke
regal stag
dim yoke
#

Like shadows that get inside the intersection/box reflections/screen space effects etc.

#

Haven't looked into Remys solution, the demo looks cool at least

toxic peak
#

Hey everyone, does anyone know if there is a way to make a general lighting (like the sun) in Unity work in per-Vertex mode instead of per-pixel (like you can do with dynamic point lights)?

craggy dune
#

Hi guys, How can i use Standard surface shader with HDRP ? because its actually pink

steel notch
#

Alright I'm confused about something. I have a shader here that just combines 2 textures through a lerp. Here is the result and the shader. The top layer has a blur to it, so it's semi-transparent along the border. For some reason, this border region appears darker than you'd expect.

#

This is the result that I want, and I can get this using the follow graph, but why does this work but not the other?

#

Is there something off with the alpha channel? Some pre-multiplication?

regal stag
low lichen
steel notch
low lichen
#

Cyan is right, I didn't look at the graph closely enough before answering.

steel notch
#

Ok I just pumped the R,G and B directly into the output.

#

And it's all white.

regal stag
#

Depends on the texture and how it was exported and imported... πŸ˜…

steel notch
#

Except alpha.

regal stag
#

Yeah, that's what I expected based on the results above

steel notch
#

So once I bring in a colored texture and just show the red channel, obviously we see the red contribution, but there's also these messy regions surrounding the art. What are these?

regal stag
#

The rest might be from the texture data itself

uncut sonnet
# regal stag If you use that include, or could copy the function/body

Okay, I'm kind of stupid, how exactly do I do that, because I have added/copied shadergraph_HDSampleSceneColor into my shader, it just returns the default black color. I have also added #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl". Is there something else I have to enable?

steel notch
#

Like creating repeating regions to save on space?

regal stag
regal stag
#

Could be easier to just use return SampleCameraColor(uv) * GetInverseCurrentExposureMultiplier(); instead

uncut sonnet
#

doesn't exist apperantly

regal stag
#

Then another include is probably needed

uncut sonnet
#

I'm just wondering which

steel notch
steel notch
#

Like for example, Unity's default particle.

uncut sonnet
regal stag
#

In these cases I'd probably use the texture only in the T input and just a color property in the B one

steel notch
#

Ya this does it.

regal stag
uncut sonnet
#

yeah, it's just after pragmas

regal stag
#

Hmm not sure why it wouldn't work then

uncut sonnet
#

yeah me neither

#

Oh well I'll sleep on it and keep banging my head against a wall tomorrow

vapid garnet
vapid garnet
waxen grove
#

Hello, is anyone there avaliable to help me calculate coords for my skybox?

#

It's a very strange issue- but it should be simple to fix (Just not smart enough to fix it myself lol)

#

Using a modified built-in skybox, I've created this function which is supposed to project a texture unto the sphere:

{
    return float2((0.5) - (acos(dir.x)/2), (0.5) + (asin(dir.y)/2)) / size;
}```
When it's called:
``tex2D(_MoonDetail, projectImage(-ray + _WorldSpaceLightPos0.xyz, _MoonSize));``
``ray = normalize(IN.vertex.xyz)``

This accurately projects an image onto the skybox! Well, expect when the sun is around ``-90`` or ``90`` on the y axis, it starts to stretch... I've discovered that this fixes this, but presents the same issue but for the other axis
```float2 projectImage(half3 dir, float size)
{
    return float2((0.5) - (atan(dir.z)/2), (0.5) + (asin(dir.y)/2)) / size;
}```
I was trying to merge them together, but no matter what I would do it would make wacky results:

```float2 projectImage(half3 dir, float size)
{
    return float2((0.5) - ((acos(dir.x) + atan(dir.z))/2), (0.5) + (asin(dir.y)/2)) / size;
}```

I'm so close yet so far to getting a moon texture on my skybox, and if someone would help me how to normalize each value out, I would GREATLY appreciate it!!
silk seal
#

Does anyone know why whenever I double click the .shader file or .hlsl file (in Unity Editor) it always opens with VSCode but not Rider? I can open the C# file with Rider when double click but not .shader and .hlsl

toxic peak
#

Yo, Im trying to get a shader graph that uses Main Light Direction to paint shadows but not per-pixel as by default, but instead per-vertex. I am using a URP Unlit shader as a basis for that, but... is that wrong? Don't I need there to be a Color node in a Vertex block?

toxic peak
#

Oh dang, thank you!

steel notch
toxic peak
#

it is rather useful tho. I remember visiting it before, and after a while I often find myself looking for something that this site has

#

Fog Plane Shader and an article about Depth are a must have

#

it kinda pisses me off a bit that when you google for these things - you mostly get results from reddit, unity forums or youtube

#

but there are a lot of blogs/sites like this that might have exactly what you need, but they don't show up as much

#

okay when I get paid from the games I put out - this fella is getting something

toxic peak
#

Okay, I was trying to blindly get this thing to work, and I ended up in an Unlit shader that includes:

  • Vertex Shadows which were painted onto the model by hand as Multiply blend
  • Normal Shadows from Global Illumination
  • Ambient Light that lights up the Normal Shadows from global illumination
  • Inclusion of the scene Fog that blends as a Screen blend

The problem is, Im plugging it all into Fragment Base Color, sooo, even though Im calculating shadow from comparing surface normals with global light direction - I don't think it's actually vertex-based shadow, so now I have to read up and figure out how to plug the same stuff into a custom interpolator

uncut sonnet
#

Does anyone have any idea on why it isn't, or where that function is actually defined?

neon hazel
#

How do I make a Canvas Shader Graph maskable?

#

Apparently just adding a new float named Stencil did the trick

tired skiff
#

Hey @regal stag
considering the force shield here: https://www.cyanilux.com/tutorials/forcefield-shader-breakdown/
Is it possible to have better impact like this in the image?

The impact we have on that shield is just a simple circle. I would like to see something with a mask texture for the impact, so that I can custom it as I prefer with an alpha mask and not just a perfect circle. is it possible?

A forcefield shader using fresnel effect for glowing edges, scene depth for object intersections and scene colour to produce ripples/distortion

#

and is it possible to make it work with hdrp?

#

hope you can help me. Thanks

jagged lodge
#

What reason might there be for one of my shaders being missing from build? It simply highlights some objects. It works as expected in editor but in build the objects become pure purple when highlighted by the shader

peak marlin
kind juniper
#

Make sure the build uses the same quality settings level as the editor.

neon hazel
#

The color from an Image doesn't match what is rendered in the game when using a canvas shader graph. This is most likely due to my game being in linear color space. Any idea how to convert the color properly within the shader graph?

regal stag
neon hazel
#

I wasn't using any texture, but I think I was doing something wrong in the shader overall, I wasn't using vertex color as I should've

#

And tried color space conversion too and yeah it wasn't the answer here

regal stag
# tired skiff Hey <@357936113983291393> considering the force shield here: https://www.cyanil...

Using a mask texture would be possible but not sure how you'd calculate the uvs to project it along the ripple direction atm, and might be a bit expensive anyway as you'd be sampling for each ripple.
Adding some noise that is mapped to the shield instead should be easier to make the ripples less circular. e.g. sample noise in graph, Multiply by 0.1 and pass into custom function, add to 3rd param of smoothstep I think should work

remote tartan
#

pls help. Material is working on cube but doesn't working on my model

regal stag
remote tartan
modern rapids
#

Using ShaderGraph (Unity 6, URP) is it possible to have self shadowing in a custom lighting shader? (base shader is unlit)

twilit geyser
#

Petition to rename this channel Cyan-Support or Ask-Cyan πŸ˜„ The amount of help you give the community is insane. Unity should pay you.

hushed silo
#

I don't suppose there's any way of doing some kind of each-eye-different processing in shadergraph whilst still using single pass/multiview VR mode? I'd love to be able to do even something as simple as something like if left eye +1 if right eye -1 , but I can't pay the performance overhead of multipass VR for it

cosmic prairie
#

It's a bit tedious but can be done

#

You'll need to search in the #include-ed .hlsl files

#

Hopefully we get block shaders soon so we don't have to mess around like this for long

#

Also, if you're using a "CG" shader you'll need to make it into a HLSL one by replacing ENDCG with ENDHLSL and same with BEGIN or whatever it's called. Also the base Unity .cginc won't work

#

you'll need the Core.hlsl include at least in your shader

cosmic prairie
#

I'm guessing 0 is left 1 is right

hushed silo
#

ooooh, and I guess this is that

cosmic prairie
#

yea

hushed silo
#

super nice, I didn't know we could get this, thanks!

cosmic prairie
#

I was about to suggest hlsl blocks, didn't know eye index was a default thing

#

no problem!

rugged relic
#

I got a quick question about shader variant compilation for builds: Each pass of pretty much any shader being compiled is taking about 2 full seconds on average, which I feel like is way too slow. Any tips to speed up this process? I have stripped pretty much all the variants I can, I'm just trying to see what I can do to speed up the time it takes to compile a shader variant. Unity is using 100% of my cpu to do this

#

I'm using an intel core i5-8400 with 24gb of ram

gloomy gust
#

Is there some way to do color replace on these colours with shader graph?

#

so i can make chromas easily?

waxen ridge
#

how can I add some code to the URP Terrain Lit shader vert's function? I am using unity 2022, but if I go to the Packages/Universal RP/Shaders/Terrain/TerrainLit shader code, tehre's no vert function

ebon moss
#

anyone know y the specular seems inverrted on my water?

neon hazel
#

How to make a canvas shader additive?

silk sky
#

I'm trying to achieve a good TV scanline animated shader, but so far I just used a mask recycled from a hologram shader.
Can somebody suggest me a good tutorial/guide to achieve it?

#

nvm just found Cyan's amazing shader

#

Thanks man πŸ™

toxic peak
#

is it possible to make a tree sway in the wind with shader graph? I know how to do that for the leaves with vertex manipulations, but how about the tree trunk? I assume swaying trees arent made through skeletons or rigging, cause that would be insane, but what about shaders?

I know Unity used to utilize SpeedTrees, especially when used with Unity's terrain and windzones, but as I understand SpeedTrees are now deprecated? or outdated? or whatnot?

strange saddle
#

Why does Rider not recognize that my Shader Graph shader is a valid shader when finding it via Shader.Find I've added it to the project to the always loaded shaders already.

#

It's a problem because then I can't set properties.

regal stag
strange saddle
#

Ah I see, thanks!

regal stag
strange saddle
amber saffron
toxic peak
hot mica
#

it it true that every shadow rendered using indirect instacning is drawn in all 4 (assuming thats the setting I have) cascades, no matter how far it is located from a player?

modern rapids
#

Also for future reference the ShaderGraph package has new examples including custom lighting

waxen merlin
#

Hi, I have a lot of skinned characters (150-300), and I'd like to fade in a damage/blood texture on them as they get hurt. Not decals, just an overall texture that covers them. I'm on 2022.3 URP, what is the best way of passing in a single value for each entity to describe the amount to blend in this texture? Are there ways of doing it without breaking batching? I heard that MaterialPropertyBlocks breaks batching in URP, correct? Thanks!

grizzled bolt
cosmic prairie
#

It would be pretty silly tho if that was the case

#

I'd imagine the renderers are culled per cascade

#

are you using "Graphics.DrawMeshInstancedIndirect"?

#

In there you need to add a "Bounds" property

#

that bounding box will most likely control which cascades your objects are drawn into

#

So if you go around making an infinitely big box they will probably indeed be drawn into all cascades

ebon moss
#

anyone know how to define a cubemap property?

regal stag
ebon moss
ebon moss
#

sorry do u know if I can fix this?

#

I'm trying to render a camera pointing at the sky into a skybox cubemap texture

#

ah nvm im just going to use a static image for now

reef jackal
#

Hello hello! Coming here from a halftone shader tutorial :)
I'd managed to get the shader graph set up with no real fuss,
but when it came time to apply it to the scene, no lights seem to affect it just like any standard unlit shader graph
Currently working on trying to figure out how to integrate the additional lights (not very well versed in shaders in general) to see if that will help, but if anyone has any advice that would be helpful :)

Currently using Unity 6 for the project if that's helpful at all
Will be sending images of the shadergraph and subgraph shortly

#

Halftone is a technique used for printing where tiny dots of different colors and sizes are layered to look like a full-colour image. In this video, I use Shader Graph to implement a similar technique, where the shaded regions of the image are converted into differently-sized darkened dots.

πŸ‘‡ Download the project on GitHub: https://...

β–Ά Play video
#

The shader graphs (The smoothstep connects to the final value of the Lerp node like in the video)

#

test cubes :)
No shadows being cast on the unlit normals

grand jolt
#

if unity's shader was built in shadergraph, can i somehow add billboard feature to it? or modify how billboards look? or is it not done in shadergraph but somewhere else
my shaders are not compatible with unity's bilboarding. so i assume i either need to modify the tree's shader (shadergraph) or how billboards work. idk which

mental bone
#

@regal stag Doing some research for my own shield shader I came across your post and tried to adapt your ripple code into my own. It works but I can't for the life of me figure out how to change the speed of the ripple. This is the custom func I currentyl have ``` float t = 1 - _hitsBuffer[i].w;

float dist = distance(Coords, _hitsBuffer[i].xyz) ;

float3 sphereMask = 1 - saturate((dist - Radius) / (1 - Hardness));

float rippleSize = 0.07;
float gradient = smoothstep( 0, t, dist / rippleSize);
// float ripple = saturate(sin(10 * gradient));
float ripple = frac(gradient*3);

float3 rippleDir = normalize(Coords - _hitsBuffer[i].xyz);

float rippleStr = _hitsBuffer[i].w * ripple;

dir += rippleDir * rippleStr * 2.2;

// dir = floor(dir * 32) / 32;

str += rippleStr;

OUT += sphereMask * _hitsBuffer[i].w;
life = t;

regal stag
mental bone
#

ohh my w of hits buffer is the lifetime of the hit

regal stag
#

Oh maybe I changed it so radius is fixed and w is lifetime, either way that's still what controls the speed

mental bone
#

right I need to redo the ripple then I think

gloomy tendon
#

anyone used the new canvas shader graphs?

amber saffron
slender ore
#

I am trying to make a typical stylzied water shader for low poly game. Problem is that this game is gonna use orthographic camera which will not render properly foam and depth which uses screen position and scene depth. I thought it may be possible to have 2 cameras, one orthographic to render whole game and one perspective to render only water, but I am not sure how can I combine those 2 cameras to make them both render things at the same time. Or perhaps there is a simpler solution that someone might have?

regal stag
#

And Scene Depth should work fine in orthographic. Unless you're on versions older than 2022.2 - then you'd need to use raw mode and convert to eye units, I have an example in a foldout in this post

rotund thunder
#

Can someone help me? I created this simple Shader Graph in HDRP to generate an outline. The outline appears in the editor, but in-game the camera doesn’t recognize it.

amber saffron
#

(also, this shader works for simple shapes like the sphere, but for more complex shapes you probably want to use a normal "push" deformation)

rotund thunder
#

I was just testing combinations with some of my other shaders, and this one ended up working (at least partially). I'm really not very good with shaders.

amber saffron
rotund thunder
#

Something like this?

#

Sorry, I really don't understand much about this.

amber saffron
#

pay attention to math operations priority

#

out = pos + ( normal * scale )

rotund thunder
#

When you say (normal * scale), do you mean the normal vector and the float scale, multiplied and then multiplied with the position to get the output?

#

like this

#

I got it!
Thanks @amber saffron

karmic roost
#

hey im trying to add simple triplanar projection for my cave game but i keep getting this pink texture, its the first time i use shadergraphs i got URP installed but still no solution

misty osprey
#

does anyone know why every so often (like every 4-5 domain reloads) a shader I use for a decal (it was the default package one before with the same error) happens to hang unity having me to force close it?

#

regenerating library cache didn't do anything

kind juniper
misty osprey
#

yeah it comes uninvited

kind juniper
#

I'd have a look at the editor logs and make sure that the project is not in some place that might cause read/write issues to unity.

fringe karma
#

alright so I have an outline shader that uses a roberts cross to get the difference between the depths/normals surrounding a pixel. But that equation always returns positive values, so it can't tell if the difference is greater or less than the sampled pixel. This means that the outlines double up when inside the object or if multiple objects are layered over each other, which looks inconsistent and janky.
What equivalent can I use that lets me tell in what direction the difference lies?

#

I want to ensure it only draws the outlines for a pixel if the surrounding depth is deeper, or the normal is angled more away from the camera, instead of pixels on both sides of a change trying to draw the normal themselves

fringe karma
#

Also, in Shader Graph is there a simple function to convert a 0 - 1 range to a -1 - 1 range, or shall I make a subgraph for it?

#

And what happens if you try to lerp between two Vector3s, using a third Vector3 as the parameter?

kind juniper
fringe karma
#

although I don't know if that's more or less performant

#

maybe it doesn't matter, but I'm also trying to learn here

kind juniper
chilly robin
#

I'm working on a circle wipe fullscreen shader, but having some trouble with positioning. I'd like the circle to be perfectly round in all resolution and aspect ratios, and also be perfectly centered. Here's what I have so far:

#

I can offset the center point using the Distance node, but I'm not sure how I'd go about getting it centered for all aspect ratios

wet sigil
#

I just made a new project and imported some assets, the project is urp and the asssets sa they support urp yet are all pink?

kind juniper
wet sigil
kind juniper
wet sigil
#

Got it in a humble bundle

#

it does contain shader files

#

and its weird some of the assets work

#

but then all of the modular ones dont

#

ah manually setting the asset to that shader works

#

and then finding their material

#

gonna take a little bit for 500 assets lol

kind juniper
#

Possibly they made a mistake when setting up or uploading the package.

fringe karma
#

also thanks @kind juniper for the info

ebon moss
#

anyone know if u can use RWTexture2D in hlsl URP shaders cause I cant geet it to work

dusky arrow
#

Im seeing conflicting information online about the range of NDC position values. Is it from -1 to 1 or from 0 to 1?

fringe karma
#

I don't actually know either, but that's how I'd try finding it out

gloomy tendon
#

I was looking at the new shader graph canvas with procedural shapes now possible, but I don't know how to use corner radius of a fixed size (not proportional). Seems you would need to add a component to pass size info from a RectTransform on an Image to the Material shader

#

But even then if it does nto nine slice it won't even work!

kind juniper
warm moss
gloomy gust
#

Can you make an array of colors as a parameter in a shadergraph?

fringe karma
#

My outline shader is turning out pretty well, except that the outlines become thinner and disappear the closer the camera gets to the model. The code in question compares the dot products of the normals relative to the view direction, and draws an outline if the difference is above a certain threshold.

I tried multiplying the threshold based on the camera distance (so the closer the camera, the lower the threshold to decide to draw the outline), which is better, but some of the outlines still disappear when I zoom in. Is the scene depth not calculated linearly or something, e.g. due to the camera perspective?

Here are the 3 methods I tried for getting the camera distance, in case there's some difference I didn't notice:

  • Getting the scene depth with 'eye' sampling (raw produces even more artifacts)
  • Getting the scene depth as a 0-1 value and multiplying by the camera's far clip plane
  • Getting the view direction in view space and isolating the Z value
  • Calculating the world space distance between the sampled position and camera position

I also tried lowering the threshold globally, but that creates fuzzy artifacts all over the model, so I need to be smarter about it.

#

alright it might be partially based on perspective. I tried setting the scene camera to orthographic and the effect was lessened. With both the orthographic camera and the distance modifier, the outlines barely changed with the camera distance

indigo ginkgo
#

do custom render textures and custom render texture shaders work?

#

Just as a simple test I'm making a shader graph custom render texture shader/material ouputting a colour and then assigning that in the inspector, but nothing changes in the render texture preview window

#

the material updates in the preview window

warm moss
fringe karma
warm moss
#

OpenGL has the best resources for theory, Directx only has like the rastertek tutorial series and that's about it.

fringe karma
#

@warm moss cheers thanks, I'll probably look at it tomorrow once I'm better rested

#

actually one more thing to ask before I go to bed, is there any disadvantage to changing a material's input values many times per frame? I've been brainstorming how to pass script data into a custom buffer, and I realised I could use a global material, then iterate through a for loop for each renderer, and before rendering change its values based on whatever data I want to glean from the current renderer in the loop.

#

I'm setting up a ScriptableRenderPass in URP

#

this is for a separate shader to the outline one I was talking about earlier

amber saffron
fringe karma
#

I do also have a hull based outline (for a different purpose) and that's turned out pretty well, except for finding a balance of depth threshold that ensures no part of the rear pokes through to the front, but none of the outline is cut off because there's an object too close behind it

warm moss
fringe karma
#

I know there's a separate function for drawing all the renderers at once under certain culling/drawing criteria, which obviously doesn't allow for adjustments based on specific objects

warm moss
#

I have a custom screen space outline that does outlines based on object id and I use material property blocks to make objects draw their id to the id buffer.

fringe karma
warm moss
#

No. All the renderers draw their ids to the id buffer. That gives me a guarantee that there will be an outline around each object 100% when I do a sobel filter on the id buffer.

#

But I was just giving an example that this works.

mental bone
#

I'm trying to use refraction on a transperant shader but with 0 alpha it looks like this. What gives ? why is the refraction not respecting the alpha.

gloomy tendon
swift loom
#

Just had a bug with a compute shader where I was setting tileSize externally, and it caused the values to glitch out. Any clue what might cause that?
I just set it using SetVector and then when I divide with it, it uses a similar value but glitches out in random ways depending on the value I set.

#

worldPos is just a value representing the pixel in world space, and worldPosOffset is the pixel within the tile

#

But when I set tileSize to (24, 18) the Y axis worked perfectly, yet the X axis showed 0-24 on the first tile, then 1-23 on the rest. Changed it to 23 in X and now it starts at 0-22 (which is correct), then goes to 1-21, 2-20, etc and all kinds of odd behavior. Some tiles even started at 6, then showed 0 for several pixels, and then counted up to like 16.

#

I have fixed it by setting the value in the shader itself but I find this quite worrying

rotund thunder
#

Does anyone know what causes my shader to fail to compute objects like this? It only creates faces that separate from the square, while with circles, the outline works fine

amber saffron
rotund thunder
amber saffron
# swift loom

You are already dooing a floor operation at the worldPosOffset line, I would avoid to also do it at the worldPos one, to avoid loss of data.

amber saffron
gloomy tendon
#

(I need to detect object edges even when no/tiny depth or normal difference between adjacent or overlapping objects)

mental bone
amber saffron
mental bone
#

The question is why am I seeing anything with 0 alpha

gloomy tendon
#

you need to use BlendMode.Fade not transparent

#

if you are not

amber saffron
gloomy tendon
#

because transparent adds reflectivity & specular and becomes non transparent even with alpha 0

mental bone
#

right.... but I want to add a disolve to this so how would you suggest I do this ?

amber saffron
gloomy tendon
#

you can fade by reducing any specular refraction etc over time no? It is a problem with this kind of transparency if you actually wanted to fade out!!

mental bone
#

Previously when I tried alpha clip it also did not work....turns out it was disabled in the material for some reason.

gloomy tendon
#

I fell like it needs an alpha and a fade value - which one could do with shader graph but bit of work...

mental bone
#

It works now

#

Stupid material remembering stupid different settings heh

warm moss
rotund thunder
#

How could I create a glitch effect similar to Pibby's Apocalypse from Friday Night Funkin'? I'd like to create something like this, where, on top of the main material, glitch effects with small pixels would continuously be generated and destroyed at intervals I define.

toxic peak
#

How does one... load that one vertex paint layer in Unity?

#

I can create several in Blender via Color Attributes, but...
A) I am certain only one is visible by default, but I THINK that all of them are packed into FBX
B) I don't see a way to get any Vertex Color layer besides the first one in Shader Graph
C) I have a suspicion that you can do this in Shader Scripting

Can anyone confirm/deny any of this?

grizzled bolt
toxic peak
#

ah, so its not like they are imported but hidden, its that they aren't imported at all

warm pulsar
#

oh hey, this is the problem I had

#

I don't know a lot about Unity's mesh system, so I don't know if there's a smarter way to do this

#

I wound up packing extra vertex data into UV1/2/3

#

Unity supports up to eight UV maps, but the Shader Graph only lets you access the first four

toxic peak
#

oooh, okay, how does that work? Like... you, uuuuh, so if you save it as a UV it acts pretty much like a texture, right? not a set of vertex colors?

warm pulsar
#

Each UV map is just an extra stream of vertex data

#

You normally only use UV0 -- and only the X and Y channels

#

But each UV map can hold up to four floats per vertex

#

and you don't have to use UV maps to sample textures!

grizzled bolt
warm pulsar
#

So the quick-and-dirty fix is to write a Blender script that writes the data you need into the UV maps

toxic peak
#

okay... okay! Im not much into Blender scripting but I think I have an idea where to find how to do that

warm pulsar
#

I'm working on a Blender add-on that exports all of the vertex data into a big blob and a Unity package that stores that data into the UV maps during import

#

I use it for a game and my VRChat avatars, but it still has a lot of rough edges :p

toxic peak
#

oh god, I think I've seen a way to save vertex colors in a UV using Color Attributes? Or am I confusing stuff?

warm pulsar
#

e.g., I have a mesh that contains many pieces of debris that I'm rendering on the water's surface

For each vertex, I record the center of the object it's a part of (to sample wave height with) and an object index (for use as a random seed)

warm pulsar
#

Oh yeah -- one issue with the simple method is that either Blender won't export 4-component UV maps or Unity won't import them. I forget which it was

#

So I was limited to UV1.xy, UV2.xy, and UV3.xy

toxic peak
#

so wait, when you paint vertex colors over an object
and then bake them into a UV map
you don't need to do any UV unwrapping? It just correctly translates stuff from a UV back into Vertex Colors?

Or, if as you say, UV maps are all values stored per vertex, then... uuuuh

warm pulsar
#

A UV map just tells you where on the texture the vertex should look

#

"UV unwrapping" is done so that two vertices near each on the model wind up near each other on the texture

#

(except at seams, of course!)

toxic peak
warm pulsar
#

But that's not what we're doing at all here. We're just putting arbitrary data into the UV map.

warm pulsar
toxic peak
#

Right, lightmapping. yeah. That's the thing I was thinking about, gimme a sec

warm pulsar
#

UV0 is being used for the usual purpose -- sampling textures. But UV1 is full of arbitrary data

toxic peak
#

so Im going for a retro look and I want to use hand-pained vertex coloring/lighting for that retro look.

As I was twiddling with it - I kinda like the idea to use both color variation and lighting variation with vertex painting

#

so I'd need 2 vertex color layers, if I go this route

#

then again, can't I just use several texture layers, several UVs, and use some more UVs for alpha masking those layers?

warm pulsar
#

How much extra data do you need per-vertex?

#

3 floats?

toxic peak
#

I think so, yeah? I can do with RGB without the A, if thats what you're asking

warm pulsar
#

In that case, you could store R and G into UV1

#

then put B into UV2

#

(since Blender will only export X and Y for UV maps, as far as I know)

toxic peak
#

would you say that's more or less convoluted than having several texture layers?

#

I guess that depends on the requirements, huh

warm pulsar
#

The problem with using textures is that they won't line up nicely with your vertex colors

#

I mean...I guess you could make a UV map that puts each vertex onto its own pixel

toxic peak
#

mmm, riiight, right

warm pulsar
#

so that each vertex could have its own color

toxic peak
warm pulsar
#

it'd be another funny Blender script :p

warm pulsar
#

It looks like I deleted the script that does this; lemme go fish it out of Git

toxic peak
#

oh dang, yeah that'd be very helpful!

warm pulsar
#

ah, there it is

#

so this is just copying the original vertex position into UV1.xy and UV2.x

#
import bpy
from mathutils import Vector

for o in bpy.context.selected_objects:
    if len(o.data.uv_layers) == 1:
        o.data.uv_layers.new(name="XZ Position")
        o.data.uv_layers.new(name="Y Position")
    for face in o.data.polygons:
        for vert_idx, loop_idx in zip(face.vertices, face.loop_indices):
            pos = o.data.vertices[vert_idx].co
            pos = o.matrix_world @ pos
            o.data.uv_layers[1].data[loop_idx].uv = Vector((pos.x, pos.z))
            o.data.uv_layers[2].data[loop_idx].uv = Vector((pos.y, 0))
#

I should have code that roughly does this, but with attributes..

#

This code doesn't use bmesh, whilst my exporter does, so they look completely different

#

You can access attribute data with o.data.attributes["NameHere"].data[0] -- that'd be the value of an attribute called "NameHere" for vertex 0

toxic peak
#

oookay, thank you! This is real helpful

#

then, in Unity I'll need to take that data out of UV1 and UV2 and push it through the vertices

warm pulsar
#
import bpy
from mathutils import Vector

for o in bpy.context.selected_objects:
    if len(o.data.uv_layers) == 1:
        o.data.uv_layers.new(name="RG Color")
        o.data.uv_layers.new(name="B Color")

    for face in o.data.polygons:
        for vert_idx, loop_idx in zip(face.vertices, face.loop_indices):
            value = o.data.attributes["Color"].data[vert_idx].color
    
            o.data.uv_layers[1].data[loop_idx].uv = Vector((value[0], value[1]))
            o.data.uv_layers[2].data[loop_idx].uv = Vector((value[2], 0))

This copies the colors out of an attribute named "Color" and stores them into UV1 and UV2

#

You can sneak in two RGB colors if you use UV1-3

#

I wound up writing my whole export-import system because I ran out of space :p

#

I'll have to work on that some more. I still have Unity import problems to work out

toxic peak
#

right, 3 channels, twice, 3 UVs

#

I wonder why does shader graph use only 4 UVs, but I guess that can be worked around with custom functions too

warm pulsar
#

I think Surface Shaders also only support up to four texture coordinate streams

#

maybe

toxic peak
#

do you use 'data attribute' or 'color attribute'?

#

I guess Color Attributes are listed in the general list of attributes as well

warm pulsar
#

I believe "Color Attributes" just shows you attributes that are per-vertex and that are colors

#

yeah

#

Those are the kinds that you can paint in Vertex Paint mode

toxic peak
#

yup yup

warm pulsar
#

I'd like if you could paint floats and vectors too..

#

I wind up painting color attributes, then throwing out G and B

toxic peak
#

I have found this video on youtube where the guy is using a 'Face Corner - Byte Color' attribute, but then he claims it is baked to Vertex Colors?

warm pulsar
#

Face Corner is storing more data than Vertex

toxic peak
#

I don't get what he means, really

warm pulsar
#

Each "side" of a vertex can store its own value

toxic peak
warm pulsar
#

That's how Blender stores UV maps internally, since a vertex might wind up being in two different places on the UV map

toxic peak
#

riiiiight

warm pulsar
#

That's one area I'm a little fuzzy on -- how a vertex "splits"

toxic peak
#

okay that sounds like an overkill. And those attributes would still follow the same rules, only 1 shall be imported in Unity?

warm pulsar
#

It doesn't really matter what your attributes are in Blender

#

you're just smuggling an extra couple of floats into Unity

warm pulsar
toxic peak
#

right, but it imports vertex colors as well

warm pulsar
#

Yeah, you get that too

toxic peak
#

but only one attribute

#

e.g. one vertex color layer

warm pulsar
#

I think blender exports the attribute that's active for painting?

#

You can get a bit of extra data out that way

#

3 floats (or are vertex colors just bytes?) in vertex colors, and then UV1/2/3

toxic peak
#

maybe this is what controls it then?

warm pulsar
#

Yeah, that's what I'm thinking

toxic peak
#

I mean look, it gets out full RGBA set

#

well not the A, I think, unless I misunderstood something

#

so you get only 1 RGB set of vertex paints from Blender
and then... you have to 'smuggle' more by some shenanigans like the UV juggling method you've done

toxic peak
#

that's it. It doesnt show anything but its there

#

I wonder why isnt there just... capacity for more Vertex Color layers? I guess it must not be used that often, or maybe there's some kind of, uuuh... standard

#

wlp thank you for everything!

#

wait

#

can you pack B/W colors into one channel?

#

like into, uuuuh, into A?

#

I guess you could call it just brightness, then.

warm pulsar
warm pulsar
#

I don't think you can do that?

#

because that is pretty fundamental to how the rendering system works

toxic peak
#

I tell you one thing - Ive bugged chatgpt about it, and it said... that it can be accessed, but not through the shader graph, only with shader code

#

he might be full of crap though

#

like, the question here is whether those additional color attributes are carried in the fbx. You say they aren't, right? Only one, unless you stuff that info across several UVs

warm pulsar
#

I believe the extra attributes do wind up in the FBX?

#

Been a hot minute

#

My first idea was to write some kind of custom FBX importer for Unity, or to at least read the extra data from the original FBX

toxic peak
#

I guess that's what I'm gonna try to figure out tomorrow

warm pulsar
#

unfortunately, the FBX format makes you want to explode

#

so I decided to not deal with it

toxic peak
toxic peak
warm pulsar
#

The question is whether you can just make up completely new kinds of vertex data in Unity. I don't believe you can

grizzled bolt
#

Per face vertex colors would've been nice to have earlier

warm pulsar
warm pulsar
#

since you have many values per vertex now

#

You could split all edges so that every face corner corresponds to a vertex, but then you'd lose smooth shading

toxic peak
#

Ha! It says GLTF format can support more stuff

warm pulsar
#

(I had to figure out how to tell my importer which original vertex each actual vertex in the model comes from after splitting)

#

I wound up writing the vertex index into UV1.x

toxic peak
#

I know Godot uses GLTF instead of FBX as a default format

#

but FBX is the industry standard

grizzled bolt
warm pulsar
#

it's only a problem because the resulting vertices wind up with different normals

#

I should have a look at glTFast

toxic peak
#

huh, so Unity doesnt have that by default for GLTF then?

warm pulsar
#

I think it cuts along UV seams

#

(which makes sense -- you're figuring out the tangents FROM the UV map, aren't you?)

toxic peak
#

gods

#

I just want to make videogames, not a computer science degree, amirite

warm pulsar
#

surprise!!!

#

i terrify my friends in VRChat with the weird nonsense i can cook up

toxic peak
#

nonsense like what πŸ‘€

warm pulsar
#

very elaborate shaders, mostly

#

i've started learning how to write editor scripts to generate animator layers

#

so i can automate more stuff

toxic peak
#

wait, are you talking about VRChat or Unity?

#

or is VRChat made on Unity

warm pulsar
#

VRChat is a Unity game, yeah

#

Understanding Unity makes it a lot easier to work on avatars -- but it's very divorced from normal game development

#

You do almost everything in the Animator

#

You can't write any custom code, and you have very limited control outside of animations

#

you do get to write whatever shaders you want, though

#

but it's sometimes hard to get the data you need into those shaders

#

hence really wild hacks like using point lights to figure out where objects are (you can access that in a shader!)

toxic peak
#

you can access point lights in a shader?? not just main the main light?

#

I guess it makes sense, shaders need to keep track of point lights anyway

#

yeah, dumb question

warm pulsar
#

Yeah -- ultimately, the shader has to figure out how to light itself

#

I've been slowly learning about all of this stuff

#

praise bgolus

warm pulsar
#

(in the built in RP)

#

you don't really write HDRP shaders by hand (as far as I know), so god knows what's going on in there

toxic peak
warm pulsar
#

I know that it gives you eight lights in a vertex-lit shader

toxic peak
#

then that's it

#

does seem like much tho

warm pulsar
#

that is per-renderer, so you can have lots of realtime lights as long as they aren't all hitting the same object

toxic peak
#

oh right

#

because why would you need that anyway

#

and the renderer decides which 8 to receive data from

#

it makes sense with small, dynamic objects

#

but lets say you have a road with streetlights. Unless you cut the terrain into pieces - you can have only 8 4 of those active at the same time, only 4 lights on the road

#

so then is cutting the terrain the solution?

grizzled bolt
toxic peak
#

the only thing about forward, forward+ and deferred rendering that I know is that they exist

#

can you swap between those in Unity?

warm pulsar
#

yeah, you can configure it

#

also, this is very silly

#

It's a link to

toxic peak
#

whoops!

ashen linden
#

okay, when I'm making a build on my game, everything besides the UI becomes black and this appear on the development build debug
WindowsPlayer "DESKTOP-KRNCDQ1" ArgumentNullException: Value cannot be null.
Parameter name: shader

#

it works normal on the editor

main totem
#

Not sure if this is the place to put this but every time I try to convert blocks to a subgraph in shadergraph I get an error and the subgraph isn't created. The error is ```NullReferenceException: Object reference not set to an instance of an object
UnityEditor.ShaderGraph.Drawing.MaterialGraphEditWindow.ToSubGraph () (at ./Library/PackageCache/com.unity.shadergraph@14.0.10/Editor/Drawing/MaterialGraphEditWindow.cs:991)
UnityEditor.ShaderGraph.Drawing.MaterialGraphView.ConvertToSubgraph (UnityEngine.UIElements.DropdownMenuAction action) (at ./Library/PackageCache/com.unity.shadergraph@14.0.10/Editor/Drawing/Views/MaterialGraphView.cs:918)
UnityEngine.UIElements.DropdownMenuAction.Execute () (at <332857d8803a4878904bcf8f9581ec33>:0)
UnityEditor.UIElements.EditorMenuExtensions+<>c__DisplayClass0_0.<PrepareMenu>b__0 () (at <80a8ce1980c648dca8e68f0d8aa3b930>:0)
UnityEditor.GenericMenu.CatchMenu (System.Object userData, System.String[] options, System.Int32 selected) (at <80a8ce1980c648dca8e68f0d8aa3b930>:0)

kind juniper
gloomy tendon
ashen linden
warm moss
gloomy tendon
warm moss
#

Fragment shaders can write to more than 1 render target at once.

gloomy tendon
#

ok ok I was wondering that. So can you allocate a buffer and write to screen and to that buffer in a shadergraph?

warm moss
#

Haha no. HLSL shaders only.

gloomy tendon
#

oh, well non shader graph is almost a no no in URP these days so that means rendering everything normal way and then rendering to another buffer with a custom shader

warm moss
#

Not really, just never upgrade your package.

#

I hate the render graph system and it's completely unnecessary for what I do so I'm never upgrading my packages(on my personal projects where I get a choice)

#

Besides, I regularly have to rewrite custom shaders from one pipeline to another and to upgrade them a little bit between package versions to support new pipeline features and I don't see what the big deal is.

ashen linden
#

!code

echo moatBOT
ashen linden
#

Assertion failed
UnityEngine.Rendering.Universal.ScriptableRenderPass:Blit (UnityEngine.Rendering.CommandBuffer,UnityEngine.Rendering.RTHandle,UnityEngine.Rendering.RTHandle,UnityEngine.Material,int)
ScreenSpaceOutlines/ScreenSpaceOutlinePass:Execute (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Rendering.Universal.RenderingData&) (at Assets/Visual/Render/OutlineScripts/RendererFeatures/ScreenSpaceOutlines.cs:171)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

this erro is appearing after I tried to Upgrade the Rendering system, the area responsible for this error is this one

 public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) {
            if (!screenSpaceOutlineMaterial)
                return;

            Debug.Log("RendererRodou1");
            CommandBuffer cmd = CommandBufferPool.Get();
            Debug.Log("RendererRodou2");
            using (new ProfilingScope(cmd, new ProfilingSampler("ScreenSpaceOutlines"))) {

                Blit(cmd, cameraColorTarget, temporaryBuffer);
                Blit(cmd, temporaryBuffer, cameraColorTarget, screenSpaceOutlineMaterial);
            }
            Debug.Log("RendererRodou3");

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
#

it's after
Debug.Log("RendererRodou2");

winged spoke
#

Hi, I tried to set a material on a UI panel, and is it just not possible to edit it's properties outside of scripting? Not that I mind, just having access to the material properties in the inspector directly would make it a lot easier to debug

grand jolt
#

how can i optimize a shader? its made in shadergraph

#

i do not know which of those nodes are expensive and which are not

grizzled bolt
toxic peak
#

A quick question, fellas.

Im rather vexed about how my texture inputs are shown in my custom shader graphs. Is there some neat way to have the same thingy with base_map and a color picker that standard Unity materials have, but to have it appear that way in shader graph?

Its a more of an organizational thing. Not a big deal, but I do be wondering

grave vortex
toxic peak
#

bummer, oh well. thank you!

grizzled bolt
#

@toxic peak @grave vortex Don't know how "neat" the way is but the Lit shader custom GUI is accessible at
Packages\Universal RP\Editor\ShaderGUI\Shaders\LitShader.cs
The graph inspector has a field for Custom Editor GUI and the Lit GUI can be used with the name UnityEditor.Rendering.Universal.ShaderGUI.LitShader
Shader graph's Production Ready Shaders includes the Lit shader made of nodes if you need an example of the GUI in use

#

Meaning you can't use it with custom shaders without modifying the script, but it's there

toxic peak
#

Thank you!

twilit elbow
#

Does anyone know why rotating a URP-Decal in Z Axis changes its color? I am confused

Currently using Unity 2021.3.21f1

#

Not being able to rotate them means I have to make 2-4times the amount of decals :/

#

Am I doing something wrong or am I not understanding how they work?

main totem
#

Is Shadergraph just broken in 2022.3.22f1 Unity? It won't let me make subgraphs, just gives an error

main totem
#

Do shadergraph shaders have GPU Instancing by default? My shader inspector doesn't have a checkbox like I see when I searched it up

pearl frigate
#

Made this very basic custom blur shader to just do some gaussian blur. Some screens are having the screen completely mess up and artifact weirdly. Works fine in editor, even on mac in WebGL. But some PC's can't handle it, and I have no clue why. I think I've safeguarded it well, but I guess not.

Any ideas?

crisp vale
#

hello! working with a vertex displacement shader and I noticed that when added to my meshes, it looks fine in Scene view. But when I hit play, the meshes sway all over the place. The only thing that fixes this is turning off Static for all of the meshes. Does baked lighting not work on meshes that have vertex displacement?

grizzled bolt
crisp vale
grizzled bolt
#

Contribute GI is for baked lighting

crisp vale
crisp vale
#

@grizzled bolt one last thing, Im trying to get some randomized swaying in here, rather than everything swaying at the same time. Here's where Im at, not sure where to go from here. Any ideas?

grizzled bolt
crisp vale
grizzled bolt
crisp vale
#

oh I know, its this one

#

Im just not sure where to plug that new node in. If I plug it in place of the position:object node, it doesnt seem to work

crisp vale
grizzled bolt
#

That would use only the X position as the "seed" so if your objects have identical X positions, you'd need to add or multiply the vector axes together first

crisp vale
grizzled bolt
crisp vale
#

hey that worked!

#

awesome, thanks a ton!

errant forge
#

Which coordinate represents the depth of the pixel on the screen position node?

#

Got it. The alpha.

dusky arrow
#

is it normal to be getting a near clip value of 3 in NDC coordinates?

#

getting these numbers from this function

main totem
#

My shader graph shader is not rendering correctly in VR. It seems to not be doing the pass in stereo. Does anyone know how to fix this?

#

I used the built-in lit shadergraph base

main totem
#

It doesn't show at all on quest and appears to only render one eye on PCVR

winged spoke
low lichen
toxic flower
#

question guys

#

is there any blur shader solution for URP that like

#

supports stacked UI blurring?

brave blaze
#

does anyone have some good resources that explain how exactly different shaders work? we touched on it briefly at uni but I don't really get it yet and I'm finding it hard to wrap my head around how they even could work

#

it looks like magic to me currently

winged spoke
brave blaze
#

I saw that shaders can also be used for stuff like trails in snow when an object moves through it and that confused me

brave blaze
# winged spoke Can you elaborate on that?

I guess what I'm asking is if anyone knows videos explaining how that actually works rather than tutorials on how to achieve the effect - doesn't have to cover every usecase but I'd like to at least understand shaders fundamentally to an extent. Idk if that makes sense

#

Before properly delving into how to make shaders, I want to know what they are and how they work

winged spoke
rich ledge
#

Hi so I followed a tutorial for making outline shaders, and after I’m done it just looks super janky and I'm not sure why because the preview is like mildly okay, does anyone happen to have experience with sprite outline shaders that I can maybe look at? I imagine it’s pretty simple lol

rich ledge
# dim yoke Which tutorial did you follow?

Here’s a couple I followed, but they’re essentially the exact same lol

https://youtu.be/FvQFhkS90nI?si=wkqmN53g_wAtVYGS

https://youtu.be/MqpyXhBIRSw?si=slFECt9e_4yBzgfv

βœ… Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=FvQFhkS90nI
Let's make a Outline Effect Shader to apply to our Sprites in Shader Graph!

Check out the entire Shader Graph Tutorials Playlist
https://www.youtube.com/playlist?list=PLzDRvYVwl53tpvp6CP6e-Mrl6dmxs9uhx

If you have any questions post them in the comment...

β–Ά Play video

Thanks to NVIDIA for sponsoring!
Learn more about NVIDIA Studioβ–Ί https://nvda.ws/38AaA8K
Razer Blade Studio laptopsβ–Ί https://www.razer.com/studio

In this video we create outline effect using 2D Shader Graph!

● Learn more about 2D Shader Graph: https://youtu.be/5dzGj9k8Qy8
● 2D Glow Tutorial: https://youtu.be/WiDVoj5VQ4c

● Get Gothicvania Ch...

β–Ά Play video
dim yoke
rich ledge
#

And then my shader graph looks the same as those tutorials do but i can send it if needed

dim yoke
rich ledge
dim yoke
dim yoke
# rich ledge for sure, is this good?

At least you need to plug the alpha of the last node into the alpha block (use the Split (edited, sorry for the blender node name) node to get it). Both of the tutorials use old enough unity version that the alpha was packed onto the Color(4) block back then (hence the 4). Now you need Base Color(3) and Alpha(1)

#

The black spots might happen due to too large outline thickness (would appear transparent if the transparency was plugged correctly). Your outline was likely not bounded by the outline thickness value but rather the physical outline of mesh

#

The method used isn't perfect though and might cause some other issues that are mentioned in the videos but at least it should look better than it does now after that

deft remnant
#

Time -> floor ignores a few numbers like 14, 23, 28, 41,43, 51, 56 and many more, no idea why, any suggestions?

deft remnant
#

same with 1397 and 1402

karmic hatch
#

I think it must be something to do with the visualiser; even the float(time) one skips from .5 to .7 - something with its rounding?
(Also skips from .0 to .2)

dim yoke
#

That was my first thought too

deft remnant
#

That's interesting, I'll check it using sprites again

#

Yeah it looks like there was a different issue, which I tried to debug with the visualizer, while doing that I fixed it and then found the issue with visualizer and didn't notice it

#

That's disappointing

dim yoke
#

@deft remnant Might just be a floating point value precision issue and not necessarily the visualizer being wrong. The shader graph only operates on floating point data and so does shading languages in general

gritty spire
#

Hi
I try to create a simple sobel effect to have some outlines around shapes in my game.
I follows this tutorial
https://www.vertexfragment.com/ramblings/unity-postprocessing-sobel-outline/
It works well with objects with a default material, but not with my custom made material.
Here the shader code, it allows me to create some "fog of war" effect with a texture that darken non explored area (unlit yes, the game don't need lights).
https://pastebin.com/s8dyJJLb
I already added a fallback to the Standard shader, to allows to theses objects to be shown on the _CameraDepthTexture.
But they are still missing on the _CameraGBufferTexture2
How i can do (i think on this shader) to add theses objects on the last buffer ?

modern rapids
#

Newbie question: does URP support multi pass shaders? I'm trying to inject an outline pass into a generated shader graph shader but it doesn't render at all..

#

Render object renderer feature works fine but I need the outline pass to use some properties from the main pass

#

*correction: it does render but it's either the main pass or the outline pass, not both

regal stag
# modern rapids Newbie question: does URP support multi pass shaders? I'm trying to inject an ou...

You can technically use passes with UniversalForward & no lightmode (or SRPDefaultUnlit) and both will render - but it breaks SRP Batching so may affect performance.
You can also use a custom lightmode tag, and write a custom renderer feature or use RenderObjects (i think it has a shader tags/names list iirc?) to render it. This should keep SRP batching too.
Or split it into separate shader & materials and manually set the needed properties to the same values. That may be easier when dealing with graphs as you don't need to edit generated code.

nimble kiln
#

Not sure if I've done something wrong but I've been creating a fire effect and I can't get the shape right. I've been following this tutorial: https://www.youtube.com/watch?v=XyOAk4rlIUY&t=396s

For some reason my fire is a square. I've gone through all of my settings and followed the tutorial perfectly but I can't work this out. Can anyone help?

Show your Support & Get Exclusive Benefits on Patreon (Including Access to this project's Source Files + Code) - https://www.patreon.com/sasquatchbgames
Join our Discord Community! - https://discord.com/invite/aHjTSBz3jH

In this 2D Unity tutorial, we'll make a REALLY nice stylized fire effect using shadergraph and the visual effect graph.
This...

β–Ά Play video
kind juniper
mystic fern
#

Hi, I need some help with pixelating shaders that use polar coordinates. I tried the multiply-floor-divide method, but it results in jagged circles as the polar coordinates expect continuous values. Is there any way to just pixelate the node that is connected to the final output, or do I still need to work with the base UVs?

winged spoke
loud rapids
#

Anyone know a good way to debug what causes shaders to display on the editor but not on the build

haughty holly
#

hello everyone, im using the following video to try and make volumetric clouds:
https://www.youtube.com/watch?v=bhW_OYuQ33k
at around 6:00, he teaches us how to make a box to render the clouds in with proper bounds, but it doesnt work, i even copied the code directly from his github in order to try and fix it, but it still doesnt work, does anyone have any idea why?

I spent a lot of time making this video. At first, I edited one, but it got too long and boring. So, I made a better, shorter, and more interesting version from scratch. Hope you like it!

Links
Sebastian Lague's Cloud Video : https://www.youtube.com/watch?v=4QOcCGI6xOU
Github : https://github.com/Parrot222/Clouds-URP

You can contact me through...

β–Ά Play video
#

please ping me if you have anything'

fringe karma
#

What does this error mean? It says no matching 2 parameter method, but none of the methods I'm using have only two parameters. Here's the HLSL code.
For context, I'm trying to set up a custom buffer.

//UNITY_SHADER_NO_UPGRADE
#ifndef CUSTOM_LIGHTING_INCLUDED
#define CUSTOM_LIGHTING_INCLUDED

TEXTURE2D(_ThermalBuffer);
TEXTURE2D(sampler_ThermalBuffer);

void GetThermalBuffer_float(out Texture2D buffer)
{
    buffer = _ThermalBuffer;
}

void SampleThermalBuffer_float(float2 screenPosition, out float4 colour)
{
    colour = SAMPLE_TEXTURE2D(_ThermalBuffer, sampler_ThermalBuffer, screenPosition);
    //colour = SAMPLE_TEXTURE2D(_ThermalBuffer, _ThermalBuffer.samplerState, screenPosition);
    //colour = _ThermalBuffer.Sample(texture.samplerState, screenPosition);
}

#endif //CUSTOM_LIGHTING_INCLUDED
kind juniper
fringe karma
#

but yes just to be safe I changed it to colour = _ThermalBuffer.Sample(_ThermalBuffer.samplerState, screenPosition);

#

although trying to use that instead gives a different, simpler error, invalid subscript 'samplerState

kind juniper
fringe karma
#

https://ameye.dev/notes/edge-detection-outlines/
this outline tutorial has some code on creating a depth/normals buffer, and I'm trying to modify it to parse custom data

kind juniper
fringe karma
kind juniper
fringe karma
kind juniper
#

You can consider that macros are almost 100% related to unity API.

fringe karma
#

so I presume the 'TEXTURE2D()' stuff is unity macros, that aren't working because I'm inputting a custom value name that Unity doesn't recognise?

kind juniper
#

Yes.

fringe karma
#

gotcha

#

I'm trying to assign it from a custom render pass using buffer.SetGlobalTexture(globalTextureName, handle.id);

kind juniper
#
TEXTURE2D(_CameraDepthTexture);
SAMPLER(sampler_CameraDepthTexture);
#

So, I'm not sure where to got that texture.samplerState. API from

fringe karma
#

SAMPLE_TEXTURE2D(_CameraDepthTexture, sampler_CameraDepthTexture, uvSamples[i]).r;

#

inside the outline shader code included in that tutorial

fringe karma
kind juniper
fringe karma
#

now time to see if it actually works

#

oh shit I think it works

fringe karma
#

except for some reason the alpha is always one

#

and I also think it's rendering everything with the same material values, even though I'm changing the material colour between each render call

#
foreach (Renderer r in renderers)
{
    // Set material colour to contain the desired data, based on properties of current renderer
    material.color = SetDataToRenderIntoBuffer(r, camera);
    // Draw data to buffer
    buffer.DrawRenderer(r, material);
}
kind juniper
#

Not quite clear what's going on in that code.

fringe karma
kind juniper
#

Assuming you modify the same material every time. All of the objects rendered with this material would have the last color value you set to it.

fringe karma
#

or at least for the number of unique colours

kind juniper
#

Yes, you would need several materials or use material property blocks

fringe karma
#

so I don't want the original object visuals to change when the effect is disabled

#

alrighty I'll get to using the object pool

stray gorge
#

i don't know why unity rotate direction of the texture but it is so annoying, how can i fix this ?
the texture showed in the scene view and the source texture have different rotations

opaque basin
#

Hi, does anyone know that if Unity (>2022.0) forces multi_compile to have an underscore option to use or not in compute shader?
Since I want to delete the underscore, but my compute shader complains an error only in runtime "Can't find kernel (0) variant with keywords: ".
(it's empty after the colon so I suppose the variant for no option is still generated? And I don't know why the non-option variant could cause any problem)

opaque basin
gloomy gust
#

why does unlit not get affected by fog?

grizzled bolt
gloomy gust
grizzled bolt
grand jolt
#

guys what if a shadergraph shader is as bright in the night as it is in the day?

#

how to fix

modern rapids
# regal stag You can technically use passes with UniversalForward & no lightmode (or SRPDefau...

Thanks Cyan, indeed it seems that URP doesn't support extra passes (other than using the lightmode trick while breaking the SRP batching - also only one extra pass would be allowed in that case). I found an alternative using the RenderObject renderer feature while setting the override mode to shader: in that case all material properties are kept (so I can access shared data) and SRP batching is still working for the main material. Not 100% satisfied but it works and only requires to setup the main material once.

grand jolt
#

idk

#

its shadergraph

#

Shadows work on it

#

but lack of light doesnt make it dark

amber saffron
# grand jolt its shadergraph

In the shadergraph settings you can select the target shader type.
I guess that if it recieves shadows, it is a "lit" type.

Did you plug things into the emission output maybe ?

dapper arrow
#

Hey guys
Just a silly question
How expensive is one dot product in shader if I am targeting lower end mobile phones too? Also for more info, I am using the lit shadergraph

grand jolt
dapper arrow
#

I saw someone advising to avoid dot products for lower end Android phones

amber saffron
amber saffron
dapper arrow
#

I created a simple shader to blend between moss and rock textures and on testing on an older device, it looks like the framerate drops quite a bit when the shader is covering a decent portion of the screen

amber saffron
dapper arrow
#

It isn't very messy or large
Can you check if I am doing something which isn't optimal

dapper arrow
#

That's interesting

#

Lemme check

dapper arrow
#

May I directly share the shadergraph file in dm maybe

amber saffron
dapper arrow
#

Yes, no secret 🫠
Hold on

#

Also I am using the red channel of the diffuse texture to get a cheap hacky heightblend kinda look

amber saffron
# dapper arrow

Hum, I don't see anything particularly costly.
You could replace the Clamp nodes with Saturate and optimise the dot product (as one input is a float), but I don't think that would help the perfs.
You could also try implementing this to go from 4 to two textures samples.

#

Replace power by multiply ?

dapper arrow
#

ohh

#

seems like power and clamp are a bit costly

#

if i understand the heatmap feature right

dapper arrow
vast talon
#

Does anyone know where I can find/buy a pixel scaler shader?

#

I'll pay someone $100 to make me one from scratch too, if not

stray gorge
vast talon
#

Oh, thank you! I've never heard it called that before

vast talon
#

Because I'm totally willing to pay for the convenience of that

ebon moss
#

During the fragment shader, do I have access to the respective worldPositions of each pixel?

errant forge
#

I have generated a normal map using a shader graph. Is it possible to save it in a png?

errant forge
#

Nvm got it thnx

ebon moss
haughty holly
#

hello, how would i make it so that particles take priority over my cloud shader, aka how can i make particles get obscured by the clouds

#

right now when the particles are inside the cloud they render through it

kind juniper
kind juniper
ebon moss
kind juniper