#archived-shaders

1 messages ยท Page 125 of 1

devout quarry
#

If you have any alternative ideas I'm very open to suggestions haha

still carbon
#

but if you're using a cutout shader, only the bush area should be writing to normals in the first place

#

but I think unity's outline system just uses its own default shader on everything to create the outlines so

devout quarry
#

Well I say 'cutout' but maybe I'm using the wrong terminology.

#

I'm using a custom outline shader

#

And for the 'cutout' I used shader graph

#

Basically I'm plugging the alpha value of the bush texture into the alpha slot

#

And then also using a slider value for alpha cutoff

still carbon
#

yeah, that should cull the pixels outside the cutoff range and thus not write to depth normals there

#

you just have to do that cutout in your outline shader too, if that's not in SG

devout quarry
#

Well if you look at the first row of images in the picture I shared, that's kind of my issue Right, that color and depth are being culled but normals are not

#

And yeah outline shader is not shader graph

still carbon
#

yeah so would have to see what you're doing in your outline shader code. Are you using discarding the pixel in the fragment function using discard; or clip(alpha - _Cutoff); ? (either are fine)

devout quarry
#

Will check later, not 100% sure

#

I'd like to mention too that I'm using the outline shader within a renderer feature in URP

#

There is no
outline material applied to the bush or something

still carbon
#

like, it replaces the outline function for everything ?

devout quarry
#

Umm yeah it draws an outline over everything using depth/normals and color textures it gets from the scene camera

#

Or well active camera rather

still carbon
#

ok well it should work then, the shader graph shader should only be writing the non-clipped pixels to the depth buffer, so not sure what's wrong. If the shader wasn't culling the depth write of those pixels, then the leaves in further behind the culled areas wouldn't be seen since they'd be depth culled

devout quarry
#

But only the non clipped pixels are writing to the depth buffer right?

#

It's normals that's the issue

still carbon
#

yes only the non-clipped pixels should be writing to the depth buffer if your shader is alphatested/opaque and clipped pixels, not transparent

#

so i feel like there's an issue elsewhere

devout quarry
#

I am generating the normals texture myself since URP does not provide it

#

You think that's the issue? That there is no link between the cutout shader and my normals texture?

#

So everything is just written to my normals texture, even the pixels that should be clipped

still carbon
#

yeah that would be an issue, as I guess you're not outputting to that render target with your shadergraph version

devout quarry
#

Ah right that would make sense

still carbon
#

Might have to bind an RT and create a custom node you can use to write normals to it from your shader graphs. Could implement the new keyword functionality to only have the shader path in editor

devout quarry
#

Yeah I think I know what you mean

still carbon
#

Either that or, for all selected objects, render them all manually using a replacement material/shader in one call which has _MainTex and _Cutoff and renders the normals to a texture in post process for you to draw outlines with

devout quarry
#

Will give it a try

#

Thank you for the input, it has been very helpful and enriching

still carbon
#

No problem, hope you manage to work it out!

floral blade
#

Trying to get shadows on this vertex animated shader, but shadows don't follow the vertex animation, anyone able to help?

still carbon
#

are you using a surface shader?

#

if so, you need to add addshadow to the #pragma surface surf line to generate a shadow pass from your code instead of a default one. Otherwise you'll have to write your own shadow pass that uses the vertex modifications. @floral blade

floral blade
#

It's a fragment shader, maybe that's why having trouble, should I just do another pass for shadowcaster and copy paste the vertex modifying code or is there another way?

#

actually got it going thanks @still carbon ๐Ÿ™‚

hoary sonnet
#

hi. I am having an issue with shader graph. Using 2019.3.0b5 with SG & HDRP 7.12

I am unable to set surface options such as surface type (opague vs transparent). I mean - I am setting it on master node in SG but in the inspector of material created with that shader the changes isn't reflected. Is there a bug somewhere or maybe I am doing something wrong?

teal pilot
#

@hoary sonnet When you say "I am setting" does it means you just change the parameter in shader graph ? Cause you need to save the graph to see change in the editor

hoary sonnet
#

yeah, I am saving the asset itself after setting it in master node

teal pilot
#

@hoary sonnet oh ๐Ÿ˜ฆ sorry then I don't know =/

young kestrel
#

Hello. I am playing around with shader graph and made it bend based on location of a player, I would like to make it work with other gameobjects too. Any suggestions how to do it? Currently I am setting player position using global variable.

low lichen
#

@young kestrel How many objects do you want this to work with? You can always just define multiple position variables and use all of them in the shader.

young kestrel
#

would be great to have more than 10, but having that many position values sounds a bit complicated

low lichen
#

@young kestrel Shader Graph doesn't support vector arrays, does it?

young kestrel
#

no support for vector arrays

low lichen
#

Then I don't see any way to simplify supporting so many positions

#

What is this for?

young kestrel
#

for foliage to move away when player and enemies walk around

#

Hmm looks like its possible to create a custom node which can be coded. I'll look around there might be a chance to do it

still carbon
#

@low lichen they should be able to support vector arrays in a custom function node

stoic mist
#

Hey guys - if I wanted to switch the shader that is being used to render a gameObject in a script, should I be doing it by:

  1. Somehow changing the shader within the material that is applied to the gameObject (is this even possible?)
    OR
  2. Having an entire extra material with the other shader already applied, and changing the material of the gameObject?
somber blade
#

The shader is the very first option in the inspector when you select the material. If you know for sure you want everything that uses that mat to use your shader then you can choose not to make a new material. I would just make a new material though

stoic mist
#

thank ya

warm shale
#

Anyone know how to create a shader/shader graph for HDRP, that would do the following: Be invisible, not render anything behind it. Use is for AR, where we want to put a 3d object in front/behind a plane from the camera, and need invisible objects occluding the 3d render.

fervent tinsel
#

I'd imagine you'd need bit more low level access to things than what shaders expose to make that happen

#

like, you could render the blocking object to stencil buffer and then use special shaders for the objects that take that into account

amber saffron
#

In recent HDRP, you could use the custom pass volume to render the object before everything, and only write in the Zbuffer

proud robin
#

Can't believe that Unity doesn't have a "double-sided" checkbox for their cutout and transparent rendering modes by default...

#

Or that most posts say that the best solution is to duplicate the geometry and flip the normals in the 3d editing software

#

That said... I have no idea how to make a double sided material where the normal map works on the backfaces too ๐Ÿ˜›

woven loom
#

So quick question about shader graph

#

Uh, how should I put this...

#

Is it supposed to work with any pipeline?

#

Because I heard a few weeks back that it was only compatible with the lightweight render pipeline

#

But now I'm watching a thing about them from Unite Copenhagen that seems to imply that it should be compatible with everything

#

And uh... it shows a lot of features that I can't see in there, so I was wondering if what they're showing is not actually rolled out

#

Even though it doesn't seem like that's what they're saying

low lichen
#

@woven loom It works with the scriptable render pipelines, so lightweight/universal and HD. But not the built-in renderer.

woven loom
#

Ah I see

#

So lightweight is the universal one?

low lichen
#

Lightweight is getting renamed to Universal for 2019.3

woven loom
#

Oooh I see

#

Also uh

#

There's mention of a version 7.1.1 for ShaderGraph but the latest I can see in the package manager is 6.9.1

low lichen
#

Some version will only be available to the latest beta version of Unity. Which version are you on?

woven loom
#

Ah I see

#

I'm on the latest stable version

#

I'll add the 2019.3 beta version and see what I get from there

fervent tinsel
#

@woven loom 7.x is for 2019.3

woven loom
#

Hm

#

Oh there was also another thing... Is it possible to remove fog distance entirely?

#

Turns out something about it might be messing with my shader

fervent tinsel
#

Remove fog itself?

woven loom
#

Yeah, I think

wary stump
#

Does Shader Graph still have the bug where if you make a new exposed variable then rename it you cant edit anything until you save and exit then reopen?

gilded lichen
#

not in latest 2019.3 betas

wary stump
#

ok cool so they fixed it, ill wait for the main release then

junior wave
real basin
#

@junior wave that shader is written in GLSL which is not commonly used in Unity. there are ways to make GLSL work in unity but I don't know the specifics, another option is to convert it to CG or HLSL

junior wave
#

i figured as much, however i read that unity does support glsl

#

is there an efficient way to convert from glsl to cg/hlsl?

real basin
#

I've only ever converted things manually, there might be an easy way I don't know of. unity does support it but the exact formatting may be off, and some people say you might need to force unity to launch in OpenGL mode to use it

junior wave
#

not really looking forward to converting this manually GWchadThink

#

thank you for your help

#

i'll see what i can find

real basin
#

you could try looking for a program. unity itself converts HLSL to GLSL internally when it runs on OpenGL so it should be possible

junior wave
#

i found out that i could just rename "Program" to "GLSLRPOGRAM", just confirms how unexperienced i am with shaders. the shader still does not work however, it now renders completely black, the errors are gone tho... @real basin

wary stump
#

is there any way to flip a texture along an axis in shader graph

#

like on only one axis

#

to fix the problem of the x position

#

its just a basic texture so its just to flip it along the z

#

but i dont know how to in shader graph

real basin
#

Just multiply the UV coordinate by -1

#

x or y depending on which one corresponds to that

wary stump
#

what if i dont have a uv coord attached which one to add

real basin
#

the UV is just 2 values so it's only passing the XY values from Multiply to UV, Z isn't doing anything. try switching the -1 to X or Y and see which works

wary stump
#

so just use a regular UV or positon? not to great with shaders

real basin
#

I'm not familiar with shadergraph myself, but I think on the multiply node you just need to change X or Y to -1 instead of Z

wary stump
#

yea, i did that and neither worked lol, its showing up blank so it must be something else, unless i code something separate to flip it before it enters

real basin
#

or it might be you need to do UV.x = 1 - UV.x if this isn't a repeating texture

wary stump
#

its an orthographic camera projection mapped onto a render texture

#

but its faced upwards so its x rotation is a bit different

real basin
#

oh okay then yeah it should be 1 - UV.x so the values stay within the 0 to 1 range. multiplying by -1 only works with repeating textures

wary stump
#

soo use the one minus node?

real basin
#

probably? I've never used nodes

wary stump
#

Ah

#

were getting somewhere

#

ok

#

so the x works now the y isnt

#

so i guess i just have to one minus the x

#

alone lol

#

AHHH boieee

#

we gucci

real basin
#

hooray

wary stump
#

๐Ÿ‘

#

the more ya learn

wary stump
#

is there a way to use a texture to displace verts

#

basically taking a depth texture and modifying the mesh to displace verts along the y axis

#

ideally the transform node at the right will go into position however its not allowing me to which means somethings not right

stone sandal
#

you need the sample texture 2d lod node for vertex stage

wary stump
#

oh

#

YES

#

nice

#

ok

#

cool

#

now to make the mesh more high detail

dusk tapir
#

