#archived-shaders

1 messages Β· Page 152 of 1

grand jolt
#

this tutorial

thick fulcrum
#

when you change values in shader graph which are public they do not update on the material which is applied to your plane in the scene

#

so you need to tweak them in the scene outside of shadergraph, if you get me

grand jolt
#

i get you

#

but i did both

#

@thick fulcrum do u know any good tutorial

thick fulcrum
#

I started with the one you are using, however I'm in URP so if that makes a difference... I would hope not.
It's strange that it is not working

#

@grand jolt instead of outputting it to emission try outputting it to color, in place of your water color temporarily.

grand jolt
#

that look so good

#

i also gt this error i just notice

#

color is also not changing now

#

i mean i change the color to

#

@thick fulcrum i can`t change color now

thick fulcrum
#

@grand jolt my bad sry the output for the foam is just a vector 1, so the albedo probably won't accept that.
I would perhaps follow the tutorial to it's conclusion as he does something different with those nodes soon which may make all the difference.

grand jolt
#

its ok np

thick fulcrum
#

I swapped to using a foam texture myself which meant this was a non-issue, but your water is looking pretty good so far.

grand jolt
#

i didn`t save so i re open the file

#

i know

#

but i want to that what`s the problem

thick fulcrum
#

it could be something to do with HDRP and how emission is handled, but I'm just guessing

grand jolt
#

i deleted , i will make new one now @thick fulcrum

#

which pipeline should i use @thick fulcrum

plush bane
#

Hi. I cant figure out a really simple thing. How to make gradient shader with shader graph. Like if I add it to a box, top would be green and then as it goes down it gets darker and darker

#

Help!!

grand jolt
#

and later if i copy that shader graph and use on different PP , is any problem going to occur

amber saffron
#

use the position.y value to sample a gradient @plush bane

thick fulcrum
#

@grand jolt HDRP is fine to use, but it can be overwhelming for novices and very small studio's. You need someone with time and knowledge to get it all setup right in my opinion.
URP is easier to get to grips with and more straight forward.
You should be able to copy that graph to URP without problems (I hope)

plush bane
#

@amber saffron how can I clamp it to be from 0 - 1

#

?

amber saffron
#

A clamp node ? πŸ˜„

plush bane
#

Clamp not right term

amber saffron
#

Let me guess : you want 0 at the bottom of the object, and 1 at the top ?

plush bane
#

@amber saffron ys

amber saffron
#

Use the remap node with exposed property value : in min = the minimum position that will be 0, in max = max position that will be 1. Out min = 0 and out max = 1

plush bane
#

Why can't I expose Gradient property?

amber saffron
#

There is no property drawer for gradients in shader, for the moment

plush bane
#

ehh

amber saffron
#

You could replace your gradient with a texture if you want it exposed, so it would only be the matter to edit the texture

grim tartan
#

Is there a way to lerp a shadergraph property in the particle system?

regal stag
#

@grim tartan You mean the particle system component, not the VFX graph particles, right? If so, I don't think you can access specific properties directly, but you can send stuff like the particle's lifetime into the shader using the Custom Vertex Streams option in the Renderer tab. (here, AgePercent is sent into UV.z, think it just starts at 0 and goes to 1 over the particle's lifetime).

grim tartan
#

Thanks! Maybe modifying the values of that inside shadergraph would work.

#

like add. cause I'm lerping between 1 and 1.5

regal stag
#

@grim tartan You can also likely use the Custom Data part (and send it into the shader using the custom vertex streams again). e.g.

#

That might not be over the particle lifetime though, not sure how it works as I haven't used it before

grim tartan
#

I'll try your first answer then. I am going to fade it with color over lifetime afterall

#

first one makes some weird effects :v

proper ravine
#

hey guys... anyone know the best way to add outlines to the tilemap sprites with shader?

grim tartan
#

got it working. thanks @regal stag Option 1 is indeed lifetime

tardy spire
#

Nooby question incoming: I'm straying away from the safety of shader graph into the scary lands of text-based shaders to modify tilt brush shaders

One thing I'm struggling with is how to pass custom data from a vertex shader to a surface shader. With a vert/frag shader the vertex shader returns a struct that is passed to the frag shader, but I'm not sure how info gets passed from the vert to surf shader.

In my case, the vert shaders writes to an inout appdata_full struct which seems to be a preset struct with common values needed for a surface shader, but the surface shader has arguments for an Input and SurfaceOutputStandardSpecular struct. What is the correlation between appdata_full in the vertex shader and the two other structs in the surface shader?

I'd like to pass some custom values from the vert to surface shader but can't figure out how.

regal stag
tardy spire
#

Ah this is the documentation I was looking for, thanks!

#

ah ok, so I just need to add an out parameter for an Input struct and Unity will know to pass it over.

marsh sparrow
#

Hey

#

Does anyone know what the constructor for a sampler2D object is?

#

I can't seem to find it written anywhere.

meager pelican
#

@tardy spire Or just copy the "appdata_full" into your source, rename and customize it. The surface shader will use a custom structure, you're not absolutely stuck with what unity gives you. But it has "expectations" if you're doing lighting and stuffis (which, with a surface shader, you are). So be careful what you remove if you want it to work. But I think most of that is in the output structure.

tardy spire
#

gotcha, thanks @meager pelican!

remote mauve
#

For mobile loading non-power-of-two textures at runtime via UnityWebRequest, is there any side effect?

#

I've been reading around and it seems that POT is really only a thing when importing texture due to compression algorithms work better with them, however I'm not sure if that's the whole story.

meager pelican
marsh sparrow
#

I see.

#

I'll look into it

#

Hey, uh

#

I'm not sure this is supposed to do this but

#

I created a new Surface Shader, just a general one. I didn't modify it, I didn't touch it at all.

#

I applied it to a material.

#

And then the material turned pink as if there was an error.

#

Do any of you know how I'd go about fixing that?

regal stag
#

If you are using URP/HDRP, surface shaders aren't supported.

marsh sparrow
#

God damn it

#

Am I really forced into using the Shader Graph?

regal stag
#

You can write shader code but it needs to be the vert/frag kind instead

marsh sparrow
#

How would I go about just making a new shader, and just making it work. No need to actually tell me how to do anything else.

#

All I need is that starting point.

#

I'm getting really annoyed by the shader graph and the lack of float array support in the ports.

regal stag
#

I think there's an "Unlit Shader" option or something which is the other shader code template

marsh sparrow
#

I see. It's unlit, though. Does this mean it will not interact with light?

regal stag
marsh sparrow
#

God I just wanted a float array...

#

It just hurts to manually put them in.

#

One by one

#

Has no one ever had this issue?

regal stag
#

Did the custom function method not work?

marsh sparrow
#

No, because I run into this issue eventually:

#

Let's say I have 4 float inputs.

#

They're used to segment some object into different parts.

#

Alright?

#

What if eventually I'll want to have more than 4 float inputs?

#

What if I'll want to have 16?

#

It's a massive pain to actually stay there and make more input ports with specific names.

#

I say this as I have a custom node with more than 40 input ports right now.

#

Around 50 even.

#

And the same 40-50 parameters on the blackboard.

#

All named properly.

#

You can imagine how much time that took me, right?

#

Why not just have a float array type parameter?

#

Why not just, you know, have an array type, or hell, I'll even take a list if it means I don't have to make 50 input ports and 50 parameters each with their own proper reference names.

#

II remember at one time the float array type was in the shader graph. Where did it go?

#

If I knew how I'd even go and try to implement it myself, but I don't know if Unity even lets you add custom data types to the shader graph.

#

But really, does anyone know how I could use a float array inside of a shader graph?

regal stag
#

I'm not entirely sure what you mean by "segment some object into different parts", but it sounds pretty complicated if you need that many float properties

marsh sparrow
#

I just need to have a float array that I can change the size of while editting, but not during run time. Nothing will change during run time. It's only for editting purposes.

meager pelican
#

I see. It's unlit, though. Does this mean it will not interact with light?
@marsh sparrow

Use SG to generate a lit shader. Modify it manually from there. πŸ˜‰

marsh sparrow
#

SG?

meager pelican
#

Shader Graph

marsh sparrow
#

Yeah... that's the issue.

#

I need a float array.

#

SGs don't have float arrays.

meager pelican
#

Then put one in AFTER you generate the template.
SG is a CODE GENERATOR.

marsh sparrow
#

Oh?

regal stag
#

Yeah, if you right-click the master node there should be a "show generated code"

marsh sparrow
#

Wait this might be

#

What I need

#

Give me a second lads

#

Also

#

If I add it after the code generates, will it destroy it if I recompile it?

#

Let's say I modify the SG.

meager pelican
#

But once you customize it, you can't go backwards.
But you can use it to make any simple SRP template.

marsh sparrow
#

Ah, so the customization actually breaks the SG.

#

Right?

meager pelican
#

Just generate a basic lit thing so you hvae something to customize.
Yeah, 99% sure it will, particularly for "something it doesn't support" that you added. πŸ˜‰

marsh sparrow
#

God damn.

#

Well.

#

At least it will do what I want it to do.

#

I just can't stand adding manually 50 ports.

#

It's such a pain and I really think that the devs should add the float array feature to the SG. It'll really help with development.

regal stag
#

The generated code will just be a separate file to the graph, I think by default it's just a temporary file so you should re-save it somewhere in your actual project assets. You can go back to the graph, but it would be before you added those changes.

marsh sparrow
#

I see. I should just give it the hlsl extension, right?

#

Or does it already have an extension?

regal stag
#

I think it's probably a .shader?

marsh sparrow
#

Fair enough

#

It's still compiling.

#

If this works, man, this will be awesome.

meager pelican
#

I think/read that custom-data of some sort is on the radar screen.

But at least you can generate a template of the type you want, and go from there and don't have to start with a blank page and a largely not-documented-yet API.

marsh sparrow
#

Wait...

#

what

#

It generated a

#

221k loc file.

#

It generated low level code.

#

//////////////////////////////////////////////////////////////////////////
// 
// NOTE: This is *not* a valid shader file, the contents are provided just
// for information and for debugging purposes only.
// 
//////////////////////////////////////////////////////////////////////////
// Skipping shader variants that would not be included into build of current scene.
#

This is also the first thing inside of the file

meager pelican
#

That's not what you want.
You're looking for a "show generated SOURCE code" (or whatever it says). You get it from right-clicking on the master-node in SG. Should pop up in 2 seconds.

marsh sparrow
#

Oh yeah I accidentally compiled it

#

oops

#

Alright I think I see it now

#

Holy crap it's a 10k LOC file

meager pelican
#

You're going to get me swearing in a minute....
πŸ˜‰

#

Sec

regal stag
#

right click the master node in shadergraph

marsh sparrow
#

I did

#

I clicked Show Generated Code

#

Is it because I used a HDRP SG?

#

I'll try it out with a regular SG.

regal stag
#

Maybe it's different in HDRP?

marsh sparrow
#

Maybe. I'll use a regular PBR SG now to see if that's the culprit.

meager pelican
#

If you want lighting, that's probably the one you'd want anyway for an HDRP project.

marsh sparrow
#

Holy crap the regular PBR SG generates a 3k LOC file.

#

Damn it

#

I think I'll have to use an Unlit one.

meager pelican
#

I'm "converting" and old HDRP sandbox project. Sec.

#

Tick. Tick. Tick.

marsh sparrow
#

All I want is just a shader for an object, an object that could behave just like a regular terrain.

meager pelican
#

Terrains are lit. And often complex ("regular terrain"?)

marsh sparrow
#

Yeah, that's the thing.

#

But in the past you would just generate a standard surface shader

#

And it would do the job

#

Holy hell even the Unlit one is generating a 2.3k LOC file.

meager pelican
#

I'm "importing" still. Please stand by. One moment please.
We'll return you to your regular program soon.

marsh sparrow
#

Hah, yeah, no problem.

remote mauve
#

HDRP also have built in shaders, no?

#

You can just copy the code of those.

marsh sparrow
#

Uh, I'll check if they do..

#

I just recently ported my game from URP to HDRP

meager pelican
#

Oh, well since your masochistic, you'll do fine here.
(Still "importing"...)

marsh sparrow
#

I think that's true considering I made 50 different input ports for a node and 50 different blackboard parameters specifically for those 50 ports of a custom node.

#

It was a pain. 2-3 hours just to set that up.

meager pelican
#

OK, so I created an HDRP lit graph.
right clicked on the master node. Selected "Show Generated Code"

marsh sparrow
#

Yes. That's what I also did.

meager pelican
#

And got 9500 ish lines of code in Visual studio

marsh sparrow
#

Welcome to my world.

stone sandal
#

yes, the HD shaders are large c:

marsh sparrow
#

the regular ones are also large

#

3k lines of code

meager pelican
#

yes, the HD shaders are large c:
@stone sandal Probably OK. We've all agreed he's masochistic.

marsh sparrow
#

Not THAT masochistic.

meager pelican
#

lol

marsh sparrow
#

I don't even know where to begin with this.

#

They are totally different than the good old standard surface shader.

meager pelican
#

Well, maybe feed it some color data or something simple in a simple graph, so you can see where your variables go, then add your array somehow???

marsh sparrow
#

I'll... see where that gets me.

#

No, there's actually no way for anyone to manually write this.

#

It's the same code in multiple places.

#

So there's multiple render passes, right?

#

Well in each pass there's pretty much the same code. I added a parameter to the blackboard and I made it be the base color of the shader by directly linking it.

#

In each of the rendering pass I see the same code.

#

Minor differences in the #ifdefs before the actual code.

simple frost
#

the graph code gets populated to each render pass based on what that pass is responsible for yes

marsh sparrow
#

Could I ask you a question pertaining to shader graphs in private?

stone sandal
#

hey, we try to keep all conversations in the public channels in case someone else can be helped by the information

#

please don't DM employees c:

marsh sparrow
#

Alright. I'd especially like others to know about this.

#

So... All of this started from needing a float array data type in shader graphs.

simple frost
#

have to answer here, but do keep in mind I am working

#

theres no reason you cant include a float[] field in a custom function node and set that as a shader property from code, as far as I am aware

#

it wouldn't be a node input because then youd have to specify all the input ports

marsh sparrow
#

Wait this is it

#

So I create a custom function node, alright, that's what I've done before, but then I have to set a shader property from code?

simple frost
#

how else would you specify it?

meager pelican
#

She means C# side code

marsh sparrow
#

That really was the biggest issue that I've had so far.

#

No, I understand she meant C# side code.

#

So, any custom function node can access the shader properties?

simple frost
#

yup, so long as they are defined

marsh sparrow
#

I'll try to implement that.

#

I'll report once done.

little dew
#

Does anyone have any insight about vertex streams for particle systems? I made a vertex animation shader but when I try to use it with particles it goes bonkers. I tried to look up some stuff on vertex streams but I can't wrap my head around how to implement them (I'm using ASE for the shader creation) https://gyazo.com/16eb1cfc276baa617cff00761295275c

marsh sparrow
#

I may have not understood something

#

So I'm including a float array field in a custom function node, alright?

#

But how do I actually set it as a shader property?

#

My custom node script looks something like this:

#
float testFloat;

void main_float(...)
{
...
}
#

Alright?

regal stag
#

That's just a float, not a float array. You'd want something like float _FloatArray[10];

marsh sparrow
#

No, I know it's just a float, right now I just want to make the connection between the custom function node's data and the C# script.

#

Do I just go:

material.SetFloat("testFloat", 0.65f);
#

?

marsh sparrow
#

No, I know the SetFloatArray and how it used to work, I'm asking whether I can just call the SetFloat / SetFloatArray directly

#

Wait so

regal stag
#

Yes, although it would have to be a property in order to use SetFloat, right? You can use Shader.SetGlobalFloat without it being a property though.

marsh sparrow
#

when I wrote that float testFloat; inside the custom node script

#

It suddenly becomes a property of the shader?

#

I don't see it in the properties of the shader when I click on it.

simple frost
#

its not something included in the Property section of the material, so it wouldn't show up in the inspector

marsh sparrow
#

Well... if it's not part of the property section of the material

#

How exactly do I reference it?

#

By that I mean through an external C# script.

simple frost
#

You can still call material.set and material.get on the string lookup of the value.
@regal stag might be right but I dont remember having to explicitly set a global variable when the shader had an unexposed value.
so it should just be material.SetFloat like you suggested

marsh sparrow
#

I did this, though.

#

It's not working.

#

I have a script that updates the value of the material while in the editor.

regal stag
#

I always thought material.SetFloat had the requirement of it being exposed, but I might be wrong, I really don't know.

marsh sparrow
#

I press a button and it calls

material.SetFloat("testFloat", 0.5f);
#

So the testFloat inside of the custom node script should have its testFloat variable updated to 0.5f

#

Yet it doesn't.

regal stag
#

I assume you are outputting the result as a colour to preview it somehow

marsh sparrow
#

The custom node has an output of a float that is connected to the master's base color. Basically if the color I'll see is not black it should be working, but it's not changing from black.

#

I assume you are outputting the result as a colour to preview it somehow
@regal stag Yes.

#

It's a grayscale, but I just need it as a proof of concept.

regal stag
#

Out of curiousity, what happens if you try Shader.SetGlobalFloat("testFloat", 0.5f);

marsh sparrow
#

the shader?

simple frost
#

no just the static class

marsh sparrow
#

oh ok

#

i'll try it soon

stone sandal
#

it should be global float, as cyan suggests

#

iirc

simple frost
#

ah my bad, misremembered from last time I did something like this

marsh sparrow
#

... nothing

#

I thought I saw something change but the material's color is still pitch black

#

I really don't think Unity sees that ```csharp
float testFloat;

