#archived-shaders

1 messages · Page 189 of 1

grand jolt
#

and idk what that means because I don't really know how to code shaders and this is one I copied from another guy lol

#

if anyone could help me with this that'd be greatly appreciated

#

if anyone answers, please do ping me

thick fulcrum
grand jolt
#

okay thanks, so you think it doesn't have to do with the shader giving me errors?

#

i thought it maybe had to do with the alpha clip or something

#

since if you notice it kind of squares every shadow

#

it's weird

regal stag
#

It doesn't seem to affect the shadow of the wheel thing in the top right?

grand jolt
#

was just going to say that

#

i dont think so

#

lemme check

regal stag
#

It looks like a problem with the AlphaClipThreshold. Is anything set to change that at runtime maybe?

grand jolt
#

yea no it doesnt affect the wheel

grand jolt
#

lemme see if the alpha clip changes during runtime

#

it doesn't

#

it's always 0.1

#

the wheel has exactly the same setting in the mesh renderer as everything else

limpid creek
#

why is my material turning the image black?

grand jolt
#

OHHHHH

limpid creek
#

how to I make it the color of the image?

grand jolt
#

i figured it out

#

on runtime for some reason every object's mesh changes from quad to "combined mesh (root : scene)"

#

what the heck does that mean

#

and why does it do that?

regal stag
#

Probably related to batching

#

I can't think of why that would affect the shadows though 🤔

grand jolt
#

it does, when in runtime i change it back to quad it projects the normal shadows

#

and wdym by batching?

regal stag
#

If it's a mesh renderer is the gameobject set to static?

grand jolt
#

yes

#

oh lol thanks

#

disabled them from static

#

don't really need baked illumination

regal stag
grand jolt
#

thanks man

#

just gonna disable the static bool

regal stag
#

If you need baked lighting, you can use the dropdown next to the static tickbox to toggle each part separately

grand jolt
#

because the graphical impact is so minimal baked vs realtime doesn't really matter rn

#

good to know that because im probably gonna need to bake later in the game when I make the maps

#

what should I check in that box

#

i dont really know what each thing means

regal stag
grand jolt
#

oh right

#

i should read that

#

thanks

vast geode
#

Having this issue where a Texture 2D Array effect on a shader is bleeding through alpha objects above it. That blue behind the price should barely be visible.. instead it appears to be Multiplied?