essentially, i want that white rounded bevel image in the bottom middle, to have the white space replaced with the gradient im generating

#

and this works for the most part, except it ignores the black border and the natural soft gradient/bevel on the image

#

and for some reason, it ignores the mask in my scene

#

as you can see, the part that has the material, just renders regardless of the mask that removes the text

wary stump
#

i think you have to multiply the mask by the gradient and then have that as the color

dusk tapir
#

that solves the bevel thing, but not the second problem

#

appreciated tho

wary stump
#

so you want the gradient to be where the white mask is and the inverted mask to..?

dusk tapir
#

and the material is just ignoring this mask

#

in the picture i posted, the other elements like text stop rendering when they leave the mask, but for some reason the material doesnt stop rendering until all of it has left the mask

gilded lichen
#

You can't create proper UI shaders that have all the stencil features (e.g. clip masks) with ShaderGraph right now

vocal lark
humble slate
#

I'm not so good in shaders but can't you lerp your alpha with the model y coordinate?

#

I also have my own question: Looking at the build-in shader file UnityShaderVariables.cginc I can see that the stereo matrices are defined in a constant buffer:

GLOBAL_CBUFFER_START(UnityStereoGlobals)
    float4x4 unity_StereoMatrixP[2];
    float4x4 unity_StereoMatrixV[2];
    float4x4 unity_StereoMatrixInvV[2];
    float4x4 unity_StereoMatrixVP[2];

    float4x4 unity_StereoCameraProjection[2];
    float4x4 unity_StereoCameraInvProjection[2];
    float4x4 unity_StereoWorldToCamera[2];
    float4x4 unity_StereoCameraToWorld[2];

    float3 unity_StereoWorldSpaceCameraPos[2];
    float4 unity_StereoScaleOffset[2];
GLOBAL_CBUFFER_END

However, I have no idea what the difference is between unity_StereoMatrixP and unity_StereoCameraProjection. Same with unity_StereoMatrixV and unity_StereoWorldToCamera. Shouldn't those do the exact same thing?

hidden knot
#

Hello,I am a beginner at shaders and especially shader graph as there is less tutorials about it with various effect as compared to the old renderer in unity. I would like to get help in changing the v.normal given below to v.vertex in shader graph v.vertex.xyz += v.normal * _Height;// scale vertices along normal.

dusk tapir
#

@gilded lichen you said you cant make UI shaders that follow stencils, but is there a better way to create gradients in runtime? i would love to not use shaders, but from what i could tell this was my best option

#

essentially, should i continue trying down this route, and just open the code that the graph generates and add stencils there, or just try something else

#

(and if i continue down this route, is there a way to make the shader not just black without putting a camera on the UI)

gilded lichen
#

@dusk tapir depending on your shader skills best way is to grab a copy of the built-in shaders, find the UI shader and make a copy of that to modify

dusk tapir
#

currently, i have 0 shader skills, just learned bout em yesterday, but i shall try!

gilded lichen
#

At some point I think either Unity or an Assetstore publisher will create a proper UI shader master node for ShaderGraph (and maybe it exists already and I just don't know)

#

But trying is good for learning :)

wary stump
#

i was now about to say doesnt shader graph support both 2d and 3d environments

dusk tapir
#

from what i can tell, it supports 2D environments, but only if its an actual scene, and not just a canvas for a UI

#

it has to have a camera on it

wary stump
dusk tapir
#

i watched the second one, thats why i was saying you need a camera

coarse hornet
#

Hey guys, I'm working on a project that will use a tile map, I don't want to use the built in tilemap functionality as I find it clunky, so what I've done is use shaders to render my tilemap onto a single quad using shaders with a lookup texture for handling the data and a tileset for the actual images.

However I have some friends who have suggested that the tileset should be on a texturearray instead of a texture atlas but the documentation for this is quite sparse and so I'm hoping one of you may know a good document or video explaining texturearray use in unity

drifting edge
#

is it just me or is the latest URP + Unity beta 2019.3.0b5 shader graph completly broken?

Shader error in 'Shader Graphs/Test': redefinition of 'unity_Builtins2Array' /Unity/DiggingGame/Library/PackageCache/com.unity.render-pipelines.universal@7.1.2/ShaderLibrary/UnityInput.hlsl(114) (on d3d11)

#

all packages latest version

#

and any ideas how to fix it? I can not use an completely empty shader graph without this error, existing shaders also broken, default shaders are working

digital shuttle
#

try uninstalling and reinstalling that package? maybe some garbage got left behind in an upgrade

drifting edge
#

you think I'd lose shaders in the process?

digital shuttle
#

Doubt it, but never hurts to have a backup

#

just uninstalling might not get rid of the garbage, so you should also delete that directory under PackageCache after uninstalling

drifting edge
#

Looks like that PackageCache folder is the actual package code, I would not have called that folder a Cache personally

#
Library\PackageCache
Library\PlayerDataCache
Library\ScriptAssemblies
Library\ShaderCache
Library\StateCache
Library\TempArtifacts
Library\UIElements
Library\webgl_cache
Library\APIUpdater
Library\Artifacts
Library\il2cpp_cache
Library\metadata

which of these folders can I safely empty you think?

#

is there a way to invalidate all cache for Unity?

#

is it GI Cache?

#

looks like it's due to GPU Instancing

digital shuttle
#

I have Library in my .gitignore, so I assume you can just delete all of it

drifting edge
#

really, wow good to know

digital shuttle
#

