#archived-shaders
1 messages ยท Page 220 of 1
going to try that, and reinstalling URP, will report back
thanks
neither worked unfortunately
Is that the only shader that throws that error?
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
Ah right
like I would happily just delete the problematic shaders but I think it's a bigger issue
But the stuff in the editor is displayed properly?
And in the build?
the build does not reach a state where anything is rendered
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
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
I also just stumbled on that post but didn't even think that it's related xD
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
Of ram memory ! Sorry for late answer
How do you know that? Are you using the memory profiler?
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
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
can someone help me with this please, i dont know why my shader loooks different on game build
unity: https://i.ibb.co/x2b9D7L/Unity-vu011-JUr-Bw.png
build: https://i.ibb.co/hyHN0DC/Screenshot-2021-10-01-15-35-54-263-com-Default-Company-Chameleon-Ball.jpg
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
i still need help with this please
Are compute shaders available in webgl?
is it possible to make a projector shader that does occlusion?
ie: NOT this?
(without resorting to a shadow-enabled spotlight)
Hey guys, do you know why this could be happening? It only happens on WebGL but on Desktop it looks fine...
Heya, does anyone know how to change ZTest in URP shader graphs?
I assume you mean the "portal" swirl shader.
And you'd get more help if you specify
- the target platform you're building for, including things like the pipeline you're using and OpenGL vs DirectX or whatever.
- Publish the shader code to see if we spot something.
- android, URP, auto graphics API
- i saw it on this tutorial https://www.youtube.com/watch?v=w0znZIuvQ2I&t=247s
See "Depth Test" here in the docs: https://docs.unity3d.com/Packages/com.unity.shadergraph@13.0/manual/surface-options.html For a recent version of SG.
Thanks a lot, I'll take a look
Well, I wouldn't use HDR on android for one. The other thing I'd do is not use pink-ish colors for testing, so you can tell if it is an error color or your color. (Pink is an error color).
You could always try an alpha clip threshold too.
If it turns out to be an error, make sure the shader is included in the build (check build settings).
I'm guessing here.
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?
what is weird is that this works on oldest versions of unity
but i cant use them since i dont have version control
IDK.
But the option was added in SG 12.0 (11.0 is current). So you'd have to enable/install 12 somehow to get it. Sorry I missed that.
Sorry @sinful veldtmeant that for @steep stirrup
^^^
Aah right, thanks!
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
Sprite?
Animated?
yeah player sprite
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.
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
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. ๐
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
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.
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 ๐
Others may comment. ๐
I'm not very sprite-aware. ๐
@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
Project Settings->Graphics, IIRC.
i tried to put my shader there but it says it has too many variants and wont let me build my game
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...
doesnt anyone know how to fix it? :/
any idea why this is still just displaying purple?
purple == some mistake in your code
but what
uff you need to wait to someone who knows shader graph :/
Are you using a built-in render pipeline perhaps?๐ค
I'm using URP
@kind juniper
But is it configured properly? Take a screenshot of your graphics settings.
Can't rn
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
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.
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
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
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
Edge detection is different. ๐ You asked about convoluting neighboring pixels.
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
The computer has to make a decision.
The easiest one is the one you mention.
If "value" is the color, you can use either:
float result = (value > 0.5) ? 0 : 1;
or a step node.
https://docs.unity3d.com/Packages/com.unity.shadergraph@6.9/manual/Step-Node.html
I wouldn't be surprised if they compile down to the same thing.
lol, posting at same time.
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
Yeah, two different things.
for the speed, that's a scale.
For the "steps" that's quantization....division, basically.
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
0 and 1 are only two quanta, though.
What do you want for a result if you have 4 steps?
ye
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
Try (value * speed) / steps.
Might want (steps + 1) or something.
sounds good, this can be done with math nodes right?
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.
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?
Yes, but once you alter it you keep going in text mode from there on.
the point of no return
"no going back"
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
You can try gradient
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
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
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
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.
like a toon gradient.....
https://medium.com/@smokelore/shader-programming-volume-5-5ed68e464b9d
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
Yeah, the gradient node in SH works with math, IIRC.
But there's a cheat.
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?
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.
this is really throwing me off, how the first node doesnt let me connect to others except the simple gradient one
As for "speed" that's a different input into it all. You'd multiply the sample point (t) by the scale/speed you want.
its inevitable that i dive into shader programming it seems
If I understand you.
Well if it is a function of time, that might be what you want to do is scale the time value.
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
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?
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
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....
Explains how shader code (ShaderLab & HLSL) is written to support the Universal RP
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?
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.
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
ok, basically use the gradient object as a way to control the "progress of the fade"?
then just quantize those
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
yeah, value t affecting the gradient object right? from all 0 at 0, to all 1 at 1.
So it's just one sample
.5 beIng at the middle if it was linear
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
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.
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?
Crap. I've seen shaders with 20 texture samples going into it.
or is it more like the results from the gradient cheat will be inputted into the shader as a texture?
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.
where can i look up the "gradient cheat" from c#
so wouldit be on another script or inside the shader script?
No, C#
Game object
Have u used the gradient editor in C#?
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
Yeah.
so is there something built in so i can skip writing it?
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.
oh so the cheat is to export that into a texture
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.
Yeah.
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.
i think i understand the math, just not how to make those values into a texture
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".
thanks again, i think ill experiment some so if im back with more questions ill atleast have started actually building the thing haha
Can someone help me?
"word"?
Not really word
In fragment part
I want to use that keyword. Like Texture2D = tex2D
How to use tex2Dlod?
Oh, it's just like tex2d, except it has an additional parameter for what LOD level you want to sample.
Level?
Is there a level?
https://developer.download.nvidia.com/cg/tex2Dlod.html
Yes, it's about mip-map level. That's the LOD part (level of detail).
NVIDIA Cg Toolkit Documentation for tex2Dlod
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.
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
You're still using the built-in rp. Look at your "scriptable render pipeline settings".
Have to remap materials in the model import settings.
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?
You could fo this with shadergraph and subgraphs
Ah, interesting. I am not really that interested in using shadergraph at the moment, but its cool to know that it is possible. Thanks
I mean you can write it by hand too ๐
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
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
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
I feel like an idiot but I can't find a way to do alpha in a URP shader graph?
I'm using the Unity provided custom lighting code (https://blog.unity.com/technology/custom-lighting-in-shader-graph-expanding-your-graphs-in-2019) in 2021.2b14 and I get a shader error when using it, I'll probably just re-roll the hlsl but figured if somebody has an idea of what else might be the cause it would save some time
What version of Unity are you using?
2021.1
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
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
glad I could help
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
Is writing shaders for URP similar to HDRP?
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
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 ?
Probably just zeroes. If you want something else encoded in it, you have to define that in the mesh.
thats what Im thinking we shall see
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?)
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.
Not sure if this belongs here but how do i change this?
what am i doing wrong the world position based shader in urp? its offset by a little bit
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
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?
never mind i forgot structs were a thing
Synonyms for this from Thesaurus.com, the worldโs leading online source for synonyms, antonyms, and more.
To restrict some objects and meshes to have same lightmap texture, the only way in unity is to define same tags in lightmap setting?
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?
Hey thanks for the reply. You are correct actually there is only one texture array per material but directly referencing it seemed like a step down in flexibility. These functions belong to a separate utilities file that I was hoping to make shader/material agnostic.
Anybody know how to generate a noise texture (or any texture) and then use it say as a texture i put in properties? thanks
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?
I've never done this before and I'm not expert but I think you have to do this in a script on the CPU
Hmmmmm ok thanks!
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
Scripts work as mentioned above.
Also, many image editors can generate noise. And shader graph has some built-in noise functions.
Well, if it helps you any...
I think of the name in the shader as a pointer already. It actually is, basically. The material's property is "pointing" at some textureArray in GPU memory as assigned in C#. So you could have 50 TextureArrays in your game, but one per property, as set on the property. The engine/GPU will make sure that texture is in memory before executing the shader.
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.
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.
Yeah I suppose going about things wouldn't be so bad (and is probably the standard way of doing it with shaders)
It just seemed odd to me that there is no equivalent of a sampler2D for a texture array
I figured that something like a sampler3d or smt would exist to fill in the gap
https://forum.unity.com/threads/render-object-behind-others-with-ztest-greater-but-ignore-self.429493/ hi guys I find this shader to make a x ray effect , but it will only work in transparent queue, is there any way I can make it work with geometry queue?
it will work with forward camera and geometry queue but i have to use defered camera
is it possible to have my camera render to a render texture and also the screen? without having to use multiple cameras
Maybe with CommandBuffers on the built-in RP.
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.
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
There is! (Check that link or the macros) but the syntax is different between HLSL and GLSL...hence those macros.
Probably, if your target platform supports MRT (Multiple render targets). Not all platforms do though.
hi guys, i've modified a simple HLSL outline shader, does anyone know why it work only with sprites but not with UI images ?
here's the shader code: https://pastebin.com/B7SLZ7hM
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
im totally newbie at HLSL shaders
You may wish to check the sampler settings in the doc - but note that the behaviour is not consistent for different hardware, e.g. some platforms don't support specifying sampling type in the shader. https://docs.unity3d.com/Manual/SL-SamplerStates.html
Also I couldn't see if you got a reply for this - but the Unity resource is way out of date, use Cyan's instead. https://github.com/Cyanilux/URP_ShaderGraphCustomLighting/tree/main/SubGraphs
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
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
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
is it off because you have an offset set in the uv node? Or did you already account for that?
This one has the same offset set on the uv node. If they're both off in the same way and by the same amount, I'd guess that's the culprit (and both work fine)
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
does it work better if you rotate first then translate?
trying that now lol -- so far results are no, generates this kind of effect:
and what did you get with the other setup?
that's rotating first then tiling:
what happens if you add your world space translation code between rotate and tiling/offset?
hm, rotating then adding delta position to the result just leads to more screwy rotation ๐ฆ
screenshot?
also, in this screenshot, is the goal to have the base of the little light source to be at the transform's origin?
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:
well its tiny because you lost the scaling that you had in tiling and offset, right?
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:
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?
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
it looks like the rotation node translates the uvs to the center position, rotates, then untranslates
somehow, I think I've found the magic configuration โจ
what worked?
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
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
need someone to rewrite a built in shader into a URP version that does the same thing
How much do you pay? ๐
how much would you charge?
Depends on the shader. Anywhere from $10 to $10000. Not that you should share job offers in this discord.๐
oh sorry
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.
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
You can try researching various forms of triplanar mapping
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
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
Did you try the invert color node?
that inverts the whole image
you can still split the rgba output and just take the channels you need
recombine them with the original
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
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.
I was going to but realockto suggested a gimp batch thing
Wait what, so gimp is another software, am I missing any plugin for unity of gimp? ๐
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
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
am I approaching this right
it's letting me add the textures but they don't apply in game still
Do you add them to the right output?
hm, how is the texture showing in scene/gameview?
Thats weird, it looks right to me.
wait hold on
So you added the right material to the object yes? Just a dumb question, but things can happen
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
is it working now? ๐
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
You can tell in the settings, what it should be
Graph settings top right
sorry I meant
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
!ban 284330108083372043 scam
SweetNES#4582 was banned
whoa
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
What is that image supposed to be?
Your keywords might be projector and decals
not sure what you mean with urp lit? In the shadergraph, you select the style of material, in the material you just select shader
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?
Is there a way to convert an atlased UV back into a normalized 0->1.0 UV without passing additional parameters to the shader?
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.
Usually the alpha block is added automatically when switching to transparent, but you should also be able to do it manually by hovering over the space below the last block, then right click -> Create Node (or press space bar)
@regal stag Thank you! That is a very unintuitive workflow.
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?
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?
This looks like it:
https://answers.unity.com/questions/187628/shader-get-object-position-or-distinct-value-per-o.html
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
thanks man
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
Scale the verts before you transform to clip space
I tried that, resulted in the position being altered
I should also mention it works fine when there's only 1 item
But breaks when there are multiple
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
does unity compute shaders not recognize vec3 or fract?
what is the alternative to them?
Vector/float4
what about fract
idek what that is
fract is used in glsl code which i thought unity compute buffers use
i need it for some 3d noise generation
have you tried frac()
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.
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?
1
?
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
so do i have to do it to each part of the float?
if i do that it says unexpected token '.'
what is p?
p is the input float3
then your floor method is taking multiple inputs
it should just be 1 float I think
again, might be different for shaders
im using a compute shader
https://docs.unity3d.com/ScriptReference/Mathf.Floor.html
the mathf.floor takes just a float
this is not my code but code im trying from shader toy
problem is it is glsl code and unity uses hlsl
Dot would return a float though.
how should that line be done properly?
What line is the error on? And what does it look like now?
the line wiht the code float3 s = floor(p + dot(p, float3(F3)))
it says number of arguments is incorrect for numeric-type constructor
One problem is what Pybounce mentioned. I thought you fixed it.
he's doing p + dot(blah)
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
You probably can't access float3 component on the same line as the declaration is.
You declare float3 s on that line
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
Whenever you do type variableName it's a declaration of a new variable.
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(....
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));
}```
Gotta convert types and function names to corresponding types and functions of HLSL.๐คทโโ๏ธ
i did but thats when i got the error stated above
all vecs are float3/4 and fract is frac
Gotta look up the differences between them and how to deal with it then.
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
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...
shader toy is written in glsl
What is this better way?
F3 is defined as a float (float1).
you're passing it to a float3 constructor. Oops.
you're trying to say
float3 s = float3(F3); basically, but with an expression. You need THREE values for a float3() constructor, you're missing two.
(comment for your original question)
okay yeah so more on this...
Looks like it all goes mental at 0.5. So if someone knows what v.vertex actually is in a vert shader it would be so helpful :')
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;```
Help me I can't change languages if I want to make a script
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.
yeah that's what I thought was going on rip, thanks though
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
@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
this?
You don't. legacy shaders for built-in renderer, HDRP shaders for HDRP
alright, well is there a way to get rid of fresnel? i like the post processing of hdrp so i dont wanna switch
The fresnel is part of PBR lighting, if you want to totally remove it, this involves making a custom lighting shader.
Isn't your issue related to how the object is lit ? Can you show a screenshot ?
Looks like some sky reflection, maybe you should add a local reflection probe ?
Or do you mean the ripples/waves?
thats actually true, i have a probe that ends right before this, and the floor looks fine there
yes
Isn't it just normal map?
i mean i want the ripples but i dont want them to have highlights on them
Well, that's what normal map does.
Probably a probe will fix it then ๐
its def an impovment but still not perfect
do u know a good tutorial for the shader stuff u mentioned?
Can you show me the shader you are using to produce this?
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
The remaining fresnel effect is probably from the ambient diffuse lighting.
This can be fixed by baking lightmaps or using lightprobes
gonna try lightprobes ๐
yea i have a base map, and when i disable normal map the effect goes away so, but i still want the normal map, none of those boxes do anything
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
But that's literally what normal maps do - they add detail to how the object is lit. If you don't want these ripples lit, then you don't want normals map.
if you want kind of an old-style look you could bake the waves into the albedo texture
they can "cast shadows" as well, thats what i want
otherwise the floor just looks like plastic
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.
totally agree. How else is the viewer going to knows its bumpy? You need the normal map to do this.
probably just gonna look into custom shaders yea
Well, if you want something like that for your shader you'll probably need to write a custom inspector.
If you just want to expose properties it should be pretty easy though.
is it a hdrp thing only
its in a tutorial i was looking at but i dont have it there on mine
share a screenshot of your material
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
And the link to the tutorial please
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
Yeah, it wouldn't be weird if HDRP and URP had different material inspectors for shader graph.
Is there a way to disable the light on the foam?
You would need to set your shader up so the foam is less reflective. Can you share a screenshot of your shadergraph?
yes
@torpid hull Tell me if one or more are to bad
and sorry its kinda messy
jesus weeps! give me an hour lol
xD
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.
Is there a way i can make a shader graph shader only effect objects on a certain layer?
(Its a projection shader)
how can i assign a shader graph shader to a material? drag and dropping doesnt work and it doesnt appear in the shader dropdown
And it should be in dropdown under ShaderGraphs/ if you did not rename it
doesnt work
also doesnt work
i did save it, it doesnt have any errors
Did you make a visual effect sahdergraph by accident?
oh
woopsy ๐
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 ๐
makes sense, thank you
Can you filter the depth buffer based on layers?
I guess you might have to have different cameras to get different depth buffers
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
well decals should be able to ignore layers anyway
oh, custom system. okay. cant debug that with you ๐
How to hide Tilling and Offset properties in the inspector in the Surface Shader?
Yeah trying to work out how to add that functionality to shader graph for me custom system
How is your decal doing its thing? How do you project it
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
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?
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
If you are on crunch, buy it and investigate later, if not. go ahead ๐ I know that feeling ๐
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
hi guys any know how to achieve the multi focus like this in shaders i already managed to make one spotlight
do the lighting normally and perform the dithering in screen space
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
im not using lighting i made a shader with texture mask and i used matrix to convert each pixel on screen to make a dithering pattern
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
is there a way i can expose gradients in shader graph?
Put the [NoScaleOffset] attribute in front of the property (in the shaderlab Properties block)
No, gradients cannot be exposed. You could use a texture & Sample Texture 2D instead though.
Or colour properties and lerp. e.g. for a 3-way gradient could use something like this :
Thanks a lot โฅ๏ธ
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
not sure which channel to ask this in but how do i save these as files to send to someone?
The code seems to be using "WorldPos" (on line 7), but the input is named "Position"
Alternatively, I've got some functions/subgraphs here : https://github.com/Cyanilux/URP_ShaderGraphCustomLighting
thank you, I'll give it a look !
They are already files with the .mat extension
You can also "Export Package"
wich will grab everything linked to the material (shader, texture, etc) and put it in one single package
How to stop my materials being that shiny as on the screen? Happens when I try to increase normal mpap
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)
is there an option on vfx graph to destroy the emitter after particles are done rendering, like on the shuriken system?
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
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?
I tend to use the planar reflections from the BoatAttack demo https://github.com/Verasl/BoatAttack/blob/master/Packages/com.verasl.water-system/Scripts/Rendering/PlanarReflections.cs
How does it work?
Do i need any manager objects or extra shaders?
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.
You should just post the question. There's others that may be able to help too
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)
Thanks! ill try to enable it
It worked๐
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?
v2f vert (appdata v)
{
v2f o;
v.vertex.x += unity_DeltaTime.x * 5;
}
what's wrong with that?
is deltaTime not the time the last frame took? so it will barely jitter at all each frame
it's, in C#, time since the last frame I think
so that should be moving at 5 units per second I think, yet instead it's moving once and then never again
this happens while in play mode?
sure does
yeah I'm at a total loss, idk why that simple thing isn't working
the appdata passed in to vert is re-initialized fresh every time the mesh is drawn. Changes you make to it affect the current draw, but they don't deform the mesh.
well that, is a massive shame, but thank you so goddamn much
if you use _Time instead of unity_DeltaTime I would expect you would get something like what you want.
whats with the new unity logo ouch
This isn't a shader question. #497866432277643275.
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
You could just make zhe 9 slice a mask and inside have your gradient just be a scaled rect
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?
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 :
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.
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
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 ?
If the wrap mode is set to Repeat and using bilinear filtering on the texture import settings, the colour may be mixing with pixels in the other corners of the texture
no it's set as point with clamp
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
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
Do sprites support shaders?
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
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
that's fine but it can be some work to get 3D stuff work correctly with 2D sprite rendering orders and such
When you inspect the texture asset in the inspector you can toggle viewing different color channels in the preview window. Check if the red channel is painted in the transparent areas.
If it relies on geometry it just wouldn't work as you expect, because you only have quads in 2d.
no theres nothing
Can you take a screenshot?
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)
{```
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?
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
0.5 might be on your character and 1 is at the other corner.
oh you meant the position
the uvs
that didnt change anything but checking tempCol.r > 0 works, so it has to be returning something... but why
What did you try?
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
I was talking about sampling the texture at .01
yes i tried that but it didn't do anything
tex2D(_MainTex, float2(.01, .01));
yeah
how to use Graphics.DrawMesh for VR ? its rendering the same mesh twice with different offsets on one eye
why do vfx graph particles pause when they go out of view? is there an option to disable this?
It should just work the same as non-VR. It will draw it it like a Renderer.
There's two different ways to do stereo rendering 1) Single-pass stereo if supported...this requires multiple render texture support on the target device...or 2) two pass stereo rendering where you get two draw calls for each object. Sounds like the one you're getting.
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".
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
@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
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
idk i didn't change any pipeline settings i right clicked -> image effect shader -> put that on the camera
ah ok then I'm pretty sure that means you're using the SRP
looks cool!
I was just curious cause I'm gonna be doing some ray marching in hdrp or urp
OK, builtin pipeline. So if you want to pastebin your shader, I'll/we'll take a look at it. I remember seeing that error before, and it's just syntax IIRC, but IDK what it was off hand. So we'd have to see the shader.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
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.)
Ok thank you, I'll look into that. I'm really new to shaders and not exactly sure what the semantics for v2f could be aside from the included ones, and a few that my professor told me about, any suggestions as to what semantics I could use for this issue?
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.
should viewdir be a texcoord?
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.
Thank you so much!
How do you clamp the brightness of a pixel?
clamp the color in the fragment shader before outputting it.
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
Obviously you'll need to write/modify a shader.
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
@kind juniper not sure how I get how illuminated a pixel is
The final color of the pixel is the output in fragment shader. a color is just float4 where values close to 0 represent darker color(and transparent) (0000 would be completely black transparent color, while 1111 would be opaque white)
overlay?
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
Well, if you use a custom shader, then the output of the shader **is **the color of the pixel.๐
If you want to mess with already rendered stuff it's more of a post processing thing, than shaders(although it might involve them as well).
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
Sounds like a custom shader to me.
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
you clamp it before it's rendered
That's what the shaders are for.๐คทโโ๏ธ
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
sounds like a plan
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
Nvm, i just put in always include on build for now. I will debug later in future
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
Hmmm, ok. thank you!
You can specify a custom editor in graph settings.
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 ?
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
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)
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?
Compiling Fragment program with _ADDITIONAL_LIGHTS _ADDITIONAL_LIGHT_SHADOWS ```
getting this error on my shadergraph shader
any idea guys?
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).
anyone knows why this happens, shader looks different if it's run as a first scene or as the second one https://streamable.com/bsg1qt
Anyone have thoughts on this? #๐ปโunity-talk message
added some more details here: https://stackoverflow.com/questions/69502738/why-is-my-shaders-call-to-unityobjecttoclippos-causing-my-other-shaders-to
You still stuck with that? Want me to have a look at the 2021 project?
Use world position for uvs.
Probably not really related to shaders, but share your skinned mesh renderer inspector screenshot.
Anyone know why this texture doesn't seem to apply correctly? https://cdn.discordapp.com/attachments/497872424281440267/896183451357683762/unknown.png
As I mentioned, you'd probably need to use world position for the uvs. Or set uvs when you generate your mesh(which probably isn't gonna work the way you expect).
How are you doing it?
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?
Hmmm... Possible via a custom shader.๐
you will also likely need to multiply it by some scale variable
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.
Well, if it works, then it works.๐คทโโ๏ธ
Didn't you say it works with the standard lit shader?
No, I just said it in a stupid way.
Okay, then yeah. You've gotta use world position for the uvs
How would I go about that the correct way?
Not sure but there should be world position node. You just use it's x and y and multiply by some exposed property float scale(can call it whatever you want).
Ah, it's a position node. It has a dropdown to specify world position
Something like this
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
-
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 -
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
@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.
gpu instancing with material property block won't break batching
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.
There's an asset for that (haven't tried it tho)
I don't doubt. But are you using it in your project?
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
Not for this client no
If you don't use skinned meshes, then dynamic batching or gpu instancing should work. Do note that dynamic batching has a limitation based on the vertex count, while gpu instancing only batches the same meshes.
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.
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?
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.
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..)
Yeah, that's what i mean.
Gonna read their shader properly before commenting further in..
Am i allowed to break down an asset a bit here?
Not all UVS have to be at the same point though. You can have different islands point to different colors in the pallet.
Break down? You mean, share it's code and stuff?
If it's a free asset, I think it's fine.
Well share code definitely i wont. But just talk about what's in/not in the shader etc
It's not free apparently
You can definitely. As long as you don't share the whole source code.
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?