#

that sits inside the hlsl file

regal stag
#

That seems strange to me, I assumed that would work. Are you sure it's actually outputting the value in the function correctly, and it's hooked up to the master? Definitely saved?

marsh sparrow
#

I'll check it again just in case

regal stag
#

And make sure the Shader.SetGlobalFloat code is actually running

marsh sparrow
#

I'll add a Debug.Log() to see if it's running just in case. I know this function is running, but it's better to be safe than sorry.

regal stag
#

Yea

marsh sparrow
#

oh nice now the shader is not responding whilst compiling

#

oh

#

it works now

#

It does actually change the color

#

For some reason I can't see it in the game view, but it doesn't matter

#

The Scene View shows it properly

#

Let me try it now by calling it locally

#

Without the global part

#

... Now it works??

#

what

#

I'm legitimately confused. Why does it work now?

#

well either way

#

I guess this solves it.

regal stag
#

Maybe the shader wasn't saved properly or something, who knows πŸ˜…

stone sandal
#

or it was just taking a while to recompile, etc

marsh sparrow
#

probably

#

Well now it works

#

I'll post a TL;DR for those interested

#

Variables of custom function nodes are actually stored in the Properties section of the shader/material, but they are not exposed, that means you don't see them in the inspector.
To interact with them, use an external C# script and use their exact variable names, such as this:

Custom Function Node file

float testFloat;

void main_float(out float grayscaleOut)
{
    grayscaleOut = testFloat;
}

C# Script

public Material testMat;

void SetTestFloat(float someFloat)
{
 testMat.SetFloat("testFloat", someFloat);
}
simple frost
marsh sparrow
#

also this way you could technically use whatever kind of data type you want as long as hlsl supports it.

simple frost
#

yup

marsh sparrow
#

or really you could make your own structs this way, too.

#

this is just for those that might stumble upon this.

simple frost
#

that one I am less certain of

marsh sparrow
#

well, regardless, the next masochist will find out down the line πŸ˜†

#

also this was fun. Thank you all for helping me out!

simple frost
#

glad you got it working!

regal stag
#

I didn't know you could use material.SetFloat on non-exposed properties, so that's cool

simple frost
#

I think it has to do with the property sheet that gets passed around by materials

#

Ill have to double check that in c++ land though

marsh sparrow
#

it's probably there but it's just not exposed

simple frost
#

I know it doesnt attach a shaderlab property to the top of the generated shader, but I think there is a lookup that gets passed around

marsh sparrow
#

you know it better than us

regal stag
#

Yeah, for some reason I assumed because it didn't have the property at the top of the shader it wasn't able to be set via SetFloat, which is wrong. I've never needed to have a non-exposed property like that so never bothered to test it.

simple frost
#

iirc the property sheet literally just contains a list of any value defines based on id=>value so and if it doesnt find an entry there it checks the global lookup, then defaults to whatever the shader sets it to

regal stag
#

Yeah, makes sense

simple frost
#

by camera shaders you mean post process shaders?

#

not easily unfortunately. What sort of post process?

#

the usual way to do it is to have the objects you dont want the effect on write to a mask and use that to mask out the effect on those areas

#

no this would be a bit more code involved unfortunately, unless the objects will be in the exact same spot all the time on screen

#

2d or 3d?

#

then this gets MUCH easier haha

#

still gonna take a bit of code tho

#

ehhhhhh

#

so what you will need to do is have all objects that you want to be unaffected by the post process render to a separate render texture that writes a bitmask. Then youll pass that render texture to your post effect and you will add a parameter to the effect for the mask. Then you will only apply post effects to the area where the mask value = 0

#

if the objects are not lit, then this can get a bit easier, since you can just draw them after the post process stack

marsh sparrow
#

Hey

#

Let's say I have a Texture2DArray in my shader's script

#

How do I actually sample it?

#

the UNITY_SAMPLE_TEX2DARRAY macro is not recognized apparently

#

neither is the one used to declare it

