#archived-shaders

1 messages Β· Page 224 of 1

steel notch
#

some cross hatching texture

#

and then multiply it by an occlusion map

#

fokin

kind juniper
#

Yeah, you could. That's what I meant by you pass some data into it defining the AO value of each pixel

crude bolt
#

Is there a built in fog shader?

tacit parcel
#

I think you can just simply enable fog from window/rendering menu

steel notch
#

so I can access the normals of a mesh using this node

#

and I want to fade out (or really just do operations) on a texture based on values from this node

#

I cant seem to just multiply it though

#

what needs to be done?

crude bolt
tacit parcel
#

the built in fog is distance fog, which increase it's thickness the farther from the camera.
if you want fog which only affect specific area, you;ll most likely need volumetric fog

grand jolt
#

im trying to get terrain holes working on a custom HDRP Terrain Shader Graph, i'm using the correct reference as when i hook it into base color I can see the painted holes.

However if I split the Alpha channel and route it into the Alpha of the master node it doesnt work...anyone know why?

#

splitting Alpha into alpha master:

kind juniper
#

You're not feeding anything into the alpha though

#

You're feeding the color to base color that ignores the alpha channel.

steel notch
#

Does someone mind giving me the Tl;dr on what "Depth Write" does and the implications of changing it's values for Transparent shaders?

#

I understand that there is a depth buffer and it's used to order meshes when rendering to the camera.

#

But the exact implications of messing with this... I'm not sure.

peak ridge
#

uh. does this server prevent long messages from going through or something? i just typed up a message and it ate it πŸ€”

kind juniper
peak ridge
#

well thats a bit tedious lol. let me try to reformat

#

ive written a shader which manually implements shadowing from point lights, but have a couple very strange issues with it.
my main pass (done with lightmode tag set to forwardadd), requires the use of one of a few of the vanilla multi compiles. i can't fathom why.
i tried to narrow things down by cutting out keywords. the minimum spec one is
#pragma multi_compile_shadowcaster
otherwise, shadows do not work.
i have no idea why this should even interact with my shader. im not even using UnityCG.cginc in this pass.
meanwhile, on the shadowcaster pass, i can comment out its multi compile shadowcaster line and everything still works. that seems... odd?

#

my point light shadowmap is being copied into a new texture via commandbuffer. that and all other values relevant to the light are being passed thru script via globals

#

so tldr: one random pragma is preventing a shader with 0 relation to any builtin unity functions from working, yet strangely isnt even required in the shadow caster pass.

weak raft
#

How would you go about dynamically changing the frequency of a sin wave in the graph editor?

kind juniper
grand jolt
kind juniper
kind juniper
#

Ah, it's HDRP...πŸ€”

grand jolt
#

i was assuming that the black areas of the splatmap are considered transparent, but that may not be the case, it could just be black / red, in which case how would i count the black areas as transparent?

regal stag
#

Just use the red channel in the Alpha port?

grand jolt
#

ill give it a try

#

doesnt seem to work, i even tried to One Minus it so the black areas turn white then feeding it into Alpha, no change

#

AHA! I may have it

#

@kind juniper @regal stag Note to self:

Telling your Shader Graph to use Alpha Clipping doesnt make a blind bit of difference. Must always activate it in the materials inspector settings.

Because telling the shader to do it is far too logical.

regal stag
#

Ah yeah, I forget HDRP has settings on the material for those too

grand jolt
#

XD

grand jolt
# regal stag Ah yeah, I forget HDRP has settings on the material for those too

Do you know how to access the last 4 layers on the terrain BTW? i've got the entire thing set up, I saw a _Control1 declaration in the Standard Terrain Lit shader so am using that to access the second set of layers, also have a keyword bool with _TERRAIN_8_LAYERS as the reference but i still cant see the 5th layer

#

The first 4 work fine with _Control0

regal stag
#

Yeah, does _Control1 show anything if you output it & draw with the 5th layer?

grand jolt
#

ill set it up and double check

grand jolt
#

results in:

#

keyword reference:

#

the T of the lerp is the R channel of _Control1

grand jolt
#

Hello everyone, I have a transparency problem ^^
I just want to clip stuff (The only possibility in shader is still alpha clip right?).
But even using 0.999 alpha I'm still seeing through the sides of the mesh. Any tips?
Thanks

regal stag
kind juniper
grand jolt
grand jolt
grand jolt
#

very detailed there Unity, nice one.

#

it clearly says HDRP can render 8 layers in a single pass though...

#

or should I try just using _Control0 and Splat4, 5, 6, 7?

regal stag
#

_Control0 would correspond with the first 4 layers, it wouldn't really make sense to use it for the others. That answer is intended more for the built-in RP which uses 4 layers per pass, while it looks like HDRP is 4 or 8 layers and single-pass only.

#

@grand jolt The HDRP/TerrainLit.shader does seem to have a tag in it's SubShader, "SplatCount" = "8" which might be required?

#

But it says in a comment those tags are for supporting "shader replacement features" so not sure

#

It looks like _TERRAIN_8_LAYERS is a keyword from the terrain system so just enabling it on the material might not work. It might be a setting in HDRP somewhere? Or on the Terrain component? Or maybe it just sets it automatically based on the number of layers :\

grand jolt
grand jolt
#

ignore that, didnt have it turned on

#

it does now lol

empty elm
#

Hello, I have a question. Here I have a transparent Shader Material, the thing is that I want to make it so you can see it from inside and outside of the material itself, how can it be done?

#

Here the inside, as you can see, it's invisible from the inside

slim steppe
empty elm
#

PBR Shader Graph

#

In URP

slim steppe
empty elm
#

Actually I'm working in 2019.4.12f1

slim steppe
#

Go to graph settings and activate two sided

slim steppe
empty elm
#

Inside the PBR editor?

slim steppe
#

probably in the upper right corner

empty elm
#

Ok I'll take a look in a bit. Thank you for the answer Max!

kind juniper
#

@dusk cobalt here's the graph. I don't have time to explain everything now, but it should be clear from the names of the properties. Velocity takes a normalized direction Stretch takes the velocity magnitude and stretch offset( -1 to 1) defines the point in the mesh that the stretching starts.

slim steppe
#

Is there anything like the scene color shader graph node for shaderlab?

torpid lichen
#

Thx, i didnt know what to search but this is what i meant

#

That was my original attempt, but i dont know how to do it in a pixel shader, my original idea was to blur, normalize, smoothstep. But then i cant control the size of the individual dots, so i didnt know how to do it in a pixel shader.

#

? I thought all drawing apps basically draw a bunch of circles along the path of the stroke ?

#

Im gonna visualize what i mean, i think im explaining it badly πŸ₯²

grand jolt
#

@torpid lichen I think they stamp alpha textures with a certain spacing.

#

If you want matrix printer dots, that's a different easier task.

#

Cause then you can just tile a pattern in screenspace.

torpid lichen
#

ok but it comes out the same as drawing dots right ?

grand jolt
#

You're not going for pixelart, right?

torpid lichen
#

wait im gonna send screenshot

#

Im not saying drawing the lines will fix the problems, i just want a kind of framwork i can use later to draw lines on top of frames according to a texture that tells the positions of the lines

#

I wanna do it this way so i can later manipulate that texture to smooth lines, introduce noise etc.

shadow locust
#

Is there a good way to do this? Actually I think I just need position/rotation, not scale

#

I guess I can use RBG of one pixel as the position and RGB of the next pixel as euler rotation angles, or the whole RGBA of the next pixel as a Quaternion for rotation.

vague pike
#

Any water shader tutorial that talks about how to make it so refraction effects don't cause objects in front of the water to get refracted on their edges?

teal breach
slim steppe
#

Is there anything like the scene color shader graph node for Surface and unlit Shaders?

meager pelican
past kraken
#

How to make sword trace in hdrp? Because motion blur built in hdrp is kinda bad

shadow locust
#

Anyone know how to get a float4 quaternion representing the rotation from a float4x4 matrix in HLSL?

meager pelican
# shadow locust Anyone know how to get a `float4` quaternion representing the rotation from a `f...
kind juniper
shadow locust
#

Is it possible to get the width and height of a Texture2D in shadergraph?

plush fog
#

texel node

shadow locust
plush fog
#

It gives the width and height of a texture

shadow locust
#

I don't think so...

plush fog
#

Well I was also confused about the naming but it is indeed like that, feel free to try it

shadow locust
#

Ok i'll try it

#

Apparently in a normal shader it's a float4 with: 1/width, 1/height, width, height

#

but it's only width/height in shadergraph

#

weird

plush fog
shadow locust
#

what a poorly named node πŸ˜›

shadow locust
#

Making a URP shader graph. Trying to use a calculated position for the vertex positon. Why won't it let me connect this node here?

#

It's like my Vector3 node is somehow stuck in the fragment shader instead of the vertex shader. (It connects to the fragment inputs just fine)

#

How can I fix that?

#

Hmm it seems as though it's because I have a Sample Texture2D node in the graph. Is it not possible to sample a Texture2D in the vertex shader section of a shader graph?

#

Figured it out - have to use Sample Texture 2D LOD

vocal narwhal
#

I was about to link you my site πŸ˜›

shadow locust
#

Sorry for the monologue πŸ˜„

kind juniper
#

Wait, so why does it work?

#

Why is lod sampling linked to vertex shader?

shadow locust
#

I'm not sure but my problem is still not fixed - it seems like there's some other node I'm using somewhere that may also not be available in the vertex shader stage

vocal narwhal
shadow locust
#

I'm looking through every node right now to see what else in my graph is not vertex stage compatible πŸ€”

#

They seem to all be ok though as far as I can tell...

Vector3
Vector2
Multiply
Split
Object (position)
Matrix Construction
Sample Texture LOD
Divide
Modulo
Add
Texel Size
Instance ID```
vocal narwhal
#

reconstruct it backwards from the vertex position and see what fails

shadow locust
#

hmmm

#

it seems to be... the Texel Size node?

#

Doesn't say anything in the docs about that being restricted though πŸ€”

#

strange but... maybe ok as I could work around this by passing in the texture resolution as a separate property if I need to.

pastel cedar
#

a vertex shader output with SV_POSITION should be bounded to -1 -> 1 right?

#
            CGPROGRAM
            #pragma vertex vert_img
            #pragma fragment frag

            #include "UnityCG.cginc"

            uniform sampler2D _MainTex;
            uniform float groundHeight;

            fixed4 frag (v2f_img o) : SV_Target
            {
                if (o.pos.y > groundHeight) {
                    return fixed4(0,0,0,1);
                } else {
                    return fixed4(0,0,0,0);
                }
                
            }```
