#archived-shaders

1 messages ยท Page 132 of 1

orchid peak
#

for anyone not familiar, UE4 has a way more developed graph tool for shaders/materials

rustic dragon
#

and the one I am on now, but the teams are generally like 50 to 70 I think, smallish

devout quarry
#

what do you find the most lacking in shader graph compared to unreal's material editor?

rustic dragon
#

@devout quarry not much really, some reroute nodes are good, the subgraphs are a bit easier to manage

grand sun
#

ue4 also has blueprints which is super helpful for tech artists.. i'm confortable with them but with unity its a lot of programming

rustic dragon
#

yeah, I hope unity's visual scripter is good, but I heard it's only for DOTS

grand sun
#

it will be a few years off from what i've heard

rustic dragon
#

@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

grand sun
#

@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 ๐Ÿ˜„

rustic dragon
#

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

orchid peak
grand sun
#

oh so it sped up!

rustic dragon
#

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 ๐Ÿ˜ฎ

grand sun
#

last i heard from the peeps at unity, it was quite some while off

orchid peak
#

yeah, I still wouldn't expect it for years. DOTS only would also be kinda odd

devout quarry
#

I do think it is DOTS only

regal stag
#

@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?

rustic dragon
#

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

regal stag
#

Ah okay yeah

crimson stone
#

guys i got the emission to work

#

it seems to need that shadergraph emission node

rustic dragon
#

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

crimson stone
#

thanks for your help anyway

rustic dragon
#

I tried that node too, so there were no other tweaks?

devout quarry
#

emission node?

regal stag
#

I think I had emission working without the use of that node, but if it's fixed that's good

#

HDRP thing

devout quarry
#

ah

grand sun
#

Should i frac _Time so over time the value doesnt get too huge? or wont make a difference?

rustic dragon
#

isn't frac to make something repeat from 0 to 1, no matter the increasing value?

regal stag
#

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.

grand sun
#

yeah which is normally all i would need if im offsetting something in 0 - 1 space

low lichen
#

@grand sun I think it'll take some days before _Time.y becomes less precise.

rustic dragon
#

not really, if you want 0 to 8 to be in 0 to 1 space, use Remap

grand sun
#

oh i totally forgot about the _Time channels ๐Ÿ˜„

low lichen
#

The faster channels will obviously become bigger faster so less precise faster.

grand sun
#

so not worth doing a frac then i guess

#

thanks!

low lichen
#

Well, it'll become less precise the bigger the number. What I meant was it'll take some days before it's noticable.

grand sun
regal stag
#

Pretty ๐Ÿ˜„

grand sun
#

i thought it would give a greyscale value from 0 - 1

#

๐Ÿค”

regal stag
#

_Time is a float4

grand sun
#

oh yeah

#

forgot to .yyyy

#

or is there a better way to write it instead of that

regal stag
#

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?

grand sun
#

thaats true, i was just doing this as a test ^^

rustic dragon
#

what are you trying to do?

grand sun
#

just playing around with things at the moment

#

but making a shader for tubes/pipes that offsets vertices in a cartoon buldge effect

rustic dragon
#

heh, nice

#

love doing that kind of stuff, especially messing with vert offsets

grand sun
#

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

rustic dragon
#

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

grand sun
#

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+

#

๐Ÿค”

rustic dragon
#

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

grand sun
#

ah yeah

regal stag
#

Having UVs beyond 0 to 1 might make texturing harder though, if certain parts need to be textured differently.

rustic dragon
#

UV2, not UV1, it's basically a data set

regal stag
#

Ah right

rustic dragon
grand sun
#

if uv1 has nothing, what exactly is the info thats in there?

rustic dragon
#

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

regal stag
#

The UV nodes in shadergraph output float4s. I would assume it's the same for code.

rustic dragon
devout quarry
#

@rustic dragon

rustic dragon
#

yo

devout quarry
#

did the same a while back

#

using vertex colors

rustic dragon
#

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

devout quarry
#

looks clean!

grand sun
#

oh yeah i saw the same with vertex colours

devout quarry
#

I like it

grand sun
#

but vertex colours are quite a nice place to put a lot of other data in

rustic dragon
#

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

grand sun
#

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

low lichen
#

There are 3 extra uv channels to play with

rustic dragon
#

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

grand sun
#

but for gameplays sake, thats actually better

rustic dragon
#

@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

low lichen
#

@rustic dragon Ooh, cool!

grand sun
#

guess you would do a different solution all together then haha

rustic dragon
#

speedtree uses all 8 of the UV channels, very bloated and expensive assets ๐Ÿ˜ฎ

