#archived-shaders

1 messages Β· Page 17 of 1

wanton grove
#

one sec

#

I see, so mesh makes duplicates but sharedMesh doesn't

#

Even if it was making duplicates I'm not sure how that duplicate could be referenced but I changed it to shared mesh already

kind juniper
#

Yes. Generally you should always avoid using mesh/material and similar properties that have the Shared version. Especially if you're assigning via the property.

wanton grove
#

I feel like I'm doing that for something else that isn't a mesh aswell though

#

I'm looking for it now

#

I'm setting textures using material instead of sharedMaterial

#

but it only does that once

kind juniper
wanton grove
#

interesting

kind juniper
wanton grove
#

Ah, makes sense

#

But I'm still getting memory buildup even with shared mesh

kind juniper
#

Then use the memory profiler as I suggested.

wanton grove
#

The addon one?

kind juniper
#

The package manager one.

wanton grove
#

Ok, one sec

kind juniper
#

Ah, I think I remember how to do it in the regular profiler. There should be a button to sample the current state of the editor.

wanton grove
#

I already did that in the detailed dropdown

#

But I'm not sure what it could be

kind juniper
#

Can you take a screenshot of the whole profiler?

wanton grove
#

Here's the bulk of the memory, apparently most of it is for profiling and System.ExecutableAndDlls (whatever that is)

kind juniper
wanton grove
wanton grove
kind juniper
#

I don't see anything too bad atm.

#

Is it sorted by Memory?

wanton grove
#

Yes

#

My task manager is still high

kind juniper
#

Did you restart the editor?

wanton grove
#

No

kind juniper
#

Lol. Why not?

wanton grove
#

Haven't done it since I changed to shared mesh

#

No reason to right?

kind juniper
#

I told you that the meshes from before the changes are still there.

wanton grove
#

I'll do it again

#

With shared material for bonus

#

Ok, baseline memory usage without unity is 51%, thanks computer

#

Gosh, unity does this thing where like half the time the editor takes like 10 minutes to open and like 15 seconds the other half

#

I'll even do obs recording with profiler

#

One sec

#

Managed to get it to 91% memory

wanton grove
kind juniper
kind juniper
#

Hmmm

#

What are the errors/warning that you get in the console?

wanton grove
#

one sec

kind juniper
#

Could it be the mesh collider? Try commenting it out and see if that changes anything.

wanton grove
#

ok

kind juniper
#

Also try using the package manager memory profiler. It should show more info.

#

Finally, are you sure that the unity memory consumption keeps on increasing? You said that your PC already consumes 51%. So 40% for unity is not that much.

wanton grove
kind juniper
#

Would it really?πŸ˜…

wanton grove
#

Yes, but that's happened before with the compute shaders so it's only ever frozen my computer with this instance

#

I could sacrifice my computer if you want but I don't think the memory buildup is sustainable

kind juniper
#

It could happen with VRAM being overfilled, but it should be fine with RAM. Your PC would just start caching to the hard disk.

#

Anyways, use the memory profiler.

wanton grove
#

I think that happened once and I had VERY low memory (e: disk space) on my pc, it was not a fun time

#

I'm going to test again now

#

It still happens without the collider

#

currently downloading memory profiler

#

the fear of all compute shaders

kind juniper
#

It's not compute shader fault though.

#

You'd get VRAM leak if it was due to a compute shader.

wanton grove
#

What's the difference between VRAM and RAM?

kind juniper
#

It's something you're doing on the CPU side.

#

VRAM is video memory. The memory on your GPU.

#

RAM is what your CPU uses.

wanton grove
#

Ah, so it doesn't stand for Virtual RAM?

kind juniper
#

Nope

wanton grove
#

Wow, those freeram.com sites need to give me some answers then

#

Ok I am trying the memory profiler now

#

Let me guess, I capture a screenshot?

kind juniper
#

If you want me to have a look, yeah.

wanton grove
#

It says it will share a bunch of personal sensitive info, is it ok to just send the summary?

#

Lol

#

And they all have 0 references

#

How could it be creating all of those if I'm using shared mesh, could it be because i use new Mesh()?

kind juniper
#

Maybe there's another place in your code you're doing it?

#

Also, share the updated code with sharedMesh

wanton grove
#

ok, one sec

kind juniper
wanton grove
#

No, they're all just named Mesh

kind juniper
#

Maybe try destroying the previous mesh before assigning a new oneπŸ€”

wanton grove
#

Ok, one sec

kind juniper
#

I guess it's not collected by the GC since it's considered an asset.

wanton grove
#

It's still going up

#
        Destroy(filter.sharedMesh);

        Mesh mesh = new Mesh();
        mesh.vertices = meshVertices;
        mesh.normals = meshNormals;
        mesh.triangles = meshTriangles;

        filter.sharedMesh = mesh;

        collider.sharedMesh = mesh;
kind juniper
wanton grove
#

ok

wanton grove
kind juniper
#

Did it do the trick?

wanton grove
#

My memory usage is as mediocre as it should be

#

yes

#

In playmode should I use destroy instead?

kind juniper
#

Yes

wanton grove
#

Ok, perfect, thanks so much for the help.

kind juniper
#

Make a check to see if the app is in edit or play mode.

wanton grove
#

Ok, the profiler should be really useful from here on out aswell

tranquil jackal
#

How to correctly strip Shaders for terrain. As my build have quite crazy amount of shaders included for terrain (hidden ones). I am using addressables and webgl Build.

round patrol
#

Got a problem. The material made from a shader graph has exposed texture slots. When I put in a texture into the slot the material preview shows the correct texture but the actual texture slots is showing the wrong image.

#

Not a big problem, only an editor problem

#

NVM I restarted unity and now it's working...

white marsh
#

am i doing something wrong here?
this is code for URP

#
float calculateFresnel(Light lightSource, float3 wNormal, float wView, float Intensity)
{
    float fresnel = 1-dot(wView, wNormal) * Intensity;

    float3 H = normalize(lightSource.direction + wView);
    float3 NdotH = saturate(dot(wNormal, H)); 
    float3 output = fresnel * NdotH;
 
   return output;
}
#

it ends up looking like this and im not too sure why. it worked fine in built in

leaden turret
#

@karmic hatch something weird started happening on the water shader (when testing in Unity 2022.2.0b9 which doesnt happen in 2021.3.10f1)
for some reason as soon as i set the 2nd normal map a huge part of the water light reflection is mostly white / too bright πŸ€”
why is this happening
how to solve?

#

problem happening in unity 2022.x

#

problem not happening in 2021.x

#

i tried going through & comparing various light-related settings and match them up as close as possible

#

problem not happening if i only use 1 normal map instead of 2

#

this is the shader pretty much

round patrol
leaden turret
round patrol
#

in the project image inspector settings dunno what it's called

#

image properties

#

jsut click the image and then the inspector

leaden turret
#

The texture import inspector? Pretty sure yes... Lemme double check...

#

πŸ™Œ you win

#

i surrender

#

weird thing - in 2021.x it was also NOT imported as normal map, but still worked... πŸ€·β€β™‚οΈ

#

thanks @round patrol

round patrol
#

That was easier than I was expecting. Glad to help

gray harness
#

does anyone know how can i write to zbuffer using custom code, for every vertex i want to set custom distance from camera and not it being calculated automatically?

round patrol
#

with both

gray harness
#

eg. I calculate my special distance in vertex shader and want the zbuffer (depth buffer) to use that distance

leaden turret
kind juniper
gray harness
#

so its in the clip pos?

kind juniper
#

Yeah, I think so. Try modifying the clip post and see if it has any effect.

gray harness
#

thanks its in the clip pos

meager pelican
meager pelican
# leaden turret

After doing the dynamic real time reflection probe, I made a grid of baked reflection probes to test with. Ran into the single-probe-per-object issue when using one large plane for water.

Worked great with a small dynamic object (reflective sphere)...it switched between probes and faded between them just fine. But one large plane....oy.

#

It kept using the default reflection probe (auto generated by sky manager). It's object relative, not camera-location relative. IDK how/if it can be hooked up. Need to research.

#

You can test if you're using the default probe or not by changing the settings in lighting, setting the intensity to 0.

white marsh
#

how do i make a toggle in the material inspector for toggling multi_compile's?

#

nvm, i figured it out

#

but then i have another question, is it possible to hide certain material properties if certain keywords are on/off?

unborn narwhal
#

I am using URP 3d and with a freshly created shader which looks fine in unity I get this when I look at it on my Quest. Now it is a bonelab level so it could have many reasons its just that I don't really know where to start. I am using the correct rendering pipeline and the material is as basic as it can get. Does anyone have an idea what could cause this?

#

Unity on the left, bonelabs on Q2 on the right

leaden turret
leaden turret
leaden turret
hallow plover
#

hi. I have been trying to learn hlsl for writing shader code for a while but implemeting lighting is really really hard. In adition to this there does not seem to be a library with a few of the comon shader graph functions. I am concidering going back to shader graph but I am not sure if I should continue to try or return to the graph. Does one have other advanatges over the other (apart from ease of use)?

karmic hatch
hallow plover
regal stag
# hallow plover Alright. How does lighting for shader graph work? Does it just work straight out...