#

my thought was that this would cover a portion of the sprite its attached to (0 < y < groundHeight) and that i'd specify groundHeight as being between ``(-1, 1)`

#

wait i've done something wrong

meager pelican
# kind juniper Why is lod sampling linked to vertex shader?

The vertex stage doesn't "know" about the screen pixel resolution (yet) nor the placement of the "depth", since that's output in clip-space. That's kind of a function of the rasterization stage that happens AFTER the vertex stage.

Therefore, it doesn't know how to select the right mip level (which is what LOD is doing) until the fragment stage hits.

Soooo.....when in a vert stage, you have to manually specific the LOD level you want in order to use a texture sampler. Thus you're required to use the sample-LOD call, since there is no default established for the lod level yet for the "normal" call.

tacit parcel
pine dragon
#

Hi, I have a question and require some help. I have about 100 objects that are all fractured to create a "chunk" which I then use to put all the chunks together to create land that I can destroy satisfyingly for the game im working on. I have about 9 chunks all loaded at once and so that creates 900 batches which just creates insane amounts of lag. I do however use the same material for each and every object. I am wondering if I can somehow use GPU Instancing or maybe something different in order to reduce these batches as I am creating for Mobile Devices.

The only thought I have is to duplicate my material 100 times for each different fractured object piece to enable GPU Instancing and to reduce batching because it only works when it is the same material + same mesh. Here is a preview of the mesh I am working with whilst using a Triplanar shader to draw the material:

#

Any help and advice is much appreciated!

past kraken
#

what the?..

honest scroll
honest scroll
#

You seem to be using HDRP…. Try everything. I only know URP.

past kraken
#

well, okay

#

thanks

honest scroll
#

De nada.

heavy oasis
#

I have a problem with my shader graph. I'm getting this error "DX11: Texture index out of range". Shader uses many textures (less than 128) but all texture samplers are connected to sampler state nodes. There are less than 16 sampler state nodes.

heavy oasis
#

This graph uses StackLit mode. The thing is that it works fine and without errors when it's set to the 'Lit' material mode. Same inputs are connected to the master node so both modes use the same samplers when I test them.

pastel grail
#

does anybody happen to know how to do fake specular highlights in shader graph in URP? I want specular highlights on my water shader but if I just add a normal map, and set high metallic/smoothness it screws with how the shader looks a lot

dusk cobalt
#

Can i add second Material and Shader to Mesh?

sour mulch
#

Sorry to pull from something days ago but this doesn't work. All I get is "There's no upgrader to convert shader to selected pipeline"

shadow locust
sour mulch
shadow locust
sour mulch
shadow locust
#

you just have to change the shaders on the materials. (or switch to a new material with a different shader)

#

and reassign the textures to the right place in the new shader

lusty badger
# pine dragon

You could try using DrawMeshInstanced and use multiple submeshes instead of objects. Not sure what are the submesh limits or how big of a performance impact it will be but I don't have any other ideas.

pine dragon
torpid lichen
#

Another kind of related question I had was is it possible to render the output of shader graph to a texture ?

#

Like a node that takes color just like the master but then writes it to a texture instead of the screen

shadow locust
#

I'm making a RenderTexture for use as an output texture for a compute shader.

The actual data I'm putting in the texture has nothing to do with graphics though. I want the data to just sit in the texture exactly as the compute shader wrote it (basically treating it as a big array of float4). What are the correct settings I should be using for creating this RenderTexture? For example I have no idea what to set for the format or for the color space conversion, or the depth buffer.

slim steppe
#

Hi, why is the edge of the depth texture less accurate?

meager mist
#

is there a way to create a tiling noise map within the shadergraph

slim tulip
#

Greetings gentlemen, what side-effect might appear if 2 different shaders have Vector1 with the same reference?
I'm planning to change materials using these shaders via one script, I can manually enter the new references into the script, but is there a reason NOT to just set the same references to Vector1/floats I need?

meager pelican
slim tulip
#

Thing is, I want to access the same property of copy-pasted materials with the same code.

meager pelican
#

Oh, the reference field in Shader Graph?
That's "just" the internal name within that shader. Since you have two separate shaders, they are independent references really. The word "reference" isn't really what you're thinking as it isn't the pointer type in C# that you might have in your mind. In fact, it is common to change the name (in this example) to "_OpacityStrength" (note the leading underscore) and that would be the property name in the shader.

And in c# you'd use something like
myMaterial.SetFloat("_OpacityStrength", myFloatValue);

Of course, it is always better to use a propertyID that you've stashed away, rather than making it do a string-name lookup every frame.

slim tulip
worldly karma
#

i don't know much about shaders. is there a way to get sprite masks to render normal maps? the sprite mask only reveals the main texture.

shadow locust
#

Say I have two float3 representing euler angle rotations.
What would be the correct way to slerp between these two rotations in HLSL (compute shader)?

Simply doing lerp(a, b, t) between them seems like it wouldn't be correct, as you could have let's say 350 degrees and 10 degrees, with the proper interpolated angle being 0 or 360, not 175. Am I thinking about this wrong?

teal breach
#

I guess represent them as quaternions and do a quaternion lerp between the?

wraith inlet
shadow locust
#

Will this float turn into (0.1, 0.1, 0.1, 0.1) or just (0.1, 0, 0, 0) when it converts to a float4?

shadow locust
#

Has anyone used the new Instance ID node in ShaderGraph yet?
https://docs.unity.cn/Packages/com.unity.shadergraph@12.0/manual/Instance-ID-Node.html

It seems to always be giving me 0 as far as I can tell. however my material has GPU Instancing enabled, and I'm drawing it with Graphics.DrawMeshInstancedIndirect(itemType.Mesh, 0, itemType.Material, bounds, drawArgsBuffer);
So I can't imagine it's not being instanced. Also in the frame debugger as far as I can tell it's being drawn in one batch.

So is there some magic sauce I'm missing for the instance ID node?

#

I'm concluding that it's always giving zero because I did this and all the instances are still drawn directly on top of each other

mental bone
#

Im trying to get the positions from a args buffer that is being filled correctly no idea where and how im messing up

regal stag
#

If it helps at all, this is what I had to do to get SG working with DrawMeshInstancedIndirect back in v10 : https://gist.github.com/Cyanilux/4046e7bf3725b8f64761bf6cf54a16eb

I think the Indirect version works differently from the regular DrawMeshInstanced. The new Instance ID node might only work with that one instead currently, but that's just a guess.

meager pelican
#

How many instances are you guys trying to draw?

If not in the many 1000's, you might be better off with regular Instanced calls anyway, unless you're procedurally generating the args buffer (and of course instanced data) on the GPU, say from a compute shader.

There's limitations to the # of instances in a call, but frankly, since there's probably no significant context switching going on, and the C# engine will do frustum culling for you, how bad are potentially a few more draw calls?

I'd time it each way if your use-case supports it.

slim steppe
#

Hi i've got some problems with making a pp shader only render if theres nothing in the depth texture that could "block" it

#

And it works great if you're directly next to it (the cube is rendered how it should be)

#

(the cube is rendered how it should be)

slim steppe
# slim steppe

but if the distance gets a bit larger it just doesnt work

#

how can i fix it?

shadow locust
shadow locust
mental bone
mental bone
#

I think for my case I might just go for dots since I dont need the objects to interact with anything at all

#

They just need to be there and play their vertex animations

slim steppe
#

I accedentally made a crappy edge detection xD

low lichen
shadow locust
#

I was so ready to latch onto any bit of hope.

low lichen
#

If it is, I'd like to see the generated shader code from the graph

shadow locust
#

I did check the frame debugger, but I'll do so again

#

Actually having a lot of trouble finding my DrawMeshInstancedIndirect call in the frame debugger

#

is there a good way to label it or something?

#

Is it even possible for DrawMeshInstancedIndirect to not be instanced?

low lichen
#

I wouldn't think so

#

Can you upload the generated shader code somewhere?

shadow locust
#

yeah one sec