meager pelican
#

Well, IDK, but these are defined in HLSLSupport.cginc

#define UNITY_SAMPLE_TEX2DARRAY(tex,coord) tex.Sample (sampler##tex,coord)
#define UNITY_SAMPLE_TEX2DARRAY_LOD(tex,coord,lod) tex.SampleLevel (sampler##tex,coord, lod)
#define UNITY_SAMPLE_TEX2DARRAY_SAMPLER(tex,samplertex,coord) tex.Sample (sampler##samplertex,coord)
#define UNITY_SAMPLE_TEX2DARRAY_SAMPLER_LOD(tex,samplertex,coord,lod) tex.SampleLevel (sampler##samplertex,coord,lod)
marsh sparrow
#

I see

#

Let me try to just sneak them into the script

meager pelican
#

Yeah, or maybe include the include file. IDK.

#

SRP's pretty new for me

marsh sparrow
#

I don't think it's working

#

I don't think it's even reading it

#

yeah I included it

#

but now that file is giving me an eror

#

xd

#

I'll just define what I need to have defined

meager pelican
#

There's macros for declaring the array too.
But IDK that this stuff even works in SRP. Maybe it's something else.

marsh sparrow
#

Well that's what I just looked over

#

I looked at the file and copied the macros over.

#

Now it works

#

It's giving me a different error, but those things work!

#

Thanks, my dude!

delicate veldt
#

Hey guys, I'm working on a portal game and wrote a shader (first time) that would map a camera view to a texture (generally works great). However, for some reason everything EXCEPT my first person gameobject is being rendered (IE --> my player model). I'm using Unity's built in FPS Controller (which I think may have to do with it possibly).

Anyone have any ideas? I really need to be able to see my own model through the portals and I'm not sure how to do this without a hacky-workaround

#

(PS --> I know almost nothing about shaders; it's possible this has nothing to do with the shader i've created)

visual flower
#

Does any of you shader experts know of any pre-made inset border outline shaders, or how I could modify the outline shader I am using? I know nothing of shaders and only need a simple border around my 3D countries. I understand what I need and kinda how it works but I really want to avoid learning to code a shader at this stage.

grizzled breach
jovial onyx
#

why in my game it does not look the same as in my preview?
@grizzled breach Because it's a different setup, lights etc, can you share your graph ?

#

I imagine you use the fresnel effect on the emission output and you didn't added lights to the scene

grizzled breach
#

ohhhhhhhhh

#

yeah is the light

jovial onyx
#

ok great

grizzled breach
#

thank you ❀️

jovial onyx
#

np

grizzled breach
#

but is it possible without adding lights?

jovial onyx
#

Yes, if you output everything to the emission channel

grizzled breach
#

how can I do that because i tried to multiply but does not work

jovial onyx
#

You can unse an Unlit Master Output if the shader does not gonna change by lights

#

try adding first

grizzled breach
#

yes with adding it works

#

what's the difference between multiply and adding im nbeginning with shader

jovial onyx
#

think of it the math way

#

your effects output a color in reality, that is composed of a vector4

#

red is (1, 0, 0, 1), white is (1, 1, 1, 1)

#

multiplication of colors will multiply each vector of the color separatedly

#

if you multiply any color by black, it will give you black

#

red (1, 0, 0, 1)* black(0, 0, 0, 1) = (1 * 0, 0 * 0, 0 * 0, 1 * 1) = (0, 0, 0, 1)

#

if you sum it, red + black should be red

#

are you catching up on me up to this ?

grizzled breach
#

the multiplication I understood but the sum if we have (1,0,0,1) and black (0,0,0,1) = (1,0,0,2) ?

remote mauve
#

Clamped at 1.

#

You can't go higher than 100%.

vocal narwhal
#

It's not clamped, you have to clamp it yourself with Saturate or other clamps

remote mauve
#

Oh TIL.

jovial onyx
#

you clamp it on rendering i think

#

*the rendering clamps it

vocal narwhal
#

It's sorta clamped when it's output depending on whether you're in HDR or not, but the maths during the process will not be clamped, which often causes problems with shaders

jovial onyx
#

I got a question with HDR

grizzled breach
#

okay I think I understood thank you guys ^^

jovial onyx
#

When you output this color

#

with HDR+2

#

What is the output ?

#

Where does the HDR data goes ?

#

because its still a Vector4

jovial onyx
#

So, they store the HDR out of the range of 0, 1 float ?

vocal narwhal
#

Though, it's stored in a way that doesn't necessarily recreate the same input, so that must be the same as

little dew
jovial onyx
#

Cool @vocal narwhal

#

didn't know about the 0-1 mode, it's easier to understand

#

so, messing up with color adding ends up making a HDR color, that explains some issues i had with some shaders i made πŸ˜†

gritty trout
#

Guys I would like to realize this aesthetic. I thought that starting from a toon shader would be a good idea, but I'm honestly a total noob for shader. Could someone please point me in the right direction? :c

grim tartan
#

Not sure, but I think Alexander Ameye shared shared a toon shader in Twitter some time ago. should be a nice start to break down his shader

thick fulcrum
#

@gritty trout I would say it's not just one shader, you need to ensure your assets are suitably textured. The shader on these assets will help to achieve that sort of effect, then you also need post processing to give good finish.
Basically what I'm saying is there is no one magic shader to achieve this with any object πŸ˜‰

gritty trout
#

I'll give it a look, thanks @grim tartan

I imagined as much 😫 can you recommend a good tutorial or documentation to study post processing effects and shaders? @thick fulcrum

thick fulcrum
#

there's probably 100 different ways to approach this, for example a recent game used a post processing effect to make the scene look like a Van Gogh painting. It had a very unusual effect, definitely unique.
I'm afraid google is probably best starting point, see if others have achieved similar style to that which you want. Then see if there's some papers on how it was done.
You may need to find a 3D / 2D artist who will create assets to the style you want.

visual flower
#

Can anyone hint me in the right direction for a custom shader?
https://pastebin.com/t37YhJqi

Is this the right approach I should take to get a "inset border outline" that works on irregular shapes positioned close to eachother? (country bordrs in my case).

I got the approach from a comment on the unity forum, but I have never worked with shaders and unsure about the Stencil { } and what code relates to this: Shrink it the same way the Standard Assets Toon shader does, by pushing the mesh by the mesh’s vertex normals.

#

is it the v2f vert(appdata) (from toonbasicoutline) that I should use in Pass 1 : Mask?

frail salmon
#

anyone want job involving shaders

meager pelican
#

@visual flower You may not like this, but if I were you, since the countries are "fixed" on your map, I'd just make an outline object for each country. Or I suppose you could make it a mask. And then overlay it either at shader time, or just enable/disable the overlay transparent object.

If shader, it could be super-simple, have an attribute on the material for "isOutlined" and pass both an albedo texture and an outline texture and just "merge" them if isOutlined is true.

The other way to do it is with some UV math in the shader. Let, say, 0% to 2% and 98% to 100% be an outline. The middle >2% and <98% just scale the UV sampling.

#

@frail salmon Kinda vague. But check unity's connect area.

visual flower
#

@meager pelican that sounds great, i considered something similar but I dont have the sofware or knowhow how to get the outline "curves" from blender into an object that would fit

#

I tried it a bit but blender is so confusing :)

meager pelican
#

Yeah, you can handle it 100% on the art side if you want. Pass in two textures for each country, one for not-outlined, one for is-outlined. More memory used.
Or just do the % thing and pass an outline color

#

But that needs masking

#

because of irregular shapes.

visual flower
#

I would need to go back at a later stage to fix the worldmap as vector, convert to mesh and import to Unity (or do it all in 2D) eventually but I have everything I need except the country broders atm and I already spent 2 days trying to fix it in blender

meager pelican
#

So maybe % isn't good if you're drawing quads. If you're drawing irregular meshes....

frail salmon
#

I want to pay someone to add hue changing functionality to an existing shader. And star flicker to another existing shader. And one more more complicated job later

meager pelican
#

There's a ddy/ddy thing too.
I have a hunch since the outlines don't change you can just either swap or mask textures.

regal stag
#

If you've got a shape mesh in blender, isn't there a way to make more vertices to just act as an outline? Inset faces, maybe? (Then you could use a uv channel, assign like 0 to all the interior faces and 1 to outlines if you need to be able to toggle it)

visual flower
#

sorry for being so nooby and dumb, but this mask would that be a texture I somehow created or does Unity have support for it?

#

I think surely there must be some easier way to do it all already before exporting from blender, but I have spent so much time on it and realized there is so much to learn about blender and Im a noob

meager pelican
#

Yeah, it would be. IDK what you're doing.
Do you have countries as quads, or are they irregular-shaped meshes?

visual flower
#

I just want to continue with C# and Unity atm but having a hard time designing the game without the outlines

#

thought it would be easy but its proven really hard πŸ˜…

meager pelican
#

The art is often the hardest part. There's 10x or 20x the art talent as programmers in many studios.

visual flower
#

So what I did was I imported an svg worldmap into blender, I took all the curves and converted them to mesh

#

then I cleaned up the meshes a bit by stumbling a bit

#

then I added a solidify modifier to all of them

#

to add some thickness, then imported to Unity

#

any outline shader I used so far wont display borders properly because the meshes intersect

#

but unity and blenders own editor shader does this perfectly

meager pelican
#

OK, meshes then. Hmmm.
You might want to reduce triangles too, or it's going to suck up your performance.
Is this 2D or 3D?

visual flower
#

yeah for sure I need to do that eventually, I told myself one day I will learn blender better and do it proper

#

its 3D

meager pelican
#

Unity has some SVG tools.

#

IIRC

regal stag
#

Your countries are just 2D shapes though right?

visual flower
#

but I am thinking about redoing it all in 2D one day. for now I jsut want to proceed with what I was working on before I lose all motivation

#

yeah technically they are 2D shapes, but to get it working nicely with Unity atm I made 3D shapes from them

#

the original worldmap is an SVG with vectors, each country with curves and categorized

#

I tried multiple SVG import packages etc got none to work

#

some were old, some complained about too many vertices

#

(again blender issue having too many verts for borders)

thick fulcrum
#

@visual flower Blender has ability to remove vertices without disrupting shape too much. But you will lose some definition, it's a trade off tbh.
You could in Blender use your svg and remove the top and bottom faces, then use the thickness tool (if I remember) with a negative value to create an edge mesh.

visual flower
#

OK that sounds interesting, thanks!

#

blender is driving me nuts atm. awesome program but so hard to get into with UI

#

and so much terminology to learn

meager pelican
thick fulcrum
#

I've been doing this as a hobby making one game for over 5 years, but some years no time to touch it at all. So have to re-learn blender each time πŸ˜„
I'm pushing to get this finished though, it's coming together slowly but surely.

visual flower
#

I tried this on monday, cant remember what the problem was (too many curves?) but I will try again

