#archived-shaders

1 messages Β· Page 2 of 1

unique oar
#

So anyways I have my own question for this channel as well. I have a texture containing a set of positions for some points in world space. As a test, I'm using a compute shader to draw their positions to the screen. What I'm doing is taking their position from that texture and multiplying it with the camera projection matrix, (unity_CameraProjection) then taking the resulting projected position and mapping it to pixel coordinates that I then draw on the screen. Currently the points are all in a sphere and colored based on their position.

#

However, these points don't seem to change when I move or rotate the camera. I tried the same thing using unity_WorldToCamera and that caused the points to move around, but it's obviously not the right matrix to multiply these points by

#

Here is my code. Sorry if it's crappy, also the float2(1003, 564) is the screen dimensions for the current window, since using the _TexelSize.zw doesn't seem to be working.

#include "UnityCG.cginc"

#pragma kernel CSMain

RWTexture2D<float4> positions;
float4 positions_TexelSize;
RWTexture2D<float4> projectedParticles;
float4 projectedParticles_TexelSize;

[numthreads(16,16,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
    float4 position = float4(positions[id.xy].xyz, 1.0);
    float4x4 projection = unity_CameraProjection;
    
    float4 projected = mul(projection, position);
    projectedParticles[uint2((0.5 * projected.xy + float2(0.5, 0.5)) * float2(1003, 564))] = float4(normalize(position.xyz), 1.0);
}```
#

(this actually generates a texture which I then add to the screen, but that's not super relevant, as I know it's an issue in this compute shader)

foggy wolf
#

Is there a way to put procedural textures on a mesh without using a uv map? (no seams and the such) similar to how you can in blender and substance. Example below

#

Procedural texture meaning noise

vocal narwhal
#

Make a triplanar shader using shader graph

foggy wolf
#

Will it work the same?

vocal narwhal
#

Yes

foggy wolf
#

Okie dokes

unique oar
coarse sable
#

anyone know how to fix this weird uv thing in a close ended sprite shape

#

nvm setting height of all points to 0

#

worked

#

ok another question anyone know how i can get as close as possible to a color ramp in blender
what ive got so far is this but the colors i choose arent exactly the colors replacing white and black

proper current
#

Hey so i need some help with merging code from two different SRP shaders but I have no idea how as i don't know anything about how to work with them
I've tried but it didn't work and i have no idea how to do it, can someone help me out?

dim yoke
meager pelican
#

You can try setting all verts to (0,0,0) in the geometry shader to cull the polygon. But then again, you could just not emit it....
So your question is confusing to me, no offense.
What type of culling do you want?

hexed surge
golden ruin
#

For some reason, i am unable to change the material on this sprite, what am i doing wrong?

meager pelican
# unique oar So anyways I have my own question for this channel as well. I have a texture con...

I don't understand. If your positions are in world space, they're not supposed to move...they're in world space.

Or maybe you mean they stay the same place on the screen even if you move the camera? In that case, take a look at the Unity_ObjectToClipPosition macro usually used in a vertex shader. You won't need the Object2World part of it, since you're already in world space, but you need the view and projection matrix. UNITY_MATRIX_VP.
https://docs.unity3d.com/Manual/SL-UnityShaderVariables.html
https://docs.unity3d.com/Manual/SL-BuiltinFunctions.html
There's also a UnityWorldToClipPos macro that you could run in a normal vertex shader that you could run in a full screen pass:

inline float4 UnityWorldToClipPos( in float3 pos )
{
    return mul(UNITY_MATRIX_VP, float4(pos, 1.0));
}```
Which you could use to transfer your WS data to the screen without a texture, or write to the texture, no compute shader needed. 

But IDK what you're doing to transfer all that to a texture, and don't forget about the perspective divide that happens during rasterization (dividing xyx by w). 

I think. πŸ˜‰  At least it will give you some matrices to play with. 

Anyway, it looks kinda cool from the pic.  πŸ™‚
meager pelican
# hexed surge I'm trying to understand if I should perform out-of-view checks on the input ver...

That does make sense πŸ™‚
Well, what happens is that the GPU automatically clips things that are outside of the camera frustum. Of course, the fewer calcs you have to do, the faster the shader is (the fastest polygons are the ones you DON'T draw).

That said, if you have to jump through hoops just to cull the polygons, you may be spending more time figuring out culling than you would just letting the CPU cull it. The only way to tell is to run benchmarks both ways. Which means you have to write and test the culling code. Sigh.

Anyway, that's what vertex shaders do. They convert everything to CLIP SPACE. And if the polygon is outside of the -1 to +1 range in all dimensions, the polygon is not in the frustum.

hexed surge
#

yeah, I was wondering if I should output from geometry stage unconditionally and let the later stages cull everything that's out of view
or perform additional checks for every input vertex and not output anything for out-of-view vertices

checks guaranteed to add more calculations
but I have no idea if less geometry from the geometry stage saves much performance wise

#

but yeah, seems like I need to benchmark that

#

especially because I want to test a version w/o the tessellation stage so I can target shader model 4, instead of 5

#

still not sure if I want to target 5 or not

meager pelican
#

OK, yeah hard to tell, but I'm guessing you might have a win, it all depends on how many out-of-bounds polygons you'd have in the first place.

The real trick, if you can find a way to pull it off, is to NOT use a geometry shader stage. They're slow no matter what.

But then you get into procedural geometry...

SM4? OK, maybe see if you can do it all procedurally like with a compute buffer full of points or something. But don't let me side-track you.

#

I think you can pull that off in SM4

hexed surge
#

yeah, no worries, I'm still not locked into geometry shaders, just researching all the options for the foliage rendering

coarse sable
#

im trying to remake this effect my friend drew in procreate of rippling cloth banners but idk how i would do that with a sprite anyone have suggestions?

coarse sable
#

my first thought was normals but i plugin a scrolling noise texture and nothing happens

waxen jolt
#

yea... it's a bit of rocket science for me, I got this shader from a youtube video and I'm still learning about the urp. I can' t figure out how to add my UV (which should be the first node on the top left if im not wrong) ad Vector2. And also this would only apply to the sprites that I allow, right? If so, isn't there a way to make it apply to all the sprites?

karmic hatch
coarse sable
#

so it will be tileable and i can have control over all the variables

karmic hatch
#

There's a normals from height node, but I wouldn't use noise, I'd just put in a simple sinusoid

coarse sable
#

wdym by that

#

a sine wave?

karmic hatch
#

There's a node that takes in a grayscale heightmap and spits out tangent space normals; if you just do sin(time + position) and put it into the normals from height node then it should give something good

#

Maybe multiply by some height difference so it's not waggling where it's meant to be attached to the wall

#

(by position, don't just whack in the vector3 but maybe add x and z components; also multiply both position and time by frequency parameters)

coarse sable
#

by position you mean this?

karmic hatch
#

no, basically take the dot product of the position and some vector2 (which you set to be a property so you can change it), multiply the time by some float (another property), add them together, then put it into a sine node, then a normals from height node (strength of that can be a third property) then put that as the normal

hexed surge
karmic hatch
#

Yep

coarse sable
#

oh woah

#

is there any way i can add noise/randomness to the movement

karmic hatch
#

yeah you could scroll gradient noise across

#

if you want it stretched along some diagonal axis you can do the dot product thing, cross the property vector with (0,0,1), then dot the position with that vector as well, and now you'll have 2 coordinates in a new diagonal basis

#

and you can then stretch one axis (multiply by some scale <1), add the time to the unstretched one, turn it into a vector2, then feed into your gradient noise

karmic hatch
#

Yes exactly

coarse sable
#

where would i plugin this dot product tho

#

would i just add it where the other one is added

karmic hatch
#

this dot product tells you how far your position is along a direction perpendicular to the direction the flags wave along, so you want to multiply it by some small value, then put it into a new vector2 with the other dot product

#

then add time multiplied by some vector2, and put the result into the gradient noise node

coarse sable
#

thank you so much dude

#

coolest shader ive seen in my life

karmic hatch
#

np :)

frosty kindle
#

noob question, don t know if here is good to ask, sorry if my topic is not good here

how can i make an effect for that blue image to looks like is coming from the edge of the screen, orrrr to looks a bit different from the background, thanks

tight phoenix
#

I'm having a problem with a normal map that I'm not sure how to solve

#

the normal map gives it this square texture instead of smooth

#

if I SUPER crank up the contrast, that grid appears

#

but even after gausian blurring out that grid from the texture, the square grid still shows up in Unity

#

Ive tried various settings on the export, import, filetype, I cant seem to eliminate the squares

#

UnityChanThink instead of putting the texture in the sampler node directly, I put it in its own node, and set that node to Bump instead of White, and that fixed it

#

weird, but good to know that affects it

#

scratch that, it stopped working immediately

#

maybe I misunderstood what I was seeing

naive shuttle
#

Hey, Im trying to make a dry up effect for a clay kiln, although Im getting some weird effects with the normal map. The 3rd pic shows how it's supposed to look (with the 1st pic as settings), and the 2nd pic shows my shader material settings, and the 4th pic is how it looks with the shader material...

#

Here's the shader graph

#

Im using URP

tight phoenix
#

and make sure the texture itself is also set to being a Normal

#

I have the node graph for a signed distance cube, but I am struggling to change it from UV space into Object space

#

here is an object space graph for a spherical distance field, but I cant seem to figure out where to plug which part of my cube into this to get cube instead of sphere

#

if I try to plug in my signed distance cube in in place of the object space, instead of getting a cube, I get eight circles at each corner of the cube

#

and im not competent enough at vector math to know why or how to fix it πŸ€”

tight phoenix
#

Output = length(max(abs(p)-b,0.0));
are the four nodes on the bottom equivalent to that formula?
the length of the maximum of the absolute of P minus B and zero?
the output appears identical but I cant be 100% sure I did it right

quaint coyote
#

One quick question while I was writing some lighting in the shader…

#

Why do we use world space normals for lighting calculations ?

mental bone
grizzled peak
#

Hello I have a water shader which is using a sine wave to displace the geometry of the "water plane" mesh it is applied too. How would I go about optimising a large water plane? Currently my scene (which is nothing but water an a blank terrain) is rendering with β‰ˆ 310 FPS

#

How could I optimise this? Simplifying the water plane mesh depending on the distance from the camera vertices are? Find a way to cull the verticies what exist under terrain?

mental bone
#

Both options are great optimizations yes

grizzled peak
#

great! I need to find a way to do those things then πŸ˜”

mental bone
#

Rather not simplifying it but tessellating it closer to the camera and not tesselating further away

#

Splitting your water into chunks and only rendering the vissible ones is also a option

grizzled peak
#

I have attempted to split the water into chunks however the sine waves don't match up

mental bone
#

You need to transform it into world space

grizzled peak
#

oh right... okay

#

hmm I am unsure if I done it correctly

tight phoenix
#

Working on this again today, trying to turn your instructions into nodes and I'm getting not the same results so I must be making a mistake somewhere.
Pictured is the Anistrophy, and the vectors perpendicular to the cube's faces

brittle owl
#

what am i doing wrong here? ive got an object space normal map that i baked in blender, when i try to use it in shader graph it doesnt work properly

#

for reference heres what it looks like without the normal map

regal stag
brittle owl
#

oh wait i forgot about that lol, ill try that now

#

hm

regal stag
#

It's also might be that the vector need to be swizzled, as I know blender & unity use different axis.

brittle owl
#

ohh

#

is there an easy way to do that in shader graph

#

without splitting

regal stag
#

There's a Swizzle node

brittle owl
#

oh wait cool

tight phoenix
#

return vec4(subColor, 0)/(1.-0.7*dot(direction, SUN))*0.4;
re-creating this in shadergraph, what does 1.-0.7 mean and how do I represent that?
one point negative zero point seven?

#

source code is shader toy

regal stag
#

Or maybe it doesn't need swizzling but needs inverting. I think the Y might be flipped 🀷

brittle owl
#

do you know what i should use as the mask for the swizzle?

#

oh

#

uhhhhhh i cant delete the swizzle node for some reason

#

something is very broken after adding the swizzle node

regal stag
naive shuttle
tight phoenix
#

why would they write 1 minus 0.7, and not just write 0.3?

regal stag
tight phoenix
#

changing it changes the result πŸ€”

regal stag
tight phoenix
#

Ahh I see

#

im pretty sure the nodes are right, its just a matter that im not sure what im supposed to pass in

karmic hatch
tight phoenix
karmic hatch
#

i see :)

tight phoenix
#

Not having much luck though, I read all your verbal comments and tried to make a graph of them but you were saying do this, no actually do it in this other order

#

I wasnt able to reproduce it

tight phoenix
tight phoenix
#

Im definitely doing something wrong in that graph because the effect gets stronger the closer my camera is to the object

#

and not based on view directions

#

view direction node must not be what I want

#

object, world, view, tangent all produce crazy results

karmic hatch
#

So basically what I had in terms of the subsurface color/brightness is:

  1. get whatever value you're using for the distance the light travels through the cube to reach the surface
  2. Remap it
  3. Multiply by the absorption color
  4. Negate
  5. Exponentiate
  6. Hyperbolic tangent to normalize it
  7. Multiply by an intensity
  8. Calculate anisotropy
    i. Dot direction and sun direction
    ii. Multiply by some float <1
    iii. One minus
    iv. Reciprocal
  9. Multiply the subsurface intensity by anisotropy
tight phoenix
#

I havent even gotten to color yet, I am just trying to map the angles

karmic hatch
tight phoenix
#

trying to do all of it at once is making me unable to figure out what does what

tight phoenix
#

for some reason the preview looks completely different to the actual model in a scene

karmic hatch
#

strange

tight phoenix
#

preview is mega black and white

#

model gets lighter the closer to the model I am, darker the further away

#

but otherwise looks shaded more or less normally

karmic hatch
#

Oh right, normalize the view direction first

#

I think that's it

tight phoenix
#

the entire graph is just me trying to debug the angles

#

ah okay

#

Okay it seems to be working-ish now, or at least isnt producing crazy results

karmic hatch
#

Nice

tight phoenix
#

its just kinda completely lit now

#

definitely looks nothing like this

#

without the ansio it looks like that

grizzled peak
karmic hatch
tight phoenix
#

the problem is probably because these ansio values are not for the color but for attenuating some other part I think?

#

the other part I have not yet gotten to?

karmic hatch
#

Yeah it just multiplies the subsurface intensity

tight phoenix
#

Ahh okay

karmic hatch
#

Doesn't do any of the work in terms of colors

tight phoenix
#

here is the hyperbolic tangents bit, the end result of this would get multiplied by the anistrophy

karmic hatch
#

That would just be a constant if I am not mistaken?

tight phoenix
#

I feel like my mistake here is that there's no concept of the cube in there anywhere

karmic hatch
#

You need some function for the distance through the cube that the light travels

tight phoenix
#

here is the signed distance field of the cube, it works as expected

#

would this be that function?

karmic hatch
#

What I did was I calculated the distance from each face multiplied by the brightness hitting that face, and plugged that in

tight phoenix
#

I do have brightness to use

karmic hatch
#

MainLightIntensity would just multiply at the end

tight phoenix
#

let me plug that in I think I understand

#

I'm not sure what the second value in distance would be here

#

hm wait this is distance from the UV map, not from the object's faces

karmic hatch
#
float fromFaceA = dot(axisA, position)*dot(axisA, SUN);
float fromFaceB = dot(axisB, position)*dot(axisB, SUN);
float fromFaceC = dot(normal, SUN);

where SUN is MainLightDirection, and AxisA and AxisB are vectors perpendicular to that face

#

(AxisA and AxisB you can get as AxisA = ObjectToWorld(ObjectSpaceNormal.xzy) and AxisB = cross(AxisA, normal))

tight phoenix
#

Thats a lotta dot products, give me a sec to try to set this up

tight phoenix
#

SUN direction is the value coming in from above

#

Axis ABC though im not fully clear on. I put in the SDF cube side for that?

#

I should make a subgraph passing in the sun angle for this to make it cleaner

karmic hatch
#

AxisA is just a vector perpendicular to the normal (but aligned with one of the other faces) and axisB is a vector perpendicular to the normal and AxisA

tight phoenix
#

vector perpendicular to the normal... so I need the cross product of... something?

#

the face normal and the view direction?

#

I have no idea how the SDF cube representation factors into this

karmic hatch
#

Object space normal.yzx is object space AxisA

tight phoenix
#

Thank you for your patience by the way, I know I don't really know anything or what I am even doing

karmic hatch
tight phoenix
#

is that the normal vector extruding from the face of the mesh?

karmic hatch
#

yes

tight phoenix
karmic hatch
#

indeed

tight phoenix
#

let me scroll back up and look at the formula from before

#
float fromFaceB = dot(axisB, position)*dot(axisB, SUN);
float fromFaceC = dot(normal, SUN);```
so position in space, and object normal, I have those values
karmic hatch
#

Might be convenient to just turn the main light direction into object space (i believe the node is called transform?)

tight phoenix
#

Ah yeah I am familiar with that

karmic hatch
#

And then just do everything with the object space position and normal

tight phoenix
#

I dont actually know what space the light direction is in, let me check

#

Ah okay thats World Space

#

ill transform to object space

foggy wolf
#

How can I triplanar map noise textures to an object? I'm trying to get procedural textures without any uv unwrapping

tight phoenix
karmic hatch
#

Direction

tight phoenix
#

Direction I think yeah

karmic hatch
#

Position also translates it depending on where the world space origin is compared to the object space origin

tight phoenix
#

is Axis A is object position, what is axis B?

#

let me scroll back up and make sure thats what you said

karmic hatch
#

Axis A and Axis B are both vectors perpendicular to the normal, but parallel to the normal of one of the other faces

#

They're mutually perpendicular

#

It's easy to get one perpendicular vector by just swizzling the object space normal

#

so rather than normal.xyz, swizzle to normal.yzx or something

tight phoenix
#

Okay got my swizzle, setting this up

tight phoenix
#

I think this is right??

#

let me look at the shadertoy what to do with abc once I have them

karmic hatch
# tight phoenix

face A should have the swizzle, and face B should have cross(axisA, normal)

naive shuttle
#

Hey, I'm trying to apply smoothness on a material using a voronoi texture, so that the white spots are smooth, whilst the dark spots arent. I want to add a sort of drying up effect, as if clay is drying up. Whenever I try this, this happens... (2nd pic WITH smoothness, 3rd pic with NO smoothness)

tight phoenix
#
float fromFaceB = dot(axisB, position)*dot(axisB, SUN);
float fromFaceC = dot(normal, SUN);```
Now im confused, I dont see cross product or swizzle in here
#

should I not be trying to replicate that?

#

is cross product and swizzle later steps?

karmic hatch
tight phoenix
#

oh its an earlier step??

karmic hatch
#
vec3 axisA = normal.zxy;
vec3 axisB = cross(normal, axisA);
tight phoenix
#

oh, okay let me throw that together

karmic hatch
tight phoenix
unique oar
# meager pelican I don't understand. If your positions are in world space, they're not supposed ...

Yes, sorry, I meant that the points aren't moving around on the screen when I move the camera. I just tried UnityWorldToClipPos and it's almost working? It's really weird that I got different results by calling this function as opposed to multiplying float4(position, 1.0) by UNITY_MATRIX_VP. At the moment, it seems to be incorrectly moving for two axes of rotation, Y and Z. It strangely doesn't do so for X rotation. I'll try to upload a video

naive shuttle
#

But, I think baking the roughness map from blender will give a better result nonetheless. I can then simply change the strength of that map to simulate it drying up @karmic hatch

karmic hatch
# naive shuttle Yes

It might be that the smoothness goes above 1 in certain places, try putting it through a saturate or hyperbolic tangent node before going into the fragment node?

naive shuttle
unique oar
#

my computer somehow lost the ability to encode MP4s one day, god knows why πŸ˜… so I have to get a converter from mkv to mp4 so itll show up on discord

naive shuttle
#

I just baked the roughness map anyways, so let me test that first

tight phoenix
naive shuttle
karmic hatch
unique oar
#

alright here's the video. You can see that the object moves the wrong way when the camera rotates about its X axis

karmic hatch
tight phoenix
unique oar
#

what do you mean

karmic hatch
#

When you are getting the world space positions at the end just say position.y = -position.y and see if that works

unique oar
#

it won't work, this is an issue with the matrix multiplication operations

#

the positions are all in a unit sphere, so inverting it wouldn't even really change anything

karmic hatch
#

right

#

try inverting the screen y position

unique oar
#

ohh wait you're right that would work

#

zamn thanks!!! that fixed it!

karmic hatch
#

nice

karmic hatch
karmic hatch
#

Might be worth making a sub shader graph of that and then you just need to copy it 3 times

#

Also make sure the rgb components of the absorption color aren't too different or it'll look weird

tight phoenix
#

Building the Subsurface function now, im definitely making a MAJOR mistake somewhere

#

since its completely broken from Remap onwards

#

trying to represent this

karmic hatch
#

You're putting a float when it wants a vector2

tight phoenix
#

right from the start remap is not happy with those values

karmic hatch
#

It divides by the difference of the two components

#

So it divides by zero and dies right from the start

tight phoenix
#

Oh πŸ€” good catch

karmic hatch
#

In my remap I assumed it goes from -1 to 1

tight phoenix
#

It still doesnt like a vector 2

karmic hatch
#
float Remap(float value, float minimum, float maximum)
{
    value = (value + 1.)*0.5;
    return minimum + (maximum-minimum)*value;
}
tight phoenix
#

is the vector 2 not the Subsurface value?

karmic hatch
tight phoenix
#

oh is Remap a custom function not Remap?

#

Im confused how 10 and -0.2 are vector 2s and not floats

karmic hatch
#

There wasn't a default remap, it's functionally the same, I just assumed it went between -1 and 1 for simplicity

#

The remap node wants a float (top) and two Vector2s

#

It's basically inverse lerp -> lerp

#

Inverse lerp involves a division by the difference between the two inputs

#

Putting in the float means it gets the same input twice, so the difference is zero, and the inverse lerp dies

tight phoenix
#

remap is taking in subsurface ( a float), 10 and -0.2, but 10 and -0.2 are not floats?

#

Why does it work on yours? I am critically not understanding how 10 is a vector 2

karmic hatch
#

Mine isn't general, it assumes things about the input that aren't true if you want to make a proper remap

#

It's techincally more of a lerp

tight phoenix
#

I can do a lerp, and I can also do vector 2s

#

Im not understanding what values I should be putting in and where when all I see is 10 and -0.2

karmic hatch
#

In the Out Min Max(2) part of the Remap, put 10, -0.2 i think

#

yes

tight phoenix
#

That will be the resulting range yes

karmic hatch
#

The input range is always -1, 1 if the cube has side lengths 2

#

(and it doesn't matter anyway bc it's linear)

tight phoenix
#

Ah okay so it takes in the subsurface, which is between -1 and 1, and THEN those two values are the min and max

#

Now I understand

karmic hatch
#

yes

#

Mine is that remap with the (-1, 1) hidden

tight phoenix
#

Ahh gotcha, tricky but more efficient if you know the assumed bits

karmic hatch
#

indeed

tight phoenix
#

now let me check this over make sure i've replicated it right

#

subColor = 1.2* hyperbolic exponential of negated surbsurface* color

#

and then returning a vector4 that is the result of that, 0, divided by this

tight phoenix
#

im definitely making a mistake with (subColor, 0)/(

karmic hatch
tight phoenix
#

return vec4(subColor, 0)/(1.-0.7*dot(direction, SUN))*0.4;

#

this should be that

#

the part past divide I mean

karmic hatch
#

You're not doing the one minus

tight phoenix
#

where is one minus in that?

#

1.-0.7 does this mean oneminus?

karmic hatch
#

yes

#

so get 0.7*dot(), then one minus

tight phoenix
#

1.-0.7 had me DEEPLY confused

tight phoenix
karmic hatch
#

Nice that looks good

tight phoenix
#

1.-0.7, (one point minus zero point seven) didn't parse to me, I assume its an expression with assumptions in it

karmic hatch
#

You could combine the multiply after the hyperbolic tangent with the multiply just before the divide

karmic hatch
tight phoenix
karmic hatch
#

When you multiply by 1.2, instead multiply by something bigger, 3 perhaps

tight phoenix
#

I definitely did it wrong

#

wait what you arent talking about the divide part? you mean the upper part?

#

I'm sorry I am not very knowledgeable about this stuff, I know this must feel like trying to give a computer verbal instructions to make a PB&J sandwich and watching them make every mistake possible

karmic hatch
#

These two operations can be merged to just one multiply (just change the float input), I'd say the one on the left is more intuitive to keep

tight phoenix
#

I'm not able to parse the verb combine in this context

karmic hatch
#

Wait why are you doing the multiply by 0.7 after the one minus

#

Multiply by 0.7 (positive 0.7 otherwise it's retroreflective instead), then do the one minus

tight phoenix
#

because I wasnt able to parse the correct order of operations from this

#

no wait, because of the 'Combine' thing

#

I didnt understand what I was supposed to be combining

#

Ill undo it

#

oh positive not negative

karmic hatch
#

yes that looks good

#

fingers crossed

tight phoenix
#

wait, Subsurface is a float

#

but arent these vector 3s

#

fromFaceA is a vector3

karmic hatch
#

FromFaceA is a float, Subsurface() is a vector4 (because ShaderGraph does colors in vector 4)

waxen jolt
#

I have an issue: I have these grass sprites placed on a tileset on which I applied a shader but the shader is moving the whole sprite but I want it to only move the top part. How can I solve this?

tight phoenix
#

if its supposed to be a float, ive made a major mistake somewhere

karmic hatch
meager pelican
# unique oar zamn thanks!!! that fixed it!

When you're outputting to a texture, sometimes Unity has the texture upside down. (well, Direct X does that, IIRC).
#if UNITY_UV_STARTS_AT_TOP
pos.y = -pos.y;
#endif
https://forum.unity.com/threads/unity-flipping-render-textures.1030057/

IDK if that is your issue or not, but if it is, you need to check IF you need to flip it or not, otherwise on other platforms it won't work correctly if you hard-code the flipping.

karmic hatch
tight phoenix
#

This doesnt produce a float though

karmic hatch
#

the blue at the end means it's a float

tight phoenix
#

should I just throw away Y and Z and only take X?

karmic hatch
#

axis a, axis b are vector3s

tight phoenix
#

Blue??

#

I will look for this blue

karmic hatch
#

the line coming out of the multiply is blue

waxen jolt
#

this is my shader graph, what should I multiply? (sorry im a newbie and I got this shader by a youtube video) @karmic hatch

tight phoenix
karmic hatch
tight phoenix
#

the literal line on the graph is blue, I see now, I didnt know that meant float

#

so this was my mistake, ill switch these to floats

karmic hatch
#

they are just being swizzled anyway so it won't affect things

tight phoenix
#

uhh somehow I cant leave my subgraph, gotta restart unity

karmic hatch
#

f

unique oar
tight phoenix
#

F in chat

#

oh fuck im still stuck in the subgraph on reboot

#

I cant close this window and get back to regular unity

karmic hatch
tight phoenix
#

okay reset my layout

tight phoenix
#

resetting layout fixed it, lost my layout though ill fix that later

waxen jolt
tight phoenix
karmic hatch
karmic hatch
tight phoenix
karmic hatch
#

Play around with the values

tight phoenix
#

these shouldnt be that bright im guessing?

karmic hatch
#

Yeah I think the multiply by 3 i guessed wrong

#

Lower it to 1 or 0.6 or somethin

tight phoenix
#

oh the min and max and multiply, okay ill pass in variables for those

karmic hatch
#

And the absorption color is actually the color of light absorbed, not the color transmitted - if you want the result to look reddish, you have to put in a blue-turquoise absorption color :)

tight phoenix
karmic hatch
#

This is the color I was using

#

It's down to taste though, pick whichever colors and values you think look nice

waxen jolt
#

like this? @karmic hatch

tight phoenix
#

should I be expecting this?

karmic hatch
tight phoenix
#

this isnt right but its definitely closer

waxen jolt
tight phoenix
#

its sorta working except on the wrong side maybe?

karmic hatch
karmic hatch
tight phoenix
tight phoenix
#

I think we might be in buisness

karmic hatch
#

very nice :)

#

The exact color I used was (0.4, 0.6, 0.9)

tight phoenix
#

I am having a little bit of trouble attenuating it with the minmax and that one multiplication

#

I cant seem to find a value range that isnt either blown out on the light side, or not visible on the dark side

karmic hatch
#

If you change the 10,-0.2 and intensity together you can change both the light and dark sides independently

tight phoenix
#

it might be a size problem with my model?

tight phoenix
karmic hatch
# tight phoenix Could you elaborate? "If you change the 10,-0.2 and intensity together" what do ...

Just mess around with the values, 10 means it gets attenuated by quite a lot, while if you lower it to 3 it won't get attenuated much at all so the dark side won't be much darker than the light side. If you mess around with the intensity, both the light and dark side get changed equally, so by changing both the attenuation and the intensity you can get both the light and dark sides to look how you want

tight phoenix
waxen jolt
#

or perhaps u meant this? @karmic hatch

tight phoenix
karmic hatch
tight phoenix
#

any values that make the back look right, make the front look like this
and same thing opposite, if the front is right, the back has no falloff at all

tight phoenix
#

Im not sure what you mean by changing them together and being able to adjust front and back separately

karmic hatch
tight phoenix
#

every adjustment to front also affects back, and visa versa

waxen jolt
karmic hatch
karmic hatch
waxen jolt
tight phoenix
karmic hatch
tight phoenix
#

it looks good in the graph, but looks not right on the model

karmic hatch
tight phoenix
#

ill try it on a default cube

karmic hatch
#

that would be good

waxen jolt
#

UV -> Split -> comes out G -> goes into voronoid UV input -> goes out...

tight phoenix
karmic hatch
#

Put the split after the pixellated uv

tight phoenix
#

I will play with the values more

karmic hatch
#

yes it looks like there's a bit coming through but the intensity is low?

#

You can get the cube normals from the smooth normals if you find the maximum absolute value of the object normal's x,y,z components, then return a vector with x,y,z components of new normal x = sign(old normal x)*(abs(old normal x) == maximum(abs(old normal x, y, z)))

tight phoenix
waxen jolt
#

so 2 connections?

karmic hatch
tight phoenix
#

10 to 0, with a power of 3

waxen jolt
#

again, im so sorry to be wasting ur time on something thats probably doable in 20 seconds and if u want I m willing to share screen u in call @karmic hatch

karmic hatch
karmic hatch
karmic hatch
#

Ok so the intensity is roughly flat all over

tight phoenix
#

0.18, is the problem maybe that im expecting this but it only looks this way because its in a black void?

#

Hmm yours the base color is black right? mine was grey

karmic hatch
#

Try changing the base color to black

tight phoenix
#

yeah doing that now

karmic hatch
karmic hatch
waxen jolt
tight phoenix
#

slightly better, but I still cant seem to get that STRONG highlight at the edges, weak at the body πŸ€”

#

maybe I need a third value

#

a power node maybe?

karmic hatch
#

ok start increasing the attenuation from 0 up (and increase the intensity a bit too)?

karmic hatch
karmic hatch
waxen jolt
tight phoenix
waxen jolt
#

and I honestly still dont know how this split into a multiply thing works

tight phoenix
karmic hatch
karmic hatch
tight phoenix
#

dont ask me why it shows 4 boxes, its a vector2 in the actual graph

karmic hatch
#

where is the 0.2 as well?

tight phoenix
karmic hatch
#

very odd

tight phoenix
#

the first and second value are the vector2

#

adjusting values isnt working, I must have made a mistake in the graph somewhere

#

Its at least working now which is way ahead of where I was, its just a matter of fixing the output values

#

I will keep adjusting it and see if I can get it to look the way I'd expect

waxen jolt
#

@karmic hatch how would I go on and fix the issue?

tight phoenix
#

I knew there must be a mistake on my part, let me plug the adds into hyperbolic tangent

#

wait wait wait hold on, another major thing

#

no wait maybe im dumb not a major thing

#

I was thinking the color was getting modified per thing and then passed into the next thing

#

but its not

#

no where in the graph does it account for the light;s intensity

#

also the Ansistrophy isnt being used either

#

ill try to see where those are supposed to be factored in

pure tide
#

so when i come close it looks fine, but when i get further away, it distorts

#

what else should i tell you? i feel like i haven't said much

tight phoenix
karmic hatch
tight phoenix
karmic hatch
tight phoenix
meager pelican
tight phoenix
# karmic hatch Nice, those look pretty cool

I noticed totally on accident that if its a sphere not a cube, that the very extreme values are doing something weird/interesting to the highlight, next time I look at this ill see if maybe clamping ranges between 0 and 1 somewhere might help

waxen jolt
#

hey @karmic hatch my grass base is still detached? u got more ideas?

karmic hatch
waxen jolt
#

that it s still floating

#

that bottom part is still getting rendered somehow

#

like it's not getting masked out

#

@karmic hatch

karmic hatch
#

Oh you want it to disappear entirely?

waxen jolt
#

yea, i guess? I mean I want the grass to be fully attached to the ground

#

like u know when there s that little wind blow that just touches the grass and doesnt detach it from the ground

#

cuz now it looks weird

#

but now that I think about it, it's better if I make a new shader cuz this is needed for the grass but not for the tree

#

this video shows and explains what I want to do but I cant figure out how to run his demo

karmic hatch
#

There's a float that multiplies the strength of the effect, right?

waxen jolt
#

yea I guess

karmic hatch
#

I think it's the property feeding into the blend

waxen jolt
#

its should be the speed variable

#

that adjusts the speed/strength of the wind

karmic hatch
#

I think the speed just multiplies the rate at which the grass moves, not how far

#

So it'll wiggle back and forth faster but not further

#

There was another float going into the blend node, can you try changing that in the material and see if it makes a better result?

waxen jolt
#

the blend value u mean>?

waxen jolt
#

I put the BlendValue to 0 and now detachment is clear

#

this detached pixel wasnt there before

#

and btw these are different sprites

#

they are 16x16 tiles

shy fiber
#

Guys is it possible to write a projector shader to desaturate where alpha = 0?

#

on the source texture

karmic hatch
shy fiber
#

desaturate the black part instead of making it darker

waxen jolt
#

cuz the grass is a different shader than the ground blocks, and the shader just makes the sprites "wiggle"

karmic hatch
#

Can you try putting the ground material on the grass and seeing if it disappears?

waxen jolt
#

so like on the trees it looks cool and nice cuz it makes everything wiggle, while on the grass it look bad cuz they become detached

karmic hatch
#

The material you use on the ground, that doesn't wiggle

waxen jolt
#

its a sprite

karmic hatch
#

Can you just put a normal sprite unlit shader on or something?

waxen jolt
#

I dont know how to remove a shader without either breaking the shader or breaking my stuff

#

like I cant remove the material

karmic hatch
#

You can always undo it after putting a different material on

#

Just make a new material, put on a sprite unlit shader with the texture you want, and put that on the grass

waxen jolt
#

ok done

karmic hatch
#

is there still a gap?

waxen jolt
#

nope

karmic hatch
#

hmm

waxen jolt
#

no wind and no gap

#

still sprites

karmic hatch
#

After the blend node, could you put it into a saturate node then the texture node?

#

Might be some of the UVs going negative or something

waxen jolt
#

math or adjustment?

karmic hatch
#

The maths one

#

There's saturation and there's saturate iirc

waxen jolt
#

true, didnt read correctly

karmic hatch
#

Is the gap still there?

waxen jolt
#

yep

karmic hatch
#

f

waxen jolt
#

isn t there a way to mask out the bottom part of the UVs

#

instead of the voronoid?

karmic hatch
#

Wdym?

shy fiber
#

Guys is it possible to write a projector shader to desaturate where alpha = 0?
on the source texture

waxen jolt
#

like u see the bottom line is getting "masked out" but its in the voronoid and the UVs are still getting rendered good

#

after the blend node

#

or is there a way to increase the bottom black part?

#

to like troubleshoot it better

karmic hatch
#

Maybe try skipping the voronoi entirely and just put the pixellated UVs into the sample texture node?

waxen jolt
#

this wont animate it tho

karmic hatch
#

just to see where the problem is

waxen jolt
#

gap still present

#

even more evident

karmic hatch
#

Ok maybe feed straight from UV to sample texture?

waxen jolt
#

what if it s the split

#

?

karmic hatch
#

The split just takes one component, it doesn't alter any values

#

It might be the texture has a line of transparent pixels at the bottom, and offsetting very slightly would skip them?

waxen jolt
#

no gaps

karmic hatch
#

Ok that's nice

karmic hatch
#

Maybe after the divide, add 0.01 and saturate? So have all the pixellation stuff, then at the end add a tiny offset, saturate, then put it into the texture sampler

waxen jolt
#

seems good to me

karmic hatch
#

No gap?

waxen jolt
#

no I mean the logic seems good

#

let me try it

karmic hatch
#

fair

waxen jolt
#

how do I add a 0.01 ?

karmic hatch
#

put an add node, and then type that into one of the inputs

waxen jolt
#

the out where?

karmic hatch
waxen jolt
#

0.01 isnt doing much

karmic hatch
#

So still a gap?

waxen jolt
#

yep

#

im trying with different values

#

and I put the 0.01 to the Y value too

#

ok got it

#

I put a value of 0.0002 into the Y and now there s no gap

karmic hatch
#

amazing :)

