#archived-shaders

1 messages ยท Page 126 of 1

void bobcat
#

Er, well

#

I wanted a star in Unity that I could change the colors of, but I didn't feel like sitting through a tutorial to get one so I could test what it would look like.

#

So I grabbed a star from shadertoy and wanted to convert it

#

But at this point I might as well find a tutorial instead to make it from scratch in shadergraph

#

Here is the version in Unity ๐Ÿ˜‚

#

On a sphere and on a plane

low lichen
#

iChannel0 is what gives it the texture in the center

#

What did you replace it with?

#

And you can't just put a fullscreen effect on a a sphere and expect it to look right

void bobcat
#

Well I mean

#

I'm not criticizing anyone

#

Just thought I'd try and see what happens

#

But thanks for the help. Means I can convert shaders in the future too.

#

This is the texture I gave it

plucky bone
#

You should probably check what the license on the shader is

#

Since you might not be allowed to use it

void bobcat
#

Oh I wasn't going to keep it.

#

If I could use this as a prototype thing for myself so I can see what a scene could look like, then I'd be fine.
Then I could get rid of the shader and find out how to make one

void bobcat
#

@low lichen Do you know of any tutorials that uses shadergraph to make something like a star texture? Or similar?

low lichen
#

@void bobcat Do you also want the glowing flares coming off of it?

void bobcat
#

Hmmm, I want to make something that looks more like a...er, white dwarf I think?
It produces a lot less heat than a yellow star does.

low lichen
#

Can you show a reference picture of what you want to achieve?

void bobcat
#

Lemme look real quick

#

Right so, upper left corner is a yellow star like ours. Upper right is a red star, low right is a blue star (which I am pretty sure is made up) and the lower left is a white dwarf.

low lichen
#

The glow effect will not be achieved in the same shader. It's either a separate mesh with a separate material that does just the glow or a post processing effect.

void bobcat
#

Right

low lichen
#

In that picture, it just looks like a 2D image overlayed on top of the stars

void bobcat
#

Well that could be the case for the picture. But I'd wanna make a 3D object

low lichen
#

The sphere will still be 3D

#

But the glow is a billboard quad, like a big particle

void bobcat
#

That's probably true.

#

I want to encase the star in a dyson sphere.

#

But that's a separate thing

low lichen
#

The star without the glow is very simple. Just an unlit shader with a nice looking texture with a color applied to it

#

It's only if you want to do something fancy like animate the surface texture that things get more complicated

void bobcat
#

It would have to be a gradient no? From the middle and outwards. White to Blue then a texture on top with a red tint?

low lichen
#

Doesn't look like that in the picture you posted

#

If you want that type of effect, you'd use a fresnel node.

void bobcat
#

And this is where you start to lose me as my shader experience is limited x)

low lichen
void bobcat
#

alright

vapid orbit
#

Alrighty, so I have changed everything over to use only rendertextures, and I changed the color space, but I am still getting the same issues. Any suggestions?

vapid orbit
#

I guess the main question is, why isn't the compute buffer and the render texture behaving the same way?

dark flare
#

Why do reflection probes do a stencil write before every actual reflection probe draw call, in unity's deferred renderer?

#

@ me if you know

sinful salmon
#

Helloo

uncut karma
#

@dark flare its likely some form of masking for the pixels affected by probes

dark flare
#

Why does it need two separate draw calls? I don't understand why it's not one pass

#

@uncut karma

#

Oh I see...

Bit #4 (value=16) is used for light shape culling during the lighting pass, so that Unity executes only the lighting shader on pixels that the light touches, and not on pixels where the surface geometry is behind the light volume.

#

It's not for the reflection itself, it's for the lighting pass later

#

Its still strange it doesn't do the stencil in the same pass

vapid orbit
#

Does anyone have any suggestions about my problem?

dark flare
#

What's the actual issue with the RT @vapid orbit?

#

Did you create the RT as linear, and are you sampling using a sampler or direct array access?

#

If using a sampler, are you offsetting by half a pixel (if using a linear sample), or try using a point sample

#

Just a few ideas

#

Gl ๐Ÿ’ค

vapid orbit
#

So, I'm not exactly sure what the issue is. Also yes, I believe I changed the color space, and as far as I understand, I can't actually sample from a rendertexture, I have to use direct array access.

dark flare
#

You can use a sampler, you just need to define the samplers manually

#

But if you're already directly accessing it it's probably better for fluid sim

#

Unless you're trying to do something clever

#

But save that until after it's working initially hehe

#

The color space is defined when you create the RT in code

vapid orbit
#

Oh, no I'm definitely not doing anything clever lol

#

Oh, is it?

dark flare
#

If you don't define one it uses whatever the project settings are set to

#

I recommend linear everything but not everyone agrees

vapid orbit
#

Ah, yeah I already set the color space to linear on my project settings, but I'll double check to make sure I'm not defining it to be anything else when I create the render texture

dark flare
#

The option for linear or gamma conversion is in here, maybe to be safe be explicit

#

Without knowing what the actual issue is it is hard to help tho

#

What's happening vs what you expect

vapid orbit
#

The only information that I have, is that for whatever reason it's behaving differently than a computebuffer that's being treated like a 2D array. So, what I expect to happen is that it will have what appears to be smoke flowing out of a position that I give it, however what is actually happening is well... virtually nothing, in that only a ball of grey smoke appears.

dark flare
#

Are you trying to read and write to the same render texture? Your GPU may not support that, if so. Try double buffering

#

If you have a DX11.0 card (instead of a 11.1) you can't read and write at the same time

vapid orbit
#

Yeah, I'm using double buffering

#

It's kind of necessary for this sort of thing, because it operates KIND OF like a cellular automata.

dark flare
#

Hmm, is the result completely static? Maybe something silly like not swapping the buffers after dispatch?

vapid orbit
#

Maybe? Let me check my code real quick to make sure

#

Yes, I am swapping the buffers.

dark flare
#

Glancing at your code, are you just copying the whole RT every time? Why not just swap the references instead?

vapid orbit
#

OH

#

Yes, don't worry I already fixed that lol

#

Someone else suggested that I change it to use rendertextures only instead of Texture3D

#

Let me push those changes real quick

#

Alrighty, the changes should be up on github now

dark flare
#

This might be silly and nit picky, but I recommend finding and caching your kernal IDs manually lol

#

Those Dispatch(0) calls stress me tf out

vapid orbit
#

Lol! It would probably be a bit cleaner if I did that

strange onyx
#

does anyone have any idea WTF they mean by these functions?

errant arch
#

@strange onyx I guess that it's lerp functions. lerp1=textA->texB where t=noise, lerp2=texC->textD where t=noise, next lerpAll=lerp1->lerp2 where t=alpha and at the end there is multiplication (but I dont know why :P)

grand jolt
#

Help

#

I can only access discord on browser from my Mac Book.

#

The app won't work.

stone sandal
#

this is not the place to ask for support for the discord app...

grand jolt
#

Oof

#

All I saw was the ask questions part

#

Lels

devout quarry
#

with tons of parameters, things get messyyy, a way to add even like simple headers would be great

#

using shader graph

remote osprey
#

Could someone give me some advice on how to remap a vertex mask to the actual vertex positions of a mesh in a sprite shader? What I have here DOES work - as long as we don't use sprites from an atlas. What happens is that the vertex mask ends up getting the same pixel positions from its texture, as the sprite does from the sprite atlas. What I need to do is have the vertex mask use the UV positions INSTEAD OF the pixel positions. I'm a bit lost on how to do that in shader graph...

cosmic prairie
#

@remote osprey but the mask is using the UV positions, it says it right there, also that lerp could be replaced with a multiplication I think

remote osprey
#

That's what was confusing me too... it seems like it is, but the sprite position appears to be affecting it. Lemme get a quick video...

cosmic prairie
#

okay

#

Btw I also have a question, anyone knows how to get a specific world position in screen position in shader graph?

remote osprey
#

These are both using the exact same shader. The only difference is the sprite on the left comes from an atlas, and the sprite on the right is a stand-alone 'single' sprite.

cosmic prairie
#