grand sun
#

damnnn

#

why?

rustic dragon
#

wind and rustling

grand sun
#

couldnt it be done all in the same one?

#

i guess not if they have to use all 8 but.. ๐Ÿ˜„

rustic dragon
#

to really layer it, not really, but 8 is excessive

devout quarry
#

@rustic dragon have you worked with any really big shader graphs?

#

with lots of properties

#

I'm talking maybe 40+ properties at least

grand sun
#

would you want to?

rustic dragon
#

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

grand sun
#

๐Ÿ˜‚

rustic dragon
#

@devout quarry I have, character customization got quite silly after a while

grand sun
#

ah you're right i guess

devout quarry
#

how was performance for you?

rustic dragon
#

but beyond parameters, a lot of spaghetti graphs for sure ๐Ÿ™‚

devout quarry
#

adding/editing a new property takes a good 2-3 seconds...

#

super laggy

rustic dragon
#

parameters area actually quite costly we found out late in the project ๐Ÿ˜ฎ

devout quarry
#

ah damn

rustic dragon
#

yeah, each instance of the material gets it's own values, so that had to be stored/streamed/destroyed

devout quarry
#

tradeoff between performance and usability then I guess

rustic dragon
#

yeah, it's a fight

devout quarry
#

ah alright but if it's for 1 object it should be all right?

grand sun
#

i guess not if that 1 object takes up all your budget

rustic dragon
#

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

devout quarry
#

yeah that's good way to think about it

rustic dragon
#

that can happen, but it's mostly the 5000 friggin' rocks, even collision starts to add up due to the instances

devout quarry
#

I really am writing all these tips down by the way haha

rustic dragon
#

๐Ÿ™‚

grand sun
#

but rocks rock

rustic dragon
#

they roll too

low lichen
#

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.

rustic dragon
#

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

low lichen
#

Overdraw and shader complexity has been something I've been having to optimize a lot for a mobile VR game.

rustic dragon
#

add to that decals, grass and particles, it can be a render mess

#

yeah, do you do LODs on the meshes @low lichen ?

grand sun
#

like how grass in breath of the wild tanks the frame rate

rustic dragon
#

not sure with memory mobile can afford them

low lichen
#

@rustic dragon No, but it's a small area you're in. Usually never any object over 15 meters away from you.

grand sun
#

can you get away with using LODS in mobile games? usually the fixed camera angle would cull a lot i guess?

rustic dragon
#

@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

grand sun
#

feel like they might not be used so much

#

oh yeah

rustic dragon
#

yeah, LODs are really only for 3D games, they help with tri counts, and on skinned meshes, they reduce the amount of skinned verts

grand sun
#

i love unreals LOD maker

rustic dragon
#

yes, it's great, better than Simplygon ๐Ÿ’ฉ

#

unity really needs to invest in some LOD systems, including HLOD

grand sun
#

question now.. im just gonna use a texture input for the scrolling vertex offset

#

ah nevermind

#

gonna try something first ๐Ÿ˜„

grand sun
#

and im struggling haha

#

How can i offset vertices using a texture in shaderlab?

low lichen
#

@grand sun You mean like a heightmap?

grand sun
#

yeah

#

tex2Dlod i guess?

low lichen
#

Yeah. tex2Dlod is necessary because you have to specify which mip map level you want.

grand sun
#

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 ๐Ÿ˜‚

rustic dragon
#

cheat, mock it up in a visual editor then see what it does in code

grand sun
#

ahha yeah ๐Ÿ˜„

devout quarry
#

is making shaders with a visual editor generally seen as a 'easier' or a 'lesser form' or making shaders

low lichen
#

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

devout quarry
#

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

low lichen
#

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.

charred depot
#

how would i go about making stars sloat towards the front of a object, like passing through space?

low lichen
#

@charred depot Are you looking to do this in one shader pass or are you open to using particle systems?

charred depot
#

would i be able to do this in a particle system tho? ive seen it done only in shaders

low lichen
#

What about the effect makes it impossible to do in a particle system?

charred depot
#

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

grand sun
#

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!

fervent tinsel
#

re: LODs

#

but there's no real info if that's something they'll go further with

#

it supports old Unity Simplygon plugin too

rustic dragon
orchid peak
#

@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

noble cave
#

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?

rustic dragon
#

yeah

noble cave
#

and if so how can i make the red value ~= 1 become an x value ~= 1?

rustic dragon
#

instead of the other one

noble cave
#

ah ty

left pivot
#

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.

vocal narwhal
#