thick fulcrum
#

I like @meager pelican 's idea, I think inkscape is free svg editor which can export as png to use as a texture / sprite.

#

if Unity was having problems

meager pelican
#

Yeah but forget the %UV calc idea, won't work except for special convex meshes.

#

Do the countries have art on them? (Like topology stuff, or other features?)

#

If so you already need a texture anyway, to overlay on the mesh. So you can just use that, maybe as a mask too.

regal stag
#

If you can produce simple textures/images, you could put it through something like this, which creates a distance field from the input image. Would probably be quite a bit of setup though. In a shader you could then step at different intervals to produce an outline, even at different thicknesses. https://assetstore.unity.com/packages/tools/utilities/sdf-toolkit-free-50191

Use the SDF Toolkit Free from Catlike Coding on your next project. Find this utility tool & more on the Unity Asset Store.

frail salmon
#

Anyone welcome πŸ™‚

#

Im just cannot understand combining shaders

visual flower
#

@meager pelican sorry just got back to PC, no it has no texture or art on it (yet) just an albedo

#

all I need atm is just to display borders

#

what does this mean?

Stencil {
                Ref 1
                Comp Always
                Pass Replace
            }```
#

@regal stag thanks, just saw your response. will look into it!

#

GIMP doesnt seem to cut it for me though :/

#

giving me all kinds of headache

regal stag
#

It writes a value of 1 into the "stencil" buffer for all fragments/pixels that mesh takes up. Other passes can test against it and discard pixels so they aren't drawn.

visual flower
#

ah ok, thanks!

regal stag
#

I'm not sure that shader will do what you want it to though, as the outlines are based on normals so is intended for 3D objects really.

visual flower
#

he mentions the standard assset toon outline shader does a "shrink" by "pushing the mesh by the mesh’s vertex normals."

#

I have 3D objects

#

thats why I am trying to solve it with a shader

#

to replicate Unity Editors outline effect when you select gameobjects

#

I just never worked with shaders so I am clueless :)

regal stag
#

I mean actual 3D spheres/cubes not a flat plane/quads.

visual flower
#

ah yeah

#

well I have some thickness to them now

#

so they are not completely flat

regal stag
#

Hmm okay, it might work then, not sure

visual flower
#
v2f vert(appdata v) {
        v2f o;
        o.pos = UnityObjectToClipPos(v.vertex);
 
        float3 norm = mul((float3x3)UNITY_MATRIX_IT_MV, v.normal);
        float2 offset = TransformViewToProjection(norm.xy);
 
        o.pos.xy += offset * o.pos.z * _Outline;
        o.color = _OutlineColor;
        return o;
    }```
I took this from the toon outline shader, is this the part I need to use in the Pass1 : Mask to push the mesh?
#

I might be able to look at some tutorial and check other shader examples and make a test, Im just not sure what part of the toon shader that actually does this

regal stag
#

Yeah, looking at the thread, bgolus mentioned that pass 1 is where the vertices are pushed in

visual flower
#

nice, thanks that helps me get going at least!