shadow locust
#
        void UnityGetInstanceID_float(out float Out)
        {
        #if UNITY_ANY_INSTANCING_ENABLED
            Out = unity_InstanceID;
        #else
            Out = 0;
        #endif
        }```
#

like based on that it seems like that #if is not being satisfied?

low lichen
#

unity_InstanceID will also have to be set to SV_InstanceID somewhere, probably in one of the include files

shadow locust
#

in case that's somehow not happening

low lichen
#

It looks like it's happening here

struct Attributes
{
     float3 positionOS : POSITION;
     float3 normalOS : NORMAL;
     float4 tangentOS : TANGENT;
     float4 uv1 : TEXCOORD1;
    #if UNITY_ANY_INSTANCING_ENABLED
     uint instanceID : INSTANCEID_SEMANTIC;
    #endif
};
shadow locust
#

so that continues to beg the question why isn't it working T_T

low lichen
#

I'm not ever seeing unity_instanceID assigned to the Attributes.instanceID or Varyings.instanceID

#

And it can't really be in an include file because a separate file wouldn't be able to reference that particular variable, except maybe through a #define

#

Supposedly it's assigned via the UNITY_SETUP_INSTANCE_ID macro

shadow locust
#

so many layers of abstraction

low lichen
#

Which is never used in the generated shader

#

unless it's in some other include file

#

But yeah, I guess UNITY_ANY_INSTANCING_ENABLED might not be defined

#
#if defined(UNITY_INSTANCING_ENABLED) || defined(UNITY_PROCEDURAL_INSTANCING_ENABLED) || defined(UNITY_DOTS_INSTANCING_ENABLED) || defined(UNITY_STEREO_INSTANCING_ENABLED)
    #define UNITY_ANY_INSTANCING_ENABLED 1
#else
    #define UNITY_ANY_INSTANCING_ENABLED 0
#endif
shadow locust
low lichen
#

UNITY_INSTANCING_ENABLED should be defined for instanced draw calls, so UNITY_ANY_INSTANCING_ENABLED should be set

shadow locust
#

god I wish you could just attach a breakpoint to a shader

#

or print something

#

I feel like I'm trying to debug a magic spell

low lichen
#

@shadow locust Do you see anything like this option on the Shader Graph? This will flatten out all the includes and defines you can actually read it.

#

This is a screenshot of the inspector with a regular shader selected

shadow locust
#

yeah these options are there hold on

low lichen
#

Get ready for a huge file

shadow locust
#

compiling 98,000 shader variants πŸ˜›

#

yep

low lichen
#

One of my shaders is 125K lines, but that's handwritten so I expect a generated shader to be much longer than that.

shadow locust
low lichen
#

Did you select preprocess only? It shouldn't be compiling variants for that

shadow locust
#

I did

#

trying again

low lichen
#

Could you send the shader to me?

#

Or I guess I could easily recreate it

shadow locust
#

This is from my phone because it's killing my PC lol

#

Seems to be stuck here >_>

#

But yeah just recreate my screenshot of the graph

#

I've basically reduced the graph to just that for now to try to debug

grand jolt
#

Why do I need to add the near plane to the depth?

#

Doesn't that break the depth being normalized.

#

(Orthographic camera case)

#

I copied this function from URP source code.

#

For SSAO I think.

#

_ProjectionParams.y is near, .z is far.

#

Oh wait...

#

Linear depth is not normalized, this is in world space.

#

I mean view space.

low lichen
#

@shadow locust Did you ever try DrawMeshInstanced instead of Indirect?

shadow locust
#

Yes I've done it in the past, but that was back when my project was using builtin RP

#

and I never had any trouble getting the instance ID when I was manually writing shaders

grand jolt
#

Holy crap, I'm actually finally getting somewhere with doing rain collision in VFX Graph.

#

Dang depth, why do they call it linear depth without specifying the unit.

vague sinew
#

Hey, back to a shader question… how do I remove the magenta from my textures?

#

I was using a custom code to read and remove the magenta by hand before assigning to the texture but now I have to use the resources folder

shadow locust
vague sinew
#

Anything with 0 alpha... Magenta is there because it is how the original game client handles transparency

shadow locust
#

Anyway you could easily have a Shader look for that exact color in the texture and replace it

#

Or clip it

vague sinew
#

Thats what I came here to ask, if you'd allow me.. I'm not really experienced with shaders

shadow locust
#

Are you using built-in or one of the SRPs

vague sinew
#

Yes, the lightweight one I guess... this is the actual shader graph. I'm experimenting with the color replacement

vague sinew
#

This was the only way of getting somewhere close to what I want but the borders are not quite there.. What am I missing?

frosty junco
#

Does anyone know how to access _CameraOpaqueTexture from a shader?

meager pelican
meager pelican
shadow locust
#

Although... didn't realize Nsight existed πŸ€”

fervent tinsel
#

I've tried to like RD for years but I always go back to nsight

#

so... it's bit like blender, why fight the UX if it's clearly not designed for you πŸ˜…

shadow locust
# low lichen <@!179367739574583296> Did you ever try DrawMeshInstanced instead of Indirect?

DrawMeshInstanced works fine. I think I figured out the problem. I might be trying to do something that is simply not supported yet... https://portal.productboard.com/unity/1-unity-platform-rendering-visual-effects/c/61-support-for-drawindirect-drawprocedural?utm_medium=social&utm_source=portal_share

You would be able to modify the ShaderGraph's vertex shader to support custom vertex behavior for use with DrawIndirect or DrawProcedural.

low lichen
shadow locust
#

I can't really see how you can reasonably use DrawMeshInstancedIndirect without Instance ID at the very least so I'm really not sure how you're supposed to use it with shader graph at all if this doesn't work.

#

I'm already hackily using a texture as a data buffer shader graph doesn't support GraphicsBuffer/ComputeBuffer yet. This is so frustrating 😠

meager pelican
#

Time to write SRP shaders by hand....
I mean, you can only expect "easy tools" to do so much. IMO.

meager pelican
shadow locust
meager pelican
#

You'd use the instance id node, and map it to different colors to see if it changes from 0 to anything else.

If you tried that, and it didn't work. It didn't work.

shadow locust
meager pelican
#

Oh. lol.

#

Well there's that.

#

Do you look up pos based on id?

shadow locust
#

Yes that's the plan

meager pelican
#

If so, you're getting all the same id...0...and they all end up in the same pos. But that's set in the vert?

meager pelican
#

frack.

#

Well you could write a test case, and randomize some verts. Oh hell.

shadow locust
meager pelican
#

"Improved documentation" is on the planned list.
πŸ˜‚

shadow locust
#

🀣

shadow locust
meager pelican
#

Yeah. Wish I could have helped.
The thing is, without compute buffers, it's a PITA to mess with this anyway. Oy.

grand jolt
#

Does anybody know why terrain textures are power of 2 + 1?

#

I hack around weird stuff being on the edges of a terrain splatmap texture by clamping the uv with a 4 texel inset but I don't get why it's this way.

#

If I don't skip the 4 outermost texels I get color leaking from as much as 40 texels away onto the border.

timid minnow
#

Tried making a UI related shader graph

#

What am I missing here?

#

I even added it to my shader graph and I still get the error:

#

Ugh... so it needs to be exposed? I don't even use this feature...

mental snow
#

So I'm new to Unity and I'm trying to use the shader graph to copy my Blender shaders, but I'm like 5 minutes in and I already encountered a peculiar error which I can't really explain

#

For some reason the scrolling intensity does not work in the actual viewport/game but it works as expected in the graph editor

kind juniper
mental snow
#

Saved the shader before the depicted gif, yes. Gimme a sec, I figured I would update Unity to a newer version to see if that helped

#

I was using the 2020.3.22f1 LTS version

#

Will try with a newer one

#

Nothing complicated

#

@kind juniper Could you take a look and see if you see something glaringly obvious?

#

I'm not familiar with unitys shader graph

kind juniper
mental snow
#

30

#

Reducing or increasing had no visible effect

kind juniper
#

And rune color?

mental snow
#

HDR orange with 4 intensity

#

I should probably cut out glow intensity and just change intensity value of the HDR anyway

kind juniper
#

Afaik hdr intensity is not represented in the shader graph color node, I think there's another node that representes intensity.

#

Also, is the game paused by any chance? is timeScale set to 0?

mental snow
#

Sure, but here I am multiplying with a value of between 0-1 from the gradient so it should lower the intensity

#

As the white will represent normal color while the darker areas of the voronoi should represent a darker blend

#

Just like the material preview

#

Works as expected in blender also

#

Not paused, no timescale to zero

kind juniper
#

Is it HDRP?

mental snow
#

Yes

kind juniper
mental snow
#

@kind juniper I'm apparently just too unfamiliar with unity -- it worked fine in the game view port, just not in the dev viewport

kind juniper
mental snow
#

After checking through a ton of menus I think I found the problem

#

By default basically all render layers were unchecked

#

in the editor

#

The one that solved it was the "Always refresh" layer

#

@kind juniper thanks for your time anyways, I appreciate it

kind juniper
mental snow
#

@kind juniper One more question -- is the Normal from Height really so incredibly terrible?

#

pixellated mess

woeful canyon
#

problem might be that there is some very sudden increases in value from your voronoi noise

#

so the normal changes very quickly and produces a pixeled reesult

#

idk though ive never succesfully used normal from height

mental snow
#

The blender equivalent is just passing the texture into a bump conversion so I expected it to work the same in Unity

#

But it's literally ultra pixellated

#

All of it

kind juniper
#

Could be related to your texture resolution? I wonder where it goes from procedural data to the actual pixel texture.πŸ€”

mental snow
#

No way that is what is happening

#

Looks like this function is rendering it in chunks instead of pixels

#

Or something

kind juniper
#

Actually it doesn't seem to be completely pixelated. I think it might have to do with extreme values.πŸ€”

woeful canyon
#

try clamping it

#

clamp and then normal from height

mental snow
#

Clamping does nothing

woeful canyon
#

did you try it?

mental snow
#

Yes

#

All the values are already between 0-1 as they just represent the amount of white so there should be no extreme values

#

clamping only changes the cutoff value where the normals arent being generated

#

So you are only "raising" or "lowering" the ceiling

#

Giving such a result:

#

Accidentally had the clamp into the strength there but same result without

#

I think this function is broken

#

Or it renders chunks instead of pixels

#

Doesnt appear to be in the same resolution as the source voronoi

#

But I see there is a different option to generate normals, Normal from Texture

#

But the texture input does not accept the output from the voronoi

woeful canyon
#

yeah

mental snow
#

For some reason

#

And there is no node to generate texture from voronoi either looks like

woeful canyon
#

could you bake the voronoi texture

mental snow
#

I could but that would completely defeat the purpose of the procedural aspect

#

btw thanks @woeful canyon @kind juniper for trying to help

#

This is the result I have from blender

#

The reason I want it procedural

#

Is because the actual UVs of my models are shrunk to a single pixel

#

Which I then move on a 8x8 color palette

#

To color it

#

So all the normals, smoothness, metallic, emissions etc have to be made procedurally

woeful canyon
#

why are you shrinking the UVs of the model to 1 pixel?

#

you mean like 0-1?

kind juniper
#

I think it might have to do with the uvs that you input into the voronoi node.

mental snow
#

The UVs are generated so that doesn't make sense

#

All of these are made without using the models UV

#

I am 100% certain at this point that it's just a disfunctional node (Normal from Height)

woeful canyon
#

have you tried testing it with a more basic case?

#

like just a procedural left to right gradient or something

mental snow
#

Yes, it pixellates

woeful canyon
#

yeah that sounds broken

mental snow
#

It looks like it's rendering chunks of 2x2 by normalizing the 4 pixels

#

Meaning you only get 1/4th the resolution

woeful canyon
#

classic unity

mental snow
#

By using this function

#

I baked a texture and used the normal from texture and it worked normally despite equal values

#

So it appears to be just this function

woeful canyon
#

yeah thats what people said

mental snow
#

Which kinda breaks procedural UV mapping..

woeful canyon
#

why do you even need it to be procedural?

mental snow
#

Because then the size of the UVs of the object won't matter, the material will still appear the same

#

You just tweak the values to get different sorts of leather

#

Instead of having ugly ass tiling textures etc

#

You will have generated a never-repeating pattern

#

If you see the above screenshot of the sword handle -- the actual UV of the handle is the size of 1 pixel only

#

Yet it has details in a limitless resolution

woeful canyon
#

how are you getting the voronoi to loop around the surface?

#

doesnt look like tri-planar mapping

#

is it 3D voronoi noise?

mental snow
#

You wouldn't need to do triplanar mapping with a generated UV afaik

#

@tacit parcel Any feasible workaround?

tacit parcel
#

I think you could do it by code instead of shader

mental snow
#

God damnit

#

:p

woeful canyon
#

make a custom node and write your own normal from height maybe

tacit parcel
#

btw, I was expecting the node samples the neighboring pixels to generate the normal, yet unity decides to use ddx/y

woeful canyon
#

how does it even calculate the derivative

#

on nvidia documentation:
"The specific way the partial derivative is computed is implementation-dependent. Typically fragments are rasterized in 2x2 arrangements of fragments (called quad-fragments) and the partial derivatives of a variable is computed by differencing with the adjacent horizontal fragment in the quad-fragment."

#

sounds like it is basically comparing neighbouring pixels

#

hm
"The partial derivative computation may incorrect when ddx is used in control flow paths where not all the fragments within a quad-fragment have branched the same way."

#

is there any branching logic in your shader graph?

tacit parcel
woeful canyon
#

i mean like branching logic before normal from height gets called

#

because that apparently might mess up the derivatives and mess up the normal calculation

#

although when you tested it, it broke for just a simple gradient

#

so its probably broken even without logic maybe breaking it

mental snow
#

It breaks no matter what looks like

#

Actually I'm wrong

#

Doesn't break if the gradient is onedirectional

#

Not that it helps me I guess

#

Just weird how unity lacks such a basic function

#

Blender has it

tacit parcel
#

Btw, here's a good explanation from Ben Golus
https://forum.unity.com/threads/low-resolution-or-bad-anti-aliasing-on-normal-from-height.1051733/#post-6808757

The ddx and ddy functions work on a grid of 2x2 pixel groups (called pixel quads) across the screen, so if there's an edge that runs through the middle of a pixel quad it can calculate an approximate normal. If the edge is between two pixel quads then neither "see" it and you get no slope. Thus you get the above aliasing.

mental snow
#

Wow, beautiful

#

Pretty elaborate setup for what is just 1 node in blender but sure

#

If that's what it takes

woeful canyon
#

i think you can export blender materials to unity though i dont know how successful that is

mental snow
#

I doubt that tbh

#

Probably would register the simple properties just fine but I doubt it would transfer any functions

#

After taking a look at it I can't really replicate it for my shapes @tacit parcel

#

I wonder why the Normal from Texture requires a texture spesifically

#

The equivalent node in blender only requires rgb input

kind juniper
mental snow
#

I just want to recreate my blender creations in Unity and I'm just disappointed given that it doesnt really appear to be viable after all

kind juniper
#

What's the name of the node in blender btw?

mental snow
#

Bump

#

I don't think it should eat that much performance given it's 3 calculations per pixel that doesn't really need to change in real time after generation

#

Unreal appears to be capable of procedural normal map generation

#

But I despise c++ compared to C#

#

Fuck it I'll just bake I've wasted enough time as is

#

Nvm, that didn't work because my UV's are scaled to 1 pixel lol

kind juniper
#

That's when the triplanar projection comes to play.

grand jolt
#

In Shader Graph, is it possible to use a keyword to switch between opaque and transparent?

#

Right now I'm maintaining two basically identical shaders, with the only difference being one supports transparency and the other doesn't.

#

Having everything use the transparent shader isn't an option - that would mean I lose out on all the (very much used) benefits of a deferred renderer, and likely some other optimizations regarding shadow blending and such.

west eagle
#

@grand jolt just write one transparent shader then change render queue at runtime

grand jolt
#

I guess that could work, but then I'm branching on the GPU as well as looping over every single material as they're created.

west eagle
#

well, render queue is on the material so it isn't relevant to shader as long as the shader support transparent

slim steppe
#

i got a shader which uses vertex color to do some stuff. The colors are set in a particle system but it only works with the start color and not the color over lifetime
what am i doing wrong?

torpid lichen
#

Guys its me again im sure youre so happy

#

So i need to sample the surface/vertex normal of an adjacent pixel in the fragment shader, is this possible in shader graph ?

#

i would have expected nor be able to input a position into the Normal Vector node but its not possible

#

Do i have to use code for this ?

meager pelican
# tacit parcel Btw, here's a good explanation from Ben Golus https://forum.unity.com/threads/lo...

Bglous does it again.

You can, as he implies, sample 3 points on your procedural height with tiny offsets between them, and calc your own surface normal that way, rather than using the derivatives. Pretty common way to do it, in fact, when you have height-mapped stuff. Google around for the formula. @mental snow
It's not that bad, it's "just" that it requires 3 sample operations (well two others and the current pixel). And voroni calcs can be expensive.
It's common to construct two vectors along the surface using the 3 points you know, and then do a cross product (see below) and watch out for handedness. (again google this stuff).

meager pelican
meager pelican
#

If so you can sample the normal map to get nearby data.
If not, you calc it?
But otherwise the GPU only knows the ddx/ddy of the float3 normal value of the current pixel, that MAY be of use depending on what you're after.
From here: http://www.aclockworkberry.com/shader-derivative-functions/
Derivatives can be used to compute the current triangle’s face normal in a fragment shader. The horizontal and vertical derivatives of the current fragment’s world-position are two vectors laying in the triangle’s surface. Their cross product is a vector orthogonal to the surface and its norm is the triangle’s normal vector
But see the discussion above about some inherent "dangers" of DDX/DDY. In this case, though, since you're doing a derivative of the actual normal value being passed in per pixel, not deriving it, it should be OK.

I think. πŸ˜‰

tacit parcel
#

if the textures doesnt change at runtime (like, only generated once), I'd vote generating the voronoi heightmap and normal by code, less shader computation too

meager pelican
#

Agreed.

torpid lichen
#

what i wanna do then is edge detect this, that why i wanna sample the normal left, right, up and down from the current pixel to compare them

#

i dont know if this is a stupid approach

#

Should i just bake the normals into a normal map and sample from there ?

meager pelican
#

baking them would make your life easier, IMO.

However, edge-detection (your real question) is an art in and of itself. There are many methods, and I'd start with researching them.

DDX/DDY is not uncommon though. But it tends to be one-sided as the GPU "sweeps" through things. So you'd "know" the change for left and the top, let's say, but not the right and the bottom pixel values.

Whereas if you can sample a map, you can get your !8! adjacent pixel values, if you want that many.

I don't know all methods, nor all code for them, off the top of my head, but it's a good research project. Some may require more passes than others.

#

Also research "outlining" and maybe "toon outline".
Unity has a tut on that too.

torpid lichen
#

i intend to do simple 3x3 sobel edge detection, and then go from there in case it doesnt look good enough

meager pelican
#

Cool, sounds like you're "on the path".

torpid lichen
#

yeah, i researched those, but they are not to my liking, backface culling leaves much to be desired and normal color edge detection too

#

Also unrelated but kinda related, is calculating ambient occlusion in shader graph realistic or should i get that out of my head ?

meager pelican
#

lol.
I'm not the one to ask, since I only EAT spaghetti, not draw shaders with it.

tender orchid
#

Hi all, are there any shader wizards that can give me a hand? I'm making a scene with a pre-rendered background in Unity, which combines the top-left image with a depth pass in the lower-left to give us a composite on the top-right.
I now want to be able to apply shadows to the scene, and I'm assuming we use a shadow pass, but I have no idea where to even start.

meager pelican
#

I'm confused, the top-right image already has shadows.
But maybe start with telling us what pipeline you're working in.

Shadows are "automagic" in unity when using lit shaders any any pipeline, for the objects themselves. BUT, if you're combining images in some sort of full-pass post-processing thing, you're probably looking to research "screen space shadows".

#

If you're adding shadows for the player character, I'd expect a lit shader to do that for you. But maybe I don't understand.

slim tulip
#

Greetings gentlemen, would anyone happen to know how to combine some effects of shader graph shader and just a shader?
I've got a cool glitch shader from asset store, but it doesn't work quite well with my sprites, since they are PNG files with transparent background. On the picture attached there's the Original Sprite, a weird way Shader Graph sees it, and a way to clean it with shader graph. But shader that applies desired effect is written in code, while my way of cleaning PNGs is done via shader graph. Is there a way to combine two shaders? Kinda give output of one to the input of the other? Or perhaps transform code into shader graph?

tender orchid
# meager pelican I'm confused, the top-right image already has shadows. But maybe start with tell...

Yes, I should have been clearer. The top left image is a pre-rendered image from Blender, complete with shadows. My character in Unity can walk around the scene and go in front of and behind the pink objects by using a depth writing shader and the depth pass image in the bottom left. This all works fine, but now I want the character's shadow (which is non-existent at the moment) to be applied to the pre-rendered image in the background, as well as shadows from the scene to be applied to the character itself.
Here's a picture of the effect used in Resident Evil. The background is a still image but the character's shadows can still 'interact' with the environment, either by shader pass magic or by potentially using invisible geometry to catch the shadows.

patent plinth
#

I don't think that's still image

tender orchid
#

They are absolutely still images, the gamecube didnt have nearly enough power to do these realtime

meager pelican
# tender orchid

Shadows on or from objects are CAST (and later received) by a shadow caster pass, in the lit shaders.
So if your character casts a shadow, using a lit shader, it should cast onto a <something>. The problem you'll have is that if they are images (I don't mean textures on 3D, I mean flat geometry) it's the shader for that/those objects that have to calculate shadows while drawing them or you distort the shadows into geometry shapes while casting them.

So somehow you'll have to either fake geometry data, and write your own custom shadowcaster pass to magically update the shadow map as if there was real geometry there, or the shadow receiving logic will have to account for that and distort the shadow map, similar to what you'd do with a decal.

I have no idea how to really pull it off, never having done it. But I'm dubious about doing any custom passes like that in SG, unless you do ALL custom lighting yourself using unlit shader and one hell of a set of sub-graphs to fake it all up.

#

And I still don't know what pipeline you're in.

#

You could try researching "screen space shadows" for some ideas. Maybe also related as I mentioned above....decals.

#

However mixing "canned" shadows and real time shadows is tricky...like I wouldn't. If I had to do screen-space shadows anyway, I'd probably do the whole damn scene and not have shadows out of blender.

Because you want scene shadows cast onto your player too, and you don't want double-shadows (hitting player and also not hitting player) if that's even possible. My head hurts now.

meager pelican
#

@tender orchid
This wiki indicates As a result, the graphical style of the remake features 3D models on top of pre-rendered backgrounds like early Resident Evil games.
https://en.wikipedia.org/wiki/Resident_Evil_(2002_video_game)#cite_note-NGC_Mag_preview-15

Resident Evil is a survival horror video game developed by Capcom Production Studio 4 and published by Capcom. Released for the GameCube video game console in 2002, it is a remake of the 1996 PlayStation game Resident Evil, the first installment in the Resident Evil video game series. The story takes place in 1998 near the fictional Midwestern t...

#

Verifying your original assertion.

tender orchid
#

At least we know it's possible!

#

I'm going to have another go at it tomorrow - I'm fine with having the original geometry in the scene to catch/cast shadows, just not have the objects themselves visible.

low lichen
#

And those shadows will still be realtime shadowmap quality, not raytraced quality like in the render.

tender orchid
#

I'm fine with it being realtime quality, if it's good enough for Resi then it's good enough for me

low lichen
meager pelican
#

They pulled all that off in 2002 with a gamecube. They must have made compromises somewhere. It's just that many of the articles cited in the wiki that have discussions by the programmers are in Japanese...

low kettle
#

Quick question, can you set the values of a gradient in a shader from a script and if so how?

meager pelican
#

Quick answer, gradients in SG (if you're in SRP) are calcs, so you could feed them in. See docs on the gradient node.
As for other methods, easiest IMO is to use a texture that you create in script. Like a 256 x 1 texture that you just sample from 0 to 1 in the x value.

low kettle
#

ok thank you

tender orchid
meager pelican
tender orchid
#

No leaf shadows on Chris

#

although this shot begs to differ...

meager pelican
#

window pane shadows....

low lichen
#

I think some of the shadows are actually also from dynamic objects casting realtime shadows on other dynamic objects and the environment

#

I saw some examples of moving shadows, like from a fireplace

tender orchid
#

I think so too - zombies also cast shadows on him. I reckon that window pane is an object

meager pelican
#

@tender orchidAre you planning on running on low-end hardware?
If you're "OK" with having some geometry to receive shadows anyway, why not do a combination of real time and baked shadows and "just" have some normal-mapped low-res geometry?

tender orchid
#

I've got it so objwcts have their mesh renderer set to Shadows Only, so they can cast onto the player at least

meager pelican
#

IDK why you even need to do that. I mean, texture mapped quads for walls and door parts, a few rough geometry for insets and stuff, windows panes....

These days, since you're not on a 2002 gamecube, you can pull it off with "real" geometry, if you get smart about keeping it low poly.
Just my 2 cents.

#

Then it all "just works". Why fight the engine? Do some tests on lowest hardware.

tender orchid
#

I could do it all realtime, but I want to stick to the late 90's pre-rendered vibe - the depthpassed BG images are an absolute must.

#

I can cast shadows onto fake geometry, I can receive shadows from said fake geometry, but the fake geometry is also casting a shadow onto the floor (along with its prerendered shadow). Should I try passing along the shadow map from Blender to do a shader that discards the shadow? Or can I tell the floor to ignore shadows from certain objects?

keen edge
#

pretty insane how they did it

tender orchid
#

it still holds up today, doesn't it?

keen edge
#

like something's off

tender orchid
tender orchid
grand jolt
#

Nice

honest basin
#

Im trying to get an image with an alpha channel to work, but the standard shader has no options for this, Which one should i be using?

tight saffron
#

Hey! I'm trying to make an eye shader and one of the things I'm trying to do it put a top down gradient on it but I'm running into an issue.

Right now I'm using a position node to control the gradient. World works how I want it to work where I can rotate the eyes and the gradient doesn't rotate with it, but when I move the model up and down the gradient doesn't follow the model.

Object mode solves the moving problem but then the gradient rotates with the eye.

So is there a way get the best of both worlds? Gradient following but also not rotating with it?

low lichen
tight saffron
#

@low lichen I just gave that a shot but its doing some funky stuff basically the causing the gradient to go up as the eye rotates up and down

#

I think I figured it out my eyes were being goofy

vale shadow
#

Hello guys, I want to make the typical hit animation that make the object go white and normal color fast. But I can't find any information about that. Also I need to make it with post processing effects so I need to use lit sprites. What can I do?

timid minnow
#

Trying to make an unlit shader graph in HDRP to use on the Image component... how do I make the vertex alpha function properly? This doesn't seem to work correctly unless the alpha is 0 (then it disappears)... any other value and it's 100% opaque.

grand jolt
#

Super easy solution.

timid minnow
# timid minnow Trying to make an unlit shader graph in HDRP to use on the Image component... ho...

https://answers.unity.com/questions/845358/custom-shader-with-unity-46-ui-canvas-group-alpha.html
It seems that maybe I need to use the tag
Blend SrcAlpha OneMinusSrcAlpha
however, it's not clear how to do this in shader graph? Is there a custom function that could be deployed to route the alpha in correctly?

marsh gull
#

Hey guys. I'm trying to generate an outline around a 2d character made up of multiple sprites (PSD importer, rigged). My shader creates outlines around each individual sprite within the character, but I'm trying to find a way to make it only go around the entire group of sprites. Is there any way to do this? I can't find anything on this topic anywhere.

#

Perhaps there is any way to input all of the textures from all of the sprites the material is applied to into the shader graph, so it gets processed as a whole?

west eagle
#

@marsh gull you may need a postprocess shader to do the outline

marsh gull
#

I'm also guessing it might be possible to separate the player into a separate camera, and then apply a shader to the camera somehow, but this is just speculation as there isn't much on this out there

west eagle
#

normally it is for 3D but same tech

#

also there is another way, write a shader control all animations and write code to transfer animation to texture

#

then do the outline wthin the shader, but this is way complicated than post processing

#

however if you have 10000 characters ,this will save a lot cpu on play animation

marsh gull
#

That sounds like it would make me drop the idea entirely out of frustration, haha.
The post processing idea sounds like it has merit but I'm worried this approach would apply an outline to everything in the scene?

west eagle
#

well that is the way everybody use,almost every outline asset sell on asset store use this way

marsh gull
#

Wouldn't really work in my case, I'm just trying to have outlines on specific sprites.

#

So far it has worked through a shadergraph + material for specific sprites that need outlines, but the issue I ran into is when I have a group of sprites that should share a single outline

west eagle
#

no it won't draw outline on everything

peak ridge
#

ive disabled screenspace shadows and was under the impression they should fall back to light space shadowmaps, but instead my directional lights dont cast shadows at all

#

this happens in a blank project, any idea why?

#

im not using hdrp or anything

peak ridge
#

well for some reason, its suddenly working. just had to keep disabling things πŸ€·β€β™€οΈ

#

ok wait, ive got it and i think this is a bug

#

it only ever works if cascades are disabled. here's cascades enabled, obviously rendering the shadow maps correctly, yet not displaying on anything in the world

#

disabling cascades it suddenly works

#

using 2020.1.3f1

kind juniper
# peak ridge disabling cascades it suddenly works

Apparently that's by design. Shadow cascades require screen space shadows to calculate the cascade areas/resolutions if I get it right.
https://forum.unity.com/threads/use-cascade-parameters-without-screen-space-shadows-enable.1012732/

#

At least in BIRP

peak ridge
#

thanks for the link!
that is very odd and definitely was not always the case.

kind juniper
#

I donno if it was different at some point - never tested it, but I don't think there were any changes to that area in the last few years. Might've been like that since unity 5 or even before.

peak ridge
#

that sounds about right πŸ˜›

dim yoke
#

<@&502884371011731486>

ocean mural
#

!ban @grand jolt Nitro Scam

echo moatBOT
#

dynoSuccess Faye#1806 was banned

heady axle
#

I would like to have a shader graph that displays a texture on a procedural terrain. I was using the position node and all texture was stretched on some faces. The texture is mapped properly on view mode but I cant use that for obvious reasons. Any Ideas?\

#

What i want:

#

What i got:

tawny cedar
#

so i have a texture, and i want to apply another texture over it with 50% alpha for example to simulate lighting

#

you can see in the left there are the two textures and right is 50% alpha black pasted over the grass texture

#

how could i approach this in a shader?

#

basically i want two uvs on two channel

#

first is texture

#

second is lighting texture and both are from the same material

#

and put lighting over the texture (not blend them)

regal stag
# heady axle I would like to have a shader graph that displays a texture on a procedural ter...

You could project a texture from above by using the Position node -> Split and take the R and B axis into a Vector2 for the UVs. If the terrain has any vertical surfaces that'll still cause the texture to stretch though. If that's needed too, then you'd want to use something like triplanar mapping (a technique that samples the texture 3 times projected in each direction and blends based on normals). There's a Triplanar node to handle it for you.

kind juniper
marsh terrace
#

so I need some help here

#

my artist sent me a object, a shadergraph file and a mat file

#

however, the material is pink and for the shadergraph, i installed the shadergraph package and I don't know what to do

#

I set out the object in the scene, slotted it's material and tried changing its shader to the shadergraph that was given to me, but everything is still pink and stuff

marsh terrace
#

it seems nothing was copied in relation to the shader graph

#

i have pasted the meta files aswell, does anyone know why this imported incorrectly?

regal stag
# marsh terrace

It looks like the graph is intended for the Universal render pipeline. If you're in 2021.2 I think you can now add the Built-in RP as an active target in those graph settings instead, or you'll need to install the URP package (see https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@11.0/manual/InstallingAndConfiguringURP.html). Though it doesn't look like the graph is doing all that much, could probably just use the Standard shader (or an unlit one?) as a replacement.
You should probably also talk to your artist and make sure you both agree on which render pipeline you're using.

marsh terrace
#

yea, it's definitely URP, I'm converting my project to URP right now (and fixing ProBuilder URP support as well)

#

the shadergraph supposedly should make the grass have a animation giving that wind feel to it

#

according to my artist

drifting snow
#

I need a little help

#

I wanna add a lightmap shader within the unity 3d standard shader

#

how can I do that

#

here is the lightmap shader

#
    {
        _Color ("Main Color", Color) = (1,1,1,1)
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _LightMap ("Lightmap (RGB)", 2D) = "black" { LightmapMode }
    }

    SubShader
    {
        Pass
        {
            Name "BASE"
            Tags {"LightMode" = "Always"}
    
            BindChannels {
                Bind "Vertex", vertex
                Bind "texcoord1", texcoord0 // lightmap uses 2nd uv
                Bind "texcoord", texcoord1 // main uses 1st uv
            }
            SetTexture [_LightMap] {
                constantColor [_Color]
                combine texture * constant
            }
            SetTexture [_MainTex] {
                combine texture * previous
            }
        }
    }```
