#archived-shaders

1 messages ยท Page 109 of 1

fervent tinsel
#

atm if you need something solid, you can't really rely on HDRP, it's still in preview for this year (or end of it if they really get it out by 2019.3)

#

a lot of things may still change

#

it does work for most parts but it's not really going to give you similar experience as released products

quaint grotto
#

my main worry is if you want to do anything major with it - it will be expected of you to have a good understanding on your own. rather than make it easier for the average person to get into it

fervent tinsel
#

if you jump in now, you have to accept that you'll face bugs and will have to jump through hoops for some things

#

like with anything, I'd suggest trying things out on your own

#

see what works for you

frigid zinc
#

i found using shadergraph much easier than coding shaders by hand.

#

but that's me maybe

quaint grotto
#

for learning i prefer to code

fervent tinsel
#

I'm actually getting bit of a pain from SG's limitations

#

but Unity is working on them

#

for example, I can do more things with ASE and that's 3rd party tool ๐Ÿ˜„

frigid zinc
#

yeah it's not perfect

fervent tinsel
#

downside of ASE is that they don't support Unity's betas

frigid zinc
#

but i find it intuitive

quaint grotto
#

i just wish i had good knowledge of shaders and the render pipeline. some people know so much about this stuff, and i find it difficult to know how to learn this topic =/

fervent tinsel
#

well, there are things that aren't intuitive on SG right now

frigid zinc
#

well i learned shaders from zero knowledge

fervent tinsel
#

like working with subgraphs

#

that's my biggest pain now

quaint grotto
#

how did you gain your knowledge on them

frigid zinc
#

i just picked at other people's work, and read up on what i didn't understand

fervent tinsel
#

but there's things coming to it that will help it

#

you gain knowledge on things by doing things IMO

frigid zinc
#

unity actually has pretty good documentation of their shader syntax

fervent tinsel
#

you can find some guides for getting started

frigid zinc
#

i forget the name they give it

quaint grotto
#

the docs are average at best imo

frigid zinc
#

ShaderLab

fervent tinsel
#

just google everything until you find the right trail to the info you need ;D

#

ah, you mean the built-in renderer now

quaint grotto
#

when i did depth textures and it has COMPUTE_EYEDEPTH(i); it never said what i was lol or what eye depth meant

frigid zinc
quaint grotto
#

i know now but at the time i was confused

fervent tinsel
#

biggest gain of node graphs is that you don't really need to know that much of the syntax

#

you can just write stuff using logical terms

frigid zinc
#

yeah you just have to look things like that up and figure out what they do

quaint grotto
#

is that a gain in the long term @fervent tinsel ?

frigid zinc
#

yes

fervent tinsel
#

yes

quaint grotto
#

100s of people who dont know how to write shaders =/ not sure on that

fervent tinsel
#

you don't have to do almost anything when you upgrade to newer engine version

#

Unity has always changed shader API that lies under it all

quaint grotto
#

i bet if you want something really fancy you will

frigid zinc
#

i shouldn't have to know how to calculate a Fresnel to use a Fresnel, necessarily

fervent tinsel
#

so updating shader code from version to another can be real pain

quaint grotto
#

i have a hard time believing it will be possible with just SG to do anything and everything

frigid zinc
#

it's nice i can drop a Fresnel node in and it's done ๐Ÿ˜›

fervent tinsel
#

if you use node graph system, the most you usually do is open the graph again and save it again

#

and it's updated to new version

quaint grotto
#

yeh but then we have future devs who wont know what fresnel does mathematically ๐Ÿ˜›

#

i had to learn it for a water shader

frigid zinc
#

and why do you need to know?

fervent tinsel
#

this is one huge advantage for all node graph tools

quaint grotto
#

because i think you should know what you are using and why

frigid zinc
#

all you need to know is what effect it provides

fervent tinsel
#

it hides the changes under hood

quaint grotto
#

if people use a fresnel because others did .. i dont think thats useful

frigid zinc
#

that's like saying you shouldn't be able to eat food unless you know how to prepare it ๐Ÿ˜›

quaint grotto
#

i used it because i read a paper that explained it

frigid zinc
#

i don't care how a hamburger is made, I just know they are delicious ๐Ÿ˜›

fervent tinsel
#

HDRP's HD Lit has distortion input on the master node too

quaint grotto
#

@frigid zinc surely not knowing how to prepare it might give you food poisoning ๐Ÿ˜›

frigid zinc
#

but i'm not the one preparing it

#

which is kind of the point

#

i'm sure unity prepared my Fresnel right

quaint grotto
#

also SG won't help you when deciding if you should do an effect in eye space, world space, obj space etc you have to dig into papers to know that stuff

frigid zinc
#

so i don't have to worry about it poisoning my shader ๐Ÿ˜›

rotund tusk
#

i dont think a fresnel node will give you food poisoning. but what do i know. im not a doctor

fervent tinsel
#

for example, when I upgraded Unity's FPS Sample from 2018.3 to 2019.1, I didn't want to keep upgrading their hacked together particle shader for each version I upgrade that project into, so I just replicated the particle shader on shader graph... now I can just open it on any future HDRP version and it will work with minimal work on my end

#

updating HDRP shaders from one HDRP version to another on shader code itself is HUGE pain

#

I've done it a lot when upgrading Unity's systems

#

it's not something I enjoy at all

quaint grotto
#

@rotund tusk if your burger comes out as magenta, its undercooked and will kill ya ๐Ÿ˜›

fervent tinsel
#

it's just a time sink

quaint grotto
#

ok how about this..

can i do fast fourier transforms in shader graph ?

rotund tusk
#

๐Ÿคท life's full of risks amirite?

fervent tinsel
#

but... if Unity actually did surface shader like approach to use SG templates, that would work too

quaint grotto
#

i will bet the answer is no

frigid zinc
#

don't get me wrong, i think it's great to understand the internals, I'm a big fan of that.

#

but it shouldn't be required necessarily

#

millions of people use computers but don't know programming, and that's okay.

fervent tinsel
#

well, IMHO, you should understand basics, but you don't have to understand everything, especially at this age when game engines are getting really complex

quaint grotto
#

@frigid zinc think of all the effects people invent and won't be able to explain how its done for us to learn though ๐Ÿ˜ฆ

#

i already hate seeing unreal engine screenshots of messy node editors on how an effect is made. give me a proper paper with explanations

frigid zinc
#

the low level programmer can provide a high level interface, so people can focus not on how something is done, but how to use it in interesting ways.

fervent tinsel
#

take game physics for example, I think it would be beneficial if gamedevs understood how physics engines work but I don't think it would help those people much to understand how they could themselves code broadphase etc individual physics engine stages

quaint grotto
#

sure that i can understand but i think if you want some real advanced stuff the high level won't get you there

fervent tinsel
#

unless you actually need some really custom physics for something but that's another deal then

quaint grotto
#

like shader forge i could not make an ocean based on tessendorf's paper

#

no way in hell

fervent tinsel
#

math tends to be pain in node graphs

quaint grotto
#

at most i could gerstner waves

fervent tinsel
#

like, if you do complex algos

frigid zinc
#

yes, a large node for every operator is clumsy

#

not like a nice clean formula

fervent tinsel
#

but most of the shaders is math anyway, difference here is that most shaders we need don't need complex math

frigid zinc
#

a node that lets you enter a formula would be nice...

#

didn't I see that once

quaint grotto
#

i dunno - the way shaders are going they are getting more and more complex

#

at least for effects

fervent tinsel
#

there will be custom function that lets you feed in shader code directly

#

they already have custom node thing on 2018.3 and earlier but it's not exposed in 2019.1 anymore

#

that custom function node will replace it

frigid zinc
#

yeah that's probably what I remember seeing

quaint grotto
#

is there a planned deadline for hdrp to be released ? i know lwrp is spring

fervent tinsel
#

it's still being worked on separate branches on SRP repo, it's not merged in yet

#

2019.3 is current target for HDRP

quaint grotto
#

ok autumn then

fervent tinsel
#

but it was earlier targeted to 2018.3

quaint grotto
#

by then i should hopefully have finished my ocean shader

fervent tinsel
#

so , if you expect it to be out next year, you probably won't be disappointed

quaint grotto
#

at least on old lighting models

frigid zinc
#

ah i found my comparison finally

fervent tinsel
#

release itself is kinda arbitrary thing, it mainly indicates that Unity is satisfied on the functionality that they can call it stable, but obviously HDPR will be getting major updates even after it's officially out