#
///Pass 1: Mask
Pass{

    ZWrite Off
    ColorMask 0 // do not render any color
    Stencil {
        Ref 1
        Comp Always
        Pass Replace
    }

    CGPROGRAM
    #pragma vertex vert
    #pragma fragment frag

    v2f vert(appdata v) {
        v2f o;
        o.pos = UnityObjectToClipPos(v.vertex);

        float3 norm = mul((float3x3)UNITY_MATRIX_IT_MV, v.normal);
        float2 offset = TransformViewToProjection(norm.xy);

        o.pos.xy += offset * o.pos.z * _Outline;
        o.color = _OutlineColor;
        return o;
    }
}```
#

so I am on the right track thinking Pass 1 could look something like that?

#

sorry for the dumb questions but never seen the code for a shader until yesterday :)

regal stag
#

Possibly yeah. I don't usually do shader code (I prefer working with shader graph in the Universal RP). You'll probably need to define the frag function too, bgolus mentioned fixed4 frag () : SV_Target { return fixed4(0,0,0,0); } in that thread.

visual flower
#

ah yes ofc, thanks

#

also that v2f I see is using the outline so prob dont want that in pass1 ? In the examples I have its located outside the SubShader{ tags

#

but I thought that code was what he was talking about for pushing the mesh

#

I think Im just gonna have to give up the idea I could fix it fast. Time to watch some shader tutorials

regal stag
#

Sometimes you have a CGINCLUDE part which I believe is just included/accessible to every pass

#

I see that's what you have on the pastebin, but I think every pass is using that vert where it's offset

meager pelican
#

Usually, if you're doing a "vertex push" outline of some sort, you draw the outline in the 2nd pass with depth clipping enabled. That draws min pixels for the outline. Otherwise, the other way around, you end up drawing the entire area twice.

regal stag
#

Also don't forget ENDCG, just noticed they are missing from the end of each pass

meager pelican
#

There's a ton of vertex-mod outline examples. But, flipping the art is probably easier if it's really a 2D tile/spirte type thing. YMMV

regal stag
#

I think in this case it's more of a "vertex pull" as the OP wanted "in-lines" rather than outlines, so there's some stencil magic going on too. I haven't tested/checked if it's correct, I just always assume bgolus knows what they're talking about.

#

Whether it'll work for sentient's case though, I'm still not sure.

#

I'd still probably go for the more 2D / texture approach instead.

meager pelican
#

I always assume that too. ;)
But IDC if it's a stencil or a depth-clip. Again, YMMV.

visual flower
#

Yeah exacly it’s a inline border I am trying to achieve

#

I will look into the texture and 2D approach eventually just figured this would do now as I have only been working in 3D and everything is setup for it, and doing that would require me to learn gimp as well :P

#

Thanks for the responses btw, appreciated ❀️

little dew
#

hey guys, Isn't the dot product between the normalized vertex pos and a vector3 like(0,0,1) a good way to find a direction? I'm a bit confused e_e

#

I'm basically trying to determine the local z rotation axis for particles in my shader

hoary acorn
#

I'm trying to create a vertex shader in the universal render pipeline. I'm modifying the standard lit 2D sprite shader but for some reason POSITION is already in world space. Any idea why?

thick fulcrum
#

it's the expected space, so just do your modifications and make sure the end result is in world space there are conversion nodes.

grand jolt
#

hi,
does exists an c# way to bypass shader compiling on headless build?

naive coral
#

what are shader passes and how do i use them

low lichen
#

To prevent all shaders from compiling, it should be enough to just clear the data list you get in that method

molten halo
#

But when I click "Apply to Systems" I'm getting this warning in my particle system's renderer (which uses that material).

#

I'm a shader noob, anyone got any ideas?

#

I'm just using the standard Unlit particle shader.

full sierra
#

I was wondering if anyone here would be able to answer a question for me. I'm procedurally generating a mesh in unity by basically making a bunch of quads and placing them then saving them out as a mesh. The mesh is intended to represent a background for isometric sprites which means that a bunch of fiddling has to happen to get things to look right. Anyway long story short there is an edge case that's been a pain in the backside to solve where quad corners occasionally overlap under the right conditions. The background is transparent and so the 2 overlapping quad edges create artifacts. They are at the same z order and are technically a part of the same mesh. I was wondering if there was a way to work-a-round the problem with a shader.

#

Here is a photo of the artifacting going on. The dark spots are what I'd like to eliminate, the rest is correct.

#

I tried editing the standard shader and toying with the Z test stuff but nothing seemed to work

craggy patrol
#

so I made this house in blender
and applied the materials in unity
it consists of a few gameobjects in one house prefab
and I want to make it look like it is being built (i thought about making a kind of reverse dissolve effekt)
is there a way to make this wihout changing the different materials? maybe using shader graph?

knotty juniper
#

@craggy patrol sure you can do a custome desolve shader for your specific case if you are running on HDRP or URP(LWRP)

craggy patrol
#

yes i am using urp
but I only made shaders like this: make a new pbr graph -> apply it to a material -> set it as the material of the object
but in this case i have more objects with different materials and i dont want them to fade out individually idealy it should affect the whole object maybe
but that would get difficult because those are all different meshes

#

sick name btw πŸ˜„

knotty juniper
#

You could make a shader that fades all meshes in a radius around a point then you could just globaly define where and with what radius you like to fade objcets

#

mmmm let me thinkt about it for a moment

#

If all the objects of the building have a fading shader you coud do it with material property blocks

#

you could make a per object overide that sets the fade progress

#

@craggy patrol material property blocks are nice because the do not break the matrials and can be done nicly iva code.

craggy patrol
#

that sounds exactly like what I am needing. thx a lot @knotty juniper. I will look into that

vague jacinth
#

Hey guys. Need help on this (in my opinion) very simple case. So in my scene there is a simple water plane with the HDRP/Lit shader on it. It's set on transparent, so I can see the objects behind/underneath it.

#

After that I want to add a custom fullscreen pass, that I can adjust, showing the depth of the scene. Here's the code. Simple af

#

Though, the result is not what I want. I can't see the surface anymore eventhough I set the Depth Write to true in the water plane material. What's wrong here?

fervent tinsel
#

@vague jacinth what do you need that fullscreen pass for?

vague jacinth
#

@fervent tinsel It's like a echolocation effect, so I can see in the dark.

fervent tinsel
#

ah

#

pretty sure someone just did that for HDRP

vague jacinth
#

Do you maybe know what's the difference between custom fullscreen pass and the post processing volume in HDRP?

#

Because the depth write is working in the pp volume πŸ˜… But my colleague is using custom passes, so we had to decide which to use because our shaders is also depending on each other

knotty juniper
#

mmm interesting have to cheack out that component πŸ™‚

fervent tinsel
#

@vague jacinth there are some overlapping functionality between the two but also major differences. You can inject them in different places. Custom passes let you render on individual mesh renderers where in PP you only use existing data as source. You also can't blend custom passes like you can blend custom postprocess passes through the volume framework

vague jacinth
#

Yeah that's my main reference πŸ˜„ But Unity breaks everytime I want to clone it. I guess he's using 2020.1.0a24 and it's not working at least on 2020.1.0b6. That's why I try to understand his shaders by looking at the codes in github

#

However, if I just copy the code and paste it directly into my project, I could see some of the shaders. But the ones using the depth buffer still have the same problem with my transparent plane :/

#

Thanks for the info about custom renderers passes btw. Pretty convenient

vague jacinth
#

@fervent tinsel do you know if i can set the order of two shaders, one from the pp volume and one from the custom pass? For example both have the injection point set to BeforePostProcess but the pp effect renders first and the custom pass afterwards. And optionally pass a buffer from the first to the second.

fervent tinsel
#

@vague jacinth I dunno about that

#

I mean custom passes have priority value but that's afaik for the things on that same volume

ornate blade
#

Hey all, run into a stupid problem. Making a shockwave shader in sg, and my mind is blank about affecting (in this case, 'raising'), the area around the players world point within a certain range. This is my current graph:

#

im tired, and have multiple problems, but the 'within a range' one is whats getting me

vague jacinth
#

@ornate blade do you even pass the player's position into your shader?

#

Or is this just a zero position for debugging?

ornate blade
#

zero position for debug

#

gonna pass it in once it works, using c#

#

I might actually be okay... just found a tut on what im doing πŸ™‚

vague jacinth
#

I wish I'm so lucky xD

ornate blade
#

oh yeah, dont worry im savouring it. Never happens when i need it haha

meager pelican
#

@full sierra I have almost no idea, but you wrote such a nice post I'd hate to see it go ignored. So without further ado, I think we can spitball some stuff. Just for giggles.

The zorder and z-test are really slightly different issues. Usually in transparent rendering (IDK if that's transparent quads in the transparent queue or what) the z-buffer is not written to. So although you can clip to the z-buffer to test for, say, an opaque tree in the way of your transparent quad, writing two transparent quads at the same z for the same pixels is asking for "problems" usually.

That's z-fighting. And it depends on what order the polygons are written. Unity will sort the meshs, and maybe all the triangles in the mesh, by z-depth farthest to closest for the transparent queue. (Opaque is the other way...closest to farthest).

Now the artifacts you're getting, I'm not sure where your quad boundaries are and why you're getting black squares that you need to eliminate. Maybe more elaboration on what I'm looking at would help. Or I'm just stupid.

atomic glade
#

I'm writing a sprite shader in shader graph, and I'm wondering what's the best way to get a subsection of a sprite sheet? There's the flipbook node, but that requires evenly-sized sprites in a grid. If I wanted to define an individual subimage of arbitrary height and width, how would I go about doing that?

grand jolt
#

Is it possible to read z-depth from an unlit surface / shader?

full sierra
#

@meager pelican Thank you for getting back to me. The polys are overlapping because in isometric view you can't just say a sprite is 256x256, if you adjust it to it's actual ISO size it'd be 210x256 but that creates akward looking "Squares" that are illongated. So the procedural generation uses the idea of "Margins"... this means the polys I generate are 210x210 but if they are on an edge there is an extra "Margin" polygon added to the top, left, right or bottom. The algorithm works well except for when the designers decide to create a line of empty spaces on a diagnol where on the opposite side of that diagnol creating an X another valid block exists. When this happens there is a small overlap in the margins, but if I solve for that problem..instead of 11 meshes with problems I end up with 169 invalid meshes and 11 correct ones. We are talking about 5-10 pixels for most situations when the overlap happens, and I don't really have a ton of time to come up with a solution due to time constraints. I did find a post on the unity forums that pointed me towards code that would allow me to manually adjust those 11 levels... though there is a little upfront work todo in order to make that more feasible because while the script works it's not all that user friendly, tabbing through every vert on a mesh and hoping you got the right one... ehh.. I did try some basic shader options but my shader experience amounts to one catlike coding tutorial and what ever I can futz around and make Amplify do. Think of a mesh of quads that are 210x210 and if they are near an "Empty Space" being on the border on the top, bottom, left, or right they get a quad that is more represenative of a illongated rectangle. So while technically the "Mesh" is a single thing procedurally created in unity it's a bunch of quads of various sizes/shapes in order to more accurately represent the isometric view.

#

(Sorry that was long)

#

I don't have access to a mesh photo at the moment but I can probably find/create one tomorrow

grand jolt
#

Hello everyone. i don't understand how to use a smoothness texture map onto a shader. the default shader has a smoothness slider but i don't want all of my window texture to be shiny, only the glass. i looked it up but the info seems to be outdated or something as it didn't seems relevant. can anyone help?

#

im using URP and it is said that "it should use the alpha channel of the metallic or specular map as a smoothness map." but there is nowhere to add a texture to the alpha of the metallic map.

#

it this something i have to do with a separate software? i dont have $$$$ to spend on photoshop

#

im so confused. Does URP not support height maps for textures?

royal field
#

I'm working on a custom shader which uses a green channel from a texture to calculate roughness. How would I get smoothness to act as roughness? (like, invert how Smoothness works so it functions as roughness instead)

grand jolt
#

could you not invert your roughness map? then it is a smoothness map

royal field
#

@grand jolt I'm trying to avoid modifying the textures as there is a lot of them that use this specific color scheme

grand jolt
#

fair enough

royal field
#

?

#

o.Smoothness = 1 - mg.g;

#

That's what I've done so far, but it appears to introduce smoothness to other areas that it is not supposed to.

thick fulcrum
#

@grand jolt generally I think the shininess comes from the metallic if working in metallic shader mode. Smoothness covers the overall min and max strength if you will. I work with textures from Substance Painter which I just replicated the standard URP using metallic texture, albedo, normal etc.

grand jolt
#

okay thankyou. problem is i dont have a metallic map as there is no metal on the texture. in the software called Materialize you can create a smoothness map which is separate and independent from the metallic map. i tried using the smoothness map as a metallic map on the unity shader but that looked completely different

#

isnt URP supposed to be an improvement on the basic unity shaders? there is no height map...

thick fulcrum
#

metallic map is not about metal, it's about roughness as much as anything πŸ˜‰

#

there is no parallax mapping as yet in URP, that's more HDRP. Normal mapping is sufficient as height maps in most instances.

grand jolt
#

hmm okay. so how come the smoothness map looks different in unity than it is supposed to? also there are some other textures that are using both smoothness and metallic at the same time, both changing different aspects of the texture.
it seems the normal map isnt doing anything at all to displace the textures mesh. 😦
thankyou for the reply though, i think its weird that there is no a single mention online that URP does not support height map. i will attempt changing to HDRP

thick fulcrum
#

you could try creating a metallic texture as input, Metallic(R) Smoothness(A) just those two channels I believe, I assume G, B are zero

grand jolt
#

i dont know how to insert the smoothness map into the alpha channel of the metallic map. i dont know enough about images or how they work.

thick fulcrum
#

you can convert greyscale heightmaps to normal, see if that's what you want. it's object space displacement on pixel level. Faster than parallax and cheaper

#

you can use a combine node which should be 4 channel if I remember, plug your smoothness grey map into the alpha. ignore others for now and plug that into the metallic. see if that helps

grand jolt
#

0.0 im guessing youre talking about graph or node editor? i havent opened that up before. ill try it now

thick fulcrum
#

oh sry I was assuming that's where you were working

#

is this standard shader?

grand jolt
#

just using the inspector

thick fulcrum
#

yea you need a means of creating a shader which has smoothness in the alpha channel, I believe most tools should have some way of doing this as it's fairly standard. Where is your textures comming from or what tools do you have?

grand jolt
#

im guessing its by changing from metallic to specular, thats what i gathered online

#

oh right, the previous image was essentially the same

thick fulcrum
#

in either specular or metallic the smoothness is in the alpha channel

grand jolt
#

okay let me sus out the node editor and try do what you mentioned, thankyou

thick fulcrum
#

the texture for specular is something I believe from google Specular Intensity(RGB) Smoothness(A)

#

I would try using another tool to convert your texture, but I'm not sure what to suggest as substance painter does it all for me I never had need πŸ˜‰

#

as creating shader graph is overkill in this situation

grand jolt
#

first time i ever made a PBR texture or even heard about it was yesterday so yeah i got no idea what I am doing

thick fulcrum
#

what did you use to make the texture?

grand jolt
#

Materialize

thick fulcrum
#

was just glancing at a tutorial, but looks like they use photoshop to combine the textures... perhaps Krita might manage as a free open source alternative if no PS

#

hmm actually should be able to do it in materialize, I'd start there add a metallic map to your setup and export that.

#

extra info in general for metallic workflow texturinghttps://medium.com/gametextures/metallic-magic-2dce9001fe15

Medium

Metalness Maps and Workflow Explained

grand jolt
#

thankyou draydak. i just updated to HDRP and it destroyed every single material in my project. all i wanted was a height map. i hate unity.

#

even when i remake them they are now black. ngl im angry

thick fulcrum
#

it's reversible, not that hard to do. Unity is not at fault for lack of understanding how textures and shaders work. Backup before any major changes is always advised, standard practice is to use a git repository for speed of backups and changes.
I would advise a good model and normal map over height mapping almost any day to be honest, much better performance.

delicate veldt
#

Right now only shadows in view of the main camera are being rendered....

Is there any way I can make it so they are always rendered? I'm doing weird camera shenanigans and I need the shadows always on.

thick fulcrum
#

I presume you have checked render shadow options on the second camera?

#

or maybe I should ask which pipeline are you using standard, universal or HDRP?

fervent tinsel
#

@grand jolt there are free channel packing tools. Even ones made for unity

#

Additionally if you really have to use individual textures you can by making a custom shader with shader graph

grand jolt
#

@thick fulcrum You're right, of course. It is my fault. I did not realise the significance of changing the render pipeline. Thankyou Olento i just found a free packer asset. That will be an incredible help!

winged pelican
#

Hello, working on asphalt shader graph, and I want to create holes. Wondering, are there any noise that I can use for it ?
Problem with simple noise, that the holes are too round, and looks bad.
Any tips ?

grand jolt
#

@thick fulcrum can i get ur water shadr graph , i want to compare with mine , its still not working

thick fulcrum
#

@grand jolt on one hand I would be happy to, but I modified mine so much that it's a messy monster (I need to tidy it). I also disabled the foam aspect as I was not using coastal foam, instead I was going to work on wave tip foam.
For my game I wanted large ocean areas, so I also added in 2 extra layers of normal map scaled to reduce tiling effect based on distance from camera.
Hence it is in a big need of clean up...
I will make a clean one to check this issue and make edge functioning foam.

grand jolt
#

its ok np ,

#

all good

thick fulcrum
#

@winged pelican you could stretch the noise UV or blend offset samples of noise together. sure there's better ideas though πŸ˜‰

wraith wing
#

hi guys, trying to make water animation graph. how to make the curve wiggle?, (somewhat like warp in substance designer) thanks...

regal stag
#

@wraith wing Try adding some noise to the uv (I guess as the 'Offset' input on the Twirl node)

wraith wing
#

thanks, more less it's work... @regal stag
anyway is there's anyway to transform 2d? (scale, rotate, move position) of shade in unity like substance does?

winged pelican
#

@thick fulcrum Thank for your tip. Combined Voronoi with simpe noise did what I want

wind obsidian
regal stag
#

@wraith wing To scale/offset the output you would adjust the UV input. You can use the Tiling And Offset node, to tile/scale and offset/move it (which is equal to UV*tiling + offset so you could also use multiply/add nodes instead). For rotations, there's a Rotate node. Could probably also do some transforms via matrix multiplication.

wraith wing
#

ok thanks, that's what i looking for.
also for the last, my vornoi edge too sharp, is there's any way to "smoothen" it out>

regal stag
#

@wind obsidian If it's made in shadergraph, I believe there's a "Two Sided" option on the master node. Or since it's a custom mesh you could just duplicate the geometry and flip the normals.

wind obsidian
#

Where is the master mode?

regal stag
#

It's the node at the very end with all the inputs, probably the Unlit one right?

wind obsidian
#

yes

#

found it

regal stag
#

There's a small cog at the top of it, the option should be there

wind obsidian
#

ye got it, thanks!

regal stag
#

@wraith wing I'm not really sure what you mean by too sharp. Maybe something like put into a Power node, multiply with a small value, then subtracted from the original?

#

Or maybe just clamp?

wraith wing
hoary citrus
#

Is there a way to use a world bending shader to bend your existing objects that have let's say one type of texture, instead of having to create separate textures on the game object in order for the curve affect to work? Case in point I have a platform I created in Paint3D (don't stone me) where I created a simple football field type platform with the numbers of the lines and coloring etc. The tutorials I've been following each has it where you have to have individual textures within the gameobject in order for the bend affect to work...sorry trying my best to explain what I need help with

lament bramble
#

hi guys! i have a lake and a river with 2 different shaders (URP). In the area, where both overlap, I would like to set the alpha of the lake shader to 0. Could someone give me a hint how to do this? πŸ™‚

devout quarry
#

You could work with vertex colors

#

multiply alpha with 1 of the vertex channels, then paint the alpha with PolyBrush

naive coral
#

how do i apply a transparent texture over another material

#

for example a checkerboard texture on top of a blue material

lament bramble
#

the terrain is procedurally generated and i want to find a solution by code, not by the editor, so I'm afraid i cannot use the PolyBrush tool

devout quarry
#

so the water is procedurally placed as well?

lament bramble
#

yes, i generate a mesh by triangulating a polygon representing the shore

#

same for the river, it's a triangulated bezier path

meager pelican
#

If you're dealing with intersecting shaders, you'll probably want to look into some form of masking such as stencils and both shaders need to be aware of each other.

lament bramble
#

ok cool this might be it. the information on google about urp and stencils are sparse but i will try to work it out - thank you very much!

slate stump
#

not sure if this is the right channel but im having an issue with using a sprite renderer in 3d. i was trying to have the sprite be effected by lighting so i gave the object a material with the sprite/diffuse shader but when running the sprite is just completely black and ive got no clue how to fix it

royal sluice
#

guys, how do I use the emission of this texture, only in occlusion? and thaf working at mobile

meager pelican
#

@royal sluice OK, the "occlusion" port is for ambient occlusion, it's a float from 0 to 1. I don't think you want to dump the RGB color in there (you're just taking the red value). I think you want that texture to emit during nighttime, right? Is that what you're trying to say?

naive coral
#

how do i apply a transparent texture over another material
for example a transparent checkerboard texture on top of a green material

meager pelican
#

Multi-materials I suppose.

naive coral
#

i tried using multi materials but they dont show up on andorid

#

why

meager pelican
#

Oh, lol. IDK. Android. And there's 50,000 levels of "android". So IDK. πŸ˜‰

naive coral
#

:(

royal sluice
#

@meager pelican so let's say I'm making a globe (like in the picture) how do I emit light using texture, just on the occlusion side?

naive coral
#

do you know where i can get help on this

meager pelican
#

Someone here will probably answer eventually. I'm just not the right one.

#

@royal sluice You mean "night" side, right? Occlusion is for "corners".

royal sluice
#

@royal sluice You mean "night" side, right? Occlusion is for "corners".
@meager pelican eah night side

meager pelican
#

OK, do you have only one "sun" lighting it?

royal sluice
#

yes

meager pelican
#

The thing is, the lighting happens after the coloring. And you don't want it to emit when it's not lit. So you need to figure out if it WILL BE LIT in the future, or not.

But if you have a light, and a surface normal, it's not too bad at all. You can tell if it's "lit" by the sun or not by checking the direction of the surface normal relative to the light location. Similar to what's done in something like phong shading. That's one way.

Lemme find out a formula or something. It's a dot product IIRC, I should have it memorized but I don't. Hang on.

royal sluice
#

ok, i'm wait

meager pelican
#

A simple Lambert lighting calc is basically
half NdotL = dot (s.Normal, lightDir)
multiplied by color.
Now, checking that value will tell you if it's facing toward or away from the light.
You'll have to have a vector fed in for the light direction (like subtract the center of the earth from the light position, normalized). That will give you the light direction vector, or maybe the other direction of subtraction. Play with it.
And check what NdotL returns, you'll have to play with it I'm not firing up Unity right now.

#

Then you can do some conditional or something.

#

You just need the NdotL value and then check it against <some-value>.

royal sluice
#

man, I can barely mess with the pbr knots lol, i have no idea how to do that you said

meager pelican
#

In for a penny, in for a pound. Hang on, will start up unity, make an example.

Did you say you were in URP?

royal sluice
#

yeah, i'm...

meager pelican
#

You're using textures, I just passed two colors in, so you'd do the lookups. But this example makes it "red" when it's "night". You'd have to play with the value in the comparison node.

That's one way.
YMMV

#

@royal sluice

#

And you'll have to calc and pass in the light direction vector.

royal sluice
#

@meager pelican

meager pelican
#

Yeah, basically, check the "x" value in the comparison and fiddle with it until you like what it does. That's the "sensitivity" basically, it's comparing the result of the dot product to what you want. You don't need that red color thing.
And I'm assuming you passed in the light direction (earth location - sun location, normalized...I think)

#

From the C# side

royal sluice
#

but, i like this... Thankz @meager pelican

meager pelican
#

πŸ™‚

naive coral
#

why is my texture not showing

meager pelican
#

@naive coral Maybe show your material inspector. Is that texture on the cube?

naive coral
#

the texture is on a very flat cube

#

a very thin cube

meager pelican
#

I don't see the texture on it. (the little box beside "Base Map")

naive coral
#

how do i get it to appear in the basemap box

meager pelican
#

I think you can just drag and drop it in there.

#

Or click on that little circle thing.

naive coral
#

oh yay it works

#

thanks

meager pelican
#

πŸ™‚

naive coral
#

hold on

#

wait a second

#

now its just black

#

its not showing the white stripe

#

or the little arrows

#

nvm i fixed it

atomic glade
#

How can I set a property in a shader/material that affects only that one object and not everything that shares a material with it?

#

Doing material.SetInt changes it in the material asset, so if I have it for something like a subimage in a sprite sheet, if I update one it updates all of them

worldly steppe
#

Hi everyone, I'm still very new to shaders. Can anyone help me convert an old shader code into a PBR shader graph? I was trying to use a particular shader, but when I import the material to URP, it broke the material.

( Error:
test material was not upgraded. There's no upgrader to convert Custom/SpriteShadow shader to selected pipeline UnityEditor.Rendering.Universal.UniversalRenderPipelineMaterialUpgrader:UpgradeSelectedMaterials())

soft harness
#

Glossy Sprite?

grand jolt
#

I know it's a bit late but is anyone up available to help?

#

I'm trying to get the world UV coordinates projected on to my surface shader/mesh

#

So the green should be the colours in the background

#

the colours in the background are a visualization of world UVs

grand jolt
#

Nevermind got it fixed

marsh sparrow
#

How can I set a property in a shader/material that affects only that one object and not everything that shares a material with it?
@atomic glade You could duplicate the material whilst creating the game object and assign the duplicate as the material of the gameobject. Now you can just modify the material that is on the gameobject and the others will be fine.

regal stag
#

@atomic glade If you get a reference to the renderer and call renderer.material at runtime (e.g. in Start(), rather than using .sharedMaterial or a public Material mat) it should create an instance of that material and assign it automatically. You need to destroy the material manually though when you are finished with it (e.g Destroy(renderer.material) in OnDestroy()). Could also use Material Property Blocks which are set per renderer, (unless you are using URP + SRP batcher as I think it breaks the batching so material instances is better in that case).

#

@worldly steppe Custom shaders won't be upgraded automatically, you'll have to rewrite it manually.

soft harness
#

wut

#

nvm fixed it

wild marlin
#

going nuts over here.. getting reports of errors from users.

#

they're getting D3D shader create error for vertex shader [0x80070057]

#

a ton of them

#

varying hardware

#

NVIDIA GeForce GT 540M, NVIDIA GeForce GT 555M and some Intel Chipsets which well.. probably shouldn't work

#

but even on a NVIDIA GeForce GTX 1050

#

not sure if that's the problem, but an older build works.. from before we switched to using the post processing stack (v2)

royal gazelle
#

I have some DXT textures I'm downloading at runtime (created via Compress and loaded with GetRawTextureData/LoadRawTextureData). I could save the width/height somewhere, but am I right in thinking I could look in the byte stream? I tried an example I found, but it's not working. Does Unity create the header info when using Compress?

#

I just had a poke around in some files... I don't think it saves headers

meager pelican
#

@wild marlin Do all those cards support DX11? And are the users upgrading their drivers? Otherwise you'll need a DX9 compatible build or set your min standards to DX11. Guessing though. From this:
https://forum.unity.com/threads/d3d-shader-create-error-for-shader-0x80070057-vs_5_0.355433/
See bottom here too: https://github.com/HouraiTeahouse/FantasyCrescendo/issues/127
And https://blogs.unity3d.com/2017/07/10/deprecating-directx-9/
Might want to add a DX11 check of some sort if you don't already.
Guessing, trying to help. Exuding optimism.... πŸ˜‰

Unity Technologies Blog

We will be removing support for DirectX 9 on the Windows platforms; as a result Windows XP will no longer be supported by default.
When will it happen?
U...

#

The 1050 should though, right? Unless they're running it on some old Win 7 or some damn thing with old drivers

humble briar
#

DX11 is supported on like everything from the past decade

meager pelican
#

I know, that's why unity dropped support for DX9.
But there are people that run old crap, for various reasons, including old drivers.
Like I said, just guessing.

#

The error seems to be (via a google check) associated with lack of DX11

humble briar
#

Even stuff like the GT 4xx series from nvidia has DX11 support

meager pelican
#

IF THEY INSTALL IT, sure. πŸ˜‰

#

not sure if that's the problem, but an older build works.. from before we switched to using the post processing stack (v2)
@wild marlin
A lot of those links indicate PP problems when lacking DX 11, DOF is one.

wild marlin
#

Oh, replies! πŸ˜„ reads

#

from their DXDiag readouts it seems that they have installed proper support

#

i'm getting feature levels: 11_0,10_1,10_0,9_3,9_2,9_1

#

@meager pelican

#

the post processing stack is using #pragma target 3.0, which should.. be fine, right?

#

(the uber shader that is)

meager pelican
#

Well, per this that's DX 9 level so IDK.
https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html
Of course that's only the shader min level compile code, not a system check in your code.

So IDK. If you're getting 11 out of DX diag, that's not it.
You need a bug report or something with Unity, or unity support.
Got any more info than that one line?

#

Is it your custom PP shader, or unity's? Which shader? All?
@wild marlin

wild marlin
#

gotta run, but yea it's like a million shaders... so it seems like something else is off

#

we found that we were prewarming all the shaders at the start of the game

#

so that might have been it

#

megaderp

meager pelican
#

lol

wild marlin
#

sending a build to a user now

#

so yea, let's just hope that did it

meager pelican
#

Exuding optimism here.

wild marlin
#

oh yea

#

thanks for the input btw πŸ™‚

meager pelican
#

I didn't do anything other than spitball.
But I wonder if like DX12 variant tried to pre-warm on DX11 or some dang thing. I wouldn't think it should. I'd be surprised that any not-acceptable variant would try to warm.

But maybe it's something like an out-of-memory or weird thing. Let us know I'm all curious now.

wild marlin
#

yea that's what i'm thinking too

#

it tried to warm up aaaaaall variants, even incompatible ones

#

or something

#

i'll write if i figure something out πŸ™‚

#

gotta run now though

#

time to pick up the kid and some pizzas 🍹

meager pelican
#

;)
You might be on the right track (when you get back). Too bad there's no resolution in that post.

solemn cipher
#

Oh, that's exactly the issue. Such a shame that there was no resolution there, yeah πŸ˜›

meager pelican
#

Unity recommends shader variant collections instead. But if you need a quick-fix, you might just remove that warmup and let the pieces fall where they may. :2c:

solemn cipher
#

Yes, we saw that too. Do you have any experience with working with variant collections? From what we could gather there could be problems with generating collections for devices (eg. Nintendo Switch)?

wild marlin
#

There we go, I'm on the tram (corona wagon). Yep, looks like we're on the right track indeed.

#

To hell with prewarming, I say. There might be a minor tiny hickup when loading into levels, but we're not on mobile anymore so that should be fine i think.

meager pelican
#

(corona wagon)
@wild marlin
Hope Not!
Insert cliches here: "These Times" "Stay Safe" etc. Wishing you the best. We're [mostly] wearing masks now in The States.

No experience with them. Looks interesting though.

wild marlin
#

Should probably get myself a mask (or 500). Think i have too much beard for them to work though...

meager pelican
#

Yeah, they don't work well with that. Mostly the masks (unless special) are for reducing particle cloud FROM you to protect OTHERS. So it has to be an "everyone does it" thing. As I understand it. But unless N95 or higher (or whatever your country calls it) it won't filter out the virus aerosol. Watch out for rashes 'n stuff on the kiddies too (Google "Covid Toes").

wild marlin
#

Hm! Haven't heard of that toe thing before. Cheers.

wild marlin
#

@meager pelican it worked! woop

visual flower
#

I am reading this topic about Unity's editor shader. Tim-C pastes some code for 2 files: SceneViewSelected.cginc AND SceneViewSelected.shader.

How are those two files connected? All the shaders I have seen only use a .shader

regal stag
#

@visual flower Shader passes can have #include "SceneViewSelected.cginc" which is like copying the entire file into the pass. It allows you to organise things nicer and reuse code in multiple passes.

mental bone
#

Hey guys I'm making a simple distortion shader with shadergraph for URP abut I have a problem. The screen position and scene color nodes dont seem to work in VR single pass instanced. Any ideas on how to make them work ?

visual flower
#

right, and im an idiot for expecting to see the include at the top, when its in the middle haha

#

makes sense now, thanks @regal stag

uneven wharf
#

hi, I'm trying to use an unlit shader graph, but when I apply it to an object it just disappears, even though the material's thumbnail display correctly

#

could someone please help?

regal stag
#

The Vertex Position input is expected in Object space

#

If you put a world space position into it, it's not going to be rendered in the correct place

uneven wharf
#

that's it, thanks so much @regal stag !

visual flower
#

I guess this is pretty old and things have changed, and this is way above my level but I figured I would try and test around with it a bit @regal stag .
Unity complains about syntax error

// #0: things that are visible (pass depth). 1 in alpha, 1 in red (SM2.0)
 Pass
 {
  Blend One Zero
  ZTest LEqual
 Cull Off
ZWrite Off
// push towards camera a bit, so that coord mismatch due to dynamic batching is not affecting us
 Offset - 0.02, 0

 CGPROGRAM
 #pragma vertex vert
....```