(and I didn't write that .gitignore myself)

drifting edge
#

thanks I think I will just delete that folder then on every upgrade!

digital shuttle
#

I think the "You do" there should be "You don't", otherwise none of that makes any sense

drifting edge
#

looks like my project indeed has a problem (this is after starting after deleting that folder)

#

I'm going to chech that manifest they mention

digital shuttle
#

there are a lot of Unity problems that go away on one or more restarts...

drifting edge
#

my guess the upgrade path for LWRP to URP is not flawless

digital shuttle
#

that is very likely

drifting edge
#

I will compare it to a fresh project

#

I'm just documenting this in case somebody has the same problem sorry for the spam

#

wow, did not expect this, my best guess: I had Visual Studio Code open. That has some kind of IntelliSense server running indexing these .tmp files and locking it for the package manager

gilded lichen
#

@drifting edge that error "redefinition of 'unity_Builtins2Array'" is gone now? In my experience it's related to VR rendering and/or having "GPU Instancing" enabled on materials. I have a bug report open about that

drifting edge
#

Unity is starting now, let me check

#

yeah did not fix anything

#

well seems this project is on halt until they manage to fix it

stone sandal
#

try adding "com.unity.render-pipelines.core": "7.1.2" to your manifest

#

it looks like something went wrong and it wasn't able to upgrade the dependency

#

might fix it /shrug

drifting edge
#

it is as herbst said, "redefinition of 'unity_Builtins2Array"

fossil cedar
#

anybody care to explain why Shader Graph has Vector1, 2, 3, 4 types... when it's generating HLSL that uses float, float2, 3, 4 ?

#

not to mention the same float types that Unity.Mathematics lib uses

inland dirge
#

Hi peeps, does HDRP have issues with alpha clipping?

#

I'm trying to create a alpha-mask-clipped version of the normal HDRP Lit-shader, and it appears to look okay in Shader Graph

fervent tinsel
#

I've only had issues with alpha clipping in the editor if I've had texture streaming enabled

#

and even then it's random

inland dirge
#

But in the editor just fades the alpha instead

#

^You can see the mask working, it just doesn't clip. :/

#

However

#

The preview looks fine?

fervent tinsel
#

yeah, that should work

inland dirge
#

... wait

#

wtf

#

It works properly if I don't have anything else beneath it?

#

wtaf

#

So should I just file this as a bug report or something?

umbral cargo
#

I wish the OVR (Oculus Integration) came with shaders that actually worked in the Universal Rendering Pipeline..

dusk tapir
#

i swear, im almost done with this shader, my (hopefully) final problem, is transparency

#

for some reason, while it gradates through the color, it changes transparency

#

(oh also just realized it isnt letting me input my texture...)

#

its over 700 lines, so i cant send all of it, but if anyone is willing to help, tell me where/when such a thing could occur

vocal narwhal
#

You can link to it via a service like hastebin

dusk tapir
remote osprey
#

I'm trying to make a 2D flag-waving shader for sprites that uses a mask to control what verts on the rendered sprite wave. I was able to do this in a shaderlab shader, but can't seem to make the same concept work in Shadergraph. Can anyone tell what I might be doing wrong?

dusk tapir
#

ive narrowed down the first problem, im 90% sure it comes from this line Blend SrcAlpha OneMinusSrcAlpha

#

i was following a tutorial, and they didnt explain why use those values, so i dont understand what it does, only that they said to put it in SubShader, but not in Pass

rapid tapir
#

Hey friends! I'm curious if this technique they used in Below to skew the geometry is within the purview of shader graph?

#

The skewing method starts at 23ish mins

warm marsh
#

Does anybody know how to guarantee a color is removed from an image when using either color mask or replace color in shader graph, I am doing it on a render texture where the camera background is hot pink so it doesn't cause conflicts with any palettes used in the game. I keep getting slight jagged artifacts of hot pink showing around the edge of my character though, only small but somewhat noticeable

plucky bone
#

That's because of alpha or transparency

#

You've got to set a threshold

warm marsh
#

figured it out, I had mipmaps turned on in the render texture - it was causing bleeding

cosmic prairie
#

@remote osprey what are you trying to use to tell the shader which verts to move? the sampled texture? or the X and Y? because to me it looks like none of them, you should multiply the wind with the mask, not substract

#

and what is X and Y?

#

and do the multiplication before you do the addition to the original vert position

steel acorn
#

Hey folks. I don't suppose anybody has any advice on using passes in Shaders?

#

I'm trying to split my shader into different passes, and I'm getting the error,

Parse error: syntax error, unexpected TOK_PASS, expecting TOK_SeTTEXTURE or '}' at line etc...
cosmic prairie
#

well without code we can't tell you where you made the parsing error

#

or is this a graph?

steel acorn
#

I'm happy to provide code - it's not a graph.

#

One moment...

#

(As Unity is booting - it's a grass shader, but I also need it to have triplanar, dissolve and outline qualities. I've got triplanar working, but the code was starting to look squirrely, so I figured I'd tidy it into different passes)

remote osprey
#

@cosmic prairie I'm using a sample texture to determine what verts are allowed to move (so a mask), and the x and y to determine the strength that they will be allowed to move. Of course there's not time nodes on there or anything yet to move them over time, so I'm setting the X and Y in the Material to test things, and rather than just the masked vertices moving, the entire sprite mesh moves its position.

sly breach
#

I got a simple shader but it won't work with colors, will only render black, why is that?

Shader "GLDebug/GLlineZOn" {
    SubShader {
        Pass {
            Blend SrcAlpha OneMinusSrcAlpha
            ZWrite Off
            Cull Off
            BindChannels {
                Bind "vertex", vertex
                Bind "color", color
            }
        }
    }
}
#

ok nvm, was something else

steel acorn
#

Sorry to bump, folks, still trying to work out passes within shaders. I think that my problems may stem from my StandardShader block, but have nothing conclusive. If anybody has shader experience, would appreciate some advice...!

gilded lichen
#

You have a surface shader there. Surface shaders expand into multiple passes internally

#

If you want a multipass surface shader it's actually easy but hacky and totally undocumented - just have multiple surface shaders below each other, no need to have "Pass" anywhere

#

They'll all expand into right passes (e.g. shadow collector, motion vectors, forward, ...)

burnt ether
steel acorn
#

Hello @gilded lichen - I'm fairly new at shader programming, so I may have the wrong end of the stick on this. The shader is initially a vertex shader (causing the models to move around like billowing grass), with the surface shader applying the texturing and colours to the model...

#

I'm not really trying to get a second surface shader on the object - after this piece, I want to apply an outer glow to the objects, followed by a dissolve effect.

#

In order to get these implemented cleanly, I'm trying to organise them with passes - somewhat for my own mental health.

#

I appreciate the advice to just do things with multiple surface shaders, but I'd currently prefer to learn how to do stuff 'correctly' with multiple passes.

#

Apologies if this sounds like I'm picking a fight here, just trying to understand the right way of doing things...!

gilded lichen
#

If you want to manually do custom passes you'll have to get rid of the surface shader and go lower level.

#

Also, while it's a good idea to organize things passes don't quite work as what you're trying to achieve

#

"passes" in shader terminology refer to drawing the same object multiple times with different settings - each is just drawing on top of the previous one with limited control over blending

#

"fullscreen passes" is commonly used as term for global Postprocessing effects that get applied to the whole screen buffer after rendering objects

#

What you want to do is better suited for having several functions that operate on the fragment shader level (or surface shader if you stick with that), but it's still one "pass" - one time rendering the object

steel acorn
#

That was sort of what I was thinking. I was going to do the vertex shader first, then clip pieces with the dissolve texture, then texture the object with triplanar, then apply a surrounding glow.

#

Hmmm.

#

Okay!

#

So I got completely the wrong end of the stick there...!

gilded lichen
#

Yeah I think just a mixup of terminology

steel acorn
#

Thanks man. Okay, so I need to just try and organise things inside the surface shader, I think.

#

I don't suppose you know of any examples of this that I could look at?

gilded lichen
#

I can highly recommend using something like Amplify (node based shader editor) for complex stuff

#

Always good to know the basics but that makes life easier

steel acorn
#

Yeah, I think that might be something for the next project... but right now, I gotsta grind it out, line by line. =D I have most of the logic, but just need to get it all working in place...

#

Without wanting to sound dismissive, most of these seem like relatively simple shaders, with a single purpose per shader.

#

You've helped me a lot, so feel no obligation - but if you happen to know of an example of a multi-function shader example, that would be amazing. =)

gilded lichen
#

Well, you could look at the Amplify examples, there's some pretty complex ones. Also, you'll find that especially contour changing effects (e.g. the outer glow you mentioned) are hard and need good preplanning. Some will only work as postfx, others might work with some tricks (e.g. inverse culling + normal offset + fresnel transparency)

steel acorn
#

Yeah, I was looking at the latter. I've just got dissolve working, so I just need to get the outline up and running and I'm (mostly) set.

gilded lichen
#

That shader is a good example of what I was talking about (it has a Pass at the top, and then the surface shader comes below without explicit pass as it unrolls into multiple passes)

steel acorn
#

...Ohh, so I can do separate passes at the top?

gilded lichen
#

Yep sure, sorry if I wasn't clear about that. You can have passes above/below surface shaders - think of a surface shader as just a block of N passes getting generated for you. Doesn't affect other passes around it.

steel acorn
#

Gotcha, okay, okay...

#

@gilded lichen ... any chance you could take a look at my current shader as I'm still a bit confused over the order these blocks are supposed to be assembled...

steel acorn
#

Whenever I try to add the pass at the top of my shader, I get a syntax error that claims I have an extra '{'...

quaint grotto
#

does any one know if unity supports RWBuffer in compute shaders

low lichen
#

@quaint grotto That's supported

quaint grotto
#

are you sure

#

because i get weird behaviour using it

#

unlike RWStructuredBuffer

low lichen
#

No, I'm not sure

quaint grotto
#

๐Ÿ˜‘

inland dirge
#

How do I enable height map displacement in Shader Graph for HDRP?

meager pelican
#

@quaint grotto define "weird behavior" in this context.

Also, interesting discussion here:
https://www.gamedev.net/forums/topic/678018-rwbuffer-vs-rwstructuredbuffer-or-rwbyteaddressbuffer/

Also what hardware and what DX level and what data type? May be implementation/device specific problems. Not saying it is, but maybe.

quaint grotto
#

@meager pelican weird as in when i set the buffer as RWBuffer the data is zero or just random, when its RWStructured buffer or Buffer then it seems valid

#

i assumed therefor that SetData does not apply to RWBuffer for unity

#

but i can't be sure of that

#

but its the only explanation i can think of so far

meager pelican
#

Huh. Do you need to set it frequently, or is it a one-time thing? Because you could create a compute pass to set it in the shader, like copy it from a texture or RWStructuredBuffer to the RWBuffer via shader, but you wouldn't want to do that every pass.

I'm out of ideas. The compression thing and performance thing was interesting in that article though.

quaint grotto
#

no but structured buffers are slower than regular buffers

#

because they are for generics

meager pelican
#

Right, which is why if it's not frequent that could be a work-around. Sorry I can't be of more help, haven't run into that.

quaint grotto
#

tis a pain if they dont support it

#

because im trying to get my algorithm down below .6 ms

meager pelican
#

Yeah, but like I said, if you only initialize it once, big deal. If you know RWSB works, use that the one time to initialize the RWBuffer.

But if you need to initialize it from the C# side each frame, IDK what to tell you. Maybe someone else has the answer. Good luck.

full kestrel
#

According to https://docs.unity3d.com/Manual/GPUInstancing.html
" Standard and StandardSpecular Shaders are already modified to have instancing support, but with no per-instance properties defined other than the transforms"
I don't understand, so it's modified to have instancing support, but has no instance properties? How is that different from not having instancing support?

#

In addition, suppose I do want to support _Color as a per-instanced property. Is there a way I can set the color per object in the inspector on the material itself, or do I have to add a script to do that?

pine lily
#

is the code for the standard shader somewhere so I can fiddle around with it?

#

found it

pine lily
#

or better I found the zip download of a ll shaders

pine lily
#

has anyone a tut on how a normal maps?

soft jacinth
#

Support me on Patreon โžœ https://www.patreon.com/DanMoran Follow me on the Twittersphere โžœ https://twitter.com/DanielJMoran Get the Assets for this Video here...

โ–ถ Play video
#

@pine lily

pine lily
#

thx I've watched that already

#

got the code but now I have to figure out how to get the normal working with an texture/albedo map

#

getting a normal map to scroll is really hard T_T

cosmic prairie
#

@remote osprey sorry for the late reply, so basically you need to multiply the X and Y values first with the mask, then do the addition to the original verts and get rid of the substract nodes

pine lily
#

meh tut didn't help at all

#

I'm kinda stuck non of the tuts I find uses/ explains how to use several maps like albedo + normal. Does anyone know something where I can learn this? I've tried taking a look into the standard shader code but that one seems to use some advanced method I don't understand.

#

I tried doing this with the standard shader via sript but that didn't work. I'd like to do this as a shader but I've already put 1 week into learning shaders but I can't seem to work this out.

median shore
#

hi, what is the difference between sampler2D and sampler2D_float?

low lichen
#

@median shore Adding the _float will ensure that you'll always have float precision when sampling the texture. On lower end devices, it will use lower precision if you use just sampler2D.

median shore
#

ok so sampler2D is dynamic depending on the device?

low lichen
#

Yes, it might only give you fixed or half precision and you'll get banding

median shore
#

nice, thanks

median shore
#

So I'm trying to draw the normals of my scene through post processing but _CameraDepthNormalsTexture seems to be empty (resulting image is plain grey)

low lichen
#

@median shore Are you using the built-in renderer and have you enabled depth normals texture on the camera you're using?

median shore
#

yep

low lichen
#

You're trying to cast it to a float rather than a float4. It should be like this:

#
float4 color = tex2D(_CameraDepthNormalsTexture, i.uv);
median shore
#

oof

#

missed this when i removed stuff

#

my original frag function was this:

fixed4 frag (v2f i) : SV_Target
{
    float depth;
    fixed3 normals;
    DecodeDepthNormal(tex2D(_CameraDepthNormalsTexture, i.uv), depth, normals);
    
    fixed4 color = fixed4(1, 1, 1, 1);
    //color.rgb = Linear01Depth(depth);
    color.rgb = normals;
    
    return color;
}
#

and output is still grey after using float4 instead of float

low lichen
#

You can use the Frame Debugger to make sure that _CameraDepthNormalsTexture is valid

full kestrel
#

What is the difference between UNITY_DEFINE_INSTANCED_PROP and [PerRendererData]

median shore
#

wait what now it's working

#

i touched nothing, beside pressing play

#

which i already tried a lot before

#

im legit getting trolled haha

low lichen
#

@full kestrel I don't think that attribute does anything except hide the property in the material inspector

median shore
#

thanks anyway

full kestrel
#

@low lichen I think you are right, thanks

full kestrel
#

If I want to adjust the strength of a normal map do I just multiply the b channel by a constant, then normalize?

woven loom
#

Haya

#

I was wondering about something

#

So I've been trying to remake that subgraph in my project, with only a few things removed from the subgraphs so that I have what I need for my thing

#

And honestly it works really well

#

Apart from one thing

#

There's added code for adding cast shadows

#

I wanna figure out if it's possible to increase that resolution thing

low lichen
#

@woven loom That's not a shader issue, but the shadow map

woven loom
#

Yo!

#

Yeah I figured

low lichen
#

Shadow map resolution is in Project Settings > Quality, I think

woven loom
#

Ooo

#

Aight hang on

#

Hmm

#

There isn't a shadowmap setting in there but it also says that some settings are hidden since I'm using a scriptable render pipeline

low lichen
#

Oh, then it's in the scriptable renderpipeline asset

woven loom
#

Ooooh aight

#

That looks much better

#

I uh... think...

#

Still looks jagged, but way less than before

#

Is there a way to increase the lightmap/shadowmap resolution on a per object basis?

low lichen
#

No

woven loom
#

Aww

#

Hmm, the bigger the object, the less obvious that jagged edge becomes

low lichen
#

Because it takes up more pixels in the shadow texture

woven loom
#

I see

#

I'd go for just increasing the scale on everything but at the same time I feel like that's just asking for performance issues

#

Then again pretty much everything is static so I could just bake these

#

Anyway, that's good, that means I just need to make the additional lights cast shadows and I'd have my shader complete

merry rose
#

working on some terrain blending shader again, this time came up with depth offset with dithering which actually gets pretty nice result, the only thing is pretty visible dithering, is there a way I could smooth that out or made it so it runs before antialiasing?

full kestrel
#

I have a scene with thousands of objects, but only 2 materials. But I still have thousands of passes. Is that because some objects have submeshes?

low lichen
#

@full kestrel Are the objects set to static?

full kestrel
#

Yes

#

Not counting the skybox, 3 materials, everything static, about 300 game objects. Not sure why so many passes other than that some of the game objects have submeshes with multiple materails?

low lichen
#

@full kestrel Each submesh is its own pass

full kestrel
#

@low lichen If i understand correctly, that means if I have 4 identical objects with 2 submeshes, then it can't batch and that would be 8 passes total? If those two submeshes had the same material, would it now be one pass?

low lichen
#

I'm not sure how batching works with submeshes

meager pelican
#

I can't tell, are the "thousands of objects" all the same mesh? If so, you could try using instancing not batching. In that case, don't mark them static. Static batching has priority over instancing.

rich echo
#

@merry rose I dont understand much about that, but have you tried increasing the size of the dithering texture ?

merry rose
#

Basically I have just simple dithering which offsets the depth in rendering meaning I get some of the stuff behind the actuall mesh, the problem cames with that its either 0 or 1, so I am looking on how could I blur it to get nice gradient from one texture to another.

#

But I dont rly mind it now as its not rly noticable its just perfection which one day It might get ๐Ÿ˜„ now just hoping for tesselation for unity's terrain ๐Ÿ˜„

grave cliff
#

i just fixed the render pipeline problem, but i found that the shadows are pixelated

#

can anyone tell me whats the problem ?

rich echo
#

I think the pipelines have different config files, make sure you have smooth shadows activated there maybe ?

grave cliff
#

even the texture isn't rendered well

#

no i don't think its from the shadow config

rich echo
#

not shader config, render pipeline config asset I think, I dont remember the name correctly

grave cliff
#

yeah i tried

#

i think i need to create a new project and make it high-definition

twin stump
#

Iโ€™m trying to create a digital glitch effect on my camera in a 2D game using LWRP. Iโ€™ve found a lot of examples using a script to apply a shader to the camera, but I havenโ€™t gotten any of them to change the rendered image. I feel like my issue is related to using the LWRP stuff (in order to get 2D lights), but I donโ€™t know enough about shaders yet to figure out where this is falling apart.

#

Is there a good resource I should start with to get a better grasp on this stuff?

winter acorn
#

@merry rose youre having trouble with unity tesselation too??

#

Cause i cant get it to work with out it having wierd tint and bad displacement

merry rose
#

I would love to have displacement on new Unity's terrain caus the shader does not support it for now, and its been long time since I tried to make my own but might give it a try

#

what weird tint do you mean?

winter acorn
#

@merry rose well the entire texture gets a white overlay. The color is just not right

merry rose
#

Thats pretty weird, are you using HDRP?

winter acorn
#

Yes

#

Its really wierd. And annoying. I love using substance designer but tesselation in unity doesnt work at all. Not terrain or objects

merry rose
#

yeah I got what you mean

merry rose
#

So I used layeredLitTessellation shader on terrain to get tesselation only thing is that I cant use any of the height amplitude parameters which is pretty bad hmm

gilded lichen
#

@merry rose dither with MSAA + Alpha to Coverage isn't implemented yet, talked to the team at Unite and they said "they have it on the roadmap" which I'd say translates to "don't hold your breath"

winter acorn
#

@merry rose thats a very intresting result. Is posible you can maybe help me out with how you got this working some time today

#

As long is it work woth hdrp

merry rose
#

Thanks for info, so in 2030 got ya ๐Ÿค” ๐Ÿ˜„

#

Yes of course, I am doing some experimenting for our future project but we are pretty on hold becase we want to use DOTS netcode and all of that stuff

winter acorn
#

Exactly what im doing. Trying to make work arounds for stuff i need to work for the production of the game

merry rose
#

Yeah, like there is so much not done that its easier to do a work around and get the result you want, before I made like own grass shader but then they changed the naming so it stopped working, but they talked about some new system basically for details, hopefully next GDC they might give some insight to that

grand jolt
vocal narwhal
#

It should animate just fine, does it animate in the scene / game view?

grand jolt
#

no ๐Ÿ˜ญ

#

should it animate in the preview in shader graph too?

vocal narwhal
#

I mean, I made the exact same thing and it does

#

I am way back on 5.7.2 though

grand jolt
#

strange

#

is there a way to code the shader instead of using graph?

merry rose
grand jolt
#

I just activated that, it does nothing ๐Ÿ˜ญ

vocal narwhal
#

Yeah you're not in Play mode in the Game View and you don't seem to have the Animated materials box ticked in the Scene view

#

Just try to remake the graph from scratch and see if it was just bugged or something

winter acorn
#

@merry rose here ima add you as a friend. Im active almost all the time and always working. Hmu

merry rose
#

Oki

winter acorn
#

@grand jolt connect the graph to to sine time not time in the end

#

should fix the issue

winter acorn
#

@merry rose is it possible i can get some help with tesselation?

merry rose
#

I am not actually making tesselation just using the LitTessellation shader that comes with HDRP, for now custom tessellation is not rly possible only with custom coding

winter acorn
#

i know that. but its acting wierd on my terrain

#

im probably going to make a tesselation shader soon if unity doesnt

lament sorrel
#

I'm confused on what is happening on the shaders.
if I go with cutoff, then the models is correct, but quality is lowered.
but if I go with sprite default, the quality is correct, but the model goes off model.

inland dirge
#

Does anyone have a tutorial for adding pixel displacement to a HDRP Lit master node in shader graph?

merry rose
#

Use parallax occlusiom mapping node

#

Anyone got an idea why I cant lerp between two different parallax UVs? working on terrain shader and I can lerp albedo, normal but the parallax UV first one always, I can bump lerp value to hundred and nothing changes

remote osprey
#

Making continued progress in this shader but not quite there yet. This is meant to be a sprite shader that waves a flag by moving the vertices, and uses a mask to determine how much weight to put on verts (so with the mask in this image, the top doesn't move at all, and the bottom waves freely - so a hanging banner). With this current setup, the bottom moves left and right - but so does the top, only the top doesn't move as much, and the mesh becomes VERY TINY. So it's CLOSE. I think I need to add a Position node, but I haven't figured out the right configuration yet, as whenever I add in the Position node and the mesh becomes the correct size - but then the entire mesh moves left and right and ignores the mask.

Thanks for all the help so far - a little more help and I think I'll understand what's needed here. Thank you!

robust ivy
#

hi guys, i would like to know how to add some refraction to my surface shader, any ideas? (im not using hdrp)

rough stump
#

@merry rose try and multiply the height of the shader

rustic dragon
#

@remote osprey an easy way is to use a LERP where the T is your mask where black = no movement then in the A just feed it the position node (set to object) then in the B feed it the wavy math you have.

#

@lament sorrel looks like it's a sorting issue, if everything is kind of on the same rendering plane, the regular blend mode can get confused and sort weird, where clip just sorts better with things so close on the same layer

jaunty quartz
devout quarry
#

I have a simple unlit shader and I'm trying to use it in a particle system

#

but several properties like 'color' in the particle system inspector now don't affect my particles

#

how can I make it so that the particle effect inspector still works?

#

aah found the issue

#

I need to use vertex color node

merry rose
#

@rough stump basically this is my setup and I cant multiply height because it takes Texture2D as input, so I should be able to do it after wards but it does not work, even whe I use it instantly at textures it will still use the first Parallax UVs and it will ignore the second one

rough stump
#

Aaah! I see that's messed up!

merry rose
#

Yeah, think so too, like why would they do that grr

ebon trench
#

Hey guys, I've been trying to figure this out myself but google and youtube yielded me no results. Might be that I just dont know what to look for, though.
I'm going for a cel shaded look and want that on my terrain as well. I want to use built in unity terrain for the ease of use and efficiency. Is there a way I can set up a shader graph for it? And can it take in lighting information?

robust drift
low lichen
#

@robust drift The lighting in the scene is dimmer, probably

robust drift
#

Can I add like a sun?

low lichen
#

@robust drift Sure, also called a Directional Light

robust drift
#

Oh ye that worked thanks

distant nimbus
#

hello. I have a quick question. I'm using LWRP and I've made a simple shader graph material and applied it to objects in the scene. On Android (and in editor) it works fine (materials have the color I choose), but for some reason I'm getting this on iOS (tested on 2 devices with iOS 12).

I have no clue what to do - any help would be appriciated.

merry rose
#

anyone knows why it throws an error? I am using correct hlsl code but custom function node is throwing error that it "cannot inplicitly convert from 'Texture2D<float4>' to 'sampler2D' "

low lichen
#

HeightMap must not be a sampler2D then

merry rose
#

but I have to use UVs how can I do that if it would be float?

#

like this code worked with shader forge custom nodes, so its weird that its not working here, I found that pretty much same error was in older UE4 version

low lichen
#

Where is HeightMap defined? Is it something that Shader Graph just gives you?

merry rose
#

its an Input of type Texture2D

low lichen
merry rose
#

It didnt helped at all, like he even said it, like the documentation is now reworked but there isnt any showcase of how to use textures in it

south topaz
#

Hi! What are people their thoughts in here about Shader Graph vs writing shaders? ๐Ÿ™‚
For example, do you think Shader Graph is better than writing shaders your self, does one have a much tougher learning curve, is one over the other better for performance?
I'm trying to figure out which of the 2 I want to learn about.

I've found this course on Udemy about shaders. Perhaps that their might be people in here which bought that course, if so is it a good one?
https://www.udemy.com/course/unity-shaders/

Udemy

Learn to program the graphics pipeline in Unity for creating unique visual surfaces for game objects.

low lichen
#

@south topaz Writing shaders has a longer learning curve. You can easily get the same performance with either. Shader Graph is more limiting, but you won't find those limits until you're doing something advanced.

south topaz
#

What would you consider as something advanced if I may ask? ๐Ÿ™‚

winter acorn
#

well ive always kinda been intrested in ray marching. cant understand it though

#

btw : comenting on the video

low lichen
#

@south topaz Maybe advanced is the wrong word. There are certain features missing from Shader Graph, such as tessellation. Features like that will likely be added later.

winter acorn
#

@low lichen tesselation is mising from unity in general to be honest. the current one sucks and its hard to make a good one

#

even quixel failed at it for unity

low lichen
south topaz
#

But if I understand you correctly, some things are still missing in Shader Graph. Which isn't too surprising since it's not very old, but in general I should be able to still do a lot with it?

meager pelican
#

@south topaz Learn both. Watch what one does to learn the other. It's not a binary choice. :2cents:

winter acorn
#

shader graph is still in preview. this argument is pointless

stone sandal
#

shader graph is only in preview for 2018 versions

winter acorn
#
  1. wont be final till 2020 i think
stone sandal
#

no, shader graph is not in preview versions for 2019

winter acorn
#

really? doesnt make sense

#

hdrp is still in preview. i cant see shader graph being final yet until the actually SRP it runs on is

#

might be wrong i guess.

stone sandal
#

shader graph runs on any SRP, both universal and HD

#

universal is not in preview anymore

winter acorn
#

yea. my bad i use hdrp.

#

hdrp is in preview until 2019.3 or 2020 ive heard

stone sandal
#

that said, there are features and functionality that aren't yet "out of the box" for shader graph but a lot of them are things we're aware of and working towards

winter acorn
#

we're? you work at unity?

#

nice

south topaz
#

Why else do they have the Unity Staff role, or did I totally miss the point of that role? x)

winter acorn
#

didnt notice

#

sorry

south topaz
#

๐Ÿ˜„

winter acorn
#

๐Ÿ˜‚

#

when spara said we're i checked the role. and then noticed how stupid i was even trying to argue with some one who works there. they definataly would know if a feature is done or not,etc.....

#

but im kinda disapointed about one thing. as a 3d env artist i always make textures in Substance Designer. but i cant really every use them like i was to since tesselation is so not focused on in unity. we dont have terrain tesselation and even normal tesselation isnt really that great. + hdrp doesnt support grass which i made a work around for and wind doesnt really work either for some reason or thats at least for me and my team.

south topaz
#

I think I'm going to give the course I found a shot, if it doesn't work out for me at least I tried. And if it does work out I'll be a step further, thanks all for responding! ๐Ÿ˜„

ebon trench
#

It also tackles some fundamentals of lighting very well and it explains why things work. Really great vid

fast acorn
#

Guys, I have the water height on UV2, I want to add waves, any suggestion into how one would do it? Flow map on UV3 perhaps?

meager pelican
#

@south topaz IIRC that course is for the standard/traditional pipeline. But it will teach you about shaders, just not the URP/HDRP specifics.

#

@fast acorn

Guys, I have the water height on UV2, I want to add waves, any suggestion into how one would do it? Flow map on UV3 perhaps?

I'd use another texture or 3, not the UVs on the meshes. Scrolling textures, offset from each other, or something.

fast acorn
#

It's procedural, I can't make premade textures :/

#

Any downside to using uvs?

south topaz
#

@meager pelican Well, itโ€™s still a start ๐Ÿ˜„

meager pelican
#

Yeah, it's a good/great start. And...it's much more well documented.

#

@fast acorn if it's procedural, can you just calculate the offsets in a vertex shader?

fast acorn
#

@meager pelican offset to what exactly?

meager pelican
#

The color or the vertex (waves). Depends on what you're doing to make a "water shader" (there's all types and styles). What were you going to stuff into UV3 and update each frame? (Ouch!)

fast acorn
#

Oh, yes, I could indeed use the vertex color for that

meager pelican
#

What? Not what I was saying.........

Besides you can generate textures procedurally too....like with perlin noise.

#

Why in the world would you want to have to update the UVs or colors on the mesh, and re-upload the mesh each frame? Yikes! You want to upload the mesh once, and then dynamically update it in a vertex shader to alter the base with an offset that you calc some other way so you don't have to update the mesh each frame.

fast acorn
#

Ohh..
No, I wanted to use the uv just to save overall what will flow to where (statically), and use noises with textures to actually make the action processed on top of that.
The problem with procedural texture (at least for me), is that the planet is a sphere, so wrapping it can be a bit troublesome programmatically

#

I would rather use textures tbh, but my concern in order to make the flow map with textures is regarding the sphere wrapping and because I kind of already have the info on the UVs

meager pelican
#

OK, but you said "flow map on UV3" and that will kill you.

flow map as delta-offset to your UV2 is what I'm thinking. And that flow map can be procedurally generated into/from a texture.

At least that's what I'm thinking. Have you seen Unity's water shader? You look like you want ocean type waves, and really maybe just reflections from X miles up. But my only point is that you don't want to modify the mesh UVs each frame, IMHO.

fast acorn
#

I agree, I don't intend to modify the uv each frame, nor any texture input, just scrolling textures in function of time in the actual shader. But I need something telling that the waves are going from the deep towards shallow waters

#

this is the piece of information that I'm not sure how I'll pass to the shader

meager pelican
#

Oh! You want a directional vector field mapped onto your planet for the water flow direction.

fast acorn
#

yes

meager pelican
#

Sorry, I thought you were talking about the wave offsets in general.

fast acorn
#

oh, OK

#

np

#

the problem with procedural texture (the problem for me, since I don't know how to solve) is to wrap it into a planet, if it was just a plane I could create a 2d map

#

for a planet I would have to "translate" the information to a texture to be then picked by the UV1 or through a world position technique

#

that's why I thought about using UV3 for that, since I already have the information about how deep is the water in the UV2

#

I guess that the pixels UV data will be the interpolation between nearby vertexes

#

if I do that

meager pelican
#

Well, if you had a scrolling wave height, and a directional field for wave-flow-direction, it's just a matter of combining the two or maybe you can even get away with one. I would think. Haven't tried it. So your lookup into the height would be modified by the direction vector at that location * some cycling time * some scale. Basically you want to distort the moving height field by the flow vectors. My head hurts, I think I'd have to try it before I walk away in shame typing more here. Maybe someone else has done both of those things at once from 250 miles up.

fast acorn
#

yes, that's exactly what I want to do

meager pelican
#

Yeah, if that doesn't change and it's static, you could put some direction into UV3 as long as you don't have to update each frame. ๐Ÿ™‚

fast acorn
#

not sure if there are other approaches since that's not quite an usual problem

meager pelican
#

Yeah Oceans are weird that way, waves. I mean on the Great Lakes or other things, you get wind-driven waves and they pretty much follow the local wind direction. So there's some back and forth on the windward side, but more lapping on the down-wind side. And then you could just color each shore with some foam or something and have it all be a single direction and call it a day. But on the Ocean, I think all coasts get waves.

Not that, from your pic above, you'd actually see waves lapping from 250 miles up or anything....

fast acorn
#

they are mini-planets and it kind of need more information to make clear that there is water in there, since I'm going for a toon look, I can't rely much on the normals, so this is the reason why I wanted some waves, I'll try this approach and I'll share the results in here.

meager pelican
#

What unity water does is use two or more textures in different "sizes" and ->scrolling in different directions <-. So that might still work to make your wave-coloring offsets.

fast acorn
#

yeah

meager pelican
fast acorn
#

that's awesome, thanks, just saved on my watch later stuff

#

first thing that I'll do once I get home

rustic dragon
#

hi, wondering if there is a way to hook into rect transform data in a shader (like how you would get scale or position from an object), or if that is something for the near future?

meager pelican
#

You mean shader graph? Position is part of the normal shader info, I think scale is in the transformation matrix too. You'll want to research the transformations that go into shader programming to understand. But it takes a local position and scale and rotation and does matrix math to get the world position then camera and screen view... that's the MVP type of thing.

rustic dragon
#

yeah, shader graph, doing some UI materials and I wanted them to update based on the change in the rect transform of the ui element (image, panel, etc).

#

I got it to work but I have to feed the local scale of the changed UI elements rect transform and feed it into the shader as a parameter in script

fast acorn
#

Rect transform positions are actually world positions too

#

You can manipulate it like that

#

They are in the world, rect transform is a layer on top of transform

#

You will probably have to send information regarding the width and height manually through a script though

#

Which is fine

rustic dragon
#

yeah, I got it to work doing the the parameter/script method, but wanted to know if there was a node that would get that information in real time like Object, Object didn't seem to react to any rect transform changes

merry rose
#

In the end I made just simple parallax mapping, which can be easily controlled, only thing I am missing rn is height blending which wont take that long, so what everyone can take from this is that current version custom function node (HDRP 7.1.2) does not allow you to modify texture data as it cannot load Texture2D properly giving an error. Hopefully they will fix it as unreal did, they had it working already in UE3 but then they had to redone it in UE4 same as Unity is doing now basically.

meager pelican
#

@fast acorn I just remembered this guy did some procedural mini planets, and although he may or may not have a water solution you like, you may find it interesting. I worked through this 'tut' for fun a few months ago and it was neat. There's like 6 bite-sized chunks in the series.
https://www.youtube.com/watch?v=QN39W020LqU

In this series we'll be creating a system for procedurally generating simple, but diverse planets. Get the project files for this episode: http://github.com/...

โ–ถ Play video
fast acorn
#

@meager pelican thanks :D
actually my planet generation algo is based on this series

#

I've added a bunch of things to it afterwards though

#

I've added a cool stamp system (which I don't use on this type of planet, just for moons as yet), but it was quite fun

meager pelican
#

Neat. ๐Ÿ™‚

fast acorn
#

that video that you've suggested earlier is awesome btw @meager pelican

#

they also use a lot the same type of technique

ocean geyser
#

I'm trying to create a shader to make an inside border of a sprite; currently the sprite is a white square, if it matters.
I tried to do that by checking the texcoord together with an offset variable, and if it's <= 0.0f or >= 1.0f, I use the border border.
It works, but I'm having a problem when scaling. When scaling, I want the border size to still be the same size as it was before the. That is,
I want a screen-size border size rather than texture-size border size. How do I achieve that?

remote osprey
#

@rustic dragon Thanks for the tip! Though didn't quite seem to do it... Check out the following 2 images. The first shows the updated material. There are 2 banner sprites here. Both are in the exact same location. One has this shader applied, the other has the default Sprite shader applied. The one with the new shader I'm making is super small and offset to the side (the entire thing still moves left / right when animating). The second image is the updated shader graph...

#

When working with this from straight shaderlab scripts, I recall that we needed to do some math so that the shader pretended like the sprite was a full texture, allowing it to act 1:1 with the positioning on the mask image... otherwise it tried to just get the same pixel positions as the sprite, but on the mask.... might that be something needed here as well?

remote osprey
#

Okay forget that. I'm REALLY close now...

#

Left is the shader in the graph image. Right is the standard sprite. Everything is just a little too small, and the bottom moves a little bit rather then being rigid. It's almost like everything is just slightly offset still... but close!

gleaming fog
#

heya guys

#

is there a way to draw geometry infront of everything using the Shader Graph?

#

i know you need to use the ZBuffer

#

but i dont think you can change that through the graph

gilded lichen
#

you can modify the resulting shader (right click on master node, copy code, paste into new shader file and modify as needed)

ebon trench
#

Iirc the only way to change the way object are drawn is by making a renderer asset

sinful salmon
#

Hello everyone

bitter vessel
#

Is it possible for a shader to check the layer of a gameobject at a certain position? im thinking about making a shader for a minimap material which sets each pixel depending on whether it is a wall or floor (i want the minimap image to be abstract not simple a camera looking down on the scene)

amber saffron
#

No, the shader has no knowledge of the layer

rustic dragon
#

You might be able to do something based on distance with your models and a shader on them that will display the models in the stylized way you want. You just set the distance so far you never see it in regular gameplay, but your minimap camera you make really far away so it draws the LOD shader part and renders that to a texture. You could probably do something similar with just an LOD system on the models too.

#

but then again you could just use layer masks with the map cam for that ๐Ÿ™‚

bitter vessel
#

yeah i think i might just make a second tilemap with abstract tiles that only renders on the minimap cam,doesnt feel as clean as potentially using shaders though

#

random other question - im playing with shadergraph with URP and trying to do a grabpass-like effect, seems like it's the Scene Color node that I need to use.. but how do I actually use the output? just seems to output grey always

rustic dragon
#

well you could just include the abstract tiles with the real tiles in the same prefab, just set them to another layer that the map camera will only see

#

that way you wouldn't have to make 2 separate maps

#

@bitter vessel This shader trick actually does work, it's just a distance calc between the camera and the models and used in a lerp, the green objects are what the main gameplay camera sees, and the camera box on the bottom right is what the map renderer sees, here I just have it go red for the map camera.

#

if you get the distances right, you will never see the red during gameplay, and 'only' see the red with the map render cam

twin grove
#

Hmm I'm a little confused by the Texel Size node, does it not return 1/textureWidth on width and 1/textureHeight on height?

#

Oh ok it just returns width and height it seems

ebon trench
#

Yo guys, Im working on a toon shader and Ive got custom nodes to get the main directional light and additional lights. The additional lights now not only give off light but also add their respective color, though only that of the last detected light that shines on a certain object. Is there a way to seperate all detected light colors rather than saving and outputting them seperately?

#

Would save a serious pain in setting up the nodes if I wouldnt have to replicate the setup for extra lights like 5 times or more

lost prairie
#

Hey everyone! Is it not possible to create&use global variables in shader graph? I couldn't find it for a long time and had to ask. Using hdrp.

ebon trench
#

Unity has global variables? ๐Ÿค” Never knew that.

lost prairie
#

@ebon trench shaders does right? I mean like Shader.SetGlobalFloat. But I can't define one inside shader graph I think... I wonder if it's a hdrp thing ๐Ÿค”

ebon trench
#

You sure that isnt just part of unity's code?

#

I think it might be part of the core HDRP package

#

What would you need them for? If you need visible variables on materials just use the blackboard.

lost prairie
#

globals let you set&sync variables of multiple materials using same shader at once. I used to use it a lot before but can't seem to find it in shader graph. thought it might be a hdrp limitation or something.

ebon trench
#

Im not sure if you can reset it on already made materials, but the default value of blackboarded variables is usable for syncing a base value?

lost prairie
#

default values won't help as instanced materials will override them. also can't set/change default values in code etc.

ebon trench
#

Figured, cant help you then Im afraid.

lost prairie
#

thanks a lot anyway @ebon trench ๐Ÿ™‚

ebon trench
#

Yw, if you find a way to pull it off please do let me know

lost prairie
#

I will! as I said I think they simply doesn't work in hdrp or something. I'm just doing it in a little hacky way at the moment, finding all necessary materials, setting variables individually etc.

meager pelican
#

@fast acorn
I hadn't seen it. That was great, loved those scrolling multiplied textures.

this one is a nice one too, have you ever seen it?

fast acorn
#

@meager pelican
yeah, they manage to get some interesting results with it, I also liked a lot the nintendo one, I'm waiting for the other ones from the series that he said it would be

meager pelican
#

The blend-add thing was a good tip too if you haven't seen it before.

cosmic prairie
#

@lost prairie I think you just define one in your shader, make it unexposed, make the reference into something readable like _GlobalAmbient orvwhatever you want it to be called and call setglobalfloat() on that _GlobalAmbient

#

it is definitely a thing, I just dont remember how I did it, but I think this is the way

ebon trench
#

pretty happy with the progress for it being my first shader ๐Ÿ˜…

#

tho I cant figure out for the life of me how to make the additional lights cast shadows

#

cause I cant reverse engineer the code used for the main light for it, sadly :/

#

Also does anyone know why blue light doesnt give off light? edit: fixed it

urban oxide
#

hey any unity ewangelist here?

#

im a little bit confused atm

#

unity is acualy offering few rendering modes

#

when u make your game do you use the light rendering presets etc or still use the standard rendering path?

#

is this new rendering preset a standard?

silent dew
#

With LWRP two cameras no longer works for rendering the world view and view model seperatly.

When i posed this question in another discord i was sent here, beeing told you guys might know a way.

(Keep in mind, im completely new to shaders)

thick fulcrum
silent dew
#

Oh wow! Thanks @thick fulcrum ! ๐Ÿ˜„

thick fulcrum
#

@urban oxide I'd advise sticking with the standard rendering path for now until the newer pipelines are MUCH more stable and feature complete.

urban oxide
#

ok, so using SRP/SGT actually is meaningless?

grand jolt
#

Anybody have any ideas how one can achieve a fog of war in HDRP?? I've done it in regular Unity versions with Render textures, but it's apparently not gonna work in HDRP with that method as you can't use depth cameras.

urban oxide
#

i mean, even i create the shaders with shader graph i need to use the new rendering pipeline

vocal narwhal
#

Feel free to use URP if you understand what restrictions that has and feel the need to use Shader Graph

urban oxide
#

so im unable to use my light shader with the standard rendering path

#

"light performance shaders"

thick fulcrum
#

shadergraph does not work with standard renderer

urban oxide
#

i mean thart

#

that hurts ๐Ÿ˜ฆ

vocal narwhal
#

URP/LWRP are out of preview so it's pretty production ready

urban oxide
#

the only one did is the amplify shader editor im right?

#

thanks for the link!

thick fulcrum
#

amplify I believe works with all rendering modes, so you could use standard.
@vocal narwhal last I checked was still some issues which require manually adjusting shader code to get them to work. Guess it depends on your view of "production ready", personally I don't like having to manually make changes, which may need adjusting each new version.

vocal narwhal
#

I'm using LWRP without issue in my current project

urban oxide
#

oh, thats also a expensive information

#

thank you

haughty canyon
#

anyone seen this before? Shader error in 'GAP_SG/GlowElectricity 2': redefinition of 'unity_Builtins2Array' at /Library/PackageCache/com.unity.render-pipelines.universal@7.1.1/ShaderLibrary/UnityInput.hlsl(114) (on d3d11) it was just a ShaderGraph built in an earlier version and i have no idea how to narrow down which aspect of it is apparently no longer supported. Opening in ShaderGraph and re-saving doesn't fix it ๐Ÿ˜ฆ

gilded lichen
#

@haughty canyon also seeing this. I think it's downright broken. This also prevents builds

haughty canyon
#

heya @gilded lichen , so i started rebuilding my shader node by node, got half way through and no issues. But as soon as i enabled GPU instancing on a material that was using it, the error appears. Disabling GPU instancing doesn't make the error go away so i'm not sure how to you can revert one that has already been corrupted in this way.

gilded lichen
burnt ether
#

So, anyone experienced with making water/glass shaders for HDRP - can someone help me with scene color node? Everything behind the material looks darkened and I don't know how to fix it.

devout quarry
#

in shader graph could someone explain to me when I should use a subgraph and when a custom node?

ebon trench
#

Custom nodes let you implement code into your shadergraph, allowing for more functionality.
Subgraphs are saved custom nodes consisting of other nodes internally, allowing you to save setups you use more often.

#

You can also save a custom function node as a subgraph to allow for easy access to it from the node menu.

devout quarry
#

yeah I know what both do, but like

#

if I have a certain set of nodes I use frequently

#

just convert them to subgraph?

#

and use custom nodes for things I can't achieve with the built in nodes?

#

because both a subgraph and a custom node can achieve the goal of saving space

#

I think I should only use custom nodes for things I can't achieve with a combination of the built in nodes

#

or like a long arithmetic operation

ebon trench
#

I mean, use whichever you want in what way works for you Id say

#

I dont think theres any real data on performance impacts either may have yet

#

I cant find it easily, anyway

uncut karma
#

There shouldn't be any performance impact, subgraphs reduce work when u get tired of repeatedly making certain node combos

#

I guess it could be an interesting test to take a complex graph, write it as custom hlsl nodes and compare instruction counts

civic finch
#

Is it possible to create volumetrics with shader graph

#

my approach would be to find the distance until the next face with normal away from view but there doesn't seem to be a node for that or anythign

grand jolt
#

anyone knows how to make a shader for an object, where the object has a red outline which is always visible but the main texture not?

uncut karma
#

@civic finch for that method you would first render the volume back faces' positions to texture, then in a second pass render front faces & sample that rendertexture, so you have the ray start and end position for a fragment. Then sample along that vector in thevolume

civic finch
#

Ah ok

merry rose
#

implemented terrain holes into my custom terrain shader, does anyone have an Idea why I cannot take textures from terrain, i use correct _variableNames but for some reason I cannot get splatmap, heightmap, only thing for now what I tested and is working is terrainHolesMap so I have holes now ๐Ÿ˜„

grand jolt
#

@merry rose How did you do the dithered terrain blending on your modules?

merry rose
#

You can use Dither node and plug it into DepthOffset, before you can remap it to get wanted result

#

To blend object of same type use Heightmap and multiply dither with heightmap, that will give some randomness which will result in same object blending together

grand jolt
#

By Dither node do you mean in ShaderGraph?

#

Do you have a visual example of the graph?

last veldt
#

Is there a way to override the lighting output strength of a LWRP PBR shadergraph material? I'm working on a scene that has some underwater and above water sections and I'm trying to implement a area specific fog that will fade objects to lower light levels depending on how far away they are.

merry rose
last veldt
#

Really, I need some way of applying a function to the PBR pixel. everything in the scene after it's rendered based on it's world space position.

grand jolt
#

How do you go about making a custom terrain shader in shadergraph?

#

For HDRP 7.1.2

fast acorn
strange onyx
#

So any shader gurus here?

#

I have been attempting to... err... essentially hack in LWRP support for the Vita.

#

I almost have it "working" as far as errors go.

#

everything up to this final piece

#

Compiling Fragment program
Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF3 SHADER_API_MOBILE UNITY_COLORSPACE_GAMMA UNITY_LIGHTMAP_RGBM_ENCODING```
#

So in the other cases, this was easily resolved as it was disabling d3d11_9x, which was throwing an error for the Vita

#

well, scratch that, seems that wasn't the issue

#

they are all erroring again

#

ok, this doesn't even make sense anymore.

#

Reports a similar error as above for line 18 for a different shader, but loading it in VS shows this at line 18:
#pragma exclude_renderers d3d11_9x
Go to the next error, another "did you forget" for line 23, but there is nothing there. the errors don't match the issues they report in the first place.

#

I give up on this.

civic lily
fast acorn
#

Probably a grab pass with two panning displacement textures

wanton crown
#

Anyone know an easy way with Shader Graph to make a bevel or emboss effect on a sprite?

crude nexus
#

this may be a stupid question but i upgraded a project and shaders are all broken, and i am stupid dumb with graphical stuff, much better with coding. do i have to somehow re-acquire and map these same shader properties (ambient occlusions, bloom, what have you) or can i upgrade them without losing them (i have like a dozen post processing profiles)

grand jolt
#

Can anyone tell me why the models are neon pink but normal in the inspector window.,

low lichen
#

@grand jolt Probably one of the LODs has a missing or invalid material

grand jolt
#

i habe no idea im not a unity dev, im just desining the scene

#

is it possible for me to turn off the LOD

low lichen
#

@grand jolt Try disabling the LOD Group component on the prefab

burnt ether
#

Trying to make caustics shader using scene depth, but I have absolutely no idea how to do it correctly.

twin grove
#

Tried making a Sprite Lit based shader graph, but it seems to disappear in play mode - works fine outside of play mode

#

Any ideas?

grand jolt
#

Tried that didint work

crude nexus
#

they missing material

grand jolt
#

Should I try to reinstall

#

if not then contract the guy

#

nvm i got it

#

thank you guys tho ๐Ÿ™‚

crude nexus
#

howd u fix

civic finch
#

So I'm back in Unity compatibility heck

#

I can't use shader graph without creating a render pipeline asset

#

if anything i want to use URP

#

but post processing doesn't work with URP

#

so

#

oh ok i found a blog post

#

Unity do like their approach of firehosing useful information over a number of different sources

#

wait so

#

i can't get URP on 2019.2

#

but post processing is broken on 2019.2 URP

#

is 2019.2 an unsupported version

#

like non LTS or whatever the equivalent is

wooden tulip
#

Post does work with URP. It has its own implementation of it though.

dark flare
#

Anyone know of a way to render to the stencil buffer while using deferred in Unity?
they say there's one free bit, and it would be useful if i could write to it

#

maybe i just have the syntax wrong?

        Stencil 
        {
            Ref[_StencilRef]
            WriteMask[_StencilRef]
            Comp Always
            Pass Replace
        }```
#

what i really want is to just write the one bit mask

#

oh wait, nevermind this IS working

twin grove
twin grove
viral orchid
#

anyone got a good resource for making a reinhardt shield shader?

#

in shader graph

novel wing
#

Is it possible to use angles in shaders?

#

Im trying to convert an integer from 0-360 to a normalized vector direction in my shader

plucky bone
#

Sure

#

iirc angle to vector2 is float2(sin(theta), cos(theta))

novel wing
#

ill just have to use trigonometry right

#

ah yeah

plucky bone
#

Yep

novel wing
#

thanks ๐Ÿ˜„

merry rose
#

Anyone knows how could I get terrain layers textures in my custom terrain shader? I am able to get the terrain holes map but other than that I cannot figure out how to get Albedo, Normal or mask map

plucky bone
#

Check the source of the default terrain shader

#

The names of your properties are probably wrong

merry rose
#

I named them the same as when I see in debug inspector of terrainLit material

merry rose
#

okay found out why its not working

plucky bone
#

Why not?

merry rose
#

because none of it is exposed, all of the textures are made in custom functions, and then just transfered to main shader to be seen, you cannot rly access it without going into code and customize it to your own will

plucky bone
#

-.-

novel wing
#

Is it not possible to use pi in shader graphs?

plucky bone
#

Make a constant node with 3.14159265359 as value

#

pi isn't a builtin thing in shaders

novel wing
#

Well I kinda need it to be exact

plucky bone
#

3.14159265358979323846264338327950288420 have 39 digits

#

That should be enough to calculate the circumference of the universe to the width of a single hydrogen atom

#

(you don't have enough precision to represent that number though)

novel wing
#

Im bending the entire world into a sphere and im pretty sure there will be a visible cut where it connects back

#

Because in my experience there is always a cut in the rendering/collisions unless its perfect

plucky bone
#

Go and try and see

gilded lichen
#

@civic finch Post doesn't work in VR on 2019.2, and in some configurations also not on desktop. If you're feeling adventurous there's a branch in SRP repo for postfx fixes

twin grove
#

Anyone else having the issue where shader graph sprite shaders turn invisible in play mode?

exotic urchin
#

anyone had any luck with getting projectors or decals to work with the LWRP?

rough stump
#

hey if you guys have any doubts or wanna try out cell shading i recently published my asset on the store! with cartoon water shader!!

grand jolt
#

Anyone got the dithered crossfade working on HDRP?

twin grove
#

@plucky bone figured it out, it's streamer mode

#

if you have streamer mode on you @ people without the # afterwards

upbeat topaz
#

How can I animate a custom post-processing shader over time in LWRP?
as trying to use _Time does not work

viral orchid
#

how do i make the edges of the mesh glow? fresnel does not work for hard edges, only curved like a sphere

upper kite
#

@upbeat topaz Try using _TimeParameters, that's what the SRP now prefers

sour jackal
#

Hi.
Where to find good tutorials for beginner to understand Spherical Harmonics and Unity lighting.
I had searched and couldn't find some tutorials/explanations to start with.
I think

  1. I need to understand Spherical Harmonics
  2. How light is converted to SH and how it is used in Unity.
upbeat topaz
#

@upper kite I couldn't get the _TimeParams to work, but it seems I just have applied the regular _Time wrong earlier, as it did work in this configuration

deft parrot
#

Hey everyone

#

Anyone here good with Shader Graph? I'm trying to get something to work and I'm not sure if its even possible

#

Or if I'm going about it the wrong way

upbeat topaz
#

try saying what that is, as then it will be easier to find the right person for ya

deft parrot
#

So, I've made a 2D water shader

#

That I'm scrolling using the offset to make it look like it is moving

#

Now, unfortunately this means that any other 2D GameObjects that sit in front of it look like they're floating above the water (because there water just scrolls right underneath it)

#

What I want (if possible) is to be able to get the underlying plane with the shader to be aware of the things rendering in front of it, and draw a border around the images to make them look like they're interacting with the water

#

I have an idea how to do this with a 3D mesh when the two objects intersect, but because the island is only rendered in front of water I don't know if I can do what I want

quaint grotto
#

@upbeat topaz your variable name is wrong

#

speed over time would be s/t

#

it should be named distance

upbeat topaz
#

ah, good catch

#

but yea, it was meant to be distance

quaint grotto
#

not sure why you couldn't get _Time param to work what were you trying

#

you likely meant to use:

unity_DeltaTime    float4    Delta time: (dt, 1/dt, smoothDt, 1/smoothDt).
#

_Time is time since level load.

#

@upbeat topaz

upbeat topaz
#

and thank you for the advice

grand jolt
#

howdy! when using normal displacement and a noise gen, it tends to rip and tear the faces apart, is there a way to avoid this ?

plucky bone
#

Smooth your object

#

Or somehow offset verts at the same position by the same amount

grand jolt
#

hmm the mesh is smoothed

grand jolt
#

"we can fix the seams using object space for the noise instead of UV space"

#

that's from a vertex displacement tutorial by Unity

#

but i am using object space added to the mix

plucky bone
#

If it were smoothed you wouldn't have duplicate vertices

#

Which would solve the issue

jaunty lichen
#

that actually sounds similar to my problem, I'm trying to do inverted hull outlines but where there's seams between objects cracks form and I was wondering if there's a way to prevent this?

#

and a weird peculiarity with certain faces not seeming to invert as if they're being culled? like this finger here I feel the outline should follow down the side where his finger is but it just kinda cuts off as if it's a plane formed on top of the hand

cosmic prairie
#

@jaunty lichen I guess all of your normals aren't smoothed, and in some scenarios they shouldn't be, you can however use other inputs for displacement, like you could bake vertex colors to be the smoothed normals, but I guess you are already using those, so you could try uv map 2 and 3, or just have a separate 3d model for the outline

jaunty lichen
#

Yeah it's started to dawn on me that the issue is the model itself, which sucks cause i've been trying shader after shader trying to get a particular feel for days now xD

cosmic prairie
#

well, just import into blender, smooth the normals and import back to unity

burnt ether
low lichen
#

@burnt ether It'll be similar to how deferred g-buffer decals work

cosmic prairie
#

@burnt ether

burnt ether
#

@cosmic prairie Thanks, but now how to use it?
Inputing this to uv node of texture doesn't work, results are crazy.

low lichen
burnt ether
#

I tried it.

#

Even tried remaking parallax mapping, but failed.

thick fulcrum
#

@burnt ether check you have enabled the depth texture, I believe it's disabled by default. In urp render settings.

burnt ether
#

Depth itself works. Problem is I can't get this subgraph to work properly.

thick fulcrum
#

@burnt ether I'm not sure if it's possible with shader graph alone yet, I know of some asset store decals for lwrp / urp. I was just looking back in forums, "on the roadmap" is general gist.

burnt ether
#

Is there a roadmap for Shader Graph?

thick fulcrum
#

of that I'm certain, publicly visible.. unlikely

jaunty lichen
#

Is there by any chance a way to convert a .fx (HLSL i believe) shader to a unity supported .shader easily?

cosmic prairie
#

hmm the subshadergraph worked for me, maybe it's gpu specific?

cosmic prairie
#

@burnt ether I'll send the built project with a 3d-ish voronoi example, please confirm that this is what you see or not:

#

you can look around similarly to blender with the middle mouse button and by holding leftshift

#

if you move around the textures should not shift around

burnt ether
#

How do you connect the node to texture's uv?

cosmic prairie
#

just plug it into PBR node's color and see if that works fine first

burnt ether
#

The demo works good.

cosmic prairie
#

btw are you trying to reconstruct from the main camera or the shadow map? because shadow map is a different story

burnt ether
#

From camera.

cosmic prairie
#

yes, but since you are trying to sample a 2d thing with a 3d thing it will look wonky:

#

is this similar to what you see in your own project?

burnt ether
#

Also I'm using HDRP, does that make difference?

cosmic prairie
#

do the textures shift around when you move your camera around?

burnt ether
#

Yes, they can't stay in place.

cosmic prairie
#

maybe? never used HDRP, but doesn't HDRP have world coordinates by default?

burnt ether
#

It has. Show me how you connect the graph with it.

cosmic prairie
burnt ether
#

Idk what happens now, I guess it's HDRP doing something differently with depth stuff.

cosmic prairie
#

yeah maybe its that

#

btw I have no clue why my subgraph even functions, there is a part in it that I made accidentally that made it work

burnt ether
#

Thanks for help anyway.

cosmic prairie
#

maybe I'll try something with HDRP when I have some time

#

bye!

winter acorn
#

would raymarching be doable with the shader graph?

hollow tendon
hollow tendon
#

But so after an hour, I've managed to make the waves work in the way I want. Now I can focus on the other parts of the water shader

vapid orbit
#

Hello! I'm new to this server and I'm not entirely sure where to go, is this an okay place to seek some help with compute shaders?

vapid orbit
#

Uhhh

devout quarry
#

yes

uncut karma
#

@winter acorn probably, I think you'd have to use the custom node to handle the for loop

thick fulcrum
#

@winter acorn it works, I've ported some raymarching from shadertoy and done object space volumetric shapes etc. but as @uncut karma said you need custom node to handle some bits.

winter acorn
#

hmm. thanks

slate patrol
#

I have a problem understanding something...

#

Let's say that I have a function, defined somewhere in the CGINCLUDES block.

#

How can I figure out from which pass it is called (e.g. deferred write, shadowcaster pass, etc.) if no defines actually work there (since CGINCLUDE block must always be higher than the preprocessor define block)?

low lichen
#

You've tried using defines in the function without success?

slate patrol
#

But how can I? The same exact function must be used in all of the passes. I cannot make a definition inside them.

#

And because functions and cgincludes must be present before the call, I cannot possibly process that definition, because it was not defined yet

#

I can just dupe the function and include it into all of the passes, but that'll become a maintenance hell.

low lichen
#

As I understand includes, all its doing is pasting the code you include into the shader before compiling it. So I don't see why defines wouldn't work like in any other function.

slate patrol
#

Yeah, that's if we're talking about the includes.

#

But what about the raw code inside that same shader file?

low lichen
#

I don't think I'm understanding what you're trying to do

slate patrol
#

I have a function in a shader, defined somewhere above the passes or inside a CGINCLUDE shader block (not the cginc file). How can I achieve the exact same behavior here as with defines + cginc files?

#

It's just a hypothetical question

low lichen
#

I don't know. Doesn't sound possible. Why not use cginc files? More duplicate code to include it in every pass?

slate patrol
#

It was just a curiosity of mine.

#

But yeah, I understand why cginc files are better for this

sour swan
#

ok so i downloaded this assethttps://assetstore.unity.com/packages/essentials/tutorial-projects/unity-particle-pack-127325?cid=1011l6DoIzYL

A collection of sample particle assets to use in your projects.

Learn how to achieve certain effects using the Unity Particle System component and modules.

You'll find fire, explosions, ice, dissolves and other awesome effects FREE to download right here.

#

and i'm new in general to unity and everything surrounding
so my question is how do you spawn a particle effect prefab
and have it happen once

uncut karma
#

@slate patrol could a forward declared function help in your situation?

#

It's basically a function defined without the body first, then later anywhere in the file it is redefined (so it avoids the compiler thinking it is missing)

grand jolt
#

Could anyone give me some help on this? It happens anytime I try to do any shadergraph

uncut karma
#

That looks like a shader graph bug, it is in control of any includes, did u check if SG and URP are same version?

grand jolt
#

they're all up to date

#

still on the same error

upper kite
#

I also see this pop up very often, seems to be a bug in the async shader compiler

sour swan
#

how do i spawn in particles

hollow tendon
#

I have a question. I'm trying to make water similar to the witness, and I'm have a lot of trouble with having the water reflect the world. I've tried a few different ways, but it usually ends in my editor crashing.

full sail
#

how big a concern is overdraw with transparent effects? I've got this shield effect rendering to a quad, but there's a lot of unused space.. should I find a better way to do this?

low lichen
#

@full sail It's a big concern for mobile hardware. Desktop and console, not as much.

full sail
#

@low lichen cool, any insight into a better way to render 2d effects? or does this approach seem acceptable?

low lichen
#

@full sail You could reduce the overdraw by making sure the quad doesn't extend much further than the texture. You could also place the quad behind the ships (?), so you're not drawing transparent pixels on top of the ship.

full sail
#

@low lichen I'm using "clip" to discard the majority of the shape currently. Are you saying pixels are automatically discarded if they sit behind other objects from the camera?

low lichen
#

Yes, it's called early Z rejection and it's an optimization that the GPU uses so it doesn't have to draw pixels that won't be visible anyway because other objects are in front of it.

#

clip and discard are really bad for mobile GPUs, you should not use it if this is for mobile

#

For desktop and console, it's absolutely fine.

full sail
#

thanks for the info @low lichen

vapid orbit
#

So, I've been having an interesting time with Unity's compute shaders. I've been working on an audio visualization project involving real time fluid simulation. After doing a lot of research and reading a lot of papers, I stumbled across this code found here: https://github.com/Scrawk/GPU-GEMS-3D-Fluid-Simulation. The thing is that I had tried to adapt this code to work with rendertextures, as in this code it's implemented using compute buffers. When I had finished my changes, I went to test it, and it's simply not behaving the way it should. I've double checked everything and made sure that all the math is correct. Also, my rather messy code that I wrote can be found here https://github.com/AsherBearce/AudioVisualizer. I also have code that is the directly modified version of Scrawk's implementation that I can provide if necessary, however I'm too lazy to post it to github at this moment. Also, the directly modified code, and the code found on my github behave in exactly the same way. I'm not entirely sure what I'm doing wrong, so if someone with more experience than me could lend a hand, I'd be very grateful.

uncut karma
#

I'd ensure that your textures are linear color space, your project settings are set to gamma space, so I think textures will be sRGB unless specified directly, but not sure if that's the issue, it only displays a small circular blob for me

vapid orbit
#

That's the behavior I'm experiencing as well. I'll try changing the color space to see if that works

#

Actually, how do I change it? Lol I can't find it in the project settings

#

Ah, nevermind found it

uncut karma
#

Oh and you're only copying slice 0 of the texture

#

It isn't required to use texture 3d, I'd just use rendertexture for both

vapid orbit
#

Yeah, I realized that pretty quickly

#

But I just haven't gotten around to fixing it. I'll try that now

real basin
vapid orbit
#

Thanks! I'll definitely give that a look. I do have a solution to my problem, but it kind of ignores why I'm having this problem, and I think this would be a good learning experience to fix it.

lime viper
#

In shader graph has anyone been able to get transform nodes to behave correctly going between object and world space? I seem to have them working after a bunch of tweaking and then they seem to change their functionality? I am still on 19.1 so it could just be versions but my cursory search of the issues database didn't seem to turn up anything.

slate patrol
#

Alright, I seem to be missing something crucial

#

How do I render the motion vectors? e.g., I have some vertex displacement and I need to write motion vector data by multiplying the previous matrix.

#

But as far as I can see, no internal shaders do that. They don't calculate motion vectors and I can't see where they write em.

#

So, how do I write the vector motion data?

#

I know that there is a "MotionVectors" LightMode, but that one requires its own pass in order to render, which is absolutely not acceptable.

slate patrol
#

Anyone?

fervent tinsel
#

@slate patrol which renderer?

slate patrol
#

Default one, of course

#

I mean, the legacy one

#

You get which one I'm talking about

#

Is it really necessary that I need a separate pass to render custom motion vectors?

fervent tinsel
#

that sample is overriding the motion vectors

#

but should give you ideas how to do other things

#

there's visualization shader too if i remember right

slate patrol
#

Yeah, I snooped around in it, but it does require its own separate pass to render the motion vectors.

fervent tinsel
#

yes

#

ah, you said that already

#

I dunno how else you could write there unless you do it on some pass

slate patrol
#

But how does the standard shader do it without a separate pass?

#

Is it just a hardware quirk that basically says "if you don't do vertex manipulation I can write correct motion vectors for you automatically"?

fervent tinsel
#

there isn't some internal pass? I wouldn't know

#

you could probably see these with some frame debugger

slate patrol
#

There is none. No internal shaders have a dedicated MotionVector pass

#

And I don't. I can debug motion vectors written by a separate pass, but not the ones that are written as a part of the main fragment shaders. They do get written though.

#

What is more dealbreaking for me is that MotionVectors pass doesn't seem to support instancing, so all of the meshes are rendered separately.

void bobcat
#

When converting from Shadertoy to Unity Shaders, what would be the equivalent to iChannel1?

#

freqs[1] = texture(iChannel1, vec2(0.07, 0.25)).x;
Like in the above example

plucky bone
#

Probably a normal texture input

void bobcat
#

Would you be able to assist me in converting? I'm pretty new to shaders, but just wanted to see a shader I found on Shadertoy in Unity

low lichen
void bobcat
#
float freqs[4];
void surf(Input IN, inout SurfaceOutputStandard o)
{
    freqs[0] = tex2D(iChannel1, float2(0.01, 0.25)).x;
    freqs[1] = tex2D(iChannel1, float2(0.07, 0.25)).x;
    freqs[2] = tex2D(iChannel1, float2(0.15, 0.25)).x;
    freqs[3] = tex2D(iChannel1, float2(0.30, 0.25)).x;```
#

I've watched that

#

The problem is he glosses over iChannel1

low lichen
#

iChannel1 is just a texture input. You have to define a texture property in the start of the shader, then sample it with tex2D, like you're doing in that snippet.

void bobcat
#

so basically the input for the user?

#

There is "_MainTex("Albedo (RGB)", 2D) = "white" {}" already, which I assume could be used here?

low lichen
#

Yeah, replace iChannel1 with _MainTex

void bobcat
#

Alright

#

I guess the other part is fragCoord

#

Would that be Input IN?

low lichen
#

I think the tutorial goes over fragCoord

void bobcat
#

Hm.

#

I'd have to watch again then.

The line is:
float2 uv = fragCoord.xy / iResolution.xy;

#

He already mentioned that, since it's on a 3D object then resolution doesn't really matter

#

But question is if the UV float does because it's used somewhere else in the computation

low lichen
#

What that line is doing is converting pixel coordinates to uv coordinates.

void bobcat
#

Right.

low lichen
#

The tutorial definitely goes over this

void bobcat
#

I'll try and watch again then

low lichen
void bobcat
#

Oh, thank you. I was skimming to look through.

#

Hm

#

I don't quite understand his fragColor cheatsheet

#

He just seems to return a float4

#

Is that right?

low lichen
#

@void bobcat Yeah, in shadertoy the main function is a void, but outputs by setting the out parameter fragColor. In Unity, the frag function returns a float4 instead.

void bobcat
#

Wait...this is a void function. I can't return anything from it.
So I'd have to write to the "SurfaceOutputStandard"

#

Ah, I picked surface shader

#

Rather than unlit shader

#

Okay

#

The result was not exactly as on shadertoy.... xD

#

I'm making a gif for the unity version I just converted

low lichen
#

iChannel1 is an audio stream, not a texture. Could have pointed that out.

void bobcat
#

huh? ๐Ÿค”

low lichen
#

This is an audio reactive shader. Do you want to convert that part, too?