a.rgba * b, it multiplies all the components by b. a.rgba + b.rgba, it adds the matching components together

regal stag
#

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.

left pivot
#

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.

regal stag
#

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.

left pivot
#

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

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

elfin quartz
#

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

left pivot
#

@regal stag then what goes into Lerp's T?

#

smoothstep again?

regal stag
#

@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

left pivot
#

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.

native garnet
#

Whats the difference between albedo and albedo smoothness?

#

From what I understand, albedo is the base map, the color of the vertex

low lichen
#

@native garnet What's the context? Is this something related to Shader Graph?

native garnet
#

Yes

#

Also, I don't understand why the shader graphs a differ so much, some dont have parameters for albedo/emission

amber saffron
#

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

tranquil bronze
#

@regal stag i dont understand why my shader isnt working

#

my toon shader thing

native garnet
#

@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

low lichen
#

It does if you bake the lighting

native garnet
#

Wait the lighting must me baked?

low lichen
#

It can't be done in realtime unless you're doing raytracing

native garnet
#

What about a moving object with emissions, shouldnt that work too?

#

@low lichen oh damn

low lichen
#

It can work with realtime global illumination, but that requires a static baked environment

native garnet
#

I had no idea, looks like a pretty simple effect, it just multiplies the nearest vertices with the emission color I think

low lichen
#

I don't know how HDRP lighting differs. Maybe they have some realtime option for this.

native garnet
#

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

amber saffron
#

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)
native garnet
#

@amber saffron thanks for all the explanations, and yeah i confused pbr graph with hd render pipeline, im acrually using the lwrp

grand jolt
#

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

low lichen
#

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

grand jolt
#

oh i see

low lichen
#

There is a way to fix that though

grand jolt
#

hopefully not complicated

low lichen
#

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.

tidal rover
#

occlusion culling? im a bit rusty on shaders

low lichen
grand jolt
#

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>

low lichen
#

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.

grand jolt
#

ok thanks!

amber saffron
#

I'd suggest to just have this wall made with one cube and not two ...

willow pike
#

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.

low lichen
#

@willow pike What's the context here? LWRP/HDRP? Shader Graph?

willow pike
#

@low lichen using URP and Shader Graph

amber saffron
#

You could make a custom lighting shader, but that seems overkill ...

willow pike
#

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.

low lichen
#

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?

willow pike
#

Maybe. Iโ€™m using a cel shaded flat/illustrative style. Trying not to overly texture my game.

rustic dragon
#

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?

willow pike
#

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

low lichen
#

@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?

rustic dragon
#

can your grass surface have some more geometry detail, like a grid of triangles/verts with a bit of height noise

amber saffron
#

This would be hardy possible, to impossible

#

(only the shadow trick I mean)

willow pike
#

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.

rustic dragon
#

looking good btw, but yeah what kind of surface is that geometrically?

#

looks like you have some pattern of verts/tris?

willow pike
#

Basically treating it like an old school tiled 2D game but with cubes and some rounding around the cliffs.

amber saffron
#

Suggestion : use layering to have a different sprite project the shadow ?

rustic dragon
#

are those premade chunks?

willow pike
#

Well I created them but they are ideally going to be repurposeable to be able to build out the whole overworld.

low lichen
#

@amber saffron Sprite? I don't see any sprites in this.

grand jolt
#

maybe add some little divots in the tree

willow pike
#

Maybe some kind of plane above the ground or built into the tileable chunks with lightly displaced tris like you're saying?

grand jolt
#

and disable shadows casted on it

rustic dragon
#

ok, so you could add some detail on the surface to make it warbled a bit, I was thinking it was procedural

grand jolt
#

and enable it casting shadows?

amber saffron
#

Sorry, my bad, that tree kind of looked like a facing camera billboard.
But still, you can use what I said for meshes

grand jolt
#

or you could do a procedural terrain

#

with minicule height variation

willow pike
#

Yeah that might work. I'll try making some subtle variation on the flat surface of the tops

rustic dragon
#

@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

willow pike
#

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

rustic dragon
#

good luck, and it's looking good!

willow pike
#

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.

rustic dragon
#

nice

grand jolt
#

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

rustic dragon
#

kind of an interesting result, the noise I used leaves a bit of a 'grass' texture on it too ๐Ÿ˜ฎ

#

are your shadows baked?

willow pike
#

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.

rustic dragon
#

ok, the one I used is real time too

willow pike
#

Wow! How would I implement this to the tops of my cliff chunks?

rustic dragon
#

I imagine you wouldn't want that edge height look, or would you?

