#archived-shaders
1 messages ยท Page 131 of 1
@willow pike you are building these meshes right?
how can i ignore that
Yeah I do but I'm really hoping to not have to edit the UVs constantly. Building the entire game's terrain out using Probuilder on even grid increments.
best bet is to either control the UV's or build a tri ridge with the tools, give them a diff material, etc
sorry for dividing, could somebody help me
i want to use the alpha channel but also want to be models look like will be upper one, when the Alpha is 1
Sweet thanks @rustic dragon hopefully I can get this working using your graph
@willow pike I don't know if my graph will help though with the different heights, but hopefully it gives you some ideas
Hmm yeah I'm almost wondering if it will be easier in the end to use a separate mesh of grass to hang over the edges
This would save me a lot of time building out the maps though
@willow pike yeah, a cap would be pretty easy, or just a tri ridge/edge loop, etc
The thing is the shader slightly changes the surface color of the grass so the player can easily distinguish when cliffs are above them in top-down view
there might be some edge finding math that would work, but it'd probably throw things along most edges :o, with the tools you are using, can you do a quick bevel?
@amber oxide what does alphatest do?
Yeah I can probably bevel the tops
see the grass surface changes color, so if I use a mesh to create the grass overhangs I'll need to use lots of custom colors for each different cliff height
Which is why having the edges masked would be super nifty ๐
are those colors always the same height?
@rustic dragon sorry what's alphatest?
@willow pike if those heights are always the same, for the diff colors, I have another idea
the screen shot means, when i add the alpha to #pragma, it shows models inside
I'm multiplying a very subtle gray over the surface based on the height of the objects
@amber oxide yeah, just wondering if you replaced 'alpha' in that line with 'alphatest', what would it look like
ah
@willow pike I think you might be able to project a mask from the side of that whole thing, dropping some grass edges with a tileable texture
@rustic dragon when i use alphatest, o.Alpha doesn't affect anything
That sounds perfect! No idea how to do that tho ๐
@amber oxide ok, you'll have to wait for a more experienced shader person, but it does look like your model is inverted, which is weird
@willow pike are those steppes always the same height?
The terrain height varies in units of 4 at a time
I probably won't stack more than 4-5 chunks vertically in any one scene
yeah, this might not work either, damn
I'd personally look into either adding a ridge along the top, like an edge loop, or managing the UV's so you can do more accurate shader stuff
Yeah that sounds the most effective way
thanks for helping me think through this, really appreciate it
no worries, send an update when you got it working ๐
Will do!
just to up(already post this on upper side),
i need to use the alpha channel(o.Alpha) but i want it look like upper one when the o.Alpha is 1
@faint notch sorry but what did you mean with after HSV I can't get it done. I can say I am noob on this. After colorspace conversion, R is dark, B is mid, G is highlight right? How can I smoothstep it 3x ? I don't understand that part.
@left pivot im on my way out, but as you see grabbing the blue will give you the values
aight So blue is dark?
@left pivot btw. do you need this only applied to one particular model? since you are new with shaders - there is an existing post fx you can use aswell, not sure if you are aware of that
@faint notch thing is I am using vertex colours. I need to do it in different manner.
I want ambient colours to get blended with my vertex colors at will.
It needs some amount of shader knowledge that I lack but I need it bad.
I have three colours from ambient. 1 is coming from light itself so it affects highlighted parts, 1 is for mid-tones and 1 for ground (bouncing lights).
Hi! Anyone who knows a good course / tutorial series on shaders which cover the basics but really explain why something is used? Most things I find are only explaining how to use something and not why. If it's even properly explained in the first place D:
@south topaz this is pretty good starting point
Hi. Any one got any good idea on how to aproach making realistic volumetric clouds in unity that are optimized and effecient?
possibly with raymarching or particle systems
in shaderlab how can i offset vertex positions by up world vector? rotation always seems try ruin my plan ๐ฉ ๐
@grand sun convert the position to world space, then add onto the Y axis
you can convert an object space vertex to world with unity_ObjectToWorld
correct
So I'm trying to make a Blur Shader that will Blur sprites placed behind it. Preferably through Shader Graph.
How can I do this?
is there a way to get the max number of uniforms allowed?
I made a shader following a tutorial but all I get is a pink texture, what did I do wrong? https://pastebin.com/LmtzZRs1
@tranquil bronze the tags seem to be it
@tranquil bronze I commented out and it worked
Hey, I'm trying to pass some simple structs between a Compute shader and C# using a AppendStructuredBuffer. When I try to copy the data out, and look at it, it seems to only contain the first value I appended to the buffer.
(this code looks pointless because it is, I'm just trying to get data going between the two before I do any real code)
https://hastebin.com/tomejebaso.cpp
https://hastebin.com/ihugahococ.cpp
The output of this is:
thanks @rustic dragon
not sure why though ๐ฎ
Hi all!
I'm writing a stencil shader to punch a hole in a mesh. It's working great except I'm still getting the real time shadow falling on the stencil area.
Any pointers to how I can resolve this?
I have a feeling I need to subtract the stencil from the depth pass or something...
Hey there. I am trying to multiply Shadows-Midtones-Highlights with defined colors. Am I doing it right? Can anyone walk me through it?
This is currently directly multiplying things but I don't feel it is right and I am in control ๐
what is going into that colorspace conversion?
RGB of Vertex Color
a color I imagine?
yeah
so you painted some vertex colors on the object?
yes, I want to affect colors by their tones. Highlights will be colored, mid-tones and shadows also.
or is that some lighting data you are retrieving?
well first thing is going from RGB to HSV and using those 3 channels is not what think it might be
Yeah feels like something is off
it just splits up the color input into Hue, Saturation and Value(brightness), so multiplying those by colors will not do much correctly
Right now it colors different parts but not really shadows or anything.
Am I after Value?
you will have to get the lighting pass somehow, are you doing that?
if it's just vert colors you are getting, that only reads what the vert color values are on the mesh, they don't change with lighting
no there is no lighting in this shader right now
it's a pbr master
Actually light color affects it automaticly right now
you see this?
yes, it uses B value of HSV conversion.
After that how can I decide which is Highlight, Mid or Shadow?
so you have that Calculate Lighting node?
nope. I have nothing about lighting.
yeah, you'd need that stuff first to isolate the areas on the visuals you want to change color or texture on, masks basically
how can i get that mask? I think it'll be 3 colored. White/Grey/Black
it's in that tutorial, you have to make a custom function node with some actual shader code to get the different parts of the lighting
let me try
cool
I re-read 3 times what you tried to achieve with the vertex color, but still don't get it
I don't know if it is just about vertex color though. I have a very basic vertex color shader. Combines RGB into color to albedo input, alpha to alpha in master node.
So you just want to do vertexColor * albedo ?
no I am using vertex colors as albedo color.
it just works in that way. I'll bake lighting data into vertex colors alpha in 3ds max.
with this I have shadowed parts
mid tones and highlights
How can I separate them and multiply it with color I don't know.
I tried sampling a sharp gradient
but after that I am stuck again because I cant get shadow parts or highlight separately. If I multiply it with any color it just colours everything.
Okay, I see now.
You'll need to mask the shadows / mid tones / highlights in the shader, tint them separately, and then re-combine everything
yes.
The HSV conversion node was a good start to get the overall intensity (the V part) of the color.
Next you need to work with it to have 3 masks
Basically, it could be :
- 0<v<1/3 => shadows
- 1/3<v<2/3 => mid tones
- 2/3<v<1 => highlights
That's right. How can I compare V value in that sense?
let me doodle some stuf ...
Thank you good sir.
Probably not the best way to do it and probably not accurate to "real" color correction but :
Thank you I'll try that now.
The different color inputs must be in HDR, and a mid-gray value corresponds to no change
Hello, I have a couple of questions:
- Can shader graph be used with standard render pipeline? I upgraded to LWRP in 2019.2.9f1 but my models are having weird artefacts in both the Scene and Game.. So I downgraded back to the standard render pipeline which doesn't have those issue. But the shaders I made following tutorials online have this warning dialog.
- How do we reduce the opacity of shadow? I want to make a the roof of a small house fade out when my player approaches it in a top down game.
Thank you for any help.
@amber saffron I did it it seems working with HDR colors but I need a better model to test it truly
Let me see
@tall chasm :
- Yes, shadergraph is for SRPs only.
- Semi transparent shadow is currently not supported in SRPs
@amber saffron
- Sorry, it's only for SRP? But I was able to use it fine in LWRP. Or did you meant to say its only for LWRP? Because the warning dialog appeared when I dropped back down to SRP.
- Ahh ok. In that case, how do I make my shadow less "blacker"/"darker"?
@amber saffron It works. It tints grey parts, dark parts or unpainted parts differently.
Thank you!
@tall chasm Sorry for the shortcut : SRP = LWRP / URP / HDRP as opposed to the built-in renderer
To have less dark shadows you need a sky that adds ambiant light to your scene.
Adding a sky in the lighting window an hitting "bake" to compute the global ambiant should be enough
@amber saffron No worries! I'm still new and unity is really overwhelming. I get it now. When I mentioned SRP I was referring to the build-in one, sorry about that.
Ok, I'll test that out.
I'm trying to make a simple outer glow for a globe. I made this shader and it looks fine in the preview, but when I put it on a default quad it's completely black. Is there a reason it would look fine in the preview, but not in the scene?
not sure what's wrong, but I can tell you that this graph shows the correct result on a quad in my project
so weird. i changed it to this and it works fine
It looks like unexposed variables don't use the default value in shadergraph, they use 0 instead.
really? damn
i just unexposed the variables in my new version and it appears you're correct
wowee
I think that's how Global shader properties are done though, so I guess you could set the global variables in a C# script using those references.
gotcha, thanks ๐
If they aren't going to change, probably easier to just use nodes rather than properties to define them though
yea, i just wanted to have names for them ๐
Could use groups to name the node in a way
Or what I do sometimes which is maybe bad practice
Use a subgraph with no inputs and 1 output
And then you can name it however you want
And then you could store the subgraph under a 'variables' section or something
But again maybe not the best use of them haha
Haha. I guess the generated shader might not be any different using subgraphs.
I always do the same with custom function nodes, so it has a name instead of just 'custom function'
I really prefer it that way
Yeah I usually just leave it as a Custom Function but I wish the name of the node just changed based on the function passed in
Yeah that would be nice indeed
I should definitely use sub graphs more often though
a single node group with it's name isn't horrible, if more of a space taker
Why would an AppendStructuredBuffer from a compute shader return the same value no matter what you do?
Specifically, the first one appended to it.
The shader: https://hatebin.com/nsdevguiur
Oh!
So. It had something to do with using multiple threads to do this?
I think I made the buffer size too small.
nevermind lol
Hello everyone! Sorry for interrupting, but I might require some help. I am currently trying to create 2d character creator where the modular playermodel will use the skeletal 2D animation. The thing is, I still don't know how I could possibly apply clothes on the model. I feel like adding another layer would make the sprites clip. Therefore, I feel like the only way is through shaders. Would it be effective to have for example a shirt texture that would then overlay the sprite of the torso ?
Anyone know how I can control the shadows of this cloud shape I'm casting onto my terrain? I want it to be significantly lighter but keep the intensity for other shadows (trees, cliffs etc). It's just a plane with a texture on it. People have recommended using cookies or the projector but neither are supported in URP.
Random idea, though I'm not an expert so there's probably many different ways around it to achieve what you want.You could go all the way and try to work with different shaders for elements, such that they write different stencil values (for example, Trees would write a 1, Cliffs would draw a 2, etc), and then try to substitute your current method of using a plane for using a Post-Processing Effect that checks the stencil and depth and projects the thing onto it.
But again, I am not an expert in this, so there is most likely a much more elegant solution to your case.
Right yeah that makes sense. Hmm. Iโve had a lot of problems using depth in my game since itโs orthographic. Iโve gotten it to work on water foam surfaces but it seems to break when I use it on more than one object or anything at a different vertical height.
I love having access to shader graph but it really sucks how many features arenโt supported in the URP
I feel you. I tried to get into ShaderGraph last week, and I said to myself "I'll try to follow one of those tutorials on how to make Breath of the Wild cell-shading with rim lighting and Shadow Attenuation!" but then I discovered that all of those are only for the LWRP...
Shadergraph has a lot of potential, but right now custom lighting and other very specific features are only a thing of people with very high skill.
@willow pike I think ambient occlusion should help with showing depth. If anything, the shadows make the scene more confusing.
Maybe if the shadow is moving across, it would show the geometry of the scene better.
Well they definitely do make it more confusing right now. At low opacity they should give the look I'm going for. Something to break up the geometry.
Post-processing could be a way of balancing the color/light balance in your game as well.
They will be scrolling across like slowly moving clouds
Hmmm... Doesn't the plane have options to manage the shadow strength?
Ambient occlusion will differentiate between inward corners and outward corners.
I feel like the option should be there, on the renderer
No, the way shadows are done, there's no way to do that.
A shame...
Yeah definitely planning on adding some AO and more post processing. Currently have my post processing turned off.
Appreciate the help ya'll. Will see if I can find a solution.
i need help with adding transparency to my water shader, can you guys help?
@fading pumice Shader Graph or regular shader?
hang on
@low lichen shader graph
idk if this helps
@low lichen do you know how to do it?
im very new to shader graph
@fading pumice Have you tried looking it up? "shader graph transparent" or something like that
I haven't used Shader Graph much
yes and found nothing
There should be an option somewhere to choose between Opaque and Transparent
@fading pumice If you hover over the PBR Master node, you should see a gear icon. Click that and there you can switch from Opaque to Transparent
ok
I just looked up a shader graph tutorial and found that
it gave me these @low lichen
wait dosent matter im ok
@low lichen it didnt do it
i set it to transparent and changed the colour but it didnt work
Once you've set the Surface to Transparent you need to alter the Alpha input on the Master node. 0 = fully invisible, 1 = fully visible.
ok
If you want it based on your Colour properties, Split the property and take the A output.
I can't really tell what is going on in that image. Have you got two overlapping planes on those squares maybe?
@willow pike you could just have all the materials in your game accept a cloud texture to just multiply against everything, with world coordinates and some shift
@willow pike late the part I see ๐
Yeah that's a good idea. Of course now I'm stuck trying to get my post processing to work again.
I didn't realize til now but since upgrading to URP from LWRP none of my post processing effects are working
tried reinstalling and making sure it was enabled in pipeline settings and it all looks good
Were you using the Post Processing V2 stack?
Yeah I think it's not supported in URP. It has it's own post processing now. There's a "Volume" script which can be attached to objects
Oh man thank you, I never would have realized this
e.g.
You've saved me again @regal stag ๐
shader ninja
While I've got you, was wondering if you had any idea why using your Ortho camera solution for depth foam I've had difficulty getting the foam to show up on multiple pools of water? Basically different tiny pools at different vertical heights.
The foam disappears and flickers in different places. Ended up just making custom meshes for my foam for now.
Also unlike PPV2, you don't need an additional script on the camera, but you do need to enable the Post Processing option, which is also where Anti-aliasing options are.
One problem with this newer post processing is that it doesn't support custom effects like PPv2, although you can sort of create your own via a custom renderer.
I haven't really tested the foam thing that much, I was unaware there was an issue with multiple heights @willow pike
Yeah it could have been something I screwed up in my graphs. Since I'm using evenly incremented tileable objects to build my game, adding custom foam isn't really that big of a headache
just wasn't sure if you knew what would be causing that
@willow pike Hmm, I could be wrong but it seems to be working fine at multiple heights for me?
I'll have to enable it again and capture what's happening, I'm sure there's more to it
it only flickers when I move my character/camera
I'm moving the camera in the editor and it doesn't seem to flicker
In play mode too?
Yeah
Hmm idk haha ๐
My water is also semi transparent, not sure if that has something to do with it
had refraction and other effects on top
How are you doing refraction?
Honestly I'll have to look and get back to you. I have sort of a frankensteined shader graph made from a combo of yours and some of the water shaders Minions Art made on her Patreon page
Haha fair enough
I'm trying to learn a ton of stuff at once with this project and definitely just kinda throwing stuff together without knowing what I'm doing lol
Is there no way to use the debug layer with the new post processing volume?
Was a nifty way to get depth of field working nicely
Nothing wrong with throwing stuff together, it will help you learn
I didn't really use the PPv2 stack that much, I'm not sure what you mean by debug layer
It was an overlay effect you could use to see where different post processing effects would be rendered to the camera. Like a red overlay that would be more opaque where the blur was strongest on depth of field for example.
Oh cool, I haven't seen anything like that in the URP post processing
is it possible to use visual shader for water or something without lightweight RP? lightweight RP wont let me import some other packagages like Unity Particle package without ruining the material.
the splash particles are just transparent squares. so many times i had to config the particles to fit LW RP and honestly i wish i didnt have to use it. i just need to create some water
@viral pollen Shader Graph only supports LWRP/URP and HDRP. There are third party visual shader editors for the built-in render pipeline, like Shader Forge and Amplify.
sahder graph doesnt come standard right out of a fresh unity project right?
well if you start a project with LWRD/URP or HDRP it will, but if you don't, you'll have to go third party, Amplify Shader is your best bet
if i used standard shader (with built in default pipeline) exclusively for pc / mobile
what is the best way to speed up the build
my big project is compiling shader variant for more than 30 minutes
some them are just basic albedo only
some are using emission only
while some are specifically for PBR with albedo, normal, and metallic
i just wondering if anyone have tips for this, at least to reduce build time
im doing project that will be built on multiple project platform (since switching big project is a nightmare)
Yeah, I have long building times too, although I don't have that many different shaders in the project. Tried different suggestions found online, but in the end nothing helped...
Thankfully, I only need to build once in a while.
@little glen @kind juniper I've been using a combination of shader variant collection and Shader Stripper
https://github.com/SixWays/UnityShaderStripper
Using just shader variant collection didn't seem to work very effectively, but giving shader stripper the variant collection works
I used variant collection, but not the Shader Stripper. Will give it a try, thanks!
You can also setup blacklists in Shader Stripper. For example, I blacklist all post processing shaders for mobile, since I don't use it on mobile.
Any quick thoughts from a shader guru here on how to scale a non-uv (triplanar) texture from center and out, not edge.. Kind of?
As you can see in the above, by changing the size, the iimage gets off-set.
well you do have the offset, I imagine you want to always scale from the center of the bitmap?
Yes.
I actually demonstrated that to somebody a few days ago, let me find it
So I can quickly change size, without re-adjusting the offset.
Fantastic. You seem to be around to help a lot of people! Good man! ๐
heh, on break right now so there is time ๐
@proven sundial I love the look of that project
@proven sundial so this will probably have to be tweaked to work with triplanar, but I send a screen asap
the UV's for this one are just the mesh UV's on a plane as of now
in action
the graph
Nice, could you try to run me through the logic of that vector1, subtract 1, multiply .5, vector2 series of nodes?
@devout quarry Thanks. Here's a bonus shot for ya ๐ !
@proven sundial I will try, but to be honest, I am kind of a try it, log it and see if it works, then repeat ๐
but at first glance it does seem weird ๐ฎ
so basically that subtract 1 and them mult by .5 is for the offset
keeps it in the center
so I needed 'center' to be 0, then anything above that to be half
made that a V2 then offset the UV's after the scale, I added another offset just now on the bottom, which might be able to be worked into some other place, that I don't know
Tweak, save, test, tweak is my solution too, but I'm so glad came in here to ask. Would have been stuck in spagetti for days before trying your solution above. Not much of a math head to begin with..
I'll copy it as best I can and let you know how it goes!
cool, let me know how it goes
to help with logic I would use a tiling and offset node instead of multiply/add
personal preference ๐
and also, I believe you don't need to split/combine, but you can plug in vector4 into vector2 slot
and xy will be used automatically
and lastly the property is a vector1 so does not need to go in an extra vector1 node I think
all details though haha
yeah, there is probably a node for that ๐ฎ
@devout quarry you know I was just thinking about that v4 straight into a v2, nice
oh, a v1 can go directly into a v2 slot and the value will be in both x and y?
I believe this might be a simpler solution
Likely the same logic involved in @rustic dragon's version
Back in for a breather.. Notice the new posts.. God I love getting some help when I'm out of my comfort zone! Gonna try that real quick Cyan.
@devout quarry I don't think you can plug a Vector4 straight into a Vector2 node. It contains two vector 1 inputs and if connected will only take the x component of the Vector4 in both.
Unless you mean putting a Vector4 into the UV(2) input, which would work fine, but any nodes before then would be dealing with a Vector4 also.
I meant like in your graph
I think
like the vector4 input in subtract node
or doing like this
Okay, yeah
not a vector2 node but a (2) input in some node
hey im working on a shader, which at first didnt cast shadows, so i just added usepass vertexlit/shadowcaster. but is there a similar thing to let the object cast shadows on itself?
Add fullforwardshadows addshadow to your #pragma @storm cloud ?
https://docs.unity3d.com/Manual/SL-SurfaceShaders.html goto shadows and tesselation here for more info
alright ill check that out
the page gives the example "#pragma surface surfaceFunction lightModel [optionalparams]" but i dont have that, I only have #pragma vertex vert and #pragma fragment frag
@storm cloud This page might be of use : https://docs.unity3d.com/Manual/SL-VertexFragmentShaderExamples.html
It has a 'Receiving Shadows' example near the bottom for vert/frag shaders.
It might be easier to switch to a surface shader as linked above though, as they can deal with lighting and shadows for you. (assuming you are using the built-in pipeline)
yea i guess, but i made a cel shader and i used a unlit base for that
i guess i could try to do the same thing in a surface shader
@storm cloud I highly recommend just using a surface shader, @neat hamlet has a ton of them https://twitter.com/minionsart/status/886934392295350272?lang=en
Adding specular to the @unity3d Toon Shader! Code and Spec Ramp in first reply :) #gamedev #tutorial
More stuff > https://t.co/FqAsMb9Plg https://t.co/s20meX02UM
218
745
if you want to learn how to do it at a lower level, I have a tut that does it from scratch: https://roystan.net/articles/toon-shader.html
thanks! ive seen that second one before, ill try it out
Anyone very familiar with Grab Pass? I'm trying to create a reflection shader (for a water effect), and it mostly works, except for one issue: when the camera scrolls vertically, the contents of my reflection change. It doesn't happen when the camera scrolls horizontally, so I think it has something to do with my "flip Y uv coordinates" part of my shader.. thinking I might need to do some math involving the world Y position, but I don't have the slightest idea what math specifically. Here's how it looks:
Shader looks like this (built with Shadero, a typical node-based shader editor):
I upgraded a project to LWRP but my Terrain is still using the old shaders. How can I tell Unity to change the shader for my Terrain to the LWRP shader? (I have done the Upgrade Project Materials step.)
I may have figured it out by going into Terrain Settings and creating a new Shader. LWRP > Terrain > Lit
I downloaded a shader that'll allow double-sided materials, but sadly it doesn't let me disable reflection or speculars like other shaders
I am using custom lightning to be able to cast shadows in my Unlit Master node (shadergraph) which works fine. I'm trying to separate shadows into casting to other objects, and receiving shadows so i can control that on each Material - like you can for PBR and other URP/HDRP shaders. Does anyone have an idea how I could achieve this?
This trick does not work in URP unlit, https://forum.unity.com/threads/turn-off-receive-shadows-on-custom-pbr-graph-lwrp.657814/
Which makes sense since I'm adding my own shadows from my custom lightning hlsl function, guess i have to try and seperate the shadows on the hlsl custom source somehow
Figured it out
hi. i'm using the snoise from the unity mathematics lib
but somehow it repeats itself
is that supposed to be?
@devout quarry Yeah, all boolean keywords you want exposed must be suffixed, from docs: To expose a Boolean Keyword in the Material Inspector, its Reference name must include the _ON suffix https://docs.unity3d.com/Packages/com.unity.shadergraph@7.1/manual/Keywords.html
Hi, so i'm currently trying to add an SRP Shader to a character model, but the inspector comes up with the error that my material does not have a _MainTex property. I attempted to remediate it with the srp property as follows:
(I added a _MainTex property with a reference of _MainTex)
For some reason it still says i do not have a _MainTex property, does anyone know how i would be able to fix this?
Can you show a screenshot of the error?
yep
"Material does not have a _MainTex texture property. It is required for SpriteRenderer."
you aren't using _MainTex in the shader
drop it in and use it for albedo and opacity I imagine
that's indeed the issue
its not allowing me to connect the property to albedo for some reason
sample the texture
using the 'sample texture 2D' node
then connect the rgba (4) to albedo slot
ok cool, and then you said i have to connect it to opacity too?
pretty sure, not done a lot of sprite stuff
is there a node opacity is under?
it's the a channel of that texture sampler he had you add
oh that's right, you have to split
stuck in unreal mode :p
I'd do the vector4 output of sampler -> split
then do alpha to opacity
then use a 'combine' node or 'vector3' node
to combine x,y,z again into a vector3 to put in albedo
or you can put the vector4 output directly in the albedo slot and x,y,z will be used automatically
since albedo is (3)
it does expose the a
yes, you are horrible ๐
I feel shame ๐
so what do i connect the split to and the sample texture to?
just make the A channel from the Sample Texture 2D, go into the opacity
It's possible that the error occurs because the _MainTex property you created isn't set to be Exposed @shrewd wave
on the post i saw it told me not to add the exposure, I'll check that out
That said, I don't know whether shadergraph works with the Sprite Renderer in that version, it looks like a LWRP preview version?
I don't have the error anymore, but my character model is still a black box
shadergraph is working for unity 2d right now
You also seem to be using the Fresnel Effect node. It uses mesh normals so is unlikely to work with sprites.
so should i delete the fresnal node and use tint to alter that color?
what are you trying to do?
just trying to make a red glowing hue for the character model
like bloom?
yeah
Do you mean a glowing outline? Or tinting the entire sprite colour?
yeah glowing outline
I imagine cranking up the emissive and post processing the heck out of it, but you'd need some control over what part of the sprite you want to 'glow'
I already have a tinting feature
my original plan was to create a still image animated effect for the player model (chowder effect), and the pipeline is as follows:
would this still be plausible with unity 2d?
I'm not too familiar with sprite rendering / 2D, but I can't think of any reason why that wouldn't work
ok i guess ill try it
id imagine ill still have to have the _MainTex property so ill keep that
yeah there were no external errors but it still appeared as a black box
can you show it?
sorry, I mean the graph
material for that sprite?
it does have one error I found in the shader saying that the "output value for 'shadowvortex' is not completely initialized
is that related to that material?
I'd either put a brighter texture into that slot, or for test just put a color into the albedo
@shrewd wave You're trying to put that stars texture over your sprite right?
yes
I believe you will need another texture property in order to achieve that. The SpriteRenderer will fill the _MainTex property with the sprite's texture
You can name it whatever you want, it's not too important unless you want to set it via a C# script
make your own for that, the name shouldn't matter here, except if you want to acces it
oh, I should look up before submitting ๐
ok so i deleted the _MainTex and instead created a new texture2d and added that property to the sample texture node
I think you need _MainTex, the idea is you add another texture 2D sample and overlay them
you have 2
This should help clear things up
yeah, I was just capturing that, you are quick
and then that all goes to albedo correct?
or emissive, whatever you want
Yeah, you'll also need to Split it to obtain the Alpha component
Well, or use the A output on the sample texture node
yeah, the one that contains the alpha, which is _MainTex
The multiply actually might want to use the A output on the top one too, so that the sprite colour isn't used. Depends on what effect you're trying to produce.
you don't need that split into the alpha
just go from A to opacity
sorry, A to Alpha ๐
so split A to Alpha?
just do this
Was about to do the same thing, now who's quick ๐
oh so do you not need the split
who is the Usain Bolt of screen captures ๐
Hey, I'm not entirely sure this is something I can do, but I'm struggling finding an answer.
Essentially, I instantiate an object that acts as a mask, but I want the mask to fade over time. I haven't been able to figure out how to go about doing this. Been slamming my head trying to think of ways haha. Would I need to write a custom shader since the Sprite Mask component doesn't seem to have the option to fade.
Here's a visual representation of what I'm trying to do.
You only need the Split if you are going from a Vector4 (pink line) to a Vector1 (blue line). @shrewd wave
@languid stream why do they need to be separate gameobjects/sprites?
@languid stream you could do the layer mask in a shader on the same sprite for sure
@languid stream and fade that mask like you want via script
Okay, so i just added sample texture a to the alpha
I do still have the error that the output of the shadowpass vortex is not completely initialized
might be something else? like not related
Not really sure what that is, it's likely a bug since you are using a preview version
just to make sure, lwrp's preview package is compatible with unity 2d?
Here's where I'm trying to implement it. Currently the dots just get disabled after X amount of time, but I'd want them to fade first before for a nicer feel.
I wouldn't know how to fade the mask since the Sprite Mask component doesn't have any methods or properties related to alpha.
because thats what ive been using
@languid stream ah nice effect, how is that setup?
It's essentially an object pooler of these mask dots and two tile maps with different color tiles. The green tilemap is visible inside the dot mask that gets enabled and placed on mouse point. But the mask fade would make it look so much better 
@shrewd wave I'm not sure, the LWRP preview is quite outdated. I'm using the Universal RP (which is what LWRP was renamed to), in Unity 2019.3.0f1, it appears to have Sprite Lit/Unlit Master nodes so might be better, although they do say they are Experimental.
I tried to do something like an animated mask that would shrink, but wasn't able to do that either. So I figured I'd try to fade, thinking it'd be easier.
@regal stag do you think there may be something wrong with the actual image?
@shrewd wave Which image are you referring to?
the stars image
@languid stream not sure how you are doing that, so you have a separate 'mask' sprite and overlays the green fill?
@shrewd wave I don't see what problem there would be with it. You could try a different texture, but the graph should work. If it isn't working, you might need to look into updating your Unity & LWRP package version.
ok cool
if that doesnt work my last resort would me making some sort of sprite mask i guess
I downloaded a shader that'll allow double-sided materials, but sadly it doesn't let me disable reflection or speculars like other shaders
probably just make smoothness 0
anyone know how to make independent texture animation in a shader without amking a new material
what do you mean exactly @warped field with without making a new material?
I think 1. You modify the shader to animate the texture or 2. You leave the shader as it is, but apply the animation as a post processing effect
I need to learn how to read ๐
well I meant like a sprite animation where you have 1 character running and one idle sort of like Duke nukem 3d or Doom
but I'm also applying this rule to make vertex animations with a custom bake Vertex color map
then problem with sprite sheets is size limitsand I cannot put everything in sprite sheet not ever per monster
Bit of a late response but.. Your best bet would be to have sprites swapped out by code rather than to let a custom shader animate everything. Let's say you want 4 frames of a simple animation for when your character is looking forward and to the player. When you want to stop displaying a forward sprite, swap it all together with a new spritesheet texture that has the direction you want
@languid stream
It's essentially an object pooler of these mask dots and two tile maps with different color tiles. The green tilemap is visible inside the dot mask that gets enabled and placed on mouse point. But the mask fade would make it look so much better
So you have this pool of "dots" and you want to age them out. That's pretty much done on the C# side, IMO, as they're going to be separate objects. Just record their date-time as they're drawn and age them, and expire them out of the pool when they get too old.
I suppose you could have a custom shader that had a center and radius or something, or expanded the masked area to figure out the outlines.
if you want it to fade instead of "pop", then the age or the inverse is the transparency% of the max. Or whatever method you want to set the alpha.
The interesting thing was the outline covering all of them, around the outside.
:2c:
@languid stream I don't know how you're doing the masking, but usually a mask is binary, so you can't fade it.
If it's a custom shader on the tilemap, then you could lerp between two color schemes or textures using a mask texture
If you're relying on the stencil buffer for the masking, it's just not possible.
be brave and dither it!
It's not uncommon to see in this art style, so that's maybe not a bad idea.
yeah, some kind of cool alpha test pixel effect might work for sure
I just noticed now you mentioned you're using the Stencil Mask component, so then yes you are relying on the stencil buffer.
You can fade the BLENDING, just not the binary op of masking. IDK why you'd want to when you have an outline around the mask, but you could fade the colors.
In the example given, the "dots" were aged out over time. And an outline was drawn, presumably with the net results of the stenciling.
If he had a multi-bit mask, he could store the age in 16 levels, or something. I suppose, if he doesn't want overlap on transparencies. I'm not sure what he's really after.
is that some git or perforce thing?
I have no idea, could be, it always stays greyed out though, can't seem to activate it
yeah, like in unreal you have to purposely set up the perforce usage until those things are active
it seems that 'check out' is indeed version control related
wonder which one
yup that must be it then, thank you
but that is a great thing for the future, do you see that elsewhere on any other assets?
what version is that?
I'm on 7.1.6
is that a shader graph version? I don't recognize that
I usually wait for releases, but .3 looks interesting
7.1.7
is also there
but I haven't seen it released on my version
gonna check out 2020.1 alpha in a second to see if there is anything new
are those usually really crashy?
I've had a few crashes maybe, but nothing too bad really, my experience with the beta/alphas has always been positive
you just looking as a curiosity, or for some other use?
I initially checked out 2019.3 for the new UI design and now I can't go back ๐
And I usually check out latest versions specifically for new URP/shadergraph stuff
ah, UIElements good stuff?
I don't mean UIElements, I mean the editor redesign
oh, haha, yeah that ๐
Hey all, on Unlit Graph after NdotL my shadows are too dark when compared to PBR master. How can I degrade them a bit?
the shaded part of your object?
I'm not 100% sure what you mean
but with this
you can control the color of your shaded part as well as the smoothness of the transition
oh, let me see this.
Is smoothstep right thing here or my values are weird? @devout quarry
Use 0 for Edge1 and a value between 0 and 2 for Edge2
these values
give me this result
oh you went with it all the way ๐
I added a quick highlight yeah
thank you. It's not working on my vertex color shader yet but we'll see about that.
shadows are thanks to you though.
yeap, got it working now. @devout quarry thank you there mate.
lovely
also if you want see something neat
I applied some of this blinn-phong shading to a raymarched sphere
and it looks very similar to a real sphere
Nice work
thank you
@meager pelican @rustic dragon @low lichen
Thanks for the thoughts. I really do appreciate it. The outline is actually kind of interesting. The dot is in two parts, the mask and then the outline. The outline is visible outside of the mask so itโs more like a pseudo outline formed by all the dots together with only the border of the combination of the dots visible due to the mask.
Thinking about what Carpe said, the fade would look strange. This doesnโt seem to be a shader question anymore, but since you all understand the context, would there be anyway to possibly animate the mask via script? Like multiple mask components and enabling/disabling them over a period of time?
The idea just came to me while I was typing this up. Hah
You could try shrinking them
Iโd probably prefer the enabling/disabling (if possible) to retain the pixel grid rather than shrinking. But I can try just to see how it looks visually.
Hmmmm, I wanna get a bit in-depth on some on a particular case
Let's say that I have a deferred light shader (let's say a directional one for now that is drawn as a fullscreen quad, just like in vanilla unity)
Let's say that I can hypothetically calculate the light attenuations with dot(normal, lightDir) and the shadow attenuation so I effectively get an attenuation mask.
This allows me to use clip() early on the attenuation and early-out of the execution. Taking the modern PC/Console hardware in mind, this'll mean that if the entire tile will get clipped, then they all will early-exit and the work will be skipped.
However, I'm not too sure about this situation
Do you think that this is a good strategy considering that such a shader will be used for modern hardware and that there's no translucency/SSS involved? What are the benefits and the downsides?
I don't know enough about the impact of clip on modern hardware to give you an answer on that. But it seems like a very quick thing to test, once you have that light shader setup. It's not like you have to know this right now to structure your shader differently, right? It would just be one extra clip line.
Well, yeah, but I find it very difficult for me to test such things. I don't have a relatively low-end GPU to test it on and my current GPU is just too beefy to work with. When I profile one time I get one results and the next day, without any changes, they're all different. So until I'll get a more suitable GPU for such things the only thing I can do is to do what's supposedly the best for the hardware.
Strange thing is that I get such varying results on all kinds of profilers, NSight and PIX included. It's just a pain
I just created a new project for the lightweight render pipeline (with the example scenes), then added a new BPR shader graph and it stll tells me that the render pipeline is not compatible
Anyone knows a fix for this
Alright fixed it lol
@languid stream would there be anyway to possibly animate the mask via script? Like multiple mask components and enabling/disabling them over a period of time?
I'm not sure what exactly you mean by "multiple mask components" but if you read up on the stencil buffer that I think you're already using, you'll find you can have several bits for your use if you don't care about lighting. So after the lighting pass, you can have the camera clear the stencil buffer THEN draw your stuff. You could, for example, use different bits for different masks. If that helps. See Unity's doco. There's a bunch of options, read masks, write masks, incr, decr, compares, sets, etc.
@meager pelican Thanks for the explanation! I ended up using a script that would animate the mask for me since mechanim can't directly interact with the mask sprite. Here's the result. I think it looks better than the fade.
Itโs gonna be a rpg/real-time fighting/bullet hell/ MS paint combo with an upgrade tree haha. Iโm just getting the gameplay skeleton framed out right now though, so very early stages.
Iโm very unsure of its identity right now, so anything could change.
I havenโt posted up anything about this game in particular, but it should be in my profile.
if anybody has any idea about this, please tag me I can't solvei t
solve it
To reproduce: 1. Open the attached project; 2. Upgrade SRP packages to master branch; 3. Open "New Scene"; 4. Make sure GPU instanci...
I'm still having the issue, even without gpu instancing enabled..
Oh wow
The issue was caused by this
Apparently you can't name the reference _AlphaClip
Looks like the generated code uses that, so it gets confused with the same name. Glad you found the solution, Good to know.
good find
luckily the other ones don't seem like keywords I would use accidentally haha
Hi. is it worth recreating the entire terrain system your self for more control and less limitations,etc... and is the best aproach using shaders
its for a studio. i work at a studio
Im a 3d environment artist. unity limits us with a couple of features. just wanted to get some opinions
Ah; then maybe, yeah... Sorry, I failed to take the advice to check my assumptions. ๐ฆ If it's getting in the way, then it's a real possibility.
its fine.
Thanks for the reply though. I feel like it might be worth it so we could control terrain maps more,etc... for example personally i would prefer more detailed map options. not just detail,normal and color
The caveat is that replacing a fundamental piece means you can't use tools that are built to use that normal piece. Like things that are built to use Unity's nav mesh have trouble when you replace it with A* Pathfinding, or such. So there's a cost to replacing it, in that you have to adapt other tools that you might also be using. For most folks it's not worth it, but for a studio it might be.
And currently im having to use splatmaps which unity doesnt really handle so well at all. felt like maybe there is a better way of texture the world procedurally. but not sure if you can make shaders for the unity terrain with out actually making a terrain system of your own where you can control how shaders work. Im not a shader programmer so i dont know im just assuming. maybe there is a way to proceduraly texture with the unity terrain
well we do use navmesh. so it might not be worth it. AI is a big deal in our game
Ahhh... Texturing the terrain might be a very different answer... I think you should be able to procedurally generate a texture that applies to the terrain. Those parts are...separate enough, I think.
Depends on what you're doing. As I understand it, many just use meshes instead, bypassing the terrain stuff. Then you can customize each material/shader. It all depends, needs, tool-sets, etc.
No way you make it one single mesh! Oi! You break it up into reasonable chunks. Otherwise you'll hit mesh-size limits. And besides, you end up having to do frustum clipping on too much of one-big-mesh.
yet alone performance would suck if it was one mesh
no way for us to do occlusion culling
^^ I don't understand your first sentence.
Navmesh doesn't require terrain that I know of.
I use a grid of meshes, and dynamically have them too (as in also, besides the static ones) since environment is destructible. Rubble is dynamically dropped into meshes in a grid shape, for example.
It all depends.
I don't know what you're doing. If you, as you say, are having limitations with terrain, and that part of the engine doesn't do what you want, do it differently. You should be able to make meshes and shaders to do what you want, whatever that is.
@meager pelican it requires baking. but where are you going to place trees
unless we make a script to place trees
should be easy
then yea we dont really need a terrain at the end of the day
I don't think occlusion culling is dependent on terrain either.
@meager pelican it isnt. i really think your not understanding what i type xD.
Im saying that if we some how managed to use a huge mesh as terrain we wouldnt be able to oclusion cull parts of that mesh cause we would oclude the entire mesh then
but if we tile. then we would be able to
Oh, yeah. But I'm not suggesting that one-big-mesh thing anyway. ๐
So I made a pretty simple dissolve shader using shader graph. It looks great on a capsule mesh. I had however hoped to use it on my players for death / respawn animations - only I was under the assumption I could just throw it on the top level game object and it would cascade down. Unfortunately that isn't the case, and my player model is made up of a bunch of different game objects, mesh renderers, etc.
If I want to dissolve my entire player, would have to apply the material / shader to all of the separate meshes?
@dim river each mesh would need to have that material applied, yes
^^ Right. Because (@dim river ) a material IS a shader+Settings. So a dissolve effect would come from the shader that is bound to the material(s).
I'm making a level on a floating island, can you suggest me some tutorials on how I could make a cloud shader for cover the section below the land?
@silk sky probably some more clever ways, but a way I know of is to apply the 'fog' gradually on the models materials based on the height of the world
Dunno, fog seems kinda cheap and also too much dark for the level i'm making
I will surely use it when the player fall down but as aestethic piece a shader would be better
I've found a 40min tutorial so ill give it a shot ^^
@silk sky yeah, check those tutorials, what I was thinking of is
I have a unique problem with Unity Shader Graph Editor. I am trying to make a 2D sprite dissolve, but the problem is that for some reason, colors don't work
Like any time I add any color at all, it just becomes invisible
or well, anything the color touches
I make an outline for the dissolve but I gave it a color, no outline.
Multiplied the texture by the color to get a tint, no texture
@quick wigeon Is the alpha component of your colour set to 0?
No
It shows it in the small previews, but when it goes to the output, it gets funky
The default value of that Color property has an alpha value of 0, it's shown by the black bar below the green
Alpha refers to transparency. If you multiply by 0, it will output 0, and be fully transparent.
@regal stag knows what he's talking aboot
What Master node are you using? Is it the "Sprite Lit/Unlit" one?
yes
And your "Sprite" property, can you show the settings of that property
That looks fine
Ah wait. Check your Material, I think the alpha component of the colour is probably 0 again. When changing default values in shadergraph it doesn't update the values on the material that were previously created
Ok, should reiterate
the sprite shows up
but the dissolve doesn't
It shows in the preview, but not in the actual scene
Okay. Could you screenshot the material inspector values though?
First, here is to show the material and the game viewport
nevermind
fixed it
forgot to expose the texture property and save it
Ok, another problem
It works fine for still sprites, but when I play an animation, the dissolve just jumps around in a weird way
Hmm. I'm not too familiar with 2D animation.. But I assume it's jumping around because it uses the UVs to sample the texture to obtain the correct sprite to display.
If the noise you use to do the dissolving is based off fragment position rather than UVs though, it shouldn't jump around, hopefully.
Try sampling the noise like this
@quick wigeon
Or possibly with the Position in Object space, if you want the dissolve effect to scale with the sprite. You can also leave the Tiling and Offset set out if you want, it's just so you can adjust the tiling/scale, but I guess the noise node has a scale too.
The concept is it is one image with the sprite on it
and it cuts out parts of that image to animate it
Yeah, that was my assumption
So because your noise is sampled using the entire texture's UVs, and the animation jumps to each sprite, the noise is also jumping.
So do i use what you said first, or last
Use the Position node. It's probably better to just use Object space, but test both out and see which you prefer.
kk
Basically in Object space, the noise will follow, rotate and scale with the sprite object. While World space, it won't.
Both (should) work, it just depends what effect you want to create
It might only react to these 2D lights? Not sure how they work, I can't even seem to put them into the scene.
Ah, you need to be using the 2D Renderer apparently, and assign it under the URP Pipeline Asset.
I usually work in 3D and haven't had time to try this 2D stuff out. ๐
ah ok
I have a question specifically about compute shaders on mobile VS PC. My shaders work fine on PC but on mobile threads (somewhat randomly) fail to execute. Anyone ever seen an issue like that?
I can't find anything on google
This is the only model I have set up. I tried censoring it but I think I made it worse? || https://cdn.discordapp.com/attachments/371347717030412298/663513666984869899/Gif_505.gif || Dark blue is good, the main kernels ran. Black or bright blue means one kernel or another failed
It is very random. Changing the number or nature of dispatches seems to affect it, for better or worse. The mobile processor is not overloaded FYI. (And again, on desktop it's totally fine)
@vocal lantern // I don't think mobile devices even support compute shaders
Hey guys, I'm learning compute shaders at the moment, is their a good reference for hlsl?
thanks that is what I was looking for
@pale lantern they do. And the system worked fine before I added more complexity and dispatches
Oh, I was wrong. It is supported on some devices
How many dispatches? @vocal lantern
atm I think 9 or 10
Problems started (I think) when I tried going from 3 to 6
wait actually it's 18 to 20 atm
But atm if I run it at around... 12 dispatches, the thread failures are pretty minimal. It's pretty random
@grand jolt if you're making compute shaders for unity this is quite a good tutorial and source code https://www.reddit.com/r/Unity3D/comments/7ppldz/physics_simulation_on_gpu_with_compute_shader_in/
gif of what we will do Introduction In this tutorial I'll explain how to use compute shader to perform...
I have a question about constant buffers.
In the shaders, you can use "CBUFFER_START"/"CBUFFER_END" to group shader variables together. However, how do I deal with alignment/padding when setting this data from C#? (ComputeBuffer.SetData).
Do I need to take the packing rules of each graphics API into account? (when using OpenGL I guess this becomes a uniform block with std140 layout?), or are there any utility functions that can help me do this in a better way?
Example:
in the shader I create a cbuffer consisting of a combination of fixed3/fixed4/etc. In c# I create a similar "struct", and upload the data through ComputeBuffer.SetData(...). How can I make sure this works on every graphics API?
how does compute shader work with a RW struct buffer ? I don't understand how i can acces an element of this buffer if the numthread is lower that the size of this buffer
SUPPORT THESE TUTORIALS https://www.patreon.com/cg_matter
MY WEBSITE https://www.cgmatter.com
In this fast blender tutorial I show you how to quickly and easily create procedural crystals with controls for color, shape, size, and surface properties (driven by materials).
Is this effect replicable with Unity PBR?
I've already made it in Blender, wanted if I can replicate the same nodes
@shadow magnet You have a SV_DispatchThreadID that should be what you need
@silk sky replicating that procedural, tessellated displaced mesh stuff would be difficult and really not needed for something like that, the surface quality itself I imagine you could get close though
Did anybody finish Part2 of TheArtOfCode's Mandelbrot Explorer? I am stuck at 8:09 where he writes a line that is supposed to make escape pixels black, but it's doing nothing for me, the color is still there.
https://youtu.be/zmWkhlocBRY?t=489
Worse, while the program is "working" with no errors most of the time, but every couple of minutes I get this error popping up:
Curl error 56: Receiving data failed with unitytls error code 1048578
It doesn't stop Unity but it makes me wonder if it's related.
Did anybody get it to work and could I ๐ your code for it?
Or better, if you got stuck also, how did you solve the problem?
Thank you
Twitter: @The_ArtOfCode
Facebook: https://www.facebook.com/groups/theartofcode/
Patreon: https://www.patreon.com/TheArtOfCode
Part 1:
https://youtu.be/kY7liQVPQSc
This is the second of two videos in which we will create a Mandelbrot fractal explorer. In this video we'll ad...
Hey @regal stag been following along the distorted force field of yours. My intersection doesn't work. Everything is same. Am I missing something?
@left pivot Have you got the 'Depth Texture' option enabled on the LWRP/URP Pipeline Asset?
Yes I did. I did the simple one first. It works same as yours. Distorted's intersection doesn't work.
Master node options are set too.
object's scale is 1 also.
What component is on the Split node on the Scale? It's a little hard to see from the image quality but it looks like an "A"?
Yeah
R I meant. yeah
It's a Vector3, so doesn't have an alpha component, so multiplying by 0 rather than the scale
It looks like the scale is off, possibly because I used a custom mesh with a different scale or something. Try putting 0.5 in the Multiply after the split.
oh, that did the trick. That scale thing is confusing though. Maybe I should provide a script that sends scale to shader to multiply with this value?
thank you though.
That might work better, and probably better for performance too, as the Scale output on the Object node isn't exactly cheap.
It does this behind the scenes.
length(float3(UNITY_MATRIX_M[0].y, UNITY_MATRIX_M[1].y, UNITY_MATRIX_M[2].y)),
length(float3(UNITY_MATRIX_M[0].z, UNITY_MATRIX_M[1].z, UNITY_MATRIX_M[2].z)));```
oh they build scale each time not feed it directly.
Yeah, using a property and sending it in would probably be better
Especially in this case where we don't even need all 3 axes, we just want the sphere radius
Yeah, maybe calculation's sake I should use a custom mesh also and feed a property into it.
And your blog is so good. Keep it coming please. I really enjoy them. Not to replicate it but trying to learn by it.
I used a custom sphere mesh, as Unity's default one isn't subdivided that much which is quite noticeable if the forcefield is quite big. More vertices is also better looking for the vertex offsetting later in the post.
No problem, happy to help ๐
why do i keep getting this error with custom functions
i copied and pasted from here https://pastebin.com/4P3WV4EY
it just decides when it wants to work for somereason
I could be mistaken, but I believe when using String mode you can't include the entire function (like the void FunctionName_float(parameters){}) in that box, only the actual Body of the function. If you use the File type instead, you can then point it to a source file which then needs the entire function.
@tranquil bronze
thanks
How do I make a material that transitions from one to the other with a slider or number
@quick wigeon Use a Lerp node. It interpolates between two values using a third variable between 0 and 1.
Oh thanks
You won't really be able to transition between two entirely different materials, but you could combine both into one shader, and use a Lerp to pick which one to display.
I also have a material that transitions the alpha of the material using a dissolve effect, how do I plug the lerp node into that
Let me know if I need to show the material
Are you saying that the alpha is separate from the colour? If so, you can either combine them first (like into a Vector4/Color rather than Vector3 which doesn't have an alpha component), or use another Lerp node (probably easier).
What are you trying to do with this?
Im showing the material, as I am having trouble understanding where it goes. Like, does it go near the sample texture node, or like the muliply node
Sorry, I'm a little confused. What exactly are you trying to achieve? You mentioned "material that transitions from one to the other". Is there another material that you are using that you want this one to change into?
im trying to follow this tutorial https://blogs.unity3d.com/2019/07/31/custom-lighting-in-shader-graph-expanding-your-graphs-in-2019/ but i ran into a problem
my materials arnt recieving shadow data
the cube on the left uses my shader graph, right is normal
I haven't made it yet. For now, Ill make a tinted version of the texture then transition to that tint using the dissolve
this is the sub shader for the main light
why isnt the shadows appearing??
im using the custom functions from the tutorial
even with saturation it doesnt work
are you sure their examples throw shadows?
doesn't look like it in those images they have on that page
@quick wigeon Okay, I'm hoping this helps clear up what the lerp does. Imagine the Slider node is your Dissolve input, when set to 1, it lets through the Color, while set to 0 it shows the texture fully. The Color/Texture outputs are both Vector4's. The Color could be replaced with another texture or tinted texture output for example.
there is also this video which is the same as the blog https://www.youtube.com/watch?v=DOLE4nrK97g, here they show shadows @rustic dragon
Learn how to write a custom lighting shader for a stylized look that can easily be shared across multiple assets.
Speaker:
Ciro Continisio - Unity
More about Shader Graph: https://on.unity.com/2oDQCbi
Slides available here: https://www.slideshare.net/unity3d/learn-how-to-...
at 11:15
@tranquil bronze I can't seem to get the custom function nodes working right now, but you could check here : https://github.com/ciro-unity/BotW-ToonShader/blob/master/Assets/Shaders/CustomLighting.hlsl
It contains the hlsl used in that video. Maybe there are some differences between that and the blog post
@tranquil bronze Just tested the MainLight_float function from what I just linked, and it's receiving shadows fine for me. I'm using Universal Render Pipeline in Unity 2019.3.0f1.
Graph looks like this in case your interested.
maybe his cube had shadows ticked off on the renderer, what else in a shader could do that?
Hmm, I just noticed some issues when zooming out though. The shadows seem to move around weirdly.
I don't think the moose guy in that creator kit he showed has the same type of materials on it
it's just doing some dot product to get some rim stuff
@rustic dragon I don't know what shader the moose guy is using. I just linked the lighting functions that were included in the project which appears to include shadows.
It just used that as the preview image for the link
ah
what do i have to do to update a hdrp shadergraph shader via script in realtime?
whatever i tried so far didnt work
do you know the name of the parameters?
so you don't have one you made, you want to update properties in the out of the box ones?
i made a new shadergraph shader, and that works fine except it doesnt seem to update in the game
show what you are trying, send us the names of the parameters, etc
i know the parameter names and can read and set them
so you're saying what i do should already be working?
do you have the proper material reference in game?
are you wanting to change a specific instance of it or the original?
i have 2 material instances with that shader that are supposed to update
its a vehicle which headlight and taillight brightness are supposed to go up when i need them
What code are you using to update the properties?
yeah, please show that, and how you are getting the reference to the material
{
Material instance = updateData.material.lightMaterialInstances[i];
instance.SetFloat("_IsHeadLightEnabled", 1f);
instance.SetFloat("_IsTailLightEnabled", 1f);
}```
i know that it does find the specific material instances, and it does update the properties
so the material on the gameobject is changing in game in real time?
I mean to the #'s in the material in the inspector, do you see those change?
so in the material you have in the project, (not running in game or an instance), if you change that float from 0 to 1, you see a change in the material sphere preview?
no, since i'm only updating the instances on the vehicle
I just want to make sure your material/shader is set up properly, that 1f truly means 'on'
so you don't need instances, just go to the material in the project, select it and alter the parameter
while the "headlight" and "tail light" bools are off in the base material
which is how its supposed to be
setting the base material parameter doesn't work either
maybe the emission is not bright enough, if there even is any
then the shader is broken
yeah
sorry, not broken, just not quite right, show the graph
how would i set the emission then?
did you set the proper keyword?
it is in the page I sent
but I don't know if that's it
you basically need to see the change you want to see in the base material
i didnt think thats needed on non-standard shaders
so get that working
Yeah I think that's just for the built-in pipeline standard material
If your values are changing, I assume the references are set correctly in the shadergraph blackboard?
yes
Could you show a section of the graph where the properties are used
but does the value of 1f really turn it on
The bool might be active, but the shader might not be set up properly to use the bool
yeah, if you change that bool and you don't see anything change in the material in the project, it's probably not doing much
changing the bool on the shadergraph blackboard works
and changing the bool on the material instance works too, updates in the preview window
show the names of the properties in the graph
I mean the names in the blackboard, where you added the parameters
ah
just want to make sure what you put in the string for the SetFloat isn't in the wrong format or something
You could remove those Multiply nodes and put the intensities into the True input on the Branch, but that won't fix your issue, just cleans up the graph a bit.
Yeah, shadergraph bools are actually floats behind-the-scenes
so, just to make sure, when in the game and you turn on the headlights, if you select the headlight object and look at it's material in the inspector, is that value 1?
yes
and if you make it go to 0 (in the game), you don't see a change in game?
nothing happens in the game if i change any of those values
i can even remove the textures from the material instance, still no change
Are you sure that material instance is definitely the one the mesh renderer is using?
you might not be selecting the instance in game?
how would i make sure that its the used instance
select the object in game during play, and look at it's material in the inspector
i loop through the list of materials on the vehicle skinned mesh rendererer and get the ones i need from there
I mean on the object in the game during play, select in the hierarchy and see what the current material settings are
i do practically the same on another material, which is the carpaint i set to a defined color in Start() and it works
custom shader too
and yes, its indeed the right instance
with the changes made
do shadergraph or hdrp even support updating textures at all
{
Material instance = updateData.material.materialsList[i];
if (instance.GetFloat("_UpdatePaint") == 1f)
{
updateData.material.paintMaterialInstances.Add(instance);
}
if (instance.GetFloat("_UpdateLights") == 1f)
{
updateData.material.lightMaterialInstances.Add(instance);
}
}```
that works
How is updateData.material.materialsList set?
updateData.material.materialsList = updateData.material.meshRenderer.materials;```
I thought so
something wrong?
meshRenderer.materials returns a copy of the materials I believe. Any changes made to them won't be written back to the original materials on the renderer.
but it works on the paint materials i mentioned earlier
just not on the light materials
Actually I could be wrong, I think I misread the docs page
yeah
I think it's...if you even reference .material it makes a new instance and returns one. So always reference .shaderedMaterial unless you want to clone the material instance.
Which might be what you guys just said. :p So don't even reference .material unless you want a unique material instance and everything that comes with that (like breaking instancing and batching in some pipelines). The .materail getter basically makes a clone if it doesn't have a unique instance already. Messes everyone up, but it's there for historical reasons, and it's a feature. ;)
:2c:
Yeah I always just use sharedMaterial.
i cant have that if i want to be using multiple cars with different colors
yeah, you need the reference to the instances
That's what "instancing" does. Material property blocks. And still use a sharedMateriel to get batching. But see differences on other new pipelines.
yeah, if you change a property on sharedMaterial it'll change them all
after instantiation into the game, you just need to get a reference to the material on the Renderer and change it when you want
isnt that what i'm doing
You need to see the docs on GPU instancing.
And then use sharedMaterial.
I'm pretty sure.
Unless you don't care about batching. Then basically, you're making a new materail for each "car".
What pipeline are you using (sorry, not following all the way back)
They are using HDRP
hdrp
like i said, at this point i'm not even sure what i want to do is currently supported
Both material references and using Material property blocks should work, the latter is probably a better choice though as then you don't need multiple instances.
OK if memory serves, that groups by shader, not material instance. So now IDK.
But if you don't need unique instances of materials by car, better for memory that you don't make them.
he wants to turn on and off the headlights, which should be done per car
but how do i add material property blocks to a shadergraph shader
you shouldn't have to, what you are doing should be working, not sure why
ยฏ_(ใ)_/ยฏ
if you are saying you are able to change other properties on these materials but the isHeadlightOn isn't working, then either that 1f value isn't doing anything, or the name of the property you are trying to reach is spelled wrong
but the reference works, it changes accordingly in the inspector of the material instance
I'd have to see deeper into the scene, seems strange
i'm just gonna create a new one and check step by step
i'll figure it out eventually
emission seems weird
i just found out there's an emission node i wasn't using
maybe that will change something
I can't get that to work either, maybe that keyword needs to be enabled
Sorry, I don't want to mess you up. Having these three pipelines gets confusing, and I should have asked you which one you were using. Batching is different between them if IIRC.
So for HDRP, is the material class different than it is for Standard? Or just the attached shaders?
There's an upgrade-materials function, so I'll have to look that up. I was thinking the materials class spanned the piplelines, but maybe not since the attributes are different. So do you end up with a unique material class for each pipeline, and thus it might behave differently when you reference .material on the game object? The Doco reads like there's only one material class, and the shaders are just different (and the pipline logic in the engine too).
I hate this. I'm going to go crawl away now. I know how it works for standard.
for how long will hdrp be experimental?
what does a proper emission map look like anyway?
is it black and white or do colors work?
so lwrp works fine
two of the same spheres with the same material, instantiated and the one on the right has it's bool changed
I coudn't get emissive to do anything in the material, let alone be able to switch it off/on in script
Is there perhaps a setting somewhere that disables it in HDRP? I seem to have it working fine.
I'm using a slightly older version though, so I'm just updating to see if there's any changes
there are so many badly documented hdrp properties
maybe something in the pipeline
I tried adding the keyword to the material (through debug) but that didn't work on my end
Hey folks, how can i make gradients in a shader without a texture look up?
ah yeah, i was more wondering if theres any math expressions or anything that makes that
and in code
and he says "And for "general knowledge", this is exactly what the sample gradient node is doing, but with up to 8 color and alpha in code with a loop "
so this is what you're looking for I think
but i guess i can just use the Y channel of a UV for one i guess
What I use is a color gradient field in my material editor -> convert gradient to texture -> sample texture
If you need a vertical gradient from black to white, then yeah, UV.y will work
but isnt it then more expensive for you to use a texture sample in the end @devout quarry ? or
did you follow me recently on twitter @regal stag ? your profile pic and name looks familiar
I guess maybe, but it's just very convenient to use a color gradient in my material inspector
and I convert it to like a 256 by 1 pixel texture
then samplle
ah thats fair
Texture Samplers should be more expensive and they have a limit, so using the UV math is a great way
thought so! ๐ thanks
whats the maths for a gradient thats peaks at 0.5 and fades at 0 and 1?
in Unreal at my work, the shader cost is rarely an issue, but samplers are
just an inverted distance with 0.5? or something more clever
@rustic dragon So using like noise is preferable over textures for performance?
Is there like a good article or resource somewhere where I can read about shader performance, I know very little about it
@grand sun I do follow you, can't remember when I followed though. You might also have seen me on twitter, I've made a bunch of shaders using shadergraph in URP.
but depends how detailed your noise is
@devout quarry honestly that one I don't know, I don't think unreal has noise, usually noise is easy to pack into some other textures which is always a good thing to do
I'd say the gradient thing is a no texture choice for sure, but noise might be a toss up, I wonder if anybody has really audited the noise in unity
It also depends on what platform you are targeting. Generating noise for mobile isn't going to be good, a texture would be a lot better.
you are right @grand sun , haven't used it ๐ฎ
yeah, we don't do mobile, just the lowest is really XboxOne
Has anyone been able to build with a custom pass volume, in HDRP 2019.3? It's crashing immediately.
it's a toss up sometimes on what to use as far as texture vs more complex shader, if you really get up there in samplers (like for characters or terrain), sometimes some extra math to make it under the limit is smart, but if you are well under the limit, textures are good especially if you can pack them
so packing something in RGBA really is a x4 speed increase compared to using 4 textures?
or is the unpacking some extra overhead or something
yeah, 1 sampler vs 4 samplers is always good
one note, if you have 6 samplers, don't do RGBA and RG, make sure to do RGB and RGB
adding an alpha doubles the cost of the texture ๐ฎ
I gotta write this down lol
@devout quarry you can actually see this in the way normal maps are stored, which is why you always have to run UnpackNormal to convert it to a direction
yeah, A is the most uncompressed, but for RGB it's G, so put your roughness/smoothness maps in there
ah cool thankyou roystan
@rustic dragon as a tech artist do you find yourself writing shaders or just using the shader graph?
shader graph, the programmers don't usually want us making shaders ๐
ah thats interesting
I am more on the art side btw, don't do any c++ or anything
rigging?
tech artists 'can' do shaders, we come in all shapes and sizes
more world gen and optimization guy, audit assets, pipeline stuff, and some tools
yeah haha, i am taking my steps to go further towards being a "tech artist" and just figuring out what i need to do
@rustic dragon how large is your team? Curious about how shader graph is holding up in real world settings
me too
@orchid peak we use unreal at my work
ah
btw
ohhhhhhhhhh
at least the game I worked on