tawny cedar
#

but no default shader supports two uv channels

drifting snow
#

hello

marsh terrace
#

it's supposed to be a grass sway

#

is there supposed to be something more to import alongside the .shadergraph file?

regal stag
#

If the graph doesn't have any other nodes I'd assume they gave you the wrong graph

amber egret
#

hi! im making a mountain with the terrain tools, and i cant seem to figure out how to make the steeper parts of the mountain made out of rock, and the flatter parts of snow. i would like to do this with a shader. does anyone know how to do it?

torpid lichen
#

your can get the vertex position, split it, and map the height coordinate to different colors

#

Guys i really dont wanna sound like a broken record, but just so im sure, does anyone know if it is possible to sample the normal vector of another pixel than the current one in either Shader Graph or HLSL ?

tight saffron
#

quick question: if I wanted to overlay this white dot on top of my texture how would I do that. most of the combining operators only seem to like black but I just want the white from this. (The dot needs to be white in the end)

lusty badger
tight saffron
#

That worked!

fathom kiln
torpid lichen
tight saffron
tight phoenix
#

is Shadergraph able to solve this overlapping problem?

#

Online I read about Stencil Buffers being used to achieve this but thusfar I havent been able to find a tutorial on how to achieve it

crude bolt
#

how do I add volumetric fog?