willow pike
#

The second one looks great with the variation

rustic dragon
#

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

willow pike
#

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

rustic dragon
#

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

willow pike
#

Yeah totally I love this. Could even do a similar approach to make the surface of the cliffs look more distressed

rustic dragon
#

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)

low lichen
#

Overdraw shouldn't be a big problem if you draw that top to bottom with ZWrite at each step

rustic dragon
#

@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

low lichen
#

I don't know enough about Shader Graph to answer that

#

Are you putting many passes into the same shader?

rustic dragon
#

this shader should be easily remade by hand too

#

not sure what you mean by many passes

willow pike
#

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 ๐Ÿ˜‚

rustic dragon
#

sounds good

low lichen
#

@rustic dragon Oh, so it's just multiple mesh renderers with this shader manually stacked on top of each other?

devout quarry
#

I'd really like shader graph to have a 'get/set local var' like amplify has

#

would make organizing my graph so much better

rustic dragon
#

@low lichen yes

#

@devout quarry is that where you can have like teleporting invisible connector lines?

devout quarry
#

yes!

#

I have a lot of overlaying lines sometimes and I don't like it

rustic dragon
#

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

low lichen
#

@rustic dragon In that case, just gotta hope Unity orders it properly, which it should

devout quarry
#

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

rustic dragon
#

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

low lichen
#

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.

rustic dragon
#

yes

low lichen
#

If you connected the threshold with the Y position of the object, it could all be the same material

rustic dragon
#

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

low lichen
#

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

rustic dragon
#

yeah, I think that would work for the same height objects for sure, good idea

willow pike
#

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?

low lichen
#

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

rustic dragon
#

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

low lichen
#

If it's on some kind of grid, it could be repeating

willow pike
#

Hmm right that's what I was thinking

#

probably isn't an easy way to make one material do this across an entire scene

rustic dragon
#

how many 'heights' do you have?

low lichen
#

This could be done with a geometry shader, where each layer is created by the shader

rustic dragon
#

that would change the shadows?

low lichen
#

That would save design time since you won't have to manually stack renderers together and you could easily change the number of layers

rustic dragon
#

shadow heights that is

low lichen
#

Sure, as long as the shadow pass also uses the geometry shader

willow pike
rustic dragon
#

you could try to repeat it, or just make materials for each level, which looks to be like 4/5

willow pike
rustic dragon
#

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

low lichen
#

I'd be surprised if Shader Graph has geometry shader support already

rustic dragon
#

the clip threshold should be .5 and not changed, but I think it does require a paramter weirdly

low lichen
#

And if this is for mobile, then geometry shader is out

rustic dragon
#

I did the threshold differently, but you could use that honestly, I am silly ๐Ÿ™‚

#

why use the invert colors?

willow pike
#

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

rustic dragon
#

I usually use one minus

willow pike
#

Ah I'm still noobing my way through Shader Graph

rustic dragon
#

heh

terse nexus
#

anything I need to consider when trying to create a shader for terrain. (shader graph)

terse nexus
#

Cause I added my shader (one I usually use for objects) to it. Which lead to overwritting/ignoring the painted textures

willow pike
#

@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 ๐Ÿ™‚

rustic dragon
#

awesome

#

hard to set up?

#

grass looks nice and fluffy too ๐Ÿ™‚

willow pike
#

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.

rustic dragon
#

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

willow pike
#

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

rustic dragon
#

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

willow pike
#

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

rustic dragon
#

no problem

dusk tapir
#

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

ocean spade
#

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

ocean spade
#

... so i've accounted for the distance and it's still not perfect but it's improved it good enough

devout quarry
#

@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

terse nexus
amber saffron
#

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

terse nexus
#

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?

amber saffron
#

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

left pivot
#

Is there a way to receive shadows with unlit graph?

silver moat
#

@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.

https://blogs.unity3d.com/es/2019/07/31/custom-lighting-in-shader-graph-expanding-your-graphs-in-2019/

As a side note, watch out if you are working with HDRP, for things may get a little trickier.

Unity Technologies Blog

With the release of Unity Editor 2019.1, the Shader Graph package officially came out of preview! Now, in 2019.2, weโ€™re bringing even more features and fun...

tranquil bronze
#

im not recieving shadows from custom lighting in shader graph

#

this is the tutorial im following

lapis vigil
#

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?!

silk sky
#

can somebody link me a tutorial to make a crystal shader in unity? I haven't foudn any

devout quarry
#

here is some cool stuff

rustic dragon
#

@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

devout quarry
#

yup definitely