What can I check besides render queue and material priorities (which are all well above the bottom shader's)?

regal stag
vast geode
#

I'm not totally sure what you mean. The background shader?

Is it possible the underlying shader color/alpha values are out of range(?), because I'm boosting the hell out of them in the shader.

regal stag
#

That's what I was referring to yeah. If the alpha/colour is out of a 0-1 range it might be causing the strange blending.

vast geode
#

is there some last-pass clamping I can do in the shader?

regal stag
#

Can use the saturate method to clamp them

vast geode
#

cool thanks!

#

@regal stag that was it, thanks again 🙂

grand jolt
#

that's really cool man

#

props

vast geode
#

is there any way to capture/export videos from a shader graph preview window?

willow pike
#

Anyone know how I can change the vertex colors of a skinned mesh renderer? I'm assigning vertex colors to the model using ProBuilder but when I add a rig in Mixamo it seems to erase the vertex color data. So I need some way of adding those vertex colors back in.

shadow locust
#

you just need

  • A mesh with vertex colors
  • A material that uses a shader that deals with vertex colors
#

default lit materials in Unity ignore vertex colors

willow pike
#

I have the shader

#

The issue is that Mixamo is stripping the vertex color data from my character when I rig it and download

shadow locust
#

OK I'm not familiar with Mixamo so maybe check the export settings?

woeful geyser
#

Looking for a good example of Graphics.DrawProcedural that draws custom triangles from custom data. Is it even possible?

willow pike
#

And I have no way to change vertex colors in Unity once it's a skinned mesh renderer. I'm coloring the mesh using Probuilder but it doesn't allow you to change the vertex colors of a skinned mesh renderer.

#

Is there a way to assign vertex colors to a skinned mesh renderer in Unity?

still carbon
#

through code yes, or a third party painting tool perhaps

#

you could just make a script that takes 2 models and copies vert colors from one to the other

willow pike
#

I’ve been looking everywhere for a tool that can do it but can’t seem to find one

#

There’s gotta be something simple that allows you to change vertex color data from the inspector. Everything I’ve found is limited to regular mesh renderers.

regal stag
still carbon
#

@willow pike you just want to set all the verts to the same color? if so that would be dead simple yeah

willow pike
#

I'm modeling and coloring the character using Probuilder but when I export the model and rig it using Mixamo it looks like it's stripping out the vertex color data.

#

I just can't figure out a good solution for putting those colors back onto the model after Mixamo spits it out

regal stag
#

Might not be easy if Mixamo alters the order of the vertices too.

willow pike
#

Yeah this is tricky. We're using Probuilder to do all of our modeling and coloring. Mixamo has been a great way for us to get rigs and basic animations, then we override them with the new Animation Rigging package.

#

But Probuilder doesn't allow you to modify vertex colors on a non Probuilder object. Fumbling in Blender to try and repaint them but seems way more complex here.

still carbon
#

I can make a script for you that'll do it when I get home tonight, it's not too complicated

willow pike
#

That would be incredible! To do what exactly? Modify vertex colors of a skinned mesh?

still carbon
#

copy from the source mesh in the project to the rigged one automatically

willow pike
#

That would be great, as long as Mixamo hasn't changed the order of the vertices as Cyan was saying

#

I'm not sure if it does

still carbon
#

order won't matter, just gotta do nearest vert and check neighbors to handle seams

regal stag
#

Yeah, hopefully it doesn't but not sure.

#

Nearest vert might also not work if the output is using a different pose

still carbon
#

unless the model is also being morphed in mixamo when you rig

#

yeah

willow pike
#

That would be amazing, this has been a bit of a stumbling block

still carbon
#

is the rigged model in the same pose?

willow pike
#

Building characters from ProBuilder that is

#

Yeah we're building our characters in t-pose in Probuilder, exporting as OBJ and rigging them as is in Mixamo, then just downloading as FBX from Mixamo

#

but we add them back to the project the vertex colors are gone

regal stag
#

Seems fine to me, I find it stranger that Mixamo doesn't support vertex colours.

uneven kettle
#

hey

willow pike
#

Maybe I'm doing something wrong

uneven kettle
#

can one of you guys help me rq

#

ok so

#

basicly

#

look in 2d im very confused

regal stag
willow pike
regal stag
#

Guess it must be Mixamo then

willow pike
#

I can't tell if it's Mixamo explicitly doing it or the transition from a standard mesh into a skinned one

#

though that shouldn't alter the vertex data right?

regal stag
#

I don't think so

willow pike
#

We thought switching to vertex colors from UV mapping would simplify our workflow since we're only using flat color and cel shading. But seems to have complicated things too 😅

#

At least with the characters

waxen wind
#

Just a shot in the dark here, anyone blended megascan textures in Unity before?

vast geode
#

what's a megascan?

still carbon
#

quixel

vast geode
#

oh just prefabs? (i'm not understanding what's unique about megascan textures vs any other)

still carbon
#

if I recall it's a texture atlas approach with blend maps that determine how to mix from the various megatextures

vast geode
#

i only know shader graph. something like that seems simple to handle with a uv offset node

#

do they give you rect info for the atlas?

still carbon
#

they have a whole plugin setup for theier megascans in unity

vast geode
#

ah, nice!

dim hemlock
#

Hey guys, is this a good place to ask about shader graph? (I can't find any dedicated channel for it)

waxen wind
#

Sorry I looked away from discord for a sec ... I don't know exactly what goes into their textures

dim hemlock
#

Ok, then. I created an ENUM inside the shader graph with those parameters :

#

but when i look at the material on my scene, all those options are not there :

#

I did save the shader

#

All i see is this standar ABC option :/

#

restarting Unity fixed it. I hope I don't have to do it every time i change something with it >. <

vast geode
dim hemlock
#

I guess it's some weird bug

#

I'm on 2020.2.0b12

vast geode
#

(sorry, edited to the correct version above)

dim hemlock
#

maybe i should update Unity. Tho I had the same problem before on older version. I ended up using "Branch" instead of enum because of it

#

Thanks for checking it out @vast geode

still carbon
#

yeah always nice to be up to date on the patch versions at least

vast geode
#

np. 2020.2.2f1 has been good here for me fwiw

glossy matrix
#

so, i have a shader i got off github thats designed for the standard pipeline,
it stopped working with urp -- is my only option to rewrite it/ remake with shader graph?

vast geode
#

i think if they're lit, yeah

glossy matrix
#

it was originally for outlining objects -- by the looks of it, exactly like the one unity uses to outline objects

waxen wind
#

Oh I think what I was talking earlier is called Vertex Blending or something

warm shale
#

Hey, I'm trying to build a shadergraph in HDRP for the UI (to do Chromakeying since HDRP doesn't seem to support transparent render textures), but when I do, the image on the canvas just ends up a pure red square, any idea what that could be?

buoyant eagle
#

Hello, Quick Question, I´m creating a shader for color palettes, it just replace red, green and blue for custom colors I want, so all my sprites have only pure red, pure green, and pure blue colors, I´m trying to create a color palette switcher like in the arcade games, so, for performance, what would be better? to have all the sprites with 1 material, and then by script change the colors of this material, or to have multiple materials and then, whenever my player changes the color palette, change the materias for all my game sprites?

full ravine
#

Does somebody have a model where it is a sphere with a hollow inside?

#

Because I need a sphere with a face on both sides of it

weak hemlock
#

does anyobody here has a GOOD tutorial for a water shader or water reflection cause all tutorial i watched were badd(unity 2D)

patent pivot
#

Add a reflection probe, set smoothness of the material to >0.9 for real time reflections

#

@weak hemlock

weak hemlock
placid kettle
#

If I'm using unity tiles, is there a way I can get the position of the tile inside the shader

waxen wind
#

Vertex painting is sooo cool

grand jolt
#

Hey I am looking for help solving a fairly common problem regarding outline shaders

#

There's extremely large gaps between the creases of the outline

#

Now I already know why this happens, it's because of the normals of the mesh

#

and it can be solved by smoothing normals, softening edges, etc. etc.

#

but this will still be problematic for me because I definitely want to go for that hard-edge look for my assets

#

Is there a performance-friendly / smart solution to stop this from happening?

#

I've heard some guides saying to store a copy of the mesh that's smoothed for the outline but that seems like it wouldn't be the most optimal approach

low lichen
#

@grand jolt You can have the same mesh, you just need to store an extra normal direction in each vertex. The original hard normal and a smooth normal.

#

I'd argue that is the optimal approach

grand jolt
#

Is that done in the 3D application or is that done in the shader?

low lichen
#

In script would be the easiest

grand jolt
#

I'm thinking I want to go with a hard-edged aesthetic, wouldn't that mean every object that wants an outline would need this script?

#

and if so, is that okay?

low lichen
#

This would be a one time calculation for each mesh, and it could even be done in edit mode and saved and loaded in builds.

grand jolt
#

Oh shit

#

okay

low lichen
#

But it's a little outdated and does things less optimally

grand jolt
#

I'm also using Amplify to create my shaders, not sure if that matters

low lichen
#

It copies the original mesh, modifies it and replaces it at runtime.

grand jolt
#

ohhh

low lichen
#

Then you just need to create a Mesh containing just the smooth normals, maybe stored in the second or third UV channel

#

Then you will be able to access it as UV1/UV2 in the shader

grand jolt
#

Okay I'm a little confused, because you are probably speaking from a GLSL perspective right?

low lichen
#

No. I call it UV1 because that's what it's most commonly called in node based shader tools, like Amplify and Shader Graph.

#

TEXCOORD1 and TEXCOORD2 if you prefer HLSL

grand jolt
#

Couldnt I also just go in my 3D application, smooth the normals of the mesh, and use the data from that?

low lichen
#

I don't know how easy it is to store that data in a different vertex attribute than the normal

#

While also saving the actual hard normals you want

#

I doubt any 3D application has export options for that, probably requires scripting, like Python in Blender.

grand jolt
#

I understand what you are saying but I am extremely confused as to how I'd do this in Amplify >,< here one second.

#

My outline shader is extremely simple right now

#

I hook this up to vertex offset

low lichen
#

What does the purple Outline node do?

grand jolt
#

Its a built-in amplify node that does exactly what it says, creates an outline vertex offset

#

here

#

These are some of the properties

low lichen
#

You will have to recreate what it does because it's going to be reading the vertex normal to do its calculation

grand jolt
#

but what I am confused about is that there's no actual input for vertex data

#

Ah

glossy matrix
grand jolt
#

I'm using LWRP right now 😛

still carbon
#

You can make an AssetImporter script that will automatically calculate smooth normals and store them in a UV channel to be used in shader. There was a script floating around that did this but I can't find it right now

grand jolt
#

You'd store the smooth normals as a texture? O.o

still carbon
#

UV channel isn't a texture

low lichen
grand jolt
#

I know but

low lichen
#

UV is just a Vector4 that is stored with each vertex

still carbon
#

UV channels are just float4 vertex buffers

low lichen
#

You can have 8 of them, but Unity only supports 4

#

The data can be anything you want

vast geode
#

(URP) Using a metallic surface, how can I have uniform metallic highlight direction regardless of object position on screen?

grand jolt
#

Sorry my mind just defaulted to UV unwrapping

glossy matrix
low lichen
#

If you really wanted to, you could also store it in the vertex color attribute

low lichen
glossy matrix
#

hmm, that seems quiet more performant tho -- drawing the mesh twice,

#

or am i wrong in asuming that?

grand jolt
#

I'm not sure how else you'd do the outline

low lichen
#

Do you mean heavier?

grand jolt
#

Yea that's what he means

glossy matrix
#

yes -- srry .-.

low lichen
#

Post processing is very heavy on mobile, so it's certainly going to be more performant to draw some meshes twice there

#

If you're already doing post processing, the post processing method might end up being more performant

regal stag
#

With the post processing method it's still the same, you're rendering the mesh again in an offscreen render texture

glossy matrix
#

my current implamentation was as simple as adding an object renderer to an list using this:

#

where in update it will check with a temp list to see if its different, call a function to update the list

grand jolt
#

So I am going to have to recreate the Outline shader logic manually in Amplify no matter what right?

#

If I want to do this

low lichen
#

Yes, but it's super simple.
Vertex Position += Smooth Normal * Outline Width

still carbon
regal stag
#

Well yeah, not the same, just saying both methods are rendering objects multiple times. The post-process will definitely be more expensive with thicker outlines, and even blurring.

low lichen
#

I'm seeing 5 nodes there, 3 for getting those 3 values, an Add node and a Multiply node.

#

Is your Amplify shader a separate shader specifically for the outline that you add as a second material?

grand jolt
#

I feel a little lost, I know how to do all the vertex offset logic, but I don't understand how to get the smoothed normal data into amplify

#

nope

#

I'm putting everything under a mega shader

low lichen
#

Are you defining multiple passes?

grand jolt
#

I don't even know how to do that in Amplify

#

I spent last week trying to figure it out and couldnt

regal stag
#

Getting it in amplify would probably be a Texture Coordinates node, changing the UV set on it. Or pass it through vertex colours.

grand jolt
#

yeah that's a thing

regal stag
#

But yeah, I think the Outline node thing is creating a separate pass. Multi-pass shaders don't exactly play nice with LWRP/URP though, It'll break the SRP Batcher.

low lichen
#

Okay, so just the presence of the built-in Outline node is creating a new pass

grand jolt
#

Ohhhh

regal stag
#

It would be better to do it in a separate shader, and use the RenderObjects feature on the Forward Renderer to re-render the objects you need outlined with the outline material.

low lichen
#

I thought multi pass shaders just didn't work in URP period. I thought it only ever drew the first valid pass it found?

grand jolt
#

I don't know, I am still a scrub with shaders so this is very foreign to me

#

Is a pass just it's own self-contained thing?

regal stag
low lichen
grand jolt
#

Okay that makes sense to me

low lichen
#

But yeah, I think using RenderObjects and a custom shader for just the outline is the best route.

#

That way you can apply it to any object with any shader, so long as they also have smooth normals

#

You can still make that outline shader in Amplify. Just as an Unlit shader.

grand jolt
#

And is it easy enough to toggle on and off the outline for individual entities?

regal stag
#

It's as easy as switching the Layer the gameobject is on

low lichen
#

There's even a separate layer value you can change on the renderer so you don't need to change the game object layer

grand jolt
#

Wait that's not how you do it is it?

#

I'm using layers right now for masking stuff

#

I've never used render objects before so it's also completely new to me >,<

regal stag
#

Well, there's also RenderingLayerMasks on the renderer as Mentally mentioned.

#

But... the feature doesn't actually support them by default

low lichen
#

Really? I swear I've used it with RenderObjects before

#

I guess it might have been a custom renderer feature

regal stag
#

Yeah, it doesn't have an option to filter based on renderingmask. No idea why it wasn't included

low lichen
#

Cool thing about the rendering layer mask is that it's a mask, so you can have multiple layers selected on one renderer.

#

And assign different effects on each layer

regal stag
#

It's a fairly simple edit though to support it

grand jolt
#

Download the project template here: https://bit.ly/outline-effect

Unity's tutorial: https://www.youtube.com/watch?v=joG_tmXUX4M
Brackeys tutorial: https://www.youtube.com/watch?v=szsWx9IQVDI

····················································································

Checkout my Low Poly Floating Islands package:
https://bit.ly/lwrp-f...

▶ Play video
#

Is this kind of what you are talking about?

regal stag
#

They're using a sobel post processing one rather than RenderObjects

grand jolt
#

Ahh.. hmm

low lichen
#

If you want to try to implement this, I'll be here if you need help. And I'm sure Cyan will be able to answer any question I don't know the answer to.

grand jolt
#

Sorry I am just a bit overwhelmed lol, I've had like 100 new things thrown at me

regal stag
grand jolt
#

I first need to even understand what Render Objects are and where to even find them

#

I'll need a bit

#

LWRP and SRP are the same thing right?

regal stag
#

SRP is Scriptable Render Pipeline, which consists of both HDRP, URP and Custom written ones.

#

LWRP is the same thing as URP, it was renamed

grand jolt
#

Is there any easy way to tell what type my project is?

#

Because I am not even sure now

low lichen
#

SRP is just an overarching term for all scriptable render pipelines. You can't be using just SRP.

regal stag
#

You can check which render pipeline is set under the Project Settings -> Graphics

grand jolt
#

just says none ._.

regal stag
#

Then you're using Unity's Built In Render Pipeline

grand jolt
#

Ah, does that support Render Objects?

low lichen
#

Which doesn't have Renderer Features or Render Objects

grand jolt
#

welp

low lichen
#

The only option in built-in is either multi pass shaders or multiple materials on each renderer

grand jolt
#

I've heard lots of things having issues with URP/HDRP so when I created this project I avoided it

low lichen
#

I have a highlighting system in the built-in render pipeline which adds the highlight material as a second material on renderers that need to be highlighted

#

Having multiple materials on renderers with one mesh will draw the renderer twice with each material, same as a multi pass shader.

grand jolt
#

So what you are saying is that, with an outline shader, you will basically always have to render the mesh twice

#

is that correct?

low lichen
#

Yes, at least the approach you want to do

grand jolt
#

What would the other approach be?

#

That works for built-in

#

something camera related?

low lichen
#

Most approaches require drawing the mesh multiple times in some fashion

#

It's theoretically possible to implement a post processing outline shader that maybe uses the alpha channel to identify what pixels to draw an outline around

#

Or use edge detection

#

That doesn't require drawing the mesh multiple times

grand jolt
#

Some games have fuzzy/soft outlines

low lichen
#

But this is both more difficult to implement and worse performance than just putting two materials on renderers

grand jolt
#

I thought that's what they did

low lichen
#

What kind of outline do you want?

grand jolt
#

I think solid

#

I think it would look the best

#

Soft is nice, but I dont think it'd fit

low lichen
#

Do you want an outline only around the outside of the mesh or also on the inside where edges are?

grand jolt
#

Only on the outside

low lichen
#

Then it sounds like inverted hull outlines like we've been discussing is the best approach for the type of outline you want

grand jolt
#

haha

#

So I guess I should push it into a 2nd material and remove it from the original shader

#

Oh shit

#

I totally forgot

#

aaaaa

#

I am already using a 2nd material

#

one for XRay

low lichen
#

It stacks, Unity will draw the renderer as many times as there are materials

grand jolt
#

Isn't drawing 3 times kinda bad though? ._.

#

wait

#

I guess aren't I already doing that anyways

low lichen
#

That's what your current outline is doing already

grand jolt
#

yeah

#

my bad

low lichen
#

What platform are you targetting?

grand jolt
#

PC

low lichen
#

I wouldn't worry about it then

grand jolt
#

Ahh ok

#

It's going to be low poly too

#

I won't be doing this on like 20k poly meshes

low lichen
#

Do you think you will only need this outline on renderers that are using your custom Amplify shader?

#

Or would you like to be able to use it alongside any shader?

grand jolt
#

Yes

#

wait

#

hmm

#

My idea was to have a mega shader that I can toggle effects on and off

#

and I would ideally have anything that may use those effects under that shader

#

the environment might be another shader, but it would still be amplify

#

I think all of my shaders will be with Amplify

low lichen
#

Amplify has support for defining multiple passes in one shader, as far as I know

#

Something Shader Graph doesn't support

grand jolt
#

It does but honestly I cannot find anything on how to do it, the documentation seems nonexistant

grand jolt
low lichen
#

Use Pass is not what you want

#

It's a way to reference another pass defined in another shader.

#

Though I guess you could create a separate outline Amplify shader and then Use the pass from there

grand jolt
#

See I did see that doc before

#

But I have no clue how they even set that up

#

There's two output modules

#

And if I create that node this is all I see

low lichen
#

Yeah, I don't know if you need that to define multi pass shaders

grand jolt
#

shrug

#

but I dont need to do this right

#

I can just have my outline shader be its own thing

#

then i add that as a material to the mesh

#

in this case it'd be my 3rd material

low lichen
#

Sure, but it's easier to toggle a pass in a material than it is to add new materials to a renderer

#

Renderer.materials is an array, so you have to create a new array each time to add a new material

#

But on the other hand, a separate material allows you to apply it to any renderer, regardless of what shader their main material is using.

grand jolt
#

The latter sounds very appealing

low lichen
#

There is another option

#

I forgot this is what I did for my highlighting system

#

Command buffers

#

CommandBuffer is a list of graphic commands you can execute with Graphics.ExecuteCommandBuffer, but you can also add command buffers to cameras and tell it to execute the commands at a certain point during rendering

grand jolt
#

hmm

#

I don't wanna go too complicated

low lichen
#

So you can do:

CommandBuffer buffer = new CommandBuffer();
buffer.DrawRenderer(renderer, outlineMaterial);
camera.AddCommandBuffer(CameraEvent.AfterOpaque, buffer);
#

And then it will draw renderer with the outlineMaterial after it has drawn all the opaque renderers.

#

I think the code ends up looking less complicated, simply because of how much of a mess it is to add new materials through code.

grand jolt
#

The way I thought it'd be is just another material on the renderer, and in code I just access that material and toggle a public property on it to turn the outline on/off

low lichen
#

For best perfomance, you would want to remove the material off the renderer when it's not being used

#

Because the extra draw call will be just as costly on the CPU no matter what you do in the shader.

grand jolt
#

Ohh

#

Would removing and re-adding a material not cost a lot?

#

I just assumed it would

low lichen
#

Most things related to rendering is done fresh each frame. So it doesn't really "notice" when suddenly it's not being asked to draw a renderer with a material anymore.

#

The cost is probably mostly in just creating the new array each time

#

Because of how terrible Unity's ancient material scripting API is

#

Which is why I avoid it by using command buffers

#

Command buffers are kinda similar to Render Objects in URP

#

Or Render Features in URP in general

#

In that they allow you to execute graphics commands at certain points during the rendering pipeline

grand jolt
#

Sorry I am just setting the shader up in amplify rq

#

Okay it's all set up

#

So that vertex normal node needs be the actual smoothed vertex normal data

#

and then it would work right?

low lichen
#

Does it looks like an outline with just this?

#

It should, just with the broken edges on hard meshes

grand jolt
#

mhm

#

correct

low lichen
#

Then yeah, you just need to replace the Vertex Normal with the smooth normal

grand jolt
#

I wonder if there's a way to do this in Amplify

#

normals reconstruction

low lichen
#

You can't do this in the shader because you can't access data from other vertices

#

And even if you could, you wouldn't be able to know what vertices are connected to what vertices. They only thing they share is their position. They're not connected in anyway.

#

Quick Outline calculated the smooth normal by grouping together all the vertices that are in the exact same position and averaging their normal values.

grand jolt
#

You mentioned something about only having to do this once, how is that possible? Don't a need a persistent reference to that smoothed normal data?

low lichen
#

You calculate the data once

#

Then you keep it stored in the mesh

#

And the shader gets access to all the data per-vertex

grand jolt
#

I haven't checked the link just yet but, (and sorry if you are repeating) how do you store that data in the mesh? Is that what you were talking about earlier by using another UV channel?

#

Just trying to fully wrap my head around this

#

It'll click soon

#

the smoothed normal data just has to be accessed in amplify, and i substitute my "Vertex Normal" node with that data

#

the block on your script you linked returns a list of smoothed vector3 data, smoothed normals

low lichen
#

Yes, you would then want to put that data into the mesh in one of the attributes, like one of the UV channels or even as the vertex color.

#

You could do that the same way Quick Outline does, by duplicating the original mesh and modifying that mesh to add the additional smoothed normals into one of the vertex attributes

#

Or you can use the additionalVertexStreams property I linked earlier

#

I would recommend that approach, because it doesn't require duplicating the whole original mesh

#

It keeps using the same mesh, you just give the renderer a second mesh and tell it "Merge the data from this mesh into your mesh before you hand it to the GPU"

#

That's what additionalVertexStreams does

grand jolt
#

And I think I asked this earlier, but is there any clever way of doing this in my 3D application to have a cleaner workflow?

#

Like somehow baking this data

low lichen
#

What 3D application are you using?

grand jolt
#

Maya

#

I have substance painter and 3dcoat as well

low lichen
#

Like I said before, I really really doubt there's any setting in Maya or any 3D modelling software to be able to export special data into meshes like this

#

Short of scripting it, like in Blender with Python

grand jolt
#

Hmm ok

low lichen
#

You could possibly export the mesh twice, once with hard normals, and once with smooth normals, maybe somehow telling Maya to put the normals into one of the UV channels

#

And then set additionalVertexStreams to the second smooth normals mesh

#

But this doesn't sound like a cleaner workflow

grand jolt
#

wait that might be possible

#

oh

low lichen
#

Compared to just adding a script to a game object

grand jolt
#

Just for clarification, doesnt that script have to be attached to every object that I want this to happen to?

still carbon
#

just take the code you posted earlier, but apply it in OnPostprocessModel using an AssetPostprocessor script. You can then have the smoothed normals automatically added to the asset itself whenever imported

grand jolt
#

I dont understand how it would only work once

low lichen
#

If you do it in a script, yes you would have to add this script to every object you want to add an outline to. Unless you have one script that finds all renderers and does this modification to them.

#

But then it's more difficult to control which objects get this modification, same with an asset post processor

still carbon
#

Can just filter out by directory name or some other organizational option

grand jolt
still carbon
#

yes

grand jolt
#

what the

still carbon
#

and you can do whatever else you want to the asset, like add scripts even

grand jolt
#

w o a h

#

wait

#

wtf

#

i didnt know you could do that

#

I dont attach this script to any object, it just runs whenever I import right?

still carbon
#

yes, just put it in an Editor folder

grand jolt
#

Ok hold on lemme test some things

#

Any downsides of this?

low lichen
#

But I would definitely find some way to filter which meshes you modify. Doing this calculation for all meshes, especially big meshes, will slow down your import time and increase your build size.

grand jolt
#

yes

#

how would I be able to filter the meshes I want though

still carbon
#

You can introduce breaking references changes in some cases if you rely on adding scripts this way is the main downside, better to rely on the prefab system for added components so that what you add is separate from what you import and doesn't get affected by the import process

low lichen
#

I don't know if you can somehow add a checkbox like the built-in model import settings

#

That would be the best solution

still carbon
#

assetPath gives you the directory the mesh is in, so you can filter that way if you want

#

nah you can't add a checkbox

#

I personally relied on the Label system, but that requires some extra code to grab that info

grand jolt
#

This feels like witch craft

still carbon
#

or for adding colliders i'd just add like __COL to object names in the asset

grand jolt
#

What about a string tag at the end like

#

TestObj_somethingsomething

still carbon
#

yup that works too. Could even include an empty game object called "ADD OUTLINE" and delete it on import

grand jolt
#

and if it reads that somethingsomething it will run the code

#

And just for clarification

#

say I import a model into Unity

#

and it runs this script

#

if I close unity

#

and reopen it

still carbon
#

yes the change is saved to disk

grand jolt
#

that data in the model will still be altered right?

#

oh fuck

low lichen
#

Unity only imports assets if they haven't been imported already. It gets saved into the Library folder in your project. Restarting Unity doesn't affect it.

#

And if you force a reimport (which you can do in the right click menu of the asset), it will run your import script again.

grand jolt
#

Okay so how does AssetPostprocess differentiate between objs, fbx, or even stuff like pngs and audio files?

#

Does it only detect meshes?

#

oh wait

low lichen
#

If you make a PostProcessor, it will run your script after it's converted the raw file type into the Unity equivalent

grand jolt
#

nevermind

#

I see now

#

So is OnPostprocessModel only acting on the mesh itself

#

so if I had an fbx that for some reason included other non mesh components, it wouldnt act upon those

still carbon
#

no, it works on Model imports

low lichen
#

On the model asset, which may include multiple meshes, materials, cameras, all kinds of things

still carbon
#

there's post processors for various major asset types

grand jolt
#

wow

grand jolt
#

Okay damn

low lichen
#

Then there's ScriptedImporter for writing importers for types Unity doesn't already recognize

grand jolt
#

So the documentation is using GameObject as a paremeter

#

I can just change that to Mesh right?

still carbon
low lichen
#

No, models get imported as prefabs. The mesh will be stored as a sub asset and referenced in the MeshFilter component

still carbon
#

Just imagine it as if you dragged the model into the scene and wanted to do stuff to it with scripts

grand jolt
#

Oh shit I see now

#

That's sick af

#

So now from this method I need to grab the mesh component, pass it into the SmoothNormals method from that linked script

#

and then I need to figure out how to store that received data into the mesh

#

sounds about right?

low lichen
#

Yeah

grand jolt
#

alright one seccc

grand jolt
#

What's the proper way to pass in the mesh component of the GameObject parameter?

#

its not getcomponent is it?

low lichen
#

I think that's the only way

#

You'll probably have to use GetComponentsInChildren<MeshFilter> to grab all the meshes in the model.

grand jolt
#

oh

#

hmm

#

Wouldnt that by an array of meshes

#

So if I have multiple meshes, ill have to run SmoothNormals on each one

#

and SmoothNormals returns a vec3 list

#

so ill need a list of lists

#

right?

low lichen
#
foreach (MeshFilter meshFilter in model.GetComponentsInChildren<MeshFilter>())
{
    List<Vector3> smoothNormals = SmoothNormals(meshFilter.sharedMesh);
    sharedMesh.SetUV(2, smoothNormals);
}
#

I use channel 2 here because channel 0 is normally used for main texture and channel 1 is often used for lightmaps.

grand jolt
#

ahh ok

#

you cant set the UVs of sharedMesh

#

or is it meshFilter.sharedMesh.SetUV

low lichen
#

I misstyped, it's SetUVs

grand jolt
#

like this right?

low lichen
#

Right

grand jolt
#

ok

#

im going to import a cube for testing

#

So now that that's done, I need to reference this data in Amplify

#

one sec

low lichen
#

Amplify UVs start at 1, so to reference channel 2, you need UV number 3

#

And then change Coord Size to Float3

grand jolt
#

oh shit

low lichen
#

I'll be honest, I wasn't expecting it to work the first time without some troubleshooting

grand jolt
#

Lemme test with something more intricate

#

holy shit

#

you're a god, I could cry

#

well and @still carbon

low lichen
#

Points to @still carbon for mentioning asset postprocessors. Totally forgot those existed.

grand jolt
#

I should do that tag filtering thing

#

Oh is there a way to force a model to reimport

#

or run that script on it?

low lichen
#

Yes, right click and re import

grand jolt
#

Damn my test skeleton is from the asset store so i think I actually have to redownload that

#

cause reimport doesnt seem to work

low lichen
#

I don't see why that wouldn't work

grand jolt
#

yeah i dunno

#

this is def not right

#

easy way I can test if its running is just doing a debug log in the script

low lichen
#

It might be something to do with skinned mesh renderers

#

I don't know if something special needs to be done to support those

grand jolt
#

Oh shit

#

yeah

#

It is printing in console

low lichen
#

Right, Skinned Mesh Renderers don't use MeshFilters

#

The mesh is referenced directly

grand jolt
#

Wouldnt that mean the outline would be static though and not move with the mesh as it animates?

#

cause the outline is moving

#

its just off

#

Oh lord

#

lmao

#

I tried switching it for skinned mesh renderer and this happened

low lichen
#

This is what Quick Outline does:

// Clear UV3 on skinned mesh renderers
foreach (var skinnedMeshRenderer in GetComponentsInChildren<SkinnedMeshRenderer>())
{
    skinnedMeshRenderer.sharedMesh.uv4 = new Vector2[skinnedMeshRenderer.sharedMesh.vertexCount];
}
grand jolt
#

My guess is its-

low lichen
#

I'm not sure what that accomplishes

#

It does that after looping through the MeshFilters

grand jolt
#

Hmm

#

did nothing

#

I dont even know what that would do

low lichen
#

That if statement is unnecessary

#

GetComponentsInChildren never returns null

grand jolt
#

just use GetComponent rather?

#

if I import something without a skinned mesh renderer i do get errors

low lichen
#

You get a null reference exception without that if statement?

grand jolt
#

mhm

low lichen
#

Change uv4 to uv3

#

We're using UV3, QuickOutline uses UV4

grand jolt
#

Nothing changed

low lichen
#

Are you reimporting each time?

grand jolt
#

yes

#

The entire folder

#

oh

#

wait

#

hold on

#

my print isnt running

low lichen
#

You didn't have a debug log in your last screenshot

grand jolt
#

I wrote it immediately after

#

if i do GetComponentsInChildren it will actually run that block

#

just for now ill keep it there

#

so its printing now

low lichen
#

Still makes no sense to me that GetComponentsInChildren is giving you null

grand jolt
#

I dunno

#

I think I explained that horribly

#

If i write this

#

the entire block doesnt happen

#

it wont print

#

if I do this

#

it will print

#

because it actually executes

low lichen
#

Well yeah, because you're trying to find a SkinnedMeshRenderer component on the root model game object

grand jolt
#

sorry, i suck at explaining stuff ><

low lichen
#

Which obviously doesn't have one

#

GetComponent only searches the given game object

grand jolt
#

yeah

low lichen
#

GetComponentsInChildren searches the given game object and all of its children

grand jolt
#

and if I dont have that if statement at all, i will get errors

#

so because this isnt a MeshFilter

#

that first block isnt running at all

low lichen
#

Try this:

var skinnedMeshRenderers = g.GetComponentsInChildren<SkinnedMeshRenderer>();
if (skinnedMeshRenderers == null)
{
    Debug.Log("Wow, I got null somehow!");
}
grand jolt
#

thats probably the first problem

#

I didnt print when i reimported the skele or the cube

low lichen
#

The null is probably happening somewhere else

#

Maybe one of the skinned mesh renderers has its sharedMesh set to null for some reason

grand jolt
#

o.o

low lichen
#

I'm almost certain that it isn't because GetComponentsInChildren is returning null

#

It doesn't do that. It gives you an empty array if it found nothing

grand jolt
#

oh

#

hmm

#

is it worth worrying about if the null check conditional prevents it from throwing errors?

low lichen
#

If it's erroring, it's probably a clue we're doing something wrong

#

And adding a null check just hides it

grand jolt
#

hmm

#

does MaterialPropertyBlock work on URP materials too?

#

is it the right tool if i want to achieve dynamic recoloring for objects?

low lichen
#

Yes, but it prevents the SRP Batcher from batching your renderer properly

#

SRP Batcher prefers you using material instances

#

It will look fine, it just won't be as performant

grand jolt
#

so i should rather define a new material for each color you say

#

oh I dont know if I mentioned this

#

This makes no outline show up

low lichen
#

You can also just not have the SRP Batcher enabled and just use the built in batching which supports property blocks properly

grand jolt
low lichen
#

@grand jolt That's what I would expect that line to do, so I don't know why Quick Outline does it

grand jolt
#

yeah i dunno

#

wait

#

uh

grand jolt
#

quick outline is an asset store item isnt it?

#

oh yeah i have it downloaded LOL

low lichen
#

@grand jolt In some cases, yes. In other cases, it's more performant. But in general, SRP Batcher is supposed to be better in all cases.

grand jolt
#

👀

low lichen
#

@grand jolt I think in most cases, the difference is minimal

grand jolt
#

i see

low lichen
#

It's only if you have a crazy scene that's using all the same shader with slightly different material settings that SRP Batcher handles better

#

@grand jolt I think all that QuickOutline is doing is just not assigning any smooth normals to skinned mesh renderers

grand jolt
#

Oh?

low lichen
#

It's doing this in its shader:

float3 normal = any(input.smoothNormal) ? input.smoothNormal : input.normal;
#

So it's checking if the mesh has any smoothNormal values and if it doesn't it just uses the regular normals

#

That's why it's just clearing the normal values for skinned mesh renderers

grand jolt
#

Hmm

low lichen
#

The reason is because the mesh skinner processes not only moves vertices to follow bones, it also rotates the normals

#

But it isn't aware of the smooth normals, so those stay unchanged

#

And pointing in the wrong direction

grand jolt
#

So unless I am mistaken

low lichen
#

You could possibly change the smooth normals to be relative to the regular normals

grand jolt
#

what I am doing is correct, but its within the outline shader that's actually checking?

#

his outline shader

low lichen
#

It's not exactly "correct". He's just ignoring skinned mesh renderers and letting them have broken regular normals

#

Which is fine when you have a smooth mesh, which most skinned meshes are

#

And probably why no one has mentioned that it's broken

grand jolt
#

what if they aren't?

low lichen
#

Then you need to find a smarter fix than what he did

grand jolt
#

What if the skinned mesh has hard edges ins-

#

oh ok

#

wait what you are saying entirely explains the deformation of the outline

#

hold on

low lichen
#

I would expect the outline to be correct if all the bones are in the default position

#

Because that's when the smooth normals are correctly rotated

#

But as soon as bones start rotating and moving, the regular normals get updated to reflect their new rotation, but the smooth normals get ignored and stay the same

grand jolt
#

the outline shader pulses

#

but this is kind of what you are talking about right

#

its a gif

#

it might need a bit to load

low lichen
grand jolt
#

Also I never thought that fixing an outline shader would be this difficult lol :p

#

well

#

to describe it, the outline looks like its squeezing into itself

low lichen
#

That skeleton doesn't look like it has hard edges though

#

Are you going to replace it?

grand jolt
#

Yes

#

this is a free asset from the asset store

#

just for testing

low lichen
#

There, it loaded now

grand jolt
#

and thank god too

low lichen
#

You might be able to store the smooth normals as the tangent

#

The mesh skinning processes should rotate the tangent along with the normal by the same amount

grand jolt
#

I'm not sure if I know what you are referring to when you say tangent

low lichen
#

Usually, the tangent is supposed to be 90° from the normal and sometimes used in shaders to calculate specular effects with normals

glossy matrix
#

ah -- no success,
how long would it take for someone with near 0 shader exp to be able to convert some cg shader to hlsl?

low lichen
#

@glossy matrix CG and HLSL are nearly completely identical

#

They are the same language, it's just CG came first and HLSL derived from it and took over

glossy matrix
#

ye -- came across the history -- nvidia released cg first with microsoft following with hlsl

#

syntax are similar, but more often than not i saw people calling them complete different languages. .

still carbon
#

in a normal compilation setting they are, but unity just treats CG as HLSL now and handles any edge cases

low lichen
#

@grand jolt It's worth a try, at least just see if it breaks with the regular meshes. Try replacing SetUVs with SetTangents. It's expecting List<Vector4>, so just modify the SmoothNormals method to return that instead.

glossy matrix
low lichen
#

@grand jolt Then use the Vertex Tangent node in Amplify instead of Texture Coordinates

grand jolt
#

sure let's try it

#

wait

#

before I do this

#

this will break non skinned mesh objects right?

still carbon
#

if has skinnedmeshrenderer else has mesh filter

low lichen
#

@grand jolt The hope is that it doesn't break anything

grand jolt
#

I could use a toggle in the shader

#

to swap

low lichen
#

That's what the test is for

grand jolt
#

ok lets test

#

one sec

#

so

#

it definitely changed

#

but still scuffed

#

at certain angles it looks decent

low lichen
#

How does it look on normal meshes?

#

Try normalizing the tangent before multiplying it

grand jolt
#

in amplify?

low lichen
#

Yes

grand jolt
#

no change

#

this is what I did

#

Since I no longer have that tex coords node hooked up its just fucked on the other models

#

but that makes sense

low lichen
#

This should work on normal models too

#

I would expect them to look just as they did

#

We're just storing the smooth normal in a different place

grand jolt
#

I didnt reimport the old models

low lichen
#

Try it

grand jolt
#

I also didnt replace the code for SmoothNormals

#

i just made a SmoothTangents

#

I can try it with them if you want

low lichen
#

Well, even though this might work (though it doesn't look like it works perfectly since its still a little scuffed), storing the smooth normal in the tangent is not optimal

#

Because unlike the third UV channel, the tangent is often in use

#

It's necessary for normal mapping

#

So this would break that

grand jolt
#

oof

low lichen
#

Hmm, that's unexpected

grand jolt
#

oh wait

#

no

#

thats my fault

#

i didnt update the shader

#

yeah it works

#

i forgot to switch back to the vertex tangent node

#

normal maps will almost certainly be used in the future

low lichen
#

Trying to think of other ways to rotate the smooth normals along with the regular normals

#

If we could hook into Unity's mesh skinning, it would be pretty simple to just do the same operation to the smooth normals

#

But I don't think that's an option

grand jolt
#

mhm

low lichen
#

Unless...

grand jolt
#

I can think of a dumb ghetto fix for this but its not optimal

#

and especially not friendly in terms of workflow

low lichen
#

There are some built in shaders you can override in the Graphics settings, but skinning isn't one of them

grand jolt
#

hmm

low lichen
#

You can see in that shader that it's modifying the position, normal and tangent

#

That's why it kinda worked to put it in tangent, since it was then getting modified

#

Not exactly sure why it was still a bit weird though

grand jolt
#

I know it's possible

#

Gunfire Reborn has that hard-edged aesthetic and an outline shader as well

#

and if I remember correctly, it doesnt have this problem

low lichen
#

With skinned meshes?

grand jolt
#

mhm

#

well anything rigged and animated will have be skinned mesh right

low lichen
#

Is that a Unity game?

grand jolt
#

mhm

low lichen
#

I don't know, kinda looks like post processing outlines to me

#

Hmm, no actually there are some thicker outlines later in the trailer

grand jolt
#

wait lemme watch a vid

#

when he hovers over enemies

low lichen
#

Are they flat shaded?

#

Hmm, yeah I guess

grand jolt
#

yeap

#

Part of me wonders if the solution is actually really easy and we're just overcomplicating it

#

I'm pretty sure Gunfire reborn started as a student project

glossy matrix
#

i saw a video just earlier on it, here ill link it (using shader graph)

#

wait no ;-; nvm -- thats old

#

fk -- maybe it was another one

low lichen
grand jolt
#

Ahh

#

I would honestly be completely lost if it weren't for this discord

low lichen
#

You could export the skinned mesh renderer twice, once with flat normals and once with smooth normals

grand jolt
#

that's the ghetto solution i was thinking of

low lichen
#

I think I have one more idea though

#

Slightly more complicated to implement, especially in Amplify

#

Might require a custom expression/code function

grand jolt
#

That's doable

low lichen
#

The idea is to calculate the rotational difference between the flat normal and the smooth normal for each vertex

#

As a Quaternion

grand jolt
#

This wouldn't be done per frame would it?!

low lichen
#

Then in the shader take the flat vertex normal and apply the quaternion in the opposite direction to get back the smooth normal

grand jolt
#

oh ok phew

#

This would work for anything, skinned mesh or not?

low lichen
#

Yes

#

To calculate the Quaternion in script, you could do:

var rotationDifference = Quaternion.FromToRotation(normal, smoothNormal);
#

Or the other way around

#

We want the rotation from the regular normal to the smooth normal, so we can apply it in that direction later.

onyx delta
#

can somone help me with shader graph?

#

the shader graph ui is ery small for some reason

low lichen
#

@grand jolt Let's move to DM maybe?

grand jolt
#

Yes

glossy matrix
#

https://www.youtube.com/watch?v=1QPA3s0S3Oo
found it -- it wasnt shader graph tho ;-;

✔️ Works in 2020.1 ➕ 2020.2 🩹 Fixes:
► If importing a model, be sure to enable read/write access in the asset inspector, so the normal calculator script can read it's data correctly.

Outlines are a fun technique to add style to your game and pair perfectly with toon shaders. There are a variety of ways to implement them, and in this video, I lo...

▶ Play video
onyx delta
#

enyone?

still carbon
grand jolt
#

The issue has be solved

#

holy shit that was insane

glossy matrix
#

thats looking pretty good!

grand jolt
#

thanks

#

But yeah, this will fix outlines on anything that's hard-edged regardless of it being skinned or non-skinned

#

metally guided me through it

glossy matrix
#

aah -- guess im stuck on this. . kinda getting late, should head out
just gonna throw this out there - kinda far fetched but if anyone could help convert this to hlsl that would be much appreciated

shader: https://hatebin.com/hesjmdosjq

outline manager (uses ray cast, stick it on camera should work): https://hatebin.com/slumwuaomz

outliner cam effect (stick this script also on camera, applies the effect): https://hatebin.com/pwzmqzidii

(Original github link: https://github.com/michaelcurtiss/UnityOutlineFX -- outline manager is re-written for mouse selection - outliner has minor tweak to update objects at runtime)

  • current issue: doesnt work with urp. . . (works fine in srp)
    Thanks if anyone does bother, guess ima head out -- GL
astral pecan
#

How do I combine big and small voronoi together?

#

To get the 3rd pic

cosmic prairie
#

do epic maths

#

(probably just multiply them together)

#

but depends what u r looking for

#

u may add them

#

divide them, replus them, make one power of the other

#

use your creativity

#

experiment

astral pecan
#

I tried all of the suggested, and it does not produce the same result

#

Which is why I am asking around

#

Does not preserve the bigger bubbles

#

Getting closer, but not yet

viral knoll
#

The first pictures you showed are two voronoi with similar size. One of them is just inverted. I guess that you should’t have different sizes if you want to create the third texture

astral pecan
#

And there is no "Octave" parameter in shader graph's voronoi

#

Its from Unreal Engine guide

#

Not sure how to recreate that

viral knoll
#

You have to create the octaves yourself. They are created by combining several textures of several sizes

astral pecan
#

Sadly so far I am not getting close yet

#

Not sure what goes on behind that octave thing

onyx delta
#

hey can shaders made in unity 2020 be used in older versions of unity like 2018,20?

viral knoll
#

@astral pecan I am trying to recreate it now

astral pecan
#

Alright, thanks a lot @viral knoll

#

Sorry for the trouble

#

1st pic is Voronoi with Power 2
2nd pic is inversion
3rd pic is Octave 3

#

Anyways playing around got me to accidentally make clouds out of a bunch of tumors

#

🤣

viral knoll
astral pecan
#

If that's inverted, it might work..?

viral knoll
#

Yes it might

#

I can send you a picture of the graph soon but I am busy right now

astral pecan
#

Sure thing, send me when you're not busy, thanks a lot for the help!

amber saffron
#

How octaves are usually done :

  • Noise value is in -1;1 range
  • for each octave, you multiply the UV (or position input) of the previous one by a constant.
  • and multiply the influence by an other constant.
  • sum the octave*influence to the result
#

I think that the voronoi of SG is in the 0;1 range, so in your case :

  • remap both noises from 0;1 to -1;1
  • multiply the smaller one by a constant (let say 0.5) to diminish the influence
  • add it to the big one
  • remap the result form -1.5;1.5 (sum of the max and mins) to 0;1
timber bronze
#

Hi I try to do wave shader on my sprite (2D) and other parts of the uv is showen. dose anyone know how to ignore this part?

low lichen
#

You could clamp it, but then you'd need to know what the min and max UV values for this sprite are

#

Which could be anything when it's part of an atlas

#

I don't know if Unity passes that information to the shader

timber bronze
#

I will try to find a way thanks!

low lichen
#

After some short googling, it looks like you have to pass that information to the shader manually through a material property

timber bronze
#

I thoght so.. Thank you!

arctic vortex
#

Hi, i've got this setup:
The presentor is on a layer: 'Videoplane'
The ground and the carpet are on a layer 'Behind videoplane'

What I want to achieve is that The videoplane always renders over the behind videoplane layer and all other depth should be preserved.

can anyone tell me how I should set up the custom passes in such a way

#

I guess it's all in the depth override settings, but I don't really get what happens when I turn on 'write depth' and what 'Equals/Less Equals/Greater/etc.' values do exactly

#

so an explanation of those values probably gets me going as well 🙂

astral pecan
tranquil fern
#

I'm trying to have a smooth gradient on a sphere. Sort of like fresnel, but smoother I suppose. I want to use it for opacity, so the outside has an opacity of 0 and the inside of 0.85, and smooth that out between them.

#

It's probably a dumb question. I tried doing fresnel with one-minus, but it's not smooth enough. I want to make floating glowing orbs coming out of a surface.

thick fulcrum
arctic vortex
#

how would that work with any objects in front of the plane?

thick fulcrum
#

they would appear infront

arctic vortex
#

and the feet in the image (that are now cut of because of the ground and carpet would also be in front of those?

thick fulcrum
#

depending on your shader you maybe able to test it by just swappig the render queue to lower than 3000, are you using a built in shader or custom?

arctic vortex
#

I have a normal HDRP/Lit shader on it now

thick fulcrum
#

it's not going to solve the feet problem, you would have to move the plane upwards as a simpler solution. But it would allow for objects behind and in-front to render correctly based on depth.

#

as it's not a 3D object you are going to have awkward angles where it will look wrong, unless you restrict where / how it's viewed there will be no getting around that aspect. depending on your project aims, if it's for client control / a composite video render etc.

simple pagoda
#

How do i convert HSV to RGB in compute shaders?

low lichen
arctic vortex
# thick fulcrum it's not going to solve the feet problem, you would have to move the plane upwar...

all other clipping isn't really a problem, its really the feet problem that I'm trying to solve, the guy you see on the plane will be replaced with a live greenscreen feed that is chroma keyed. if that person however would move towards the camera, you get the feet problem, thats why I was trying to solve this with custom passes, from all that I've read it is the way to go but I don't know enough about rendering passes to correctly use them

#

thanks for the help so far 🙂

grand jolt
wheat spire
#

How would one make a digital screen that looks like this with the squares?

wheat spire
#

Which effect? @shadow locust

shadow locust
#

Or just overlay a texture over top?

wheat spire
#

That might be an easier way.

digital gust
#

Anyone knows if I can have one shader with different values on different materials?

shadow locust
digital gust
#

Okay, I guess than I am instancing the materials wrong, let me put it that way. Can I generate materials on the fly with a copy of a source material and alter them?

shadow locust
#

yes

regal stag
#

If you use GetComponent<Renderer>().material to edit property values, it'll automatically create a material instance and assign it

digital gust
#

So this is what I have ```
foreach (Transform tr in nodes)
{
LineRenderer lineRenderer = tr.gameObject.GetComponent<LineRenderer>();

            if (!lineRenderer)
            {
                Material newLineMat = new Material(lineMaterial);
                lineRenderer = tr.gameObject.AddComponent<LineRenderer>();
                lineRenderer.sharedMaterial = newLineMat;
                lineRenderer.sharedMaterial.SetFloat("_Offset", Random.Range(0,5));
                lineRenderer.startWidth = startWidth;
                lineRenderer.endWidth = endWidth;
            }
            else
            {
                linePositions[0] = nodes.IndexOf(tr) > 0 ? nodes[nodes.IndexOf(tr) - 1].transform.position : nodes.Last().transform.position;
                linePositions[1] = (tr.transform.position + linePositions[0]) / 2 + new Vector3(0, 1.5f + nodes.IndexOf(tr) * 0.3f, 0);
                linePositions[2] = tr.transform.position;

                lineRenderer.material.SetFloat("_Length", Vector3.Distance(linePositions[0], linePositions[2]) * 175);

                DrawQuadraticBezierCurve(lineRenderer, linePositions[0], linePositions[1], linePositions[2]);
            }
        }
But somehow,  the random.range is always the same number, like if it is instancing it only once and sharing it between them
shadow locust
#

to copy the material you do Material copy = Instantiate(originalMaterial);

digital gust
#

I am assign the material on the fly

#

Instantiate? ohhh

shadow locust
#

ah actually no you're right

#

that constructor should work

#

lemme look at your code

#

what part isn't working exactly?

digital gust
#

Hm, I am not sure if it was just a bad random thing, but now with instantiate, it seems to work or I just had bad luck with the numbers always being the same, let me increase the range 😄

#

Hm, yep, I guess it was either instantiate or just bad luck with numbers. I had like 10 times all of them being 2... Thanks and sorry for taking your time 😄

shadow locust
#

interesting ok

digital gust
#

I guess range from 0 to 5 as int isnt that much

fresh vigil
#

I'm trying to implement fog of war in URP. I'm currently using a camera that renders the line of sight to a render texture, and then use that texture to mask the output of the main camera.

#

After the whole day trying to figure what to do next, I want to read the depth from the camera that renders to the texture, so I can reconsctruct the world pos and use it with the 2nd camera to "work with XZ positions"

#

Problem is, I have no idea how to access to 1st camera depth

#

Any hint very much appreciated

neat gull
#

Is it a Cinemachine camera?

#

It should have a public variable called FOV

#

It controls the length of the fustrum

#

Ah here we go

#

Camera.main.fieldOfView

fresh vigil
#

not sure what cinemachine has to do there

neat gull
#

I dont use the normal camera and only use virtual cinemachine cameras

#

So I cant speak to those

#

There is also Camera.main.depth

#

Depending on what you are trying to do

regal stag
neat gull
#

No wait depth has to do with render order

#

I remember now

fresh vigil
#

Thanks cyan, that looks a reasonable approach (from my humble rendering knowledge) I'll try it tomorrow 🙂

neat gull
#

Im sure ive done this use case before 🤔

fresh vigil
#

And yep, the 2nd camera overrides it

regal stag
#

Do you need the depth texture for the second camera too? If not, disabling it might also stop it overriding it

#

(Should be an option to turn it off on the camera that is)

fresh vigil
#

Not for any custom effect, but it is the camera that is doing all the postprocessing stuff, so I guess I'm using it, although maybe I could do all the PP stuff on an overlay camera too, i think

neat gull
#

What I did was make a cube as a child of the camera, set its size based on Camera.CalculateFrustumCorners, and on trigger enter, enabled the mesh renderer

regal stag
#

Ah right, yeah post processing might force it on

neat gull
#

I controlled how much was disabled by taking a ratio of the frustrum size off

regal stag
#

@fresh vigil I've got a BlitRenderFeature that can allow you to blit from one ID to another if you want to try it. https://github.com/Cyanilux/URP_BlitRenderFeature
Unity also has one in the UniversalRenderingExamples (linked on that page too) which they updated to work with a source & destination. Theirs might only work in v10+ though, not sure.

The two cameras should use different Forward Renderers (can assign multiple on the URP asset and set which is used per camera). Can put the blit on the first camera one, maybe in the "Before Transparents" event (or later would probably work too). source being _CameraDepthTexture, and destination being any custom ID you want.

#

I haven't really tested what happens with multiple cameras but hopefully it'll allow you to copy the depth over and use it while rendering the second camera. Frame Debugger window should be helpful in debugging if it doesn't work.

fresh vigil
#

I already downloaded the URP examples, which I needed for the render pass, I'll look at it tomorrow, need some rest now. Thanks for the resources and hints, its gold for me 🙂

teal leaf
#

but there's no top face, and I can't figure out how to fix that

#

anyone know how I could fix this?

regal stag
onyx delta
#

hi if i make a shader using shader graph and then try adn import it to a version of unity without shader graph will my shader brake? its for a vr chat avatar

shadow locust
#

Yes your shader will break

still carbon
#

look up ShaderForge on github and download a recently updated branch, or buy Amplify shader editor

#

they work with the old pipeline

onyx delta
#

ok thx il theck it out

tardy willow
astral pecan
#

It is still pretty far from what octave does

astral pecan
#

Distort scene color with normals

tardy willow
astral pecan
#

Its the same as creating water ripple effects

#

Displace UV with noise, etc

#

A lot of ways to do it

tardy willow
astral pecan
#

Yeah you probably can

tardy willow
sage owl
# astral pecan

It's funny that you mention generating tumors with voronoi diagrams, because that's surprisingly accurate:

"Voronoi tessellations have been used to model the geometric arrangement of cells in morphogenetic or cancerous tissues, however, so far only with flat hyper-surfaces as cell-cell contact borders. In order to reproduce the experimentally observed piecewise spherical boundary shapes, we develop a consistent theoretical framework of multiplicatively weighted distance functions, defining generalized finite Voronoi neighborhoods around cell bodies of varying radius, which serve as heterogeneous generators of the resulting model tissue."
https://link.springer.com/article/10.1007/s11538-009-9498-3
:P

amber saffron
#

And why the distance node ?

#

Higher octave > lower intensity, starting with 1 for the first octave.

amber saffron
astral pecan
signal rapids
#

Hey! In shader graph, I'm trying to use a 2D image as a mask for tweaking the vertex normals, but I'm unable to connect it. I'm unsure of the reason. What am I doing wrong here?

thick fulcrum
signal rapids
#

@thick fulcrum Thanks man; saved my day!

brisk prism
#

Guys, how do i give this shader an alpha mask ? (Additive Alpha Blend Shader)

SubShader {
        Tags {
            "IgnoreProjector"="True"
            "Queue"="Transparent"
            "RenderType"="Transparent"
        }
        Pass {
            Name "FORWARD"
            Tags {
                "Queue"="Transparent"
            }
            ZWrite Off
            Cull Off
            Blend One OneMinusSrcAlpha
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma fragmentoption ARB_precision_hint_fastest
            #pragma target 2.0
            #include "UnityCG.cginc"
            uniform float4 _Color;
            uniform sampler2D _MainTex; 
            uniform float4 _MainTex_ST;
            uniform float _ColorMul;
            struct appdata {
                half4 vertex : POSITION;
                half2 texcoord : TEXCOORD0;
                half4 color : COLOR;
            };
            struct v2f {
                half4 pos : POSITION;
                half2 texcoord : TEXCOORD0;
                half4 color : COLOR;
            };
            v2f vert(appdata v)
            {
                v2f o;
                o.pos = UnityObjectToClipPos(v.vertex);
                v.color *= _Color;
                o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
                float alphaBlendFactor = 1.0f - saturate(max(max(v.color.r, v.color.g), v.color.b) * 2.0f - 1.0f); // 1 = alphablend, 0 = additive blend
                o.color.rgb = v.color.rgb * v.color.a * lerp(_ColorMul, 2.0f, alphaBlendFactor);
                o.color.a = v.color.a * alphaBlendFactor;
                return o;
            }
            fixed4 frag(v2f i) : COLOR
            {
                fixed4 color;
                fixed4 tex = tex2D(_MainTex, i.texcoord);
                color = tex * i.color;
                return color;
            }
            ENDCG
        }
    }
    FallBack "Diffuse"
}
meager pelican
#

clip(o.color - threshold);
in frag shader stage to clip per pixel.

#

You'll have to set the threshold variable or hard code a value there.

neat gull
#

I have a VFX graph for it, one second...

#

Well, I realize now this is a shader channal lol

#

And that is a VFX solution...

#

Hope it helps E:

neat gull
hard lichen
#

Hello, I'm wondering how can I make an outline shader that works by grouping multiples skinned mesh renderers as a whole?

#

Nothing from the assets store works

tardy willow
neat gull
tardy willow
neat gull
#

Yeah im pretty sure its in the unity default assets