quaint grotto
#

this and new terrain system is perfect timing for my project lol

frigid zinc
#

same scene/model/textures/lighting

#

only one is standard and one is HDRP

#

(and this was something Unity released in a sneaky place)

quaint grotto
#

well there is definately a difference

#

one is less blurry

#

for a start

fervent tinsel
#

I don't really believe in comparisons like that

#

they can't do 1:1 setup on them

frigid zinc
#

yeah there's a difference. but part of me likes the Std best

fervent tinsel
#

so it's not really fair comparison

frigid zinc
#

HDRP seems like way too much i dunno, Fresnel ๐Ÿ˜›

fervent tinsel
#

you could make the built-in look better in that scene too

quaint grotto
#

at least its the same scene/artist ive seen video comparisons not even using the same artist or scene

frigid zinc
#

everything has a white edge around it

quaint grotto
#

so dumb

frigid zinc
#

yeah this is a comparison Unity hid in the documentation

fervent tinsel
#

it's totally different lighting on those two

frigid zinc
#

so i didn't make any of it

#

but it's the closest comparison i have seen

#

well it has all the same lights in all the same places

#

that's why i say same lighting

#

but yeah their values may be dis-proportional

quaint grotto
#

this is all going to be a pain to learn i think

fervent tinsel
#

there is one main thing that is going to look a lot different on built-in vs HDRP/LWRP and it's the dynamic lights falloff, built-in got errors on that which they can't fix because it would break backwards compatibility

#

but if you do baked lightmaps, that falloff is fixed even on built-in

#

to be honest, I don't really agree on the backwards compatibility excuse

#

you could just make a toggle for it

#

and it would solve that right away

#

(people could use the old way still)

#

but I do get that they don't want to keep updating the built-in renderer at this point

frigid zinc
#

well nothing about HDRP is backward compatible

#

so i don't see why they would leave anything as such

fervent tinsel
#

yeah, I'm talking about built-in now

#

like, they could have fixed the light falloff on built-n if they had wanted to do so

frigid zinc
#

ah i see

#

those scenes are in this section btw if you want to try them yourself

quaint grotto
#

in hdrp will we have to worry about making something on one platform and then writing solutions for it to work on another

frigid zinc
#

what was cool in 2006

quaint grotto
#

i have the sea of thieves paper on their water tech

#

probably the worst paper ive read in a long time

foggy agate
#

Anyone knows how to create an effect where you see with sound waves?

quaint grotto
#

@foggy agate you mean like a sonar effect?

#

to get the propogation of mesh

foggy agate
#

Oh god

#

That is exactly what I need... but I get 1/4 of what he is saying (dont know that much about shaders)

#

so I'll watch it a few dozen more times : P

#

Thanks @quaint grotto !!!

ornate blade
#

So, I have a fire shader that I made off a tutorial. Im trying to add an edge to it. So, I have applied a greater offset to a different version, which has successfully made a version which is slightly higher. I am hoping to use this as the edge, but I cant figure out how to mix them properly. Any ideas?

still orbit
#

depends on the colour you want the edge

#

if you want it to work in any colour you kinda need masks of both

#

(well, your second one there is already a mask, youll just need to also make a mask of the first)

#

use blend nodes set to overwrite mode, with the mask as the input to Amount (or whatever its called)

ornate blade
#

ahh I kind of see what you mean. I will have a go!

#

luckily, my final products were just their previous maths (which is pretty mask like), with color applied. Looks good! Im going to work on making it only apply to the top now, but thanks so much for this @still orbit!

still orbit
#

glad to help ๐Ÿ˜ƒ

tight forge
worthy hazel
#

Hey all, so it's easy to do a shader that lerps between values based on world or vertex local height, but is it possible to have variations in that height? So that the line of cutoff wasn't uniformly straight?

wraith tide
#

sure. one good way would be to provide it with a noise texture, and add it to the height for the blend calculations

#

needs to be a gradual noise texture, not random. such as a height map.

#

you can use the world XZ as coordinates within the noise texture.

worthy hazel
#

Thank you as you replied I was trying to implement it using a random noise texture. Could you clarify why generated wouldn't work?

wraith tide
#

A random (white noise) texture would have adjacent pixels jumping all over the place. for example, one pixel would have the value of 0.5, then next one would have the value of 1, and the next 0. That would mean that your blend line would be jumping up and down all over the place.
Now if you use a gradient noise map, such as perlin noise, the values would not jump from 0 to 1, but will gradually increase from 0 to 1, creating a nice, connected line in your blend.

#

Generating perlin height map is very easy:

        public static float[,] GeneratePerlinMap(int sizeX, int sizeY, float frequency, RandomGenerator random = null) {
            if (random == null) {
                random = new RandomGenerator();
            }

            // choose area in map
            float startX = random.GetRandomValue() * 1000f;
            float startY = random.GetRandomValue() * 1000f;


            float[,] result = new float[sizeX, sizeY];
            for (int x = 0; x < sizeX; x++) {
                for (int y = 0; y < sizeY; y++) {
                    float perlinX = startX + (float)x / (float)sizeX * frequency;
                    float perlinY = startY + (float)y / (float)sizeY * frequency;
                    result[x, y] = Mathf.PerlinNoise(perlinX, perlinY);
                }
            }
            return result;
        }
#

(just use Random.value instead of my custom RandomGenerator)

worthy hazel
wraith tide
#

simplex is very similar to perlin. It's not random.

#

This is what simples/perline and other heightmap noises look like:

#

you can see the difference, where one has a pattern of gradual color changes where the other is just plain random, with huge jumps between white and black

#

but anyway glad you got it to work like you wanted

fresh monolith
#

How to easily write shaders for VR/AR?I am working on an AR/VR project. The VR part is basically to show the idea in a virtual environment (with the use of Google Cardboard) , before porting it to the Microsoft Hololens (I have access to Hololens only once a month, a the current unit is experiencing some issues). I'd like to create shaders using shader graph but I decided it is best to work on the LTS (2017.4) version, which has no support for shader graph, but works best with the SDKs (MRTK and Cardboard SDK) and recommended by Google and MS. I imagine simply copying the code from 2018.2+ won't work, so I am looking for something else (Shader Forge in mind). I have issues understanding the whole thing with LWRP as I don't get it to work, unless I download a pre-made UT package.

frigid zinc
#

there's a page here about how to add VR to shaders

#

it's mostly about modifying the view transform for each pass (two eyes)

#

or probably more correctly, the screen space coodinatse

fresh monolith
#

Thanks for the docs, but the feature lists only PC and PS4 VR, the CardboardSDK is for Android.

broken field
#

Use LWRP for VR

#

it will come with shader graph and shaders so it will be harder for you to ruin performance

#

There's a version for VR/AR

tawdry hearth
#

^ this

#

Use the VR template - it has the same content (shaders etc) as regular lwrp, but some VR settings enabled. And you can use Shader graph.

frigid zinc
#

does LWRP work with MRTK and cardboard SDK? because that's his application.

echo badger
#

I have been trying my hand at making a stylized water shader with the shader graph. From what I understand I want to get the camera depth texture. But it seems to be not possible right now? Is this true?
I'm on 2018.3.4f1 and SG 4.9.0.

fervent tinsel
#

@echo badger it does work on HDRP at least, haven't tried LWRP in ages

echo badger
#

I am on HDRP. Maybe I am doing it wrong then?

#

Yeah I saw that

fervent tinsel
#

there is "Scene Depth" node

echo badger
#

oh, is that the same?

fervent tinsel
#

afaik yes

#

there isn't any other depth sampler afaik

echo badger
still orbit
#

that shouldnt be necessary at all...

worldly sky
#

Shader Graph Blackboard is throwing this, so Shader Graph is literally unusable
Unity v2019.1.0b3
HDRP v5.3.1

frigid zinc
#

Unreal has a "Bump Offset" node, i'm curious if anyone knows, does Shadergraph have something similar, or reference to how one would implement something similar?

#

from what i read here, it's a similar concept to parallax but not really the same

still orbit
#

Yep, just use tangent space view dir like bgolus says

frigid zinc
#

reticle is a bit hard to see in the gif, but this is what i made, simulates how a RDS sight works

north rampart
#

hey @urban breach just wanted to know if you had any luck with how to create the XRay effect from the Spaceship demo?

ornate blade
#

does anyone know how to do a procedural scanline? Most of the tuts that I have seen seem to use a pregenerated texture. My idea so far was to get the uv, split by y, and tile the output, but that doesnt seem to be working. Ideas?