#

now just pretend that's your pixellated UV and use that throughout and it should hopefully work

#

fingers crossed

waxen jolt
#

do I need the saturate?

karmic hatch
#

Probably not, because the maximum value of the pixellated UV should be <1

waxen jolt
#

mhh I mean its not really fixing the problem

karmic hatch
#

Saturate basically clamps all the values between 0 and 1, it's good for being safe if a value might escape that (whether it's supposed to or just some numerical error) but in this case yeah it's probably not needed

waxen jolt
#

the gap is still there I now can shift the sprites

karmic hatch
waxen jolt
#

yep

#

but that s not really the fix I was going for, cuz like I could ve done that just by grabbing the sprites and position them a bit lower

#

did u check the vid I sent u earlier?

#

maybe that can help

#

this is part of his graph

karmic hatch
#

as far as I can tell, multiply -> floor -> divide shouldn't put any pixels out of the 0-1 range that UVs live in

#

so i don't know why something should be going wrong there

#

it might be a numerical issue of some sort in which case a cheap fix is all it really warrants

waxen jolt
#

I might have found a way

#

not to fix my thing but to get the same mechanic working

waxen jolt
#

but im getting the pink material error

karmic hatch
#

i'll have to sleep now but if you're still having trouble tomorrow i will be back

waxen jolt
#