#

I just want things that are further away from the camera to become less visible and more blue (it's underwater) in specific areas

pseudo narwhal
tawny cedar
#

how can i make my texture trasparent in shader graph?

#

somebody suggested multiplying by the alpha channel but it just makes it black

vocal narwhal
#

it is transparent

#

just use the alpha channel

#

just because the nodes do not display it as transparency doesn't mean the data isn't there in the .a/.w coordinate

#

you're just discarding it right at the end

tawny cedar
#

ohh

#

how do i disconnect a single node btw?

vocal narwhal
#

I forget what the nodes are, but it might be called Split?

tawny cedar
vocal narwhal
#

If you want the output to have alpha, yes

tawny cedar
#

umm it just makes it all transparent

#

edges are still messed up

#

ah no wait now i see

#

its out 4

#

do i just add a vector 4? πŸ€”

vocal narwhal
#

well, these operations don't make sense for a start

#

there's no reason to do this, so make sure you've removed it

tawny cedar
#

how do i convert from a split back into a 1?

#

so rgb back into 1

vocal narwhal
# tawny cedar

also, what you did there didn't make sense either. That uses .r

#

you need to use .a from a split node.

#

Combine

#

just pass the out from the lerp into albedo, and the a from the split into alpha

tawny cedar
#

worked πŸ˜„

#

ty for the help @vocal narwhal

#

now let's see if i can actually use the two uv channels lol

#

nope 😦

#

current shader

#

and my code

#
        mesh = GetComponent<MeshFilter> ().mesh;
  
        float x = transform.position.x;
        float y = transform.position.y;
        float z = transform.position.z;
  
        newVertices.Add( new Vector3 (x  , y  , z ));
        newVertices.Add( new Vector3 (x + 1 , y  , z ));
        newVertices.Add( new Vector3 (x + 1 , y-1 , z ));
        newVertices.Add( new Vector3 (x  , y-1 , z ));
  
        newTriangles.Add(0);
        newTriangles.Add(1);
        newTriangles.Add(3);
        newTriangles.Add(1);
        newTriangles.Add(2);
        newTriangles.Add(3);

        newUV.Add(new Vector2 (tUnit * tGrass.x, tUnit * tGrass.y + tUnit));
        newUV.Add(new Vector2 (tUnit * tGrass.x + tUnit, tUnit * tGrass.y + tUnit));
        newUV.Add(new Vector2 (tUnit * tGrass.x + tUnit, tUnit * tGrass.y));
        newUV.Add(new Vector2 (tUnit * tGrass.x, tUnit * tGrass.y));

        mesh.Clear ();
        mesh.vertices = newVertices.ToArray();
        mesh.triangles = newTriangles.ToArray();
    mesh.SetUVs(0, newUV.ToArray());
    mesh.RecalculateNormals ();

    newUV.Clear();

        newUV.Add(new Vector2 (tUnit * tOne.x, tUnit * tOne.y + tUnit));
        newUV.Add(new Vector2 (tUnit * tOne.x + tUnit, tUnit * tOne.y + tUnit));
        newUV.Add(new Vector2 (tUnit * tOne.x + tUnit, tUnit * tOne.y));
        newUV.Add(new Vector2 (tUnit * tOne.x, tUnit * tOne.y));
        
        
        mesh.SetUVs(1, newUV.ToArray());
        mesh.SetUVs(2, newUV.ToArray());
        mesh.SetUVs(3, newUV.ToArray());
        mesh.SetUVs(4, newUV.ToArray());
#

why is the second uv channel being ignored?

plush fog
#

The blend factor is 0, the lerp factor is 0

tawny cedar
#

i see here in the example they are using a split with in4 and out 1

#

how can you do that? πŸ€”

plush fog
#

just link 1 to 4. You can create a float node and link it

#

or link whatever you need into it, idk what you're trying to do

tawny cedar
#

lol, well i don't exactly understand what the T for lerp does, basically i want my UV2 to be overlayed over the UV0

wraith inlet
plush fog
#

Try this? Note that blend is set to Overwrite. And if you need alpha to apply when blending uv2, send the uv2 alpha into the blend factor

tawny cedar
#

here's an example of the final effect

#

so basically this will be the lighting for my textures

plush fog
#

Yeah that's what overwrite does. I guess I don't understand what the goal is. You can change it back to overlay or whatever

tawny cedar
#

i take one piece of the same texture

#

plop it over the other texture

#

and it simulates lighting

#

when it's fully black it just turns out black

#

so basically a copy paste of UV2 over UV0

plush fog
#

The top left grey square has transparency right? Have you tried linking the alpha of UV2 into the blend factor?

tawny cedar
#

the first block is just a black block with alpha set to 50%

plush fog
#

Can also try this

tawny cedar
#

ahh right multiply

#

lemme see

#

so it sorta worked

#

im displaying a pink number over the grass texture

#

but the rest of the grass dissapeared

#

lemme try with the 50% alpha block

plush fog
#

If it's not shaded it should be multiplied by white

tawny cedar
#

hmmm

#

well i'm thinking like this

#

i want that final color

#

but i don't want the alpha to apply

#

because the alpha will make the other block transparent as well

#

but how to multiply so it only adds the color of that semi transparent black over it

#

hmm, just add doesn't seem to do anything at all πŸ€”

plush fog
#

You can just multiply the base texture by a value between 0 and 1 (white is 1, black is 0)

tawny cedar
#

so i made separate textures to test

#

this is the result

#

and textures i used

#

if you multiply it's still too much black

plush fog
#

You're multiplying by pure black so it's gonna output pure black. If you want a 50% shade multiply by grey

#

Oh and alpha should be 1 everywhere on the shadow texture

tawny cedar
#

not sure this is the right way

#

if i multiply by pure black it's still visible

#

maybe i need to figure out the formula of what happens when a 50% black texture is pasted over the texture in the aseprite editor πŸ€”

#

applying 50% black to that red basically makes all rbg values in half πŸ€”

#

so i guess i take the alpha channel extrapolate it to a value between 0 and 1 and then multiply all rbg values by it πŸ€”

#

cause when it's by 0 it's gonna be 0 which is black

kindred granite
tawny cedar
#

hmm so it worked, i just linked the alpha channel directly into the multiply second value

#

but it's inverted

#

the more alpha the brigher it is

#

how can i invert it somehow?

#

invert colors doesn't work

#

cause i guess the alpha is ignored?

#

it worked with subtract UnityChanCelebrate

tawny cedar
#

it works!

#

thanks for the support @vocal narwhal and @plush fog !

#

here's the final shader

tawny cedar
#

i'm back with another issue, i'm trying to make it so a different lighting hew is added to the lighting, yellow in this example

#

but when rbga is all 0 on the secondary lighting texture

#

it makes it look all weird

#

i don't understand why this is happening, if i'm adding just 0 to all rgb they should all be the same as before

#

this doesn't happen if i remove the addition

#

hmm even in the preview window it looks normal πŸ€”

crude bolt
meager pelican
# tawny cedar hmm even in the preview window it looks normal πŸ€”

It's all color math. And colors are "just" vector4 floats (float4's).
You can do it manually, as you're doing, or you can use some automatic blend modes.
But to see more about how to think about it....have you read this thoroughly? Including the alpha calcs?
https://docs.unity3d.com/Manual/SL-Blend.html
In particular:
finalValue = sourceFactor * sourceValue operation destinationFactor * destinationValue
there's tables for the different operations, and factors/values.
Like you mentioned something was inverted in alpha, which indicates to me that you should be using (1-alpha) somewhere.
And there's multiply, additive, etc. operations.