#

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

rustic dragon
#

yeah, I hope for loop functionality soon, right now you just have to duplicate things as many times as you need/want

devout quarry
#

Or use a custom function node, it's convenient

rustic dragon
#

I know, just saying it'd be nice to just use nodes, making custom function nodes isn't artist friendly

devout quarry
#

Are there 'loop' nodes in ue4? What do they look like?

#

Like what are the inputs/outputs

rustic dragon
#

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

devout quarry
#

@rustic dragon

#

I did something like this

#

The grid pattern is a quad and kind of mapped to the geometry below

rustic dragon
#

where is the quad compared to the sphere height wise?

#

is it like a projector for like a decal?

devout quarry
#

I'll show you what I wanted to replicate, 1 sec

rustic dragon
#

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?

devout quarry
#

this was it

#

quad is parallel to ground plane, cube is also not rotated

#

the angle is 90 degrees

#

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 ๐Ÿ˜‰

rustic dragon
#

so that uses the CameraDepth data?

faint notch
devout quarry
#

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

rustic dragon
#

I was actually sampling _CameraDepthTexture though, what you are doing is much better!

devout quarry
#

I mean internally my shader is sampling _CameraDepthTexture right?

rustic dragon
#

yeah, with some built in nodes, I will try that

#

like I used a texture sampler with that as an input

devout quarry
#

the surface depth node is a subgraph btw, but it's screenposition.a basically

#

or well screenposition.w

low lichen
#

@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

rustic dragon
#

@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

low lichen
#

That effect uses multiple cameras? I thought it was just post processing effect using the depth texture.

rustic dragon
#

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

low lichen
#

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.

rustic dragon
#

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/

โ–ถ Play video
#

not asking for solution at work in unreal, but it's an interesting effect for unity too

devout quarry
#

I have a cool shader to share

low lichen
#

Let's see it!

rustic dragon
#

tease

devout quarry
#

I wanted to push my personal limits and use as few textures as possible

rustic dragon
#

hah, nice

dusk tapir
#

@devout quarry yea, i am having problems, i can use the color brush, but not the texture brush

low lichen
#

@devout quarry So the background isn't a texture?

devout quarry
#

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

rustic dragon
#

what is that done in?

devout quarry
#

shadergraph 100%

#

except for the stencil mask

rustic dragon
#

so that's not render to texture for the pokemon?

devout quarry
#

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

low lichen
#

Shader Graph supports stencils?

rustic dragon
#

what do you think the instruction count for that is? can you have multiple cards on screen even overlapping eachother?

devout quarry
#

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

low lichen
#

Using multiple textures would certainly be fewer instructions and more performant, but that wasn't the goal of this shader I imagine.

devout quarry
#

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

rustic dragon
#

pretty damn cool

devout quarry
#

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

willow pike
#

That looks amazing @devout quarry

low lichen
#

Nice! What's the process of creating functions for icons like that? Are there tools to help with that?

devout quarry
rustic dragon
#

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

devout quarry
rustic dragon
#

saved link ๐Ÿ™‚

devout quarry
#

ah so it becomes 3D, that's a cool effect

rustic dragon
#

that is the hope, with a real 3D background behind it

dusk tapir
#

Alexander, last night/this morning, you said you were able to use the texture brush in polybrush with HDRP?

devout quarry
#

yup I used this shader

#

for vertex painting

#

I hope that's what you mean with texture brush otherwise I'm misunderstanding

dusk tapir
#

why does your unlit master only have one option?

devout quarry
#

I collapsed the unused options since I only use color

#

There is like a little downwards arrow on a node that collapses the ports

dusk tapir
#

well, im wondering because your one option is "Color" whereas mine is "Base Color", and wondering if that has any difference

devout quarry
#

I'm using unlit node in URP

rustic dragon
#

is the split node different now in URP, or are you collapsing it somehow to only show the output you are using?

devout quarry
#

collapsed, I always collapse all my nodes

rustic dragon
#

oh, I see it now, it's on the top right

devout quarry
#

I would love for shadergraph to have a screenshot button

#

exporting your whole graph has a crisp high quality image

low lichen
#

Maybe possible through an editor script ๐Ÿค”

rustic dragon
#

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

knotty juniper
#

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.

rustic dragon
#

ah, so it does do that

stone sandal
#

the .shadergraph file extension is a JSON text file c:

#

they're not super human readable at the moment

#

but definitely shareable text files

knotty juniper
#

i would like to have better copy paste to json for it but its working for the moment

dusk tapir
#

@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

dusk tapir
#

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