random meadow
#

heya, anyone got any pointers on using the depth texture in orthographic perspective?

#

I can get the texture, but when I map it on to a quad it fades in the z axis (I guess as it should) but I'd like this to be a linnear color and map vertical depth

#

...trying to add a foam effect to a water shader

ornate blade
#

cant answer that ^ but I can say that for anyone looking for an answer to mine, you can just use tiling + checkerboard with 0 x. Then just offset the tile to make it move ๐Ÿ˜ƒ

echo badger
#

The more I look in to it the more it seems not so. But is it feasible to make stylized water shader with shader graph and HDRP?

frigid zinc
#

theoretically you should be able to make any kind of shader with shadergraph

#

this sample unity project is made on LWRP and does pretty nice water

quaint grotto
#

@frigid zinc thats not true

frigid zinc
#

I beg to differ

quaint grotto
#

anything with even remotely difficult math algorithms

frigid zinc
#

Shadergraph is purely generic

quaint grotto
#

is not going to happen in shader graph

frigid zinc
#

you can make anything with it

quaint grotto
#

ok make me a FFT ocean

frigid zinc
#

it's being done

ornate blade
#

you cant make an outline shader. Just sayin

quaint grotto
#

bet the math won't hold up

frigid zinc
#

the maker of Crest ocean is making a LWRP version to start out, then HDRP later

#

using shadergraph

quaint grotto
#

does that use FFT ?

#

dont think so

frigid zinc
#

just because something is hard doesn't make it impossible

fervent tinsel
#

@frigid zinc that boat demo uses extended LWRP for that water

frigid zinc
#

Crest uses Gerstner waves, I don't know if that qualifies as FFT but if not it's probably better than FFT ๐Ÿ˜›

quaint grotto
#

that does not lol

fervent tinsel
#

also afaik FFT has always been considered higher fidelity approach to ocean than Gerstner waves

quaint grotto
#

gerstner is simple sine ways with exponential

frigid zinc
#

well Gerstner looks mighty fine to me

quaint grotto
#

sure for shallow waters

#

but stormy water it looks bad

fervent tinsel
#

people use it as it's simple and cheap

quaint grotto
#

the arguement was if it was do able in shadergraph not what looks good enough

frigid zinc
#

yes this looks so bad ๐Ÿ˜›

quaint grotto
#

i dont think shadergraph can do FFT because its not a simple algorithm

#

thats a flow graph

frigid zinc
#

it's an ocean system

quaint grotto
#

yeh but i asked about FFT

#

your changing the arguement

frigid zinc
#

well that's neither here nor there

quaint grotto
#

no its not

#

you said you can do anything in shader graph i asked about FFT you then replied with an unrelated approach

frigid zinc
#

yes it is, trying to use one edge case to make a blanket statement is ridiculous

fervent tinsel
#

I thought this discussion was done like day or two ago ๐Ÿ˜„

quaint grotto
#

fft is not edge case

fervent tinsel
#

Sir has been asking for FFT on SG for a long time already

frigid zinc
#

especially when the guy asked about making stylized water

#

not realistic water to begin with

fervent tinsel
#

there can be many types of stylistic waters :p

quaint grotto
#

you made the claim that shadergraph can do literally anything. i disputed that saying FFT would be difficult

#

aswell as any advanced math algorithms

frigid zinc
#

yes and they don't require FFT

quaint grotto
#

but your claim was ... anything

fervent tinsel
#

you can't just argue out of the blue what others projects need

quaint grotto
#

ceebee: you can make anything with it

frigid zinc
#

so it's a bit ridiculous to say you can't do stylized water just because you believe someone can't do FFT on shadergraph

still orbit
#

it can do anything, its open source ๐Ÿ˜‰

quaint grotto
#

i was disputing that claim

frigid zinc
#

WHICH isn't even proven

fervent tinsel
#

lol

quaint grotto
#

i was saying you can't make anything with it

frigid zinc
#

