#archived-shaders

1 messages ยท Page 220 of 1

kind juniper
#

Might need to restart unity

sterile sigil
#

going to try that, and reinstalling URP, will report back

#

thanks

#

neither worked unfortunately

kind juniper
#

Is that the only shader that throws that error?

sterile sigil
#

no, they all do

#

the hatebin link shows every error, I believe

#

you'll see some of them are even URP default or hidden shaders

kind juniper
#

Ah right

sterile sigil
#

like I would happily just delete the problematic shaders but I think it's a bigger issue

kind juniper
#

But the stuff in the editor is displayed properly?

sterile sigil
#

yes, no pinks

#

even while playing

kind juniper
#

And in the build?

sterile sigil
#

the build does not reach a state where anything is rendered

kind juniper
#

Wait, so it crashes the game?

#

Or are you unable to actually build it?

sterile sigil
#

I click 'Build and Run'. The green loading bar pops up, finishes. The exe runs, and only gives a DOS style box that features those errors

#

so I do believe it 'builds', it just only presents an error log rather than the fullscreen exe I'm expecting

kind juniper
#

Oh

#

I see

sterile sigil
#

I was building in Server Mode for some reason

#

I knew I had done something subtly stupid along the way

#

changing this fixed the problem generally, thanks for the help @kind juniper

kind juniper
#

I also just stumbled on that post but didn't even think that it's related xD

sterile sigil
#

I do intend to build a Server Only build at some point but not now and I didn't intend to turn that on. Thanks for prompting me to keep Googling every error line lol

torpid sapphire
#

Of ram memory ! Sorry for late answer

kind juniper
normal grotto
#

I want to make a ShaderGraph that can be seen through terrain and objects with URP, if you know how, pls point me in the right direction

hearty horizon
#

Hey everyone, I'm trying to make this 3D model to be rendered in front of the other 2D objects in the Render Queue.
I've tried setting ZTest to Always, but it still doesn't quite work.

#

Does anyone here have experience with 2D & 3D render queue orders? Is there any way I can solve it?
The project is using the Universal Render Pipeline

sinful veldt
orchid zephyr
#

hello, I know this answer was a while ago, but I just wanted to say tyvm, this solved all of my problems as I ended up going back to that direction of things

sinful veldt
strong oriole
#

Are compute shaders available in webgl?

onyx cargo
#

is it possible to make a projector shader that does occlusion?

#

ie: NOT this?

#

(without resorting to a shadow-enabled spotlight)

raw pollen
#

Hey guys, do you know why this could be happening? It only happens on WebGL but on Desktop it looks fine...

steep stirrup
#

Heya, does anyone know how to change ZTest in URP shader graphs?

meager pelican
# sinful veldt i still need help with this please

I assume you mean the "portal" swirl shader.
And you'd get more help if you specify

  1. the target platform you're building for, including things like the pipeline you're using and OpenGL vs DirectX or whatever.
  2. Publish the shader code to see if we spot something.
steep stirrup
#

Thanks a lot, I'll take a look

meager pelican
steep stirrup
#

Unfortunately 'Allow Material Override' is not an option in my graph's inspector. I'm on the latest version (10.7.0) though

#

Might be because I'm using URP?

sinful veldt
#

but i cant use them since i dont have version control

meager pelican
steep stirrup
#

Aah right, thanks!

narrow knot
#

hello. is there a way to use shadergraph to make it like flames or liquid is rising from the edges? Ideal the edges facing up?

#

do does it not know any of what up is because its a sprite?

#

almost like sliding a voronoi that is masked by everything but some distance off of the top edges

meager pelican
#

Sprite?
Animated?

narrow knot
#

yeah player sprite

meager pelican
#

Make another version that has fire animation, and select what you want on the game object. That will be easier...to handle it on the art side, then you can do anything.

The down side of that is it might/will look repetitive.

If that's not an option...

#

It can get complicated fast.

narrow knot
#

yeah trying to do it that we dont need to replicate sprite sheets and play different ones it say the attack state
we some fire behind them it just does not look that good because it does not really go with the player

#

and cant really anchor a bunch of small ones to the arms since they is no bones

#

that is why i was looking if there was a shader or something

meager pelican
#

IDK much about it, someone else will have to give you details.
All I can tell you is that by default, sprites are bounded by a computed set of triangles to reduce pixel count. You can overried that with a quad.

And you'll need to, since you need empty space to draw your fire into, however the hell you do it.

As for doing it, IDK for sure. I'll leave that to someone else. Like you say, figuring out "top" may be hard, since if you use ddy to detect changes from background to sprite-pixel, you've gone past it already.

So some kind of smart mask would be needed I'd think. But I don't do that sprite stuff very often. Maybe others will comment. ๐Ÿ™‚

narrow knot
#

yeah i think the best way to go is start with a mask that feathers out from the top (would need to do this for every frame)

#

then have some gell looking noise to scroll up

meager pelican
#

I'd build it into the sprite sheet(s), and distort the fire with a shader. But that's me.
If you don't want to duplicate the sprite or sprite-rows to have fire vs no-fire, I'm not sure how to do that in a shader without some mask.

I suppose you could have ONE set with a mask, and either ignore the mask, or use the mask for fire. Then distort it with noise.

narrow knot
#

then also thought about a particle system that used the mask to spawn to but i can seem to get that working either

#

yep agreed.
I cant wait to tell the artist the news ๐Ÿ™‚

meager pelican
#

Others may comment. ๐Ÿ˜‰
I'm not very sprite-aware. ๐Ÿ˜‰

sinful veldt
#

@meager pelican how do i make sure my shader is included in build? i checked build settings but i do not see any shader settings there

meager pelican
#

Project Settings->Graphics, IIRC.

sinful veldt
vernal island
#

hello. im making the shader and i want the change intensity of light and then change the color of the object. i tried _LightColor0 but when i change global light it doesnt change anything
code here:

#

i think only way is to push the data to shader (float xAmbient) but i think its little meh. i try to make solo shader without any inputs from other scripts

#

oh wait its changes .... but i need to click on scene and come back to game ... o.o

#

it doesnt change when i change it using slider in runtime...

vernal island
#

doesnt anyone know how to fix it? :/

tribal galleon
#

any idea why this is still just displaying purple?

vernal island
tribal galleon
#

but what

vernal island
#

uff you need to wait to someone who knows shader graph :/

kind juniper
tribal galleon
#

@kind juniper

kind juniper
tribal galleon
#

Can't rn

unkempt fjord
#

hey so if I'm trying to write an image effect shader that looks at surrounding pixels

#

how do I get the colors of the pixels around the pixel in frag()?

#

just need a simple 3x3 convolution

meager pelican
# unkempt fjord how do I get the colors of the pixels around the pixel in frag()?

You probably don't (depending on what you mean).
The thing is, there ARE NO surrounding pixels yet...they're all being processed at the same time, and aren't done yet. Remember....GPU = massively parallel multi processing. UNLESS you're talking about the background from a previous draw call(s), that's available in a render texture.

So it is done in multiple passes. You draw it all, pixel by pixel. THEN, in another pass, you convolute them all. This is why it is called "Post Processing".

The other way is to try to compute the 8 pixels around the current one the same way you compute the current one, reading texture(s) and doing lighting calcs, and then convolute it. But...that's a total of 9 texture reads for each pixel, 8 of which are redundant. Yuck.