It's all just number crunching. There's really nothing special about it, other than maybe overriding alpha output in an opaque queue.

#

Grab a piece of paper and figure out what you want to happen with some sample values.

native spoke
#

someone know where i can find some textures for a procedural Sand Dune Mesh Shader? Or a tutorial πŸ™‚

tawny cedar
#

And it worked!

marsh terrace
#

So I managed to get my artist's shader to work with a grass sway and everything. However, it seems that the shader doesn't compute shadows from meshes. Would anyone know how could I make it so the meshes actually project shadows into the ground/grass with the shader applied?

#

May I add, how can I make the shader accept Unity's lightning as well? It seems the directional lightning is not affecting the shader in any capacity

marsh terrace
#

I have almost zero knowledge of shaders and this shadergraph seems complex enough and I don't even know where to begin

paper oar
#

Can somebody help? How to remove OpenGL validation at runtime? Oculus does it inside their .so file - how can we do it in Unity?

clear vector
#

Hi guys, i'm trying to make first steps with HLSL and right now trying to write custom function in shader graph. ShaderGraph gives me an error on my CustomFunction node,
Is this because ShaderGraph doesn't support some shader model? What i'm trying to do is to make an int from my float, so i want to use ceil or floor, but both produces and error. My code is simple as float intPresicion = ceil(Precision); or float intPresicion = floor(Precision);
As i can understand error says, that there is no such a function with 1 parameter, but msdn tell me that there is https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-floor

dim yoke
dim yoke
clear vector
#

I was thinking that there is some bult-in defenition for Precision value, so i have tried to replace it with Itereation name and error has gone, then i have wrote Precision name back and there is still no such error. But i have new, now "undeclared identifier ReplaceColor"

My hsls code:

