#archived-shaders
1 messages ยท Page 132 of 1
and the one I am on now, but the teams are generally like 50 to 70 I think, smallish
what do you find the most lacking in shader graph compared to unreal's material editor?
@devout quarry not much really, some reroute nodes are good, the subgraphs are a bit easier to manage
ue4 also has blueprints which is super helpful for tech artists.. i'm confortable with them but with unity its a lot of programming
yeah, I hope unity's visual scripter is good, but I heard it's only for DOTS
it will be a few years off from what i've heard
@devout quarry one big thing that doesn't work with unity is using materials for UI, they don't render with the Screen Overlay method, you have to use Camera Overlay ๐ฆ
one of the thing I did was ui materials, doing things moving about, health bars, etc
@rustic dragon what do you use for world gen ? custom tools or something specific
and sorry in advance, i question every tech artist i see nowadays ๐
we are looking at houdini for that stuff, but on the last game I think they used world machine for the base and then just went in and painted terrain, placed structures, etc
@grand sun Visual scripting is available as an experimental build https://forum.unity.com/threads/dots-visual-scripting-4th-experimental-drop.749273/
oh so it sped up!
custom tools are hard to come by for smaller or smallish teams
and honestly I am a fan of using as vanilla of an engine as possible, middleware and tools are hard to maintain ๐ฎ
last i heard from the peeps at unity, it was quite some while off
yeah, I still wouldn't expect it for years. DOTS only would also be kinda odd
I do think it is DOTS only
@rustic dragon I seem to be able to use materials on UI in Screen space overlay fine in URP, unless you mean it doesn't work in other pipelines?
I don't have URP yet, using LWRP in the latest, my experience is they just come out black
maybe it's fixed, or yeah, user error on my part
Ah okay yeah
In order to make your Shader Graph render correctly in Screen Space-Overlay mode, you will need to set the blend settings as they are in the Default UI shader. As of this writing, Unlit Shader Graphs set Blend at the Pass level: Blend One Zero, One Zero. We need it at the SubShader level: Blend SrcAlpha OneMinusSrcAlpha. (See line 49 in the code below.)
so yeah, I guess you can fiddle with stuff
@crimson stone nice
thanks for your help anyway
I tried that node too, so there were no other tweaks?
emission node?
I think I had emission working without the use of that node, but if it's fixed that's good
HDRP thing
ah
Should i frac _Time so over time the value doesnt get too huge? or wont make a difference?
isn't frac to make something repeat from 0 to 1, no matter the increasing value?
Yeah, frac(_Time) will cause the value to loop. It returns the fractional part of the number, so when it reaches 1 it drops back down to 0.
yeah which is normally all i would need if im offsetting something in 0 - 1 space
@grand sun I think it'll take some days before _Time.y becomes less precise.
not really, if you want 0 to 8 to be in 0 to 1 space, use Remap
oh i totally forgot about the _Time channels ๐
The faster channels will obviously become bigger faster so less precise faster.
Well, it'll become less precise the bigger the number. What I meant was it'll take some days before it's noticable.
doing frac on _Time kinda gives you a rainbow haha ||https://gyazo.com/b60188964bdec77b2e137e3e21f18750||
Pretty ๐
_Time is a float4
I'd probably just keep a float variable around until the final output, if you do any more operations on a float4 it's going to be more expensive than just a float... right?
thaats true, i was just doing this as a test ^^
what are you trying to do?
just playing around with things at the moment
but making a shader for tubes/pipes that offsets vertices in a cartoon buldge effect
heh, nice
love doing that kind of stuff, especially messing with vert offsets
https://vimeo.com/256240586 here is a spring that doesn't stretch, it the thickness doesn't change
im just thinking about the best way to get it to scroll along the UV that might have a tiling texture
without the bulge tiling several times along the mesh
yeah, if you can control the UV's so even a bending pipe is straight on the UV's and they go seamlessly on down (even extend past 0 or 1, just use UV2), it should be good
yeah i just wonder then because it would extend past 0-1
and the bulge offset would expand past that meaning it would tile twice+
๐ค
you can sample UV's past 0 to 1
and if you don't do any looping past 0 or 1, you should be good
like for that spring, the links around go up pretty high, I don't think it's necessary honestly, but at that time I figured more fidelity to the values would help
ah yeah
Having UVs beyond 0 to 1 might make texturing harder though, if certain parts need to be textured differently.
UV2, not UV1, it's basically a data set
Ah right
https://vimeo.com/248862524 this one really required a few UV set tweaks
if uv1 has nothing, what exactly is the info thats in there?
it has 4 floats of value
though I don't know how you'd edit the 3rd and 4th one in a 3d Package
wait, maybe it's just a V2
so you can store anything really, and access them in the shader to do cool stuff, I made a fortnite wall building system with that technique
The UV nodes in shadergraph output float4s. I would assume it's the same for code.
https://docs.unity3d.com/ScriptReference/Mesh-uv.html yeah, I thought so too, but there's this for the mesh
@rustic dragon
yo
ah nice
https://vimeo.com/290457079 here is mine, basically takes objects you add to the 'grid' and then you do some settings for how it comes and goes, gravity faking, etc, then it comes all of those gameobjects into a single mesh and bakes the UV's and stuff
looks clean!
oh yeah i saw the same with vertex colours
I like it
but vertex colours are quite a nice place to put a lot of other data in
yeah, I didn't want to overwrite any vertex colors, so I just added uv channels to hold the data, just in case the user was using vert colors
i know in the talk for fortnite they say said they did some special stuff to include the data into each of the individual meshes, i wonder if all it really was was the second uv channel haha
There are 3 extra uv channels to play with
well the idea is to make a single wall a single mesh, then with the UV's or vert colors make it 'animate' coming together or being destroyed, the main flaw is the collision doesn't change with the visuals
but for gameplays sake, thats actually better
@low lichen actually it's 7 extra now
for sure, but if you wanted to do something that you might be able to interact with, it'd be trouble
@rustic dragon Ooh, cool!
guess you would do a different solution all together then haha
speedtree uses all 8 of the UV channels, very bloated and expensive assets ๐ฎ
wind and rustling
couldnt it be done all in the same one?
i guess not if they have to use all 8 but.. ๐
to really layer it, not really, but 8 is excessive
@rustic dragon have you worked with any really big shader graphs?
with lots of properties
I'm talking maybe 40+ properties at least
would you want to?
the idea is you want the trunk to bend in one way, the big branches in another, smaller branches to the actual leaves in the wind
๐
@devout quarry I have, character customization got quite silly after a while
ah you're right i guess
how was performance for you?
but beyond parameters, a lot of spaghetti graphs for sure ๐
parameters area actually quite costly we found out late in the project ๐ฎ
ah damn
yeah, each instance of the material gets it's own values, so that had to be stored/streamed/destroyed
tradeoff between performance and usability then I guess
yeah, it's a fight
ah alright but if it's for 1 object it should be all right?
i guess not if that 1 object takes up all your budget
yeah, the idea is you really put a lot of work optimizing into the objects you have a lot of in one scene, special one offs can be nice and detailed
yeah that's good way to think about it
that can happen, but it's mostly the 5000 friggin' rocks, even collision starts to add up due to the instances
I really am writing all these tips down by the way haha
๐
but rocks rock
they roll too
Also, shader complexity is usually in the pixel shader, so it doesn't matter how many objects use that shader, it matters how many pixels on screen are drawn with that shader.
yeah, overdraw from the mesh is a worse offender
but generally shader cost hasn't gotten to be an issue, the terrain is one that can get up there and it covers a lot of the screen
Overdraw and shader complexity has been something I've been having to optimize a lot for a mobile VR game.
add to that decals, grass and particles, it can be a render mess
yeah, do you do LODs on the meshes @low lichen ?
like how grass in breath of the wild tanks the frame rate
not sure with memory mobile can afford them
@rustic dragon No, but it's a small area you're in. Usually never any object over 15 meters away from you.
can you get away with using LODS in mobile games? usually the fixed camera angle would cull a lot i guess?
@grand sun grass is hard to deal with, it's mostly the draw distance that takes the punishment, so you have to resort to tricks to not get a bald hill 100 feet from you
yeah, LODs are really only for 3D games, they help with tri counts, and on skinned meshes, they reduce the amount of skinned verts
i love unreals LOD maker
yes, it's great, better than Simplygon ๐ฉ
unity really needs to invest in some LOD systems, including HLOD
question now.. im just gonna use a texture input for the scrolling vertex offset
ah nevermind
gonna try something first ๐
@grand sun You mean like a heightmap?
Yeah. tex2Dlod is necessary because you have to specify which mip map level you want.
got a headache trying to figure this out
so funny when i know how to do this with visual shader editors but in code its harder ๐
cheat, mock it up in a visual editor then see what it does in code
ahha yeah ๐
is making shaders with a visual editor generally seen as a 'easier' or a 'lesser form' or making shaders
Certainly easier to learn because you don't need to learn the basics of programming and the special shader language syntax.
I don't think easier means it's a lesser form of making shaders
For me it does feel like a bit easier yeah, not so much because of the syntax but because of the visual component, I've always been a very visual learner and it helps me to see things layed out in a graph
Being able to see a preview at each step is very nice. But I still prefer writing shaders, because it feels less limiting and it's something I'm used to.
how would i go about making stars sloat towards the front of a object, like passing through space?
@charred depot Are you looking to do this in one shader pass or are you open to using particle systems?
would i be able to do this in a particle system tho? ive seen it done only in shaders
What about the effect makes it impossible to do in a particle system?
i didnt explain it too well, basically want a black background and stars going forward and then disappearing, iits going to be on a flat object
can anyone help me figure out what i've done wrong that is making the offset only work on half of the mesh o.O
very confused
red line is roughly the origin
ah i guess its because i just took the x channel of the tex2Dlod? fixed!
re: LODs
Unity does have this experimental thing https://github.com/Unity-Technologies/AutoLOD
but there's no real info if that's something they'll go further with
it supports old Unity Simplygon plugin too
nice
@devout quarry it is definitely easier, but it's not so much "lesser" as in that it can be a different role (on larger teams). I've done a ton of shader writing but for simple things I prefer graph editors, since shaders are visual anyways so seeing step by step just makes it faster
I'm looking for some help with a shadergraph i've made.
I'm trying to change vertex position but am unable to put a vector 3 as the input for vertex position.
I have a feeling it has to do with getting one of the values from an rgb, but that shouldn't matter should it?
yeah
and if so how can i make the red value ~= 1 become an x value ~= 1?
I replicated the issue and that's what it is, use this as your sampler
instead of the other one
ah ty
Hey I was wondering if anyone help me with my confusion. Let's say I have a colour, if I multiply it with a Vector1 (min 0, max 1) what happens to colour? Second question is, if I add 2 colours together what happens? Are they blend in? Little bit confused.
a.rgba * b, it multiplies all the components by b. a.rgba + b.rgba, it adds the matching components together
Colours are just 4 float values, so adding them will simply add each component together. If you want to blend between colours you should look into a Lerp.
since last week I couldn't get colors blend right. I am trying to blend shadows with a color, light parts with a color. I tried, add, multiply, blend, lerp. Maybe I am doing something wrong. Let me try Lerp again.
I wonder am I stupid or something ๐
this is a modified version of blog post's lighting model.
currently LightColor and DarkColor change color of same region.
and I am losing shaded parts all together.
If you want to apply colours to the light/dark areas, it might be easier to have a single Lerp, where A is the LightColor, B is the DarkColor, and T is the NdotL Smoothstep output.
switching A as Dark, B as Light works correctly. Still it still takes so much from shadows blackness but yeah It's something like that.
thank you
again @regal stag
If you want it darker, adjust the DarkColor to be darker
Or you could then multiply the lerp output by the smoothstep. @left pivot
So, I have a question about implementing point light attenuation. I'm basically extending the Standard shader to do a muzzle flash effect on the environment when the player shoots (to avoid more realtime lights).
I'm doing this by simulating a simple version of a point light from the player position when they shoot.
However, I can't seem to get it to work correctly. It doesnt light up at all on the floor below me, only walls. They both use the same shader.
And the attenuation seems completely off, I cant figure out how to implement radius. Could anyone take a look? Shader link : https://pastebin.com/MuUadxjS
Video of how it looks
Point Light Standard Shader
@left pivot Yeah. It should look something like this, if that's what you want. I'm not doing a smoothstep so might look slightly different, just using the value straight from the saturate before it.
If the smoothstep is still not dark enough, try the Saturate output instead
Well someone here help me with that smoothstep and one minus to get shadows and highlights separately. I can try this.
smoothstep multiplying get it too darker ๐
let me try this one.
well this is better on darker areas but It also slightly changes highlight areas.
I can fiddle with it further I guess.
Whats the difference between albedo and albedo smoothness?
From what I understand, albedo is the base map, the color of the vertex
@native garnet What's the context? Is this something related to Shader Graph?
Yes
Also, I don't understand why the shader graphs a differ so much, some dont have parameters for albedo/emission
Can you extend a bit what you see ? Are you using URP or HDRP ?
I don't see where "albedo smoothness" is.
As for the differences of the master nodes, this is expected, as "albedo" is the color of diffused from the surface, and emission is the color emited by a "luminescent" surface, those don't apply to the "unlit" master node, that only has the color that is displayed
@regal stag i dont understand why my shader isnt working
my toon shader thing
this is my project, what is going wrong ????https://github.com/bobthetreegod/Shaderland
@amber saffron oh sorry, my bad, it's actually just smoothness and its a standard shader property. I see thanks for the explanations!
I'm using hdrp right now, and i find strange that emission doesnt contribute to lighting
It does if you bake the lighting
Wait the lighting must me baked?
It can't be done in realtime unless you're doing raytracing
What about a moving object with emissions, shouldnt that work too?
@low lichen oh damn
It can work with realtime global illumination, but that requires a static baked environment
I had no idea, looks like a pretty simple effect, it just multiplies the nearest vertices with the emission color I think
I don't know how HDRP lighting differs. Maybe they have some realtime option for this.
Btw, I am workin on a mobile game
Is it normal for the game to drop 30+ fps and gain +20 latency when using shadows?
Right now I disabled them all, with them I get horrible performance, even tho they looked awful
HDRP doesn't work on mobile
Or better : "not supported"
For the shadows perf drop : this is expected
For emission on materials : this is not as simple as it seems, and the best way to have dynamic lighting from those kind of objects is to fake it using a light.
Lighting objects with the emission of other ones is made through global illumination as is either :
- fully baked and static (nothing moves)
- partially dynamic : enlighten realtime GI (but is no more supported in HDRP)
- fully dynamic using realtime raytracing (NVidia card only, and obviously not on mobiles)
@amber saffron thanks for all the explanations, and yeah i confused pbr graph with hd render pipeline, im acrually using the lwrp
im not sure if this belongs here
but
i have a material which becomes transparent when between the camera and player
but
I have two pieces stacked to make one wall
and i get this weird effect
is there a certain shader or a way to remove the added opaqueness
this might be more clear
Basically, right now when the upper cube is drawn, it doesn't "realize" that the cube below it is a transparent block. It might as well be a lighter colored opaque block, so it blends its transparent pixels on top of it
oh i see
There is a way to fix that though
hopefully not complicated
And that is to add a depth pass to the shader. What that means is it will render the cube twice, first only writing depth and then writing the transparent pixels.
occlusion culling? im a bit rusty on shaders
You can read about it a little bit here
https://forum.unity.com/threads/transparent-depth-shader-good-for-ghosts.149511/
ok thanks for the resource!
doesnt look like that is helping
apparently you can draw the square with a stencil buffer activated
and not draw the second one where it overlaps
you know of any resource for that>
You can think of the stencil buffer as an extra channel, like the alpha channel, which you can write to in a shader. But it's special because you can make an object only draw on places on the screen where the stencil value is equal, greater than or less than a certain value.
The syntax for writing and comparing stencils is here:
https://docs.unity3d.com/Manual/SL-Stencil.html
ok thanks!
I'd suggest to just have this wall made with one cube and not two ...
Anyone know a way I could add some noise to the edges of shadows? Trying to make shadows cast onto a flat surface look roughened like itโs being cast onto grass without using heavy grass geometry everywhere.
@willow pike What's the context here? LWRP/HDRP? Shader Graph?
@low lichen using URP and Shader Graph
You could make a custom lighting shader, but that seems overkill ...
Iโm using a top down camera that cannot be rotated. If I could just add some vertical noise to my shadows I could achieve this effect.
Yeah debating if this is worth it but would be better than covering my entire game with grass geometry. Figured that would get heavy fast.
I'm trying to imagine if noise would look any good. Surely you'd want to displace it with some kind of grass like texture?
And you're not talking about the blades of grass that are lit and in front of the shadow, right?
Maybe. Iโm using a cel shaded flat/illustrative style. Trying not to overly texture my game.
what do you mean noise, isn't that shadow warbled due to the shape of the tree compounded by the uneven ground and grass, is that what you are talking about?
I do have some actual taller grass blades using geometry that will displace shadows but I want the entire surface to look grassy without placing the blades on every grassy surface
@willow pike Can you post a screenshot of a grassy patch with shadow on it so we can see what look you're looking for?
can your grass surface have some more geometry detail, like a grid of triangles/verts with a bit of height noise
That might be the right solution @rustic dragon
So you can see what I mean here. There are patches of tall grass, but for example I'd like that tree's shadow to have some roughness even though it's being cast onto a completely flat surface.
looking good btw, but yeah what kind of surface is that geometrically?
looks like you have some pattern of verts/tris?
Basically treating it like an old school tiled 2D game but with cubes and some rounding around the cliffs.
Suggestion : use layering to have a different sprite project the shadow ?
are those premade chunks?
Well I created them but they are ideally going to be repurposeable to be able to build out the whole overworld.
@amber saffron Sprite? I don't see any sprites in this.
maybe add some little divots in the tree
Maybe some kind of plane above the ground or built into the tileable chunks with lightly displaced tris like you're saying?
and disable shadows casted on it
ok, so you could add some detail on the surface to make it warbled a bit, I was thinking it was procedural
and enable it casting shadows?
Sorry, my bad, that tree kind of looked like a facing camera billboard.
But still, you can use what I said for meshes
Yeah that might work. I'll try making some subtle variation on the flat surface of the tops
@willow pike I think somebody above mentioned the idea of layering the ground plane a few times with other grass planes slowly increasing height, and use a material on it with alpha clip with an ever increasing clip threshold on some noise (world mapped noise) then the shadows would warble that way
Nice! Yeah that's a great idea @rustic dragon
Thanks everyone for the help, I'll try to put something together using these ideas and post the progress
good luck, and it's looking good!
Thanks @rustic dragon forgot to update you on the grass overhangs. Just ended up using some custom texturing and messing with the UVs to vary them around corners.
nice
how can I check if objects arent being hit by a raycastall that have been hit before? before I switched to raycastall i used raycast and kept track of the last object and when the raycast was false I did whatever
kind of an interesting result, the noise I used leaves a bit of a 'grass' texture on it too ๐ฎ
are your shadows baked?
Wow that looks awesome! @rustic dragon I love it. Very much the look weโd like.
Using real-time shadows for now but havenโt tried baking the lighting.
here it is with an optional grass color variance based on height
ok, the one I used is real time too
Wow! How would I implement this to the tops of my cliff chunks?
I imagine you wouldn't want that edge height look, or would you?
The second one looks great with the variation
could be tricky on the cliffs, this is how this is set up, the drop shadows just get mipped away at a distance to get that more subtle look, not sure if that's a problem in the long run
Ah I see. I wonder if it could just be lowered near the edge lips of the cliffs.
It might not even look bad with the top the down down perspective
that is just a shader made in shader graph that uses alpha clip transparency that for each 'layer' I make the threshold go up
if you control the geometry completely, just pull the edges down on the models for that layer
only the middle parts would need to 'float' above
when modelling this a simple bevel extrude a few times would probably be enough for the different layers, map them the same way (or world mapping might be better), then apply something like this
the noise is texture driven btw, just clouds and some noise in photoshop
Yeah totally I love this. Could even do a similar approach to make the surface of the cliffs look more distressed
yeah, overdraw can be an issue with doing stuff like this, so worth a try and see how it affects performance
geometrically it's not much, texture is small (512x512)
Overdraw shouldn't be a big problem if you draw that top to bottom with ZWrite at each step
@low lichen I am using LWRP to do this, do you think he'd need to write an actual shader to do this best?
not sure if a shader graph shader has all of those things set properly
I don't know enough about Shader Graph to answer that
Are you putting many passes into the same shader?
this shader should be easily remade by hand too
not sure what you mean by many passes
it's a default PBR shader with this as the graph
Thanks so much @rustic dragon Iโm gonna give this a shot when I get back from lunch. Will probably bug you about it again later ๐
sounds good
@rustic dragon Oh, so it's just multiple mesh renderers with this shader manually stacked on top of each other?
I'd really like shader graph to have a 'get/set local var' like amplify has
would make organizing my graph so much better
@low lichen yes
@devout quarry is that where you can have like teleporting invisible connector lines?
I remember that, it would be cool, as long as you can have 'go to' type deal to help with navigation and knowledge of what is going on
@rustic dragon In that case, just gotta hope Unity orders it properly, which it should
I added a relay node that's just 'Out = In' and it helps because then I can have sharp corners in connector lines
but still
the lines are sometimes just easier to follow if you can pin them, which it's missing compared to unreals and I think amplify
yeah, being able to reroute lines I think is the best option
@low lichen yes, that can be a concern depending on the distance he sees them at, but you can fudge the distances to match I hope
Doesn't URP have a special order number for renderers?
If not, you could also use render queues, if that works in URP
It looks like each layer needs its own material with that shader, though.
yes
If you connected the threshold with the Y position of the object, it could all be the same material
they are at different heights
and to base it on the actual object position would be hard as the models are of different scales
could be some sets of 'heights' though where you can do that with fewer mats
Just gotta add an offset position to define the starting position and then a multiplier for how much 1 unit of height increases the threshold
yeah, I think that would work for the same height objects for sure, good idea
Just trying this out @rustic dragon
So in your example, is each layer of grass using a different material with a different alpha clip threshold?
Or is it dynamically changing the threshold based on the object's vertical position?
In the screenshot they took, they just had a GrassThreshold property, so a different material for each layer
But it's totally possible to have it use the vertical position like we were talking about
yeah, you can try to do it based on height, but it might be more difficult if you have a lot of varied heights
so you'd need an offset property and make as many set Materials as you have different heights of cliffs
If it's on some kind of grid, it could be repeating
Hmm right that's what I was thinking
probably isn't an easy way to make one material do this across an entire scene
how many 'heights' do you have?
This could be done with a geometry shader, where each layer is created by the shader
that would change the shadows?
That would save design time since you won't have to manually stack renderers together and you could easily change the number of layers
shadow heights that is
Sure, as long as the shadow pass also uses the geometry shader
At the moment it's stepped up like this, increments of 4 and 8 units I believe
you could try to repeat it, or just make materials for each level, which looks to be like 4/5
Hmm thought I was on the right track here but it doesn't seem to be working
then if you expose an offset you could push each of the 4/5 materials for the height
but definitely look into what @low lichen is talking about, unless you want this to work with the shader graph, not sure you can do what he's mentioning in shader graph
I'd be surprised if Shader Graph has geometry shader support already
the clip threshold should be .5 and not changed, but I think it does require a paramter weirdly
And if this is for mobile, then geometry shader is out
I did the threshold differently, but you could use that honestly, I am silly ๐
why use the invert colors?
Oh wait yeah
Hmm idk I thought it was "thickening" the grass as I moved the plane up on Y and I wanted to reverse it
I usually use one minus
Ah I'm still noobing my way through Shader Graph
heh
anything I need to consider when trying to create a shader for terrain. (shader graph)
Cause I added my shader (one I usually use for objects) to it. Which lead to overwritting/ignoring the painted textures
@rustic dragon Only using one layer of noise for now but it's already giving the effect I want, really happy with the way the shadows of the player and tree are hitting the grass. And it's a nice bonus that it looks like grass is growing up around the crates, cliff edges and player's feet ๐
Not at all, was struggling to get the multiple layers that change based on height, but after I gave up I just tried a single layer and really liked the look
Thanks, used a noise node instead of the texture so I could control the detailing. Works pretty well.
how are you handling the edges?
so the reason I used more of a macro noise texture was to get that warbling on the shadow edges
I would try a bit of that too, maybe mix 2 layers of noise, one macro and one micro
if you wanted that larger warbling of uneven ground and patches that is
Yeah I might do it with the second material, really wanted to get one to do it but it's probably not worth it
Edges look like this right now, don't hate it but if you have any ideas for how to make it better lmk
It does make for a cool effect for the top side of grass where it's near the water, looks almost like a brush stroke
yeah, it does
if you wanted to make the front edges fluffy, you'd have to push forward that polygon edge
that closer show shows the warbling on the shadows, that looks great
Yeah I may just manually pull some of those vertices forward in Probuilder to make them hang over the lips of the cliff sides
You rule though, thanks again
no problem
so, im trying to work with polybrush, and was wondering if it was even possible for HDRP to work nicely with polybrush's texture painting
i'm trying distortion shaders with the Scene Color node.
Here, the red quad is distorting outwards from center, but because distortion is in screen-space, the effect appears stronger when it's at the far side of the disc, when really i'd like it to be more consistent with world space if that makes sense
there should be a way to account for this and make it world-space and i guess it should involve the distance and perpendicularity to the camera but i thought i'd ask if anyones tackled this before i start trial and error'ing
... so i've accounted for the distance and it's still not perfect but it's improved it good enough
graph if anyones curious, selected nodes where the fix
@dusk tapir yup shader graph + polybrush works nicely for me, are you having any issues?
@ocean spade I was having the same issue yesterday, will try out your fix
This https://discordapp.com/channels/489222168727519232/497874081329184799/664197146463174722
Really giving me a hard time. I dont even know where I can find an entry point to start looking
Nothing really yet. You'll need to wait for a terrain master node for shadergraph
You still can do a shader and apply it to the terrain, but getting the layers splat and textures is no trivial
Is there any info when that will be added?
Cause the terrain kinda sticks out through not having that shader
Or can I just write a custom node that gives me the needed textures/layers?
I kind of tried that and failed. But I might get back to it
But you can still "hack" it I guess, by only adding texture properties for the splat maps that are visible in the project view (so you can reference them), and do what you want afterwards in the shader
Is there a way to receive shadows with unlit graph?
@left pivot
There is, and it's basically how some people create "custom lighting". Basically, you get information on the lights yourself (direction, intensity, color, etc) and then do the neccesary math within your graph to compute those values.
Check out the following link for more info. If you search for "custom lightning unity" you will probably find blog posts about it somewhere else.
As a side note, watch out if you are working with HDRP, for things may get a little trickier.
im not recieving shadows from custom lighting in shader graph
this is the tutorial im following
When I load Polybrush, it only loads two Shaders. The Unity tutorial implies that there should be around ten or so. I've removed and reloaded Polybrush, as well as restarted Unity. Anyone know what else I could try?!
can somebody link me a tutorial to make a crystal shader in unity? I haven't foudn any
Official Post from Minions Art: I've played around a little with parallax effects in the Procgen Eyeball shader (link).But there are more visuals you can use this effect for.So in this post i'll show off a few experiments/examples. ย What is Parallax?It's the effect of fake d...
here is some cool stuff
@devout quarry nice, we use something like that called BumpOffset in unreal and you can do some great fake 'depth' things with it, I wonder if that math included in that is possible to replicate in shader graph without a custom node
looks like it could
yup definitely
Cracked Ice Unity Shadergraph Tutorial โบ https://youtu.be/rlGNbq5p5CQ
Fifth and final part in the Series about Cracked Ice Material. This Video directly builds on the last one โบ https://youtu.be/8rf0SlbJhcQ and shows how to add variance to the depth of the crack paralla...
ah without a custom node haha
this ice shader uses a loop
in a custom node
I tried replicating a bump offset node in shadergraph a while ago, let me see what I got
yeah, I hope for loop functionality soon, right now you just have to duplicate things as many times as you need/want
Or use a custom function node, it's convenient
I know, just saying it'd be nice to just use nodes, making custom function nodes isn't artist friendly
Are there 'loop' nodes in ue4? What do they look like?
Like what are the inputs/outputs
I don't think they have them, they just have some built in nodes that do that, though BumpOffset is badly named
just thinking a node for that would be nice in the long run, but I can see how it would be a pretty detailed node
so it might be a non-starter as an idea
@rustic dragon
I did something like this
The grid pattern is a quad and kind of mapped to the geometry below
where is the quad compared to the sphere height wise?
is it like a projector for like a decal?
I don't think it's 100% perfect but it's kind of working
I'll show you what I wanted to replicate, 1 sec
ah nice, how did you get it to NOT just stretch infinitely on the side of that cube, are those cube sides not perpendicular to the sides, or is the quad slightly rotated?
this was it
quad is parallel to ground plane, cube is also not rotated
the angle is 90 degrees
https://twitter.com/klemen_lozar/status/952219112796598272 here is a link to the tweet
You can use the depth buffer with a bump offset function to map textures to the geometry in your scene. Very handy for dynamic UI elements, character damage effects, etc...#UE4 #gamedev #indiedev https://t.co/6KFjpo7vwA
322
1662
I'll clean up the graph a bit and show you
but it was just a quick mockup and haven't worked on it since so don't judge me too much on it ๐
so that uses the CameraDepth data?
@tranquil bronze https://github.com/ciro-unity/BotW-ToonShader/blob/master/Assets/Shaders/CustomLighting.hlsl use this instead. Which uses GetMainLightShadowSamplingData() that will work for unlit master node.
@tranquil bronze the customlightning hlsl from https://github.com/Unity-Technologies/ShaderGraph-Custom-Lighting/blob/master/Assets/Includes/CustomLighting.hlsl doesnt work on unlit, it will always return shadowattenuation of 1
These are the relevant nodes
yeah it uses the camera's depth texture
but as I said, this graph does not work 100%, there are some issues
ah, I was playing around with it, trying to get some 'encroaching' doom thing https://gfycat.com/jubilantillfatedichthyosaurs using the depth and render to texture
I was actually sampling _CameraDepthTexture though, what you are doing is much better!
yeah, with some built in nodes, I will try that
like I used a texture sampler with that as an input
the surface depth node is a subgraph btw, but it's screenposition.a basically
or well screenposition.w
@rustic dragon Cool effect! It could be improved if it was based on distance from camera rather than the depth value directly, so it's more of a radius rather than like a quad approaching the camera
@low lichen yeah, I was thinking of doing that but am noob enough to not really know out at this time ๐
my original ideas was to 'stretch' reality like reality was warping in some way, like 'up' as it came to you
but there really wasn't enough data in the render to texture, but also my setup with how I am capturing and displaying uses 3 cameras, so I really need to learn about the render pipelines more
That effect uses multiple cameras? I thought it was just post processing effect using the depth texture.
it's a material thing, originaly I had lines like scanning lines coming from the camera, and I don't know how to use a shader graph material for post processing
You could always just do a Graphics.Blit from a script after the camera has rendered. There's ways to do your own custom effects using the post processing stack which I'm sure is more performant if you're doing a lot of stacked effects, but last time I tried that it was a lot of boiler code.
totally, this was just a fun hack as a proof of concept (or working on it) as somebody wanted a teleport affect and it piqued my interest
https://www.youtube.com/watch?v=fpLevdY7o0o this one everybody at work wants, I 'think' with the bump offset node I could do it visually, but being able to fall into it is pretty cool and I have no idea where to start
Gears 5 has unique gameplay features. One of them is a destroyable ice surface. You can actually shoot the ice under the enemies to sink them into freezing water.
Gears 5 is out now on PC and Xbox One https://www.gears5.com/
not asking for solution at work in unreal, but it's an interesting effect for unity too
I have a cool shader to share
Let's see it!
tease
Card (except for pokemon model) is 1 quad, 1 shader and only 1 sampled texture (for the text)
I wanted to push my personal limits and use as few textures as possible
hah, nice
@devout quarry yea, i am having problems, i can use the color brush, but not the texture brush
@devout quarry So the background isn't a texture?
nope, the only texture is for the text
the background is some gradient with voronoi
all the icons are signed distance functions
the spheres are raymarched with faked lighting
and yeah the pokemon is 3D with a stencil shader in front of it
what is that done in?
so that's not render to texture for the pokemon?
it's a 3d pokemon model with a stencil mask in front of it
so the card is 1 quad, but then I put 1 extra quad with a stencil shader in front of it to make room for the pokemon scene
hold on
Shader Graph supports stencils?
what do you think the instruction count for that is? can you have multiple cards on screen even overlapping eachother?
no, stencil is not done in shadergraph
haven't tested but my graph is very large and I think this is the worst way to make this card
Using multiple textures would certainly be fewer instructions and more performant, but that wasn't the goal of this shader I imagine.
Nope, I actually wanted to use 0 textures and started using bezier curves to render the text in shader, but in the end it got super annoying and did a texture
this is the setup
pretty damn cool
And I made quite a few pokemon type icons actually in shadergraph using signed distance functions
Because I wasn't sure which pokemon I was going to use
That looks amazing @devout quarry
Nice! What's the process of creating functions for icons like that? Are there tools to help with that?
yes! https://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm this page by far
Tutorials and articles of Inigo Quilez on computer graphics, fractals, demoscene, shaders and more.
I have a card game I am kind of making, and I planned on doing something like this where the gun kind of 'pops' out of the card if it's selected
https://alexanderameye.github.io/parallax-card.html I have some more info on the card here if you're interested
saved link ๐
ah so it becomes 3D, that's a cool effect
that is the hope, with a real 3D background behind it
Alexander, last night/this morning, you said you were able to use the texture brush in polybrush with HDRP?
yup I used this shader
for vertex painting
I hope that's what you mean with texture brush otherwise I'm misunderstanding
why does your unlit master only have one option?
I collapsed the unused options since I only use color
There is like a little downwards arrow on a node that collapses the ports
well, im wondering because your one option is "Color" whereas mine is "Base Color", and wondering if that has any difference
I'm using unlit node in URP
is the split node different now in URP, or are you collapsing it somehow to only show the output you are using?
collapsed, I always collapse all my nodes
oh, I see it now, it's on the top right
I would love for shadergraph to have a screenshot button
exporting your whole graph has a crisp high quality image
Maybe possible through an editor script ๐ค
yeah, unreal has this ability to save your node graph as a text file, so you can 'share' it really easily, you just copy the text and paste it in the editor
yeah, unreal has this ability to save your node graph as a text file, so you can 'share' it really easily, you just copy the text and paste it in the editor
@rustic dragon Guess what the Shadergraph asset file is.
ah, so it does do that
the .shadergraph file extension is a JSON text file c:
they're not super human readable at the moment
but definitely shareable text files
i would like to have better copy paste to json for it but its working for the moment
@devout quarry yea, it looks like we are talking about different things, because that doesnt work for me
this is what im trying to use
the middle brush, the one that just paints colors works fine with the example shader, but no matter what i try, the texture shader always tells me that it isnt supported
@terse nexus did you look at the book of dead project? it uses hdrp with custom terrain shader, might get you started.
Hey there, just downloaded a skybox package from Assets Store, first time changing Skybox, where do i do this ? Like i now have some files with 6 image each
Don't really know in which channel to ask that so i guessed here would be appropriate, sorry if not
Open the Lighting window it should be right at the top @ivory dock
Anyone know how I could write a shader (or otherwise) to easily create paths like this using a single mesh? Made them as tiles but if I could get just the grass edge with the shadow to repeat along the edges I could get the effect I want.
Would save me a lot of time making dirt paths ๐
Just not sure how it would wrap along corners
I'm on it, how do i create Skybox from my 6 files now ? looks like this :
You should be able to make them a Skybox in the texture and material settings
make a material for each skybox and make sure the texture is marked as a skybox
@willow pike if the shape of that is not determinant it might be tough in a shader unless you made some sample 'texture' prefabs of dirt paths
Worked fine, thank you bro ๐
Ahh yeah, I guess I'll probably end up making a bunch of different path types using prefabs
Was hoping I could just draw out the paths using planes in Probuilder and slap a material on them. Probably wishful thinking
the edge work would be a problem, hard to really control
you could probably do it with some gradients and some polygon meshes with some edge loops around the edges that would help inform the edge stuff
Interesting, well it might be above my skill level atm. Just wasn't sure if there was a simple way to do it in Shader Graph I hadn't realized. Thanks!
@willow pike make a C# script to combine them on build automatically, thats what they did in monument valley
Hi, I'm using shader graph in URP. Is Overlay not support in render queue?
Good idea @faint notch I saw that video where the dev of MV talked about how they did that. Iโll have to see if I can pull something like that off. Iโve been using visual scripting for everything so far. More of an artist than a developer ha.
I'm fairly confused by the shader manual on unity's website. could someone point me in the direction of some resources that will provide me with a good rundown?
There are some resources pinned to this channel
not sure what exactly you're looking for
Hey, I'm thinking of practicing mapping textures to meshes using a technique that I've heard about, but am not sure what it's called. The idea is to colour a model according to a material type, then for each colour, paint over that colour with some other texture. So for example, "red" parts might represent wood where "green" parts might represent metal. Does anyone know what I'm talking about?
vertex coloring as a mask
so you can paint vert colors on the models verts, RGB like you are saying, then in the shader you can use the vert colors as a mask to lerp texture layers together
@rustic dragon Right, does this technique have a specific name?
Or is that just it?
Okay, thanks! I was looking for a starting point so I could at least speak the same language as others on the subject.
Apart from hooking up a PBR graph linearly like this, for what reason would my cube appear so dark with a directional light facing directly at it?
I'm using the HDRP example scene metal textures.
The subgraph is also linearly passing those textures through. Metal, occlusion and smoothness are RGA channels respectively. I've checked 1000x that everything that I just said is exactly how it's set up in my project.
More information: I've reduced the inputs to just diffuse and normal maps, and the lighting still looks wrong. The better-looking cube is a material packed with the HDRP default scene.
@willow pike if your not used to programming, you could try probuilder and progrids, there is some built in functionality to combine meshes there.
does exist a way to invert the fresnel effect?
I remember that adding a -1 somewhere will generate that effect
@silk sky Just use one minus?
oh its actually a node
thats just showing you what the node outputs, think of it as a mask
if you multiply by a color for example green, your gonna get a green glow from center - the inverse of a fresnel which gives you green glow on edges
okok
@vocal narwhal wdym tiling
and i just plug that into the UV of the noise , right?
Is it possible to change render queue to overlay in shader graph using urp?
@faint notch shadows are appearing but am still getting weird results ?? https://gyazo.com/19f105f2a5689019b508bf68d3a5c7dd
i changed the distance value for shadows in the urp renderer and it seems to fix the issue however the shadow quality decreased, there is 4 cascades btw. How can i maintain the shadow quality
i dont want it to be pixelated
@tranquil bronze
@tranquil bronze yep! that is whats causing it
are you developing for mobile?
all platforms
set distance as low as you can for your game without losing shadows, if you are on mobile i dont think you can use cascades, might need to look into alternative solutions as the sharp shadows for LWRP/URP on asset store
so mobile too
can i change the distance value via a script?
depending on how far away the camera is
yep
ok thanks :)
But as i mentioned you might not get cascades on mobile right, so might be worth to look into other solutions if that is something you want to include
Is anyone familiar with normal maps in Shader Graph? I know how to combine vertex normals with a normal map in a shader, but I'm unsure how to properly achieve that in a shader graph with custom lighting.
I know you can normally just plug a normal map into the Normal input on a master node, but I have custom lighting calculations, and so I want to get world space normals manually and pass them in.
I got a world-space normal out of the texture with some trial-and-error, like so:
But the vert normals aren't being normalized per-vertex, so the results aren't quite right. I could add a Normalize node after, but the whole thing seems hacky. Is there a "proper" way to get world normals, or is this pretty much it?
this might have been asked before
but how do i recreate water ripple effects
im trying to get a scene where a plane is hovering over a plane
what is a simple of achieving it effectively ?
@grand jolt Plane hovering over a plane? What does that have to do with water ripples?
You mean an airplane hovering over water?
Airplane hovering over a planar surface, I assume.
Hi everyone, i wanted to ask a quick question. Is there an easy way of implementing effect shaders to apply on meshes on top of their own materials? For example: When a character is under the effect of a healing status effect they get a green fresnel effect. Implementing the effect for every material in the game is a lot of work and not expandable so I was wondering if its possible to just create the effect as a seperate material and apply it on top of other materials. Thanks!
from what I know, not unless you have another mesh on top of the other one
what you'd need to do is include the shader math to include when the spell is on, and then enable enough parameters to get you any type of spell affect (parameters, masks, et), then in script get the spell parameters and set those in game
Ah, okay. Thats what i wanted to avoid. Adding a new effect would mean going over every material one by one, which is pretty bad if there are a lot of things that can have that effect
Thanks
yeah, it can suck, if you are using shader graph, you can make a subgraph that acts as a pass through on all your new materials (old ones, etc), then in that pass through subgraph, you can add all the new fun stuff when you can, then it will propagate throughout your materials if they have that subGraph implemented
@tall gull You can add the special effect material as a second material (yes, mesh renderers can have multiple materials). What that will do is it will render the mesh multiple times for each material there is.
I tried that first but it seemed like it doesn't function well, not sure tho
a lot of clipping etc
Hmm, that shouldn't happen. Did you have multiple mesh renderers or just one with multiple materials, like I described?
I've done this myself, with a fresnel glow effect as well
No issues
This is without any scriptable render pipeline, I don't know if it's any different in LWRP or HDRP
you can't have multiple mesh renderers, at least I cant with my build
You mean multiple materials?
ah, saw you say multiple mesh renders
each material will only render on it's specific triangles from my experience
each submesh
Yeah, that is if you have submeshes. If there are no submeshes, it will render the same mesh again with that second material
ah interesting
Seems to work fine in LWRP, too
I wonder if it's literally 2x the cost
Versus doing the fresnel in the one material?
with or without any transparency on the upper layer
yeah
I imagine if the 0 material is opaque, and if you did a translucent material in 1, if it'd just be opaque
In terms of CPU cost, then kinda since it introduces an extra draw call
Yeah, the glow material is a transparent additive blend just doing fresnel.
In my case, anyway
probably be cheaper to do it in one material, though it's more hassle for sure
For GPU, it will cause overdraw where it could have been avoided by doing it in the one material
If you can manually render stuff in Unreal, then it's just a case of rendering the same mesh again in the same place with a different material
It just happens that Unity has this kinda undocumented feature of rendering the same mesh multiple times
It would be possible to do in script, too
yeah, instead of a swiss army shader
though 2x the cost would not be welcome at work, I should do a comparison, I wish unity had some overdraw and shader cost visualization modes
The fresnel shader is super simple, almost everything in the vertex shader. That reduces the cost of the overdraw a lot, which is how we got away with it even on mobile
The most significant cost is on CPU
but overdraw would be 2x
Well, it depends how complex the pixel shader that is shading that pixel
And how many pixels on screen
There's probably some overhead to just draw onto a pixel, regardless of how complex or simple the shader is, but it doesn't seem to be much.
I never did any proper profiling on it though
the triangle count with stats with just the sphere (alone in the scene) goes from 4.8k to 5.5k
and verts, damn
actually more with two default-materials
True. This technique is quite similar to how the built-in renderer does additive lighting. It renders the meshes with the base lighting, just directional and baked lighting, and then draws the mesh again with additive lighting drawn on top.
yeah, exactly the same reaction to if I duped the sphere, makes sense
If you have many objects using the same additive glow material, then there won't be 2x SetPass calls, since Unity can draw all the additive glow materials in a row.
So it's not quite 2x on CPU, unless you only have one object using this technique.
But it is always 2x triangles and pixels
does anyone here have experience using depth based edge detection?
I'm trying to create a Black and White floorplan effect and I seem to have gotten really close but it falls apart on faces that are angled, instead of a nice outline it creates a stepped effect, (forum post with current code in it: https://forum.unity.com/threads/possible-to-hdrp-edge-detect-each-object-and-show-overlapping-objects-floor-plan-effect.804540/#post-5349783)
this shader based on roystan's tutorial?
I guess you'll need to change the sensitivity based on the angle
and so in the floor plan these objects are like desks or something and they are slightly tilted right?
lower your depth threshold so the small depth differences don't get picked up and use the normals, could be a solution
or you calculate whether or not a pixel belongs to a surface that is somewhat facing the camera, then turn down the depth sensitivity for that pixel
a dynamic threshold/sensitivity based on surface angle would be a good solution here I think
Wouldn't it be a lot more robust if it was based on scene normals?
Eh, I say this with no experience in edge detection shaders
yeah adding normal based detection is nice, but this could be done with depth only too
I'm not aware of Roystan or their tutorials, it was modified from the TIPS effect on the alelievr repository that a Unity staff member directed me to, I will look them up.
yes the circled parts are control panels that have about a 7 degree angle to them
I have 0 experience writing shaders haha didn't even know you could do that for some of them, I will try to implement those changes, thank you for the advice!
okay hold on
read this
especially section 3 but I recommend reading the whole article
He explains changing depth thresholds based on view direction
I'm fairly sure this will solve your problem
wow thank you very much!
and tbh like mentally mentioned it would be worth it to try out normals based outlines as well
you sample them the same as depth
then use max(edgeNormal, edgeColor)
and so then a pixel will be either an outlined pixel because of a depth or a normal contribution
and that way you could turn down the depth sensitivity until it no longer picks up the depth discontinuities on the slightly tilted surface, and let the normals handle the work
ah okay, thanks! I will dive into this tutorial and see if it solves my problems
good luck, I'd be interested to see the result so feel free to tag me
dumb question but do you still use #include "UnityCG.cginc" for renderpipeline shaders? edit found the replacement
Can anyone suggest reading material on writing fast compute shaders? I'm considering using compute shaders for an aspect of my game's AI but I'd like to determine if it's even worth trying first
@dapper pollen yeah, that's legacy thing
usually if you put that into SRP shader, you are in a whole lot of trouble ๐
yeah, im really out of my depth with shaders and renderpasses ๐
Anyone good with ASE?
For mesh particle instancing, does ASE support vertex color and UVs?
a vfx guy here is having some trouble getting it working.
for ASE, you'd probably get better luck on asking about it on amplify's own discord
they have quite active staff and community there
@mental verge
@grizzled oriole What kind of computation are you planning on doing in the compute shader?
thank you, @fervent tinsel I initially threw that question over there, but didnt get a response within an hour, so thought I'd put it here just in case. thx! sorry for being impatient!
I got an interesting question
Can you put a pbr shader to the skybox?
I mean pbr graph shader
No
Not even any other custom shader?
I wanted to give the skybox a sinusoidal wave like movement
Depends on what renderpipeline you're using.
In HDRP there is some doc to write your own sky
i followed this tutorial in brackeys
https://www.youtube.com/watch?v=szsWx9IQVDI&t=32s
the shadows are rendering on top of the player (the blue capsule) how do i fix this??
Let's learn how to render characters behind other objects using Scriptable Render Passes!
This video is sponsored by Unity
โ Download Project: https://ole.unity.com/occlusiondemo
โ More on Lightweight: https://ole.unity.com/lightweight
ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท...
@native garnet you can put unlit graph to custom mesh that has faces inside but you'll not get renderers sky feats from it (ambient light etc)
It is not the intended way but could work still, depending on your application
Exactly what I do in my projects 0lento
Have a sundisk follow the directional light direction
Shader graph question: anyone passed Texture2D/SamplerState to a custom function before? I can't seem to get it to use the texture's default sampler.
On the custom function node, I'm passing in the texture, but nothing for the sampler - in the texture's import settings, wrap mode is Clamp, but when I sample it in the custom function, it's Repeat. I can create an explicit SamplerState node and pass that in, but I want it to use the texture's default sampler in case its import settings change (and for future reference, of course).
@graceful lotus As far as I know, you can't obtain the SamplerState created for the texture2D passed into the function. However, one is created for each texture property created, using the "sampler" prefix. (e.g. If the property has the reference "Tex", the sampler will be "samplerTex"). If you always know which texture is being passed into the function, you can do something like this to use the sampler for that specific texture (and use a default one for the shadergraph preview, as it will error otherwise).
This isn't a perfect solution of course - it requires a specific property to be used, and won't work if you switch the texture input out for a different texture property. Hopefully it gives some ideas though. (Alternatively, you could use the Sample Texture node and pass in the Vector4 result, assuming you aren't sampling the texture in a loop. Or if you are using the custom function to manipulate the UVs, perhaps output the Vector2 UVs to then be put into a Sample Texture node rather than sampling it in the function).
You make a good point - indeed, it's a look-up texture so I know the name and could assume the name of the sampler.
And yes, I'm sampling it for lighting calculations, so it's in the "additional lights" loop, and can't be done within shader graph itself. :/
Until they add support for looping or returning multiple values.
Thanks!
I particularly like that this removes the SamplerState as an argument, that sure was bloating the function signature.
For that matter, do I even need to pass in the texture? I could just sample it by name too, or will Unity think it's unused and strip it out?
Well, I think it still needs a SamplerState argument, as if you try to use "samplerTex" in shadergraph it will error, hence the need for the #ifdef SHADERGRAPH_PREVIEW. I suppose if you are writing the function via code though, you could create a temporary sampler though? (like the "SamplerState my_point_clamp_sampler;" example in https://docs.unity3d.com/Manual/SL-SamplerStates.html)
Also I could be wrong, but I don't think the blackboard property values get stripped out, even if you don't use them.
Oh of course, I believe you're right.
So yeah, you might not need to pass the texture in. However, if you don't pass it in the preview won't be able to access it, assuming the preview is important.
If the preview isn't important, then you could just pass out float3(1,1,1) or something.
In my case it's not, since I can't #include other files to use the Light/BRDFData structs, so the preview is already useless to me for this shader.
Exactly.
@graceful lotus Hmm, I could be wrong but if you specify the function in a file, you should be able to use #include.
Oh or do you mean for the sake of the preview?
Yes.
Ah I see ๐
In the preview, it was giving "redefinition of _Time" and other errors, so I couldn't include the Light struct for example, which I use in my lighting calculations.
So the preview is already just unlit albedo.
Ohhh, I think the texture property exists, but it thinks it's unused, so in the compiled shader there's no Texture2D _MyLUT declared.
So, I do need to pass the texture into the function... or at least use it somewhere so it gets included. ๐ฆ
It worked - I was just testing the function in a written shader, and had to move my custom file's #include to after the LUT is declared, so it can find it. ๐
It's beautiful, hooray!
Here, have a fleshy ceiling light. ๐
Custom lighting with approximate sub-surface scattering.
...I just grabbed the first complex mesh I could find to test it on.
just because you can create such a thing doesn't mean you should . . ๐
Haha
@low lichen I want to simulate a grid in a match-3 puzzle game. Or, rather, lots of them, because I'm writing an AI that will be planning a few moves ahead
I'm having an issue where I'm moving 2 identical textures at different speeds and overlaying them. Periodically they line up and you see like a 'flash' because the intensity is doubled. I tried fixing it with a minimum function but it does not seem to work like intended..
You'll see a brief flash in the preview right
Can you also rotate one of them, so they never line up?
Maybe just flip the uv coords?
How can I convert this into unity nodes?
@devout quarry If the noise is between 0 and 1, when they line up both sample textures will return 1, so the minimum is 1.
or just scale up the 2nd one, in addition to rotation and/or flipping
A simple 45 degree rotation would do enough to never make them line up right?
Literally any rotation/scale will prevent them from matching up.
I think scale would be cheaper, you can save like .0001 ms!
Then I'll scale ๐
Depends on the visual result you're going for - obviously scale will increase (or decrease) the noise grain size.
do all the transforms
You could flip the UV coords to mirror one sample too; maintain grain scale and prevent lining up.
Thank you all
How can I get the scene luminance in shadergraph?
could I extract it from the scene color?
Ah! there is function 'Luminance' that converts rgb -> luminance, perfect
@grizzled oriole Do you have some algorithm in mind that can be run in parallel in a compute shader?
I would like to create a vertex displacement by using a texture, can somebody help me?
@low lichen Basically, porting this Burst job I wrote https://pastebin.com/zJygzbB6
The data going in to the GPU would be:
- One copy of the game's block grid (an 8x20 byte grid, basically), copied locally by each GPU thread as needed
- A list of actions to consider, grouped in triplets (because the AI looks up to three moves ahead); not sure how big each triplet will be but I'm shooting to get it under 8 bytes
Data coming out of the GPU would be:
- A score for each triplet (probably 32 bits each but I could probably do 16), and then the CPU will look at each score and tell the AI what to do next
@silk sky in shadergraph?
yes
@low lichen As I understand it:
Pros:
- Not executed every frame, probably more like every second or so
- Each block grid prediction is independent of the others
- An individual prediction doesn't need a lot of memory (but there will be a lot of predictions)
Cons:
- Lots of branching
- Lots of loops (mostly fixed length, but one of unknown length)
- Math is entirely integer-based, not float-based
What I want to know is:
- Are there pros or cons I'm not seeing?
- Are any of these cons (including ones I don't know of) enough to sink my idea, or is it still worth putting the time in to implement and test it?
@grizzled oriole Are you okay with the data coming back possibly coming in a frame or 2 after the compute shader is dispatched?
@low lichen Yes.
As long as I can reliably tell when it's done executing. And as long as I can make it faster than my existing Burst version
(Though I may still need to use Burst for parts of it anyway, in order to prepare the buffer to send to the GPU.)
@silk sky
The 'trick' is to use the Sample Texture 2D LOD node instead of just Sample Texture 2D
ok thanks
Because Sample Texture 2D is a pixel shader node
Sample Texture 2D LOD is a vertex shader node
@grizzled oriole So you're not using any jobs or threads currently? Just Burst?
ooh ok
@low lichen Well, yes, Burst and the Job system
but is this displacement only for one axis?
@low lichen What I'm trying to determine is if there's a possibility that using a compute shader for what I want to do would be faster (so I can make my AI smarter). If there's a possibility, I'll try it and find out for sure. But I'm not gonna do it if there are red flags in my plan that I'm not seeing
The more threads you make use of, the better
You can do the displacement however you want, in my example it is for the y axis only
ok
@low lichen Yes, of course, but these threads will have a lot of branching and loops. On the CPU, that's fine. On the GPU, less so, but I don't know if that's a deal-breaker.
@grizzled oriole I don't understand exactly what each job is doing here. Is it being run for each cell of the grid? Why are there so many for loops in the SimulateGrid method?
@low lichen My game is a match-3 game. When 3 or more blocks of the same color are matched horizontally, vertically, or diagonally, they disappear. The blocks above them fall down, and when they land that might in turn cause new matches.
4 loops because I have to check four directions (W-E, S-N, NW-SE, SW-NE)
One outer loop of unspecified length because I don't know in advance how many chains there will be
Oh, also, there are garbage blocks that don't match with other blocks, but are cleared when any non-garbage block next to them is cleared (if you've ever played Puyo Puyo, exactly like that)
And how many jobs are you running in parallel now?
One job with (number of parallel threads) - 1 threads
My CPU is a hyper-threaded quad-core, so in my case 7 threads (I leave one for the main thread)
I also use Burst for some other related jobs (e.g. to decide which actions the AI should consider, and to pick the best one after they're all simulated), but those related jobs operate sequentially so I don't see much of a point in putting them on the GPU
Are you planning on running the compute shader for each cell of the grid? Like each pixel of a texture?
Yes but it's a small grid (just 8x20). The issue isn't the size of the grid, the issue is that the AI will have a lot of choices to make (and therefore predictions to simulate)
Each thread evaluates one prediction, and I imagine on the GPU the same would be true
Doesn't sound like a task that the GPU would do much faster than the CPU, unless I'm missing something
Can you tell me your understanding of my problem?
I guess that's the problem, I don't have a very good understanding :P. So you're running 8x20 jobs currently?
No.
I'm running one job with thousands of predictions to evaluate. Each thread simulates one prediction
My understanding of the C# job system was a job = a thread. Is that a misunderstanding?
Sort of. One job == one to-do list. If that to-do list is big, it's often run on several threads
If the to-do list is small (but the item itself is big), it's just run on one thread (but in the background so it doesn't stall the main game)
So it's somehow automatically splitting a big synchronous task into multiple threads? How does that work?
It's not. It's splitting a bunch of small tasks into multiple threads.
I could split a single big task (say, sorting a big array) into multiple threads with the job system if I wanted to, but I don't.
Are these small tasks defined in the pastebin you posted?
Yes
The big complicated function is that task, but it's being run thousands of times
Many thousands. I haven't taken a count in months, but it's big enough that I have to artificially limit the number of predictions (i.e. the number of times that the job I linked is run)
The mean reason I'm considering moving this to a compute shader is to see if doing so would allow more predictions (and therefore a smarter AI)
SimulateGrid is simulating the whole 8x20 grid at different states?
Yes
Well, one state in that function call
Maybe if you play the game it'll be a little clearer? https://corundumgames.itch.io/chromavaders
Right, but each run is of a different state
Yes, that is correct
Each run is also independent; I just need to give each run a score (through means specific to my game) and later on I'll make the AI do whatever caused the run with the best score
So you say this function is being called thousands of times. Is each thread calling it multiple times then or are there thousands of threads?
Thousands of threads, if you want to think of it that way
(Technically just a handful of threads sharing the load amongst themselves, but that's an implementation detail of the job system)
So how many threads do you plan on running? I'm thinking of the Dispatch method specifically:
https://docs.unity3d.com/ScriptReference/ComputeShader.Dispatch.html
A lot more than 7.
I could if it would help
There's a specific resolution that you have to choose, though. If you wanted to run a compute shader to turn every pixel of a texture to red, you'd run (width, height, 1) threads
So there's one thread for each pixel of the texture
Then in the compute shader, you get this index which you can use to write to a texture or a cell of a grid
Yes, that's right
Even though my list of predictions is logically a 1D list, I guess I could treat it as a square or even a cube, even if I need to pad it at the end so it'll factor into 2 or 3 divisors nicely
So each prediction will run the SimulateGrid function to compute the resulting score?
Yes
And you keep simulating until the combo has ended, if there is one?
That is correct
I do it up to three times, because the AI will look up to three moves ahead
You mean up to 3 separate combos or up to 3 matches in a row?
I assume the former. The AI simulates doing an action and that might end up doing a 10 match combo, then it simulates a second action and that might lead to 1 match, then simulates the last third action?
It doesn't sound super compute shader friendly. In theory, one thread could run for 100 iterations (if it's a really long combo) and another thread only 1 iteration, if there was no match?
Yes, that's correct. But definitely not 100 iterations (because the grid is small). I haven't yet come up with a worst-case but probably not more than 10 iterations
The reason I'm even considering a compute shader is because each invocation is independent and doesn't need a lot of data (and doesn't output a lot of data)
I can't say I'm confident enough about this to advise you to not at least test this. If you have the time to spare to convert this to a compute shader, why not
But I don't know if one of these considerations significantly outweighs the others.
So what are you saying: Worth trying, not worth trying, or unsure?
My gut tells me that the amount of branching and unknown iteration count will make this unfit for a compute shader, but I don't have enough experience to tell you straight that it isn't worth it
I think @dark flare will know better than me.
๐ฆ how far up should i scroll for this
whats the question?
You want to answer that @grizzled oriole?
ping me when you have a single message with question pls lol, at work atm
cant read the whole discussion
Sorry about that, I'll let @grizzled oriole decide if they want more answers.
@dark flare The aforementioned Pastebin contains a Burst job that I am considering porting to a compute shader. On one hand, the job is embarrassingly parallel and individual threads don't need a lot of data as input or output. On the other, there's a lot of branching and loops, and one of the loops isn't of a constant length. My question: is there enough of a chance that a GPU port of this job would outperform a Burst version to warrant a benchmark?
If so, then I can make the AI smarter by making more predictions
Just try it lol. Depends on your hardware, although recent hardware doesn't have such issues with branching. If you can gaurantee loop length you'll get some milage though
If you have it working in a burst job it should be trivial to port and test
If it's for a game, I'd be concerned with the latency of reading it back. Unity doesn't have a way to immediately run a scheduled compute job and return, it has to flush the GPU queue and wait
They have asyc readback for data but it can get delayed multiple frames
That's fine, the job doesn't run every frame (probably every half-second or so)
@dark flare Okay, I'll benchmark it and try it. It sounds like there's no immediate deal-breaker, which is ultimately what I was trying to ascertain. Thank you. And you, @low lichen
why does fresnel not really work on cubes?
It's based on the difference of the normal to the view direction
so basically the surface has to be curved?
I mean, you can see that the parts of the capsule that face the same directions as the cube share the same colour
So it's working exactly as expected
@mild sleet what effect are you trying to achieve?
An outline glow/highlight sort of thing (similar to how it looks on the capsule)
What is a good approach to create/draw masks in shadergraph?
I've used a rgba mask for tinting and controlling different materials areas on the model in my shader, but I need even more control. For example I'd like to control emission on a,b,c on this illustraton independentlly.
As the location of a,b,c on the texture will not change, I guess i could somehow draw those masks directly in the graph?
..Or simply put, how do you create a square in shadergraph?
D'oh!
@mild sleet you could do it depth based http://alexanderameye.github.io/outlineshader.html
The hlsl shader file for the custom function node is the relevant part for you I think
Thanks, I'll check it out :)
I need help
I'm making something like a glow effect inside a transparent crystal using a reverse fresnel
how can I make so the property "Power" change it's value over time from X to Y and vice versa?
you want it to pulse?
hello, I think you can push a time node into sin or cos to get a range from 0 to 1 that ping pongs
doesn't go up and down or pulse, just rises then back to the start
oh, I think the way you have it @silk sky should actually work, does it not?
I'm trying, it does in the graph but not in the scene
maybe I just have to adjust values
yep it works now
triangle wave is a bit more exactly like a ping pong
the sin one kind of lags at 0 and 1
Now im trying to make only 2 propertis for control Min and Max
in your remap?
yes
i made it ๐
like this, I know it's dumb stuff but for me I so satisfying when something works on the first couple of try
here we go a lil issue
I playing with value between 0 and 1
0.2 and 0.8 seems ok but if I lower the max sometimes the fresnel generate a strange result like a negative color
clamp or saturate the value
even if its a vector 2 or should I do it before?
basically after you do math on something, before it goes into a slot, it's safe to saturate unless you really know you want to go above and beyond
Ok maybe havent figured out precisely what In Min Max and Out Min Max are. I tought they were a X to Y and Y to X values but that doesnt make too much sense
@silk sky If you're confused about what the Min/Max values are in the remap node, this might help. The remap node is equal to doing a Inverse Lerp & Lerp like so : (using UV.x as an example input)
- Note that if your In Mix Max is 0 and 1, the Inverse Lerp node will not actually change the values at all. So rather than using a remap, you could use a Lerp node.
- And if the Out Min Max is 0 and 1, the Lerp node will not change, so you could use a Inverse Lerp node instead.
If you are unfamiliar with Lerp & Inverse Lerp, this is a good twitter thread : https://twitter.com/FreyaHolmer/status/1184218791334612999
a thread on Inverse Lerp - a super useful, yet often overlooked function!โจ
Lerp( a, b, t ) = value
InvLerp( a, b, value ) = t
โข lerp returns a blend between a and b, based on a fraction t
โข inverse lerp returns a fraction t, based on a value between a and b
#unity...
243
1272
Still very new to shaders + shader graph, I have a basic dissolve shader which works on a solid albedo color. Looks great on a cube, however I now want to transition it to dissolve a model with its own material, texture. I also want this to happen at runtime. This is my current idea, but are there better ways?
- Have 2 materials, standard - and dissolve. The dissolve shader will need to be updated to have all of the properties of the standard shader
- At runtime, switch out these materials when I need to use it, switch back afterwards
Secondly, recreating all of the properties on a standard shader seems like a lot of work - is there any way to just "extend" the lit shader (for example)
Hey, wondering what the most efficient way to pipe 20736 bytes(192x108 10x10 tiles on a 1080p screen) into a fragment shader per frame. Trying to rig up an ansi-terminal style renderer and have the tile selection pretty much figured out, but need some way to map what character is set for which tile. I'd use a VBO, but apparently from what I've read on the forums they don't seem to work or something
@dim river
so you want an object to dissolve?
Why does a simple dissolve not work on your object?
You can make the shader so it has an albedo texture slot
Right, but there's also a ton of other properties from the URP/Lit shader that might be being used, base map, metallic map, normals, occlusion, emission, tiling, offset, shadows
True
Personally, if it was my project, I would see what exactly I need in my shader and just create it from scratch, but if you need pretty much everything the lit shader offers, it doesn't make much sense to build it from scratch of course
@lime meteor Is it data that can be encoded into a texture?
but honestly, base map, metallic map, normals, occlusion, emmission, tiling etc can all be done fairly easy in shader graph
If you use all the slots of the PBR master node you will have a fairly advanced material already
yeah, a 192x108 texture would be ideal but there's got to be a decent way to blit to it like a canvas. Trying to essentially port the entire ansi controlset to unity
@lime meteor Maybe Graphics.Blit is what you need
Using already attached to my main camera to pass through the shader
https://i.imgur.com/0T6aEoM.png this is what it's got me so far