I could probably write FFT in BASIC on an Apple ][

#

code is code

fervent tinsel
#

well, all node graph editors have pretty big limitations when you go to more custom code, especially if you need more passes or compute stuff

quaint grotto
#

exactly ^

fervent tinsel
#

dismissing that is just silly

quaint grotto
#

they are limited

frigid zinc
#

limitations are just something to overcome

quaint grotto
#

no but dont tell people you can make literally anything in shadergraph thats silly and misleading

frigid zinc
#

they aren't roadblocks

still orbit
#

honestly, you shouldnt be doing FFT in shader graph

#

just write the code

fervent tinsel
#

I mean, these are great tools, they simplify a lot of tasks but one key thing is to acknowledge the limitations of the tools so you can work around them

frigid zinc
#

i'm fine with that, I didn't ask about FFT to begin with

quaint grotto
#

shadergraph can do a lot but it can't do everything

frigid zinc
#

that's someone else's obsession ๐Ÿ˜›

quaint grotto
#

fft is the only way to go ๐Ÿ˜›

#

end of discussion ๐Ÿ˜›

frigid zinc
#

nope ๐Ÿ˜›

still orbit
#

but yes you can do good stylised water in SG

fervent tinsel
#

why can't you just agree that everyone has right to their own opinions? :p

still orbit
#

but FFT is complex, write the code ๐Ÿ˜›

fervent tinsel
#

you are just wasting each others time with pointless argument

frigid zinc
#

everyone is yes

still orbit
#

i have the time

fervent tinsel
#

๐Ÿ˜„

frigid zinc
#

but doesn't mean I have to agree necessarily heh

still orbit
#

im just fighting to get C# out of JS and obj C anyway

#

this is less painful ๐Ÿ˜„

frigid zinc
#

lol

#

i just spent 3 hours fighting with CMake, don't talk about painful ๐Ÿ˜›

still orbit
#

var points = {};

fervent tinsel
#

I hate cmake with passion

still orbit
#

please ๐Ÿ˜‰

quaint grotto
#

superior

frigid zinc
#

yes it's pretty

quaint grotto
#

lacks SSS atm

fervent tinsel
#

I have still yet to see any open source project that makes cmake work out of the box for me

frigid zinc
#

but not stylized ๐Ÿ˜›

still orbit
#

its also incredibly expensive ๐Ÿ˜›

fervent tinsel
#

well, expect for bullet I guess

quaint grotto
#

@still orbit compute shader

#

not really taxing

still orbit
#

for example Sea of Thieves spent half its budget on FFT

fervent tinsel
#

your GPU still does the work

still orbit
#

yes, its still expensive

quaint grotto
#

i have the sea of thieves paper

#

@fervent tinsel sure but not linearly like a cpu

#

its all unrolled

still orbit
#

They said at Siggraph it was half their GPU budget per frame

#

that aint cheap

quaint grotto
#

yeah i know

fervent tinsel
#

need them next gen consoles

random meadow
#

@still orbit any chance you could explain what your doing for orthographic depth in your ToonShading water shader?

still orbit
#

it sure is pretty though โค

frigid zinc
#

but fine, I will concede, you can't make any kind of shader. I retract my blanket statement

#

but you can make water ๐Ÿ˜›

still orbit
#

@random meadow I dont do orthographic. I generate world position from depth.

quaint grotto
#

@random meadow how does orthographic depth texture work =/

#

since theres no real visual concept of a depth

fervent tinsel
frigid zinc
#

yeah that's one type

quaint grotto
#

oh sure thats definately do-able in shadergraph

still orbit
#

^ this is the function

random meadow
#

@still orbit oh ok

#

yeah

#

i've been looking at it all morning

#

I'm trying to add some foam to water in ortho perspective

still orbit
#

why ortho? what are you trying to do?

random meadow
#

becuase my game is ortho

still orbit
#

ah lol

random meadow
#

๐Ÿ˜‰

still orbit
#

well at least that makes some sense ๐Ÿ˜›

#

whats the camera angle if its ortho? side? top? isometric?

random meadow
#

3/4

#

like that

still orbit
#

helpful thanks

random meadow
#

I can kinda get the depth texture and project it on to a plane, but it's not quite right

frigid zinc
#

ah i see the water there

still orbit
#

show me the depth on a plane

random meadow
#

it's almost there, but the depth on the plane fades in the z axis (as it should without any alteration)

echo badger
#

I guess I should have specified. Right now I am just trying to get a intersect line to work (Shore line). Or depth, but am unable to get either to work.

quaint grotto
#

what you mean by intersect line ? foam ?

#

you sure you cant use a second camera as perspective then linearize the depth texture from that and hopefully its close enough to not notice

random meadow
#

@quaint grotto me or @echo badger ?

quaint grotto
#

who ever is stuck with orphographic depth textures

random meadow
#

oh, me then

#

hmmm, i guess that would work

#

just feels like i'm missing some kind of transform on the depth though, rather than something that complicated

still orbit
#

well my immediate asusmption was that youre doing linear depth

#

idk maybe you are? idk what the amplify scene depth node does

random meadow
#

Nope, not linear. it has a checkbox

#

i'm doing "Eye space" (not 0-1 mapping) and non-linear

still orbit
#

well eye space will also be wrong in ortho

random meadow
#

oh

still orbit
#

depth is linear by default in ortho

#

eye expects log input

random meadow
#

ok

quaint grotto
#

you need linear depth

still orbit
#

it will be linear by default, its ortho

random meadow
#

ortho is already linear

still orbit
#

youll have to manually remap it to the clip planes if you want 0-1 tho

quaint grotto
#

i wasnt aware depth textures work in ortho

still orbit
#

yea they do

quaint grotto
#

but if thats the case whats the issue =/

random meadow
#

I think the issue is that i need to map the depth texture onto water plane

quaint grotto
#

in fragment its already mapped if you use tex2d proj function

still orbit
#

the mapping is right

#

the issue is the space of the texture

#

(probably)

quaint grotto
#

if i had to guess

#

he needs to get depth relative to water plane

#

rather than relative to camera position which is what the depth texture has

still orbit
#

yea i thought they were doing that already?

#

just using clip.z

quaint grotto
#

dunno . vague details so far

random meadow
#

hmm

#

let me look at the clipping planes when using 0-1

stone sandal
#

have you tried switching the screen depth out of eye space for funsies?

#

my debug method when Iโ€™ve double checked my math is to just check and un check all the settings lol

random meadow
#

ok, got that mapping the depth onto the plane, but it's still fading in the z axis

stone sandal
#

Iโ€™m a bit tired so this May be dumb but I wonder what happens if you subtract screen pos.y instead of w

random meadow
#

nothing ๐Ÿคท

still orbit
#

is amplify screenPos.z just clipPos.z?

random meadow
#

let me check

#

Screen Po is UnityObjectToClipPos(v.vertex)

still orbit
#

ok so yes

#

subtracting clipPos.z should definitely change it, a lot ๐Ÿ˜›

stone sandal
#

yeah pos.w didnโ€™t seem right lol

still orbit
#

well screenPos is clipPos.xyz / clipPos.w right

quaint grotto
#

dont use clip use screen

still orbit
#

but in vertex

quaint grotto
#
float depth = tex2Dproj(_CameraDepthTexture, i.screenPos ).r;
float trueDepth = (depth - i.screenPos.z) 
#

tex2Dproj will divide by w for you

still orbit
#

yea but in that example Sir, screenPos.z is clipPos.z

quaint grotto
#

no its not

still orbit
#

how is it not?

quaint grotto
#

because in vertex shader:

i.screenPos = ComputeScreenPos(i.vertClipPos);
COMPUTE_EYEDEPTH(i.screenPos.z);
random meadow
#

COMPUTE_EYEDEPTH is not happening

quaint grotto
#

well ... then good luck

#

not sure why it wont happen

#

its a helper function

still orbit
random meadow
#

the shader is generated by amplify

still orbit
#

^ ZW is untouched from clip space

quaint grotto
#

oh your doing it in amplify

#

@still orbit well sure but thats why i use tex2d proj for the w and use compute eye depth on z

random meadow
frigid zinc
#

should it be normalized or not

quaint grotto
#

i dont use editors so i cant help you with assets

still orbit
#

Ah ok, this mess is why we dont do it like this anymore

quaint grotto
#

only directions need normalizing

#

if its a point it doesn't

still orbit
#

its so pointlessly confusing

random meadow
#

i'm happy to poke in the code and then figure out the amplify version later

quaint grotto
#

is amplify abandoned like shader forge ?

#

or is it kept updated

still orbit
#

its still actively developed

quaint grotto
#

i see

random meadow
#

yeah, it's actively updated

quaint grotto
#

wonder how well they will sell with shadergraph which is free

still orbit
#

probably still doing fine for now, we are missing some fairly important features

random meadow
#

well at the moment amplify works and shader graph + lwrp is super not production ready

#

yeah, i need stencils which are still missing from shader forge

#

graph*

frigid zinc
#

they are adding HDRP/LWRP support, so i expect they will keep going

random meadow
#

yoooooooo

frigid zinc
#

though they are only supporting them via templates

random meadow
#

COMPUTE_EYEDEPTH(screenPos.z);

#

did the trick

frigid zinc
#

hmm

random meadow
#

just need to figure that out in amplify now

still orbit
#

-UnityObjectToViewPos( v.vertex ).z

frigid zinc
#

there's an object to view pos node

still orbit
#

that is SO dirty

frigid zinc
#

so shouldn't be too hard then

still orbit
#

SO SO SO dirty

frigid zinc
#

hehe

still orbit
#

treating clip pos as object space

#

then converting to world and then view

#

I need a shower

random meadow
#

hmmm

#

that's not quite same result

still orbit
#

oooooh

#

I misread

#

its a replacement

#

weird macro

#

replace screenPos.z with -positionViewDir.z

random meadow
#

ok

still orbit
#

#define COMPUTE_EYEDEPTH(o) o = -UnityObjectToViewPos( v.vertex ).z

#

this is the macro, weird one

stone sandal
#

thatโ€™s.. a couple conversions

still orbit
#

isnt it lovely ๐Ÿ˜›

random meadow
#

hang on, so what do i want?

still orbit
#

and wow im so tired, its view space position

#

you need view space position

#

.z ...flipped

quaint grotto
#

yes thats screen pos

#

you do a uv look up so you need screen pos

random meadow
#

-UnityObjectToViewPos( v.vertex ).z < so this should be correct?

quaint grotto
#

why negative?

still orbit
#

because viewspace is object > camera

quaint grotto
#

right but .z makes no sense

#

or does it

#

my brain hurts

still orbit
#

yes, it does, trust me ๐Ÿ˜›

quaint grotto
#

i can never remember half the functions

#

i hate their naming conventions

still orbit
#

all of this depth stuff in bultin renderer is terrible

#

much better in SRP

random meadow
#

ok, think i'm gonn have to write a custom node for that

quaint grotto
#

ive not read how its done in SRP yet

random meadow
#

nope!

#

found it, Surface Depth node

frigid zinc
#

you already have one in your graph ๐Ÿ˜ƒ

still orbit
#

wait what are you doing ๐Ÿ˜›

frigid zinc
#

oop my bad that's screen depth you already have

random meadow
#

surface depth yeah

frigid zinc
#

screenshot type is tiny for my old eyes

quaint grotto
#

why cant you use screen space since you already have it ?

random meadow
#

hm, how do you do code inline in discord?

#

๐Ÿ˜ƒ

#

thanks so much guys!

#

that was killing me!!

#

a fair few pips above my knowledge of 3d/shaders, so doubt i'd have ever got there on my own

still orbit
#

damn it, how do i stop it from formatting ๐Ÿ˜›

stone sandal
#

it will format everything

#

canโ€™t stop wonโ€™t stop

random meadow
#

haha

still orbit
#

omfg it even formats them indented

#

its the "tick" key

random meadow
#

ah ticks

still orbit
#

lol yea

stone sandal
#

isnโ€™t it just md formatting?

random meadow
#

sorry, i was being lazy tbh, should have just googled

still orbit
#

idk, it just matches Slack

#

its probably based on md

stone sandal
#

should be md then

frigid zinc
#

looks good.

#

and i learned a few things hehe

random meadow
#

i learnt a lot! I just don't understand half of it

#

time to go read some things

#

seriously though, thanks folks, i'm super happy with that!

foggy falcon
#

it is markdown

ornate blade
#

hey guys, my old "put world space UI on top of everything else" shader was broken by LWRP. Does anyone know where I can find a working one?

still carbon
#

@quaint grotto Amplify supports classic unity render pipeline so that's enough for them to maintain development. Last I heard, ShaderGraph had no plans to support old pipeline, only LWRP/HDRP, unless things have changed.

amber saffron
#

^ Still true.

brave tinsel
#

gentlemen. i require knowledge of shader graph

#

how can i make a material move (or extrude) a tiny bit closer to the camera? i am trying some decal work

still orbit
#

Where you would traditionally move the vertex position along its normal, move it along the view direction vector instead

brave tinsel
#

that is what i am trying to do

still orbit
#

lemme just check for you before i give advice

fervent tinsel
#

@brave tinsel worth noting that since you want that for decals, there's specific decal graph on recent HDRP's

#

unless, you just want to do decal like stuff without using decal functionality

brave tinsel
#

but i need something that can wrap. projection does not work great ;(

fervent tinsel
#

I thought you could do mesh decals too

#

but I admit I haven't tried these things myself

still orbit
#

but it depends on your use case

#

(the grey there is a cube in equal size of X, Z to the red cube)

brave tinsel
#

cool. i replaced view direction with camera direction and now the thing is being pulled out towards me a tiny bit to negate the z fighting

#

now i need to reflect on how it runs and learn from it. thanks

still orbit
#

Fwiw camera direction is just the opposite of view direction ๐Ÿ˜ƒ

brave tinsel
#

it got stuck on one axis for some reason. maybe because its all working in object space ๐Ÿค”

still orbit
#

you might need to do all the calculations in world space then convert the result back to object

echo badger
#

I am having a lot of trouble getting an intersect shader to work in Shader Graph (Like what you would see on a shield or water shader). I was wondering if someone could help me out? Weather that be a tutorial, example project, or just showing me how you get that data. I would really appreciate it ๐Ÿ˜ƒ

still orbit
#

theres a number of ways to do it

#

I linked this yesterday but:

#

In my water I converted the depth buffer to work space and used that for intersection

#

you can also do it by just testing fragemnt depth (clipPos.z) against linear depth buffer

fervent tinsel
#

(I'm rizu on the forums)

#

also I have no idea if that's doing some extra things, half of that isn't even my own graph

#

you can skip the double sided if you don't need it to show on both sides of the mesh

still orbit
#

1 - (depth.r - clipPos.z) ๐Ÿ˜ƒ

#

yes, that is the most common intersection function

fervent tinsel
#

in the graph, there was multiplication with far plane

#

that's not needed?

#

that was part of the code I just copied from other user (noted on the post)

still orbit
#

shouldnt be ๐Ÿค”

#

Linear01 already accounts for clip planes

fervent tinsel
#

ah

echo badger
fervent tinsel
#

so, one could just omit that multiplication

still orbit
#

what RP are you in?

fervent tinsel
#

also worth noting I didn't put safety clamps on the pows, so you may get something that isn't in range of 0-1 for alpha

echo badger
#

I am on HD

fervent tinsel
#

yeah, but there was some issue on earlier HDRP versions for depth node afaik

still orbit
#

post graph plz

#

and yes what package version?

fervent tinsel
#

so, if you are like on 4.1.0 HDRP, it might not work right

#

4.9.0 does work

still orbit
#

HDRP had a bug where depth returned the entire pyramid

echo badger
#

Entire pyramid? Isn't that like 3 of the same image and each one smaller or something?

still orbit
#

yup

#

also looks like this package is too old (depth node doesnt have dropdown)

echo badger
#

What the heck.... i just double checked and it is not on 4.9!? I specifically downloaded 4.9 just last night.....
let me upgrade and try it then :/

fervent tinsel
#

hmmmm, I checked the far plane thing, it is needed when scene depth node is set to linear01 but not when the node is set for "Eye"

#

docs say "Depth converted to eye space units"

#

what is eye space? ๐Ÿ˜„

#

is this like for VR ?

frigid zinc
#

screen space?

#

but yeah eye space sounds odd

echo badger
#

Okay so I ended up just making a new project. But it does work now! ๐Ÿ˜„

#

Though it does have an error of pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them

fervent tinsel
#

yeah, it's just a warning

#

you can abs it if you want to but it's really pointless if you just limit the properties input scale itself

#

and I don't think SG monitors the limits set there so the warning gets sent anyway

#

but that clamp (which I had on the image I just posted as last node) would be nice failsafe as you can get way out of 0-1 range with those pow values

echo badger
#

Okay, that is what I figured.

fervent tinsel
#

I don't get that warning myself on my finished graph but I do remember seeing it at some stage

echo badger
#

I am going to mess around with it now in a new shader to see if I can now piece together an idea of what it is all actually doing ๐Ÿ˜›

grand jolt
#

Hi! I'm working on a multi-purpose shader for my game, it allows a coat of metal on the albedo, and to get "inked" (covered by colored ink, basically)

I'm also trying to implement a decent "fade effect" / semi transparency version for stuff like hair and torn capes. But when that happens, anything under alpha / transparent parts is like "erased" here,

Anything I can do to fix that?

frigid zinc
#

pretty much what I covered in #archived-works-in-progress relating to hair. the shader she pointed out would generally fix that, it's an alpha layering issue.

#

there's a name for what the shader does but I really can't remember the name of the top of my head

#

there's a free example here

#

though as I recall when I tried it, it wasn't the best

#

this is another free example, but looks a lot better. it's nearly as good as the 20 dollar one on the store.

#

has that nice Anisotropic highlighting

#

(I got Fresnel on the brain now)

grand jolt
#

I'm looking at the source now, I kinda want to implement it in my own shader.

frigid zinc
#

i think Adam's touches on what they do in the description

#

We render the lower pass using alpha testing versus blending; this fixes a host of issues with ordering; it's a little smelly, but it works better over all.

#

basically one pass is alpha test, and the other is alpha blend

#

so you kind of get the benefits of both

#

it is a bit of a hack but that's what most hair shaders do to avoid layering issues

still orbit
#

That is definitely the recommended route yes

#

I havent looked at Adam's code but does he clip at a higher threshold then test the blend against the clip?

#

that way you dont overdraw, and only just the very edge pixels with blend

frigid zinc
#

Yeah i noticed he mentioned he used it in the description ๐Ÿ˜ƒ

#

i got both of those months ago, they are somewhere in my bottomless bag of shader stuff lol

#

And no I don't see he uses that technique, it sounds like a good idea.

#

would you just use clip() to do that, or another technique?

still orbit
#

yea discard like you would with any alphaclip, but do it at a slightly higher threshold so you discard a few extra pixels on the edge

#

like when you contract selection in photoshop to feather the edge of a rasterized shape

frigid zinc
#

makes sense, cool

still orbit
#

then do a custom depth test of the blend, with a tiny offset so it fails against the clipped one ๐Ÿ˜ƒ

#

other yea, youll get a tonne of overdraw

frigid zinc
#

I wonder if the 20 dollar shader does that, now i'll have to check hah

#

it does hehe, that guy is pretty clever

#

he has two thresholds so you can tweak both levels

still orbit
#

wth

#

why do you need two ๐Ÿ˜›

#

you need one threshold, where clip turns into blend

frigid zinc
#

cause programmers love tweaking stuff ;p

#

how much overlap heh

still orbit
#

any overlap is dumb <__<

#

thats the whole point...

#

anyway ๐Ÿ˜›

frigid zinc
#

yeah i would agree

#

but he put it there just in case anyway lol

still orbit
#

<__<

#

this is why the world needs technical artists...

frigid zinc
#

actually i'm not sure what he is doing with the second

#

does this look right

#

c.a = s.Alpha * step(_BlendAlphaCut, s.Alpha) ;

#

oh i see, yeah that's his 'clip'

#

so the way he's doing it it still draws just either opaque or transparent....

#

doesn't really save overdraw at all does it?

still orbit
#

oh hes doing it in one pass?

#

wait, thats not right

frigid zinc
#

it's two passes

#

yeah i don't think that's right

still orbit
#

so yes, it saves overdraw

#

oh wait

#

no i follow

#

his doesnt no, thats not clever ๐Ÿ˜›

frigid zinc
#

yeah i will have to fix this heh

still orbit
#

you want to get it to fail the depth test

#

unless hes doing that also, and that later code is redundant

frigid zinc
#

he's implemented it as a surface shader and that's in the lighting function

#

ok i isee

#

in the surface function he has the clip

#

so that's unrelated

still orbit
#

if not its doing double draw

frigid zinc
#

in one pass he does clip ( o.Alpha - _Cutoff );

#

and the other pass he does clip ( _Cutoff - o.Alpha );

#

so i think it's fine ๐Ÿ˜ƒ

still orbit
#

ergh, dirty

#

depth test offset is faster

#

and better design ๐Ÿ˜›

#

how bad that is depends on platform though

#

discard isnt cheap on mobile

frigid zinc
#

yeah i don't see offset is used

#

that's neat about Offset, i hadn't read up on it before, looks super useful

#

there's still a lot i have to learn about shaders

still orbit
#

offset is amazing for multipass stuff

frigid zinc
#

completely off topic but While researching something today i found this tutorial on how to change Blender Icosphere into a hexasphere: https://blender.stackexchange.com/questions/67334/how-to-turn-my-honeycomb-pattern-into-the-sphere

#

reminded me of the code from yesterday lol

#

tried his technique and it worked

#

it's imperfect though, there are a few pentagons scattered about

still orbit
#

BAHHHHHHHHH

#

you have no idea how annoying that is to me!!!

#

its a goldberg polyhedron and it has 12 pentagons regardless of subdivision. ๐Ÿ˜ข

ornate blade
#

Hey guys, just checking in once more to see if anyone has a working "World UI Text Render On Top" shader. Trying to modify Unity basic text shader, but am horrifically bad at actual shader coding.

still orbit
#

which render pipeline?

ornate blade
#

LWRP, 2018.3

still orbit
#

hmm tricky

#

youll need to take the LWRP Unlit and port the text specific stuff from the regular text shader onto it

#

i mean, i guess the default text shader should work, but its not recommended

ornate blade
#

true. I hadnt considered grabbing the source from LWRP. Its even better actually, because while the Text and TextDetail default shaders only specify materials with a fallback, LWRP/Unlit has all its bits in the one shader

still orbit
#

yup

#

then you just need to port the text rendering specific stuff

#

which iirc isnt a lot

ornate blade
#

yeh, doesnt look too bad

ornate blade
frigid zinc
#

i can't get it to work says it can't find "UnlitInput.hlsl"

still orbit
#

Do you have LWRP installed, requires it

#

ah

#

youve duplicated UnlitInput locally?

frigid zinc
#

yeah must be

#

i know how to do it for the standard pipeline but looking at LWRP i'm a bit confused.

#

but looks like they have it set to overlay and ZTest off, which is what you'd do for standard

#

so not sure why it would still be hidden behind objects

#

well i take that back, I don't see they turn ZTest off, only ZWrite

#

try setting ZTest Off

ornate blade
#

yeh, i got all its dependencies and copied them across. There were some weird settings for ztest etc, so I have now replaced them with ZTest Always, Cull Off and Blend[_SrcBlend][_DstBlend] (the last was theirs). It is now sitting on top, but is always black, no matter the color setting

#

which is what im warring against now ๐Ÿ˜›

#

For the dependency thing, I tried to add a new shader to the package, it didnt like that ๐Ÿ˜›

frigid zinc
#

if you want it to render the text over top of everything, you want to set ZTest off, not ZTest always

#

or maybe i misunderstood what you're after

ornate blade
#

weirdly, it is currently overlaying everything else with its current setting. Could it be because I set Queue to overlay?

frigid zinc
#

that's part of it yes

ornate blade
#

sorry, "Overlay+1"

#

I needed it to overlay my other overlay stuff ๐Ÿ˜›

frigid zinc
#

i don't see where you're setting Ztest in that shader

ornate blade
#

line 30

#

I just solved the color issue. changed texColor.rgb * _Color.rgb to have only _Color.rgb

frigid zinc
#

line 30 has nothing but a bracket ๐Ÿ˜ƒ

#

maybe you modified it since it was put on pastebin

#

but if you got it working all good

ornate blade
#

I modified that file

#

It even has revision history set ๐Ÿ˜› Love me some git

frigid zinc
#

ohh i see, you changed it since i opened the page

#

i needed to refresh lol

ornate blade
#

ahh yeh thatll get you every time

#

thank you both @still orbit and @frigid zinc for your help ๐Ÿ˜ƒ

frigid zinc
#

well i didn't do much but glad you got it working ๐Ÿ˜ƒ

still orbit
#

lol i did nothing xD

#

but also glad

ornate blade
#

haha its always helpful to bounce ideas, and you gave me the idea to use the lwrp unlit Kink ๐Ÿ˜ƒ

ornate blade
#

for interests sake, I ended up getting a problem with text disappearing after this. Overlay + 1 doesnt like the Mask component. Instead of masking it outside of the area, it just masked it everywhere. All good, everythings just on Overlay now ๐Ÿ˜ƒ

still orbit
#

thats probably hardcoded Unity voodoo magic lol

wraith tide
#

Hey guys, I have a question about making fog of war for lower camera angles. Right now, I have a separate camera and a "view radius" around every unit, which creates a RenderTexture that shows which parts of the screen should be fogged, and which shouldn't.

#

The problem is, as you can see, that objects that are within the fog of war are also cut out if they are tall enough, like that tree.
Any ideas on how to solve this in a well-performing way?

quaint grotto
#

maybe cull by distance if its a circle

wraith tide
#

Hmm, it's many circles, there can be many units that reveal the fog

quaint grotto
#

most people use a mesh inbetween the camera and the land

#

maybe if you change the draw order =/

#

im guessing though at this point

wraith tide
#

Changing draw order won't work because I do want objects that are placed outside the fog area to be hidden

#

A mesh around these circles could work, but it would add a lot of vertices/tris to the scene, and also create a vert sharp edge. The best would be to use actual fog for a more gradual edge, but that would kill performance the way I know it.

neat bridge
#

The solution would be in the stencil (your render texture) rendering . You want the tree to be rendered white, because it's within X distance of your unit. I'm not sure if this is the cheapest way to do it, but in your second camera rendering shader's vertex function you could get the horizontal distance from the unit and tell the fragment shader to render white if it's within range of some player unit.

wraith tide
#

That would mean passing data to the sader about hundreds of units, and checking against each one...

neat bridge
#

I'm not sure how you'd check against multiple player units inside the shader. Another technique that i remember reading about ages ago, you create a stencil rendertexture of a top-down 2D view of your playfield with white circles representing the radius around player characters. That 2D texture represents your playfield, so the fog rendering camera can get the world position of each vertex and compare the x and z values of that world position against the top-down stencil texture

#

It only works for 2D, and the scale of the stencil texture would depend on how big your playfield is

wraith tide
#

Hmm, if I pass the vision texture of the entire world from a top-down orthographic view to the 3D object shader, I could multiply each pixel by the value in the vision texture using that pixel's world XZ. That would work in 3D too.

last robin
#

i would try making the fog of war mask top orthographic from above and then in the units shader don't draw any thing unless the center of the object is within the white part of the mask

wraith tide
#

I wonder if I could do it in post-processing somehow, save a buffer of the world XZ of every pixel, and then in the post-processor add a fog depending on the XZ

last robin
#

that could work too. The tree would instead be cut in half i guess

#

which sounds pretty neat tbh

wraith tide
#

@last robin that's a good idea for hiding units in "discovered but not currently visible areas". But I still need to mask the terrain, objects, etc - too, in the undiscovered areas.

#

lol, yeah. Though I have a gradient so it would be smoother than that

last robin
#

i like what you were saying a line ago. Top down ortho mask, inside unit's shader discard if pos.xz is outside mask

wraith tide
#

question is - how do I get the XZ position of every pixel on the rendered texture...

last robin
#

one sec i think i have that somewhere

#

so this is actually done in a compute shader but it should be somewhat easily converted to an image effect

float4 GetWorldPos(uint3 id, float w, float h)
{
    float2 screenPos = float2(2.0f*id.x * (1.0f/w) - 1.0f, 
    1.0f - 2.0f * id.y * (1.0f / h));
#if UNITY_UV_STARTS_AT_TOP
    screenPos.y = -screenPos.y;
#endif
    
    float4 worldPos = mul(_ScreenToWorld, float4(screenPos,0,1));
    worldPos /= worldPos.w;
    return worldPos;
}

called with this

Source.GetDimensions(w, h);
float2 currentWPos = GetWorldPos(id,w,h).xy;
#

supposed to be for xy but i think rotating the camera to point down will make it output xz

#

also somewhat of a warning i've never tested this on other machines

#

Matrix4x4 screenToWorld = (camera.projectionMatrix * camera.worldToCameraMatrix).inverse;

#

that's _ScreenToWorld. you gotta pass it in with a script

#

id is pixel position int from 1 to texture width/height. w and h is texture width/height

#

you can change that to use uvs in [0,1] range instead i'm sure

#

shouldโ„ข just be changing float2 screenPos = float2(-1 + 2 * uv.x, 1 - 2 * uv.y)

wraith tide
#

Thanks, I'll check it out.

#

I think it may be a bit more complicated, because you can't interpolate world position from clip XY alone. You also need to get the Z from the depth buffer somehow.

#

any idea how to access the Z buffer from a shader? I wasn't able to.

last robin
#

i don't think depth matters with an orthographic camera

#

but you can use _CameraDepthTexture

wraith tide
#

I tried that, I just get 0 everywhere.

last robin
#

you have to make unity render to it with a script

wraith tide
#

Probably because it's a different camera

#

ok. I'll try reading up on that a bit

#

It's not an orthographical camera btw. the idea was to use orthographical top-down only to render the "viewable areas" texture, which you can then sample based on the "world XZ" position of every pixel on the screen.

last robin
#

i think it's just this Camera.main.depthTextureMode = DepthTextureMode.Depth;

#

oh you want world position of pixels in a post process effect?

wraith tide
#

Thanks!

last robin
#

with perspective?

wraith tide
#

yes

last robin
wraith tide
#

thanks again!

last robin
#

ya np

#

that channel is a gold mine btw i'd suggest watching more

wraith tide
#

it seems so indeed

wraith tide
#

so, tried that. problem is to get something that looks good, we need a really large render-texture for the world-visibility thing...

#

but it is working rather nicely

light basin
#

Hi,
I have two transparent objects, and I want to hide one object behind the other

#

how can I go about achieving this?

#

I want the object behind to be fully occluded by the near object

#

i.e. you should not be able to see the lower half of the sphere (which is behind the cube)

#

(I already have a shader which does not render the backfaces, of the same object)

amber saffron
#

I would say : use stencil buffer

#

Or make transparent with depth test ...

light basin
#

okay thanks

wraith tide
#

@light basin not sure I understand. If you want the object behind not to be visible - then it means that the object in front is NOT transparent. What am I missing?

tidal beacon
#

Can someone help me figure this out? When I have no material set on my buttons, they automatically display the material for my tileset, even though it specifically says I do not have a material selected.

Setting the material to another material fixes the problem, but I want to know why not having a material is causing this bug.

light basin
#

the object in front is transparent to opaque objects

#

@wraith tide

wraith tide
#

Ah ok, so there are some objects you do want to see behind it, and others that you don't...

#

Yeah, Stencil sounds like the right way to go as Remy suggested

light basin
#

yeah that's correct. Thank you

echo badger
#

So I have gotten my water shader to this point (Which doesn't look like a lot. But there were several different iterations trying different looks)
Now for the life of me I can't figure out how to color the black water. Now that I hooked up the depth part of it.

quaint grotto
#

just apply a basic color first then apply the lighter colour on top when you have shallower depth

#

like a dark blue and just lighten it the more shallow it gets

#

you could use a lerp between dark and light blue with your depth values

echo badger
#

I'm sorry, I can't figure out at what point to apply the color.

#

Would it be after the One Minus and before the Multiply?

still orbit
#

you should have a black and white depth value

#

then lerp dark > light based on that

#

or better yet, sample a gradient based on that

echo badger
#

Oh I see! Thank so much @still orbit!

stone sandal
#

you should totally sample a gradient based on the depth value, you could get some really cool looking things from it i think

echo badger
#

Yeah, gradient seems to work well!

#

Wait... why can't a gradient be a Property? ๐Ÿ˜ฆ

still orbit
#

ShaderLab shaders dont support gradient properties ๐Ÿ˜ฆ

#

anyway, when youre happy with it, you should probably convert it to a texture instead

#

itll be faster

#

gradients are just really good for prototyping

echo badger
#

How would one do that do you know?

snow thorn
#

You can sample a texture as a gradient by just sampling it at custom UVs instead of the UVs from your geometry. For instance, sampling a horizontal gradient image at UV (depth,0) will get you a sample of the gradient at the position you want.

still carbon
#

isn't a simple lerp between two colors a more efficient operation than adding another texture sample?

#

though with a gradient texture the nice thing is you can swap out different non-linear gradients easily

still orbit
#

yes a lerp is much faster, but with water colour it doesnt look very good

#

linear interp is not how transmission works ya know ๐Ÿ˜ƒ

still carbon
#

Of course, but chances are they're not making a gradient texture that matches water falloff either haha, but it can definitely help make some more artistically pleasing water for sure. I'd be interested in what the math would be for calculating the proper transmission/attenuation for a given depth, density and IOR would be though

knotty juniper
#

is there not a option to encode the gradient data into a texture or a array of floats? i know super hacky but haveing no gradients from the inspector is not so nice.

still carbon
#

They'd have to make a shaderlab attribute for texture properties to have a gradient color picker and the material editor generating a texture asset behind the scenes... doable but I can imagine it could introduce a lot of headaches for little gain to the average user. I'd just make a material editor extension for that if a team needed something like that. General approach seen has usually just been LUT inputs, easy enough for any artist to deal with

knotty juniper
#

@still carbon probablc correct and runtime changes (what i would have used it for) are not that easy

still carbon
#

Yeah, you'd be generating new textures at runtime when changes are made, though that's not bad if they're just small strip gradient textures. But if needing to keeping changing over frames I'd imagine it might be better to just have a few color/float inputs on your shader that calculate the gradient

knotty juniper
#

i have to look into making a shadergraph node thats does take some float and color inputs and generats a gradient that can be chaged at runtime

still orbit
#

well our gradient node is just that under the hood

#

a struct containing a bunch of vecs for the keys

#

when i end up making it so you can declare unifroms for them

#

ill probs make a C# script that can set that from a gradient field

#

pretty simple solution

still carbon
#

Oh I hadn't looked at the grad node in SG, that's pretty nice

still orbit
#

๐Ÿ˜ƒ

#

its a nice representation, but its just a struct

#

which in fairness is what gradients are really

#

float4[] colorkeys
float2[] alphakeys
int mode

still carbon
#

that's a nice idea to decouple the alpha gradient from the color, was surprised by that as you don't often see it

still orbit
#

well thats how the gradient is represented in unity in C#

still carbon
#

Is there anything exposed in non-package unity that used that gradient representation? I don't recall see controls like that in unity before

still orbit
#

yea the shuriken particle system ๐Ÿ˜ƒ

#

although the one in shader graph is UIElements, so not technically the same UI. But i think it works the same way.

still carbon
#

Ahh that's why I hadn't seen it haha, I rarely delve into the particle system. I see it's using the same popup as the SG node, for color by speed and over lifetime

foggy agate
#

Absolute noob here... Does someone know a good source for blur-like shader?

ornate blade
#

hmm, for your normal script shaders, I would google terms such as 'unity hex bokeh shader'. I havent looked into it yet on SG, that could actually be an interesting next project

foggy agate
#

seems what I'm looking for times ten with the depth probably : )

#

I'll look into it thanks

ornate blade
#

all g ๐Ÿ˜ƒ good luck!

ornate blade
#

is there a way to name the outputs of a subgraph is SG?

#

Made a scanline maker, and would like to label outputs as "Main" and "Opacity"

still orbit
#

I just made a PR for this today

#

its coming

rotund tusk
#

๐Ÿฅ‚

fervent tinsel
#

That has bugged me as long as I've used sub graphs in SG :)

#

Oooh, custom function node too on the PR

rotund tusk
#

hmmm i should get on that...

stone sandal
#

Wyatt pls

rotund tusk
#

You too yo

peak spindle
#

Hi, could anyone help me in figuring out what this type of shader it is I'm looking for? I basically want the rectangle to be invisible, and only show the square that touches the body (on both sides)

amber saffron
#

You probably want to work with stencil here

peak spindle
#

Stencil it is. Thanks, I always get stuck figuring out what keywords I should search

fervent tinsel
#

@still orbit there's one breaking issue on the PR, I noticed it on the WIP branch too but thought it wasn't just finished: If you have multiple output ports on subgraph and you rename the first one, it messes up with the other ports

#

I think this only happens if you have old existing output ports in the subgraph. It totally messes up if I try to rename old, existing ports but if I remove them all and make new output ports, they work as expected

#

actually, it happens on newly made ones too if you restart the editor, it only works like it should in the session you make the outputs first time...

fervent tinsel
#

same issue exists on Custom Function's inputs too

still orbit
#

Oh wow :/

#

This happens if the ports are unconnected?

fervent tinsel
#

I didn't test

#

I'll check

still orbit
#

i think this is because its technically removing and adding the port if you change anything about it

#

currently removing a port that has connected edges throws nulls and breaks the graph

fervent tinsel
#

if I disconnect all ports and rename it does work

#

however if I only disconnect the port I'm about to rename, it still messes it up

still orbit
#

Yea ok, this is a known issue then ๐Ÿ˜ƒ

#

Todays job is to fix that...

#

it needs to go in separate PR first, the current subgraph output node has the same bug, it just only reproduces one way because of how rigid the node is'

fervent tinsel
#

atm, is there any difference if you expose SG's Sub Graphs properties or not expose them?

#

I really can't tell what effect it has atm

#

I could swear it used to toggle port visibility for the subgraph node on the main graph but right now they show up anyway

stone sandal
#

there is no difference for exposing vs not exposing on a subgraph

fervent tinsel
#

is there any plan on being able to expose subgraph properties for c# access?

#

I'm now just routing things to main graph and setting things there but it's extra step

stone sandal
#

uuuh i don't think there's any plan for that right now no, since you'd have to putting the subgraph into a regular graph to use it anyway. if the extra step is a high user pain for a lot of people then maybe, but right now it's such a specific use case that other things are higher on the priority list afaik

fervent tinsel
#

yeah, curious about this since I know ASE can do this

#

so now if I want to have like that Occlusion Probes sampling subgraph, I can't just trivially throw it out there without explanations as the sub graph can't expose the needed properties

#

in ASE, I can do that in it's subgraph equivalent and all I get is nice and clean node on the main graph without anything extra to wire

long lotus
#

Hi, I have a scene that is made from depth-sorted SpriteRenderers. We're doing this because using 3D textures would make it look like a Playstation One game (ugly) so we would prefer to use isometric pixel art.
The art-team would like a glow effect on all of the objects to make it look like you are in a Tron-style VR environment. Here's a mockup:

#

I've said that because objects must be in front of each other, the glow would have to be applied in sequence on every sprite. Some objects will occlude others, meaning the glow on some objects will be partially visible.

#

Am I right?

#

I'm also not sure how I would go about writing a shader to do this to all of the sprites in depth-sorted sequence. If I'm wrong then perhaps I can just do a single pass on the camera output instead of every sprite.

stone sandal
#

yeah if you wanted that effect to be dynamic it might get tricky, but tbh depending on what they want it to look like i might be inclined to just "bake" the glow effect directly into the sprite texture

#

basically just like the mockup is done (i'm assuming) directly in photoshop, just use that in the actual sprite texture

#

fake the look real hard

long lotus
#

The problem with glow on every object is that all of those alphas are going to get dirty when stacked on top. I believe the artist is expecting some kind of blend mode to be applied - but the game engine needs to depth sort in real time (I have the engine working fine with clean pixel art).

stone sandal
#

hmmm fair point on the alpha but i think you're going to hit a limitation of your asset method. it looks like the artist wants interior edge glow too but if you're just rendering flat pixel art, there's no edge data to feed into the shader. you'd need some kind of look up map for each object that tells the shader what the interior edge data is as well as the depth sorting...

long lotus
#

Yeh - the thing that kills it is two cubes sitting next to each other - whose glow is in front? What if the depthsort swaps them?

stone sandal
#

yeah this is... not an easily problem to solve...

long lotus
#

I'm mostly building a case for us to try a different direction with the art. I think people are cool with that, but I needed advice. I appreciate your input.

broken field
#

why not bake glow into another channel?

#

then you can just render all glow in a post effect pass

grim bane
#

Any ETA to be able to define arrays of float and vector as properties to be accessed from c#, like in the built-in pipeline?

Now that we are going to be able to write full HLSL code with the new code function, and write loops on it, I think it is a functionality that we are going to miss.

still carbon
#

@long lotus i'd think, for the case of the two cubes side by side, their glow contribution should just mix, no? Let them write their glow to the emission buffer and let post process bloom take care of the rest.
If you want to avoid making separate glow textures, then the less flexible option would be customizing the sprite shader to have a sort of "Emission Cutoff" value that you would multiply any values above that range by your emission intensity value on the shader. (and could clean up this effect by using a bit of a soft-step at the cutoff so it's smoother transitions to glow). This would allow you to use just one sprite, but you'd have to be aware of this when crafting the sprite colors.

still orbit
#

@grim bane If youre using this in a custom function node, and are going to set this via C# anyway, you can define whatever unifrom types you like, including arrays and structs

#

Youll just need to define all this stuff in your HLSL include, along with your function

#

it wont be accessible via the graph

#

well add functionality for arrays in the graph, just not in the immediate future

grim bane
#

Wow, great news!

still orbit
#

the advantage of doing things via includes, do whatever you want in there ๐Ÿ˜›

quaint grotto
#

does the hdrp make it any easier to make a render texture of objects below a plane ?

broken field
#

Actually it kind of does with a planar probe

#

I've not tested it upside down though

#

Maybe you mean something different though

quaint grotto
#

isnt that for things above the plane not below ?

#

for me i need a render texture of things below my water plane

#

i know there is a way with matrix transform on camera but i can't understand it properly to use it

#

unity's code is painfully long and unexplained on what they are doing

still orbit
#

yea planar projection, i assume HDRPs planar probe can go upside down?

still carbon
#

Render screen to render texture with replacement shader that cuts objects off at water plane height, use Rt in your water shader?

still orbit
#

nah you need an oblique projection matrix

grand jolt
still carbon
#

what does the oblique projection matrix help do?

#

looks cool mago

grand jolt
#

Thanks, this is my first shader

still orbit
#

planar projection is oblique

#

by definition because its a reflection

grand jolt
still carbon
#

For a planar projection yeah, I just meant in the context of what Sir is trying to make i'd imagine an RT from the same view but with just the underwater parts of meshes would be enough for his goal of creating some slight wave distortion on the surface for underwater parts only. I'm guessing a planar projection would be nice though for creating more convincing refraction? (just genuinely curious about this stuff, never dealt with oblique projection matrices)

still orbit
#

oh sorry i wasnt actually paying attention <__<

#

yea draw underwater to offscreen RT then blit back against a stencil

quaint grotto
#

@still orbit yeh oblique matrix but i dont understand it well docs kinda non existant no real tutorials on it either

still orbit
#

Yea there isnt really ๐Ÿ˜ฆ

quaint grotto
#

@still carbon how would i ever get the underwater parts from the same view without it

#

some objects will be partially in the water too

still orbit
#

its mix of example code of planar projection ....and then straight up maths docs on oblique matrices

quaint grotto
#

@still orbit thats been my problem with unity for a long time, when you want to do specific things unity offers nothing in the way of working it out

still orbit
#

well, this is getting better

quaint grotto
#

i worry hdrp will be even more "figure it out" rather than actual helpful guides

still orbit
#

HDRP has planar probes out the box

#

LWRP has planar projection in the boat demo

quaint grotto
#

is there a good doc on it ? need to check if it does reversed normal planar aswell

#

i need up normal for reflections, and down for refraction

still orbit
#

HDRP is still preview and mostly undocumented im afraid

quaint grotto
#

are the probes different in hdrp to lwrp ?

still orbit
#

but im sure you can figure out if you can flip it pretty easily...

#

planar in LWRP isnt probes

quaint grotto
#

oh

#

its a shader clip ?

still orbit
#

its good old draw again to offscreen with oblique and blit to screen

quaint grotto
#

ah

#

so its a second render then

still orbit
#

well probes is a lot more than 2 renders xD

quaint grotto
#

isnt that what unity's pro water already does ? at least from what i can figure out from the source

still orbit
#

yea LWRP planar reflection is similar to our old pro water reflection

#

except good

quaint grotto
#

rofl

#

dont say good just yet

#

unity frequently misses the mark ๐Ÿ˜›

still orbit
#

my friend wrote it, im going to go ahead and call it good ๐Ÿ˜›

quaint grotto
#

there is always something they do which gives you a headache

still orbit
#

remember they is you in this case

quaint grotto
#

nah they always have something which is awkward to work out

#

niche things are often just a pain to solve

#

compute shader i can't work out well at all

#

you ever used them in unity?

still orbit
#

Of course, I work for Unity

#

In graphics R&D...

quaint grotto
#

oh you work there

#

well compute shaders is not easy to get into !

#

also do you know if hdrp planar stuff is reliable to use at the moment or am i likely to run into bugs

north rampart
#

Hey guys! Coming back to this channel to see if someone has any idea of how to get a draw on top of everything shader within HDRP?