So you use a STENCIL! (Last I knew, Shader Graph didn't support stencils yet though). You flag pixels to be convoluted by marking them with a stencil, and the post processing pass can tell what pixels to mess with.

So research stencil for whatever pipeline you're using, and also post processing, or at least multi-pass processing.
๐Ÿ™‚

#

But if you "just" need the background, see the scene-color node in SG, or check out Render Textures and multiple passes the background in built-in.

unkempt fjord
#

I found some code online that managed to work actually, unless this is fundamentally wrong. I was trging to achieve edge detection after the screen is rendered, and it seems to have worked

#

It actually doesn't use multiple passes - just one, takes colors from main tez

#

Tex

digital tide
#

for tree shaders that use the built in render pipeline, what shader in urp should I upgrade to?

#

The tree tree02 must use the Nature/Soft Occlusion shader. Otherwise billboarding/lighting will not work correctly.
I get this error when using Nature/SpeedTree8

hollow talon
#

I can't use Range for my custom shader in URP
What I use:
_ExampleName ("Float with range", Range(0.0, 1.0)) = 0.5
The error I get:
Shader error in 'CustomShader': Parse error: syntax error, unexpected TVAL_ID at line 28

meager pelican
livid helm
#

what would be the best way to round something like this into either 0 on the left and 1 on the right, i tried using power but i figure there must be a easier way to just round anything below 0.5 to 0 and anything above to 1

#

found step

meager pelican
#

lol, posting at same time.

livid helm
#

thankyou, that code opens up the world of shader coding for me. right now dipping my toes into shaders with shader graph.

#

my issue now is tryign to scale that

#

basically im trying to create a fade slider on a shader

#

but control how "hard" the fade is

#

so both how fast it goes from 0 to 1, and in how many "steps" resolution wise

meager pelican
#

Yeah, two different things.
for the speed, that's a scale.
For the "steps" that's quantization....division, basically.

livid helm
#

so in a sense be able to slide between the step function and the other

#

so, id have to quantize to smaller divisions the more resolution i want

#

hard step being quantized to either 0 or 1

meager pelican
#

0 and 1 are only two quanta, though.
What do you want for a result if you have 4 steps?

livid helm
#

0,0.25,0.5,0.75,1

#

i guess thatd be 5

meager pelican
#

OK (but that's 5).

#

lol

livid helm
#

ye

meager pelican
#

same time again

#

lo

#

OK.

livid helm
#

so let me try to explain it the best i can

#

basically i want 2 variables

fade value, (0 completely fade out, 1 completely faded in)

fade resolution. (0 meaning it works as a step, 1 meaning it works as the original uv r values)

#

it would fade for example from left to right. so fade value would dictate how far in is the fade

meager pelican
#

Try (value * speed) / steps.
Might want (steps + 1) or something.

livid helm
#

sounds good, this can be done with math nodes right?

meager pelican
#

Yes, unless you use a custom function and type in the math. Which might not be a bad idea, this "fade" being considered a unique idea/function.

#

Then you could make this "fade thing" a sub-graph with a custom function node, and use that in many other shaders.

#

Like a subroutine called by many other things. I think.

livid helm
#

makes sense

#

ive been wanting to make a sinelerp, sounds like a similar concept but with shaders

#

ill have to look into custom nodes

#

and shader programming. whatever shader graph asset i have i can go in and look at the code?

#

and alter it?

meager pelican
#

Yes, but once you alter it you keep going in text mode from there on.

livid helm
#

the point of no return

meager pelican
#

"no going back"

livid helm
#

thats cool

#

i mean ideally itd be some sort of "steps" node, as opposed to step

#

and if you choose "infinite" steps, it just keeps the original resolution, and then slowly make it less

meager pelican
#

You can try gradient

livid helm
#

kind of a circle becoming a polygon with less "steps"

#

thanks for the help, looks like a fun dive into shaders in the future

#

ill explore gradient node

meager pelican
#

With gradient, you'd quantize the "t" value into discrete steps. But that's really just the math again. Followed by a lookup at "t".

#

Or quantize the result in the gradient regardless of the t, as long as it is in range. Used in toon shaders a lot.

#

To get a stepped color

livid helm
#

thanks that really helpful

#

thing is im trying to get a "picture" of the gradient with all its t values, as opposed to the value at one time. so kinda like a step function going from 0 to 1, but having access to a resolution of step amount

#

so itd be about mapping the quantized t steps into a map of all of them

meager pelican
#

Hmmm.
To me, you're either at or below 0, in the middle, or at or above 1.

#

The middle ground is quantized into steps.

livid helm
#

yeah thatd be 1 setting, the more "steps" the more shades of grey thered be

#

i think i just need to understand how gradient node works worrectly, or how to map that into a uv-sort of thing

meager pelican
#

Yeah, the gradient node in SH works with math, IIRC.
But there's a cheat.

livid helm
#

kinda like this, right now im using power to have the 0 slowly overtake the 1

#

although it doesnt really overtake it

#

but is there a way to have a gradient map in that sense?

meager pelican
#

You can use the gradient object in C# in the unity editor.
Then store the result in a texture.
Then do the UV lookup into the texture.
Just call gradient.evalueate() in steps, like 256 or 512 or whatever steps of resolution you really want. And sample the texture from 0 to 1 UV.

livid helm
#

this is really throwing me off, how the first node doesnt let me connect to others except the simple gradient one

meager pelican
#

As for "speed" that's a different input into it all. You'd multiply the sample point (t) by the scale/speed you want.

livid helm
#

its inevitable that i dive into shader programming it seems

meager pelican
#

If I understand you.

livid helm
#

yeah thered be speed and resolution

#

and time

meager pelican
#

Well if it is a function of time, that might be what you want to do is scale the time value.

livid helm
#

ill look into that toon shader link you shared, appreciate it. and work on making my first code shaders because it would make more sense for me to code it since i understand how it works, just not how to make it with shader graph

#

true makes sense to scale the time value

meager pelican
#

Yeah, many (me) feel similar. I have a history of programming in code, so all these boxes and lines drives me nuts.

#

But YMMV

#

Do you want lighting in this? Do you care about light values, directions, etc?

livid helm
#

i just need to get acquainted with the workflow i think, or do it atleast once and not be so intimidated

#

not right now

#

looks pretty much like that toon shader, except affect the alpha values instead of light

meager pelican
#

Either make a lit or an unlit shader graph, just give it a passed-in color for the pixel. Nothing else.

Then edit the code from there. It is a code generator for the pipeline, and will give you a default template.

BUT...you'll have to learn the library.
Cyan wrote up some stuff. Sec....

livid helm
#

sweet thanks a lot

#

imonly familiar with c# programming since i learned programming in unity pretty much over the years so i think ive just been postponing learning shader programming since syntax can be a bit new to me. that link will become a good resource. appreciate your help

#

itll need a passed in texture as well as the color right?

meager pelican
#

As for "how GPUs work"....
There's many videos on the net, and also some courses like Udemy or Hollistic 3D or others that I've seen.

meager pelican
# livid helm itll need a passed in texture as well as the color right?

If you use the "gradient cheat" from C#, sure.
Or it is math, but you'd have to pass in an array of info. So either way you'd pass in something.

But if you don't want to write it by hand, try generating it in SG first.
For the "cheat" way, you don't need a gradient node, just a sample-texture node, and of course the texture to sample.

#

And code on the C# side to create the texture to sample from a gradient

livid helm
#

ok, basically use the gradient object as a way to control the "progress of the fade"?

#

then just quantize those

meager pelican
#

Yeah, you'd just end up with a texture that has N colors in it.

#

Say 256 x 1 pixels. Or 512 or 1024 in size.
But it might only have 4 colors .....0, .333, .666, 1
Or whatever...in 4 blocks of color

#

Then the result is whatever at value t

#

0 <= t <= 1

livid helm
#

yeah, value t affecting the gradient object right? from all 0 at 0, to all 1 at 1.

meager pelican
#

So it's just one sample

livid helm
#

.5 beIng at the middle if it was linear

meager pelican
#

Well, 0 to .332 would be black.

#

.333 to .665 would be 1/3 light

livid helm
#

right, i see what you mean

#

kinda like bit crushing in audioit seems

meager pelican
#

The steps.
Artists love this, easy edit in unity's gradient editor. You can map I think up to 8 change points.

#

But if you need more, use math instead.

#

Also, math is faster than a texture sample

livid helm
#

good to know that

#

so math> gradient for performance?

meager pelican
#

GPU's are built for speed. So what happens is that if it is stalled off waiting for a memory access while sampling a texture, it goes off and works on some OTHER sets of pixels "from the top" of the pixel shader code. Latency hiding, groups of cores in "waves".

But that has overhead too.

So in the end, math wins 99% of the time.

#

But GPU's are built to sample textures. ๐Ÿ˜‰

#

Using dedicated hardware in silicon.

#

You may never notice the differences, depending on your use case.

livid helm
#

i dont think ill push the limits yet but its good to know to plan ahead for heavy processing

#

for the gradient cheat i just have to figure otu how to implement that into my shader script, can it be added as a property?

meager pelican
#

Crap. I've seen shaders with 20 texture samples going into it.

livid helm
#

or is it more like the results from the gradient cheat will be inputted into the shader as a texture?

meager pelican
#

The texture?

#

It's a texture2D

#

Just a run of the mill texture. That you sample, however you calc t.

#

If you're not using math to do the whole thing.

#

You need C# code to make the texture from the gradient on the object.

livid helm
#

where can i look up the "gradient cheat" from c#

#

so wouldit be on another script or inside the shader script?

meager pelican
#

No, C#

livid helm
#

i have no idea yet of the anatomy of a shader script sorry

#

kk

meager pelican
#

Game object

livid helm
#

oh

#

a component?

#

already built?

meager pelican
#

Have u used the gradient editor in C#?

livid helm
#

not willfully haha idk if ive used it at some point and not know what it was

#

closest ive come is editing the color on a linerenderer i think

meager pelican
#

Yeah.

livid helm
#

so is there something built in so i can skip writing it?

meager pelican
#

It's got the little triangle tabs, and you can set colors at those points and drag them around. Artists love that. Easy to edit.

livid helm
#

oh so the cheat is to export that into a texture

meager pelican
#

Then in the code, you'd do an OnValidate or some such, and create or re-create a texture2D, and set the pixels into it.

meager pelican
livid helm
#

where can i look up how to export a texture in c#

#

or build it in that case

meager pelican
#

You'd use a for loop to evalueate the gradient at each pixel and set the texture.

Say a 512 x 1 texture. (512 being the x value).
Sample y at .5 in the shader.

livid helm
#

i think i understand the math, just not how to make those values into a texture

echo solstice
#

Can someone help me to use tex2Dlod word?

#

I want to use that

#

On glsl shader

meager pelican
#

Gradient.Evaluate() IIRC.
You don't have to know the math. Just leave it to the person editing the gradient.

If you want to do the math, don't bother with the "cheat".

livid helm
#

thanks again, i think ill experiment some so if im back with more questions ill atleast have started actually building the thing haha

echo solstice
#

Can someone help me?

meager pelican
echo solstice
#

In fragment part

#

I want to use that keyword. Like Texture2D = tex2D

#

How to use tex2Dlod?

meager pelican
#

Oh, it's just like tex2d, except it has an additional parameter for what LOD level you want to sample.

meager pelican
echo solstice
#

Thank you

#

Let mee check

meager pelican
#

The level is in the .w component.

#

xy are x and y for the sample.

#

Don't ask me why it isn't in z. IDK, but I don't care either.

odd grotto
#

when importing a model as an fbx with textures

#

is there anyway to change the shader type without setting up an external material

#

or even set the default shader to something else like unlit

kind juniper
# tribal galleon

You're still using the built-in rp. Look at your "scriptable render pipeline settings".

kind juniper
violet sable
#

Is there a way using Unity's current material system to apply multiple "sub-materials" or "sub-shaders" and mask them with the RGBA channels under a single material? Something similar to how Destiny processes its armor shaders system?

digital gust
violet sable
#

Ah, interesting. I am not really that interested in using shadergraph at the moment, but its cool to know that it is possible. Thanks

digital gust
#

I mean you can write it by hand too ๐Ÿ˜‰

violet sable
#

Yeah, that is what I was thinking. I just wasn't sure how Unity would handle it or if the shader system was not modular enough to have external materials assigned as submaterials

digital gust
#

Well materials are on top of shaders. But i guess your desired thing lays in the shader part and from there feed the materials according to their needs

midnight spade
#

Does anyone know if you can pass texture arrays as function arguments?

#

Like what would their type be?

#

That question might be pretty nondescript so here is a picture instead

#

The first function allows me to perform a triplanar sampling of a 2d texture. I'd like to be able to do the same with a texture array but I'm not sure how to pass the actual texture array

worn furnace
#

I feel like an idiot but I can't find a way to do alpha in a URP shader graph?

lime viper
lime viper
worn furnace
#

2021.1

lime viper
#

the Graph inspector should have a Graph Settings tab

#

you can turn on Alpha clip, or change the mode from opaque to transparent there

#

that should give you the alpha input node on the master stack and allow you to use it

worn furnace
#

omg thank you

#

I spent the last two hours writing a shader in CG to do something that would take like 30 seconds in shadergraph because I couldn't find that toggle lol

lime viper
#

glad I could help

lime viper
#

ok well that is definitely not what I expected, multiplying my normal vectors by -1, negating them, or multiplying them by a -1,-1,-1 vector seems to be the problem so I think that's a bug

#

Yep, changing my multipliers to -0.999999 fixes it

karmic hatch
#

Is writing shaders for URP similar to HDRP?

toxic flume
#

I have a box shape and use it as a skybox, I have used a camera to render that skybox object.
Do you know better approach instead of adding an extra camera?
For example using GL commands to render it

mental bone
#

So I toniced that texcoords are defined as float4 in UnityCG.cginc. I'm re-writing a old shader for hdrp and there texcoords are float2 in the AttributesMesh struct. Does anyone know what unity puts in the w and z of the texcoord from UnityCG.cginc. in the default render pipe ?

low lichen
mental bone
#

thats what Im thinking we shall see

meager pelican
# midnight spade The first function allows me to perform a triplanar sampling of a 2d texture. I'...

I'd go find that macro in the includes. (You're passing a sampler in the first example, BTW).

But see here for some history: https://gist.github.com/aras-p/a3aeac5c84ce233f6787

How many different texture arrays do you have? At worst-case, you could create a switch statement for them (yuck!). Sucks in shaders due to shared instruction pointers in a work group.

Or if each drawn object only has one texture array assigned, you should be able to just reference it if you assign it on a material by material basis. (But you wouldn't be asking this if you could do that, right?)

Gist

Possible texture array syntax. GitHub Gist: instantly share code, notes, and snippets.

#

It appears that the reason they're using macros is to abstract platform differences.
Pointers really don't exist in shaders, and IDK if you can create an array of texture2DArrays. Oy.
And the sampler syntax is different by platform too.

sacred minnow
#

Not sure if this belongs here but how do i change this?

summer shoal
#

what am i doing wrong the world position based shader in urp? its offset by a little bit

verbal condor
#

can you declare a class in CG? trying to pass more info than what's in a float4 (rgb + a + distance) for raymarching and i can't find how to declare a class or where to do that

wicked niche
#

Can you please tell me what combination of ZTest and ZWrite should I write so that my red object is displayed over the white object, but still not displayed over the skin?

verbal condor
meager pelican
toxic flume
#

To restrict some objects and meshes to have same lightmap texture, the only way in unity is to define same tags in lightmap setting?

slim steppe
#

Why is the shader only working in the editor?

pine flax
#

I'm getting the error message "Unexpected TVAL_ID"

#

And the proposed solution was "leave the shaderlab top section, move the VS and PS programs into vertex and fragment blocks of a GLSL program, and make sure your unity is set to use OpenGL as it's rendering API"

#

how the hell do i do that?

#

I suppose this is the VS block?

midnight spade
dry oasis
#

Anybody know how to generate a noise texture (or any texture) and then use it say as a texture i put in properties? thanks

wary jackal
#

Hey, it's been a while since I've been here. I have a question about 2d sprite shaders. I want the sprite color to carry into the material properties. How do I do that?

midnight spade
dry oasis
#

Hmmmmm ok thanks!

midnight spade
#

Np ๐Ÿ™‚
It's not a very specific answer but I'm sure people have done this online before haha

#

Although if you want a simple solution that should meet most needs you could always just download a noise map

meager pelican
meager pelican
#

And it is dereferenced in HLSL by whatever name you use in the shader property. But what is messing with you...is that it is set in C# on the material, not in the shader code. Because of the basically client/server relationship between C# and GPU.

And there's always include files and macros to help abstract things to your train of thought when dealing with several shaders.

lime viper
#

So this might be a bit in the weeds, but is there a way to make it so that a shader uses an uncompressed version of a texture? I'm baking out shader results and want to avoid leaking compression artifacts in and I'd rather not change the original source texture settings if possible.

midnight spade
#

I figured that something like a sampler3d or smt would exist to fill in the gap

west eagle
west eagle
#

it will work with forward camera and geometry queue but i have to use defered camera

junior kelp
#

is it possible to have my camera render to a render texture and also the screen? without having to use multiple cameras

kind juniper
junior kelp
#

i dont know shaders : (

#

only shader graph lol

kind juniper
#

It's unrelated to either.

#

It's something you do on the C# side.

#

Your question is more of a render pipeline question, rather than shaders related.

junior kelp
#

oh

#

thanks though

hollow dagger
#

Hey guys, I need some quick help

#

So i'm on URP, and I am trying to add a dither effect to my custom shader

#

And followed a tutorial. But my issue is this:

#

Connected to that multiply is my color, and texture 2D, which I put into this multiply

#

I am trying to split its alpha, and multiply it with my "opacity" propterty

#

Which connects into the alpha slot. But when that happens, my material makes my objects invisible

#

if it helps the shader is on a quad, and this is a lit graph

meager pelican
meager pelican
wooden kite
#

hi guys, i've modified a simple HLSL outline shader, does anyone know why it work only with sprites but not with UI images ?

#

im totally newbie at HLSL shaders

teal breach
teal breach
novel blade
#

how can i display a square on a terrain with a surface shader ?

i download this image from google and i can't find any tutorial

torpid sapphire
#

I've been on this problem for a few days, could someone help me understand how memory allocations of shader work ? In my scene, I have a terrain using the unity Lit Terrain shader. It takes around 400mb of RAM memory in build according to the Memory Profiler. As I understand it, it compiles every variant at build time and when I need the shader it loads all variants at once at runtime. Thing is, I technically only need 1 variant don't I? Why would it compiles/load thousands of variants if my terrain only exist in one and only one situation ?

Is it in case I change settings at run time (ie : toggling shadow on and off) ? I will not do this in this scene.
How do I reduce this gigantic shader memory footprint ?

Thank you ๐Ÿ™‚

#

I heard about swapping multi compile statements for shader feature statements to strip even more shader variants for things I know won't change in my scene, but is this the right way to go ? How would one do this with unity built in shaders and Shader Graphs without having to copy the code and edit it manually every time I do a single change

kindred forum
#

I am trying to position and scale a mask on a texture positioned on a point in the world -- I sort of have it working but am not sure what's the right way to translate the mask to the desired position -- any tips?

#

this sort of works -- I'm pretty new to shaders so feel free to point out anything wrong:

#

but the above doesn't quite map to the PeekPosition

#

also I previously had:

#

which works somewhat, too, but seems to position the mask slightly off from the PeekPosition -- which is what's sent me down this rabbit hole

wraith inlet
wraith inlet
kindred forum
#

yeah, probably, the issue is I'm trying to rotate the mask around its bottom center ๐Ÿค”

#

fiddling w/ offsets reduces the translation problem -- but rotating around the point feels off

wraith inlet
#

does it work better if you rotate first then translate?

kindred forum
#

trying that now lol -- so far results are no, generates this kind of effect:

wraith inlet
#

and what did you get with the other setup?

kindred forum
#

that's rotating first then tiling:

wraith inlet
kindred forum
#

hm, rotating then adding delta position to the result just leads to more screwy rotation ๐Ÿ˜ฆ

wraith inlet
#

screenshot?

wraith inlet
kindred forum
#

exactly the cutout should start at the transform -- bottom center aligned w/ the pivot/transform

#

then rotate around that transform

#

here's the graph, no tiling to try to reduce noise:

#

but now the cut out is way off, and rotates in a way that has no relationship to the pivot:

wraith inlet
#

well its tiny because you lost the scaling that you had in tiling and offset, right?

kindred forum
#

right, not super worried about that

#

more like the position offset didn't work as expected

#

oh my bad in the above I rotate then feed into the sampler, I will post add then feed into rotate -- results aren't much different IIRC

#

results:

wraith inlet
#

what happens if you flip peek position and world position going into the subtract node?

#

wait, and why don't you want to pass in peek position as the center of rotation?

kindred forum
#

that's not ideal from a certain point of view but may just be crazy enough to work

#

scratch that, thinking more the reason that won't work is because the cutout is a cone, so we can't rotate around it's center -- it won't look good

wraith inlet
#

it looks like the rotation node translates the uvs to the center position, rotates, then untranslates

kindred forum
#

somehow, I think I've found the magic configuration โœจ

kindred forum
#

it was basically what I had at the start, but w/ offsets nudged around and aligned -- the texture was slightly off center, I think:

#

for the next poor soul who wants to create a "keyhole peek cutout"

#

key bit was making the offsets for tiling and rotation match

#

and realizing that there needed to be a slight x offset FML

wraith inlet
#

ahh, that make sense

#

it looks great!

kindred forum
#

(bugs and all ๐Ÿ™‚ )

obtuse basin
#

Hi! I'm using materials to change some of my UI color depending on the character being played

#

I'm using this shader graph, which takes the luma of the texture and hue and saturation of the blend color

#

And I believe it is technically correct

#

it's a replication of Photoshop's color blend

#

however, when I test it, the resulting colors do not match the expected result

#

it gets close, but I don't know if that's the result of some shader graph settings

#

the resulting colors hue, saturation and luma just never matches my expected result from the shader graph

wispy stump
#

need someone to rewrite a built in shader into a URP version that does the same thing

kind juniper
wispy stump
kind juniper
kind juniper
#

If you really want to hire someone, there's a forum section for that on unity forums. Or you could try one of the freelance platforms, like upwork.
Otherwise just do it yourself. You can of course ask help here or info on learning resources.

devout imp
#

hey hey

#

i just come with a quick question

#

how do i stretch a texture over a mesh via shadergraph?

#

im wondering if thats possible without having to UV map manually

meager pelican
odd grotto
#

Hey, this is a shot in the dark but I figured this is the best place to ask, I've got a collection of textures I'm using for a project

#

the only problem is the y channel is inverted on all of them

#

Is there some way either in unity or externally that I could fix the normals in bulk

odd grotto
#

I've been trying to get a working method for that but the only batch plugin for gimp doesn't support the one thing I need to do

#

did you read what I just said

#

oh right sorry I wrote unity instead of gimp, my bad

#

but I've already tried that

#

I can't find any way to invert specific color channels

#

that would typically be done with a curve modifier

#

which surprisingly isn't supported

#

the only other thing I found flat out did nothing to the textures

digital gust
odd grotto
#

that inverts the whole image

digital gust
#

recombine them with the original

odd grotto
#

not with batch

#

unless you suggest that I separate everything out completely and recombine it

#

shouldn't this be possible with the shadergraph anyway though

digital gust
#

thats what I was thinking you are using. Get image, rgba split of original, invert original, split the inverted, recombine original channels with the once you want inverted.

odd grotto
#

I was going to but realockto suggested a gimp batch thing

digital gust
#

Wait what, so gimp is another software, am I missing any plugin for unity of gimp? ๐Ÿ˜„

odd grotto
#

nope, but it would have been a valid suggestion if it worked

#

I did ask for a solution including an external issue

#

however I'm not great with shaders

#

I'm just trying to get a texture input right now

digital gust
#

Top left is where you put your variables to be used outside:

#

You can click it and on right side use "exposed" to make it usable in the inspector and scripts

odd grotto
#

am I approaching this right

#

it's letting me add the textures but they don't apply in game still

digital gust
#

Do you add them to the right output?

odd grotto
#

i'm pretty sure I did

digital gust
#

hm, how is the texture showing in scene/gameview?

odd grotto
digital gust
#

Thats weird, it looks right to me.

odd grotto
#

wait hold on

digital gust
#

So you added the right material to the object yes? Just a dumb question, but things can happen

odd grotto
#

for some reason it removed itself from the object

#

it was on previously though

#

and I could have sworn It was in the inspector for it

digital gust
#

is it working now? ๐Ÿ˜„

odd grotto
#

I think so?

#

but It seems like there's a problem with the object / tangent space

#

is there a way I can force it to use this instead of the URP lit by default

#

so when I make a new material it's ready

digital gust
#

Graph settings top right

odd grotto
#

when creating a new material can I make unity use this instead of the urp lit

#

I think I got everything else working perfectly though

#

thanks a lot

tame topaz
#

!ban 284330108083372043 scam

echo moatBOT
#

dynoSuccess SweetNES#4582 was banned

odd grotto
#

whoa

novel blade
#

how can i display a square on a terrain with a surface shader ?

i download this image from google and i can't find any tutorial

kind juniper
digital gust
digital gust
timber carbon
#

hey is there a way to generate a mesh using a compute shader and update the gameobjects mesh without having to send it back to the cpu?

warm zodiac
#

Is there a way to convert an atlased UV back into a normalized 0->1.0 UV without passing additional parameters to the shader?

charred anvil
#

When using Shader Graph in Unity 2020, how do I set the alpha channel of the fragment? I have set surface type to be "Transparent" and the blending mode to be "Alpha", but I don't see anywhere to inject the alpha. The base color only accepts RGB, and it rejects alpha.

regal stag
charred anvil
#

@regal stag Thank you! That is a very unintuitive workflow.

ashen elm
#

Hey

#

I'm trying to make a sprite rotate only its Y axis towards the camera

#

This is what I'm trying

#

It works on some angles

#

Any idea on what I should use to convert the direction from the object to the camera into angles/radians?

ashen elm
#

ok splitting the matrix didn't work

#

it just gets flatenned

#

it workedd

swift yoke
#

does unity have a built in property for the position of an object inside of the shader code? Or is it just the position of the vert that it has?

kind juniper
# swift yoke does unity have a built in property for the position of an object inside of the ...
grand jolt
#

How would I scale a object in a vertex shader?

#

No matter what I seem to do I can't get it to scale

#

It is a sprite shader

#

this is my code rn

            v2f vert(appdata_t IN)
            {
                float multiplier = (_MainTex_TexelSize.zw + float2(_Size * 2, _Size * 2)) / _MainTex_TexelSize.zw;
                
                v2f OUT;
                OUT.vertex = UnityObjectToClipPos(IN.vertex) * multiplier;
                OUT.texcoord = ((IN.texcoord -.5) * multiplier) + .5;
                OUT.color = IN.color * _Color;
                #ifdef PIXELSNAP_ON
                OUT.vertex = UnityPixelSnap (OUT.vertex);
                #endif

                return OUT;
            }
#

ignore the texcoord part that's for a different thing I just need the vertexes to scale correctly

mental bone
#

Scale the verts before you transform to clip space

grand jolt
#

I should also mention it works fine when there's only 1 item

#

But breaks when there are multiple

mental bone
#

I beleive the issue here is dynamic batching since that transforms all verts to world space on the cpu. You need a way to pass in the object vert positions or transform them back into object space

#

If you are doing this for outlines there are better ways to achieve it btw

lyric sun
#

does unity compute shaders not recognize vec3 or fract?

#

what is the alternative to them?

swift yoke
lyric sun
#

what about fract

swift yoke
lyric sun
#

fract is used in glsl code which i thought unity compute buffers use

#

i need it for some 3d noise generation

swift yoke
#

okay guys, I'm having trouble with a vertex displacement shader. Basically I have an object with a cube Mesh. Then I also have an empty Transform.
I wanna move the transform around and have the verts of the cube mesh follow it, I'm trying to make a softbody/spring system idrk.

float localDelta = v.vertex.x - _OriginPos.x;
float restTarget;
if (localDelta < 0) { restTarget = _OriginPos.x - _RestDistance; }
else { restTarget = _OriginPos.x + _RestDistance; }
float strain = restTarget - v.vertex.x;
v.vertex.x += strain * _ForceFactor * _Time.x;
                

Right now I'm just testing on the x axis.
The 'OriginPos' is the Transform I move around.
The _RestDistance is basically just how far I want the verts to be from the Transform, so if you picture a spring, this is the length of it at rest, then as you get further (stretching/compressing the spring), the force will increase and aim for the point of rest.

lyric sun
#

ok so i get this error

#

Shader error in 'testGen': incorrect number of arguments to numeric-type constructor at kernel CSMain at testGen.compute(321) (on glcore)

#

with this line

#

float3 s = floor(p + dot(p, float3(F3)));

#

how many arguments is floor supposed to take?

swift yoke
#

1

lyric sun
#

that is one argument though

#

so why the error?

swift yoke
#

float3

#

s

lyric sun
#

?

swift yoke
#

in shaders maybe it can take more since they're pretty great

#

floor gives you 1 output

#

and you're assigning it to a float3

lyric sun
#

so do i have to do it to each part of the float?

swift yoke
#

float3 s;
s.xyz = floor();

#

maybe it can go on one line idk

lyric sun
#

if i do that it says unexpected token '.'

swift yoke
#

what is p?

lyric sun
#

p is the input float3

swift yoke
#

then your floor method is taking multiple inputs

#

it should just be 1 float I think

#

again, might be different for shaders

lyric sun
#

im using a compute shader

swift yoke
lyric sun
#

this is not my code but code im trying from shader toy

#

problem is it is glsl code and unity uses hlsl

kind juniper
#

Dot would return a float though.

lyric sun
#

how should that line be done properly?

kind juniper
#

What line is the error on? And what does it look like now?

lyric sun
#

the line wiht the code float3 s = floor(p + dot(p, float3(F3)))

#

it says number of arguments is incorrect for numeric-type constructor

kind juniper
#

One problem is what Pybounce mentioned. I thought you fixed it.

lyric sun
#

i tried .xyz

#

but then it says unexpected token at '.'

swift yoke
#

p is a float3

#

needs to be a float

kind juniper
#

He's getting a dot product

#

It returns a float

swift yoke
#

he's doing p + dot(blah)

kind juniper
#

Ah

#

You're right. Kinda missed that lol

lyric sun
#

so should it be float3 s.x = floor(p.x + dot(p.x, F3)?

#

F3 is a const float

#

and then continue for x and z

kind juniper
#

You probably can't access float3 component on the same line as the declaration is.

lyric sun
#

?

#

the declaration is outside of the funtion that has the line

kind juniper
#

You declare float3 s on that line

lyric sun
#
const float F3 =  0.3333333;
const float G3 =  0.1666667;

/* 3d simplex noise */
float simplex3d(float3 p) {
     /* 1. find current tetrahedron T and it's four vertices */
     /* s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices */
     /* x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertices*/
     
     /* calculate s and x */
     float3 s = floor(p + dot(p, float3(F3)));
     float3 x = p - s + dot(s, float3(G3));```
#

there is part of the code

#

for better understanding

kind juniper
#

Whenever you do type variableName it's a declaration of a new variable.

lyric sun
#

i really dont understand shaders

#

but i need one for the speed

kind juniper
#

It's not shaders. It's the same in C#

#

It's something common to most programming languages with strong typing.

#

So you need to declare it above with float3 s; and then you can do s.x = floor(....

lyric sun
#

ok here is better . . . how do i meke this work in compute shaders? this is in glsl and works fine

#
/* discontinuous pseudorandom uniformly distributed in [-0.5, +0.5]^3 */
vec3 random3(vec3 c) {
    float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
    vec3 r;
    r.z = fract(512.0*j);
    j *= .125;
    r.x = fract(512.0*j);
    j *= .125;
    r.y = fract(512.0*j);
    return r-0.5;
}

/* skew constants for 3d simplex functions */
const float F3 =  0.3333333;
const float G3 =  0.1666667;

/* 3d simplex noise */
float simplex3d(vec3 p) {
     /* 1. find current tetrahedron T and it's four vertices */
     /* s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices */
     /* x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertices*/
     
     /* calculate s and x */
     vec3 s = floor(p + dot(p, vec3(F3)));
     vec3 x = p - s + dot(s, vec3(G3));
     
     /* calculate i1 and i2 */
     vec3 e = step(vec3(0.0), x - x.yzx);
     vec3 i1 = e*(1.0 - e.zxy);
     vec3 i2 = 1.0 - e.zxy*(1.0 - e);
         
     /* x1, x2, x3 */
     vec3 x1 = x - i1 + G3;
     vec3 x2 = x - i2 + 2.0*G3;
     vec3 x3 = x - 1.0 + 3.0*G3;
     
     /* 2. find four surflets and store them in d */
     vec4 w, d;
     
     /* calculate surflet weights */
     w.x = dot(x, x);
     w.y = dot(x1, x1);
     w.z = dot(x2, x2);
     w.w = dot(x3, x3);
     
     /* w fades from 0.6 at the center of the surflet to 0.0 at the margin */
     w = max(0.6 - w, 0.0);
     
     /* calculate surflet components */
     d.x = dot(random3(s), x);
     d.y = dot(random3(s + i1), x1);
     d.z = dot(random3(s + i2), x2);
     d.w = dot(random3(s + 1.0), x3);
     
     /* multiply d by w^4 */
     w *= w;
     w *= w;
     d *= w;
     
     /* 3. return the sum of the four surflets */
     return dot(d, vec4(52.0));
}```
kind juniper
#

Gotta convert types and function names to corresponding types and functions of HLSL.๐Ÿคทโ€โ™‚๏ธ

lyric sun
#

i did but thats when i got the error stated above

#

all vecs are float3/4 and fract is frac

kind juniper
#

Gotta look up the differences between them and how to deal with it then.

swift yoke
#

is v.vertex just the delta between the origin of the object, to the vert. Because that's how I've been treating it and it's not working at all

verbal condor
# lyric sun ok here is better . . . how do i meke this work in compute shaders? this is in g...

https://youtu.be/CzORVWFvZ28
here's a vid i found helpful

Twitter: @The_ArtOfCode
Facebook: https://www.facebook.com/groups/theartofcode/
Patreon: https://www.patreon.com/TheArtOfCode
PayPal Donation: https://paypal.me/theartofcode

Ever wondered how to get a shader from ShaderToy imported into Unity? Well wonder no longer because in this video I will explain how to do it. Its really not that hard.

Ru...

โ–ถ Play video
#

shader toy is written in glsl

meager pelican
#

(comment for your original question)

swift yoke
meager pelican
#

Incidentally, the float constructors can take a variety of formats, but it has to result in having 3 values. This is a good thing, since it catches some unintentional errors.
So if foo is a float2 you can say:
float3 s = float3(foo, 1.0); and that works too...since there's THREE components and the compiler will figure it out.
Also these two statements are equivalent:

float3 s = .5;```
grand jolt
#

Help me I can't change languages if I want to make a script

meager pelican
# swift yoke okay yeah so more on this... Looks like it all goes mental at 0.5. So if someone...

Is v the input or the output?
If input, it's the vertex (object space) from the model for each vertex in the model/mesh being processed. The vertex stage applies the transforms and outputs verts in clip space for the rasterizer to process. That's that UnityObjectToWorld (whatever it's called) thing going on.

I have to bail though, I'm out of time for now. Work calls.....
Hang in there. It's all just learning curve.

swift yoke
sour grove
#

i cant find surface options on my material in urp

#

any one can help?

hollow mica
#

how do i use legacy shaders in hdrp? right now they are pink

#

what im trying to achieve is to disable the smoothness around edges of objects (fresnel), if there is another way of achieving this im open to suggestions

lyric sun
#

@meager pelican thanks for the help. I didn't realize hlsl doesnt allow single arguments that fill in all fields for the floats. That right there helped me fix my issue and get the code working

kind juniper
amber saffron
hollow mica
amber saffron
hollow mica
#

i want this to be completely flat

amber saffron
#

Looks like some sky reflection, maybe you should add a local reflection probe ?

kind juniper
#

Or do you mean the ripples/waves?

hollow mica
#

thats actually true, i have a probe that ends right before this, and the floor looks fine there

hollow mica
kind juniper
hollow mica
#

i mean i want the ripples but i dont want them to have highlights on them

kind juniper
#

Well, that's what normal map does.

amber saffron
hollow mica
#

its def an impovment but still not perfect

#

do u know a good tutorial for the shader stuff u mentioned?

torpid hull
# hollow mica

Can you show me the shader you are using to produce this?

hollow mica
#

standard hdrp/lit

torpid hull
#

remove the normal map just to see if your getting highlights on the surface still, If you dont then it'll be the normal map that is creating the highlights.

#

Also do you have a texture in your base map? or just a flat colour?

#

Also have you tried unchecking receive SSR/SSGI - sorry I dont use HDRP only URP

amber saffron
#

The remaining fresnel effect is probably from the ambient diffuse lighting.
This can be fixed by baking lightmaps or using lightprobes

hollow mica
hollow mica
#

ive tried urp myself before and i think i was able to fix this issue there, its a bit harder in hdrp

#

lightprobes didnt rly fix it ๐Ÿ˜ฆ

#

thanks guys non the less

kind juniper
#

if you want kind of an old-style look you could bake the waves into the albedo texture

hollow mica
#

they can "cast shadows" as well, thats what i want

#

otherwise the floor just looks like plastic

kind juniper
#

that's one side of the same coin

#

You'll have to change how normal maps contribute to lighting in the shader if you want to change that. Imho.

torpid hull
hollow mica
#

probably just gonna look into custom shaders yea

sour grove
#

dlich u are my hero lol where u

kind juniper
#

If you just want to expose properties it should be pretty easy though.

sour grove
#

is it a hdrp thing only

#

its in a tutorial i was looking at but i dont have it there on mine

kind juniper
sour grove
#

he is using 2020 i am using 2021

#

in the video atleast

#

i put surface to transparent inside shadergraph

#

i just dont know if im missing out on something here

kind juniper
#

And the link to the tutorial please

sour grove
#

or they reintegrated it to shadergraph what have u

#

it says hdrp/material on his screenshot

#

so is it safe to assume urp doesnt handle it that way

#

materials dont come with a surface type and extended options im guessing

#

that is handled elsewhere in the Universal pipeline

kind juniper
#

Yeah, it wouldn't be weird if HDRP and URP had different material inspectors for shader graph.

slim steppe
#

Is there a way to disable the light on the foam?

torpid hull
slim steppe
#

@torpid hull Tell me if one or more are to bad

#

and sorry its kinda messy

torpid hull
slim steppe
#

xD

kind juniper
#

afaik surf is just a unity facade for vertex and fragment shaders. When it compiles, it puts everything in them. Assuming that surf is mostly relevant to fragment shader, the answer is once per fragment, which is usually a pixel on your screen.

faint tartan
#

Is there a way i can make a shader graph shader only effect objects on a certain layer?
(Its a projection shader)

brazen kernel
#

how can i assign a shader graph shader to a material? drag and dropping doesnt work and it doesnt appear in the shader dropdown

faint tartan
#

right click the shader and create a material

#

it will link it to the shader

digital gust
brazen kernel
digital gust
#

Can we see the shadergraph?

#

did you save it, does it have errors?

brazen kernel
brazen kernel
digital gust
#

Did you make a visual effect sahdergraph by accident?

brazen kernel
#

oh

digital gust
#

woopsy ๐Ÿ˜‰

brazen kernel
#

i didnt think that'd make a difference

#

im guessing its only for vfx graph?

digital gust
#

yeah you can use that on visual effects directly as shader, so your particles or meshes generated have that shader with fancy effects. Not be usable by a standard material ๐Ÿ™‚

brazen kernel
#

makes sense, thank you

faint tartan
#

Can you filter the depth buffer based on layers?

digital gust
faint tartan
#

Ahh that could work but then has the over head of extra rendering, basically I have a decal projection shader and I want to exclude certain objects from receiving projections, like if the player walks through a projection area I don't want the player to take on the projected texture

#

I know decals are coming to URP in version 2021.2 but it will be ages before the version is tested enough for me to feel comfortable moving my project too it so I'm making my own decal system

#

My system works but the decals project on anything with in the decal projection area

#

Iv never really used rendering layers in unity, but it seems like there should be a way to deal with it with them

digital gust
#

oh, custom system. okay. cant debug that with you ๐Ÿ˜„

languid zodiac
#

How to hide Tilling and Offset properties in the inspector in the Surface Shader?

faint tartan
#

Yeah trying to work out how to add that functionality to shader graph for me custom system

digital gust
#

How is your decal doing its thing? How do you project it

faint tartan
#

with the depth buffer to find pixels with in the box then project the image onto that

#

Im also in unity 2019 so using an older version of URP

digital gust
#

So you got the pixels from the mesh, any connection so you can check if the mesh of th epixel is on a specific layer?

faint tartan
#

This shader is a little over my head, the convention to projection space is a bit confusing

#

I'm pretty good with shaders but I gotta admit this tech is pretty confusing lol

#

For 25 bucks I can buy an asset that does what I need, but would be nice to work it out for myself

digital gust
#

If you are on crunch, buy it and investigate later, if not. go ahead ๐Ÿ˜„ I know that feeling ๐Ÿ˜„

faint tartan
#

Haha yeah I lose a lot of time to trying to make things I could buy

#

Still trying to get funding for this project so I can kinda waste time on playing with tech at this stage haha

dreamy pewter
#

hi guys any know how to achieve the multi focus like this in shaders i already managed to make one spotlight

teal breach
#

e.g. by doing RGB->HSV conversion of the scene color, and then choosing a pixel to be white or black based on UV coordinate, dither pattern and the Value of the converted color

dreamy pewter
#

here my shader and his c# script if any one interested

#

the problem is i want to create multiple spots (mask circles) like spotlights but i dont know if there is a way to communicate between shaders

brazen kernel
#

is there a way i can expose gradients in shader graph?

regal stag
regal stag
#

Or colour properties and lerp. e.g. for a 3-way gradient could use something like this :

languid zodiac
grim sage
#

Hello everyone, I'm having an Issue with my shader that used to work fine, but for no apparent reason, it doesn't want to make the shader work anymore.

The Issue comes from the subgraph using a custom function taking the Main Light parameters:

#

so far, no issues in the subgraph itself, but when I use it in a master shader, it doesn't work:

#

Unity version is 2020.3.19f

#

it should give me this result I usually had:

#

the script in the subgraph is the one showed in the unity Official blog:

#if SHADERGRAPH_PREVIEW
Direction = half3(0.5, 0.5, 0);
Color = 1;
DistanceAtten = 1;
ShadowAtten = 1;
#else
#if SHADOWS_SCREEN
half4 clipPos = TransformWorldToHClip(WorldPos);
half4 shadowCoord = ComputeScreenPos(clipPos);
#else
half4 shadowCoord = TransformWorldToShadowCoord(WorldPos);
#endif
Light mainLight = GetMainLight(shadowCoord);
Direction = mainLight.direction;
Color = mainLight.color;
DistanceAtten = mainLight.distanceAttenuation;
ShadowAtten = mainLight.shadowAttenuation;
#endif

#

I've been looking for a way to fix it for 2 weeks already and I wonder if onyone have an idea of where to start ? as I'm certainly attacking the problem from the wrong side

vast flume
#

not sure which channel to ask this in but how do i save these as files to send to someone?

regal stag
grim sage
regal stag
grim sage
#

You can also "Export Package"

#

wich will grab everything linked to the material (shader, texture, etc) and put it in one single package

thin girder
#

How to stop my materials being that shiny as on the screen? Happens when I try to increase normal mpap

astral turret
#

been working on a 2d game, using sprites and possibly a bit of mesh dynamics... is it diffcult to try and do an effect such as 'blending' colors on a particular sorting level, but otherwise treating over/under layers normally for overlap and alpha?

#

(or if not by sorting level, some other tag or per-class identification)

#

(might be well in over my head at trying to do this, heh)

brazen kernel
#

is there an option on vfx graph to destroy the emitter after particles are done rendering, like on the shuriken system?

jade depot
#

I'm having issues with when I shine a light on a model. When the light shines directly on the model it shows the texture with no UV mapping

slim steppe
#

Whats the best way to create water reflections in urp without any assets? @regal stag

#

Are there any options like moving a dynamic reflection probe to the right position?

slim steppe
#

Do i need any manager objects or extra shaders?

regal stag
# slim steppe How does it work?

iirc the component is attached to the camera, and uses the forward renderer assigned to index 1 on the URP asset. It generates a texture, _PlanarReflectionTexture which can be globally referenced by any shader. Sample with screen coordinates.

slim steppe
#

thanks

#

@regal stag i've got another small problem can you help me?

regal stag
#

You should just post the question. There's others that may be able to help too

slim steppe
#

oh ok so

#

Why is the shader only working in the scene view?

regal stag
#

I would assume the effect relies on the Depth Texture, make sure it's enabled on the URP Asset (might also have multiple for each quality setting)

slim steppe
#

It worked๐Ÿ‘

steady lintel
#

Do Roystan materials work in URP or HDRP?

#

Specifically the toon shader that roystan made

#

I know that it is incompatible with URP, or it at least bugs out and doesnโ€™t render properly, but what about HDRP?

#

If not, is there a way to get them to work using a pipeline other than the built-in one?

swift yoke
#
v2f vert (appdata v)
{
  v2f o;
  v.vertex.x += unity_DeltaTime.x * 5;
}

what's wrong with that?

feral kraken
#

is deltaTime not the time the last frame took? so it will barely jitter at all each frame

swift yoke
#

so that should be moving at 5 units per second I think, yet instead it's moving once and then never again

feral kraken
#

this happens while in play mode?

swift yoke
#

sure does

swift yoke
#

yeah I'm at a total loss, idk why that simple thing isn't working

inland ridge
swift yoke
inland ridge
#

if you use _Time instead of unity_DeltaTime I would expect you would get something like what you want.

swift yoke
#

yeah

#

think I'm gunna just make a compute shader or something

zenith heron
#

whats with the new unity logo ouch

tame topaz
dull silo
#

I have this button. It's ninesliced so I can make it as wide as I want with a single sprite.

#

However, I want it to have a gradient that fades to transparent on the end.
Kinda like this (mockup)

#

But because it's ninesliced, if I just multiply the alpha by 1-uv.x in the fragment shader, this happens

#

Is there some sort of way to get the normalized coordinates inside the full rectangle or something like that?

#

Or alternatively, is it possible to rasterize part of the UI hierarchy to a texture, then draw that texture with a custom material?

#

(if that even is advisable for common UI elements)

EDIT gave up and instead the gradient is just in the body of the button and the ends are solid opaque and transparent

vast flume
digital gust
worn osprey
#

Hey! I'm drawing decals using command buffers. Is there a shortcut to integrating lightmap data (even lightprobes would work) or am I gonna have to go the extremely wordy route with LightProbes.CalculateInterpolatedLightAndOcclusionProbes and writing a shader to read the spherical harmonics?

grand jolt
#

Hello, I want to have a functionnal xray feature for my game so I'm using an Overlay camera to draw some objects on top of everything however I realised that when I use a Transparent material, even if the object is not in the culling mask of the camera it renders on top of everything like my other objects, I don't know what is the probleme everything was fine until I recently opened it up here are some pictures :

fallen portal
#

Hey guys, I have an issue where the scene view is different from the game view.

Bloom post processing on the game view, as seen on the water, are way more intense in scene view. I've confirmed that changing the bloom intensity changes both game view and scene view, but on a different intensity for both somehow.

Running unity 2019.4, would really appreciate if there's anyone who knows something about this.

EDIT: Found out that HDR option in the renderer pipeline needed to be checked for this to be more accurate, now it works.

torpid sapphire
#

Anyone have any script example of OnProcessShader where they strip shaders that do not belong to a specific shader variant collection or any list of desired shaders ? I'd be really grateful. Thank you

swift loom
#

So I've got a texture with an empty pixel in the bottom left and I'm checking tempCol = tex2D(_MainTex, float2(0,0)); Is there any reason why tempCol.r == 0 returns false while tempCol.a == 0 returns true?? Is an empty transparent pixel not 0,0,0,0 ?

regal stag
swift loom
#

no it's set as point with clamp

regal stag
#

Well it may depend on how the texture was created then, but RGB colour may still be stored even if the pixel is fully transparent

swift loom
#

hmm no there shouldn't be any color information in it. it's simply saved from aseprite.

#

unless there's something i'm doing wrong here

mighty fox
#

Do sprites support shaders?

swift loom
#

yes

#

it's just a texture

mighty fox
#

Idk i am tried to use displacement shader for sprite and it havent changed at all

#

It seems like i can only change its colour

swift loom
#

well it depends what you're trying to use exactly. i dont know what specifically that is but you might have to write something yourself because a 3D shader might not work right for a 2D shader and it might not play well with combined with the Sprite-Default material on other objects in the scene either

mighty fox
#

๐Ÿ˜ฆ

#

Well

#

Is it good idea to use 3d shader in a 2d game?

swift loom
#

that's fine but it can be some work to get 3D stuff work correctly with 2D sprite rendering orders and such

kind juniper
kind juniper
swift loom
#

no theres nothing

kind juniper
#

Can you take a screenshot?

swift loom
kind juniper
#

Hmm

#

Are you sure that it's not 0 though?

swift loom
#

All I know is that this works when I remove tempCol.r

#
                        
                if(length(_MainTex_TexelSize.xy) != length(float2(1,1)) && tempCol.a == 0 && tempCol.r == 0)
                {```
kind juniper
#

Then why check it? Do you care for areas that are transparent but have colors in other channels?

#

Also, do you get the same result if sampling at .01 .01 or something similar?

swift loom
#

i want to check if the bottom left pixel is transparent so i can treat those objects as the normal object, while others might have a color dot to determine other behavior.

#

i've tried 0.5 and 1 but same result

#

i just dont understand why it's doing this

kind juniper
#

0.5 might be on your character and 1 is at the other corner.

swift loom
#

oh you meant the position

kind juniper
#

And corner/edge is what I'm worried about

#

yeah

kind juniper
swift loom
#

that didnt change anything but checking tempCol.r > 0 works, so it has to be returning something... but why

swift loom
#

well

#

if(length(_MainTex_TexelSize.xy) != length(float2(1,1)) && tempCol.a == 0 && tempCol.r < 0.11)

#

tempCol.r can be checked against < 0.11 and it works

#

but not 0.1

#

im gonna try overwriting the color values and reexport there's some spooky nonsense going on here

kind juniper
#

I was talking about sampling the texture at .01

swift loom
#

yes i tried that but it didn't do anything

kind juniper
#

tex2D(_MainTex, float2(.01, .01));

swift loom
#

yeah

kind juniper
#

Okay

#

then I've no clue

swift loom
#

yea โ˜น๏ธ

#

thanks tho

sly breach
#

how to use Graphics.DrawMesh for VR ? its rendering the same mesh twice with different offsets on one eye

brazen kernel
#

why do vfx graph particles pause when they go out of view? is there an option to disable this?

echo solstice
#

Hello

#

Will

#

My code public

#

If I use pastebin

#

?

low lichen
meager pelican
#

Don't ask me for more details though, as I've not done much of it, not having a VR device. But it will give you things to search for. Like "single pass stereo rendering".

sour mulch
#

So I'm trying to make a fairly basic unlit shader, and I keep getting the error "shader is not supported on this GPU", anyone have any idea what this is or how to solve it? I'm working on a relatively powerful computer so that shouldn't be the issue

#

this is in shaderLab (CG) btw

verbal condor
#

@tired canyon i didn't use a pipeline, i coded an image effect shader, first following this tutorial series
https://youtube.com/playlist?list=PL3POsQzaCw53iK_EhOYR39h1J9Lvg-m-g
then to try and get a transparent raymarching thing going, i looked around on shadertoy and found this
https://www.shadertoy.com/view/4sGfDD
i attempted to port that over to HLSL in unity, and you saw the effects of that here
#archived-works-in-progress message
i'm very new to the whole shader thing, and it's most likely not the best way to do some raymarching, but i got it close enough to what i'd like

tired canyon
#

What do you mean you didn't use a pipeline?

#

even if you did all the work in a shader

#

you had to pick between SRP/URP/HDRP

verbal condor
#

idk i didn't change any pipeline settings i right clicked -> image effect shader -> put that on the camera

tired canyon
#

ah ok then I'm pretty sure that means you're using the SRP

verbal condor
#

oh ok

#

the standard one

tired canyon
#

looks cool!

#

I was just curious cause I'm gonna be doing some ray marching in hdrp or urp

verbal condor
#

thanks

#

the turorial i linked is a nice one

meager pelican
sour mulch
meager pelican
# sour mulch https://pastebin.com/YwUzjK3M

I think that auto-generated note is relevant. It's excluded from DX11 because your v2f struct has members without semantics (like the viewdir, for example). See the comment in the code.

#

And texcoord1 may be in two places (I'd have to looke up the fog macro to be sure, but that (1) is texcoord1 I think.)

sour mulch
meager pelican
#

Yeah, it all looks a bit strange at first.

Any of the texcoords will work, just keep the numbers unique. It binds things to special registers in the GPU. Like a color or a vertex, or general purpose registers texcoordX. And these get bound to interpolators, so the values change during rasterization.

meager pelican
#

Sure! ๐Ÿ™‚

#

Don't let that texcoord semantic mess with your brain. It's just a general-use interpolator. I'm assuming your professor talked about interpolators.

#

Someone, in the way-back history of creating a programmable GPU stage language decide that "texcoord0...texcoordN" was a good idea. IDK why.

#

Probably due to texture coordinate reads (UV's). But meh. You can use them for anything. They're float4 registers.

#

If you want to stuff a float3 viewdir into them, fine.

#

You get N texcoords in the GPU. Depends on the GPU. Say 4 or 8 or 16 or 32 of them.

#

You can usually count on at least 8, IIRC.

#

texcoord0 to texcoord7, but maybe more. You'd have to check feature levels.

crude bolt
#

How do you clamp the brightness of a pixel?

kind juniper
#

clamp the color in the fragment shader before outputting it.

crude bolt
#

Any tips on how I would do that?

#

Cuz I'm not sure how to set the color of a pixel without it also just using the brightness of the default shader

kind juniper
paper pelican
#

Is it possible in the URP shader graph to hide a property from the inspector unless a condition is met? General idea was to show a RGB field if colour map wasn't set

crude bolt
#

@kind juniper not sure how I get how illuminated a pixel is

kind juniper
crude bolt
#

So then wouldnt I need a standard shader

#

And somehow overlay a fragment shader?

kind juniper
#

overlay?

crude bolt
#

Cuz I need to get the color of the pixel rendered which got rendered eith thr dtandard shader, and then get that color clamp it and redraw it

#

Cuz otherwise there is no brightness of a pixel to get right, cuz nothing has been rendered then

#

So I first need to do it all normally like a standard shader and then clamp the color that that pixel has been made

kind juniper
kind juniper
crude bolt
#

Tbh I just want a material where I can select the shadoe color, so what color dark spots on it are, and the normal color

#

And a threshhold slider

kind juniper
crude bolt
#

Yes I know

#

But the thing is

#

I first need a pixel to clamp right

#

How do I clamp a pixel when I haven't rendered it

#

Waitttt

#

I think I got it

#

Rlly shit at shaders but

kind juniper
#

That's what the shaders are for.๐Ÿคทโ€โ™‚๏ธ

crude bolt
#

Yes but then how do I get the brightness value of a pixel

#

With my shader

#

Wait

#

I think if I just take thid and when the attenuation is beloe a certain valur it returs another color

crude bolt
#

๐Ÿ‘

#

Thanks btw

#

Srry for sucking so miserably at understanding shaders lol

little glen
#

I need help. I check both in editor and in built to load assetbundle from url.

The only thing i noticed is that the one with standard specular setup is pink in app but ok in editor. Standard material seem no issue

Anyway to check why this happened? I assume shader stripping or something

little glen
#

Nvm, i just put in always include on build for now. I will debug later in future

hushed vigil
dry oasis
#

How do i do a fresnel effect on a unlit shader?

karmic hatch
# dry oasis How do i do a fresnel effect on a unlit shader?

I think fresnel does something along the lines of taking the dot of the surface normal and the view direction, and then if you do one minus that you have something that goes to white at the edges and black in the center, and then you can put that to a power or something to get the desired effect

dry oasis
#

Hmmm, ok. thank you!

grand jolt
barren sage
#

Why i can't see my Boxes When i drag a shader to them?

open thicket
#

hey guys , i wanted to use the ripple effect here : https://github.com/keijiro/RippleEffect
but its old and my unity 2d project is URP , when i disable the URP profile in the graphics sittings it works when i re-assign the URP profile it does not work , any ideas for a fix ? or maybe how can i upgrade an old shader ?

GitHub

Water surface ripple effect for Unity. Contribute to keijiro/RippleEffect development by creating an account on GitHub.

kind juniper
# open thicket hey guys , i wanted to use the ripple effect here : https://github.com/keijiro/R...

You'll need to rewrite the shader to work with URP. I'm not a great expert but a few things that I know is that you need to replace CGINCLUDE and ENDCG with HLSLINCLUDE and ENDHLSL and remove #include "UnityCG.cginc". Then you'll probably get a bunch of additional errors that you'll need to fix. Mostly converting CG stuff to HLSL and replacing macros and functions from UnityCG.cginc with something else.

Then you'll also need to make some changes to the c# script. Specifically, OnRenderImage is not a thing in URP. You'll need to replace it with a custom renderer feature, which I don't know much about.

#

It might be easier to get a simple unlit URP shader template and add the logic from the ripple effect shader imho.

#

Or even do it in shader graph

hushed cove
#

Does anyone know what an error d3d11: buffer size can not be zero in log means? It's posted every single time I enable a skinned character, and that character remains invisible instead of rendering properly, like it did on 2019.4.15 (I just upgraded to 2019.4.31)

solid geyser
#

Trying to fix lighting on double-sided flat objects. Unfortunately the objects no longer can be partially lit and instead fully light up after a threshold.
We were previously using the built in SpeedTree8 shader but it seems to render everything transparent now.
Any thoughts on how we could fix this? There are some things like fences/grass/props that need double sided transparency and normal lighting

#

Nevermind, the artist tried playing with HDRP and reverting on our main branch but there seems to still be files affected

#

How can I go about restoring the default state of those shaders and lighting?

sour grove
#
Compiling Fragment program with _ADDITIONAL_LIGHTS _ADDITIONAL_LIGHT_SHADOWS ```
#

getting this error on my shadergraph shader

#

any idea guys?

tribal locust
#

anyone have any ideas what's going on here?

something about this shader -- which I created using a visual shader creation asset -- is causing other shaders in the scene (UI elements) to not render at all.

if I remove the highlighted part and change it to v.vertex;, then the other shaders render fine (but of course, this shader loses some of its effects).

sinful veldt
rare charm
tribal locust
kind juniper
kind juniper
rare charm
kind juniper
rare charm
#

Sorry didn't see your comment, I'll try it out.

#

@kind juniper nope

#

no luck

kind juniper
#

How are you doing it?

rare charm
#

Maybe I can approach this a different way. Shaders are the kind of black magic I try to avoid. Is it possible to use this mesh as a mask for a sprite?

kind juniper
kind juniper
rare charm
#

The only reason I made that shader is bc a tutorial suggested I make sure all the normals are (0,0,-1). But if I use the URP/Standard Unlit it doesn't do anything different as far as the texture is concerned.

kind juniper
#

Well, if it works, then it works.๐Ÿคทโ€โ™‚๏ธ

rare charm
#

But it doesn't ๐Ÿ˜ฆ

kind juniper
rare charm
#

No, I just said it in a stupid way.

kind juniper
#

Okay, then yeah. You've gotta use world position for the uvs

rare charm
#

How would I go about that the correct way?

kind juniper
#

Ah, it's a position node. It has a dropdown to specify world position

#

Something like this

rare charm
#

woohoo finally

#

thank you so much

plain urchin
#

So this is what i said to my client wanting a armor part dye system
Not sure exactly where to ask this but shader people would definitely know some more approach/tricks about it

#

So as i mentioned before, using multi material and changing material property will break batching

  1. The only style that wont is either the using palette texture. Mesh' uv gets moved at runtime and so only a single material gets used.
    This can also use vert properties for other use like gloss/metallic/whatever and still all use single material

  2. Or the vertex color style, this can have more artistic freedom. The VC can have brightness and even saturation defined, and the "dye" will hue shift it. Artistically again, can even respect color triads etc. This is what i'm going for

Changing material property means each material can have actual textures, but for low poly generally textures aren't used
If u want textures with pictures, the picture can be separated, and also use one of the 2 techniques to change the picture's colors
Even better if the picture is atlas'd in a sprite sheet

#

And ofcourse asking for confirmation if my statement is even correct

kind juniper
#

@plain urchin If it's skinned mesh renderer, it doesn't get batched anyway.

#

So you can use individual materials and textures without worrying about that.

west eagle
#

gpu instancing with material property block won't break batching

kind juniper
#

It's still not gonna work on a skinned mesh renderer imho. You'll need to pass the bone deltas as material property blocks. And probably modify the unity batching system, because it just doesn't include skinned mesh renderers into batching afaik.

#

You could bake the animation into a texture and use that to animate the character on the gpu directly. Unity did it in one of their dots demos. But that's more complicated and probably not worth the effort in most cases.

plain urchin
kind juniper
plain urchin
#

Alright for my game i'll be using 1, and my game's a body part style (no skinned mesh, only rigid bound)
Should work right

#

Actually i know it works nvm

plain urchin
kind juniper
#

Using multiple materials would break batching, but if you use a texture atlas with all your textures in it + a material property block indicating the texture index/position, it should still batch. You'll need to write a custom shader that samples the right texture in the atlas though.

plain urchin
#

Yeah from here on it gets too specific for the game, what approach is best..
But what i get from this is, SMR doesnt batch anyways so yeah.. carry on

#

Actually still on the topic:
So what's the best approach when a armor part dye system is involved?
Given some common game styles
-I'm mainly interested in the common "palette texture, change material property" style like in the screenshot (it's from an asset). Or mmorpgs like GuildWars2
-Or for my game, since it's non SMR. Any other ways i can play around with "color" customization gameplay?

kind juniper
#

An atlas of pallets seems like a decent choice imho.

#

It will require mapping uvs in a certain way though. To prevent interpolation between colors over the whole atlas.

plain urchin
#

Well texture palette's uv is really crumpled in to a dot usually

#

(That's from the default model's uv. I hope u can see it..)

kind juniper
plain urchin
#

Gonna read their shader properly before commenting further in..

#

Am i allowed to break down an asset a bit here?

kind juniper
kind juniper
#

If it's a free asset, I think it's fine.

plain urchin
#

Well share code definitely i wont. But just talk about what's in/not in the shader etc

#

It's not free apparently

kind juniper
plain urchin
#

So anyways, they have 3 predefined colors (exact cyan, magenta, yellow) and compare with the palette's result from the uv
If it's exactly that color, then the Color1/2/3 property gets used, else use the palette (effectively means this part is un-customizeable)

#

But as far as i can tell, it doesn't make use of vertex color at all

#

Vertex Color is greyed out here, does this mean this mesh doesn't have a VC channel info in its mesh?