gn mate

#

and thanks for everything

quaint coyote
mossy remnant
#

are there any free texture websites to download textures other than textures.com

dim yoke
mossy remnant
rain minnow
#

I've written a simple shader in hlsl which I'm using inside of shadergraph (as shown in screenshot). But when I move the around (in the scene view, right now I can't test it in game), there's some weird clipping going on with the mesh. Why is this and how can I solve it?

regal stag
# rain minnow I've written a simple shader in hlsl which I'm using inside of shadergraph (as s...

Pretty sure it's because of Transparent surface type. Transparent objects don't render to the depth buffer (in order to achieve the correct alpha blending). But that also means it cannot sort per-pixel and only sorts based on the mesh origins and triangle/index order.

Should use Opaque instead. Unless you really need alpha blending... might then be able to do a prepass writing only to the depth (ColorMask 0, ZWrite On). But if you just need 0 or 1 alpha can use Opaque + Alpha Clipping instead.

elder ingot
#

i was using fog node in my shadergraph but the amount of fog is effected by the object direction towards camera

#

how can is fix this?

#

do i use some combination of world space of object space? im not sure which one

rain minnow
quaint coyote
mental bone
quaint coyote
pure tide
tight phoenix
#

What do I have to do to make this effect not get bigger or smaller based on distance from the object?

tight phoenix
#

hm I got this far, the texture is futzed up but it does respect scale

#

how do I unfutz the texture though

#

here is someone achieving it but I cant figure out how to translate UE4 to SG

tight phoenix
waxen jolt
#

hello, a shader of mine isn't being affected by a global light, anyone can help?

#

nvm fixed it

tight phoenix
#

this is supposed to be the formula for a signed distance cube, but when I impliment it in shader graph, the result I get is eight points, the outer corners of a cube, and not the cube volume itself

#

right from the start, absolute has a completely opposite color to what theirs shows for some reason

#

this could bed an XY problem

#

im TRYING to do this

#

Beer-Lambert light light absorption through a transparent medium

vocal narwhal
#

You are also remapping Z and W

#

split it so you're only using UV

tight phoenix
# tight phoenix

this is as close as ive gotten and its obviously completely fuckin wrong

#

but im too inexperienced to know what im doing wrong, what, where, when why, or how to diagnose or do basically anything

tight phoenix
#

yeah SDF is not the answer

tight phoenix
# tight phoenix

even though i have the sdf of the cube, I cant use it to make this look because im too inexperienced

mossy remnant
#

I want to create this printed mirror wall on the left

#

I made a mask on photoshop

#

but I don't know how to combine them in shaders, nor I can find any tutorial please help

native pilot
#

Is it possible to toggle these at runtime?

thorn zephyr
#

Hi @kind juniper This is happening to us on Android phones and iOS phones, seems not to be just on some devices. In particular we think this native shader is the problem: β€˜Particles/Standard Unlit’

#

Is there any other shader we can test that is similar to this? Many Thanks!!

silk bridge
#

There is anyway to debug this and get know what is the problem? im not sure if the platform is the problem this happen to us with iOS also.

kind juniper
kind juniper
median pagoda
#

Hey @kind juniper

#

question

#

so

#

would there be a way to find out what shader I am using to get the right pipeline for it?

kind juniper
#

What file extension does it have?

median pagoda
#

How do I find that

#

found it

#

its a shader graph

#

shadergraph

kind juniper
#

..?

median pagoda
#

it says .shadergraph

kind juniper
#

Then what was the file that you took a screenshot of before?

median pagoda
#

the same thing

kind juniper
#

In general code

median pagoda
#

it was the same

#

I just needed to install shader graph

#

before I had it

kind juniper
#

It was definitely a compiled shader, not a shader graph

median pagoda
#

ik

#

but

#

I looked up a solution and it says to use shader graph and it told me how to get it

kind juniper
#

Okay. So what's the issue currently?

#

Can you take a screenshot of the file?

median pagoda
#

that the material is pink

#

yea

#

hold on

#

there

#

that pink material isnt supposed to be pink

kind juniper
#

Okay, so yeah it is a shader graph. And it's not exactly compatible with Built in render pipeline. If you want to use it, you should switch to URP or HDRP

median pagoda
#

How do I get URP or HDRP

#

also what is better quality URP or HDRP

#

Would it be HDRP

#

High Definition Reder Pipeline

kind juniper
#

Yes. HDRP is for photorealistic stuff. It's also several times more complicated than urp.

median pagoda
#

so urp would be better for simple wise

kind juniper
#

Yep

median pagoda
#

how do I get URP

kind juniper
#

That you can Google. There are many steps. Can't explain everything here.

median pagoda
#

k

stark agate
#

Any idea how to accomplish this effect:

#

instead of this:

#

My main problem is that i have no idea how to make objects have one unlit color and make them transparent at the same time.

#

Without parts of the mesh 'adding' to each others alpha

#

How to create transparent object with uniform color?

karmic hatch
#

If you're only doing one trail or don't want them to overlay, you can use the scene color since it'll only include the background, not the trails, so it won't build up

#

(so lerp (scene color, trail color, alpha))

stark agate
#

Thanks a lot for help. I don't know why i didn't think of that.

#

Any idea on how i could make this work with multiple trails

drowsy surge
# median pagoda

Late heads up to let you know that the shader was indeed faulty/incompatible. Top right of the master node, there is an exclamation mark icon.
The solution stays the same as dlich's, a render pipeline is required to use shader graph shaders.

regal stag
#

Shader Graph does now have Built-in support in Unity 2021.2+, but may be a bit limited (Scene Color node might not work)

crude flume
#

Hey anyone know of any good water/ocean shaders? I wanna make some really rough looking waves form on my avatar, I know mochi has a water shader but I'm looking for like hurricane type waves with froth and all with crescents if possible. Or something that is a really nice hurricane storm water shader so I get those really nice rough waves

heavy vine
#

I got this lava shader from an asset, how would I make it work properly on a sphere?

#

Like basically a sphere lava
It's not shader graph

white marsh
#

Would need to se the shader to help i think

shadow locust
heavy vine
#

umm, nothing I just want a spherical version of it

heavy vine
#

I basically just want it to be a spherical lava ocean

shadow locust
#

What's not spherical about it now?

#

If you apply it to a sphere, does it not become spherical?

heavy vine
#

Basically tries to be plane even though it's on a sphere

white marsh
#

Sounds like it doesn't displace along the normals then

restive oriole
#

hi guys, I've been looking for this info for a while now :

How do you make UI SHADERS in unity 2021+ ?

#

ours have been working well on 2019, and while doing an update, they all broke
from what I understood, it was an error and it won't be fixed

but I guess the community have found workarounds of some sort

heavy vine
white marsh
#

Im kinda bussy so i cant do much rn

#

All you would need to do is change line 71

#

And maybe get the normals i didn't check if they where already in there or not

heavy vine
#

I'll send you the code

#

can you maybe help me with removing those weird gaps?

#

they seem to be there because of the edges of all of these "sides", there are 6 sides here that are not connected with each other

#

because the height of the edges of all of them is different, the texture seems to be properly flowing though

white marsh
#

And if you didn't fix it already, it needs to move in the normal direction

heavy vine
#

Yes I'm doing vert.vertex.xyz += normalize(vert.vertex.xyz) * lerp(_MinHeight, _MaxHeight, texPixel.r) * _Amplitude;

mental bone
#

vert.normal* lerp....

#

Not the normalized position of the vertex

heavy vine
mental bone
#

Well the other thing I can think of is that you are sampling the texture using the second uv chanell
Does your sphere have proper uvs there ?

heavy vine
#

it's the built in unity sphere

#

sorry I don't really know much about shaders πŸ˜…

#

this is from an asset

#

what do you mean by sampling the texture?

kind juniper
mental bone
#

tex2Dlod(_HeightMap, vert.texcoord1 + _FlowDirection * fmod(_Time.y, 1200) * _Speed); is sampling the height map in the vertex function

heavy vine
kind juniper
mental bone
#

Seems like the displacement is toi strong yeah

heavy vine
#

I'm sorry what's displacement πŸ˜…

#

I feel really dumb

kind juniper
#
noun
1.
the action of moving something from its place or position.
"vertical displacement of the shoreline"
heavy vine
#

I meant in the term for shaders lol

kind juniper
#

In this case it's the displacement of the vertices

heavy vine
#

I was playing around with the amplitude and it kinda makes sense now

#

it has this now, which I guess can be ignored but it keeps getting bigger if I increase amplitude

kind juniper
#

I guess it's due to the way the sphere vertices are placed. Can you enable wireframe mode in the scene view and take a screenshot?

heavy vine
kind juniper
#

Yeah, that makes sense. I think you wouldn't be able to get better results by sampling a texture for the heights.

#

You can't really map a rectangle to a sphere without any artefacts.

#

If you want procedural planets or something like that, I suggest checking Sebastian Lague's series on procedural planets. He managed to solve the issue somehow.

heavy vine
#

Oh

#

wasn't making procedural stuff but thanks I'll check that out

#

thanks a lot for helping out with this, I really appreciate it!

cosmic prairie
#

You could use triplanar sampling to have it go on any smooth surface without artefacts

heavy vine
#

Never really used that before

cosmic prairie
#

you render that texture with 3 different UVs, the u and the v are set to the pixel's xy, yz, xz object/world positions, then, you combine them all this way -> get the pixel's normal, make it... ehh.. not normal? put it into an equation to make x + y + z = 1, after that you add everything together: nX*texYZ+nY*texXZ+nZ*texXY

#

surely it's explained better here xD

heavy vine
#

I've never even made a shader myself tbh πŸ˜…

#

This one that I'm modifying is from an asset

cosmic prairie
#

you just need to modify the existing one

#

find the part that takes in the UVs and start from there by switching them out to object or world positions

heavy vine
#

could you help me a little with it?

cosmic prairie
#

I'm on my phone, so unfortunarely not right now

heavy vine
#

Oh

#

ok

half nebula
#

hey, im unsure which channel to ask this but here is my problem
my armor looks very dull
is there is a way to make it look better?
or adding albedo texture is the only way?
thanks

gray harness
#

how can i convert uv to position on the mesh
I need to change texture on mesh based on some things from scene

plucky hazel
#

How can I add URP Decal Projector support for my custom shaders?

grand jolt
#

can someone please list off the full versions of the image abbreviations?
prm_B
prm_G
prm_R
prm_Alpha
_cdr

shadow locust
#

primary I guess?

#

rgba channels of "primary"?

#

Just guessing

small hinge
#

I'm using the built in rendering pipeline to write a custom shader based off of this tweet. I'm stuck on the part where it says "Get length or sqrMagnitude of that (dot with itself)". Basically I think it's saying that I should get the dot product of a world position fragment, but wouldn't that just be 1 since the vectors would be identical??

this is the tweet:
https://twitter.com/Ed_dV/status/1321618279270473730?s=20&t=XVQB3h5doKLvlvlKVyjdbg

(2/2)

Files are available on my patreon if anybody wants to play with them or use them in your projects. See what's available at https://t.co/XsxxAIDuxW

Likes

119

β–Ά Play video
grand jolt
#

then what colors do I put into the metallic, or smoothness maps?

mental bone
#

Colors ? Metallic and smoothness maps are greyscale

tight phoenix
#

I am having some trouble with multiple UV channels.
Im trying to export multiple UV channels but I can't seem to find the other UV channels/map layouts

#

when I set anything at that UV3, its always the same layout as UV0

#

the mesh im exporting from 3dsmax definitely has different UV layouts in channel 3 (4) but for some reason when I bring it into unity, it doesnt

#

what are the steps to figuring out what is going wrong? Im guessing its something to do with the export of the mesh from 3dsmax

meager pelican
# small hinge I'm using the built in rendering pipeline to write a custom shader based off of ...

They show you the graph.
But since you're in BiRP, you know about the length keyword, yes?
I think what they're actually saying is that since the sqrt of the dot product of a vector with itself is the length...or another way to say that is that the dot product of a vector with itself is the squared magnitude....

You can either do sqrt(dot(v,v)) to get the length...which is the same as length(v), or just do dot(v,v) to get the squared length.

tight phoenix
#

hmm, exporting as FBX instead of OBJ retained the extra UV channels, but now the extra UV channels wont show up in scene, they work in the preview though (text textures)

#

I cant find this in shadergraph

meager pelican
tight phoenix
meager pelican
#

IDK on that, but you'll probably have to show others your graph.

tight phoenix
#

here is my graph which is just a copy of that guy's graph from that post - the preview its working

#

hm wait mayvbe I am dumb

#

it might not be the same mesh in the scene

#

okay it wasnt the right mesh in the scene - but this was my worry about using an FBX - the model export is completely wrong

#

I was using OBJs because they're simple and just work, but OBJ wouldnt export multiple UV channels

#

FBX supports multiple but it also brings in all kinds of useless bloat and settings and multiudes of ways to fuck up the mesh

#

that tiny cube is allegedly the same mesh πŸ€”

meager pelican
#

Also note that your x value is a hard-coded 1 in your blend.
But others will have to comment on this, as I'm spaghettied out for today. πŸ˜‰

tight phoenix
#

i guess this is an export settings problem now rather than shader

tight phoenix
#

woohoo fixed the FBX, multiple uv channels working as expected

#

unity was converting units but Im already working at unity's scale in 3dsmax

coarse sable
#

anyone have a starting point i can use for a pixelated 2d fog my attemps have been underwhelming

#

or overengineered i should say

#

i think this is the bare minimum needed but theres a lot wrong (fog doesnt move only one direction for starters)

small hinge
olive hinge
#

I have a question that I have no idea how to properly explain, but I'll try. I have a position node that passes Absolute World Position (X, Z) into a Sample Texture 2D LOD node's UV input. Let's say for example the world position of the vertex is (5, 0, 5), how does the shader decide what part of the Texture to sample from? It's doing what I want, I just don't understand how it works.

meager pelican
# olive hinge I have a question that I have no idea how to properly explain, but I'll try. I h...

Depending on how the texture/sampler is set up, it will either clamp or wrap (most common is wrap) the UV's around and around until they are in the 0 to 1 range. So in your example xz of 5's wrap around several times to end up being a (1, 1).

This is why the tiling and offset nodes multiply for tiling, and add for offsets. If you do the math, you'll see how it works accounting for wrapping.

But if you clamp, you clamp all results to 0 thru 1. Then there's some other weird stuff like mirror I won't bother with.

tight phoenix
#

What are some different ways to rescale(?) transform(?) a linear range of values into a curved range of values? UnityChanThink

#

math is not my strong suit 😨

shadow locust
tight phoenix
shadow locust
#

I think so

tight phoenix
#

remembering highschool math, power node multiplies things by themselves x numbers of times πŸ€” might be what I need

shadow locust
#

well yeah you could use pow node or mul to create like an x^2

tight phoenix
#

animation curve would be way easier to get the exact ranges I wanted though

#

Oh that helps

shadow locust
#

there's javascript code for that curve

#

which you could adapt to shadergraph

tight phoenix
#

Wow this site is really handy, the preview buttons are awesome

shadow locust
#

yeah i love it

tight phoenix
olive hinge
#

why doesnt my custom shader function have any input/output dots?

#

maybe something just buggy with the node, created a new node and no issues..

regal stag
grizzled peak
#

Hello, how would I go about getting the distance from an object with my outline shader and the camera? Cause I want my object outline to decrease in scale as I get firther away

#

URP + shaderlab not graphs btw

karmic hatch
#

might be useful

tight phoenix
#

https://gfycat.com/klutzyunitedaustraliankestrel
What could I use to offset my UVs so that when the sphere is rotated, it looks like its inside out when its really right side in?
When the sphere is actually inside out, the texture moves opposite to the rotation of the object, so I'm thinking the answer is that I need to offset the UVs by twice as much as its rotating in the opposite direction of its rotation

#

But how to actually do that πŸ€” I am not sure how to get the object's rotational value, or where to then add/subtract/divide/multiply/ what method to then translate the UVs

#

View Direction sorta does it but at a scale way beyond what I want πŸ€”

#

hmm the cross product of the tangent view direction vs the object view directionalmost kinda does it, but only on one axis, the other axsies get weird

#

I cant seem to isolate whatever is happening that makes it work on that one axis and then apply that to the other axis πŸ€”

tight phoenix
#

this -almost- works but there must be a simpler less stupid way, the scale is way off on the result

#

there's too many small weird things to correct for, this cant be the answer, gunna restart from scratch πŸ€”

#

How do I move the normal vector in opposite direction? πŸ€”

#

I feel like the answer is just going to be braindead simple

amber saffron
#

Why don't you simply use an inside-out sphere mesh ?

tight phoenix
#

That's less fun than solving this

#

I could but I want to see if I can do it without using an inside out sphere, mainly because I can't also use URP's lighting on the outside

#

and I don't want to layer two transparent spheres

thorn tapir
#

Hey so I'm trying to plan out script and shader I want to set up, that will allow me to adjust the contrast value of individual tilemap layers.

So far, the only thing that works in my head is to have a camera outputting to render texture for each layer, then run each of those textures through a shader material that can adjust the contrast (haven't gotten to the bridge of how to do this yet)

but this seems a bit messy... +1 camera and material for every layer

Any one have any thoughts on better ways to do this?

amber saffron
#

@tight phoenix For the normal, logically the normal of the inside but opposing side of the sphere has the same value, so you shouldn't need to touch it πŸ€”

tight phoenix
amber saffron
#

Ah, erm yeah, sorry, my point was only for if looking trhough the exact center of the sphere

tight phoenix
#

Ahh

#

I think all I need to do is move the normal vector by twice the object's rotation, this person here discusses how to get the rotation value of the object in the graph, maybe I can make progress here

#

time to learn matrix math

amber saffron
#

Have fun πŸ˜„

tight phoenix
#

why doesnt this work? πŸ€”
if I take the real value, make it opposite, and add twice the opposite, shouldnt that make it rotate in the opposite direction?

#

obviously I am wrong, but I don't know where I am wrong in my assumptions to make it produce the result I desire

#

hmm the problem must be because im not sampling the object's rotation value

#

back to matrix math I guess

#

this sollutin only works in the Y axis, what do I have to change to make it work in all 3 axis?

#

no matter what values I plug in where, it just wont spin backwards

#

trying to rotate by the radians of the object didnt work

#

I can change which side the normal vector ends up on, but cant seem to make it rotate opposite

#

this should be stupidly easy

#

its literally just 'take whatever its doing, and do twice of it the other way'

#

why cant I figure it out? am I too stupid?

thorn tapir
#

but the thing is, i'd still need a camera and render texture per layer, because if I just try ot grab all the layers into one render texture, then its just all one flat image

#

if I could somehow get one camera to output 4 different render textures, that'd be nice

#

but maybe I should just concede to having the extra cameras

#

at least, get it working first

unique oar
#

Is there a certain order in which image effect shaders process texels (or chunks of texels, really) when you use Graphics.Blit?

#

Like, should I expect the shader to affect the top-left region of a texture first, or something like that?

lean lotus
#

Is there a way to mix raytracing shaders and compute shaders in such a way such that I can use compute shaders for the shading but use raytracing shaders for ray-scene intersection?

karmic hatch
#

That gives the position on the other side of the sphere

#

(if it's radius 1/2 which the default unity sphere is)

tight phoenix
tight phoenix
karmic hatch
#

Probably object space would work best (should make it independent of scaling)

#

Also you're adding and multiplying in the wrong order

tight phoenix
#

oh I guess I forgot my pemdas or pedmas or whatever the acronyms is

karmic hatch
#

probably should've used brackets tbf

#

Position + (View Direction * dot(View Direction, normal))

tight phoenix
#

is tangent space normal vector not the normal maybe?

#

Now im not sure what space/direction/thingy node represents surface normal

#

I thought it was tangent but now im doubting

karmic hatch
#

Object space normal vector

#

Object space everything

#

Tangent space normal vector is just (0,0,1) by definition

tight phoenix
#

Oh

karmic hatch
#

(unless you use a normal map)

tight phoenix
#

Object space everything isn't producing the correct result

#

its spinning twice as fast in the direction that I turn it, instead of spinning equally fast in the counter direction

#

something must be flipped

karmic hatch
#

Oh then subtract instead of add

#

(probably)

tight phoenix
#

Hmm that is producing even stranger results

#

the effect is getting close to existing, I think its just a value is backwards or negative when it should be positive somewhere

karmic hatch
#

No subtract top from bottom I mean

#

Subtract the view direction stuff from the position

tight phoenix
#

By top from bottom do you mean flip the inputs?

#

like that?

karmic hatch
#

Yes

tight phoenix
#

this is the product of the current graph

#

minus the turning salmon part that's the gif's issue

#

up/down doesnt seem to change at all πŸ€”

#

while the others are rotating

karmic hatch
#

I think the display sphere in shader graph is radius 1

#

But the default unity sphere is radius 0.5

#

So double the view direction stuff and it should work for the display sphere?

tight phoenix
#

oh you are right it works in scene

karmic hatch
#

ayy nice

tight phoenix
#

that's weird that they aren't the same thing

karmic hatch
#

Yeah I forget why i found that out, but it was probably screwing something up

#

Ig for scene view it could reasonably be used in game, whereas here it won't, so they can do an analytic sphere rather than a mesh

tight phoenix
#

bigger on the inside πŸ‘€

karmic hatch
#

If you're just using it on a unity default sphere and do everything in object space I think it would be fine with scaling

#

Or any sphere that's diameter 1 by default

#

(the scaling affects the world space stuff but not object space)

tight phoenix
#

hmm yeah when I zoom in and out the effect is getting scaled

#

hmm or maybe its not, might be my imagination

#

ill use it as UVs instead of as a color, should reveal

#

okay yeah it was my imagination, everything works great πŸ‘

small hinge
#

trying to access the normals in _CameraDepthNormalsTexture by using DecodeDepthNormal() but for some reason the output normals are all solid black.

tight phoenix
#

or even HOW to use it to solve any kind of problem at all

karmic hatch
#

Ig since you can get the back of the sphere as a function of properties of the front, you can more easily do refraction inside the sphere or go through some volumetric thing

tight phoenix
#

I don't know why I thought rotation based on normal vector would do literally anything to help me achieve this

#

this looks roughly right but this is just the exterior - I need to somehow also get the interior

#

which I knew i needed that reverse invert mapping πŸ€”

#

left is how it should look, right is how it does look (photoshop)

#

ill keep plugging away at it, I have the inside out UVs now πŸ€”

amber saffron
thorn tapir
#

aaah I see, yea that makes sense

#

I was overcomplicating it a bit I guess

tight phoenix
#

Im just going to give it a break, my brain is mush

#

I guess I DIDNT want object space at all, what I wanted was arbitrarily pointing towards the sun space