faint notch
#

@terse nexus did you look at the book of dead project? it uses hdrp with custom terrain shader, might get you started.

ivory dock
#

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

willow pike
#

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

ivory dock
willow pike
#

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

rustic dragon
#

@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

ivory dock
#

Worked fine, thank you bro ๐Ÿ˜„

willow pike
#

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

rustic dragon
#

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

willow pike
#

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!

faint notch
#

@willow pike make a C# script to combine them on build automatically, thats what they did in monument valley

autumn seal
#

Hi, I'm using shader graph in URP. Is Overlay not support in render queue?

willow pike
#

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.

sand pasture
#

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?

vocal narwhal
#

There are some resources pinned to this channel

#

not sure what exactly you're looking for

drowsy abyss
#

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?

rustic dragon
#

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

drowsy abyss
#

@rustic dragon Right, does this technique have a specific name?

#

Or is that just it?

rustic dragon
#

vertex blending I think, or that is what I call it

#

yeah, use that to search

drowsy abyss
#

Okay, thanks! I was looking for a starting point so I could at least speak the same language as others on the subject.

drowsy abyss
#

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.

faint notch
#

@willow pike if your not used to programming, you could try probuilder and progrids, there is some built in functionality to combine meshes there.

silk sky
#

does exist a way to invert the fresnel effect?

#

I remember that adding a -1 somewhere will generate that effect

faint notch
#

@silk sky Just use one minus?

silk sky
#

is it wrong?

#

Idk I'm asking xD

vocal narwhal
#

"One Minus"

#

Not a single minus

silk sky
#

oh its actually a node

faint notch
silk sky
#

ok

#

so in a transparent object there's white inside and black outside right?

faint notch
#

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

silk sky
#

okok

brazen kernel
#

@vocal narwhal wdym tiling

vocal narwhal
#

I mean tiling

brazen kernel
#

and i just plug that into the UV of the noise , right?

tidal rover
#

Kinda saids that in the documentation

#

but yea

autumn seal
#

Is it possible to change render queue to overlay in shader graph using urp?

tranquil bronze
#

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

faint notch
#

@tranquil bronze yep! that is whats causing it

#

are you developing for mobile?

tranquil bronze
#

all platforms

faint notch
#

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

tranquil bronze
#

so mobile too

faint notch
tranquil bronze
#

can i change the distance value via a script?

#

depending on how far away the camera is

faint notch
#

yep

tranquil bronze
#

ok thanks :)

faint notch
#

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

tranquil bronze
#

yeah i will

#

thanks for all your help :>

graceful lotus
#

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.

#

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?

grand jolt
#

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 ?

low lichen
#

@grand jolt Plane hovering over a plane? What does that have to do with water ripples?

#

You mean an airplane hovering over water?

graceful lotus
#

Airplane hovering over a planar surface, I assume.

grand jolt
#

over water xD

#

but yea much like a still water causing it to ripple

tall gull
#

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!

rustic dragon
#

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

tall gull
#

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

rustic dragon
#

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
#

oh thats a good idea

#

thanks

low lichen
#

@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.

tall gull
#

I tried that first but it seemed like it doesn't function well, not sure tho

#

a lot of clipping etc

low lichen
#

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

rustic dragon
#

you can't have multiple mesh renderers, at least I cant with my build

low lichen
#

You mean multiple materials?

rustic dragon
#

ah, saw you say multiple mesh renders

#

each material will only render on it's specific triangles from my experience

#

each submesh

low lichen
#

Yeah, that is if you have submeshes. If there are no submeshes, it will render the same mesh again with that second material

rustic dragon
#

ah interesting

low lichen
#

Seems to work fine in LWRP, too

rustic dragon
#

I wonder if it's literally 2x the cost

low lichen
#

Versus doing the fresnel in the one material?

rustic dragon
#

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

low lichen
#

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

rustic dragon
#

probably be cheaper to do it in one material, though it's more hassle for sure

low lichen
#

For GPU, it will cause overdraw where it could have been avoided by doing it in the one material

rustic dragon
#

yeah, but that is pretty cool

#

don't think unreal offers that

low lichen
#

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

rustic dragon
#

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

low lichen
#

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

rustic dragon
#

but overdraw would be 2x

low lichen
#

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

rustic dragon
#

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

low lichen
#

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.

rustic dragon
#

yeah, exactly the same reaction to if I duped the sphere, makes sense

low lichen
#

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

umbral trench
#

does anyone here have experience using depth based edge detection?

devout quarry
#

yes

#

what can I help you with?