"Shader error in 'SceneViewSelected': Parse error: syntax error, unexpected '-', expecting TVAL_VARREF or TVAL_NUMBER at line 91"
#

What would be "todays" way to achieve this in Unity?

#

sorry I forgot to say its the Offset - line

regal stag
#

Uh, I'm not sure sorry, maybe someone else knows though

#

@visual flower Actually, it might be the space. I think it should be Offset -0.02, 0

visual flower
#

aight np, thanks :)

#

Im giving up, modifying this without understanding anything about shaders is impossible lol

cerulean mountain
#

Hello guys, I'm making an RTS, and I want a selection circle for units. Is there a simple way to draw a circle on a plane and scale it without it getting thicker and without making a new circle texture for each diameter?

cerulean mountain
#

HELP: what does Albedo mean? is it possible that it has no alpha? and what could I use that has alpha?

devout quarry
#

albedo -> base color of the surface

#

and check the import settings of the texture you're using

#

if the texture has values specified for alpha, you can use them for transparency

cerulean mountain
#

how can I get this to make the background transparent:

o.Albedo = float4(0, 0, 0, 0);

devout quarry
#

did you set the 'Tag' to 'Transparent'?

cerulean mountain
#

yes

fervent tinsel
#

use Alpha value

#

ummm

cerulean mountain
#