There are Lit graphs which handle lighting for you.
But if you want custom lighting models (e.g. toon/cel shaded) you would need to use HLSL code in Custom Function nodes. (For URP at least, unsure if it's possible in other pipelines)
e.g. https://github.com/Cyanilux/URP_ShaderGraphCustomLighting
That is usually still easier than writing the whole shader from scratch.

The main places where you probably would avoid graphs is for UI, or requiring ColorMask & Stencil operations, as it doesn't have good support for those.

tropic sluice
#

Does anyone know which UV map slots are free to be used? I know Unity uses some for lightmaps and such

#

obviously UV0 is fine to use, but UV1 is used for lightmaps... is it okay to use UV2 and UV3?

regal stag
tropic sluice
#

Right thanks, basically making a list of what each is used for

#

With lightmaps I assume if I turn off the generate lightmap UVs option I'm good to use it

#

Maybe similar with UV3 if I'm not using realtime GI (which I'm certainly not going to use in VR)

coarse sable
#

How would I add a simple falloff like The Inverse square law To this Shader.
here's what I'm using it for like a cone of vision thing for a guard

karmic hatch
meager pelican
meager pelican
coarse sable
karmic hatch
#

wait do you want it to fade with distance from the camera or distance from the guard

coarse sable
#

distance from guard

karmic hatch
#

ok so if you have the coordinates at the guard's head then that's the corner i mean

coarse sable
#

I can Input specific coordinates?

karmic hatch
#

if you don't already know it in object space, you can have it be set on the c# side (create a Vector3 property for it in the shader, then set that property with the script)

coarse sable
#

oh ok

#

and i would plug that into alpha?

karmic hatch
karmic hatch
karmic hatch
#

yes

#

also instead of divide, you can use a reciprocal node

#

and then just as a general rule, saturate it before putting into alpha

coarse sable
#

So Like This?

karmic hatch
white marsh
#

how can i convert a color into a white/black mask?

atomic glade
#

Anyone have any idea why this specific material is tinted entirely blue when viewed through a transparent material, but not any others? You can see the blue disappear when I move the camera inside the hologram wall, and at the end I go fly close to a different wall material that isn't doing the same thing.
https://streamable.com/jqg03o

#

It's a shader graph shader so I can't just post the code for it. If anyone needs to see a specific part of it I can try to screenshot that group of nodes so I don't need to post a screenshot for ants of the entire thing at once

white marsh
atomic glade
visual mesa
#

Does anyone know why I'd be seeing this error with a shader I wrote?
ArgumentException: ComputeBuffer.SetData() : One of C# data stride (28 bytes) and Compute Buffer stride (16 bytes) should be multiple of other.
UnityEngine.ComputeBuffer.SetData (System.Array data) (at <edb09cd490414b2684a18fe60d255a59>:0)

shadow locust
visual mesa
#

I honestly don't understand lol Really new to shaders @shadow locust 😦

stark dune
#

How do I set up my inputs on my custom shader to be like this?

stark dune
#

Anyone?

visual mesa
#

@stark dune I am super new to shaders. However, if you are looking to change your shader surface values, maybe try this:

stark dune
#

I'm using graphs

#

I know how to change values, I just can't get it to give me both sliders/colors AND a map option

stark dune
#

Oh so it's not possible with graphs?

meager pelican
#

The shaders/graphs set WHAT is input.
The Unity editor property panel shows the settings, so that's on the engine side. You'll see a default, but can override that with material property drawers.

IDK if you can duplicate the exact style or not, I never bothered to try. But I'd guess you can.

meager pelican
lyric copper
#

Do you guys have any resources for scaling the UV of a material based on distance via code? Without writing a new shader

visual mesa
#

How do you access the item at index 0 in a StructuredBuffer? My shader is currently doing:
positionBuffer[unity_InstanceID]
but I'd like to instead get the value at index 0 doing
positionBuffer[0]

visual mesa
#

I'm writing it out right now. Need to make a few adjustments. But thought I'd post here to save me the time if someone knows

kind juniper
#

There's no reason it shouldn't work. Unless you write to it.

visual mesa
#

I was originally passing an array of structs where each struct instance just has float x,y,z. But each struct instance also has their parent transform x,y,z (it's the same for all array elements). So to be more efficinet, I'm just going to pass the parent transform in at index 0. If possible

kind juniper
#

If it's a hierarchy kind of thing maybe use 2 buffers: one for positions and the other for indices of the parents.

visual mesa
#

What about Shader.SetGlobalFloatArray()?

#

Just came across that method in the docs

visual mesa
#

This is how I set the buffer currently:
material.SetBuffer("positionBuffer", positionBuffer);

kind juniper
kind juniper
visual mesa
#

Could I use that to set the parent x,y,z and have it accessible in the shader?

visual mesa
tight phoenix
#

Is there a way I can make exposed vectors less than 4 show less boxes? Its only a Vec2 but there's four boxes

kind juniper
visual mesa
#

I'm using a surface shader. It's for GPU instancing

kind juniper
kind juniper
leaden turret
#

if my water shader simply does not do any vertex manipulation, so the water plane is always flat, only illusion of movement is from normal maps

is there a super easy way to make an underwater fog then? it could even be "hardcoded" as: "anything below world Y position of 100 should render this fog effect" ?

#

basically - how can i achieve this underwater distance fog effect, only when camera is positioned underwater

hoary valley
#

so i created a new Universal render pipeline project
and i created a cube game object
but it wont let me change the shader or the material

ebon basin
#

Make a new material and drag it onto the mesh renderer

#

No clue why the default lit shader is erroring though

hoary valley
#

could be the Stress Level Zero Custom URP

kind juniper
leaden turret
#

ok

leaden turret
kind juniper
#

Postprocessing is just rendering a full screen quad with a shader after all.

cosmic prairie
halcyon plank
#

perferably for free

#

do you guys have any idea where i can learn how to make a shader that auto textures terrain from height and slope perferably for free

kind juniper
halcyon plank
#

@kind juniper well ive been looking and havent found much am i possibly searching with the wrong question

kind juniper
#

I imagine you're doing some sort of custom terrain solution?

halcyon plank
#

yes

#

something that looks good but can cover a large map in a short amount of time

kind juniper
#

In this case maybe check the Sebastian Lague channel on YouTube. He has a series or two that could be relevant.

#

Then there's the "catlike coding" website that also covers many relevant topics.

halcyon plank
#

i forgot about him duhhhh idk why i havent checked his channel

#

Thank you @kind juniper

karmic hatch
#

Brackeys is also good @halcyon plank

halcyon plank
#

nope i cant do it sabastian basically requires to be using his terrain setup and for brackeys i cant find anything

#

i tried to do what subastian did in shader graph but i could only reproduce the grey scale effect

karmic hatch
#

i have a thought; you could give each texture a weight that's a function of slope (dot(normal, up)) and height (position.y) and then do a weighted average

#

(if you want it to fade)

halcyon plank
#

@karmic hatch that is true let me try that rq

ebon basin
#

https://i.imgur.com/GT81KJU.png

So I've been playing with the graphs more, following some tutorials, and now I'm experimenting with them. However, I'm having a hard time trying to understand how to merge some of these nodes, such that I get the desired transparency on my shader. It seems that multiplying those two subtraction operations will always result in my alpha channel inputting 0, even though the node display right afterwards is not completely black. If anyone could help me understand how to merge this stuff together correctly I'd appreciate it.

long moat
#

Is there a way to make a shader to display through it only specific objects? like some selective window that has lots of junk behind the window but it will display only specific stuff though it

kind juniper
ebon basin
#

I fixed the problem by inverting after multiplying those two subtraction methods, but the node display is incorrect

#

really wish you could see values in this thing

kind juniper
#

What's incorrect?

#

What's the current issue?

kind juniper
ebon basin
# kind juniper What's incorrect?

The problem is that when I multiply those two nodes which I previously subtracted, the alpha is now (or less than 0). I would like both, the noise and the fade, to be applied to my shader, but it seems trying to combine them how I am creates problems.

long moat
ebon basin
#

I can use one of those nodes fine and it will work, but trying to combine them does not.

#

Inverting does fix some issues surprisingly, but the noise becomes reduced by a lot. Pretty complicated some of this stuff and the tutorials kinda spread thin on the actual logic of it all.

karmic hatch
ebon basin
#

Ah, yeah I remember watching something about that. But, it still seems to be clamping at 0.

karmic hatch
#

You seem to be using an opaque material with alpha clip, is that what you want or do you want a transparent material?

ebon basin
#

I'm using transparent

karmic hatch
#

I think you need to turn off alpha clip if you want it to fade smoothly

tropic sluice
#

If I'm blitting a shader into a Render Texture but I only want change a region of it, how can I avoid needless processing of the areas I don't want to affect?

ebon basin
#

I've been just messing around with that, but even then the preview is completely transparent.

#

I'm obviously doing something I shouldnt be doing with the operations, just the nodes are lying to me lol

karmic hatch
#

What settings are you using

ebon basin
karmic hatch
ebon basin
#

It kinda is showing up after resetting, but color isnt being applied now

#

The saturate may have helped

#

Ill eventually figure it out, just gotta fool around with it more

#

ty tho

kind juniper
kind juniper
#

If the issue that the values are negative

karmic hatch
ebon basin
#

Yeah they are negative I think

#

So clamping them results them in 0. Inverting them or abs does do something, but kinda reduces the noise to nothing

ebon basin
#

I've got some noise and a fade effect which work fine independently, but trying to multiply them together gives me a node with the preview I want, but negative alpha

ebon basin
karmic hatch
#

Is it just grey?

ebon basin
#

Yeah

karmic hatch
#

The colors are set properly in the material?

ebon basin
#

They are, but I also have the preview on the graph with a default material

karmic hatch
#

Is the graph preview also grey?

ebon basin
#

Yeppp

karmic hatch
#

Can you show me the fragment node and preview?

#

Are all the other nodes working fine?

ebon basin
karmic hatch
#

I think the background is grey, so you're seeing the transparency. Try just putting the color from the lerp into base color directly

#

Or switching the blending mode to additive (and then removing either the alpha or multiplying the base color)

#

Since the alpha is usually low, when you multiply by the gradient it just makes it very dark compared to everything else

#

(or so I theorise)

#

Oh also make ambient occlusion >0

#

And smoothness, you probably want <1

kind juniper
#

I'd check if the noise is returning -1 to 1 values?

karmic hatch
ebon basin
#

Yeah, doing the lerp directly does apply the color now.

#

How do I even check for values on this thing besides just eyeing it

karmic hatch
#

Eying it is usually the way, you could put a step at some value you're interested in or multiply/divide some quantity with a small/large range so that it's more manageable to look at

ebon basin
#

I've got to head out, but I think you've got me on the right track.

karmic hatch
#

good luck :)