umbral trench
devout quarry
#

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

low lichen
#

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

devout quarry
#

yeah adding normal based detection is nice, but this could be done with depth only too

umbral trench
#

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!

devout quarry
#

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

umbral trench
#

wow thank you very much!

devout quarry
#

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

umbral trench
#

ah okay, thanks! I will dive into this tutorial and see if it solves my problems

devout quarry
#

good luck, I'd be interested to see the result so feel free to tag me

dapper pollen
#

dumb question but do you still use #include "UnityCG.cginc" for renderpipeline shaders? edit found the replacement

grizzled oriole
#

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

fervent tinsel
#

@dapper pollen yeah, that's legacy thing

#

usually if you put that into SRP shader, you are in a whole lot of trouble ๐Ÿ˜„

dapper pollen
#

yeah, im really out of my depth with shaders and renderpasses ๐Ÿ˜„

mental verge
#

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.

fervent tinsel
#

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

low lichen
#

@grizzled oriole What kind of computation are you planning on doing in the compute shader?

mental verge
#

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!

native garnet
#

I got an interesting question

#

Can you put a pbr shader to the skybox?

#

I mean pbr graph shader

amber saffron
#

No

native garnet
#

Not even any other custom shader?

#

I wanted to give the skybox a sinusoidal wave like movement

amber saffron
#

Depends on what renderpipeline you're using.
In HDRP there is some doc to write your own sky

tranquil bronze
#

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

ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท...

โ–ถ Play video
fervent tinsel
#

@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

devout quarry
#

Exactly what I do in my projects 0lento

#

Have a sundisk follow the directional light direction

graceful lotus
#

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).

regal stag
#

@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).

graceful lotus
#

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?

regal stag
#

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.

graceful lotus
#

Oh of course, I believe you're right.

regal stag
#

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.

graceful lotus
#

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.

regal stag
#

@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?

graceful lotus
#

Yes.

regal stag
#

Ah I see ๐Ÿ™‚

graceful lotus
#

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.

rustic dragon
#

just because you can create such a thing doesn't mean you should . . ๐Ÿ˜›

regal stag
#

Haha

grizzled oriole
#

@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

devout quarry
#

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

graceful lotus
#

Can you also rotate one of them, so they never line up?

#

Maybe just flip the uv coords?

devout quarry
#

Yup rotating does fix it thank you

#

but why would a min function not work?

silk sky
regal stag
#

@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.

rustic dragon
#

or just scale up the 2nd one, in addition to rotation and/or flipping

devout quarry
#

A simple 45 degree rotation would do enough to never make them line up right?

graceful lotus
#

Literally any rotation/scale will prevent them from matching up.

rustic dragon
#

I think scale would be cheaper, you can save like .0001 ms!

devout quarry
#

Then I'll scale ๐Ÿ˜‰

graceful lotus
#

Depends on the visual result you're going for - obviously scale will increase (or decrease) the noise grain size.

rustic dragon
#

do all the transforms

graceful lotus
#

You could flip the UV coords to mirror one sample too; maintain grain scale and prevent lining up.

devout quarry
#

Thank you all

devout quarry
#

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

low lichen
#

@grizzled oriole Do you have some algorithm in mind that can be run in parallel in a compute shader?

silk sky
#

I would like to create a vertex displacement by using a texture, can somebody help me?

grizzled oriole
#

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
devout quarry
#

@silk sky in shadergraph?

silk sky
#

yes

grizzled oriole
#

@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?
low lichen
#

@grizzled oriole Are you okay with the data coming back possibly coming in a frame or 2 after the compute shader is dispatched?

grizzled oriole
#

@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.)

devout quarry
#

@silk sky

#

The 'trick' is to use the Sample Texture 2D LOD node instead of just Sample Texture 2D

silk sky
#

ok thanks

devout quarry
#

Because Sample Texture 2D is a pixel shader node

#

Sample Texture 2D LOD is a vertex shader node

low lichen
#

@grizzled oriole So you're not using any jobs or threads currently? Just Burst?

silk sky
#

ooh ok

grizzled oriole
#

@low lichen Well, yes, Burst and the Job system

silk sky
#

but is this displacement only for one axis?

grizzled oriole
#

@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

low lichen
#

The more threads you make use of, the better

devout quarry
#

You can do the displacement however you want, in my example it is for the y axis only

silk sky
#

ok

grizzled oriole
#

@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.

low lichen
#

@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?

grizzled oriole
#

@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)

low lichen
#

And how many jobs are you running in parallel now?

grizzled oriole
#

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

low lichen
#