this the sewn together piece of shader that I have pasted together from varios sources

fervent tinsel
#

doesn't the built-in renderer still use color instead of albedo

#

ah, its albedo

cerulean mountain
#

I litteraly have no idea what I am doing

fervent tinsel
#

either way

#

use Alpha

#

literally o.Alpha

cerulean mountain
#

still just black

fervent tinsel
#

maybe that part of the code just never runs

#

try setting it without that if

#

see if it works

cerulean mountain
#
                        if (d > _Radius && d < _Radius + _RadiusWidth)
                        {
                            o.Albedo = _Color;
                            o.Alpha = 0;
                        }
                        else
                        {
                            o.Albedo = float3(0, 0, 0);
                            o.Alpha = 0;
                        }
#

still black

fervent tinsel
#

if your material itself set to transparent?

#

I don't mean shader now

#

literally the material

#

its been ages since I've done shader work on built-in but on SRPs you can set the materials mode to different than what's defined on the shader itself

cerulean mountain
fervent tinsel
#

anyway, how I'd start to decipher that myself is that I'd check some shader that is known to work and see how the shader setup differs for it

cerulean mountain
#

I do not know of any "material mode"

fervent tinsel
#

also would recommend highly using ASE or even free shader forge unless you really want to write shader code by hand

#

wonder if the setting was on the mesh renderer instead

cerulean mountain
fervent tinsel
#

could try adding ZWrite Off

last robin
#

you could do

if (d > _Radius && d < _Radius + _RadiusWidth)
{
  discard;
}

Not sure if that works in surface shaders, but it should

#

I think it's black because you have no blend mode set

fervent tinsel
#

I always cheat on these and see what either some stock shader does for these or just use node graph to do same thing and see the generated code

last robin
#

ie: add Blend SrcAlpha OneMinusSrcAlpha to the top of the subshader

fervent tinsel
#

that would make sense

cerulean mountain
#

you could do

if (d > _Radius && d < _Radius + _RadiusWidth)
{
  discard;
}

Not sure if that works in surface shaders, but it should
@last robin that works

#

now, the next step is to somehow get the transform model scale inside the shader

#

to have circles of different sizes depending on the scale of the quad they are rendered on

#

but all circles with same thickness

#

any clues?

last robin
#

you want radius to be scaled based on the object size? I suppose you could multiply radius by max(xScale, zScale) assuming they're always going to be flat on the xz plane

#

the tricky bit is getting those 2 scales

#

you could set them as a property

#

or you could pull them from one of the matrices

meager pelican
#

Are you sizing the quad appropriately already?

last robin
#

oh actually this could probably be done much simplier, if the circle is always in the center of the object anyway, assuming you have uv coordinates you could calculate the float d = distance(float2(0,0), uv);

#

your radius wouldn't be in world units though if that matters

cerulean mountain
#

I don't fully understant

meager pelican
#

There you go. But it's float2(.5, .5)

last robin
#

ah true

meager pelican
#

That's where I was going too. πŸ˜‰

last robin
#

basically try this float d = distance(float2(0.5,0.5), IN.uv);

cerulean mountain
#

that breaks the whole thing

#

now it's a yellow plane

last robin
#

oh i guess it's uv_MainTex in your case

meager pelican
#

He'll have to change his width to be a % of the quad size.

cerulean mountain
#

oh i guess it's uv_MainTex in your case
@last robin shader does not have a texture

last robin
#

i'm not a surface shader expert as you can tell

#

i don't know how that works in surface shaders, but it you could just throw a _MainTex("_", 2D) = "white" {} at the top even if it doesn't have use a texture

meager pelican
#

The radius would be from 0 to .5 the width would be like .1 or .05 or something.

cerulean mountain
#

basically try this float d = distance(float2(0.5,0.5), IN.uv);
@last robin still this doesn't work

last robin
#

float d = distance(float2(0.5,0.5), IN.uv_MainTex );

#

and if that doesn't work throw _MainTex("_", 2D) = "white" in the properties section

#

it might just be zero without any texture idk

meager pelican
#

You have to fix the ifs. Publish code again so we know where you're at. Too many edits.

cerulean mountain
#

not same thickness now tho

last robin
#

ah hmm

meager pelican
#

The thickness will be a % of the quad size.

#

Bigger quad, bigger circle if the % stays the same. So you'll have to scale that based on whatever. But you can pass that in from C#

cerulean mountain
#

is there no way inside the shader?

meager pelican
#

It's all relative. Sure there's probably a way. But how do you define, in human terms, how thick it should be. You have to be able to describe it to code it. So what defines the thickness?

#

World units?

#

Object units?

#

screen space size?

cerulean mountain
#

world units

meager pelican
#

OK, but that will scale with the quad.
World units will NOT scale with the quad.

#

Oh, edit.

#

OK

cerulean mountain
#

well then that should be possible right?

#

the whole scaling normaly but the inner thickness using world units

last robin
#
float d = distance(_Center, localPos);
if (d > _Radius && d < _Radius + _RadiusWidth)