void ReplaceColorCyclically_float(float3 In, float3 To, float Precision, out float Out)
{
    float intPresicion = floor (Precision);
    float3 colorStepHalf = (float3(1, 1, 1) / intPresicion) / 2;
    float colorReplaceRange = length(colorStepHalf);
    Out = In;

    for (int i = 0; i < intPresicion; i++)
    {
        float3 from = i * 2 * colorStepHalf;
        Out = ReplaceColor (Out, from, To, colorReplaceRange, 1);
    }
}
float3 ReplaceColor(float3 In, float3 From, float3 To, float Range, float Fuzziness)
{
    return lerp(To, In, saturate((distance(From, In) - Range) / max(Fuzziness, 1e-5f)));
}
#

oh, defining should go before call, lol

marsh terrace
#

So how one would go to make a custom shadergraph receive shadow?

#

in a lit one, that is

meager pelican
#

nm I see it above. Sorry.

clear vector
#

@meager pelican all is ok for now, thanks. That was some mistake with variable data type

lament bramble
#

Hi guys πŸ™‚
I'm seeking your council. I have some procedural terrain with a custom mesh. I'd like to have several textures (>5), therefore i would go with a splat map.
As far as I see and read, i would need non-shared vertices to get it to work. Actually, I already have a working splat map shader in shader graph.
However, I considered making use of the primitiveId and use per-triangle data, so i could use shared vertices and therefore massively reduce the number of vertices at the cost of additional lookups in a buffer. Unluckily, it seems that the shader graph doesn't support primitiveId yet, so I would have to write a new shader.
The map size is intended to be quite huge, so storage space and speed is definately important.

As I'm new to the topic, i would like to have a hint, which route I should follow: Use the shadergraph splat map with non-shared vertices or use a shader, utilizing primitiveId for per-triangle data. I attached a screenshot of my current status πŸ™‚ Thanks in advance everyone!

ocean blaze
#

how are shaders made?

clear vector
#

i was searching for a good way to implement palette swapping shader, but i see now, there is no convenient way. I have found few

  • Hardcode color swapping, when you just define N color params and do replace color on each. So for different color number you need different shaders. Not the best variant

  • Main texture is a map itself to palette texture. Every pixel contains index to palette pixel. It can be done with writing to red channel or with grayscale.

The second one seems good for me. But i see problems: you'll have to generate mapped texture for every sprite you using with such shader.

Is there any tools to hook up import process and generate mapped sprite from given palette? Or maybe somewhere in the world exists generator for such images? Any suggestions? πŸ™‚

meager pelican
# lament bramble Hi guys πŸ™‚ I'm seeking your council. I have some procedural terrain with a custo...

Nice question.
I admit I'm guessing a bit here, but the additional overhead for accessing memory on your per polygon data buffer will probably cost as much or more performance than the shared verts, since you'd have to be reading from an additional buffer and that will impact memory coherence/cache. But I get your point about memory usage/size.

Any way you can code up a test case and benchmark? I'm curious as to the results.

Also, I'm sure you know that primativeid will lock you into DX 10 or later.
And be aware of this: https://github.com/Unity-Technologies/HLSLcc/issues/49

It occurs to me that there's probably several ways to "cheat" this process vs having one huge map. For example, break your terrain into manageable sized chunks, and take advantage of frustum culling. Then you'd not have to share verts AND you could somehow index into your own buffer if you still need to by calcing an index based on some data stuffed into the verts (I know that sounds wasteful too, but it'd be smaller anyway). And of course there's the whole procedural draw thing, were you don't even send full meshes, but IIRC you have to do your own frustum culling.

GitHub

When declaring an input such as // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_PrimitiveID 0 N/A...

shadow locust
#

But they are just code

ocean blaze
#

● Check out Bolt: http://ludiq.io/bolt/download

The time has come... Let's explore Unity's new Shader Graph!

β™₯ Support Brackeys on Patreon: http://patreon.com/brackeys/

Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·Β·

β™₯ Subscribe: http://bit.ly/1kMekJV

● Website: http://brackeys.com/
● Facebook: https://f...

β–Ά Play video
shadow locust
ocean blaze
#

or do u have to use a shader graph for that

shadow locust
chilly ocean
#

Currently wrangling with Unity's support for GLSL shaders. Does anyone here know how to go about getting the tangent normals as a vec3/vec4? There is seemingly no simple answer online, as far as I can see.

vague pike
#

Not really sure where this goes... but how would I go about having a texture that stretches across multiple meshes sort of?
Basically I'm thinking of like a 3d tilemap, so I'd have one big grass texture and that's supposed to stretch/repeat over the whole tilemap (but only for the grass tiles of course). Then a sand texture thats supposed to stretch/repeat over the sand tiles and so on.
I'm thinking either I have to somehow combine the grass tiles (even if disjoined from one another) into one big mesh. Or each grass tile would use texture UVs calculated as a modulo of its world X/Z position

cerulean dune
#

Hello ! Do you know why it's showing me this error ?

vague pike
#

what does that connection lead to?

cerulean dune
#

It's connected to a lerp with a Vector 3 in A, and Vector 4 (automatically converted to Vector3 by the shader graph) in B

vague pike
#

hmm is it supposed to be that error texture btw? :p

#

If not, wheres that left Add coming from on your first screenshot

cerulean dune
#

It should be, but in game there's nothing strange x)

vague pike
#

Ah

cerulean dune
#

Well it's just a sky gradient x)

#

But everything looks good

vague pike
#

Isn't that the multiply?

cerulean dune
#

But the place where the texture is first strange is here :

#

It's another thing that I add

#

The Negate of the MainLight direction seems to give the error

kind juniper
#

Although unlikely

#

What does the error on dot product say?

cerulean dune
#

Yeah, I just realized that it was using a custom node, but still find it strange that it's working with these errors :s

#

'Invalid Conditional Expression' on every errors

kind juniper
#

It's not event conditional expression though...πŸ€”

meager pelican
# vague pike Not really sure where this goes... but how would I go about having a texture tha...

You have to know how many meshes in the shader.
If you have 2x2 meshes, each set of UV's would be adjusted to 1/2 what they'd be for a "normal single mesh" with starting offsets. So lower left would start at (0,0) and go to (.5, .5), and upper left would start at (0, .5) and go to (0, 1), etc. You could set them in the modeling program individually, or you can procedurally calc them.

Also, as you implied, you can "just" calc them based on world space coordinates, and tile them like you said in your last line.

As for combining, it's commonly done with a splat-map, like the terrain system uses (google them). That lets you blend between grass and sand. But you could, if you choose, map each triangle even to one or another texture and not blend at all! All up to you.

vague pike
opaque gale
#

Hi, i have a question. I want to create a shader that makes objects look like plastic, but i want the shader to use the objects material color

#

how can i fix that

amber egret
#

Hey, i need help with my shader. i made a shader where the steep parts of the mountain is made of rock while the rest is made of snow. I did this in HDRP. Theres one problem though. The shader is pink, and i cant upgrade the materials because its a custom shader. Anyone know how to fix this? thanks

kind juniper
kind juniper
#

Share the shader code.

amber egret
#

one sec

#

no errors, but heres my code:

#
Shader "Custom/Terrain" {
    Properties {
        _SnowColour ("Snow Colour", Color) = (0,1,0,1)
        _RockColour ("Rock Colour", Color) = (1,1,1,1)
        _SnowSlopeThreshold ("Snow Slope Threshold", Range(0,1)) = .5
        _SnowBlendAmount ("Snow Blend Amount", Range(0,1)) = .5
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        CGPROGRAM
        #pragma surface surf Standard fullforwardshadows
        #pragma target 3.0

        struct Input {
            float3 worldPos;
            float3 worldNormal;
        };

        half _MaxHeight;
        half _SnowSlopeThreshold;
        half _SnowBlendAmount;
        fixed4 _SnowColour;
        fixed4 _RockColour;

        void surf (Input IN, inout SurfaceOutputStandard o) {
            float slope = 1-IN.worldNormal.y; // slope = 0 when terrain is completely flat
            float snowBlendHeight = _SnowSlopeThreshold * (1-_SnowBlendAmount);
            float snowWeight = 1-saturate((slope-snowBlendHeight)/(_SnowSlopeThreshold-snowBlendHeight));
            o.Albedo = _SnowColour * snowWeight + _RockColour * (1-snowWeight);
        }
        ENDCG
    }
}

kind juniper
#

Ah, that's a CG shader

#

Hdrp and urp only work with HLSL shaders.

amber egret
#

oh

#

any way i can change it?

kind juniper
#

Start from changing CGPROGRAM and ENDCG to HLSLPROGRAM and ENDHLSL

#

Then you'll get some errors that you'll need to solve by changing CG stuff to it's counterpart in HLSL

regal stag
#

It's more to do with that it's a surface shader, which isn't supported in URP and HDRP

kind juniper
#

Oh, guess that too.

regal stag
#

I'd recommend using shader graph though, writing shaders by hand in HDRP is a nightmare from what I've heard

amber egret
#

i have no clue on how to use the shader graph :/

fervent tinsel
#

then it's more likely you will have even harder time doing custom HDRP shaders

#

in short, Unity doesn't want you to do custom hdrp shaders

#

basically you could take stock HDRP lit and modify it if you really need to but would be just so much easier to use SG as it will not break on every second future HDRP release like your custom HDRP shader will

amber egret
#

are there any other ways i can acheive a look like this?

fervent tinsel
#

that's typically done by precomputed mask texture

#

then just layered few materials with a shader

#

or use some kind of terrain shader if it supports that

unreal gale
#

Hi, got a quick question, I made an outline material shader with ShaderGraph, and I want it to apply to all objects when rendering on a secondary camera, how can I achieve that ? I tried searching online but no solution worked so far

unreal gale
# kind juniper https://docs.unity3d.com/Manual/SL-ShaderReplacement.html

I tried using this, and either my shader doesn't work with this system, either I am not using it properly. Could it also need the meshes to already be present in the scene to make the shader replacement ? I am loading my other scenes (which contained the meshes) additively after my main scene start

kind juniper
regal stag
#

Which render pipeline are you using? Replacement shaders are only supported in built-in afaik. URP has an override material which is similiar, the RenderObjects feature on the Forward/Universal Renderer asset can do that.

unreal gale
unreal gale
#

I saw it existed but didn't look into it much as it said it could be unoptimized to use

regal stag
# unreal gale I am using the the URP, are there examples using RenderObjects or other function...

There's an example on how to use the feature here : https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@11.0/manual/renderer-features/how-to-custom-effect-render-objects.html (You'd just need the Material override, not the depth parts though)