Are you planning on running the compute shader for each cell of the grid? Like each pixel of a texture?

grizzled oriole
#

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

low lichen
#

Doesn't sound like a task that the GPU would do much faster than the CPU, unless I'm missing something

grizzled oriole
#

Can you tell me your understanding of my problem?

low lichen
#

I guess that's the problem, I don't have a very good understanding :P. So you're running 8x20 jobs currently?

grizzled oriole
#

No.

#

I'm running one job with thousands of predictions to evaluate. Each thread simulates one prediction

low lichen
#

My understanding of the C# job system was a job = a thread. Is that a misunderstanding?

grizzled oriole
#

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)

low lichen
#

So it's somehow automatically splitting a big synchronous task into multiple threads? How does that work?

grizzled oriole
#

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.

low lichen
#

Are these small tasks defined in the pastebin you posted?

grizzled oriole
#

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)

low lichen
#

SimulateGrid is simulating the whole 8x20 grid at different states?

grizzled oriole
#

Yes

#

Well, one state in that function call

low lichen
#

Right, but each run is of a different state

grizzled oriole
#

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

low lichen
#

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?

grizzled oriole
#

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)

low lichen
grizzled oriole
#

A lot more than 7.

low lichen
#

Right :P

#

But would you be running it at 2 dimensions, like you would a 2D texture?

grizzled oriole
#

I could if it would help

low lichen
#

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

grizzled oriole
#

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

low lichen
#

So each prediction will run the SimulateGrid function to compute the resulting score?

grizzled oriole
#

Yes

low lichen
#

And you keep simulating until the combo has ended, if there is one?

grizzled oriole
#

That is correct

#

I do it up to three times, because the AI will look up to three moves ahead

low lichen
#

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?

grizzled oriole
#

That is correct

#

That would be 3 invocations of SimulateGrid

low lichen
#

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?

grizzled oriole
#

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)

low lichen
#

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

grizzled oriole
#

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?

low lichen
#

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.

dark flare
#

๐Ÿ’ฆ how far up should i scroll for this

low lichen
#

@dark flare Up to the pastebin

dark flare
#

whats the question?

low lichen
#

You want to answer that @grizzled oriole?

dark flare
#

ping me when you have a single message with question pls lol, at work atm

#

cant read the whole discussion

low lichen
#

Sorry about that, I'll let @grizzled oriole decide if they want more answers.

grizzled oriole
#

@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

dark flare
#

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

grizzled oriole
#

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

mild sleet
vocal narwhal
#

It's based on the difference of the normal to the view direction

mild sleet
#

so basically the surface has to be curved?

vocal narwhal
#

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
#

fair point

#

yea i guess that makes sense

#

thanks

rustic dragon
#

@mild sleet what effect are you trying to achieve?

mild sleet
#

An outline glow/highlight sort of thing (similar to how it looks on the capsule)

proven sundial
#

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?

proven sundial
devout quarry
#

The hlsl shader file for the custom function node is the relevant part for you I think

mild sleet
#

Thanks, I'll check it out :)

silk sky
#

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?

rustic dragon
#

you want it to pulse?

silk sky
#

basically yes

#

hi tho ๐Ÿ™‚

rustic dragon
#

hello, I think you can push a time node into sin or cos to get a range from 0 to 1 that ping pongs

silk sky
#

is this good?

rustic dragon
#

or just push out sine time

#

from the time node, to mult to your remap

devout quarry
#

What about a wave?

#

like a sawtooth

#

might look cool

rustic dragon
#

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?

silk sky
#

I'm trying, it does in the graph but not in the scene

#

maybe I just have to adjust values

#

yep it works now

rustic dragon
#

triangle wave is a bit more exactly like a ping pong

#

the sin one kind of lags at 0 and 1

silk sky
#

Now im trying to make only 2 propertis for control Min and Max

rustic dragon
#

in your remap?

silk sky
#

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

silk sky
#

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

rustic dragon
#

clamp or saturate the value

silk sky
#

even if its a vector 2 or should I do it before?

rustic dragon
#

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

silk sky
#

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

regal stag
#

@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...

Retweets

243

Likes

1272

โ–ถ Play video
dim river
#

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
dim river
#

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)

lime meteor
#

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

devout quarry
#

@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

dim river
#

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

devout quarry
#

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

low lichen
#

@lime meteor Is it data that can be encoded into a texture?

devout quarry
#

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

lime meteor
#

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

low lichen
#

@lime meteor Maybe Graphics.Blit is what you need

lime meteor
#

Using already attached to my main camera to pass through the shader