float3 xBasis = float3(unity_ObjectToWorld._m00,unity_ObjectToWorld._m10,unity_ObjectToWorld._m20);
float3 zBasis = float3(unity_ObjectToWorld._m02,unity_ObjectToWorld._m12,unity_ObjectToWorld._m22);
float scale = length(cross(xBasis,zBasis));
if (d > _Radius * scale && d < _Radius * scale + _RadiusWidth)
{
  discard;
}
jovial onyx
#

Hi, I'm trying to add #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" to a custom node in shader graph, but when i add it it throws Shader error in 'hidden/preview/CustomFunction_6AB1134F': redefinition of '_Time' at /Users/Bri/Test2020/Library/PackageCache/com.unity.render-pipelines.universal@9.0.0-preview.14/ShaderLibrary/UnityInput.hlsl(37) (on d3d11), anyone has met the same proeblem? is there a way to see the actual generated shader ?

last robin
#

that should do it

#

basically scale the radius by the area of the quad

#

it's basically grabbing right*xScale and forward*zScale from the matrix

#

and the cross product gives you a vector with a length of the area of a quadrilateral formed by those two vectors

meager pelican
#

@jovial onyx right click on the master node and it should give you an option to see the code. But it MIGHT be that it's already included.

cerulean mountain
#

@last robin it does scale, way to much

#

if I scale the quad (which is 1Β² unity unit big) to more than 1.6 the circle is outside of it

jovial onyx
#

@meager pelican I'm adding that because i need a function from there, and looks it's not imported because i get an not defined error

#

i'll check that

cerulean mountain
#

basicly I'd want the circle to always stay inside the quad, not leaving the edges

#

when scaling the quad up

#

I hope you understand what I mean

last robin
#

ah yeah float scale = sqrt(length(cross(xBasis,zBasis)));

visual flower
#

I cant seem to find any working "inset"/"inline" outline shaders for Unity, which I find strange. Anyone ever heard of one/seen one recently?

cerulean mountain
#

yesh

#

tho it isn't perfectly at the border of the circle, it scales perfectly

#

stupid me, I can just adjust the radius in the shader material

#

now it is, on a radius value of 0.4

last robin
#

it's not at the edge because you've defined the radius width to go beyond the radius

#

so radius of 1 means the outer right will be > 1

cerulean mountain
#

mhh, how could we make it that a radius of 1 does mean it barely touches the edge?

last robin
#

you can change it to if (d > _Radius * scale - _RadiusWidth && d < _Radius * scale) if you want the radius width to be the inside of the _Radius value

cerulean mountain
#

great!

#

its not 1 but 0.5, but whatever

last robin
#

well it is a radius not a diameter

#

quad of size 1,1 would have a diameter of 1

cerulean mountain
#

yeah, makes sense. well it works perfectly and exactly how i wanted it

#

@last robin thank you for the help!!!

#

and there I was close to despair, using a line renderer xD

#

um, one last thing, how can I make the ring semi transparent?

last robin
#

then use o.Alpha i guess? not sure about what you do in surface shaders

#

but that basically enables alpha blending

cerulean mountain
#

ie: add Blend SrcAlpha OneMinusSrcAlpha to the top of the subshader
@last robin that is already there, and was when you wrote it

#

still doesn't draw alpha

last robin
#

oh

#

post your code i'm not sure

cerulean mountain
#

bah too long

last robin
#

well you need ZWrite Off too

#

not sure if that's the enough to fix it though

#

also maybe try #pragma surface surf Standard fullforwardshadows alpha:blend

#

looks like that might be how surface shaders do it?

cerulean mountain
#

yea

#

but now its lit

#

and since it's a part of UI of sorts, I need it to be Unlit

#

ignoring all stuff with light and shadows

last robin
#

idk how to do that

#

probably another pragma though

shy spruce
#

so i want to make a kind of laser beam for my character

#

and btw its in 3rd person

#

ive been using shadergraph, with a linerenderer, but the texture looks flat

#

is there a way to curve it somehow so it looks more cylindrical

#

or should i instead try to procedurally generate a mesh

jovial onyx
#

@shy spruce what do you mean to "curve"

meager pelican
#

They're probably (ideally) looking for a volumetric-ish laser beam...cylindrical.

#

Line renderer does flat stuffis.

shy spruce
#

how do i get around this?

#

like make a curved surface

jovial onyx
#

I'm using GetMainLight() hlsl code, but the color is always set to black even on a scene with a sunlight, anyone knows why?

meager pelican
#

You can A) Use a particle system type of thing B) use multiple lines in a funky pattern instead (I've done that with like 3 narrow line renderers offset with sin waves 'n stuff) C) research volumetric rendering (but you won't be happy), D) use a cylinder

What makes most any of it look "round" is lighting/shading.

shy spruce
#

i think ill use a cylinder

#

thanks for your help!

jovial onyx
#

Using Cylinders and a shader with color by normals should be fine i think

meager pelican
#

np, just my 2c

Brian, IDK. lemme help dig around.

#

sec

jovial onyx
#

Ok thanks!!

meager pelican
#

@jovial onyx What pipeline/shader. Is it URP by chance?

jovial onyx
#

yes

meager pelican
jovial onyx
#

It's URP, i really don't know if i have to set up that th direction light is the main light for the scene

#

the shader is now compiling

#

it's not that problem

meager pelican
#

Well, since it's called GetMainLight() I'm kind of betting you do.

regal stag
#

Maybe check that the Main Light is enabled in the pipeline asset

#

I think the main light is the "Sun" source in the Lighting tab too. Although if it's not set, it should just use the brightest directional light available.

spark crystal
meager pelican
#
#if SHADERGRAPH_PREVIEW
    Direction = half3(0.5, 0.5, 0);
    Color = 1;
#else
    Light light = GetMainLight();
    Direction = light.direction;
    Color = light.color;
#endif```
#

From

jovial onyx
#

Yes i'm using that exact tutorial

#

void SceneLight_float(out float3 Direction, out float3 Color) {
  #ifndef UNIVERSAL_LIGHTING_INCLUDED
    Direction = float3(0.5, 0, 0);
    Color = float3(1, 0, 0);
  #elif defined(SHADERGRAPH_PREVIEW)
    Direction = float3(0, 0.5, 0);
    Color = float3(0, 1, 0);
  #else
    Direction = GetMainLight().direction;
    Color = GetMainLight().color;
  #endif
}
#

using that because it doesn't compile the original code

#

Found it

#

It was on the URP Asset inspector

#

My fault, it was on disabled because i assume i messed up some days ago when i was testing everything

#

Thanks @meager pelican and @regal stag ❀️

grand jolt
#

If I multiply it for a color I wont get a preview (I cant see the sprite if I use it).

worldly steppe
#

@worldly steppe Custom shaders won't be upgraded automatically, you'll have to rewrite it manually.
@regal stag Ah I see, I tried rewriting it on a new standard surface shader file and I have the same error. Is there a specific shader type that I have to use? Also is there a starting standard shader template for the URP that I can use?

distant pawn
#

I've been trying to get the toon effect from this video: https://www.youtube.com/watch?v=joG_tmXUX4M to work for URP as it only works for LWRP atm. I went through and changed all (i think) the LWRP references to URP in the shaders and scripts, which got rid of all the errors and the materials stopped being the error texture (purple) but now I don't know what to do. I went through all the Data files (custom srp files) and checked they were all correct, but still nothing is changing. And yes, I have definitly applied the main SRP setting to the Graphics tab in settings. What would I do next?

quaint tree
regal stag
#

@grand jolt Check the alpha of your colour, it's set to 0 so the resulting sprite is fully transparent.

#

@worldly steppe Sadly URP doesn't have any support for surface shaders, you have to write vert/frag ones instead (with a few differences like using HLSLPROGRAM/ENDHLSL instead of CGPROGRAM/ENDCG and include URP's ShaderLibrary files & functions rather than UnityCG.cginc ones).
There's some nice examples here : https://github.com/phi-lira/UniversalShaderExamples and a nicely commented PBR example : https://gist.github.com/phi-lira/225cd7c5e8545be602dca4eb5ed111ba

You can also use Shader Graph to create a shader instead, and can even use it to generate code which you could edit later if you need to tweak something that shader graph can't do.

meager pelican
#

@quaint tree Well, since what you're doing is "filling it in with a material" that implies that you're going to ADD some meshes or distort the exiting one.
You didn't include any details as to what pipeline or hardware you want to run on.

I can think of several general approaches:

  1. Adding meshes that intersect/overlap...like mesh particle "blobs" placed somewhat randomly. Depends on how "permanent" you need it to be, or if it's some temp effect like a quick animation that you can later swap out for a "canned mesh" or something.
  2. A canned mesh that you truncate somehow or maybe procedural mesh, tessellated if you can, that you build dynamically.
  3. A "flat" plane that you treat like water, but it's not moving in waves except at the weld-point...it's opaque silverish/color-distored water. Masked off as to "filled vs not-filled". So check water shaders. Again, tessellation would help you get the details in place particularly at the edges.
  4. some form of volumetric metal, like you'd do for any liquid (ugh).
  5. distortion of the original mesh, like vertex distortion, maybe combined with a mask/map of some sort to indicate surface type and coloring differences.

/spitballing

#

P.S.
Are you building terminators? General rule of thumb is "Don't build terminators." πŸ˜‰

#

@distant pawn That video is for a post-processing effect that is a "posterize" I think with outline. Is that what you're doing?

quaint tree
#

@meager pelican Thanks for the detailed answer! The goal is to run it with ARFoundation on iOS and Android as the reference application works like, for now my plan was to go with approach #3 of the flat plane, but in case of mobiles tessellation is not really an option, so that leaves us with texture effects.

The interesting thing is that depending on the movements (speed and shaking) of the nozzle waves are generated accordingly, so it’s not some predefined sin (whatever trigonometric function) pattern of waves...

P.S. We are building just normal robots πŸ€–

meager pelican
#

Can you support compute shaders on your mobile target?

grand jolt
#

heya im a bit confused. i want to use an additive particle shader however there isnt one for HDRP. does anyone know what i can do?

meager pelican
#

User shader graph with transparent master with an add node in the mix?

grand jolt
#

is that a reply to me? if so ill check that out

meager pelican
#

Yeah. πŸ™‚

regal stag
#

Isn't there an additive blending mode option on the HDRP Particle shader? I think the URP one does.

meager pelican
#

@quaint tree You can always calc some texture-stuff on the C# side too if you need to and/or can't support compute shaders

#

You'd think there would be Cyan. IDK HDRP off the top of my head though. But additive is additive....

#

Maybe they just change some blend mode.

quaint tree
#

Metal has got limited support of compute shaders as far as I know

grand jolt
#

@meager pelican to be honest i have no idea what you meant. is there a tutorial for this somewhere? i cant seem to add a transparent master, the default is lit master

#

i just check the pinned... found tutorials

meager pelican
#

Yeah, there's a "gear" that let's you set queue options, like transparent queue.