You can create a second Forward/Universal Renderer asset somewhere in your project files and assign it to the list on the URP Asset. Then on the camera switch the Renderer, that way it doesn't affect your main one.

unreal gale
#

though now I need to figure out why it does this ^^

#

actually it's fine, I just used the wrong processing event, all is in order ^^

#

Quick snap at the first pass of my (mini)map feature it renders ^^

grand jolt
#

@meager pelican can I get a reminder when I am supposed to use .DrawFullscreenMesh() and when to use Blit() for fullscreen effects?

chilly ocean
# kind juniper Why not HLSL or CG?

The ability to reproduce the same shader in Maya is one of the deliverable requirements, so GLSL was determined the way to go, since the changes required for porting are minimal.

silver sparrow
#

https://youtu.be/vIh_6xtBwsI could somebody please explain to me why did the person split the Absolute World Position to obtain the X and Z value, and then have it plugged into a Vector2 node to obtain a texture that projects only at the top? starting from timestamp: 4:20

Tutorial on how to make a tileable material in unity shader graph.
Works in HDRP or URP
This works great for walls and floors or other objects that use a seamless tileable texture

β–Ά Play video
#

i'm genuinely confused

regal stag
# silver sparrow https://youtu.be/vIh_6xtBwsI could somebody please explain to me why did the per...

The position is a Vector3 (xyz), but to sample a Texture2D it requires a Vector2, hence the need for the Split and Vector2 nodes. The X and Z is used since those are the axis involved with the top surface. The Y isn't used so the texture stretches on the side, but I'd assume later in the video they project textures from other sides too and blend based on normals. There's also a Triplanar node that does it for you.
Absolute world space is used so moving, rotating and scaling the mesh doesn't change the projection.

grand jolt
#

I'm trying to make a ray marcher in unity using hlsl

#

And instead of a sphere, it gives me this:

#

Here's the code

#

I have a warning: implicit truncation of vector type

meager pelican
grand jolt
#

URP SSAO uses it instead of blitting.

#

It draws a quad scaled up to match the whole screen.

#

So instead of mixing stuff manually in the shader they draw the SSAO on a quad with alpha.

meager pelican
#

Well, the good news is do does blit (the fs quad). And blit let's you pass a material.

But I'm obviously not the one to ask, maybe someone else knows.
I'm curious now though, so may dig further.

grand jolt
#

No, with blit you feed the camera target and you have to make sure to output the old pixels where your special effect has 0 alpha.

#

With draw fullscreen mesh you can just dump a (0, 0, 0, 0) out and it won't give a shit and will blend on top of your screen target nicely.

#

At least that's how I think.

meager pelican
#

Oh, you're saying you can use alpha blending and just blend into the back buffer.

Sounds like you've answered your own question, beat. πŸ˜‰

grand jolt
#

But when do I pick one over the other.

#

What are the perf implications.

#

I can't be writing "skills: shaders" in my resume if I don't know this πŸ˜„

meager pelican
#

I would think that the fsmesh call with blending would be faster, if you don't need to know what you're blending over (but I haven't dug in yet), so I'm grasping here. SSAO would have to have read that somewhere, and then "just" blending the result over top with that fsmesh call. Like as a final step after it had the shading info for AO.

SSAO isn't cheap.

grand jolt
#

Oh, I know how SSAO works.

#

I just don't know how to learn stuff like that.

#

The whys.

meager pelican
#

But but but....
You just learned it, explained it, and then educated me. πŸ˜‰

It sounds like...that they're doing that final call just to blend the result in using alpha blending per your explanation.

grand jolt
#

Yeah, but why not blit.

#

It's not the only builtin render pass in URP I've seen that uses fullscreen mesh.

meager pelican
#

YOU answered that. Blit gives you the OLD target, and a new target, and you'd have to be:

  1. reading the source.
  2. writing to the destination
    AND
  3. adding in the AO result. So that's reading 2 things and writing 1 new one back out.

As compared to taking what you have (however long it too you to get it...and that's no slouch with AO) and "just" splating that on top of whatever you already have in the back buffer. Like shadows do. That's one read input, and a hardware blend output to the back buffer.

I think. That's what it sounds like.
So I'm GUESSING that's why they did it.
BUT...IDK how long it took to get the AO results to AO Map back on top of the screen.

#

But the GPU is going to be designed to "dump" stuff blended into the back buffer. Like fast.

grand jolt
#

Hmm, true.. AO pass needs the depth prepass target but not the camera color buffer so we save 1 texture tap since we are no longer blitting using the camera target as a source.

meager pelican
#

Yeah, since the depth is often/usually "free" with the back buffer.

grand jolt
#

Nah, URP uses depth prepass target rendered before everything, not the camera's depth target. We also got depth priming recently so maybe URP maybe also uses that same prepass to prevent overdraw even.

meager pelican
#

But pre-pass just means WHEN/HOW they get the depth buffer populated. Right?

So...they do a pre-pass. No pixel shader necessary. It basically "just" writes depth information to the back buffer, colormask 0 basically. Only depth info gets output, IIUC. At least that's the goal... have the vert() do its thing, position the triangle, and then rasterization just outputs the interpolated depth across the triangle for all frags and doesn't even call any pixel shader.

I think.

Pretty fast.

And then you have a depth buffer sitting around for all the good stuff in later passes.

grand jolt
#

I just mean it's a separate render texture, not the "live" camera target.

#

Oh, us programmers and semantics 🀣

meager pelican
#

So you need it for the pipeline anyway.
I just meant that it's "free" to the AO process later.

meager pelican
# grand jolt I just mean it's a separate render texture, not the "live" camera target.

That gets complicated IIUC, and may be (is) implementation/hardware dependent. Sometimes Unity makes a separate one, sometimes it is a hardware one. I get confused as to when it does which, to be honest. And it's part of the RT setup.

Maybe it makes one if you have to read it, but otherwise if you're just doing hardware z-testing it "knows" it won't need it. Not sure.

grand jolt
#

Well, it comes from cmd.GetTemporaryRT() so I dare the GPU to remove it 😎

meager pelican
#

lol

#

Yeah, and RT depth buffers and copying....oy....

primal dagger
#

How can I make a gradient fog effect?

steel notch
#

So in this video, in the area where the shader cuts off the mesh, a texture covers the cross section
https://www.youtube.com/watch?v=o8PdPdcbMzk&ab_channel=AbdullahAldandarawy

#

How exactly do you get this effect?
(Specifically something like Shader Graph πŸ˜›)

steel notch
#

Oh thanks. Exactly who is Remy?

regal stag
steel notch
#

emphasis on a while πŸ˜›

#

thanks ill take a look

steel notch
#

sick it works

#

alright nice

#

thanks

storm trout
#

Is there currently a plan to add a node similar to Blender's ColorRamp?

regal stag
storm trout
#

Kind of, but it's also kind of a pain

#

And the noise options are way more limited

#

Had to abandon a project because Unity has no wave texture node

sweet cosmos
#

Previous versions of Shader Graph contained PBR Graph which had AlphaClipThreshold parameter in its master

#

How can I set AlphaClipThreshold in newer versions?

onyx veldt
#

i think this goes here
how can i make this not blury
Its a very small image

#

got it^

rocky rapids
#

How would i do something like this in 2d

#

without actually making it part of the texture

rocky rapids
onyx veldt
#

tf is happening

tacit parcel
onyx veldt
#

i fixed it now

#

im using this one

exotic kraken
#

Can you have multiple shaders apply to a single material at the same time? Like an outline shader on a mesh that has a pbr shader as well?

chilly ocean
#

So, odd issue that maybe someone here can help with... I'm working on building an identical shader in Unity and Maya, and am getting different results in the two programs with what should be identical inputs.

#

Left is Unity, right is Maya. A simple swizzle of a vec3 fixes the mirroring issue, but for some reason the normal data in Unity displays as much smoother than Maya. Anyone know why this might be, or how to fix it?

exotic kraken
#

Maybe the interpolated vectors in the vertex shader aren't normalized in Maya?

chilly ocean
#

I'm not sure if that's the issue. Applying normalization during the Pixel Shader stage doesn't seemt o make any sort of difference to the output color.

#

At least if my understanding of your suggestion was correct.

timid rose
#

can anyone help me with trying to get a boids project working in hdrp?
specifically https://github.com/Shinao/Unity-GPU-Boids
or at least point me in some direction on how i can try figure it out myself
i assume the compute shader works the same on all pipelines but normal shaders and specifically surface shaders dont with hdrp
i tried looking at shadergraph examples that have a structured buffer as i assume that's important for the optimization of this boids implementation but couldnt find much
any help would be really appreciated
I assume trying to get this (https://github.com/Shinao/Unity-GPU-Boids/blob/master/Assets/8-GPU_Boids_Final_Clean/Boids.shader)
to work in hdrp isn't a simple process at all but i've looked for resources for hours and thought maybe someone could help

ocean blaze
#

can someone please help me. pbr graph is gone and idk how to make the shaders now

vocal narwhal
ocean blaze
#

and it just shows lit shader graph

#

unity said they removed pbr

vocal narwhal
#

that's it

ocean blaze
#

but how are we supposed to make the shaders now...

vocal narwhal
#

what's wrong with lit shader graph?

ocean blaze
#

and i follow brackeys tutorial

vocal narwhal
#

what's wrong with that

ocean blaze
#

i folloed it

#

and it didnt work

#

the shader stayed pink

vocal narwhal
#

If it's pink then you're likely not using URP properly

vocal narwhal
#

If you create a material that uses a built-in URP material does it display properly?

#

or is it also pink

vocal narwhal
#

Assets/Create/Material

ocean blaze
#

how would i then apply the shader to the material

vocal narwhal
#

you don't need to do that

ocean blaze
#

since you have to pick it through the shader thing

#

oh i dont?

vocal narwhal
#

just use the default URP material, it should be preset if you create a new material if you are using URP

ocean blaze
#

the mateiral is still pink

vocal narwhal
#

Then you are not actually using URP

ocean blaze
#

i set the shader to URP/Lit

ocean blaze
#

and then i made a new shader graph

#

lit shader graph

#

and made the shader

#

i installed URP @vocal narwhal

vocal narwhal
#

If the default lit URP material displays in pink, then your project is not configured for URP.

ocean blaze
vocal narwhal
#

Yes.

ocean blaze
#

do i need to set it in project settings