Hmm, maybe unity overrides the first UV map of sprites? (I don't know a much about sprites) Maybe try using the secondary UVs for the displacement, or vertex colors, or maybe even normals

#

or actually Object space vertex positions should also work I think if set up properly

remote osprey
#

It's certainly something Unity doesn't like doing... we had do to some wild tricks to make this work when this was originally a shaderlab shader, lol

cosmic prairie
#

does it really have to be in an atlas?

remote osprey
#

Yeah

#

Way too many sprites not to

cosmic prairie
#

okay I'll test this ๐Ÿ™‚

remote osprey
#

Hey I got it!!

#

It was the object space vert positions.

#

Pass those in to the UV for the vertex mask

#

Really I should say, YOU got it @cosmic prairie !

#

THank you!!! I've been stuck on this for like a week.

cosmic prairie
#

no problem ๐Ÿ™‚

#

I was just testing that out too ๐Ÿ™‚

remote osprey
cosmic prairie
#

hmm I thought they would have made sprites to be 1*1 but it turns out they are not, you might have to fiddle with numbers to get proper uvs but they should work

remote osprey
#

Yeah, I don't think they ever thought someone would treat the sprites like meshes to get vfx.

cosmic prairie
#

Umm so anyone knows how to convert a given world space coordinate into screen space (or back)

#

?

#

or even view to screen space

grand jolt
low lichen
#

@grand jolt Depth Test set to Always, like the material already is, should make it draw on top of everything

#

Only other thing to change would be the sorting priority to make sure it's drawn last.

kind helm
#

Is there any way to loop through an array in the shader graph?

kind helm
#

Okay, first i need to know if you can even have an array of vector3

regal stag
#

@kind helm You'll have to use a Custom Function node, but you should be able to use arrays & loops. I don't think you can have a float3 array though and set it correctly, as material.SetVectorArray takes a Vector4 array. It may have to be a float array, set it using material.SetFloatArray, and loop through in sets of 3. Or use a float4 array, set it using material.SetVectorArray and just ignore the last component.
e.g.

float _Points[5*3]; // 5 x Vector3s, but split into floats.
void FunctionName_float(...){
    for (int i = 0; i < 5*3; i += 3){
        float3 p = float3(_Points[i], _Points[i+1], _Points[i+2]);
        ...
    }
}```
low lichen
#

Has to be float4 array unless you use a ComputeBuffer and SetBuffer instead.

solar pecan
#

i have the grid working, but its just vertical, and i would like it to be in perspective

full kestrel
#

Hi, I wanted a projector with an animated texture. So I created a quad with a material that is animated. I then use an orthographic camera that looks at that texture, writes to a render texture, then I assign that texture to the projector. However, I found it is incredibly slow, taking about 2 milliseconds per instance. Any tips on this?

meager pelican
#

@kind helm

I remember reading an article that float4 was an optimal size for cache coherence or indexing or whatever, even when using compute buffers.

So although I'm not sure, you might want to use a float 4 and reserve the final float for something else like some kind of flag(s). Just a thought.

grand jolt
#

Instead of height map you use the render target however you want

full kestrel
#

Bernard, what I am doing is different but I appreciate the link

grand jolt
#

The point of the link was for the setup of the temporary render target and using the Blit operation to draw your animated material to the rendertarget, should get rid of the whole orthographic camera and multi rendertarget

#

Part 4 of that tutorial might be more what you want

royal sluice
#

how do I make this white part transparent, I'm kind of new to shaders

grand jolt
#

transparent albedo?

royal sluice
#

I think so

#

actually, this is a force field, I just want an aura right in the sphere .. like it's those snow globes

#

i don't need more! ty

oblique fox
#

Hey there, how do I create a PBR Graph in Unity 2019.2.f1?

oblique fox
#

but when I save it and look at the plane I've associated the material to, it doesn't show the shader

#

any advice would be greatly appeciated

vocal narwhal
#

Looks like your default colour for the ripples being black would likely be the issue

oblique fox
#

wow so weird! It didn't update from the shader but that did the trick haha thanks

#

I'm still learning ๐Ÿ˜ฆ

lost prairie
#

how does implicit float4 to float conversion works? I just realized I've been making a mistake doing most of my stuff using color instead of R channel and now when I try to fix that, bunch of stuff is broken. ๐Ÿ˜ฆ

#

wait I think it convertes by taking the R channel as I needed, I probably broke it a different way

cosmic prairie
#

yeah it uses the r

lost prairie
#

thanks @cosmic prairie ! ๐Ÿ™‡

sly fossil
fervent tinsel
#

@sly fossil you have SRP asset assigned in the project settings->graphics?

#

shader graph requires you to use some SRP (URP/LWRP/HDRP)

grand jolt
#

Does anyone know how to resolve this?

#
WARNING: Shader Did you use #pragma only_renderers and omit this platform?
WARNING: Shader Unsupported: 'HDRP/Lit' - Pass 'DistortionVectors' has no fragment shader
WARNING: Shader Unsupported: 'HDRP/Lit' - Pass 'TransparentDepthPrepass' has no fragment shader
WARNING: Shader Unsupported: 'HDRP/Lit' - Pass 'TransparentBackface' has no fragment shader
WARNING: Shader Unsupported: 'HDRP/Lit' - Pass 'Forward' has no fragment shader
WARNING: Shader Unsupported: 'HDRP/Lit' - Pass 'TransparentDepthPostpass' has no fragment shader```
grand jolt
#

Does anyone have a sample billboard shader graph?

grand jolt
#

wont work :/

grand jolt
north karma
ebon trench
#

Yo guys, is there any way to get a good shadow distance going in LWRP without it ruining the shadow quality when you're close to them?

#

cause I want shadows at a reasonable distance, not just 3 foot away, but I also want them to look better the closer you are to them

meager pelican
#

shadow cascades?

merry rose
#

@north karma I have a same issue, found on forums that Custom Function does not support Conversion from Texture2D to Sampler, same as Unreal didnt back some time

little dew
#

is anyone familiar with this error from ProcessingStack v2? Shader error in 'Hidden/PostProcessing/MultiScaleVO': failed to open source file: '../StdLib.hlsl' at line 9 (on d3d11)

#

I tried removing it and reinstalling multiple times from the package manager with no luck

fervent tinsel
#

@little dew what are you using it with?

little dew
#

2019.1.6f1

fervent tinsel
#

@merry rose you can run samplers on custom function

#

@little dew you have the old asset store version installed?

little dew
#

not that I'm aware of, no

fervent tinsel
#

also you are using it with built-in renderer, LWRP or HDRP?

#

HDRP doesn't support PPv2 anymore on 2019.1

#

also if it's not HDRP, then make sure it actually installs the latest version for 2019.1

#

it doesn't always do that by default

#

instead it can default to the verified package which can often be a lot older

little dew
#

yeah I checked the package info and says 2018.1, might be that maybe

merry rose
#

how can you do it? It always shows same error, tried almost every version of unity or HDRP, the thing is always giving me error

fervent tinsel
#

@merry rose there are shader macros you can use, I can't remember them out of my head tho

little dew
#

altho it says 2019.1 verified ๐Ÿค”

merry rose
fervent tinsel
#

yeah, I don't remember if those worked as is for sampling on HDRP but I'm pretty sure I did this thing a while back

#

@merry rose what are you trying to do with these?

merry rose
#

I am trying to do parallax occlusion mapping, I made parallax mapping but for the more sampled one I need to do a loop and that only works with custom functions, they should add a loop node maybe ๐Ÿค” ๐Ÿ˜„

fervent tinsel
#

@merry rose there's a POM node on newer HDRP already

#

I can't remember when they added it tho

merry rose
#

I know but when you use it you cannot lerp between two of them, only one can be used at a time, so for terrain shader that does not work

fervent tinsel
#

you can't make a true terrain shader with shader graph either

#

if you use it on a mesh, then that's doable

merry rose
#

I cant even lerp POM on anything, I tried on custom meshes, the UVs are broken, it gets the first parallax effect and uses it on everything

#

but I actually made my own terrain shader, looks nice, but yeah its not instanced, I have to look into that

merry rose
#

@fervent tinsel So I am looking into it, learned about it for what 6 hours now and got the first thing working ๐Ÿ˜„ , you can use SAMPLE_TEXTURE2D(textureName, samplerState, UVs) to sample a texture fuuu ๐Ÿ˜„

fervent tinsel
#

sounds about right

#

you coud probably use the sampler node too

#

unless you insist of doing it all on custom code

#

I can't remember if subgraph fixes has been backported to 2019.1 but that's the way to do complex graphs now

#

basically you stuff most of the logic in subgraphs and use custom function thing for things you don't find nodes for

void bobcat
#

I have an issue with a material I don't understand

#

This wall is supposed to emit blue

#

And it does when I'm not in playmode

#

As soon as playmode is turned on, it goes purple

#

What am I missing about Emission here?
I'm using Universal Render Pipeline

#

Didn't change any default settings on it

plucky bone
#

You need gi

void bobcat
#

Is that a setting I need to use or something I need to put on a light?

north karma
#

@merry rose @fervent tinsel So, how did you managed to just do a simple sample texture in a Custom Expression node? I need to loop through texture (array of positions written into RGB), so I need sample and modify the UV of the texture inside Custom Expression node. https://prnt.sc/pllc52

Lightshot

Captured with Lightshot

#

Sadly, but SG HDRP does not support arrays as a variable.

merry rose
#

basically it should go like this for you: tempPos = SAMPLE_TEXTURE2D([Texture2D], SamplerAffectorsCE, tempUV);

sand wasp
#

Is there a way to duplicate the effects of the Gradient Noise Node in C#?

#

IE Plugging some vector2 and a Vector 1 into the script and getting an identical output to the Gradient Noise Node seen in shader graph

north karma
merry rose
#

@north karma you can't create SamplerState inside, add it as input

north karma
#

@merry rose Thx, it worked ๐Ÿ™‚

sand wasp
#

Or alternatively, get the gradient noise, or a custom node, to function identically to the C# Mathf.PerlinNoise(float * Scale, float * Scale)

wet geode
#

Hey guys. I've got this starfield shader im working on and i wanted to have a flickering texture. What i did was having a moving simple noise moving multiplied on a speckle texture but for some reason it's just making the emmisive dark in the area with those speckles

#

this is it without the flickering ones

#

here's how it looks with the "flickering"

#

it isnt flickering though, as i said. It's just showing those dark spots

#

actually, just noticed. It is flickering. However, it's flickering where it goes from black to the blue speckle color then back

#

what i want is for the star to be transparent except for when it occasionally flickers

#

i hope i explained this well enough

glad fern
#

Looks great!

wet geode
#

Thanks, itโ€™s real simple though. I just need help with that one issue

north karma
#

@merry rose Sorry for bothering you again, but this one is complicated. For some reason when I plug the output into the Position this error appears

#

This only happens in a Position input and when the texture is sampled in a Custom expression.

worthy ridge
#

is it possible to apply a one shader operation to the previous operation in full? I want to process an image and then process that result for a few iterations.

north karma
#

Fixed it by using the SAMPLE_TEXTURE2D_LOD

worthy ridge
#

or let me put it another way, is it possible to sample the pixels of a previous pass in a shader?

merry rose
#

@north karma yeah, that makes sense, basic SAMPLE_TEXTURE2D is not not working on vertex level, so it cannot change vertex position, the LOD one does

cosmic prairie
#

@worthy ridge try RenderTextures

fervent tinsel
#

@merry rose yeah, I was going to say about the SS

#

also I do recommend using the file approach instead of the embedded text as it's easier to work with

merry rose
#

Yeah, i use file, it can get a bit messy ๐Ÿ˜…

steel kayak
#

Hey guys, is it possible to know which part of the texture you're touching with shader graph?

amber saffron
#

It's not really clear ... how would you like to do that ?
It depends on the UVs you're sendign to the sample texture node.

steel kayak
#

@amber saffron I'm trying to make a selectable grid. But i have no idea which node to use.

amber saffron
#

Oh okay, got it.
You can't do that with purely shader graph

steel kayak
amber saffron
#

You'll need to find the coordinate of where you're touching the grid, and then send it to the shader from c# code

steel kayak
#

how do i update the texture/coordinate of it?

#

idk how to pick a coordinate and affect that part of the texture.

amber saffron
#

And in the shader, use it as a mask

steel kayak
#

use it as a mask?

amber saffron
#

Yes, you can take the input coordinate to build a mask in the shader to display something else instead of the texture for example

#

but since I don't really know what your final intention is, I'm only throwing ideas here.

steel kayak
#

I want to be able to make a node change color when i select a node in that coord in script

#

I'm currently using IPointer. Am i still able to use this or i need to change to raycast?

public void OnPointerClick(PointerEventData eventData) {
            OnClickEvent.Invoke(eventData.pointerCurrentRaycast.worldPosition);
        }
amber saffron
#

You can use an other method, I suggested raycast because it's easy, but the idea is to transform the cursor position to a data that can be used in the shader.

steel kayak
#

Okay

#

I will try it first. Thanks alot!

amber saffron
#

Yep, something like that

steel kayak
#

Alright thanks alot!

fervent tinsel
#

@steel kayak most wouldn't make that kind of thing in a single shader

#

instead just move a selection quad where player selects the thing

#

(maybe I misunderstood the intent here)

steel kayak
#

im able to build but i need a grid repressentation for the grid. those gray boxes are gizmos.

#

i select nodes by using the position i get from hitiing the plane

#

so i was thinking whether i could make the plane into like vr grid(?)

#

if you guys have any tutorial series that has similar concepts, let me know please. I'm willing to learn.

fervent tinsel
#

I bet most would just have each object to have selection quad in it and then enable the renderer on demand when selected etc

#

if you'd want to be more efficient, then have a pool of selections somewhere and move things into sight from there

#

(if you need multiselection)

#

again, I may totally miss what's the intent here

steel kayak
#

Ohh i see what you mean. The plane above should be holographic grid.

grand jolt
#

How can i create shader, which hides all UI in object with him?

sand wasp
#

I'm trying to add noise to a shader, and gradient noise works fine, but I need it to align with a scipt, so I can't use that. Likewise, mathf.perlinnoise does what I need, but I can't call it in shader.

rustic dragon
#

you can expose any parameter in the shader and you can change those via a script

sand wasp
#

Sorry, I don't know what you meam

#

My shader settings are already controlled by script, which ensures it's values are synchronized with my other scripts.

#

But I need to pass a position node through a function identical to the functions in my c# script, and the shader functions don't contain the same noise functions as c#

wet geode
#

hey guys. Say i have this code

#

and i wanted to import it so that i would get a graph like it

#

how would i do that?

#

i mean get a node like that, not a graph

wild edge
#

does anyone know why a vertex shader would be broken by static batching?

#

I'm getting bizarre behavior where instead of moving vertices outward by v.normal they seem to move in a random direction instead

#

looks fine in scene view, only happens when you start running the game

ocean geyser
#

how can I get the world position of a pixel in the fragment shader? I tried to use this:
output.worldSpacePos = mul(unity_ObjectToWorld, float4(input.vertex.x, input.vertex.y, input.vertex.z, 1.0));

But then in my fragment shader I'm displaying the X position:
return fixed4(0.0f, input.worldSpacePos.x + 0, 0.0f, 1.0f);

And it's half green at (0.0), starts to get green at around (30, 0) to the right, and starts to get black at around (-30, 0) to the left.

#

@wet geode what is a "node like that" ?

worthy ridge
#

I'm trying to apply the output of a shader on top of itself 3 times each frame.

#

would graphics.blit help me do this?

#

im doing recursive image processing,

ocean geyser
#

@worthy ridge that's actually what I'm currently trying to do, unsuccessfully though. I'm trying to use the render texture as both source and destination.
It does output the shader, but I can't get it to get the source texture value from _MainTex. I might be doing something wrong though

worthy ridge
#

@ocean geyser what I'm doing now is simply using two render textures

#

@ocean geyser i load a texture into one RT1 using graphics.blit and then process RT1 with RT2 as the destination

#

@ocean geyser then i repeat the other way, process RT2 into RT1 using graphics.blit

#

I don't know if this is bad practice or whatever, but it seems to work in an update loop for some realtime image processing

ocean geyser
#

I actually just tried to use an extra texture rather than a single render texture, that also work.
Your process is also fine - but doesn't it also mean you need to change the texture you're using every time? from RT1 to RT2 and vice versa?

worthy ridge
#

yeah, i swap source and destination every time i want to run my shader again on its result

#

im guessing you can't read and write to a RT at the same time

ocean geyser
#

no I'm not talking about the processing it self - I'm talking about the usage of it.
You're doing recursive image processing - what happens when you're done with the processing?

In my case for example I'm drawing the end result, meaning I need the result to be attached to a material.
If I did it your way, I would also need to call renderMaterial.SetTexture("_MainTex", RT1); , and sometimes RT2.

#

and yeah you can't read and write to an RT at the same time, but you can use 1 render target + 1 texture.
Process the texture into the render target, then copy the result back to the texture.

worthy ridge
#

I'm only looping a pixel errosion shader over and over a few times each frame in Update() before displaying the result in the gameview

#

why would i need to call SetTexture?

ocean geyser
#

how are you displaying it in the gameview?

worthy ridge
#

pretty simple, i just have my RT's defined in the project and have assigned one of them to the materials albedo map slot

ocean geyser
#

right. But that slot accept a single texture. Which RT did you assign to it? RT1 or RT2?

worthy ridge
#

RT2. It since it's the one used last in my code.

ocean geyser
#

Well you're doing it multiple times in a single update, so I guess in your case it's not really an issue. I'm doing it once per frame

#

anyway it works for you now then?

worthy ridge
#

yeah it does

#

including RenderTexture.GetTemporary

ocean geyser
#

Yeah I saw that when googling, didn't like the idea of it though. I much prefer to have a constant extra render target/texture, assuming it's only 1. That's just me though.

#

Any chance you could help me with the world position issue I'm having btw?

worthy ridge
#

sadly i have to sleep now

#

good chat ๐Ÿ™‚

uncut karma
#

@ocean geyser that world space stuff looks right to me, assuming input.vertex is in object space

sand wasp
#

Alright, so, I'm converting the Shader Graph node Gradient Noise from HLSL:

float2 unity_gradientNoise_dir(float2 p)
{
    p = p % 289;
    float x = (34 * p.x + 1) * p.x % 289 + p.y;
    x = (34 * x + 1) * x % 289;
    x = frac(x / 41) * 2 - 1;
    return normalize(float2(x - floor(x + 0.5), abs(x) - 0.5));
}

float unity_gradientNoise(float2 p)
{
    float2 ip = floor(p);
    float2 fp = frac(p);
    float d00 = dot(unity_gradientNoise_dir(ip), fp);
    float d01 = dot(unity_gradientNoise_dir(ip + float2(0, 1)), fp - float2(0, 1));
    float d10 = dot(unity_gradientNoise_dir(ip + float2(1, 0)), fp - float2(1, 0));
    float d11 = dot(unity_gradientNoise_dir(ip + float2(1, 1)), fp - float2(1, 1));
    fp = fp * fp * fp * (fp * (fp * 6 - 15) + 10);
    return lerp(lerp(d00, d01, fp.y), lerp(d10, d11, fp.y), fp.x);
}

void Unity_GradientNoise_float(float2 UV, float Scale, out float Out)
{
    Out = unity_gradientNoise(UV * Scale) + 0.5;
}

to C#

Vector2 gradientNoisedir(Vector2 p)
{
    p = new Vector2(p.x % 289, p.y % 289);
    float x = (34 * p.x + 1) * p.x % 289 + p.y;
    x = (34 * x + 1) * x % 289;
    x = ((x / 41)%1) * 2 - 1;
    return (new  Vector2(x - Mathf.Floor(x + 0.5f), Mathf.Abs(x) - 0.5f)).normalized;
}

float gradientNoise(Vector2 p)
{
    Vector2 ip = new Vector2(Mathf.Floor(p.x), Mathf.Floor(p.y));
    Vector2 fp = new Vector2(p.x%1, p.y%1);
    float d00 = Vector2.Dot(gradientNoisedir(ip), fp);
    float d01 = Vector2.Dot(gradientNoisedir(ip + new Vector2(0, 1)), fp - new Vector2(0, 1));
    float d10 = Vector2.Dot(gradientNoisedir(ip + new Vector2(1, 0)), fp - new Vector2(1, 0));
    float d11 = Vector2.Dot(gradientNoisedir(ip + new Vector2(1, 1)), fp - new Vector2(1, 1));
    fp = fp * fp * fp * (fp * (fp * 6 - new Vector2(15,15)) + new Vector2(10, 10));
    return Mathf.Lerp(Mathf.Lerp(d00, d01, fp.y), Mathf.Lerp(d10, d11, fp.y), fp.x);
}

void Update()
{
    UV = somevector2;
    Outputt = gradientNoise(UV * Scale) + 0.5f;
}
#

For some values, my converted function is spitting out identical values to the source HLSL function, but for others it's spitting out either totally unexpected values, or just out of sync values. Did I convert it wrong?

last robin
#

i think x%1 might be different behavior from frac(x)

#

try makingfrac(x) to be x - floor(x)

sand wasp
#

ok let me try that

last robin
#

x%1 i believe can be negative but frac can't

sand wasp
#

If that's the case, that's probably it

last robin
sand wasp
#

but wait, wouldn't x-Mathf.Floor(x) potentially spew negative

last robin
#

I don't think so

sand wasp
#

Hmm, that's fixed the absurd artifacts

last robin
#

i'm also thinking maybe the modulo in unity_gradientNoise_dir acts differently in C#

#

not sure how to fix that one though

sand wasp
#

Yeah, I'm still getting some out of sync values

last robin
#

maybe try ```
float mod(float x, float y)
{
return x - y * Mathf.Floor(x/y)
}

sand wasp
#

as a % replacement you mean

last robin
#

yea

sand wasp
#

that made it worse

#

wait, I might be breaking order of operations...

#

@last robin I'm still seeing some out of sync values, but I think we've almost got it dialed in

last robin
#

the only other thing i can think of trying is float mod(float x, float y) { return x - y * trunc(x/y) }

I'm not sure if % is the same as fmod but that's what fmod does

#

i'm also not sure how to translate trunc

#

maybe that's just x - frac(x)?

#

there is Math.Truncate but no Mathf.Truncate

#

maybe (float)Math.Truncate((double)x/y)

#

๐Ÿคท

sand wasp
#

I'mma try swapping out my Mathf.Lerps for Vector3.Lerps

#

ahh it doesn't wanna do that...

craggy sage
#

hi all. Got a lil problem here. When I import VRML files into Unity, they can be visualized thanks to a shader I found online. Vertex shader for 3D Pipeline... But, this shader does not work for the HD pipeline. Does some one knows how to make it work?

sand wasp
#

Supposedly casting to int also truncates numbers, so a supposed mathf.truncate(float) is the same as (int)(float)

ocean geyser
#

@uncut karma yeah it is. At least it looks like

#

then again, it's also how it looks with
output.worldSpacePos = mul(unity_ObjectToWorld, float4(input.vertex.x, input.vertex.y, input.vertex.z, 1.0));
It's like unity_ObjectToWorld is an identity matrix. Not sure why that would be

last robin
#

you can just do mul(unity_ObjectToWorld, input.vertex); btw

#

or even float4(input.vertex.xyz, 1.0) if you want to change the w for some reason

ocean geyser
#

ha .xyz is nice. I'm using float4(input.vertex, 1.0f) rather than input.vertex btw because that is what I saw in the unity docs.
But neither one is working actually.. they don't result in world space coordinates, that is

last robin
#

ya i'm not sure why that would be the case unfortunately

ocean geyser
#

mm unity_ObjectToWorld should be the same as transform.localToWorldMatrix; right?

last robin
#

i believe so

ocean geyser
#

well I just tried to using it manually instead.
It "almost" works. It does seem to change when I'm moving the object, hence represent world space coordinates, but 0 is seems to be actually -74.
What is going on..

last robin
#

are you able to post the code that you're using unity_ObjectToWorld in?

#

would be easier to see what's wrong

ocean geyser
#

ha the shader actually works on a "clean" object.
I think the problem is because I'm trying to use Graphics.Blit(). I guess I need to push some matrices my self in there

last robin
#

oh yeah

#

that makes sense i thought you were using this on an object

ocean geyser
#

yeah sorry, I didn't think it matters. I was the single line Graphics.Blit for some time now and it all looked the same, didn't even cross my mind.

#

I'm a bit confused though. The examples I found in the unity docs either use Graphics.Blit or GL... functions but without Graphics.Blit()
Any idea how to combine them properly?

last robin
#

can you link what docs you're looking at? Not sure

ocean geyser
last robin
#

oh just use Material.SetMatrix for passing a matrix

#

and then you can get whatever matrix you need from the camera or from the object

ocean geyser
#

oh just do it my self then, ok. I got that piece of code already

#

well it still doesn't work correctly; as said it's world space coordinates, but with an offset (0 is -74 or so).
I did found this in the docs for transform.localToWorldMatrix:
IMPORTANT: If you're setting shader parameters you MUST use Renderer.localToWorldMatrix instead.
What renderer is it talking about though?

#

ok nvm, that's not the issue. I'm having scale on the object, and removing the scale fixes it. I'll try to look into that, but it looks like the solution.

#

Ok it seems to work now. Thanks for the help @last robin !

sand wasp
#

@last robin I think I fixed it. Rather than perfecting my translation from HLSL, I just took what I had and translated it back to HLSL

#

I'll have to test later, because it's 4AM and I need sleep, but either way you was a hugehelp

steel kayak
signal rapids
#

Hi! Is there an easy way to create a Lit Shader with fuzz in the shader graph, like in Marmoset?

#

Or perhaps any documentation on the fabric node

steel kayak
#

@signal rapids dither?

#

i'm very new to shader. ๐Ÿ˜…

signal rapids
#

@steel kayak Nice idea, but I'm looking for something with the fresnel node!

#

Probably

grand jolt
#

Does anyone have a snippet for creating a billboard that faces the camera?

#

in standard shader code (not shader graph)

oak latch
#

Any way to make a Quad face always the camera with PBR graph?

low lichen
oak latch
#

@low lichen helps ๐Ÿ™‚

#

I thought it would be much easier... waow

sand tartan
#

Hey everyone, I am trying to get the main light shadows in shader graph using this : https://blogs.unity3d.com/2019/07/31/custom-lighting-in-shader-graph-expanding-your-graphs-in-2019/
But it seems that it doesn't work in 2019.3.0b7 or am I missing something ?

Unity Technologies Blog

With the release of Unity Editor 2019.1, the Shader Graph package officially came out of preview! Now, in 2019.2, weโ€™re bringing even more features and fun...

tawdry zodiac
#

I would be interested in this sample converted to 19.3b and HDRP, was looking at it just today. Just learning thingsโ€ฆ

stone sandal
#

that sample project is only officially supported to work on 19.2 right now

sand tartan
#

Alright

stone sandal
#

that's my project haha unfortunately do not have the time to update and maintain it

sand tartan
#

That's strange because if I look at the github repository, function called are the same.

stone sandal
#

it might work but like i said, it's only officially supported for 19.2

#

other things unrelated to it might break ยฏ_(ใƒ„)_/ยฏ

sand tartan
#

Yup I understand ๐Ÿ˜‰

tawdry zodiac
#

@stone sandal no need to maintain, just update it once to HDRP 19.3 ๐Ÿ™‚ That would work for me ๐Ÿ™‚

sand tartan
#

@stone sandal I found a way to get shadows on the main directional light (just to let you know)
float4 shadowCoord = TransformWorldToShadowCoord(WorldPosition);
ShadowSamplingData shadowSamplingData = GetMainLightShadowSamplingData();
half shadowStrength = GetMainLightShadowStrength();
Shadow = SampleShadowmap(shadowCoord, TEXTURE2D_ARGS(_MainLightShadowmapTexture, sampler_MainLightShadowmapTexture), shadowSamplingData, shadowStrength, false);

tardy jolt
#

Hi, I made a grid system using GL and Shader's
but my Grid is always drawn over everything, even my UI
I can't find on internet how I can draw my grid underneath everything but my background image

#

here is my code

low lichen
#

@tardy jolt What object is this shader applied to? A plane on the ground?

north karma
#

Is there a way to change a master node/shader lighting model in Shader Graph? For example, from lit to unlit.

tardy jolt
#

@low lichen to this

#

I am drawing lines

stone sandal
#

@sand tartan Iโ€™m actually a dev for shader graph , Iโ€™m well aware how to get it working, just havenโ€™t been able to update the blog c:

tardy jolt
#

@low lichen the result gives this

sand tartan
#

@stone sandal Oh alright cool !

north karma
#

I can create a Lit Master node inside a Unlit Shader Graph, but I can't delete the original Master node.

sand tartan
#

Maybe it might help someone else ๐Ÿ˜‰

tardy jolt
#

Also I use 0 pass no idea if it have something to do

low lichen
#

@tardy jolt So this is in orthographic view? If so, the Z position, which you seem to be just setting to 0, will determine if it renders over other objects.

tardy jolt
#

It is yes

#

I tried changing z pos

#

It didn't change anything sadly

#

My camera is at Z -10
My line is at Z 1

low lichen
#

@tardy jolt When are you calling the GL functions?

tardy jolt
#

"void OnPostRender() {"

low lichen
#

Have you tried OnPreRender instead?

tardy jolt
#

I didn't let me try

#

nothing is draw

#

when I use prerender

low lichen
#

@tardy jolt This simple example is working for me. The line is rendered behind objects in front of it:

private Material _material;

private void Awake()
{
    var shader = Shader.Find("Hidden/Internal-Colored");
    _material = new Material(shader);
    _material.hideFlags = HideFlags.HideAndDontSave;
    _material.SetInt("_SrcBlend", (int) BlendMode.SrcAlpha);
    _material.SetInt("_DstBlend", (int) BlendMode.OneMinusSrcAlpha);
    _material.SetInt("_Cull", (int) CullMode.Off);
    _material.SetInt("_ZTest", (int) CompareFunction.LessEqual);
}

private void OnPostRender()
{
    GL.PushMatrix();
    _material.SetPass(0);
    GL.Begin(GL.LINES);
    GL.Color(Color.red);
    GL.Vertex3(1, 1, 0);
    GL.Vertex3(-1, -1, 0);
    GL.End();
    GL.PopMatrix();
}
tardy jolt
#

I try thank you

#

@low lichen what are pushmatrix and popmatrix for ?

#

also it doesn't work as well

#

I must have done something wrong

low lichen
#

@tardy jolt As I understand it, it saves the current camera matrix and Pop restores it, in case you modify it I suppose.

#

@tardy jolt Are the elements you want drawing on top, sprite renderers and UI elements?

tardy jolt
#

They are not

#

I have
My camera > Z -10
My game elements > Z 0 > Sorting Layer : game
My UI elements > Z 90 (can't change it) > Sorting layer : UI
The GL lines drawing > Z 0

#

and here are my sorting layers

low lichen
#

How are the game elements drawn? With a sprite renderer?

tardy jolt
#

yes

#

I don't understand why I can't get this to work ><

low lichen
#

It's something to do with sprites

#

I tested with 3D objects. With sprites, I'm also seeing the same thing as you

tardy jolt
#

okay but why is it still over the UI ?

low lichen
#

Or actually, it's because of transparency

tardy jolt
#

if it's the problem I can disable it

#

how can I disable it ?

low lichen
#

Surely your UI needs transparency though?

tardy jolt
#

it does

#

I can also disable it if there is no other way but I would prefer avoid

low lichen
#

The problem is that transparent objects don't write to the depth buffer, so when the line is drawn after everything, it's testing against the depth buffer, which the transparent objects aren't on

tardy jolt
#

ah

low lichen
#

So the lines have to be drawn after opaque objects but before transparent objects

tardy jolt
#

how can I achieve this ?

low lichen
#

But it should also be fine to draw the lines before opaque objects, as long as you have the lines ZWrite

tardy jolt
#

okay

#

how can I achieve this then ?

#

also thanks for your help

low lichen
#

I thought OnPreRender would have done it, but I guess it's not ready to start drawing at that point

tardy jolt
#

seems so

low lichen
#

I'll try some stuff, see if I can get it to work and let you know

tardy jolt
#

thank you very much catthumbsup

#

I just spent 3 hours writing a grid system in 2D and I can't get this to be drawn behind !

low lichen
#

@tardy jolt I figured out one way to do it, but it's a little ugly because it requires an unnecessary Graphics.Blit, but it works. This is assuming you're not using LWRP/URP or HDRP:

[ImageEffectOpaque]
private void OnRenderImage(RenderTexture src, RenderTexture dest)
{
    Graphics.Blit(src, dest);

    // Your GL code goes here...
}
tardy jolt
#

oh thank you so much !

#

it's working @low lichen

#

I can draw a background behind it @low lichen ?

low lichen
#

@tardy jolt Yeah, that should work. Does it not?

tardy jolt
#

hum I'm not sure how to proceed

#

I just drag and dropped an image into the editor and set the sorting layer to background

low lichen
#

Hmm, I see the same thing

#

Looks like maybe GL.Lines isn't writing to the Z buffer

tardy jolt
#

it does

#

when I change the Z I see the line differently

low lichen
#

How so?

tardy jolt
#

this is what I get when setting line start to z 50 and end to z -50

#

and when setting it to 0

low lichen
#

Is that not it just clipping outside the far plane?

tardy jolt
#

I think so

low lichen
#

What is your camera's far plane set to?

#

That's got nothing to do with whether it writes to Z

tardy jolt
#

far plane is the Z ? It's -10

#

oh okay

#

maybe I could use something else than line ?

#

why are we getting so much trouble just to write some lines in background ><

low lichen
#

I think the image effect workaround is the problem. It's losing the depth buffer in the blit process.

tardy jolt
#

uh

#

so I can't get background image ?

#

what if we write the background using GL

low lichen
#

Is the background just a solid color?

tardy jolt
#

It's probably going to be an image

#

or a procedurally generated image

#

like, can't we draw the image using GL before drawing the lines ?

low lichen
#

I mean, sure, but that's not going to fix other depth issues

tardy jolt
#

I don't have anything but the background behind the grid

#

everything else is in front of the grid

low lichen
#

I assume the grid is always going to be uniform, right?

#

You're never going to skip a line or have crooked lines?

tardy jolt
#

Hum no

#

But the grid is dynamic

low lichen
#

The size of it?

tardy jolt
#

Depending of the zoom it changes

low lichen
#

Right, that should be doable without GL lines

tardy jolt
#

let me send you my code so that you can see

low lichen
#

It would reduce draw calls as well

next sinew
#

hey guys, trying to make an animated UI image. Just want it to scroll infinitely. Problem, i can't get my shader properties to show in the inspector:

tardy spire
#

I'm drawing a quad a bunch of times using Graphics.DrawMeshInstanced to connect vertices (the quads are stretched to look like lines). Is there a way to get the quads to cylindrically billboard towards the camera in a shader similarly to the line renderer? As you can see, the quads have a fixed alignment and it doesn't look great. The quad mesh sits on the xz plane and is rotated/scaled to connect points.

grand jolt
#

guy told me to go here

#

anyone know how to make a projectile that leaves a decal on a mesh that shortly fades away. specifically for vrchat

devout quarry
#

@next sinew it says you're using a material based on hidden/cloudmoving

#

and not UITextureGraph

#

your shader graphs are located under Shader Graph/

#

should look there I think

uncut karma
#

@tardy spire it would take some math, I don't know exactly, but mainly a cross product.
You need a way to identify the 2 verts at each end of the quad (could use vertexID and modulo or bitwise operators), you probably also need to know the "side" of the line as well (for flipping the tangent vector when creating the line's width).
You'd need the start and end of the line (that the quad is meant to represent), that line as a vector with the vector to the camera can be used to create a tangent, then"spread" each of the 2 verts of the quad outward (2 from start pos, 2 from end pos) along the tangent creating the width of the line

#

you can probably ignore the miter join... but it illustrates the general idea

grand jolt
#

Hello, I'm really a noob in shader, but yesterday I succeed to use the LWRP/Particles/Unlit shader for a distortion effect (yeah!), now I would like to access to the Advanced/Distortion/Strength (param of the shader) dynamically on my code is that possible? If anyone can highlight me it would be great ๐Ÿ™‚

stark urchin
#

How to multiply the uv node before texture sampling in the shader graph?

#

ok for some reason my uv node didnt have an output port, but i deleted and created a new one and it has one now.

kind helm
#

Is there any docs that talk about the difference between Unlit, PBR and VFX shader graphs?

tardy spire
#

@uncut karma thanks a bunch. I'll look into it and see what I can come up with

stark urchin
#

Hey guys, how do i hook up perlin noise in the shader graph in order to make my texture tiling look better?

#

the perlin noise node accepts a uv vector and returns a float, where do i use that float?

amber saffron
#

@stark urchin It's not very clear on how you would like your noise to make tiling look better...

stark urchin
next sinew
#

@devout quarry you nailed it fam! Thx

meager pelican
#

@stark urchin That's not a shader thing. It's a "how to author seamless textures in a photo editor" thing.

There's a quick trick you can use depending on the texture: Cut it into 4 equal chunks and exchange the four "corners" diagonally. Swap Upper left with lower right, etc. Then you clean up the seams in the "cross" across the middle. It will tile. But it's not a "shader trick", pass the resulting texture into the shader. ONCE.

stark urchin
#

@meager pelican I get what you are saying but I don't have an artist and giving a chance to my artistic instincts will result in me dying of hunger. Luckily, it turned out there is an algorithm for creating procedural stochastic textures by tiling and blending and it works awesome! https://eheitzresearch.wordpress.com/738-2/

kind helm
#

Cleaning the seams in the cross is not part of what a shader does?

#

I mean if you want to do it at runtime

stark urchin
#

and turns out this guy works for unity and has created a package and custom shader graph node for it

#

arent i lucky?

meager pelican
#

Sure. Gimp can create textures for you too if you want. Some of the "noise" types have a "tileable" option. It all depends on what you want...real pics or noise.

You can find many on the net too. Or use that package.

#

@kind helm Shaders "do" what you program them to do, but normally you don't want to compute all that stuff each frame for each texture. If you can do it once while generating/making the asset, do it once and be done. Don't make the poor GPU do it every frame for all time. The drudgery! The drudgery! The horror! ๐Ÿ˜‰

#

@stark urchin That's a pretty impressive blog he has. (eheitzresearch)

#

@kind helm EDIT: But it's OK to use a GPU to generate the art asset AND THEN SAVE IT OFF to a texture for use in a game. ๐Ÿ˜‰

formal tide
stark urchin
#

@meager pelican sadly, i cant make it work, i get errors, im using 2019.3 beta

#

see what is says

This version is distributed here as a custom package containing ShaderGraph 6.7.1 entirely, with our added code. It requires using Unity 2019.2 or later, and a project that has either the LWRP 6.7.1 or HDRP 6.7.1 package installed. Make sure to update your render pipeline package to that version in the package manager.
#

does this mean that it works only with shadergraph 6.7.1 or this and above

#

im using 7.1.2. It's weird how the whole shader graph code is copied just because a custom node is added

#

also the manifest file, i need to add this line to it:

      "com.unity.shadergraph": "file:../procedural-stochastic-texturing",

meager pelican
#

IDK, I can't even see the errors.

Do a google search for some free ones, check the asset store, or "exercise those art skills". Otherwise IDK what to tell ya. Good luck. Art is one of the hardest parts of game dev (it's all hard, in a way). That's why there's often more artists on a game than any other discipline.

stark urchin
#

im gonna try to fix it first, worst ill end up buying textures, so not a big deal.

uncut karma
#

@stark urchin yes it only works on 6.7.1, you might be able to copy only the custom code to 7.1.2 if the shader graph api hasn't changed, but you still must use a custom copy of 7.1.2 because you will lose changes if modifying a package directly.

stark urchin
#

@uncut karma got it, ty.

brazen kernel
#

is it possible to import blender made shaders into unity?

stark urchin
#

@brazen kernel Sounds pretty impossible.

brazen kernel
#

So no

#

Shame, shame

#

But it's kinda understandable

stark urchin
#

Guys, can someone check if he has Blit option in the forward renderer? I have only Render Objects and the youtube tutorial I'm watching has also Blit and something else.

sand wasp
#

All these toon sharers only support one light source.

wet geode
#

why dont i have the custom function node in unity

#

shadergraph is up to date

#

i'm using lightweight RP

cosmic prairie
#

@wet geode is your Unity version up to date?

#

it might say lw rp is up to date because for that version of unity it is

wet geode
#

@cosmic prairie hmmm apparently i wasnt up to date. Its weird because im sure i checked a few days ago and it was

cosmic prairie
#

weird, I never trusted the package manager, it was super buggy when I started using it, it seems to be usable now tho ๐Ÿ™‚

signal rapids
#

Hi! Can anyone point me in the right direction for how to generate geometry or instances of geometry on surface with Shader Graph?

#

Like generating grass

#

From an existing set of prefabs or meshes

alpine cliff
#

Hi everyone. How convert stencil buffer from shader to shader graph ?

fervent tinsel
#

@alpine cliff sg doesnt support stencils atm

#

You'd need some custom code to access them

alpine cliff
#

What is custom code means? Is that custom script code from c# or custom function in shader graph?

cosmic prairie
#

I think custom shader code, since you need a pass for rendering to stencil buffer I think? or can you render to stencil buffer from just any pass? If so you can use custom function

fervent tinsel
#

most likely means custom modifications to the SRP itself

#

no idea if you mean URP, LWRP or HDRP tho

#

in HDRP I had to modify the HDRP code itself to get stencil data (but I didn't expose it myself to SG either)

#

the main issue is getting the access to the buffer

#

I have no idea how this even happens on URP/LWRP tho, I've only played with this on HDRP

tame skiff
#

Hey guys, I just updated to Unity 2019.3 and now my shaders which I build with shader graph get errors like "redefinition of 'unity_Builtins2Array' (UnityInput.hlsl:114).
Does anybody can give me hint what is wrong or how to fix it?

alpine cliff
#

@fervent tinsel I am currently learning this video.

https://www.youtube.com/watch?v=xkcCWqifT9M&list=PLFt_AvWsXl0dohbtVgHDNmgZV_UY7xZv7&index=3

In this video, he use stencil buffer via shader. But i am using URP and there is no way to use shader direct like him. So if possible, i wanna know how could i make same thing like video via shader graph in URP. and if not what should i do?

In this bonus episode we create a stencil shader to achieve a cool limited FOV effect. Source code: https://github.com/SebLague/Field-of-View Some links abou...

โ–ถ Play video
fervent tinsel
#

I don't really know how stencils work on URP, but you may find some results if you search for LWRP stencil

#

I wouldn't expect it to be trivial tho

#

and definitely wouldn't expect it to work in SG alone

gilded lichen
#

@alpine cliff "best" workflow currently for "ShaderGraph with Stencils and other custom features" is to rightclick > copy code on your master node, paste into a new shader file (not shadergraph, text based) and adding your stencil features etc. there.

#

If it's something you do a lot then you might want to look into making custom master nodes, but that's way more involved

#

@tame skiff it's a known bug and they're working on it. No ETA. Disable "GPU Instancing" on your materials as a workaround

left pivot
#

hello how can I convert this into shader graph? ``` float3 halfVector = normalize(_WorldSpaceLightPos0 + viewDir);

#

_WorldSpaceLightPos0 is which node actually

#

I get what it is after that.

#

Is it main light direction?

devout quarry
#

@alpine cliff I have stencil shader working in lwrp/urp

#

Not with shader graph tho

alpine cliff
#

how can you do that?/

devout quarry
#

I can send you the file tomorrow

#

Umm send me a PM so I don't forget

alpine cliff
#

ok

devout quarry
#

This was the effect I made btw

alpine cliff
#

yeah this what i want it

devout quarry
#

Ok cool

alpine cliff
#

is this work in urp or lwrp?

devout quarry
#

Umm tbf I think it was lwrp

alpine cliff
#

i send pm to you with my email

devout quarry
#

I'll test it in URP tomorrow

#

Yup cool

alpine cliff
#

if lwrp is work i think there is some way to use in urp too

devout quarry
#

I think so too

alpine cliff
#

thank man ^^

random meadow
#

Hi there

#

Using legacy forward rendering... should a shader that has a ForwardBase always call ForwardBase first?

void sable
#

Hey guys, is there any way to create dissolve shader for the UI (overlay) in URP (2019.2)?

digital venture
#

hi all, i have a question too. Not sure if its the place to post it tho.. how do i make it so that objects in the distance dont get greyed out? i think it might be some fog?

brisk cloud
#

@digital venture You can change that in the Lighting Windows

#

Window > Rendering > Lighting Settings

#

All the way down, you have "Other Settings"

digital venture
#

oh it was that easy

brisk cloud
#

you can change the Fog Activation

digital venture
#

thank you very much

brisk cloud
#

and the distance

#

Welcome ๐Ÿ™‚

#

Hi All, I have a question: Can anyone tell me why the Colors look washed out when using a simple vertex Shader ?

tough roost
#

probably the metallic and roughness values?

brisk cloud
#

On the left is a Simple vertex shader made with shader graph (Vertex color node to albedo)

#

and on the right is a lit shader

#

they both use the same color ๐Ÿ˜ฆ but the result is not the same

#

I already tried to change those value, Shadow

tough roost
#

mhhh, Well looks it the same if you disable all the lighting?

brisk cloud
#

nope, everything is activated

#

this is very strange, I am scratching my head since 2 days

#

there is a post here where the person had the exact same problem

#

but I don't like the suggested solution

tough roost
gilded lichen
#

@brisk cloud Vertex color might be in wrong colorspace, depends on your authoring tool

brisk cloud
#

๐Ÿ˜ฎ

#

What do you mean ?

gilded lichen
#

Try the lineartogamma and gammatolinear nodes

#

On your vertex color

brisk cloud
#

(Am a shader noob)

#

ok trying it right away

gilded lichen
#

Before it goes into Albedo channel

brisk cloud
#

!!!!!!!!!!!!

#

NO WAY!!!!

#

IT FIXED IT!!!

#

I LOVE YOU SO MUCH!

#

Thank you so very much.... Savior of the day!

#

I have been looking for an answer for the past two days

cosmic prairie
sly breach
#

i want to draw decals on my texture

#

but im looking for something like blend 2 textures via 3rd BW texture

#

since decals are slow and not supported in mobile

#

( will be using 1000's of decals )

cosmic prairie
#

@sly breach you mean like a "lerp" function?

sly breach
#

yea

#

watching shader tut now

#

might figure it out

#

if you know a better way to do it, please tell

remote osprey
#

I'm trying to port a distortion shader from a 3D project to a 2D project with sprite shaders, but I'm a bit stuck... this works great in the 3D project, but in 2D, everything renders as solid black. I'm presuming I'm getting my spaces messed up somewhere... can anyone tell what I might be doing wrong in this graph? Thanks!

split willow
#

So, I'm new to shader development

#

And I really need some help here

cosmic prairie
#

@split willow just ask your problem(s) here and someone will (hopefully) answer them

split willow
#

Kk,

#

So is it a good idea to have a master shader as an image effect shader for an entire 2d render pipeline?

#

Because I'm programming a simple 2d engine In unity,

cosmic prairie
#

@split willow well I never tried making a custom 2D render pipeline before (that is what you are doing if I understood correctly, right?), but I mean if the image effects you are trying to do don't care about neighbouring pixels, or only the first effect needs them, I'd say its fine, but idk if I understand what you mean by a master shader, and why are you making a 2d engine? unity already functions as one? :D or are you making like a terrain system for it? btw you can also ask this in render-pipelines channel I think

inner oxide
#

Heya I think this goes in the right place, I was thinking of getting these 2 shaders from the asset store but I don't know if they'd work in unison or there'd be problems with them. One of them converts the unity scene into pixelart and the other converts pixelart into vectors. ThinkingBTTV

#

I don't really know how to determine otherwise, so sorry if it's an obvious answer. peek

low lichen
#

@inner oxide I'm not sure what you mean by pixelart into vectors. Can you link the asset?

split willow
#

Yeah, the shader renderes everything

inner oxide
#

Oops sorry lemme find the thing

#

And then this is the other one I wanna use

low lichen
#

@inner oxide It depends how they are hooking into the rendering. You may have to manually adjust the timing to ensure the pixel shader is rendered first and vector later.

inner oxide
#

Huh so do you think if I adjust that then they should work together?

low lichen
#

I've never used these assets. The vector one only has one review which says it doesn't work.

#

And it was last updated in 2015

plucky bone
#

Perhaps, it's hard to say whether they work together or can be made to work together

inner oxide
#

Hm

meager pelican
#

Maybe you're after a cartoon effect? Smoothing pixel art to "vector" is kind of a cartoon result. Just a thought.

inner oxide
#

Yeah thatโ€™s what I was hoping for at least

meager pelican
#

Well, what I'm trying to say is maybe look for a toon shader or "cell shading" instead. Depends on your input models.

sly breach
#

how can i get access to a custom shader texture ?

#

assuming i got 3 different textures

#

in C#

#

oh nvm, Material.GetTexture( name )

grave mauve
#

I'm rendering the entire camera viewport, and I can get the width and height of the camera viewport. But when trying to convert the width and height by the thread IDs, it is hard for me to figure out getting the right aspect ratio.

#

And yeah, it's a full screen compute shader.

Asking about Compute Shaders, been trying to fight against aspect ratio being incorrectly displayed on the Compute Shader itself. ๐Ÿ˜ฆ

I wanted to know how to convert the ID number of the dispatch thread ID into a nice normalized (-1, 1) coordinates for both X and Y axes.

uint width;
uint height;
Result.GetDimensions(width, height);
float2 uv = (id.xy / float2(width, height)) * 2.0 - 1.0;

meager pelican
#

Aspect ratio is width/height, which you already have.
Thread ID has nothing to do with any of that stuff that I know of.

last robin
#

You'd probably want to get the dimensions of the source texture, not the result

grave mauve
#

The dimension of the source texture is the camera render texture itself

#

So I guess I need to pass in a uniform to the compute shader, so the shader knows the dimensions of the camera?

meager pelican
#

Well, you could check for predefined unity stuff, it's there for regular shaders, but IDK if for compute shaders off the top of my head. Otherwise, yeah, and a uniform will be fastest. Whatever you do, be sure as hades not to compute it every time for every pixel. Ouch.

grave mauve
#

Compute Shaders don't have any predefined Unity stuffs, only standard HLSL stuffs

#

From the stats, Unity app is running at 13~14 ms, while the rendering thread is around 0.4 ms.

#

I already put in a ton of logic on the compute shader, so I think it's pretty fast,

#

What's amazingly confusing is that my other computer shader calculates the correct aspect ratio using the same algorithm as I mentioned above...

#

I am so confused...

#

The thread ID paired with the render texture (result[id.xy]) gives you "UV unit coordinates". This raw coordinate system needs to be applied with the camera's matrix transformations, in order to get the correct aspect ratio

#

I haven't touched the code in a long while, but I remembered something about this.

#

Better document this down. Anyway, that's all.

solar thicket
#

I have to say, without Shader Graph I would've never been able to make this in just 3 days

#

the ah, see through effect

#

though um does anyone know where I can maybe find a shader graph that's basically the standard URP Lit shader? I want to basically use this shader effect on everything that that Lit shader can also do and have it look just the same (if it's not being faded out).

devout quarry
#

If I'm working with a scene with unlit shaders

#

but I still want them to be influenced by the directional light so that the scene looks different at night

#

how would I organize that?

#

Have a 'night color' field for all my unlit shaders and blend between day/night color based on a parameter?

#

or something different?

grand jolt
#

How do I make a texture scrolling?

#

fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;

#

simply doing this wont work:

#

fixed4 c = tex2D (_MainTex, IN.uv_MainTex * _Time) * _Color;

low lichen
#

@devout quarry So you want the unlit shaders to uniformly become darker or lighter in all directions? Or should the faces of the mesh facing the sun be lighter than the faces facing away?

#

@grand jolt _Time is a float4. X is seconds / 20, Y is seconds, Z is seconds * 2 and W is seconds * 3.

#

Try multiplying by _Time.y instead.

grand jolt
#
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex * _Time.y) * _Color;
            o.Albedo = c.rgb;
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = c.a;
            o.Emission = float3(1.0, 0.2, 0.7)* pow (1.0 - saturate(dot (normalize(IN.viewDir), o.Normal)), 2.0);
            o.Normal = UnpackNormal (tex2D (_Normalmap, IN.uv_Normalmap));
        }```
#

it works with a +

#

thank you @low lichen

devout quarry
#

@low lichen yes so currently my unlit shader already has 2 colors based on lit/unlit side so using the direction vector of the directional light. What I want to add now is indeed uniformly lighter/darker based on whether it is day or night

meager pelican
#

That could just be an ambient-light multiplier.

so color.rgb *= ambientLightLevel.

devout quarry
#

how can I get the ambient light in shader graph?

#

ah there is an 'ambient' node

#

that's cool

worldly horizon
#

Hi, I recently switched to linear color spacing, and my blood and muzzle flash effects are not looking right. When I turn the intensity up on my directional light, the blood starts to look normal, but then the light is too bright. I'd like to have someone help me correct these issues - it would be greatly appreciated.

hoary umbra
#

Hi

stark urchin
#

Hey guys, how do I use the material.color property in shader graph?

low lichen
#

@stark urchin Material.color uses the _Color property name. So as long as you have a property with an internal name of _Color, it will work with Material.color.

stark urchin
#

@low lichen awesome, that worked, thanks, also I had to mark it as Exposed.

stark urchin
#

changing the material color of one object changes the color of all other objects that use that material

#

any way to change it just for the object?

#

answer is material property blocks

devout quarry
#

in SG

#

I'm using the ambient sky color node

#

just outputted to color

#

but with these lighting settings, where is this color actually set?

#

because the material is just orange

#

even though I set ambient color to green in lighting settings

devout quarry
#

hmm now it's working but seems that the ambient light node doesn't always update?

#

I have to open/reopen the graph

alpine cliff
#

How can i use shader type file in URP?

maiden gull
#

Did Unity just re-break LWRP Android VR on 2019.2?
I'm getting a ton of fancy problems with it forgetting how to map the eyes in single pass
Like it did a while back

olive brook
#

Hey, what book would u guys suggest me to read to leaen shaders really full ? From scratch

candid musk
#

Whats this? I opened my project this morning and i get this and the scene is magenta. Using LWRP

digital venture
#

hi guys can anyone help me figure out what to do? I bought a shadergraph asset and it came with an error. Looks like it can't find a custom function. has anyone experienced anything like this?

amber saffron
#

You might want to look if the mentioned asset exists in the project -> try to reimport it -> look if it has errors

digital venture
#

i figured it out. i had an older version of shadergraph, that didnt include custom function node

#

updated, reimported package and it works

#

thanks for replying though, appreciate the help

civic pike
#

Hey guys! I have a simple question: Imagine a cup of tea. Means I have a mesh of a tea cup and now I want to have some water inside which is represented by a cube with a transparent material. How can I achieve that the cube won't render the lower edges in order to prevent clipping out of the cups geometry?

amber saffron
#

The easiest solution would be to model the surface of the water inside the teacup.
Else, you could use stencil buffer to mask the "inside" of the cup, and display the cube mesh only where the mask is valid

plucky bone
#

It's easier to just have a blend shape than using a shader to mask it

civic pike
#

Thanks for the feedback @amber saffron & @plucky bone , will dig into it ๐Ÿ™‚

olive brook
#

Hey guys, what book would u suggest to learn shader in unity3d ?

plucky bone
#

There's none afaik

#

You're better off learning how graphics programming works in general

low lichen
#

There are some. Can't say which are any good.

plucky bone
#

I meant more in the way, there are no good ones

stark urchin
#

How do i use material property blocks in shader graph? I want to mark the _color input variable in shader as [PerRendererData].

grand jolt
#

Hi! Popping in to let computer programmers that there are extensions that allow intellisense to compute shaders

runic tangle
#

Hi all, I'm looking for some help, I have a shader that is using a splat map to blend 3 different textures into a terrain but the lighting is not behaving... I have a normal map. Not sure where I should be looking for a solution. Thanks

stark urchin
#

@runic tangle the problem is either with the properties of the light, or the normal map

#

oh sorry, didnt see you have a custom shader, so the problem might also be in the shader ๐Ÿ˜„

olive brook
#

@plucky bone @low lichen thanks

runic tangle
#

Thanks for the feedback @stark urchin Here is the shader, the issue arises when I add the additional texture lerps (channel G and B). I've tried removing the color multiplications but that does nothing...

low lichen
#

@stark urchin You don't need to add the PerRendererData attribute to be able to use it in a MaterialPropertyBlock.

sly breach
#

what is the inverse of tex2D ?

#

i want to set the alpha channel of a texture

#

inside the surf function

low lichen
#

@sly breach You mean you want to write to a texture in a shader?

sly breach
#

yes

low lichen
#

You can only write to RenderTextures that have been configured for it and only on certain hardware

grand jolt
#

inverting a texture looks like this vec4(1.0 - tex.r, 1.0 - tex.g, 1.0 - tex.b, 1.0 - tex.a)

low lichen
#

You can't just write to a regular Texture2D, like a sprite or something

sly breach
#

hmmm i mean to write into the pixel value

#

like this works right now ( sort of ) :
_MainTex.a = _Color.a;

#

but it makes the whole thing transparent 100% no matter the alpha value

low lichen
#

You don't write to textures like that

#

What is _MainTex? Is it a Render Texture?

sly breach
#

ye

#
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;            
// o.Albedo = c.rgb;
o.Albedo = c;
low lichen
#

I want to be absolutely sure that you know the difference between a render texture and a regular texture. In the material property, the texture thumbnail is of an eye, right?

sly breach
low lichen
#

You have no texture assigned. How are you going to write to no texture?

sly breach
#

yeah... i figured there is a default value

#

once sec ill do that

#

i did assign it, still facing the same problem

#

trying to make a shader transparent

low lichen
#

Then why do you need to write to the texture?

sly breach
#

to set its alpha value ?

#

read few posts on the forums, nothing seems to do the trick for me

low lichen
#

The shader returns the color, so you can return whatever alpha you want

grand jolt
#

have ya tried o.Alpha = 0.5;

sly breach
#

yes, still nothing

grand jolt
#

aha

#

post full source of shader

sly breach
#
SubShader {
        
        Tags { "RenderType" = "Opaque" "Queue" = "Transparent" }
        LOD 200

        // Pass 
        // {
            ZWrite Off
            Blend SrcAlpha OneMinusSrcAlpha
            ColorMask RGB
        // }
        
        CGPROGRAM

        #pragma surface surf Standard fullforwardshadows
        #pragma target 3.0
        #pragma alpha:fade
#
void surf (Input IN, inout SurfaceOutputStandard o)
{
    fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    
    o.Albedo = c.rgb;
    // o.Albedo = c;
    
    o.Metallic = _Metallic;
    o.Smoothness = _Glossiness;
    o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
    // o.Alpha = 0.5;
    // _MainTex.a = _Color.a;
}
grand jolt
#
Tags { "Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector"="True" }

// inside Pass
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha```
low lichen
#