ebon basin
#

Appreciate it yo

ebon basin
# karmic hatch good luck :)

So you're right about the gradient becoming way too dark. Seems like the more operations I applied to the noise, the darker it got mixed with the alpha levels getting way too low itself and getting clipped.

#

Overall, it works now ty again ;)

leaden turret
# kind juniper Postprocessing is just rendering a full screen quad with a shader after all.

ok. I guess when you mentioned "there are many ways to do it" made me wonder which one might be the least intensive / most performant way to go for mobile... i dont know much about rendering & shaders but i thought i remembered that shaders on the scene object (fragment shaders specifically it's called?) is more performant than post processing effects, or something like that... πŸ€·β€β™‚οΈ could be i'm totally off about that

leaden turret
#

if there's some tutorial or step-by-step guide i could follow to achieve this, would be very helpful... unfortunately still quite noob to shaders 😬

cosmic prairie
#

zwrite on

#

just insert it somewhere in your shader

#

should do the trick

leaden turret
#

thanks πŸ‘
I was using ShaderGraph in this case (from another step by step tutorial i was following) does this setting exist somewhere that i can enable it in shadergraph?

cosmic prairie
#

(sry for ping Mao lol)

ebon basin
leaden turret
#

ok cool so once i have that enabled (assuming that does the same as ZWrite on) now how do i put it to use when swimming underwater

leaden turret
#

or if someone could point out an Asset in the store which does this effect ready-made i'd prolly buy it. The only thing is I was hoping to get the plain raw effect as-is without too much other complicated fancy effects, only what i need, since i'm trying to cut down on intensive computation for mobile

#

i'm guessing i need to use this position input with World space selected? also leaving "Depth Write" as Auto should be OK because it will be automatically enabled when needed/used?

vast tiger
#

Hey, I'm trying to create a water shader which changes the water colour based on its distance from underlying geometry.
I'm following the Unity tutorial linked below which does this but it does not quite fit what I need.
https://www.youtube.com/watch?v=gRq-IdShxpU&t=148s
As for what I need help with, it appears the camera's position also bares a factor in how the colour changes in addition to the geometry below the water.
This is how it looks when the camera is completely overhead
https://i.imgur.com/PyTPMH8.png
This is how it looks at another angle
https://i.imgur.com/nGkKNZv.png
And lastly
https://i.imgur.com/krFoc2B.png
If there are any suggestions on how to remove the camera's influence, it'd be much appreciated
This is the current graph
https://i.imgur.com/rEjbYa2.png
Please ping if you respond

graceful hazel
#

hey I'm working on a sprite shader and I'm getting these weird patterns around the sprite. it probably has something to do with alpha, but not sure what's going on. anyone know what this is?

#

oh I just had to connect the alpha channel lol

karmic hatch
karmic hatch
# vast tiger Hey, I'm trying to create a water shader which changes the water colour based on...

I think part of the camera's influence is a bias towards the center/edges, which you can remove by dividing by the b component of normalized view space view direction (might need to negate). The other part is just that the distance along the line of sight between two planes is much larger if those planes are at a steep angle to the ray, vs if they're at a shallow angle. That is expected from the geometry of the system (though you can get rid of it by dividing by the g component of normalized world space view direction (again might need to negate)

strong musk
#

any idea why the URP/Lit (PBR Workflow) shader causes materials to be invisible?

tight phoenix
#

the older one that looks less good but doesnt have the discontinuity

#

I did notice there is a weird circular band of weirdness in the preview

#

oh here we go, it looks awful on a capsule

#
void NormalFromHeightTangent_float(float In, float Strength, float3 Position, float3x3 TangentMatrix, out float3 Out)
{
    float3 worldDerivativeX = ddx(Position);
    float3 worldDerivativeY = ddy(Position);

    float3 crossX = cross(TangentMatrix[2].xyz, worldDerivativeX);
    float3 crossY = cross(worldDerivativeY, TangentMatrix[2].xyz);
    float d = dot(worldDerivativeX, crossY);
    float sgn = d < 0.0 ? (-1.f) : 1.f;
    float surface = sgn / max(0.00000000000001192093f, abs(d));

    float dHdx = ddx(In);
    float dHdy = ddy(In);
    float3 surfGrad = surface * (dHdx*crossY + dHdy*crossX);
    Out = normalize(TangentMatrix[2].xyz - (Strength * surfGrad));
    Out = TransformWorldToTangent(Out, TangentMatrix);
}```
What in unity's code could be causing this?
#

my only guess is the tangent matrix

#

because I didnt know what to sub into that

vast tiger
tight phoenix
#

float3x3 TangentMatrix
How do I substitute this? What is it? Its the only thing I can concieve is wrong because I dont know what it is

#

I need to know what this 'is' in the original node so I can replace it in my custom one

#

google doesnt have the answer

#

a random post on the net said its this, but that doesnt work

#

hm it looks like it WAS that, except in object space instead of world space

#

discontinuity is gone

tight phoenix
#

hrmgh that didnt actually fix it

#

the end result looks totally janked up from certain faces

#

how can this happen?

#

okay this fixed it, after setting the right transform matrix, I had to pass in the object position instead of the UV position

orchid latch
#

peeps
can we use PBR on built in pipeline ?

meager pelican
#

So are the Surface shaders if they use the "Standard" lighting model.

restive grove
#

Is it possible to make sample cubemaps glow?

#

Im using a hdri

tight phoenix
#

@karmic hatch In your SSS shader, do you recall what controls this range here? I've tried adjusting every value but nothing I change affects that depth in any way
I am trying to make the cutoff less stark and discontinuous

swift flame
#

I'm trying to create a water level mask from a height map. I'm getting close just not quite there.

swift flame
tight phoenix
burnt wind
#

Hey does anyone know how I can access the world position within a compute shader

#

I can get the camera UV for my scene, and it works fine, but I want to use the world position

tight phoenix
burnt wind
#

like... do I use the camera to world matrix thing? I attempted using that before and it just does some weird stuff

kind juniper
burnt wind
#

I need to get the position in the first place

#

where do I get that

kind juniper
#

Transform.position.

burnt wind
#

its a compute shader..

#

theyre pixels, not objects

kind juniper
#

Yes. That's why you set it from C# script. Via the ComputeShader api

#

So you need a position of a pixel?

burnt wind
#

Its a global UV... not transforms..

#

I cant just create this transform in the C# script,

#

Currently its using the position of every pixel on the camera

#

which works, but it follows the camera, when I need it to follow the world position

kind juniper
#

Well, you can't get a world position from that. You need some reference point.

burnt wind
#

I know theres a way to get the world position... I just dont remember how honestly

kind juniper
#

Not in the compute shader.

burnt wind
#

I know

#

But I dont know what to reference in the C# script

kind juniper
#

In a fragment shader unity does all the job for you, so you can just access it.

burnt wind
#

Do you have an example?

kind juniper
#

In compute shader you'll need to make the calculations manually. I don't understand why you'd need to do it though?

burnt wind
kind juniper
burnt wind
#

This is a raymarcher

#

(its in 2D)

kind juniper
#

Just have a plane/quad in the world with a material.

burnt wind
#

lol

#

no..

#

that would ruin the whole point of having the raymarcher in the first place

#

Im making the raymarcher because I have a project that requires a raymarcher

#

theres certain things that geometry and meshes just cant do

kind juniper
burnt wind
#

problem is, I have no clue how to do that

#

I dont normally use unity for shaders

kind juniper
#

So we're back to setting a shader property from C#.

burnt wind
#

but Ive been asking you... what property

#

like... what calculations

kind juniper
#

I told you. SetVector or something

burnt wind
#

._.

kind juniper
#

Check the Compute shader api

burnt wind
tight phoenix
#

Random you are wasting your time

burnt wind
#

If I wanted someone to tell me I needed to change something in the script, I wouldnt have asked for help

burnt wind
tight phoenix
#

I'm not skilled enough to help you but I can at least recognize that

kind juniper
burnt wind
#

its literally a UV..

#

a fkin UV

#

I just need to access the UV centered and scaled on world origin

#

I dont get whats so complicated about that

kind juniper
kind juniper
#

So without the camera position and orientation you won't be able to transform them to their world position.

burnt wind
#

It uses the global position of objects in the scene

#

but its rendering the world origin as the center of the camera screen

#

so its like the world is following the camera

#

even though its really not

kind juniper
#

You probably need to transform the uv positions using the view matrix of the camera. But you'll have to research that on your own.

burnt wind
#

thats the whole reason I came here

#

and the reason Im quite irritated with you.. Im well aware of what I need, Im asking how exactly to do it

#

if you arent sure, just dont reply and wait for someone else to help me

karmic hatch
celest steppe
#

Is there a way to create a decal shader without using urp or hdrp?

mental bone
#

Well im sure that the build in pipelie has tons of examples. This blog post has a pretty decent example of a deffered decal system

celest steppe
mental bone
#

I suppose that the new render pipelines are overtaking the BiRP in search results, but there are 100% tutorials for the old shaders

#

But if yoy are new

#

Why are you using the build in render pipeline. urp and hdrp are the future and I would suggest for you to learn urp and stick with that

celest steppe
#

Okay thanks I will take a look if I find any older tutorials. Unfortunately my project is using the build in render pipeline and I cant switch that easily

meager pelican
# burnt wind thats the whole reason I came here

Well, with respect, you could have laid it out better from the start....like the fact that you're in 2D (you want a ray marcher in 2D?) and that you're ray marching effects/worlds.

Maybe use your google fu and see what you get when you research "reconstruct world position from depth buffer". πŸ˜‰
in 2D, you'd have a relatively fixed z value, but otherwise I suspect you can get the necessary transformations.

BTW, generally in ray marching you're going to end up having to ship the geometry/SDF/whatever data up in compute buffers anyway...so when you do a "ray hit" you'll end up knowing what polygon you hit and more importantly you'll know the vert world-positions. You could use barycentrics to interpolate across the polygon if you get clever.

spare ermine
#

How would I go about making a shader graph, that takes in a 2d texture, and applies it to all sides of a cube while staying tiled nicely, regardless of size?

meager pelican
#

If you want the texture to stay the same size (is that what you mean by "tiled nicely"?)...check out triplanar mapping. There's a node for it.
You could possibly work out a system to use object space but adjusted by scale. Or if you don't mind that it is axis aligned, you could use world space and that would take care of the scaling regardless of object size, but it won't rotate with the object...try it and play with it and see.

#

@spare ermine

burnt wind
#

And having to ask someone for half an hour for an actual piece of information rather than telling me "you need to change something in the c# script"... well... yeah... its kinda irritating

#

Regardless, I had to make up my own solution. So now my coordinates are warped by the active camera's scale and position.

#

:p

patent plinth
#

is there a way to blend object with the ground without using secondary camera?

white marsh
#

how can i get rid of this black on the specular when i lerp it instead of adding it on top? Im working on a toon shader and i dont want it to be effected by what is under it from whatever texture and whatever might be there

// Adding specular without being effected by textures
float _SpecularMask = (SpecularToon.r + SpecularToon.g + SpecularToon.b)/2.0f;
_SpecularMask = saturate(_SpecularMask);
output = lerp(output, SpecularToon, _SpecularMask);
// adding specular correctly, but its being effected by textures
output += Specular;
karmic hatch
white marsh
#

nice, thanks that works

#

ok so it works with a white color, but other colors doesnt seem to work exactly how i want it

#

this should be opaque

#

should i maybe replace the float3(1,1,1) in the lerp with the base color of the specular? that didnt fix anything

karmic hatch
#

Maybe swap the white for white plus the diffuse color

#

Tbh I'm not entirely sure why adding it doesn't work

white marsh
#

im not too sure either, i only want it to be transparent when the alpha is under 0. not when i have a colow that isnt white. it should replace not be layered shruggie

white marsh
karmic hatch
white marsh
#

well, apparently as i can se how its not adding it that seems to be a problem, its that its not the same color as what i have set it as

karmic hatch
#

You mean if you set it to green on a red background, you don't want any red coming through at all?

white marsh
#

yes

#

only if its transparent

karmic hatch
white marsh
#

it should be, but i can check

regal stag
white marsh
#

actually it might not, im multiplying the diffuse with a couple of things but its not saturated after

karmic hatch
#

wait

#

actually just do lerp(output, _SpecularColor, _SpecularMask) where _SpecularColor is your specular color property

#

(realised that if you want the peak of a highlight to be colored, it's not going to go to 1 for some components)

quasi oak
#

I don't know where this should go, but I exported a model from blender that I want to use in my game, but parts of the mesh are invisible/gone. Anyone know why?

regal stag
#

Looks like the normals might be reversed. (and faces are be culled due to back face culling, but in this case it's the wrong side). In blender, would want to recalculate normals while those parts are selected. (I think it's Ctrl+N in edit mode iirc)

quasi oak
#

ah, thanks

haughty moat
#

Hello. Are compute kernels essentially compiled into separate shaders (they do share some non buffer variables)? The documentation doesn't make it super clear what they do beyond keeping code with related or dependent functionalities in the same file

shadow locust
#

not sure what you mean otherwise

#

with multiple kernels in it

haughty moat
#

I guess my confusion stem from the fact types like int or float can be set for a whole shader, whereas buffers need to be bounds per kernel, even if they use the same RWStructuredBuffer member.

tight phoenix
#

Im trying to give this mesh a frosted glass surface finish but nothing I do looks right

#

reference

#

I've tried adding noise to the smoothness, to the normal map, but it never comes out looking right

#

Suggestions πŸ€”

hallow plover
#

is there a way to limit the amount of vector components in a vector type in the shaderlab properties. My current vector property only needs an x and y component and not 2 other ones you get.

tight phoenix
hallow plover
regal stag
hallow plover
tight phoenix
regal stag
#

Yea, you could write a custom ShaderGUI to change how the whole material inspector looks, and can set that in graph settings. But that's probably overkill.

regal stag
tight phoenix
#

so far my best efforts have made it look like a stone instead of like frosted glass

regal stag
#

Perhaps that's just the grey colour? Or maybe it's too strong. Not sure

tight phoenix
#

comparing it to the reference its clearly completely wrong

#

but everything I try to do to fix it only makes it worse

#

its too glossy and not glossy enough, its too rough but not rough enough

#

its too bright over all

#

everything is both

#

the little white specs are too white but not white enough

#

the gloss is too glossy but not gloss enough

#

its completely too bright over all

#

i keep fucking bashing my head off of it tweaking every value and its never fucking working

#

Im going into crisis now, time to leave

long rune
#

I cant build my project because of this error:

#

Does anyone know what this means?

meager pelican
#

Also maybe try setting higher requirements for target platform.

tight phoenix
#

What is a good way to lerp across multiple colors, without using a gradient (because gradients can't be exposed and edited in materials) and preferably without sampling a texture of a gradient (since you have to then sample textures and make textures of all your gradients) ?

acoustic flame
#

is there a way to make a shader not be effected by fog?

long rune
#

@meager pelican I have no idea what samplers are

kind juniper
grand jolt
#

Any "simple" shader graph/urp shader that is like the default urp shader but adds (black) outline?

kind juniper
wooden kite
#

how do i change the HDR intensity of a color in shader graph ?

#

i basically want the color's intensity to sine from a value to another

wooden kite
#

i basically wan't to replicate this thing with the spikes on the shader itself, i don't think i should need to use a script to do that

ebon basin
#

Could also do a tiling effect to scroll across the texture

karmic hatch
# wooden kite

If you multiply the color by some brightness, the intensity is the log of that brightness, so exponentiate the output and then multiply by your color

long rune
#

@kind juniper I will when I get home, but it's just a standard dissolve shader with 1 texture and normal map. Is it because I can't use the shader with so many materials at the same time?

kind juniper
long rune
#

I have a feeling that it's another shader.. Unity does not say which shader tho

#

@kind juniper But the error is being thrown on a built in shader no?

#

I'm using URP

kind juniper
long rune
#

Under 10 for sure

kind juniper
long rune
#

Why does it say light cookie then?

kind juniper
#

That's just one of the shaders in urp.

long rune
#

Yeah but it's pointing to an error with the light cookies no?

kind juniper
#

If you look at the path, you'll see that it's in urp package shader Library.

kind juniper
long rune
#

So there is no way to tell which shader is causing the error, but delete 1 at time?

kind juniper
#

Mmm... If you check the individual shader files in the inspector they might have an error on them.

#

The faulty file might have an error.

long rune
#

Fair nuff, I'll have a look thanks

frigid ether
# tight phoenix even with color it still looks wack

I think what gives the glass this effect is Sub Surface Scattering, but it is kinda hard to simulate in unity, you could maybe fake it in the texture or check this https://www.alanzucconi.com/2017/08/30/fast-subsurface-scattering-1/

gray shuttle
#

Hello! I'm receiving shader errors after upgrading my project to Unity 2021.3.2f1. Not sure how to resolve.

tight phoenix
#
inline float hash2( float2  p, float offset )
{
    p = float2( dot(p,float2(127.1,311.7)), dot(p,float2(269.5,183.3)) );
    return float2(sin(p.y*+offset)*0.5+0.5, cos(p.x*offset)*0.5+0.5);

    //return frac(sin(p)*43758.5453); // original return
}

inline float2 voronoi_noise_randomVector (float2 UV, float offset){
    float2x2 m = float2x2(15.27, 47.63, 99.41, 89.98);
    UV = frac(sin(mul(UV, m)) * 46839.32);
    return float2(sin(UV.y*+offset)*0.5+0.5, cos(UV.x*offset)*0.5+0.5);
}
#

I'm trying to fix the behaviour of the right Voronoi so that angle of offset acts like the left voronoi

#

to the best of my knowledge, the above 'hash2' is responsible for generating the random angles

#

but it does so like that image above

#

how can I edit it to generate random angles like the left most one?

#

I tried to sub in my standard random alg, 'voronoi_noise_randomVector' but for some reason that rips the effect appart completely instead of working

#

hrmgh it WAS ripping it apart, but now when I reverted it to that to show a gif of what I mean by rip apart, now it no longer does anything, angle wont change

#

WELP its working now and I dont know why

#

dont know why it tore it appart before and doesnt now, oh well πŸ”₯

grizzled bolt
gray shuttle
grizzled bolt
# gray shuttle I upgraded from 2020.1.0f1

Considering that's an experimental version and there's a massive leap between the two I don't think that's realistically salvageable
Unless someone has better ideas I'd recommend starting a fresh project and importing your assets as unitypackages

#

Also, why not newest 2021.3.?

gray shuttle
#

Didn't realize how big of a jump it would be. I know the old version I was working with wasn't LTS so I wanted something newer and stable

#

The project is actually fine, it's just when I build to my Android phone that I'm getting these shader errors

#

I deleted the shader asset and reimported everything and reconverted to URP

#

Doing a full overhaul so I can keep my game. I'm not abandoning it

gray shuttle
#

What an absolute nightmare that was

grizzled bolt
gray shuttle
#

Everything went from curved to flat. When I checked the prefabs they said "missing keywords" and there was a button to update shader. I updated and it went back to curved. Going to try and build again and wish for the best lol

#

Yeah I think it was just a build issue or compatibility issue thankfully

#

Issue is fixed! Thanks

wet pagoda
amber saffron
#

Try adding ZWrite On ZTest LEqual Cull Back in the first pass

wet pagoda
amber saffron
wet pagoda
wet pagoda
amber saffron
#

yes

wet pagoda
#

ok let me try

wet pagoda
amber saffron
#

IDK what's happing in the files included in this shader, but I can 100% confirm that the issue is that it need to be rendererd in the depth buffer.

wet pagoda
# amber saffron IDK what's happing in the files included in this shader, but I can 100% confirm ...

Shader "TF/Cylindrical"
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_Bump ("Bump (RGB)", 2D) = "white" {}
_ShadowTex ("Shadow (RGB)", 2D) = "white" {}
_Cutout ("Cutout", Range(0,1)) = 0.5
_SaturationRandomize ("Saturation randomize", Range(0,1)) = 0.5
_BrightnessRandomize ("Brightness randomize", Range(0,1)) = 0.5
_Ambient ("Ambient Color", Color) = (.5,.5,.5,1)
_LightMult ("Light multiplier", FLOAT) = 1.0
_Speed("Speed",Range(0.1,4)) = 1

_Amount("Amount", Range(0.1,10)) = 3

_Distance("Distance", Range( 0, 2 )) = 0.3

}    
SubShader
{
    Tags {"Queue"="Transparent-2"   "IgnoreProjector"="True" "RenderType"="Opaque"}

    
    Pass
    {
        Tags { "LightMode" = "Always" }

ZWrite On ZTest LEqual Cull Back

        CGPROGRAM

        #include "UnityCG.cginc"
        #pragma vertex vert  
        #pragma fragment frag 
        #pragma multi_compile_fog
        #pragma exclude_renderers xbox360
        
        #define TF_CYLINDRICAL_MODE
        
        #include "tf.cginc"

        ENDCG
    } // pass
    
    Pass 
    {
        Name "ShadowCaster"
        Tags { "LightMode" = "ShadowCaster" }
        Fog {Mode Off}
        ZWrite On ZTest LEqual Cull Back
        Offset 1, 1
        
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #pragma multi_compile_shadowcaster
        #pragma fragmentoption ARB_precision_hint_fastest
        #include "UnityCG.cginc"
        #pragma exclude_renderers xbox360
        
        #define TF_SHADOW_TEXTURE _ShadowTex
        
        #include "tfShadow.cginc"

        ENDCG
    }        
} // subshader

}

wet pagoda
orchid tusk
#

Does anyone know how to lerp 2 colors together with a gradient? As an example; I'd like one color to be green, the other color to be red, and then transition them with a gradient. So the top of the output node would be red, the bottom green, and then a blend between the two in the middle. I tried using a Lerp with a Sample Gradient (black to white), but the time only blends the gradient into a solid color. I could use a gradent image I suppose, but I wanted to see if there was another way. Thanks!

shadow locust
orchid tusk
regal stag
shadow locust
regal stag
#

These settings only affect how the model is imported. If it was flat to begin with, the imported/generated normals would all likely be (0,1,0) pointing upwards (in object space that is)

Displacing the vertex positions in the shader will not affect the normal vectors. You would need to manually calculate them. Using an Add node like you have done here isn't correct, you would need to "simulate" multiple positions by offsetting the Position node with the Tangent and Bitangent vectors, then displace them using the same calculation. Take the difference (subtract) the displaced position you have and take the cross product. Example here : https://www.ronja-tutorials.com/post/015-wobble-displacement/ (though it's shader code, not graph).

An alternative to obtain flat shaded normals, is to use a cross product on the partial derivates (DDX and DDY) on the displaced position for the fragment Normal (Object Space) port - would need to change your space in the Graph Settings. Might be easier.

#

Oh, the question was deleted :\ (oh well! hope that helps someone)

ebon basin
#

So I've been playing around with post-processing, and it's fine and dandy, but I'm having a lot of difficult with the camera stacking in the URP. So reading around it seems that just applying the effects to shaders is ideal, so that's probably what I want to do for all my vfx stuff. However, I can't seem to quite get the effect of the bloom that pp applies, even messing around with the emission and nodes like fresnel I can't achieve that extra glow that I want. Any idea what I should be looking into?

regal stag
ebon basin
#

Oh, I've it off purposely to mess around and compare shaders

#

also turns out the vfx decal node doesnt support shaders right now for some reason x_x

#

oh yeah that's a complete bummer. I guess camera layering it is

halcyon plank
#

Hey does anyone know how to make a shader graph that automatically paints textures on the terrain

ebon basin
reef grove
#

I just want some lines based on where on the screen a given pixel is

#

it works with orthographic camera but not perspective

crimson delta
#

Pls i need help in understanding this... Am using an asset called "Toony colors pro" am trying to enable outline in a URP project but i can't understand the process

regal stag
reef grove
#

ty !

regal stag
# crimson delta Pls i need help in understanding this... Am using an asset called "Toony colors ...

As that image is saying, you need to add the RenderObjects feature to the Forward/Universal Renderer Asset. It'll be in your Assets folder somewhere. If you used the URP template, under there is multiple under "Assets/Settings", one for each quality setting.
See https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@10.1/manual/urp-renderer-feature-how-to-add.html
Configure the feature to use the settings as shown in that screenshot.
If you need further help, #archived-urp may be a better suited channel.

spare ermine
#

How would I get the colour of pixels behind an object?
I'm trying to create a distortion shader with screen color but the result is much brighter than the scene's actual color

soft fern
#

Hey everyone.
Is there anyone that can nudge me the right way how to create this kind of shader:
https://www.shadertoy.com/view/MlVGDK
But i would like to have a hexagon pattern that is distorted and moving like it has a water kind of shader distorting it.
Most tuts ive seen just scrolls the shader. how can i add a voronoi kind of effect to a hexagon texture pattern to get this kind of effect?
thanx

#

ive played around with voronoi noise, but it isnt distorting the texture.

tranquil jackal
#

how to increase spacing between textures repeating it self?

#

this is made by muving UV by time, but I want the space between Texture talk area and next talk area to be bigger, like to skip one or two repeats

#

I could create super long texture, but that would jsut waste texture size

#

i just want to increse the spacing horizontaly between

kind juniper
#

Adjusting the texture is probably gonna be the easiest solution

tranquil jackal
#

that is true.... but I want to learn how to control textures more. Like Want to move them up or down. left or righgt, increase spacing and etc.

#

another question, textures always needs to be square right?

kind juniper
#

The "increase spacing" thing is the problematic one.

kind juniper
tranquil jackal
kind juniper
#

Why does it need to be huge?

#

Just add some space on the sides.

tranquil jackal
tranquil jackal
kind juniper
#

Yeah

#

2.5x actually

#

Well, you could try the other solution too

#

If the scrolled uvs are not in certain range set them to 0 0 or something. Assuming the left bottom corner of your texture is transparent, it should work.

#

You'll have to figure out how to check the range though.

tranquil jackal
#

I was tihnking using bool, if something is correct then multiply from sothing that hides the uv, but then in the end it just blinking :DDDDD I used the increasing texture... resolution sucks..... size of texture sucks... but oh well

median timber
#

is there a way to make a material transparent, but have the transparency not be recurrent? (like see through, but you cant see through it more than once)

tranquil jackal
chrome orbit
#

hi! sorry very new to unity, its an incredibly basic question but i've been through maybe 5 youtube videos and 10 documentation pages before trying here and nothing helped

#

i'm trying to export a model from blender to unity with its materials. from blender, I removed all the non unity nodes like one guide said, exported as fbx etc. the materials are not working in unity, so i'm just trying to find a way to open the shader graph in unity to try to reconnect the texture maps etc

#

i've just not been able to open the shader graph to touch the materials in unity so far. it is added to the scene through package manager but materials just won't open, even creating new unlight graph

#

tldr - i installed shader graph but can't manage to open any shaders

knotty juniper
chrome orbit
#

oh alright so theses will just not open for unity

#

i dont mind remaking all of them i just want to get it to work

knotty juniper
#

that not a shader graph

chrome orbit
#

right ok

knotty juniper
#

you can make one via the create asset menu

#

(or right click in the project window)

chrome orbit
#

alright this is going to be super weird, and i think it's because of something i fucked up earlier but opening a new unlit shader opens the unity hub (i didn't have shader graph actually installed, the default software to open .shader files changed, and i've yet to find a way to fix it) fixed finally

#

instead of opening the shader

#

is there another way to open the shader graph that isn't opening a shader bceThinkHmmSweat

#

finally oh god InaTired

karmic hatch
visual mesa
#

What is the difference between Graphics.RenderMeshInstanced vs. Graphics.DrawMeshInstancedIndirect? I'm essentially asking what is the difference between drawing and rendering?

shadow locust
tight phoenix
#

is there a better / more efficient way to get a more densely packed voronoi?

#

doing a single voronoi alone with a higher cell density doesn't have the same appearance

#

feeding a voronoi into a voronoi sorta works but ist still using 3 voronois and 3 powers πŸ€”

#

better question maybe is do I even want a denser voronoi, it looks kinda bad when the object is distant

visual mesa
dim yoke
visual mesa
#

Thank you!

tight phoenix
#

x/y question, my real question is how to replicate sparkles of this density

tight phoenix
#

yeah

#

maybe I should use a texture of dots? because im pretty sure if it was a texture the mipmaps or whatever will solve that

karmic hatch
#

Yeah a texture would work

tight phoenix
#

yeah no jank if I use a texture

karmic hatch
# soft fern Is it that simple?

If you just want to distort the hexagons, you need to change what you're using to sample the texture, eg by adding some noise to the UVs.

rustic dagger
#

I'm trying to use a post-transparents camera color blitted texture on an object and I can't get that object to not be included as one of the objects that render pre-blit.

is there a "proper" way to do this in URP?

#

I'm getting this:

#

the cylinder (as it appeared in the last frame, actually) appears inside of itself

dense bane
#

does unity have a getter for numGPUcores?

rigid sandal
#

Could anyone help me please?

rustic dagger
rustic dagger
leaden turret
#

hello again

#

trying to make the underwater fog effect now, which from previous research seems must be a URP Renderer Feature Full Screen post processing effect.... i think.

#

this is my first attempt at the underwater fog effect... which i basically copy-pasted the screen depth part from the URP Water Shader unity video tutorial

#

effect off:

#

effect on

#

it does seem to be doing something though; if i zoom in close to terrain ground it looks like this

leaden turret
#

ahh the variable inputs, lemme set them up...

soft fern
soft fern
leaden turret
swift totem
#

Hello everybody!

Does anybody know how to fix the noise, so it doesnt get "flat" from time to time? Its done with shader graph and i followed a tutorial. Im not really familiar with it
Thanks in advance!

dim yoke
swift totem
hearty basin
#

Hello friends and neighbors. Can you help me find the words to Google for the following effect? What I would like is a box with one face missing. The missing face is facing the camera. I would like the backfaces (here shown in red) to not render. But I would still like them to occlude the pixels behind them, effectively making the red pixels transparent, but ALSO any blue pixels that fall behind the red pixels. Is there a word or approach that I can search for? Some things that come to mind are portal rendering, but the ensuing camera wouldn't have to be in a different location.

slender chasm
#

@hearty basin Like parallax interiors?

hearty basin
#

I've been fascinated by technique used on the windows in Marvel's Spider-Man and Forza Horizon 4 so I set out to learn how these games achieved the effect and to see if I could build an Interior Mapping Shader myself using Shader Graph in Unity. Here's how it went...

Flexible Grids: https://www.youtube.com/watch?v=CGsEJToeXmA
Making UI Look Go...

β–Ά Play video
slender chasm
#

Yep. I was just about to say there are some tutorials on YouTube to help you out.

slender chasm
#

No problem

hearty basin
#

Hmm except that approach uses a static texture. I need the area inside the box to be interactive...

tidal cypress
#

what could I do to display a cone given an origin, direction, and a vector representing the slope?

#

I was thinking like some sort of post processing effect, but i'm not sure

rustic dagger
#

but obviously it's not exactly standard

hearty basin
#

Now I am looking into hole shaders. Getting closer

regal stag
hearty basin
rustic dagger
#

basically portals

regal stag
hearty basin
#

Here's hoping I can send a ray into that stencil 😐

regal stag
leaden turret
#

i see ok πŸ‘Œ lemme try

#

do i need to use blend mode Alpha?

regal stag
swift totem
# dim yoke In the shader graph of course

I dont get it. I dont seem to have the problem when i use simple noise. but with the gradient noise it cycles to back to 0... My Gradient Noise is setup like in the screenshot and goes to the Y of the vertex output

leaden turret
#

also i should probably clarify; currently this fog is applying to the entire scene, but next step i'm hoping to limit it to only apply to under water level which in my case is a static flat Y world position (i dont have waves)

regal stag
#

Probably something like : Lerp between the BlitSource and FogColour, with the T input set to the Scene Depth (eye mode).

leaden turret
regal stag
#

Yeah you wouldn't use that in a fullscreen effect

leaden turret
#

k removing...

#

i already have a Lerp going on in my current shader graph, should i leave that one as is? add another lerp before it / after it?

regal stag
leaden turret
#

"the graph should also be set to use Transparent surface mode for the node to function correctly" doesnt seem like i have that Transparent option in this version of unity / URP.... 😬

regal stag
#

That's because I typically use the Unlit graph template. The Fullscreen graph is new, and probably doesn't need Transparent surface mode.

leaden turret
#

ah ok

leaden turret
leaden turret
leaden turret
swift totem
# dim yoke In the shader graph of course

i think i found the "problem"? Is that the normal behavior of the gradient noise? i just added two gradient noises and offset the time a bit and now it doesnt go flat all at once... is that the correct way or can i achieve it with only one gradient noise?

leaden turret
#

hmm i might be getting somewhere here?.... i hope?....

#
  1. do my nodes look sane? do i have any extra / nonsensical / unnecessary nodes there for what i'm trying to achieve?
  2. how do i make it always at least a bit foggy, it should never be this clear near the viewing camera
  3. next step - how to do that limit at world Y coordinate so it only happens underwater
karmic hatch
soft fern
# karmic hatch If you just want to distort the hexagons, you need to change what you're using t...

i tried this and it went horribly wrong. what im trying to do is kind of making a heatwave shader that distorts a hexagon pattern. its kind of a forcefield that needs some movement on that hexagon. and im very certain that i want a voronoi pattern, cus its that kind of movement noice, but it should move the hexagon pattern. what i got now is nowhere close to that.
If i follow a heatwave tutorial, is there a way for you to show me where i should put the hexagon pattern for it to be effected of the heatwave distortion?

soft fern
soft fern
karmic hatch
#

(those circles are because the voronoi is swizzled to 2D, so you end up just sampling a diagonal line across your texture, where how far along the line you are is determined by the distance from the nearest point generating the voronoi)

soft fern
karmic hatch
soft fern
soft fern
#

its like water moving now.

soft fern
ebon basin
#

Hey, is it possible to make lightning branch out in a single shader pass, or does that require multiple billboards/passes or animation to make that effect?

tight phoenix
#

Im trying to use a 3d texture in a custom node but I cant figure out what it wants in

#

this method is being called

#

it says the in is a Sampler3D

#

but how do I pass that in? what is that? its not in the dropdown of types

#

which of these is Sampler3D?

#

How do I substitute or create a Sampler3D if none of them are?

#

im trying to make that line work

#

How do I resolve the error: "Too few arguments to a macro call"

#

float4 sampledColor = SAMPLE_TEXTURE3D(_MainTex, SS, (samplePosition + float3(0.5f, 0.5f, 0.5f));

#

this line has too few arguments but that method only takes in 3 arguments

#

so I dont understand how its too few

#

float4 _SampleTexture3D_Out = SAMPLE_TEXTURE3D(Texture, Sampler, UV)

#

what am I doing wrong? whats different that makes mine too few but theirs not too few?

#

How do I replace this? How do I fix this? How do I sample a 3d texture???

#

it says the error is happening at line 21

#

but line 21 is just a bracket

#

why am I getting all these errors, why is nothing working

#

cannot convert from 3d texture to 3d texture????? that makes no fuckin sense

#
'SAMPLE_TEXTURE3D': Too few arguments to a macro call
': 'tex3D': cannot implicitly convert from 'Texture3D<float4>' to 'struct UnityTexture3D```
#

How do I solve these 3 errors? google has zero answers

#

I got the code fro mhere but it doesnt work or do anytrhing

#

getting fed up, time to quit workng because there's no help on right now and no help in google either

velvet swallow
#

hello, I was hoping someone could give me insight on how I might correct this issue.

img1: working correctly. single texture import.

img2: spritesheet texture.

#

it seems when its a spritesheet, the sample uses the whole texture and not the sprite's texture location.

regal stag
# velvet swallow it seems when its a spritesheet, the sample uses the whole texture and not the s...

It's actually the opposite. When using a single texture the UVs range from 0 to 1. But when using a sprite sheet the UVs stored in the sprite mesh is a portion of that texture. That's why only the wizard-cat is displayed here, not the entire texture.

I assume there's some polar coordinates stuff going on here for the swirl & outline masking, but for the sprite sheet a value of (0.5, 0.5) is no longer the center! And there's some scaling differences.

If you pass some info from the SpriteRenderer to the material, it's possible to convert the sprite coordinates back to a 0-1 range. The answer here might help with that : https://stackoverflow.com/questions/53820303/how-to-get-original-texture-from-spriteatlas-to-use-in-a-shader-as-alpha-mask (though may want sprite.rect in this case rather than sprite.textureRect?)

velvet swallow
#

relative to the sprite.rect

#

thank you @regal stag

regal stag
# tight phoenix ```cannot convert from 'const struct UnityTexture3D' to 'Texture3D<float4>' at l...

In SG v10.3+ (Unity 2020.2.3f1+) you need to use the "Bare Texture 3D" and "Bare Sampler State" on the dropdown for the port types if you use Texture3D and SamplerState in the code parameters.

When using the "Texture 3D" type you can instead use a UnityTexture3D type as an input, which also provides the sampler associated with the texture via .samplerstate.
float4 sampledColor = SAMPLE_TEXTURE3D(_MainTex, _MainTex.samplerstate, (samplePosition + float3(0.5f, 0.5f, 0.5f));
In this case you don't need the SS input. But if you wanted to be able to override the sampler you would use the UnitySamplerState type for the input.

If you need to sample in the vertex stage, you would use SAMPLE_TEXTURE3D_LOD instead, which has an additional lod param.

rigid sandal
#

Could anyone help me?

kind juniper
kind juniper
rigid sandal
kind juniper
#

Well, then it's gonna be pretty hard to troubleshoot it...

rigid sandal
#

😦

kind juniper
#

What render pipeline are you using?

rigid sandal
kind juniper
#

Yes.

rigid sandal
#

I got lightweight one

kind juniper
#

You mean urp?

#

Because lwrp is super outdated ...

rigid sandal
#

Oh

kind juniper
#

Anyways, the shader is for built-in rp.

rigid sandal
#

Okay

kind juniper
#

So it's not gonna work with lwrp or urp.

#

Or HDRP.

rigid sandal
#

Okay, thank you

devout quarry
#

Is there a reason that my texture preview (in the inspector) looks so dark/faded while the preview in shadergraph looks normal? Really weird behaviour. The texture is a single channel one.

#

If I set the alpa source to 'from grayscale' it looks good but that's not really the intended behaviour since I have explicitly set the alpha values of the texture.

spark cape
#

im trying to find a shader on store that i swear i saw someone do, where it makes it seem like it "combines the meshes" by blending or something, does anyone know what its called or where can i find something like that

leaden zinc
#

Hi! Im looking to upgrade from built in to URP because URP has some features and new resources that i find very useful and are no available in built in.
My question is, most people complain about URP being not stable enough, what are your thoughts on this?
Also, do quality or performance actually improve from built in to URP?

#

Im learning shadergraph and most resources use URP, also Render Objects is a very useful feature.

karmic hatch
devout quarry
wooden canopy
#

Not sure if this is the best place to ask this.
I'm trying to make a game object that is a disappearing hoof print.
I'm using the time node to affect transparency and make it disappear. But time makes it so once one object is spawned and it runs, it won't appear on new game objects.
Since the material is being used by all game objects I'm assuming that's the problem, but I'm not sure if I'm trying to make shaders do something they can't, or I'm missing something in the shader graph

karmic hatch
tight phoenix
#

    float4 sampledColor = SAMPLE_TEXTURE3D(_MainTex, _MainTex.samplerstate, (samplePosition + float3(0.5f, 0.5f, 0.5f));
#

passing in UnityTexture3D and using it doesnt work

wooden canopy
karmic hatch
tight phoenix
#
    // Start raymarching at the front surface of the object
    float3 rayOrigin = i.objectVertex;
    // Use vector from camera to object surface to get ray direction
    float3 rayDirection = mul(unity_WorldToObject, float4(normalize(i.vectorToSurface), 1));

What are these vec3 in the context of shadergraph? how do I pass them in / generate them?

#

I dont know what i.objectVertex is, or i.VectorToSurface

grand jolt
#

is it possible to use shader graphs in build in render pipeline?

karmic hatch
karmic hatch
karmic hatch
#

I believe so

tight phoenix
#

hm its outputting something but that something definitely isnt a volumetric perlin noise

#

fixed the black top by changing the position size, but its still opaque πŸ€”

#
void RaymarchTest_float(texture3D _MainTex, SamplerState SS,  float _Alpha, float3 rayOrigin, float3 rayDirection, float _StepSize, out float3 Out, out float4 OutColor)
{
    float EPSILON = 0.00001f;
    float4 color = float4(0, 0, 0, 0);
    float3 samplePosition = rayOrigin;

    if(max(abs(samplePosition.x), max(abs(samplePosition.y), abs(samplePosition.z))) < 0.5f + EPSILON)
    {
        float4 sampledColor = SAMPLE_TEXTURE3D(_MainTex, SS, samplePosition + float3(0.5f, 0.5f, 0.5f));
        sampledColor.a *= _Alpha;
        color = BlendUnder(color, sampledColor);
        samplePosition += rayDirection * _StepSize;
    }

    Out = samplePosition;
    OutColor = color;
}```
#

Can you see why its not building up?

#

its not volumetric, its just surface

wooden canopy
karmic hatch
#

There's no loop

karmic hatch
tight phoenix
karmic hatch
tight phoenix
#

they are adding 0.5 onto a ton of things for reasons I dont know

karmic hatch
#

(In the if(), the 0.5 is to check whether the position is outside the cube)

tight phoenix
#

Because nothing changed visually when I did this

#

I also noticed that inside the loop its doing
samplePosition += rayDirection * _StepSize;

#

so wasnt it already adding that before I just did?

#

and it wasnt working before either

karmic hatch
#

In each iteration, add the jump onto sampleposition, so it keeps marching along in the direction of the ray

wooden canopy
tight phoenix
#

there is a loop

karmic hatch
#

there there is, in the code block earlier there wasn't

karmic hatch
# tight phoenix

You're looping until it reaches _StepSize, instead do 1.8/_StepSize (since the diagonal of a 1x1x1 cube is ~1.7 something units iirc, and you want all your rays to march all the way across

tight phoenix
#

oh sorry I added the loop after you told me to but didnt update the posted code

#

i added a max size and now it ray marches but it does it only when step size is negative and it looks janky when rotated πŸ€”

karmic hatch
#

You could also use what you did earlier with the refraction stuff to get the depth through the cube, and instead of sampling at regular distance intervals (which will give you lines like that, unless the intervals are very small) you sample at regular percentage intervals along the ray through the cube

#

Doesn't work as well when the cube is almost opaque, but works better if you're doing fewer steps

karmic hatch
tight phoenix
#

I was trying something with that but couldnt get anywhere with it

#

I think this is a dead end though, the raymarch version looks pretty awful and because the 3d texture has to be passed in unsampled, I cant do anything to make it look less bad

#

im trying to do volumetric effects inside the dice

karmic hatch
tight phoenix
#

it doesnt have to be a texture 3d, but everything ive tried that isnt raymarching looks awful or inconsistent

karmic hatch
#

(Though also if you make step size very small it would work and look OK)

#

(if expensive)

tight phoenix
#

yeah expensive is the problem

#

there will be many of this so I dont want it to be heavy

#

is there some non raymarching way to emulate having interiors like that? probably not?

#

my problem with multiple paralax planes of noise is that there is no way to keep it consistent across different angles

#

the interior looks completely different depending on which angle you look at it from

fervent flare
karmic hatch
#

(here the texture is 32x32 so i made small steps (128 of them) but for a lower resolution noise you could do much fewer steps)

tight phoenix
karmic hatch
#

Right, my fault (had it set to private). Should work now

tight phoenix
#

working now πŸ‘

karmic hatch
#

Also I modified it to only take a small part of the texture (8x8x8) and fewer steps (10)

#

Tbh even at 4 steps it looks volumetric (ig bc the angle isn't changing much due to the refraction)

grand jolt
#

I am new to unity, this might seem like a stupid question, but is there a way to apply a shader to an entire camera?

brave kettle
#

Does anyone know what is happening in the "scene" the boxes look fine but then when I'm in "Game" they come out with a black background texture.
I am using a material with a shader to change the color of the object.

velvet swallow
#

@brave kettle
maybe it's sharing a material with something else thats changing the background color

you could try

setting the material on awake

Material mat;
void Awake() {
var sr =  GetComponent<SpriteRenderer>();
mat = new Material(sr.material);
sr.material = mat;
}

brave kettle
#

ye but the background change the color when restart the unity idk that happens

velvet swallow
#

here i'm doing polar coordinates and rotating a cone

#

but the right one isn't looking as good because it's not a circular shape

#

any better ideas?

brave kettle
velvet swallow
brave kettle
#

because i have shaders to change border colors and other colors like this (the first item havent material)

#

my material have this colors but i dont have this red baackround in nothing

subtle dagger
#

does anyone know how I can create a camera shader that will color an object based of it's emission color

#

ie If emission color was pure white the object would be entirely white (unlit)

warm marsh
#

What is best practice for passing an array of structs (or just floats) to Unity's Shadergraph?

tropic sluice
#

Is there a way I can modify vertex data and have it persist into another shader or pass?

#

kinda of like a rendertexture but for vertex data?

high beacon
#

I have an animated texture and a texture mask, how do I combine the two such that the animated texture gets erased by the texture mask?

#

Still of the animated texture in question

#

The texture mask

steel notch
#

You guys have a good resource for maps?

#

Things like distortion textures and all that.

#

Black and white stuff.

#

Tile-able.

grand jolt
#

is there a way to exclude an object from shading?

leaden turret
leaden turret
tight phoenix
leaden turret
#

my water plane is at world Y coordinate 100

#

so Edge needs the value 100?

tight phoenix
#

I don't have enough experience to say

#

if it was me I would try different values for edge to see what result I get and figure it out from there

leaden turret
#

i'm not even sure if Edge is supposed to be the static value (ex. 100) and the In the camera world position, or vice versa

tight phoenix
#

The Step function returns 1 and 0, white and black

#

the edge value determines where that cutoff originates

leaden turret
#

ok

tight phoenix
#

if you pass in a UV node into In, and set edge to 0.5, you'll get exactly 50% white and 50% black

leaden turret
#

so i'm guessing Edge should be the 100 and In should be the camera pos Y

tight phoenix
#

Maybe, I don't know your use case, I just know how the node works

leaden turret
#

cool thanks lemme try

tight phoenix
#

question about 'Distance' in shaders πŸ€”
I know that distance is a float, a measurement of distance between two points
But what does distance mean for a fragment shader? What is being measured against what distance wise?
if I pass in object position, 'distance' from that seems to be measured by the 0,0,0 coordinate if I understand it correctly
Is each individual pixel fragment measuring its distance away from something? How does it know where to measure against based on the other vec3 input?

#

like a vector 3 can be a single point, but it can also be more than a single point

vocal narwhal
#

distance takes two inputs?

tight phoenix
#

length takes one, distance takes two

vocal narwhal
#

Because I don't understand your question, you pass it two coordinates and it returns the distance between them

tight phoenix
#

my question is I can pass in a vector 3 that is 3 arbitrary float values, like a color, and a vector3 that is a coordinate, how is it measuring distance between vec3 at the fragment level

tight phoenix
#

passing in an object position vs passing in a vec3 that is 3 random numbers

vocal narwhal
#

(b - a). magnitude

#

Why does it matter what space a and b are in, they're numbers

#

If you're getting the distance between a colour and a screen position that's still just the distance between two float3/4s, what they are doesn't matter

tight phoenix
#

a position node is not 'just a number'

#

its many numbers?

#

how does it know what number is the number to measure against?

vocal narwhal
#

It's a vector

tight phoenix
#

nevermind, you clearly don't understand my question

grand jolt
# grand jolt bump

i'm in need of an answer on this, i need a shader to shade every object on the screen except for two sprites

vocal narwhal
#

What does shading mean?

#

If you want to make something invisible put it on a layer not rendered by your camera

grand jolt
grand jolt
vocal narwhal
#

If it's a post processing shader then you either need to render the object after post processing, or write a complex setup that punches a hole out of the post effect using a buffer or stencil mask.
None of it is really that simple and depends on the render pipeline

leaden turret
#

(still have a few questions, like why does it only work if i use a negate node and negative Edge value, however if i remove the Negate node and try using positive Edge it does not)

#

but mainly: I realize my requirements goal posts have shifted πŸ˜› the effect i'm after should work even in "split screen" i.e. even when camera near plane is partially above Y 100 and partially beneath Y 100, i.o.w. i need the shader to perform its effect "on all pixels which belong to areas beneath world Y coordinate 100" no matter where the camera viewing angle is positioned from/to. Whereas currently if the camera is at a position above world Y 100 but the camera near-plane is still partially dunked underwater - there is no underwater fog which looks not good (and theoretically if the camera position is beneath Y 100 but still near-plane peeks out above water partially, it might still render the full effect even above water - altho i havent seen this happen currently)

vocal narwhal
# tight phoenix nevermind, you clearly don't understand my question

Perhaps try to describe it better, because it's getting the distance between the two inputs. It doesn't matter if they're a float, float2, float3, float4.
It'll just be distance in 1d, 2d, 3d, 4d.

float distance(float3 pt1, float3 pt2)
{
  float3 v = vt2 - pt1;
  return sqrt(dot(v,v));
}```
Is what a float3 distance function might look like.
A position is a float3, the function doesn't care what space it's in, what it is semantically. It's essentially the same as 3 random numbers making up a vector as far as the function is concerned.
If your question is about how things are interpolated as they enter the fragment shader, then that's a problem unrelated to distance. If your question is about passing mismatched dimensions into the function, like comparing a float with a float3 then I would probably avoid that entirely and swizzle the argument so it's clear what dimension is being compared.
```c
distance(a.xxx, vec3);
distance(a, vec3.x);```
leaden turret
karmic hatch
karmic hatch
leaden zinc
#

Good morning!
Anybody familiar with light cookies?
Im trying to use them in URP but Unlit shaders dont support it.
Any workaround for this?
Thanks!

forest ledge
#

can someone help me? how would i pixelise the dither output?

#

i can pixelise a texture with the pixelise group but im not sure how to do it to the generated shader

karmic hatch
forest ledge
#

i got it thanks

#

now i need to make it not scale when you resize the object and not move when you move the object

#

do i just do that by chaning the uv to position?

karmic hatch
forest ledge
#

yes

karmic hatch
#

Gradient too?

#

Or just the pixelisation

forest ledge
#

yea that changes on y axis doesnt it?

karmic hatch
#

yeah so if you move the object around the gradient will follow

forest ledge
#

then no i would like the whole thing to stay still

karmic hatch
#

Take the screen position and use that instead of the UV, and it should work

forest ledge
#

ok thanks

#

what does that mean?

#

am i supposed to have a texture?

karmic hatch
#

You could try just adding a property in the shader graph, calling it _MainTex and then seeing if it's happy

forest ledge
#

ok

plush yarrow
#

guys how do i edit the emmission of my custom shader?

#

i want it to give me the window that it typically opens for HDR color

haughty willow
#

Guys, can anyone help me with this or have a hint for performance optimization of a shader with several passes, executed via Graphics.Blit?

https://forum.unity.com/register/genesis?state=PkLY4VOH6aiSx0Micr5KOfotfX8ndJqo2VZX25s4%3B%2Fthreads%2Fshader-settexture-which-will-perform-better-optimization-ideas.1346132%2F&error=login_required

meager pelican
# haughty willow Guys, can anyone help me with this or have a hint for performance optimization o...

So that sample shader isn't the "real calcs" right? Right now you're basically averaging everything but blending over top. That just for "discussion purposes" yes? Because I think you could do it all in one pass otherwise. I think...
Try researching MRT (Multiple render targets) as your 2nd pass seems to be copying c to d, whereas you could just output to c and d at the same time in the first pass if the blend would work that is, they'd have to have the same contents to start with.
Or maybe I read it wrongly...flyby. πŸ˜‰

leaden turret
karmic hatch