You have to assign the alpha value to o.Alpha

sly breach
#

i did before

#

( its commented out now )

low lichen
#

alpha:fade is not supposed to be in it's own #pragma. Put it after fullforwardshadows

sly breach
#

huh ... ?

#

ok

#

why tho ?

grand jolt
#
        
        Tags { "Queue"="Transparent" "RenderType"="Transparent" "IgnoreProjector"="True" }
        LOD 200

        Pass 
        {
            ZWrite Off
            Blend SrcAlpha OneMinusSrcAlpha
        }
        
        CGPROGRAM

        #pragma surface surf Standard fullforwardshadows
        #pragma target 3.0
        void surf (Input IN, inout SurfaceOutputStandard o)
{
    fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    o.Albedo = c.rgb;
    o.Metallic = _Metallic;
    o.Smoothness = _Glossiness;
    o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
    o.Alpha = 0.5;
}```
low lichen
#

It's a surface shader modifier, so it needs to go where the surface shader pragma is defined

#

Just like how fullforwardshadows isn't in it's own pragma

sly breach
#

interesting

#

do they both add up to the Standard ?

#

when i do this:

#pragma surface surf Standard fullforwardshadows alpha:fade
low lichen
#

No, Standard is the lighting model used.

sly breach
#

ok

low lichen
#

#pragma surface surfaceFunction lightModel [optionalparams]

sly breach
#

i tried the suggested edit, not the whole material is invisible

sly breach
#

oh nvm its fine now

#

thank you @low lichen person ๐Ÿ™‚

#

i wish i was more like you

#

so the default value is white after all

#

_MainTex ("Albedo (RGB)", 2D) = "white" {}

dark flare
#

UNITY_DECLARE_TEX2D_NOSAMPLER doesn't seem to actually separate the texture and sampler in Vulkan on Unity. In the builtin_shadersarchive, i noticed the defines for which version the macro uses doesn't include Vulkan. is it not possible in Vulkan for samplers to be separate objects from their textures?

#

@ me if you know

ocean bison
#

I've got specular reflections going in my shader.. but I''d like to "strech" the reflected light in my shader, sort of like the sun becomes a longer and longer oval when reflected. any suggestions how to modify this.. (I feel like it shouldn't be THAT complex.. but all my attempts are failing):
lightDirection = reflect(-lightDirection, normalDirection); float specularPower = dot(lightDirection, viewDirection) * viewAndLightDirFactor; specularReflection = attenuation * _LightColor0.rgb * _SpecColor.rgb * pow(max(0.0, specularPower), _Shininess);
Ideally I can control the "streching" with a float

#

(fragment shader.. if that wasn't clear.. sorry)

low lichen
#

Any reason you don't use Phong or Blinn-Phong shading? Which does have this stretching at extreme angles

ocean bison
#

don't know those.. will check em out now..

#

hmm.. phong looks like it just adds regular specular.. at least acording to wikipedia.. have a favorite source on phong?

low lichen
#

And you want something more than regular specular?

ocean bison
#

I want to get that sunset look going.. without using bump maps.

#

I expected it would just be a tweak.. like ignore the Y coordinate of the light dfirection, or view direction.. or somthing... and only compute dot proucts based on XZ plane positions/directions... but no such luck

ocean bison
#

getting closer... using this.. but it still ain't quite right.. adjusting the _ShineSqueeze only works so much... it just cant squeeze beyond a certain amount...```//custom
float3 XZLightDir = -lightDirection;
XZLightDir.y = viewDirection.y;
float viewAndLightDirFactor = pow(max(0.0, dot(XZLightDir, viewDirection)), _ShineSqueeze);

                //normal specular
                lightDirection = reflect(-lightDirection, normalDirection);
                float specularPower = 
                    dot(lightDirection, viewDirection) * 
                    viewAndLightDirFactor; // custom
                specularReflection = 
                    attenuation *
                    _LightColor0.rgb
                    * _SpecColor.rgb * 
                    pow(max(0.0, specularPower), _Shininess);```
worldly horizon
grand jolt
#

I'm trying to convert the Fountain Bleue HDRP shader for lens flare to work with gpu instancing for Single pass instance in VR. I'm getting an undeclared identifier 'UNITY_INITIALIZE_OUTPUT' when using UNITY_INITIALIZE_OUTPUT(v2f, o); in my v2f vert(appdata v) shader chunk

#

Anyone got a clue?

grand jolt
#

I'm fairly certain it's because of UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

brisk cloud
#

Hello!
I am trying to create a simple water shader with ShaderGraph and the Scene Depth Node to get a darker color for deep waters but I have trouble understanding what the Depth node returns and how to properly use it. (Again, I am a shader noob...)
Can anybody point me in the right direction or explain to me how to use the Scene Depth node please ?

rustic dragon
#

Anybody know if there are shader graph versions of the render pipeline standard shaders like Lit? Probably wouldn't be hard to replicate most of it, but I want to use it as a base to add a few things to it, unless there is a way to easily extend one?

short scroll
#

Failed to find expected binary shader data in 'UI/Default'.

#

Anyone ever got that error before ?

#

All my UI is just pink on device..

ornate blade
#

do i need to specify a pragma target 4.0 in a compute shader if i want to use a for loop?

#

new to compute shaders, experienced but bad at normal shaders ๐Ÿ˜›

ornate blade
#

So, I am having trouble find the correct term to google for my current problem. I am trying to transfer the main flocking calculation run from CPU to GPU. My objects need to be able to reference every other object to compare position and velocity, but I dont know how to reference a different member of my buffer from the current member

#

does anyone know either the term for me to google, or the data structure i should be using?

meager pelican
#

You mean indexing into a RWStructuredBuffer that you're already doing for the current index, but aren't sure how to use other indices?

ornate blade
#

yes!

#

I think i found an example, but it turned out to be non-unity and broke, so im currently looking through Shinao's flocking example

#

I think i understand the referencing other indices at this point

meager pelican
#

You might want to google "shader atomic operations" too. Remember massively parallel....

ornate blade
#

ahh thanks ๐Ÿ™‚

cosmic prairie
#

@brisk cloud with the scene depth node you can get the distance between the camera and the current background pixel, there are 3 options: 01 which gives you a number between 0 and 1, the Eye setting which gives you the distance in metres (this is what you need in this case) and Raw which idk what it does

#

you should calculate the darkness with substracting the current distance of the pixel to the camera from the scene depth and using the value as a UV value in a Texture Sampler

#

also you can multiply this value to change the opacity of the water if you set this all properly, also use texture wrap mode Clamp in your texture settings instead of Repeat

#

(btw I'm talking about using a gradient texture)

digital venture
#

hi guys quick question how come i cant apply my material to an imported model? Any other material applies ok, but the one specific i made doesn't

#

so am i missing something?>

low lichen
#

@digital venture Imported models get a special prefab asset that cannot be changed. You can't change the material, nor can you add scripts or anything to it

digital venture
#

ok so i can apply the material through mesh renderer

#

it just didnt work when i dragged onto the model

low lichen
#

Yeah, you can add the prefab to the scene and then make modifications

#

And then you can save that to your own prefab

digital venture
#

yes, so just the dragging thing didnt work for this model, but i know the drill

#

sorry for wasting your time, but i appreciate a reply good sir

meager pelican
#

@ornate blade - ahh thanks
Well, I qualified it. IDK what your algorithm looks like. If you only modify your "own" cell, it might not be a problem. BUT if you need to modify other cells, then be careful.

Basically, in C# you're looking at one cell at a time. But in a shader, you're running parallel (think 64 cells running at once). So make sure you not only don't clobber neighboring cells if you write to them, but also you need a way to know if they've been updated or not. Or maybe not! Depending on the flocking routine. Maybe there's artifacts if it HAS been updated. IDK. Might just work. You have to think about it in a parallel-processing mindset. Might not be a major issue.

ornate blade
#

@meager pelican its definitely going to be a new challenge for me. Luckily, my routine doesnt involve modifying the other cells, simply using their values to influence the changes in the cell im working in. I might work on some logic to detect whether they have been changed during the pass, but tbh the changes are so incremental that it shouldnt matter too much.

#

thanks a lot for your info, it helped get me on the right research track ๐Ÿ™‚

brisk cloud
#

@cosmic prairie Thank you for the explanation!
Gonna try this right away!

#

@cosmic prairie Does something like this look okay? I followed your instructions ๐Ÿ™‚

#

it's ugly but I am getting there ๐Ÿ˜„

tawdry zodiac
#

I have these errors from a pretty simple shader graph. If I open it and save without any modifications, the errors go away. Any ideas?

grand jolt
#

How would I go about adding transparent motion vectors to a custom shader in hdrp?

grand jolt
tawdry zodiac
#

Looks like the same error I posted just above

#

And I have pretty similar shader

stone sandal
#

vertex normal output on the master node needs to have the original normal connected in the chain somewhere, or else the master node isn't generating the the needed interpolator

#

it's a known issue logged in our buglog but the workaround currently is to include the original normal vector in the chain

cosmic prairie
#

@brisk cloud yes, that's looking fantastic so far! if you are going for a stylized water effect you can also use this depth value and a noisy texture to add some foam near the shores, btw nice voxel terrain, is that editable in-game? ๐Ÿ™‚

strange onyx
#

Due to me reconstructing normal Z, I am left with 2 free channels. my target prefers compute over texture reads, and I currently have 3 textures:
Albedo = RGB
Normal = RG
MRAO = RGB (Metallic, Roughness, AO)
Doesn't having the normal map unpacked alter all channels? If not, is it possible to repack my albedo into those free channels, and append them in order for my albedo output?
The result would have been something like:
Normal Map: RG = Normal XY, BA = Albedo RG
MRAO: RGB = MRAO, A = Albedo B
MRAO being metal,rough,AO

#

this would trade 1 texture read for 1 function (append)

brisk cloud
#

@cosmic prairie Thank you! A stylized water is what I would like to get! And no, the voxel terrain is just for the visual style, not editable ๐Ÿ™‚

cosmic prairie
#

ah okay ๐Ÿ™‚

sly breach
#

how can i modify the shader color value only for the current gameObject in code ?

#

oh nvm, just realised i can view the shaders source code in the archive

#

in my case its the _EmissionColor & _Color

drowsy abyss
#

Hello, everyone! I am trying to get a shader (made with Shader Graph) to render on a UI RawImage using a canvas set to Screen Space - Overlay. Does anyone know what I might be missing to get this working? Screen Space - Camera works fine.

plain urchin
#

Use rendertexture?

#

Not sure what u mean by missing. RawImage takes a texture btw, not sprite

uncut karma
#

@sly breach another way is to set the inspector to debug mode, it will show all material property names sorted by type ๐Ÿ‘

#

@strange onyx that should work but I would keep albedo together, it's overly confusing splitting the B out to another map. Metal is the least important channel as often a material is purely dielectric so metal is black.

uncut karma
#

Also the green channel might have 1 more bit with certain compression types

#

So often normals are rb and G is used for roughness etc

drowsy abyss
#

My custom shader doesn't use a texture input, it's for a health bar that is completely generated inside the shader.

#

I'm not sure why my shader works in world space, but doesn't display correctly when attached to a screen space overlay. I assume it has something to do with the canvas?

#

@plain urchin I'm using a RawImage with a null texture and a custom material.

strange onyx
#

@uncut karma I would be the only one using such a workflow, so I wasn't worried about confusion. The problem I ran into was that amplify didn't provide a means to specify UV coords on appended results, which was in and of itself an issue.
The other issue I ran into in general was not knowing the formula to essentially build a normal from 3 greyscale inputs. Google didn't help much either. It's only one more texture read, so I should still be fine.

#

what I would like info on is how to read a specific range for a greyscale map. e.g. grey25 grey50 grey75 and white values could be used as input. Bungie uses a method like this where specific values in a texture mean specific outputs, allowing them to divide a single channel into multiple outputs.
DICE does similar with Battlefront 2 in that they use a "slice mask" channel as an array index for a texture array. I am curious how I can read and process specific ranges.

drowsy abyss
#

@strange onyx If you are using Shader Graph, I believe you need the step node for that.

strange onyx
#

I'm using amplify, then modifying the vert/frag output for performance

#

the later I am very limited in knowledge of, so I mainly rely on amplify

drowsy abyss
#

I was just thinking, how about multiplying your gradient against a colour ramp?

#

I'm not familiar with amplify, but I'll see if there's a function like that.

#

@strange onyx I looked around Amplify's documentation but can't find anything without having the asset myself. I would look at using a colour ramp if amplify supports that.

strange onyx
#

might be a similar concept

#

will look into it.

drowsy abyss
#

A graphic similar to this would be your input (with the black on the left, most probably).

#

Also called colour correction. The math is very similar.

strange onyx
#

Basically, Bungie uses a dye system where the albedo is greyscale until color is added. I was thinking of taking that concept, using a greyscale mask, and multiplying color to the result based on the greyscale values.

drowsy abyss
#

This sounds interesting; what's an application for it? Team colouring?

strange onyx
#

their shader system

#

1 sec

drowsy abyss
#

Like, as in shaders for hard surfaces?

strange onyx
#

in game shaders

#

not shaders as in code.

#

essentially like an item or json or such, that tells the game what colors to apply. There is an article on their workflow, which isn't really designed around RPs like Unity or Unreal, so implementing their design comes with a penalty (trust me, I have tried). They use a LOT of shaders compared to most engines, so their RP is centered around that. basically a few instances of specialized uber shaders.

#

during the devcon presentation, one of the devs said if they could go back, they would have given more values to metalness, but otherwise the system is solid for them.

#

but the key snippet to grasp here is the dye system slice. essentially contains a few select color values as a sort of mask to tell the in game shader what to change.
I personally want a bit more control over this, so I am willing to dedicate a channel to allow for up to 5 values, and ALL portions alterable rather than select portions.

#

Albedo even in their setup doesn't use alpha That alone leaves a free channel if I follow a similar setup

#

it also allows me more values for metalness.

#

Another use case I actually implemented in Unity was DICE's Slice Masking for detail normal maps. They take small slices of detail normals (e.g. cloth, leather, etc), a well optimized base normal, and do some magic to generate a result on par or better than a 4k normal without the memory overhead.

#

and as affirmation I got it right:

drowsy abyss
#

Well, that's just cool.

strange onyx
#

I just love learning neat tricks like these.

#

BTW, DICE's slice mask and Bungie's Dye system was what lead me to come up with the concept of using a single greyscale channel with however many values you define as individual color parameters. All you would need to do is adjust them at runtime, and you can color any part of the albedo any color. Just need to learn how to implement it and I can release a shader.

#

sorry for the wall of text

drowsy abyss
#

Oh I see. You're completely palette-swapping your greyscale image as your colour input if I understand correctly.

strange onyx
#

yep. all the greyscale is used for is to provide the details.

#

the highs and lows

drowsy abyss
#

Okay, I can comment on this.

#

What you are doing is essentially colour correcting, except with a 100% power. That basically makes a colour lookup system.

strange onyx
#

so same concept to some extent?

#

only inside the sahder

drowsy abyss
#

Exactly the same unless I'm missing something.

#

You don't have to colour correct with smooth ramps. Your ramp (the dye gradient) can be as janky as you want.

strange onyx
#

shouldn't be. I would be following Bungie's gstack for all other mapping, and increasing metallic range, if I can figure out how to read specific ranges like they do.

#

in the end, I still have 3 texture reads, but very precise control over the results.

#

I wouldn't have to swap out an entire albedo to go from pastel to deep

#

and even PBR maps like metallic and roughness can be altered with another form of input. I could theoretically alter the ranges on them to alter those effects as well.

#

compute over reads.

drowsy abyss
#

Regarding my UI shader, I managed to solve my problem by attaching a second camera as a child to my main camera that only renders the UI layer. My UI canvas is set to "World Space".

#

HDRP does not play well with Camera - Screen Space even natively.

prisma birch
#

Anyone know how to update unity's default materials after importing HDRP?

drowsy abyss
#

Yeah, I had to do that recently...

prisma birch
#

Freshly imported assets and the model preview are displaying models with a pink texture

#

๐Ÿ˜ฎ Do you have a solution?

drowsy abyss
#

Look under Edit > Render Pipeline in the editor.

prisma birch
#

I played with that for a bit but I didn't mange to fix it

drowsy abyss
#

For me, I had to swap all my objects' materials out after that. "Default-Material" won't cut it anymore under HDRP.

alpine cliff
#

Hey guys.
How can use shader file in URP?

drowsy abyss
#

@alpine cliff Create a material and attach the shader to that. Then, use that material on a Renderer component.

#

Unless I fail to understand what you're asking.

alpine cliff
#

@drowsy abyss I have shader format file and i want to use in Universal renderer pipeline. if i just do what you said, the object shown pink color.