#archived-shaders

1 messages ยท Page 193 of 1

lost kernel
#

or, let's say it works but the values can't be right

#

i tryed to get a random on the triangle location and use the localpos.xyz as seed to have the same value every time, but it gives the same result as positionWS somehow and so the random changes every time the triangle moves in the world ๐Ÿฅบ

#

im wondering how i could get a ONE TIME random for every triangle in the geometry shader if anyone has an idea

#

preserved over every following frame of course

merry rose
#

Anybody got an idea why when I have generated normalmap used in Shader Graph, one axis gets inverted, I have clean Vertex Normal and Tangent so they both match, but they only match in one direction, it seems like Bitangent is inverted but how do I modify bitangent?

merry rose
#

Found fix, If anyone has this problem then terrain is for some reason taking inverted normals, so either try multiply X or Y by -1 of the unpacked normal map

glossy matrix
#

found this on the internet -- if anyone needs a shader where the object is always facing the camera

steel jackal
#

Does anyone know the equivalent to Blender's "Darken" and "ColorRamp" in Unity Shader Graph?

mossy cobalt
dusk tapir
#

Im trying to get started writing a compute shader, i have an algorithm i need to run on every value of a 6dimensional array, but i dont know how to have a shader do that, and doing it with a massive nested for-loop seems atrocious

vital stream
#

Anybody know way to find all shader graphs' used the subgraph? Currently i replace subgraph file from project and see on shader graph errors in console, but that is small confused and look not as "correct way".

glossy matrix
untold shard
#

uhm guys, does shader graph has problem with setfloat going from 1 to 0? I'm trying to do a dissolve back but the effect refused to run

sly breach
#

I'm trying to make a function node , how do i read those errors ? doesn't tell me much about anything

Shader error in 'hidden/preview/RadialBlurCustomFunction_b6a14967fbbd4143b9294e091a5245e1': undeclared identifier 'RadialBlur_float' at line 157 (on d3d11)
#

that's my node settings

#

and the function itself

regal stag
sly breach
#

so do i just change the function name to RadialBlur_float ?

regal stag
#

Yes

sly breach
#

it doesn't work :<

#

oh it does

#

i just see another error lol

#
cannot convert from 'const struct UnitySamplerState' to 'SamplerState'
#

is this a URP thing ?

regal stag
#

Ah, you're in v10.3+, they changed the texture and sampler types to make them better to work with

sly breach
#

i see

regal stag
#

You should use UnitySamplerState instead of SamplerState, and UnityTexture2D instead of Texture2D

sly breach
#

10.3 it's for the package version , yes ?

regal stag
#

It means though, that if you want to use the sampler from the texture you can now, with MainTex.samplerstate though, so you might not need the SS input

#

Yeah these were 10.3 changes, the function won't work if you make those changes and want to use it in versions prior to that, you'd have to go back to Texture2D/SamplerState instead of the Unity_ ones.

sly breach
#
MainTex.samplerState * coord 

vs 

SAMPLE_TEXTURE2D(MainTex, SS, coord);
#

?

regal stag
#

I mean that you might not need the SS input at all, instead just do SAMPLE_TEXTURE2D(MainTex, MainTex.samplerstate, coord); and it'll use the sampler from the texture. Unless that's not what you want of course.

sly breach
#

i see , may its better

#

it does work now

#

thanks @regal stag

#

how do i convert float2 to make it a UV input ?

regal stag
#

For now, you just have to connect a UV node

sly breach
#

so its only a (visual) node thing , i mean it doesn't impact the calculations ?

regal stag
#

Yeah

sly breach
#

i see , thanks

left stump
#

Hi, i'm trying to find a shader that create something light beams like this https://ibb.co/z6wdMYC
And same lasers like this https://ibb.co/LCTwdC9
I know there is a payment way but i can't afford to buy it now

But i the only problem is i need to use a Render Texure for the color.

I can give more info if you need just MD me.

Image Captura hosted in ImgBB

Image Captura hosted in ImgBB

sly breach
#

@left stump for the 1st one i would try making a cylinder shape with the top part having a smaller radius , and making a transparent shader that move a noise function as time passes , and apply a gradient with HDR with tiny step and without hrd for the rest of the shape to make that light at the edge popup / or just add a source or light instead , for the 2nd one u could simply use a line renderer with white as its primary color and purple as the outline color , idk about the blending area near the tip that make it look like a triangle tho ?_?

left stump
#

The lasers that you see, they change colour with a Render Texture, and it's a plane but i don't know how to code :c

sly breach
#

any one knows how to make phat lines ? is there a blur method in a node or is it better to write a custom function that scans the neighboring cells and sharpens the edges ?

sacred patio
#

This is pretty basic, I am not using any graphs so far but does anyone know why the colors won't project onto the planes?

frosty zenith
#

(ping me if you reply)

frosty zenith
#

okay i don't think there is any way to get the GO from the render pass

#

(witch does make some sense)

#

soo i would need to
A) add the extra renderer to the default shader, like make a variant of it or similar
B) maybe add the objects that need it with some render command in the update

slim steppe
#

I'm moving vertices using shader graph how can I paint the strength at which they're moved?

My idea was to paint colours between black and white on a texture and then multiplying the movement with the strength reaching from 0 to 1 but how can I do something like that?

glossy matrix
#

a bit of an issue -- transfered some shaders from an test project, the generated shader code from the other project doesnt work with the current version, and unity has removed the ability to copy the shader code

wanted to edit ztest to off. .

regal stag
glossy matrix
#

oh thx! thought i was strung outa luck

mint vector
#

Could anyone guide me towards a good tutorial for water physics?

tranquil plume
#

Is it possible to have decals in URP?

amber saffron
tranquil plume
wintry minnow
#

Hello.. I'm trying to make part of a decal transparent using an alpha map. Instead of being transparent its showing black. Anyone know what I'm doing wrong?

meager pelican
#

You're looking for alpha-clip. The "how" varies by what pipleline you're using.

wintry minnow
#

I have clipping checked, I don't see any difference between 0 and 1

opaque sorrel
#

What form of render pipeline closely reflects the shader-node style of Blender? I'm trying to duplicate my shader I used for Blender, rather than just baking everything in.

#

Or how exactly would I get to a point I can do shading setup similar to this?

amber saffron
opaque sorrel
#

Oo kk thank you

#

This is probably a nonsense question, but is shadergraph/ URP/HDRP really taxing when it generally comes to rendering a world? Like I feel like if I wanted to make a game for mobile baking in from blender will probably be the only truly manageable way.

grand jolt
#

is there something similar to tesselation / subdivide node in URP?

#

i made a heightmap shader but its really blocky, i mean it obviously has low amount of triangles (i'm testing this on a quad now)

#

this isn't possible with URP, right?

merry rose
alpine goblet
#

just in case you are working on a terrain and are later thinking about adding a mesh collider so you can have some kind of player controller on it, you should know that a shader that changes the vertices of a mesh wont affect the mesh collider and it might have other limitations ( im not very informed so there might be some kind of workaround )

grand jolt
#

yeah, that method is heavily limited for other reasons as well. i really don't want to go down the collider only route

#

thanks for this, i'll check it out

opaque sorrel
glass verge
#

hello! im a complete newbie to shaders, but i was wondering, given this example where i have 2 intersecting spheres with inverted normals, if it would be possible to remove the parts of each sphere that intersect? ideally, if one sphere enters the radius of another, the vertices that intersect should be cut off (i will only ever be doing this with spheres, if that helps). if anyone knows how to do this or where i should go to learn, please let me know :)

shadow locust
glass verge
#

the player will be inside the spheres, so they should be able to see from one sphere, through the intersecting area, and to the other sphere

#

so in this case i guess i'd want it to show the parts of the sphere that are behind the other sphere? it would be a bit like a boolean addition, if that makes sense

knotty jacinth
#

Hey all, I'm relatively new to shaders and wondering if I could get some help with trying to solve this issue. I've got a dissolve shader that once a mesh is disolved, i'd like it to continue to cast shadows. I've been able to achieve that by making the Surface transparent, and passing my cutoff into the Alpha Clip Threshold as well as my Alpha. However, as you can see in this video, i'm getting some issues that i don't fully understand, though know it's related to the Alpha Clip. I don't get this issue if I leave the shader surface Opaque, however I no longer get the shadows from the dissolved meshes. Can someone point me to some reading or offer advice on how i'd be able to solve this? Here is the Shader graph:

mossy cobalt
#

heeeeey simple question maybe

#

How can I make a shader not cast shadows?

eager folio
#

Does anyone have a good rundown on making URP screen effects?

hollow trellis
#

Anyone have experience with Replacement Shaders?

I'm trying to figure out how to make a transparent shader turn opaque using them. I need the Camera's depth buffer to reflect this change for a post processing effect though

regal stag
# eager folio Does anyone have a good rundown on making URP screen effects?

I have one here, though perhaps a little outdated : https://cyangamedev.wordpress.com/2020/06/22/urp-post-processing/#CustomEffects
In short, for fullscreen effects you can use a Blit in a custom renderer feature (which basically draws a quad with the source texture to the destination target, but a material/shader can also be applied). Unity has one here : https://github.com/Unity-Technologies/UniversalRenderingExamples/tree/master/Assets/Scripts/Runtime/RenderPasses
(that version likely only works in v10+, can switch the branch/tag if you are using an older version. I also have one here : https://github.com/Cyanilux/URP_BlitRenderFeature for v8).
You can assign a material/shader to the feature that uses _MainTex to grab the source input. Can even use shader graph (unlit graph).

regal stag
# mossy cobalt How can I make a shader not cast shadows?

There should be an option on the Mesh Renderer to disable casting shadows which might be easier than editing the shader. But if it's a code-written shader, for vert/frag there will be a ShadowCaster pass which is responsible for casting shadows. Without that pass it shouldn't cast them. If it's a shader graph I don't think there's a way to toggle it though, other than on the renderer.

regal stag
# knotty jacinth Hey all, I'm relatively new to shaders and wondering if I could get some help wi...

Transparent objects don't write to the depth buffer so cannot always be sorted correctly. It's best to always stick to opaque. I can think of two ways to fix this :

  • Duplicate the floor gameobject, assign a normal lit material and set it's Mesh Renderer to Cast Shadows Only, that'll make the object invisible but still cast shadows. You can then disable casting shadows on the dissolving object.
  • Or, Using a Custom Function it's possible to change the output of the shader for it's ShadowCaster pass compared to the regular pass. This would allow you to set the alpha clip for the main one so it dissolves, but leave the ShadowCaster at 0 so it always casts shadows. I have a tutorial that includes a section on this here : https://www.cyanilux.com/tutorials/intro-to-shader-graph/#shader-pass-defines
    But I'll post the code here too (slightly edited) :
#ifdef SHADERGRAPH_PREVIEW
    Out = 1;
#else
    // For URP this is needed :
    #include "Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Includes/ShaderPass.hlsl"
    
    // Test if we are in the SHADOWCASTER pass
    #if (SHADERPASS == SHADERPASS_SHADOWCASTER)
        Out = 0;
    #elif (SHADERPASS == SHADERPASS_DEPTHONLY)
        // might also want to treat this one as no clipping.
        Out = 0;
    #else
        Out = 1;
    #endif
#endif

Custom Function using String mode (so it's contents is edited via Graph Inspector). Either replace 1 with an input or Multiply the output with the Alpha Clip value before putting it into the master stack.

eager folio
#

@regal stag Thank you! I'll need to check that out.

eager folio
#

How about rendering an outline around an entire particle effect?

#

Or alternatively how to draw a duplicate of the particle system with the same random seed

#

Can I just set the seed to the same in both and have them match?

#

hrm, nope

#

Solved it. Apparently particle noise isn't based on the seed of the particle system o.O

eager folio
knotty jacinth
#

@regal stag Woo! Thanks so much! Took me a second, I was misunderstanding what you were saying, but the opaque shader solution worked perfectly! There was an issue with the SSAO still showing but that was because the source was set to Depth. Setting Depth Normals fixed that! Your site is also great! I've been looking for some good resources, so this is a treasure trove ๐Ÿ™‚

grand jolt
#

does any one have a good shader code recourses?

bitter elm
#

Hey,
It's possible to send data from a MonoBehaviour-script to a shader. But is it also possible to retrieve such information, for example how much of an object's surface is receiving shadows?

#

Using the URP here

merry rose
#

Material property blocks or Global properties can be used to pass data into shaders, but how I have no idea how can you retrevie aswell.

clear dragon
#

Hi ๐Ÿ™‚ Very quick question: why doesn't unity_ObjectToWorld work at all?

regal stag
clear dragon
#

Even if that were the case, the result should still be correct, right?

#

Of multiplying the input vertex by unity_ObjectToWorld

regal stag
#

If it's the identity matrix then multiplying shouldn't change the input vertex position.

clear dragon
#

Whoops sorry, my mistake. It's not unity_ObjectToWorld that isn't working, it's WorldSpaceViewDir

#

I've been rendering out values as colours for debugging, and had the wrong value output. Yeah, it's WorldSpaceViewDir that doesn't work.

#

Is it okay to post an image to show the problem?

regal stag
#

Yes, an image might help show it better

earnest scroll
#

not sure if this is about shaders but is there anyway to get real time raytracing on the latest hdrp package for unity 2020.1.17

clear dragon
#

OR I could just stop being so goddamn stupid and read the definition of the function

#

I saw 'worldspaceviewdir' and assumed it wanted a WORLD SPACE input. It doesn't.

regal stag
#

Be aware that a vector contains negative values so might show as black depending on where you are looking at the object.

clear dragon
regal stag
#

Ah right, yeah WorldSpaceViewDir needs the localPos. There's also UnityWorldSpaceViewDir which takes a world position to make it more confusing though ๐Ÿ˜„

clear dragon
#

Yep, that's sorted it. God I've been stuck on that for two hours

regal stag
#

I think it is recommended to use the UnityWorldSpaceViewDir one instead as then you don't have to do the matrix multiplication twice

earnest scroll
#

I really need to know this not sure if this is about shaders but is there anyway to get real time raytracing on the latest hdrp package for unity 2020.1.17

clear dragon
regal stag
#

It also links to pages where you can likely find more information

earnest scroll
regal stag
#

You should check that last link I posted to ensure the setup is correct

earnest scroll
#

yeah I see thx for the help it actually helped

#

okay that sounded weird

stray kiln
#

hi have this error in my shader

#

Shader error in 'Water': 'vert': output parameter 'o' not completely initialized at line 69 (on d3d11)

#

anyone know how to fix?

regal stag
#

@stray kiln Assuming this is a surface shader, either remove the out Input o if you aren't setting any custom values, or add UNITY_INITIALIZE_OUTPUT(Input,o); to the function.

stray kiln
#

yes its a surface shader

slow blaze
#

I'm generating a lot of small tiles from a single prefab, but I want each prefab to have a slight difference in the amount of dirt it has on it, which I'd like to randomly generate with noise. Is this something best handled in a custom shader, or a secondary map, or another approach altogether?

woeful geyser
#

Global constants don't work in compute shaders?
I get different results here

// Global scope
const float3 V1 = float3(0,1,0);
// Inside main()
    v1.positionWS = start + V1;
// This is not equal to
    v1.positionWS = start + float3(0,1,0);

stray kiln
#

@regal stag ty mate that worked

wanton yarrow
#

Is there a way I can apply render scaling without the need for a scriptable render pipeline?

fluid lion
wanton yarrow
#

Am I able to make a shader that sets a bilinear filter?

grand jolt
#

what the hell is float4

#

and float3

#

and float2

regal stag
# grand jolt what the hell is float4

float refers to a 32-bit method of storing decimal numbers, in a "floating point" format.
float4 is a vector extension of that, where it has 4 of these float numbers. Usually labelled as RGBA as shaders deal with colours a lot, or XYZW which is commonly used for positions.
float3 and float2 are the same, just with less components, so only RGB/XYZ and RG/XY.

#

If you are familiar with C#, the equivalents are basically Vector4, Vector3 and Vector2.

grand jolt
grand jolt
regal stag
# grand jolt there is only 3 axis in unity so why float 4 ?

Like I said, shaders deal with colours a lot which includes an alpha channel (e.g. to handle transparency). That's the most common use for the A/W component. It's also used in graphics during rendering with a perspective camera projection. But any four float values could also be packed into a float4, they don't have to correspond to a 3D position.

steel hawk
#

what does public in c sharp mean?

shadow locust
#

Not sure what that has to do with shaders though...

steel hawk
#

thanks!

loud remnant
#

How can I have my shader render on top of everything?

mossy cobalt
#

Does anyone know how I can get this alpha shader to stop rendering on top of itself?

#

It seems to arbitrarily decide which faces render in front

#

So it looks like a mess

thick fulcrum
toxic flume
#

Can I fallback when target 3.0 is not supported in some devices?
#pragma target 3.0
Does Mobile/StandardShader have target 3.0 or 2.0?

#

and I have written an offset shader to solve z-fighting
I want to change it for example from (1,1) to (-1,-1) when it flips or the camera view changes (front to back face), Can I do that?

mossy cobalt
#

@thick fulcrum You were exactly right. Thank you :]

toxic flume
#

Where is graphics emulation in Unity2019?!

heavy ether
#

hi, does anyone know if its possible to access meshes/renderers bounding box values in shader graph? im trying to mod vertex positions relative to the objects center position, without manually setting the property for each object

zenith meteor
#

Im trying to make a basic lambert shader on HDRP started from an unlit node but this doesnt work for me.Any ideas?

meager pelican
wanton yarrow
#

Has anyone found a way to create a "render scaling" feature in a shader WITHOUT the need for an SRP such as LWRP?

solar sinew
teal breach
#

Is there a way to override a hidden shader? Eg, the WavingGrassBillboard shader from URP has ColorMask RGB, so it doesn't write the alpha channel. It's a simple change to make it write alpha, but if I edit the shader file unity just overwrites it again

wispy stump
#

Is there a way to combine a geometry shader with a lighting based one?

loud remnant
#

Can someone help me with this please

#

I want to be able to edit this shader graph variable from a script

#

blinkRenderer.material.SetFloat("Alpha", 1);
I tried this but didn't work

regal stag
shadow locust
wispy stump
loud remnant
#

@regal stag It didn't work

#
    private Renderer blinkRenderer;
    // Start is called before the first frame update
    void Start()
    {
        blinkRenderer.material.SetFloat("_Alpha", 1);
        blinkRenderer = GetComponent<Renderer>();
    }
shadow locust
loud remnant
#

omg.. I set the float before I get the component. Sorry for the @
Yeah it works. Thank you!

wispy stump
shadow locust
#

Written a vertex and fragment shader? Yes

#

In Shader graph? No

inner mist
#

Does anyone have a way to make Metaballs in the modern URP 2d renderer?
Every setup I've found breaks when I set things up for lighting.

fluid peak
#

so a shader i finished over the last 2 days I'm proud of, its a resource collection storage pod (the decorative metal bits outside arent here yet, just the container) the geometry shown here is a simple elongated sphere, completely smooth, no internal geometry or anything. I got it to be able to have ore add into it from the bottom up, and have a cool internal glow, and look like it has depth thanks to some parallax stuff. it reacts to environment lights and shadows only against the ore bits, and the internal glowey bits don't as they are supposed to be lit internally... overall came out nice. originally had the reveal wipe using visually individual chunks of ore, but it was to large of a granularity, so it doesn't really follow the visual chunks but mostly still works, easy to change it back just a single texture map change to a different gradient.
https://www.youtube.com/watch?v=q7gmlPckHr0

fully smooth spherical shape all depth and resource and shadow and glow is full inside the single shader

โ–ถ Play video
fluid peak
#

had to edit together several screenshots to get a big image out of the shadergraph editor (future feature maybe?) but its not a super complicated graph. the only custom nodes i have here are a simple 3 point gradient, because the inbuilt gradient function A) can't be manipulated by external c# code. and B) they tend to lose their color settings randomly and go completely white. and it could be more efficient, but i will improve it later. (pay no attention to variable names, they make no sense cause they got re-used and moved around a lot)

frail yarrow
#

I am trying to replicate this grass overhang that can be seen in the bottom picture.

So I've been working on this technique trying to figure out how it was accomplished, and I'm not terribly familiar with shaders, but I wrote one to try and replicate this.

The top left is the masks, the top right the attempt with textures, which in this picture doesn't look terrible.

However the issue i'm running into is stretching with the edge. If the normals are not consistent like this, as I am just using world normals and a dot product to detect which texture to sample.

Ignore the textures, but I'm struggling to keep the overhanging grass a consistent height and not stretched, does anyone have any thoughts on how this was accomplished?

Could I be sampling the texture incorrectly, or maybe there is a technique to keep a textured area the same height in worldspace rather then object space?

I see a seam in the screen shot, could it also just be a UV trick rather then a texture rendering technique?

I feel like I'm close to getting this to work and would like to hear any thoughts on how it was done, or what I might be able to explore to get it closer to the result.

Two examples of the inconsistencies to follow

mossy cobalt
#

Okay odd question, maybe

#

How could I create a shader that mocks an unlit shader, that brightens and darkens according to the light?

#

Or maybe put more accurately, is it possible to average out the light hitting the object?

#

So it all brightens and darkens at the same pace?

shadow locust
#

I guess you'd basically just have the fragment shader read the lighting information from a single point no matter where the pixel is on the model. Not 100% sure how to go about that

mossy cobalt
#

Yeah it's a weird problem, I've been trying some hacky workarounds like raising the dark spots' emission so the shade is less apparent

#

But then obviously I have the problem of the brightness being raised when it exits the light

fluid peak
#

@mossy cobalt you can take the position of the light, color and intensity, pass them into variable in the shader and take inverse square distance to the light point (point lights) then multiply by color, intensity, and you could even drag in "range" depending on how you wanted to react to light settings. using "position (world)" node gives you calculations based on actual world position of each pixel so the object is lit based on how close each little bit is to the light, whereas using "object (position)" node calculates ALL pixels for the object based on its position point, so the whole object is the same color, but affected by the lights its tracking

#

for each light you want to track, then just add them all up before dumping into color output unlit master node

mossy cobalt
#

Wow that's beyond my expertise perhaps, haha

#

If I'm understanding correctly, you need to configure which lights specifically to take the parameters from?

fluid peak
#

its actually super easy once you think in how stuff works. manipulating shader stuff from code is SUPER powerful, makes stuff very dynamic

#

your code can just have a collider following the object and have it test for any lights within that collider, then just pass however many lights your want to track, starting with closest,

#

depends on what look you want to achieve in the end i can't imagine its a super complicated visual game, but i don't know what your building

#

have the shader be "able" to handle up to 5 lights or whatnot, and if nothing is passed in, set those lights to black when you feed the shader, so the object doesn't react at all

mossy cobalt
#

Yeah the code part is my weakness! I'm just an artist, haha

fluid peak
#

its always something to play with if for no other reason to be able to talk to whoever your working with and being able to talk their language and work through what you need from them, or understand what they need from you. crosstraining is always good ๐Ÿ™‚

eager folio
#

@fluid peak Very cool, but maybe enabling backfaces for the ore would help show that it is a container, rather than just a surface change? Also maybe still show the glass on top of the chunks; right now it kinda looks like a coating rather than stuff inside?

slim steppe
#

Im trying to create stylized Shaders(In Shader Graph) who is the best Content Creator to learn those Things?

regal stag
frank trellis
#

Why is this pink ?

swift loom
#

i have a lightmap.png default texture type file that's 1x1, and at game launch I have a script that resizes it and SetPixels to fill it with RGB values as light blockers to be read by my shader. however when i start my project and hit play, it always does this weird thing in the scene view and i have to fix it by reimporting the shader

#

It's like _TexelSize doesnt get updated in the shader when the file gets resized

slim steppe
#

@regal stag Your work looks awesome!

regal stag
swift loom
#

it's definitely the lightMap.Resize() step that doesn't update something properly ๐Ÿค”

digital gust
#

Anyone got a good wireframe shader? Just want to show the edges, but I cannot seem anything that I can use in shadergraph. Just bought an asset and it is not even working with the standard unity meshes...

swift loom
#

well... for some reason not having the lightmap file assigned to the shader and applying it via code fixed it, even if i "reapplied" it before too after making the changes. Don't get it but it works.

grand jolt
#

How can I make a shader that puts a texture to the intersecting faces with shader graph in HDRP ?

fluid peak
#

@frank trellis a couple of possibilities, most commonly its referencing a texture that no longer exists. or there is a math error like a division by zero, could be there are too many texture samplers in a single shader (i think its like 16 or so but at some point it will throw a fault). very unlikely but that is an actual color that can be the legitimate output but if your not expecting it, then probably not

fluid peak
#

@eager folio I am gonna see what I can work into it, but there isn't any separate geometry for the ore bits, its all a single surface. should be possible but I gotta play with it

loud remnant
#

How can I set my shader to render on top of everything?

#

I'm using an unlit shader graph

small lichen
#

I'm trying to create an unlit shader for HDRP but the exposure of the world is affected when I get too close to an object with it. Any tricks to fix this?

ebon lotus
#

Whats the shader node called that mixes two colors based on a value

#

at .5: 50% a and 50% b, at 1: 100% a

ebon lotus
#

Ye thats the one

#

Thanks

lapis hearth
#

Is the standard shaders here to stay or is unity pushing it to the urp and hdrp pipelines?

shadow locust
#

Yes

frozen mason
#

How I can create such a custom skybox (2 sided, top and bottom)

shadow locust
#

It looks like you already did?

frozen mason
#

nope its some image from internet

shadow locust
#

Honestly doesn't look like a skybox

#

Just looks like some big planes

hollow harbor
#

How can I make it such that my buildings are not see through?

fluid peak
#

That looks like a render order issue?

hollow harbor
#

Hmm..it is a demo scene from a package I have.

regal stag
#

@frozen mason Maybe something like this

frozen mason
#

Awesome @regal stag gonna play with this! Thank you

hollow harbor
frozen mason
#

@regal stag how you create those anchor or whatever it is so you can alter line path

regal stag
grand jolt
#

I'm working on a shader to blend 2 textures using noise but as you can see the pattern of the noise repeats is there a way to fix that I was thinking it might be possible to add world position to the noise but I'm not sure if that would work

#

this is the noise part of the shader the clamp connects to a lerp with the 2 textures

knotty juniper
#

you can use 2 cordinates of the wold position node as the uv for the noise

grand jolt
#

do you mean like this?

placid kettle
#

How do I add comments to the shader graph?

grand jolt
#

right click "create sticky note"

twin swallow
#

When I set my shader surface to transparent, cameras higher on the stack render completely on top of objects with the shader, even though I've not set Clear Depth on my overlay cameras.

#

Am I misunderstanding something?

regal stag
twin swallow
#

Is there a way to make it do so, or act like it is?

#

๐Ÿ˜ฎ i think i got it

#

nope, just made them opaque again ๐Ÿ˜‚

eager folio
#

You can add a render objects render feature, and render that object with an opaque shader that only draws to the depth buffer

twin swallow
#

thats what im trying now

grand jolt
marsh merlin
#

I downloaded an Asset Store package with shaders that work, but the shader says it has errors. Should I fix it? If so, how? It works perfectly fine except for the errors.

twin swallow
#

i think i have it "working," but the cameras higher on the stack dont blend properly with the transparent shader, they just disappear when behind a transparent object ๐Ÿ˜ฉ

#

theres probably a better way to do what i want without a camera stack >.>
i have a group of cubes aligned with a 3d grid, arranged like a rubiks cube.
i want to make one "layer" of the cubes render normally and darken all others, so i set up a camera stack with a post processing effect on the lower camera to darken cubes, and i swap the cubes between the camera layers when they need to be lit vs darkened

twin swallow
#

like that. is there a simpler way to do this without multiple cameras and layer swapping?

merry rose
#

Hello, any Idea why would only one shader get GlobalMatrix? I am setting it and only one shaders receives it, others just get 0 in all Matrix fields.

loud remnant
#

Does having a transparent material decrease performance if it's alpha is 1?

#

I've got lot's of windows on my VR house and I want to basically make an LOD system for the windows

#

Instead, I thought maybe I could lerp the alpha as the player gets away from windows

merry rose
#

@loud remnant I would change its LOD for Opaque version to draw in Opaque queue as it gets batched better.

ornate blade
#

Hey all ๐Ÿ™‚ Im working on a third person game, and a system to show an area when the view of the player is occluded by a wall.
Now, im currently using a stencil shader with an ovular mask, but its cutting through walls in front of the player as well (which is pretty expected).

Is there any standard way to only cut holes in the objects that are between player and camera? At this stage my main idea is to change object layer on the fly by using camera position, but that feels clunky af.

#

(apologies for darkness, i havent fully sorted lighting yet)

fallen cypress
#

can :Amplify Shader Editor import custom shader then convert them to use in srp

#

I've read somewhere that cg can be converted to hlsl by changing the light model or something

#

light tags*

merry rose
#

Any Idea anyone whats wrong? I cannot get this matrix in any shader, it just gives me 0.

twin swallow
#

Does that string _TerrainMatrix match the reference? (Graph Inspector > Node Settings)

solar sinew
merry rose
#

I basically wanted to instead of using 4 vector4s use one Matrix4x4, which somehow worked on terrain, but other objects received 0s.

solar sinew
#

either way Cyan's page that I linked should solve your issue

merry rose
#

not yet, but it will quite defi the point of not having to setup everything first, and I read the whole page and didnt find my solution, it just said what I already know, gonna try now update to UPR 11.0 to see if there is any fixes for this kind of a stuff.

solar sinew
merry rose
#

well still gotta move for new features but I will try that if it will do anyting

ebon lotus
#

Having the same issue ( i think )

fluid peak
#

to me it looks like its picking the distance the sprite is from the camera based on the center of the sprite, and since the door is taller, when the camera pans up and around, at some point the center of the case door is closer than the guy, so its drawn as being in front, even though logically it shouldn;'t be, maybe it can be resetup to use the depth texture from the camera to test per pixel in shader what to draw in front?

vocal narwhal
#

transparent materials are sorted by their object center

#

cutout materials shouldn't be transparent, and properly write to depth, which sorts them accurately

ebon lotus
#

I have no idea how i would make cutout materials receive and cast shadows ๐Ÿคทโ€โ™€๏ธ

thick fulcrum
ebon lotus
#

Its super complex shader

#

made in urp

#

Lit-transparent

thick fulcrum
#

then you can just change it to opaque and enable "alpha clip" I think it's called, which will enable the alpha cutout portion of the graph. This should keep all the shadows etc.

ebon lotus
#

Oh, look at that, It actually works

#

Thankyou โค๏ธ

elder briar
#

hi all! does anyone uses amplify shader using globalcolor?

#

with unity HDRP?

surreal current
#

Hi there! I just started with URP & shader graphs and created a very basic shader. However, I can't get rid of the error implicit truncation of vector type and I don't know where it's coming from. I'm a shader noob and don't know how to get to the root of this.

amber saffron
#

Can you post a screenshot of your graph ?

surreal current
#

Ha, strange. I just hit the "save asset" button in the graph view again and the errors disappeared. ๐Ÿฅธ

regal stag
polar relic
#

Hello, anyone know why trying to use Cubemap in a ShaderGraph custom node result in "unrecognized identifier 'Cubemap'" ?
Nevermind, as soon as I ask I finally find something on Google.
Apparently you have to use "TextureCube" in HLSL.

regal stag
polar relic
#

Yes thanks. Saw that just after posting :-x

#

Kinda weird to have two completly different names, would have expected the custom node compiler-thing to smooth things behind the scene and keep Unity's nomenclature for simplicity.

regal stag
#

Be aware that if you're in v10.3+, you should also use the newer texture structs, e.g. UnityTextureCube as it can provide access to the sampler state for the texture (via .samplerstate)

polar relic
#

Weird, even with Preview Packages enabled I only have HDRP 10.22. But thanks for the warning.

regal stag
#

It'll probably only be available in newer Unity versions

polar relic
#

I will upgrade my 2020.2 to 2020.3 then.

whole citrus
#

Does anyone know if there is a way to skip a specific pair of shader variants?

I'd like to make a shader with the following variants no_detail, detail_mul2x and detail_lerp. Each of them also has a detail_spec_gloss variant, except no_detail of course.

So detail_mul2x and detail_mul2x detail_spec_gloss are two different variants.
When i write it like this:

    #pragma shader_feature_local _DETAIL_OFF _DETAIL_MULX2 _DETAIL_LERP 
    #pragma shader_feature_local _DETAIL_OFF _DETAIL_SPECGLOSS       

There is a DETAIL_OFF DETAIL_SPECGLOSS generated. Pragma skip variants skips everything with a certain keyword, i dont want that, i only want to skip that specific combination. Is the only way with a shader postproc?

stray kiln
#

Anyone know how I can add an albedo to _DetailMapB?

polar relic
#

@regal stag Updating to 10.3 broke everything. Is there any documentation about what that new "Bare Cubemap" thing is and if I should use it ?
I also get errors like "cannot convert from 'const struct UnityTextureCube' to 'TextureCube<float4>'", regardless of using TextureCube or UnityTextureCube, despite the node working in 10.22. Any ideas ?

regal stag
polar relic
#

Weird, I still get the "cannot convert from 'struct UnityTextureCube' to 'TextureCube<float4>'" error even with everything at "Bare Cubemap" in the graph and "TextureCube" in the hlsl file.
It seems to finally compile by converting everything to the new stuff tho (non-Bare & UnityTC). Guess I will use that then.
Thanks for the troubleshooting.

#

"Internal error communicating with the shader compiler process. Please report a bug including this shader and the editor log."
Okay, maybe I should stop working on shaders today.

grand jolt
#

I'm working on a shader to blend 2 textures using noise but as you can see the pattern of the noise repeats is there a way to fix that I was thinking it might be possible to add world position to the noise but I'm not sure how to do that

#

this is the noise part of the shader the clamp connects to a lerp with the 2 textures

stray kiln
#

anyone can help me with my shader please?

#

I want to be able to use the textMax image here

#

here

#

so my texture is generated based of the height data

#

the textMask holds the heightmap data

polar relic
#

So, I identified the source of that "internal communication error" :
I'm doing a shader for buildings' interior, and need to use several cubemap to avoid visible repetition.
Right now it just sample every one of them and only afterward multiply by 0 the ones not randomly selected before adding everyone's output. It work, but it's not super clean.
I would like to pick the cubemap directly, to only have one sampling to do. Problem is that this HLSL code make the compiler cry. Returning directly any of the Cubemap work, but adding a condition break everything.
Is this an actual bug of there is some HLSL specificity I'm missing ?

low lichen
polar relic
#

I don't see that as an option for ShaderGraph's nodes. Will look into the doc.
Weird, doesn't look like SG can use them, how did you do it ?

low lichen
#

I haven't used them in Shader Graph

open quarry
#

so im working in shadergraph making a grass shader, and im having a huge issue

#

my shader looks great, but its a performance issue

#

when i have the grass shadergraph ope, i get 170 fps

#

when shadergraph is closed, i get 110

#

how do i resolve this?

merry rose
final helm
#

If I want to get a whole prefab model to be tied to a particular shader, do I really need iterating on all its materials to set their shader?

fluid peak
#

@grand jolt the โ€œuv0โ€ input on the simple noise, plop down a position node, set to world, and feed it into that i would suggest putting a tiling and offset node between the two also

merry rose
#

I tried even on start, same result I get Matrix in FrameDebugger but the shader actually dont receive it or somthing

regal stag
merry rose
#

yes, already upgraded the script, now trying per material and that works but defies the point of setting it globally as it needs to be used by any Shader that needs it.

regal stag
#

@merry rose Hmm, I'm testing it now and I see what you mean. It looks like the SRP Batcher can't deal with global matrices properly and is setting it to garbage values.

merry rose
#

Yeah, disabling SRP batching fixes it hmm.

#

I am going to try retreive it with a custom function node, hopefully that will work.

regal stag
#

@merry rose Which version of shader graph are you in? If you have the "Override Property Declaration" setting you can force it to Global which fixes it

merry rose
#

I have URP 12.0

#

Oh wow, thank you so much ๐Ÿ˜ฎ

#

I tried learning how that Override works but I was getting some weird things back in URP 10

fluid peak
#

liable duke, world position is a vector3 inherently, uv input is a vector 2 inherently. so you are seeing x and Z being used for the coordinates, and the wall that is along the x axis is recieving the same x coordinate.

regal stag
# merry rose I tried learning how that Override works but I was getting some weird things bac...

Yeah, unless you're dealing with DOTS and need the Hybrid instanced you usually don't have to use the Override Property Declaration setting. Other properties can be "exposed" which makes them non-global vs global anyway... (and you shouldn't even change it with those property types as it breaks SRP Batching compatibility).

Matrices are treated differently though, can't be exposed and aren't serialised on the material, so I guess by default it's always trying to set it per-material. I knew that was a thing but didn't realise it would cause this problem with global matrices. At least I know now if others have the same problem in the future ๐Ÿ˜„

merry rose
#

Thank you for explanation, I will change others too, one day we would love to move to entities so this might speed things along ๐Ÿ˜„ , and yeah never imagined it happening as I have so many other values that are working globally but does not have override.

grand jolt
fluid peak
#

using a triplanar shader is probably the best option, the builtin triplanar node only works with a input texture, however you can rebuilt the functionality of it using nodes (found on a webpage https://cyangamedev.wordpress.com/2020/01/28/worldspace-uvs-triplanar-mapping/, I didn't figure it out myself) but here is the shader built in nodes, as a place to start

This post includes an introduction to using the Position node to sample textures rather than using mesh UV channels, which is also the basis of Triplanar mapping. It wonโ€™t be super in-depth but wilโ€ฆ

grand jolt
#

thanks

amber saffron
#

Because you only need a mask, the built-in triplanar sample node should be enough.

solar sinew
#

@amber saffron is there any documentation planned for your node library? There are so many great nodes Iโ€™ve used, including all the noise functions, but there are many other I just donโ€™t understand how to use, but I bet they would be useful

amber saffron
solar sinew
#

Haha. Yeah, I understand. I was just seeing so many triplanar options and material data nodes that I know would be useful but I donโ€™t know my way around them

amber saffron
#

including all the noise functions
I can't take a lot of credits for those, I blindly copied the code from a github repo and made it into nodes. Noise generation is dark magic to me ๐Ÿ˜„

solar sinew
#

I do also confuse some of your node library nodes with nodes from the surfgrad workflow, which also need documentation

fluid peak
#

the downside of the builtin triplanar node is it is based on a single texture, and the original original problem he was solving was visual tiling of the noise, and the texture used in the triplanar node tiles, leading to that same visual tiling problem. breaking it out into nodes lets you feed in procedural noise, so it won't tile

solar sinew
amber saffron
fluid peak
#

3d noise would be good, but without resorting to custom coded node, triplanar fed with procedural 2d noise should do ok

amber saffron
#

I'm not sure if the cost of 3 2d noise wouldn't be worse than a single 3d one

#

I have a lot of noise options, including 3d in my nose library mentioned above

solar spade
#

I'm not really sure where to ask this. I hope this is the right section.

If I'm making 3d models for my game in blender and importing them into unity is it better practice to apply modifications (vertex paint, materials, shaders etc.) to the models in blender, then port them over to unity or just port the basic grey 3d model to unity and handle all the shaders and coloring that way?

#

or is it some combination of the two?

regal stag
solar spade
#

gotcha, that makes sense. Thank you!

fluid peak
#

a single 3d noise function would probably be cheaper performance wise... but unless its on a pocket calculator class system, or being super optimized for every last scrap of FPS. but i would guess 99% of the time there won't be any noticeable difference except for some edge cases where they have HUGE numbers of objects with the noise functions on them. but meh they both work, i guess go with whichever he is more comfortable with

regal stag
#

If they're only applying the material to walls like in their image above, could probably also ignore the Y axis projection of the 2D noise and just do the X/Z ones. Not sure how 2 x 2D and 3D compares performance wise but would be an improvement over 3 x 2D.

fluid peak
#

i think it was your tutorial page i found the example on (or it was a different cyan ๐Ÿ™‚

regal stag
#

Yeah it was me ๐Ÿ™‚

merry rose
#

Is there a way currently to use instancing on terrain when using Shader Graph?

amber saffron
fluid peak
#

Well it would be bilinear mapping so it would blend the noise between the two directions, shouldnt cause seams i dont think, but i guess if it was a sharp 90 degree corner then yeah it would have some kind of seam. Thats true

grand jolt
analog crest
#

I currently have this shader in unity and was wondering where could I find documentation on how to add a controller/slider to adjust the number of lines/divisions

solar sinew
analog crest
#

thanks !

outer shuttle
#

is there a way to know the length of a RWStructuredBuffer ? when i do mybuffer.length, it throws me an exception. Im new to hlsl, but i can't find a solution for this?

analog crest
#

Ok so i was able to understand how to add ramps trough my code, now is there a way I can control how many of them i want to show up with a slider/controller ?

solar sinew
#

Could the example script on this page be tweaked to create 3D bounding box UV coords in local space? I'm hoping to set this globally rather than have to attach a C# script to an object.
https://docs.unity3d.com/ScriptReference/Mesh-bounds.html
I'd prefer finding a way to do that instead of remapping object space vertex position.
The goal is:

Automatically-generated texture coordinates from the vertex positions of the mesh without deformation, keeping them sticking to the surface under animation. Range from 0.0 to 1.0 over the bounding box of the undeformed mesh.

fluid peak
#

All things are possible if you believe... i mean there will be a script somewhere running, you can reference other objects from within it. Either directly by dragging them over in inspector. Or dynamically finding them in scene.

solar sinew
eager folio
#

Stupid question, but is there a way to simply capture a screenshot of an entire large shader graph?

amber saffron
# analog crest

Your ramps are not uniformly placed, is that what you want ?
If yes, the only way I can think of would be to have a float array variable in the shader to set the threshold values, and loop into it to make the ramp.
If no, you could greatly simplify the code :
ramped = floor(diffuse*quantity)/quantity;

#

An other easy option is to use a lookup texture, that is either generated from code, or hand made in an image editor.

smoky spire
#

I'm trying to get post processing setup on an old project I've just upgraded to 2020.2.3f

#

I'm just doing a simple test with a cube with hdr color values over 1, and trying to get the bloom effect to work

#

but all of the docs i'm following don't seem to work

#

is there a simple test I can do to verify I have my post processing set up correctly?

merry rose
#

Is there a way to calculate new View Direction? I am reconstructing normals myself but view direction is then "planar", how could I reconstruct view direction within shader graph? if there is a way

lethal flint
#

hey guys do you know why a side of my object mesh is invisible and how do i solve this?

amber saffron
amber saffron
lethal flint
#

i checked in blender all faces orientation are corect

amber saffron
amber saffron
lethal flint
#

yes

#

someone said to me that i need double side shading

smoky spire
merry rose
smoky spire
#

can shader graph show just the edges of a cube, like the wireframe of it

#

or if it's just a cube, is there a way to fake it?

amber saffron
merry rose
amber saffron
#

You do have information, as I can clearly see a color change on the terrain.
You might have to get the world space direction and transform it yourself to the tangent space.

merry rose
#

like I have this but how do I get view direction from it is beyond my brain capability rn I think

amber saffron
#

Well, since you've set the normal to 0,1,0 and tangent to -1,0,0 in world space , I think the view direction from world to tangent is -x , y, -z

smoky spire
#

I think I found a solution using the rectangle node

amber saffron
#

Yep, that's one way to do it

smoky spire
#

the uv's on my cubes aren't the same though, so sometimes my lines are thick and thin

#

you mentioned a way, if it's just a cube, to get it's edges?

#

will that still work if the uvs are different

amber saffron
#

Well, it's a bit more math, but the final result is the same as with the rectangle node.

smoky spire
#

ah ok

#

so if I have cubes that have different uvs, the shader would still look different on each one

amber saffron
#

yes

smoky spire
#

welp back to the art dept then

#

is there an outline shader, in shader graph, that doesn't need the uvs to be the same for just cubes?

amber saffron
#

Wait, you were talking of wireframe before, and now outline ?

smoky spire
#

yea, honstly all I need is the edges of the cubes to glow when I hover over them

#

and I'm trying to figure out how to make that work

#

it's lots of cubes, like packages on an assembly line

#

I have a glowing fresnel thing working, but since they are cubes, it doesn't look right when you are looking straight at them

#

so I was trying to see if I could just isolate the edges, and then make them glow

#

and the rectangle thing is kinda working, but not if I have to adjust it for every cube with a different uv layout

amber saffron
#

To make it clear, you want all the edges to glow, or only the border ones (like an actual outline) ?

smoky spire
#

either would work

#

I'm exploring options

#

think if you lined up a bunch of individual lego

#

and you wanted either the edges/outline to light up

#

not just light up, glow and stand out, I have the post processing working for that part

amber saffron
#

If you only want to do it with shadergraph, you'll have to find a way to "bake" the edges in the objet. using a secondary uv is a good option.
For real outlines, you'll have to use a post process

smoky spire
#

do you have a link for an example using real outlines?

#

because I think I'm at the end of my shader graph progress on this

merry rose
regal gorge
#

Texture 2D Array, something important is missing.

willow egret
#

Is anyone able to help with a shader issue? Legit cannot figure out how to fix it

merry rose
#

any Idea why I cant get hlsl files into shader graph? it wont find any and I cant even drag it into custom function, and if I make Text Asset that works but then it throws error that it needs to be .hlsl or .cginc WTFF

regal gorge
merry rose
#

Yes

regal gorge
#

Looks good, nice.

merry rose
#

thank you

#

I would just like to try parallax occlusion mapping but I cant get custom functions working :/

regal gorge
#

You have only 4 layers, or managed to feature more?

merry rose
#

I have 4 in one "pass" and made it so its one SubGraph I can copy and get 8, 12, 16 etc...

regal gorge
#

I trying to solve that problem for about week I managed to create as many layers as I want, but drawback is that I using Red channel for 6 layers blue for 6 etc. so layers go always in one direction and I cant have sand near rocks.

#

Still trying to do it better. ๐Ÿคท

#

My lack of experience dont help me. ๐Ÿ˜„

#

You have any good tips?

merry rose
#

Fuu I could try but I started rly researching this like week ago so im new to it too ๐Ÿ˜„ I just had previous experience with Shader Forge so that pushed me a bit forward ๐Ÿ˜„

#

but using Texture Arrays seems good but I cant rly find solution to do parallax as when you sample Texture2DArray it gives you Vector4 not Tex hmm

regal gorge
#

You using it for terrain or polybrush? ๐Ÿ˜„

merry rose
#

terrain

regal gorge
#

I just want know how you creating more than 4 layers with subgraph.

merry rose
#

but instancing is disabled, cant figure out to instance it with shader graph grrr

#

Like I can use multiple splatmaps, and assign one to each subgraph where each handles 4 textures.

regal gorge
#

I think I dont understand anyway. xD

merry rose
#

Okayyy xD ๐Ÿ˜„

#

Like I dont even know if its good solution, I just went with what came onto my mind ๐Ÿ˜„ just hate the instancing caus terrain takes like 20 batches for each round- shadows, normals, opaque.

regal gorge
#

I can do same thing with Vertex Colors?

merry rose
#

If you gonna use vertex colors try to go through this Unity Blog, they made pretty cool Vertex Shader with like 6 textures https://blogs.unity3d.com/2021/02/24/experimenting-with-shader-graph-doing-more-with-less/

Unity Technologies Blog

You can improve the runtime efficiency of your shader without sacrificing the quality of your graphics by packing physically based rendering (PBR) material information into a single texture map and layering it into a compact shader. Check out this experiment.

willow egret
#

For some reason, my shader moves away from the object when I move the object? How can I fix this?

regal gorge
#

@merry rose its almost same thing that I have.

#

So its not really good.

merry rose
#

Like you cant get much more with just vertex colors :/

regal gorge
#

Maybe, but there is still drawback.

merry rose
#

yeah

sacred hull
#

I am having problems following this tutorial: https://www.youtube.com/watch?v=gRq-IdShxpU
I've done everything like in the video (I think) but when I change the values my plane doesn't change color at all.

In this video, we'll take a look at how we can use the Shader Graph feature in Universal Render Pipeline, or URP for short, with Unity to create a water shader! The water shader can be simple or complex, and include the features you desire. Let your imagination get wild in this tutorial, or simply follow step-by-step to get about the same result...

โ–ถ Play video
regal stag
sacred hull
#

Thank you! I missed the transparent mode thing

zenith meteor
errant atlas
#

Does anyone have advice for building shaders that can apply different effects in a modular way? For example if I want to add weather effects (snow, rain) to a foliage shader I need to add them into my shader graph for each shader I write (trees, grass, etc) since each material can only accept one shader. Is stacking multiple materials a viable solution?

I've seen solutions like the Better Shaders asset that allows you to stack shaders if you're willing to write them as code, but I wanted to get an idea of how this problem is generally solved since it seems like a common consideration

errant atlas
#

Another consideration is if I want to apply a transparent effect on top of an opaque shader they cannot be part of the same shader to my knowledge, which rules out adding them to a combined shader

eager folio
#

@errant atlas If you are using URP you can add a render feature to render specific objects with a specific shader.

#

Slight drawback of needing to use a layer for each variant

grand jolt
#

@regal stag I know we were talking about this around last week

#

but lettier actually managed to get pixelated shading

#

But this is in blender

void viper
#

Is there a simple shader that only renders a material within given screen params?

#

I basically want it so that an asset only ever renders in a certain "box"

fluid peak
#

Have a screenspace mask lerping between โ€œscene colorโ€ and the output of a โ€œtransparentโ€ texture with alpha set all the way up?

void viper
#

Yeah I have image like this basically

#

I mean I guess a plain black one texture would make more sense

#

There would be a fully transparent window to see through as defined by the user

#

it's just the implementation that's tripping me up

errant atlas
#

Ah wait I think I get it, I'd use one layer for the base leaves shader, for example, and then another layer for the snow or rain or whatever other shader should be layered on top?

eager folio
#

Yes.

errant atlas
#

I looked into renderer features a little more and I think that should accomplish it like you said, I don't see a ton of resources unfortunately but I'll keep looking around. Thanks for the tips!

sacred hull
#

I have a problem with displacement where two of the planes collide. I think what I want to do is add the current position of the plane to the noise offset. But I just can't find a node for it. Any help will be greatly appreciated

#

The combine node is going into the PBR master's Vertex Position

#

Im not even sure if that's the "correct" way to do it. If you have any info please @ me thanks :D

regal stag
sacred hull
#

Thanks a lot. I think I can just multiply it beforehand. Anyway I'll try it out tomorrow

slim apex
#

I just made a standard shader, how do i open it?

#

when I click on it it just goes to a script

#
Shader "Custom/Cube_Shader"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows

        // Use shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;

        // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
        // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
        // #pragma instancing_options assumeuniformscaling
        UNITY_INSTANCING_BUFFER_START(Props)
            // put more per-instance properties here
        UNITY_INSTANCING_BUFFER_END(Props)

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            // Albedo comes from a texture tinted by color
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            // Metallic and smoothness come from slider variables
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = c.a;
        }
        ENDCG
    }
    FallBack "Diffuse"
}
#

it just takes me to this script

#

in visual studio

#

here is the shader

low lichen
shadow locust
#

Shaders are scripts (programs really) that run on your graphics card @slim apex

slim apex
#

like this

#

from the image above

shadow locust
#

Check out shader graph

#

That's a shader graph screenshot

slim apex
#

ohh i get it now

shadow locust
#

And BTW the stuff on that screenshot gets converted later into stuff like what you posted above

slim apex
#

ty

#

yeah

slim apex
#

I looked in Window > Light but it isnt there

#

and every thing I search up just tells me to click on the shader I made

#

to get the graph for it

shadow locust
#

Are you using URP or HDRP?

slim apex
#

urp

shadow locust
#

It should be in the create Asset menu

#

Pbr graph or unlit graph or lit graph

#

Stuff like that

slim apex
#

oh wait I just found it

slim apex
#

Now how do I assign the shader to the shader graph?

#

oh thanks for the link I will look at it

shadow locust
#

Wdym

#

You make a material

#

And choose your graph as the shader for the material

slim apex
#

Im pretty sure I messed something up at the start with the default stuff

#

because im not getting that option in the menu

#

anyway its fine thanks for the help

fluid peak
#

A โ€œmaterialโ€ is just an interface to a shader. A shader is inherently script code that runs on EVERY pixel individually as its drawn by the graphics card. Shadergraph is a graphical UI that lets you assemble/wire together pseudo code thats easy for a human to understand, but does compile back into script code for the machine. standard materials just reference prebuilt unity supplied shaders. So to get it to work, you need to make your shader (in code, or shadergraph) then make a new blank material, and assign the shader to it. Now you can assign that material to objects.

#

But remember it runs for EVERY pixel, so whatever code you end up with runs 3.6 million times per frame on a (2560*1440) 2k resolution image, 60 times a second. Graphics cards have a large capability, but if you do super complicated or expensive things it can cause slowdown.

sly breach
#

how to draw an object that is behind geometry above ?

#

similar to how some outline shaders on the market show obstructed objects

#

but i want to draw the whole object to be always visible

fluid peak
#

@sly breach Seperate render pass as an overlay, or maybe custom render path setup maybe by watch through this, should be what your thinking

https://youtu.be/szsWx9IQVDI

Let's learn how to render characters behind other objects using Scriptable Render Passes!

This video is sponsored by Unity

โ— Download Project: https://ole.unity.com/occlusiondemo
โ— More on Lightweight: https://ole.unity.com/lightweight

ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท

โ™ฅ Subscribe: http://b...

โ–ถ Play video
sly breach
#

sounds expensive

#

when aiming at mobile vr

fluid peak
#

Not entirely, i mean there is a renderpass anyway, all your doing is customizing it, so its what you want rather than the stock one

sly breach
#

just added it and it was what i needed

sly breach
fluid peak
#

That is beyond my knowledge especially when targeting lower capability systems like mobile, but there should be tutorials and whatnot abailable

shell wadi
#

Anyone know the best way to get a variable to persist in a certain state on the GPU between passes, without ever being touched by the CPU?

#

(but also be modifiable by the GPU - ie. a float)

fluid peak
#

The short answer is probably no, the longer answer involves compute shaders to get data back from the gpu or render textures to save data between frames but the cpu must be involved then. As far as I know

astral turret
#

Question. Is it viable to do color combination (Blend One One) but only with others sharing the same shader?

shrewd crag
shrewd crag
shrewd crag
#

vfx graph essentially stores state on the gpu

#

you can use it to make textures

#

doesn't have to be particles

astral turret
# shrewd crag ?

new to shaders - not sure if I can have the shader 'blend' with only certain objects

#

(and to act normally otherwise)

sly breach
sly breach
shrewd crag
#

i'm answering other user's quetsions

#

ah

sly breach
#

ye

shell wadi
#

Objective is to maintain a variable across multiple frames and forgo having to deal with it on the CPU for a 100% GPU-based algorithm

sly breach
#

r u looking to make a simulation ?

shell wadi
#

it's actually a post process shader for URP, the algorithm is GPU-based autofocus

#

so unfortunately rules compute out in an ideal world

sly breach
#

u can always store a 2x2 texture and have 2x2x4 float values for example

#

or create one in runtime

shrewd crag
#

good luck out there

#

sounds hard

shell wadi
# sly breach or create one in runtime

Yeah, that was going to be my fallback, just seems like out of all the things that 'should' be possible, accessing some static memory on the GPU and changing a float on it might be haha. Thanks though

grand jolt
#

How to assign or add opacity maps to URP material ?

low lichen
echo solstice
#

Hello

#

Can someone give me shader for a fog?

#

Animated one for fog

shadow kraken
#

I'm using Amplify and I'm using a static switch to toggle between two modes. Does anyone know of a way I can hide the parameters that are redundant for one mode?

wintry pike
#

Does anyone know how I can draw a texture at a specific location on the mesh uv at a given size?

It's for painting, I got the painting done, want to implement a brush texture but can't figure it out, right now it's just spherical.

#

Here's what it's like right now

#

Here's what happens when I try to implement it...

#

I want the brush to paint the shape of the texture, not the colours, here's the method I use to get the mask:

#

This paints on the UV for obvious reasons, so any help on how I could paint the brush texture would be great.

#

(The painting part is not the problem, I already have that done and working, just looking for brush shape instead of a sphere)

amber saffron
#

Instead of doing a spheremask, you probably just need to sample from a texture, and use one of the color channels as a mask.
In order to do this, you need to calculate proper UVs for the brush shape.

wintry pike
#

I'd have to redo the frag shader for that. Right now it basically just does this

#

I'm not 100% fluent with shader code so any pointers on drawing said texture shape at the UV position on the mesh and fill it with the colour?

#

Tried looking it up but there's no resources I can find on this

#

The shader projects the _MainTex into screenspace for the render texture to blit

#

Essential for painting

#

So I'm not sure how to 'draw' the brush at _Mouse and fill it with _BrushColor

marsh merlin
#

I made a shader using the Unity Vertex Displacement tutorial. Instead of putting it on a sphere, I used a plane. Now, it only ripples on one axis. I want it to distort on both.

#

Here is the preview. I want it to distort the z-axis edge.

amber saffron
wintry pike
#

That's simple enough, the problem is just drawing the shape at _Mouse, my limited knowledge is holding me back on excluding every pixel but the ones within _BrushSize at _Mouse in the shape of _Brush

#

Like a sphere mask is simple enough, just normalize the alpha from the distance of the pixel to the mouse, but applying that to a shape I'm unsure how to go about it

#

I know ^ won't work since it's still obviously setting b equal to a sperical radius, but that is where I'm lost

#

So here's the brush, for testing obviously

#

With that the result is this, as expected

#

I know I would use _BrushColour as b to get rig of the brush colour

#

So how does one go from that, to painting the shape of tex, I'd assume I will probably have to use some values from white/black for the mask, no problems there

#

I have an idea, what if I clamp the texture so it's all black, then using the brush uvs to paint it on, make all the black pixels the base texture and anything in the mask _BrushColour?

#

Okay now I'm having issues aligning it to the _Mouse, why am I so bad at shaders

amber saffron
#

What's _Mouse here ?

wintry pike
#

A position on the mesh basically

#

For instance, using a Raycast's hit.point

#

Works well

amber saffron
#

And it does properly take in consideration the Uvs ? If not, adding mouse.xy to the uvs might not offset properly. It might explain what is happening here.

wintry pike
#

Guess it doesn't no, I want to avoid using Raycast texcoord for anything since it's MeshCollider specific

#

However, the vertex function has a worldPos variable, that's how it's able to line those up

#

Which was used for that

amber saffron
#

Yes, for the sphere mask, because it is also using world position, but not for the brush

wintry pike
#

I'm not sure how to proceed, what do you suggest I try?

amber saffron
#

Hum, idk if there is a built-in world to tangent space matrix, that would help here ๐Ÿค”

wintry pike
#

If it helps

#

The actually shader projects the data into screen space

#

It doesn't render it ofc, it's just for the command buffer

#

Not sure if that helps at all either

#

There's obviously an offset here

merry rose
#

Started on Pine Trees 2 down 3 to go! plus 360 fps with all of them being LOD0s, I will make LODs when I get all of them looking right

wintry pike
#

Uh

amber saffron
# wintry pike

I'm getting lost about what is the current state of the shader, what the screenshot is showing, and what exactly you want to do ๐Ÿ˜…
Is the brush texture projected with the UVs ? Is it supposed to be in screen space ? Anything else ?

wintry pike
#

My bad, let me explain better:

The shader is used to 'paint' on a mesh, it draws the desired brush at _Mouse (world position) and that is then used by a RenderTexture in the command buffer to blit, this creates a paint affect on the texture where the brush was drawn, this allows painting to occur in UV space.

Currently it only draws a sphere mask as you've seen, I want to draw a mask using the shape of a texture (_Brush) at _Mouse.

merry rose
wintry pike
#

Oh you were talking to him

merry rose
#

no i think he was talking to you but I just replied soon

wintry pike
#

Oh in that case, here's an example of it currently as it is

#

Particles paint at their collision point

amber saffron
#

Ok, it start to make more sense to me now

wintry pike
#

Yeah so shader draws at _Mouse, CommandBuffer blits to create paint affect

#

Rinse and repeate

amber saffron
#

So maybe the final goal is to have the brush texture alligned with the normal ?

wintry pike
#

I'm not sure about the path to the final goal but the final goal would basically use the _Brush texture as the mask

amber saffron
#

Yes, but, is it projected from screen space, or aligned with the surface of the mesh, or anything else that is relevant ?

wintry pike
#

It paints on the UVs of the mesh, so it unwraps the mesh into screen space which is sent to a RenderTexture, that is then painted it and wrapped around the mesh

#

So the verts are projected from world to screen

#

Which is executed in a CommandBuffer

#

I can grab you an article on the process if I'm still making no sense

amber saffron
#

My suggestion :

  • In addition (or instead of) to the mouse "position", pass more informations to the shader. Best would be a transformation matrix that transforms object (or world) to "brush" space. For a world to brush matrix, it could be constructed with m = Matrix4x4.TRS( hit.position, Quaternion.LookRotation( hit.normal), 1.0/brushWorldSize)
  • In the vertex stage, calculate the "brush UVs" using the matrix p = mul( brushMatrix, worldPos).xy - float2(0.5, 0.5);
  • In the fragment stage, sample the brush texture for the mask
#

That's just on top of my head and probably needs testing and tweaks.

merry rose
#

now for something shader vise... is there a way to sample Texture Array and use its output in parallax mapping? or it will always get you Vector4?

amber saffron
#

It will always get you a vector4. What were you expecting ?

merry rose
#

Tex as it in parallax node I need Tex input, went over 40 docs yeasterday if I can use Vector1 to drive Parallax but it seems that it needs Texture to sample from...

#

Could I possibly parallax Texture Array and then sample from there? xD I m just putting ideas out...

amber saffron
#

Yes, because the paralax node will sample multiple time the texture, so it needs a texture object not just a constant value.

#

Do you mean you have a texture array of heightmaps ?

merry rose
#

Yes, I actually have texture array of MaskMaps but in docs I saw you still sample from one channel

amber saffron
#

The parallax nodes output uv to sample later the textures you want. As input, it only needs a one channel texture for the height sampling.

#

If you're brave enough, you could replicate the parallax mapping node code into a custom function node, an replace the texture sample inside with a texture array sample.

merry rose
#

Oh wow, I have to try that ๐Ÿ˜ฎ

amber saffron
#
merry rose
#

Thank you so much ๐Ÿ™‚ let the coding begin

#

But for some reason I cannot use HLSL files in shader graph? it wants Text Asset but event empty txt gives me error that it needs to end with .hlsl...

#

I am on URP 12.0 and 2021.2.0a8 if that might be issue here...

solar sinew
#

you must create a txt file in your IDE and change the file ending to .hlsl

merry rose
#

ouu good to know, gonna try that now

solar sinew
#

otherwise it isn't an hlsl file

#

it would be a txt file

merry rose
#

well I made it in Visual Studio and it still wont accept it grrrrr

#

I dont wanna again type custom code inside shader graph.... Its painfull process...

#

selector still only finds C# and Txts in project...

#

Could we maybe get IDE for Custom Function in Unity Inspector when selected? ๐Ÿ™‚

solar sinew
#

Not needed

#

It does work

#

Not an issue with URP either

#

you just need to troubleshoot more

#

also did you try dragging the hlsl file into the field

merry rose
#

it wont even find packages hlsls..

solar sinew
#

yes because it's looking in assets, not in packages

merry rose
#

Yes thats first what I did, I get window circle lined

solar sinew
#

check your hlsl file's path

#

if you continue to have issues then I would do the usual troubleshooting of saving the graph/closing and reopening it/restarting Unity etc

amber saffron
#

There was a discussion this morning about unability to drag .hlsl files in the custom node inspector iirc

#

With 2020.3

merry rose
#

ouu, thats gonna make this quite a bit slower, but nevermind gonna type it out in code function...

solar sinew
#

huh really? I haven't run into it yet in 2020.3

fluid peak
#

Persobally i am going to try and edit the parrallax node code to be able to take in something other than a texture heightmap, it would just split out the texture sampler to outside the node if you wanted the same functionality it has now, but if you wanted to pump in some other 2d information or procedural stuff it would still work

#

Yay, into the deep end

amber saffron
merry rose
#

That would be nice but idk how would I create heightmap from splatmapped heightmap... tho rendering just heightmap in one Render Pass and then rendering terrain with that texture as heightmap might work...

amber saffron
fluid peak
#

It more came from the desire to be able to manipulate the information it was processing. The input being locked to a (t2) is very limiting in shadergraph.

amber saffron
#

Well, like I said, you can easilly recreate the parallax offset mapping with only node, and input any value you'd want.
But for parallax occlusion, the only way is to pass a texture object

merry rose
#

same, but I haven't found anything yet that good, only parallax offset seems to work with just with its information, that what I am currently using.

#

gonna try sampling arrays and post if it works or no

fluid peak
#

You can recreate the occlusion mapping function in nodes as well it would just be clunky to do, its just a series of normal parrallax nodes with clipping masks layered over each other stepping down the heightmap gradient. Ill fiddle with it this weekend, im working on IK procedural walking for a 4 legged robot thing right now

merry rose
#

cool

amber saffron
merry rose
#

uff ๐Ÿ˜„

fluid peak
#

Yeah, clunky

merry rose
#

how do I define Input for Array? I cant even find it from generated code, only how to sample it SAMPLE_TEXTURE2D_ARRAY...

#

I am asking for this one if I wasnt so clear ๐Ÿ˜„

amber saffron
#

It should be an object of type Texture2DArray

fluid peak
#

how do you setup the micro steps with the built in parrallax oclusion node, visually ive only seen the primary sample steps?

amber saffron
#

I'm not 100% that the built-in one does it, but HDRP/Lit shader parallax occlusion does iirc

#

Haven't looked at the POM code for a while.

merry rose
#

Well this works ๐Ÿ˜„ good to know ๐Ÿ˜„

#

so If you wanna file in newest builds just include it and call your action there ๐Ÿ˜„

fathom vault
#

Hey guys I'm trying to make a general depth view as a replacement shader in HDRP but anything I do doesn't seems to work

#

could somebody know where is my problem if I show you my shader?

fluid peak
#

probably but without seeing the shader shrug

fathom vault
#

here is the shader (didn't want to spam images for nothing):

#

my goal is to bake the depth of an orthographic camera in a rendertexture

#

and to do that I do a SetReplacementShader in my script, but it seems that it doesn't do anything when I see the result (the red plane is my renderTexture that should have a depth look rather than this):

#

and here is the place where I set my Replacement Shader:

merry rose
#

if you need terrain heightmap texture you can just use TerrainAPI

fathom vault
#

I would like it to work with mesh terrains too, but if it still make me pull out my hairs I'll just take simple terrains

merry rose
#

ou okay, gotch ya

#

I would love if terrains were simple ๐Ÿ˜„

#

Like every axis seems to be inverted some way or another and I have no idea if I did something right or no :/ ๐Ÿ˜„

#

but if you need heightmap its one line of code ๐Ÿ˜„

wintry pike
#

Remy, we have progress

#

In theory I can now use a shader to process brushes

lapis hearth
#

Is the only way to recreate shaders in urp to do it in shader graph? Or is it possible to create shader code in urp?

#

I have found a basic unlit shader in the urp manual but there isn't anything about lit?

regal stag
merry rose
#

@amber saffron First step done, now lets see about that POM ๐Ÿ˜„

lapis hearth
#

are there things that only can be created in shader code and not in the shader graph?

merry rose
#

Terrain instancing for example

#

my terrain takes like 50 batches in some views because its made in Shader Graph

merry rose
#

@amber saffron I had no clue how to use Unity POM, but I tried Relief Shading I learned from 2016 and it looks awesome and uses Texture Arrays, now just gotta invert it ๐Ÿ˜„

hearty wasp
#

hey guys, I'm basically just trying to combine these foreground textures on top of the background blue gradient but nothing gives me a result where the foreground is preserved

#

any idea how I can combine them without discolouring the foreground?

#

I guess I could make a system to mask it but if you guy have any other ideas I'd be happy to hear

stone ibex
#

you could just draw the background first?

#

and render the foreground onto it

#

or make the background like a plane that's behind the foreground so unity sorts it out with the depth buffer

hearty wasp
#

I think what you mean is something I am doing already, I'm just trying to keep it to 1 shader & 1 material

stone ibex
#

any reason to keep it 1 shader? that just makes it more difficult i think

regal stag
hearty wasp
sacred hull
#

So I wanted to add foam to my water shader. But I don't know how I would go about this. I imagine doing something based on the distance to an edge. Any help is appreciated

hearty wasp
#

thanks ๐Ÿ‘

regal stag
regal stag
hearty wasp
#

good tip! I'm not seeing any edges with these initial prototype sprites but I'll keep it in mind, thank you

somber bolt
#

Converting some HSL ShaderToy shaders to GLSL and getting the following error
undeclared identifier 'iChannel0'

Can anyone give an example of how you would implement a texture in a Shaderlab shader?

Right now in my Properties I have
Properties { _MainTex ("Texture", 2D) = "white" {} }

regal stag
amber saffron
#

Look at render features in URP, or custom passes in HDRP

merry rose
#

Is constructing Matrix4x4 inside shader graph and later splitting it waste of performance? should I rather pass 4 Vector4s inside another sub graphs?

fathom vault
amber saffron
merry rose
#

Alright, thanks

#

Will there be in the future Set Reference and Get Reference Node? sometimes Graphs get little bit spaggeti ๐Ÿ˜„

somber bolt
stone ibex
#

i don't understand why it's any different than with play mode on

#

(the monobehaviour has [ExecuteInEditMode])

#

it only runs when I do something (move the camera, etc) in edit mode.. but seems to get slower and slower the longer I do so

#

that's play mode

#

and edit mode moving the camera:

somber bolt
#

Trying to convert these WebGL noise shaders for use in ShaderLab using a Standard Unlit Shader as a starting point but have been unsuccessful so far. Any chance someone could point me to a tutorial to get me started? I have no problem converting GLSL to HSL but WebGL seems different.
https://github.com/ashima/webgl-noise/tree/master/src

stone ibex
#

webgl uses the same GLSL that opengl does

#

what are you having trouble with? the main thing you'd need to change is all the vecX to floatX

somber bolt
vast timber
#

Hey, is it possible to offset a position so when it is multiplied by the view matrix it keeps that position as origin?

#

Currently trying to make a billboard shader that uses the quads of a mesh as different billboards

verbal mauve
#

Hey good people. I'm trying to make a basic water shader, panning normal map on a transparent alpha premultiplied plane.
Something is bothering me.
My normals maps are reflecting the bottom of the cubemap even with a low normal map scale and it makes those visible splotches. Normal map is fine i think. I'm not sure if this an expected behavior ?

shadow locust
merry rose
#

@amber saffron Okay I got it, layered and everything but you cannot control the layers as precise as without or with Parallax Offset, its just always one layer is floating above the other... I think it has something to do with splatmap not being sampled aswell so its not occluded, but I got no clue how to that while its even on different UV set, so I dont this this setup is much viable xD

astral turret
#

eyeballing shader graphs for the URP. I'm trying to apply a Lighten Blend between two objects using the same shader... I can define the color properties for my shader graph, but is there any way to grab the base I'm applying to?

fluid peak
#

@merry rose how did you setup that relief shading setup you did

astral turret
#

Objective - making a 2d shapes based game, trying to have the light cones and light lasers combine colors (r+g, g+b) where they intersect. but to not have them combine with non-light effects, just normal alpha overlay.

rain niche
#

what could be preventing Shader.SetGlobalFloat from not setting a uniform on mobile builds?

#

works just fine in editor

#

the code is executed but shader uniforms don't change on device. we're using shadervariants so i'm wondering if its related to that

eager folio
#

@astral turret draw the light effects to a separate camera?

lapis hearth
#

I don't know a thing about shaders but I am trying to learn shader code. Would it be a good idea to start with the urp shader code? Because I was looking at the lit shader code in urp https://cyangamedev.wordpress.com/2020/06/05/urp-shader-code/ and I was quite overwhelmed. Right now I have a urp project and I really want to learn shader code but it seems so hard

Intro A lot of shader code tutorials youโ€™ll see online are written for Unityโ€™s built-in pipeline and wonโ€™t really work in the Universal Render Pipeline โ€“ Theyโ€™ll either produce magenta โ€ฆ

thick fulcrum
# lapis hearth I don't know a thing about shaders but I am trying to learn shader code. Would i...

Depends what your end goal is, it maybe worthwhile following some of the more basic examples. Cyan has some great resources and using shader-graph can be more beginner friendly than writing code.
Unless you need custom lighting e.g. for making toon style perhaps. Then it's better to stay away from that until you are more confidant with the basics.
That said, if you are a confidant and experienced coder... code could be more logical than graph. it all depends ๐Ÿ˜‰
Good luck though, it's a steep but rewarding learning curve

lapis hearth
#

@thick fulcrum thanks it was just so overwhelming going into the urp lit basic shader and seeing around 400 lines

eager folio
#

Well, even the very simplest of shaders will be twenty lines or so

lapis hearth
#

yeah but if the simplest urp shader you find is 400 lines.

merry rose
# fluid peak <@261946364340994048> how did you setup that relief shading setup you did

I used this one just used arrays for sampling https://www.youtube.com/watch?v=zmq-26XsOSg

Heres how the Relief shader I showcased earlier looks like.
It has its quirks, some oddeties; like the fact that you have to manually reverse/invert the heightmap in an image editing software, otherwise height values will go in the reverse order.

The original Relief Shader made by Eideren:
https://forum.unity3d.com/threads/shader-forge-a-visual...

โ–ถ Play video
#

Its kinda hard doing everything in there shader graph window, and #include things its line by line aswell, I hope they fix hlsl soon ๐Ÿ˜„

heavy belfry
#

How would you guys go about implementing the EPX algorithm in Unity ?

#

Compute shader ? Shader graph ?

vast geode
somber bolt
#

Need some help with a Shader Conversion.
Have converted this shader https://www.shadertoy.com/view/XllGzN
following Martijn Steinrucken's excellent tutorial https://youtu.be/CzORVWFvZ28

No compile errors, however my shader is completely black!
What are some other possible causes of a totally black shader after conversion from GLSL?
My complete ShaderLab code is here.
https://pastebin.com/KgxVhdKc

Twitter: @The_ArtOfCode
Facebook: https://www.facebook.com/groups/theartofcode/
Patreon: https://www.patreon.com/TheArtOfCode
PayPal Donation: https://paypal.me/theartofcode

Ever wondered how to get a shader from ShaderToy imported into Unity? Well wonder no longer because in this video I will explain how to do it. Its really not that hard.

Ru...

โ–ถ Play video
vast geode
heavy belfry
#

I've never used compute shaders but from what I've read it sounds like a perfect fit

grand jolt
#

hi guys, is there some good resources about stylized shadows (with shader graph)? I'm trying to understand how to do that with a toon shader ^^ replacing the shadows by pencil lines

zinc pike
#

Hey y'all, Im pretty new to working with shaders in unity2D, and was wondering if someone could offer me some guidance on a problem I'm having. I want to, procedurally, fill a shape with a gradient, however, instead of it being a simple y-coord gradient that just gets masked by the shape its filling, it matches the shape. If you want to help, and need some more details I'd be happy to discuss in PM, let me know : )

marsh merlin
#

My PBR Graph material is opaque in the game view and builds but transparent in the scene view. How can I make the game view one see-through? I have transparent mode selected in the PBR Master Node.

(Note: For a brief moment, the Game View one is transparent then immediately turns opaque).

regal stag
wintry pike
#

Anyone know how to achieve per-texel lighting in shaders?

fluid peak
#

use a standard lit shader... lighting and everything is calculated per pixel anyway, if you include a normal map then it uses that normal information which is per texel at that point to calculate lighting? or i misunderstood the question

wintry pike
#

Interesting, so applying the normal would make the shadows per-texel?

#

Doesn't seem like it would

#

I guess my question is probably a little too vague, I'm aiming for per-texel shadows

fluid peak
#

well, lighting is per texel, getting self shadowing from a texture is a different beast, possible but a lot more work

wintry pike
#

Yeah I've heard, there's barely any resources on it so I'm unsure how to even start

fluid peak
merry rose
#

@amber saffron So I ended up calculating terrain view direction like this, because I had to reset Normals and Tangents of the terrain and (position - camPos) gives bad info even without resetting normals/tangets so I had to manually displace them with PerPixelNormal in frag. I have no Idea how Unity does PerPixelNormals so mine are small fraction off the original ones but its not noticable so thats fine.

#

also found out that terrain tangent is always X=1 so I dont even need to reset it just the objects blending with it ๐Ÿ˜„

woeful geyser
#

How do I specify amount of times that compute shader should run?
I can set numthreads but what if I want to process more than 1024 elements in a buffer?

[numthreads(1024, 1, 1)]
void Main(uint3 id : SV_DispatchThreadID) {
stone ibex
#

on the C# end, you do DispatchCompute(shader, 0, numberOfElementsInBuffer/1024+1, 1, 1)

#

(the +1 is just if it's not multiples of 1024)

pale nest
#

Can someone point me to a tutorial or ss that I can get a smooth gaussian blur on my background sprites? I've tried using tiling and offset following some tutorials but the result seems very rough like a motion blur

bitter elm
# pale nest Can someone point me to a tutorial or ss that I can get a smooth gaussian blur o...

Blur effects are not very complicated, we only wrote them in java (not for a shader^^), but you should easily be able to build one from scratch. in HLSL you can always get the neighbouring pixel values (I forgot the function's name, but there is one) and thus you can just modify them to reduce the differences in value. On the other hand you can create a larger mask and do this across all pixel within. Not sure how to get those pixel, but an effect shader should allow for that somehow.

#

For some reason the shadow attenuation just doesn't return any meaningful values, I think. Or it just doesn't play nice with directional lights, idk.

#

Generally I am struggling with any attemt to write custom functions for shader graph, could someone point me towards a good tutorial, preferably anything light-related?

pale nest
#

I don't have much experience with shaders unfortunately...is there a tutorial to achieve that?

bitter elm
regal stag
somber bolt
#

Anyone able to tell me, what is the equivalent of the GLSL 'textureLod' method in HLSL? Did some googling but nothing apparent.

bitter elm
regal stag
bitter elm
#

Also: I am looking at the MainLightShadows-subgraph rn and it notes that I need at least two shadow cascades.

#

What's meant there? I can include the property as many times as I please, but I don't see what it actually does.

regal stag
bitter elm
#

I am very much not familiar with them-.-''

#

Looking into it rn

bitter elm
#

By the way the subgraph in itself seems to work, the notification pops up from the fllowup nodes (a regular multipy node)

regal stag
hollow trellis
#

Are there any good tutorials on using the Stencil Buffer to test if a surface is between a front and back face of a mesh?

bitter elm
#

Well, your example shader works pretty much jsut like intended, but I do feel a bit bad for using that one over my own work-.-''

hollow trellis
bitter elm
#

oh wait, so they did in fact interfere, replacing all the references worked. Now something in the calculation is off, but that I can fix.

bitter elm
#

Am I a hack? Maybe XD

inland cobalt
#

define sprite using this

regal stag
bitter elm
#

Those I can just add, right?

#

Yeah, that looks much better actually^^''

#

Guess I'll add a folder for all the dirty implementations I've ever done^^
This one definitely warrants it

knotty jacinth
#

Does anyone know if there is a shadergraph translation of what the base Lit shader is doing in URP? I'm getting a different result with a transparent shader i'm working

stone ibex
#

are you using a Lit master node?

thick fulcrum
tranquil bronze
#

why can i see the scene skybox in the render texture

#

im trying to make a ray marcher with compute shaders

grand jolt
#

UnityGltf_Pbr_BoomBoxScene_Glb-Unity2019Run see Material Shaders

thick fulcrum
# tranquil bronze

on the camera used to capture the render texture you can change the background type under Environment to either "skybox", "Solid Color" or "uninitialized" one of the later two should suit your situation.

tranquil bronze
#

@thick fulcrum its not just the background but scene objects also show up in that middle area

#

for some reason this only happens when i add the plane to my ray marcher

thick fulcrum
#

just so I understand, your writing the output from the compute shader to a render texture which is at some point along the journey now getting scene elements?

tranquil bronze
#

yeah its just rendering the scene

#

in that middle area

thick fulcrum
#

does the render texture populate correctly?

tranquil bronze
#

yeah withou thte plane

thick fulcrum
#

I'm presuming it's not as simple as looking at wrong side of plane, unity default is single sided? ๐Ÿ˜›

tranquil bronze
thick fulcrum
#

well if the render texture is populated, it must be something to do with the plane / shader / material used to apply the render texture.

knotty jacinth
strange lynx
#

Hi everyone, I am looking to make a shader that renders only that which is lit by a 2d point light (everything else would be transparent), is this possible using unity's shader graph?

#

I managed to do something similar, to set the alpha to 0 if the distance to a point is greater than a max distance, but its not exactly the same thing

scenic bough
#

I was about to ask for help then realized I finally know how to phrase my question and found a tutorial that will be an awesome start for me, so woot ๐Ÿ˜‚

#

Eventually hoping to be able to make this as a shader

#

The slow glow is very much dramaticized, as many things are in the anime, but the main idea is that itโ€™s a geometry shader where each triangle is separated, glows randomly between green/blue with a fair amount of bloom, then suddenly separates out in the direction of its normal with a tad bit of randomness and is applied vertical speed while dissolving

And the fact that I can explain that means Iโ€™m much further into understanding it than I thought ๐Ÿ˜‚

errant turtle
#

Hey, I'm very new to shaders and I'm having an issue rn with alpha blending (I think).
I want to make a shader, that takes a planes position and cuts the model into two parts. One is displayed as usual, the other should be transparent. Now I have both parts working nearly as I want them to, but the transparent parts seem to not render anything behind them, as seen in the picture: the transparent part of the purple sphere doesnt render the parts of the brown cube behind it.

What can I do to prevent this / what is responsible for that so that I can google more about it, atm I'm really lost and don't know what to google.

Here is my code: https://gist.github.com/staddle/95d0c455575f2b417b1cb6c644de04f8
It consists of two parts, both nearly identical, just that one renders the model as normal, the other with flipped normals on each vertex, this way I got to be able to look "into" the model and render the inner vertices.

Gist

Unity Shader. GitHub Gist: instantly share code, notes, and snippets.

scarlet pulsar
#

How can i set ZTest Always in shader graph?

regal stag
# errant turtle Hey, I'm very new to shaders and I'm having an issue rn with alpha blending (I t...

I'm not super familiar with surface shaders, but I imagine the problem here is with ZWrite (referring to writing to the z/depth buffer). Opaque shaders usually write to the buffer and test against it (see ZTest too) so that objects behind don't need to be rendered (since they'd be covered up anyway so there's no point in wasting time with the calculations).

For semi-transparent shaders, you would want ZWrite to be Off so that objects behind are still rendered and blending is correct, however it may also lead to sorting issues. You should be able to disable it via specifying ZWrite Off along with your Cull/Blend in the SubShader (or Pass). Or, you might want to look into the other "alpha" parameters for the surface shader rather than keepalpha. https://docs.unity3d.com/Manual/SL-SurfaceShaders.html
https://docs.unity3d.com/Manual/SL-CullAndDepth.html

errant turtle
#

Thanks, I'll take a look at that

regal stag
#

Alternatively generate the shader code from the graph and edit it

scarlet pulsar
#

only way its upgrade to 10 version?

regal stag
final hollow
#

anybody know if theres a programmatic way to get a script reference to a shader besides dragging it into the slot in the editor?

final hollow
#

interesting, do you suppose a corresponding method exists for a compute shader?

regal stag
final hollow
#

hmm, also, looks like that might fail me if nothing has a reference to it

#

oh thats interesting @regal stag , that could be a solution to a lot of similar classes of problem if that works

desert orbit
#

I think this happens due to black having extreme values after multiplication. Had something similar, fixed by remapping to strict 0-1 range.

fluid peak
#

Since true โ€œ0โ€ causes math errors sometimes. The easiest solution is to run it through a clamp set to 0.001 min and max of whatever you need (usually 1, but whatever)

solid chasm
#

how do i get started with shaders any suggetions?

noble bobcat
#

Guys i was trying to create a shader that allows the player to see a area arround them. To do this i basically did a sphere and created a fresnel effect that would only show a light border arround the edges. The issue is that even though i can see any outline in other players i cannot see mine. I assume that this happens because the shader is only applied to the other side of the sphere meaning that mine wont show up unless i make the shader affect both sides. The problem is that if i make it affect both sides it just turns solid. e.e Anyone knows any solution??

ebon lotus
#

Try reversing the normals in the sphere model

#

You can do that with probuilder if thats just the default sphere

noble bobcat
#

@ebon lotus but i want both sides :/

regal stag
# noble bobcat Guys i was trying to create a shader that allows the player to see a area arroun...

If you want the Two Sided to work with the Fresnel Effect, you need to flip the normals for the backfaces as they are facing the wrong direction for the calculation. You can do so with the Is Front Face node into a Branch with the Normal Vector in true, and the same into Negate for false.

You will likely find that the Fresnel won't really be visible however, as the faces of the sphere in front of the camera are facing the camera (or will be when flipped). When the normal is similar to the view direction that's what gives you values close to 0, (so if used as alpha will just be mostly transparent).

noble bobcat
#

thanks @regal stag , ill look into it ^^

somber bolt
#

Hi guys. Trying to feed a texture2D into a .hlsl pixel shader. In my pixel shader I have a tex2D method which expects a sampler2D, NOT texture2D, as the first argument.

How do I convert a texture2D into a sampler2D?

regal stag
somber bolt
#

@regal stag , thank you! I need to learn about sampler states.
Tried the easier solution, feeding a sampler2d into my Custom Function,

but now get a " cannot implicitly convert from 'float3' to 'sampler2D' at line..."
error.
My texture is defined as a Vector4 in my Custom Function Inputs.
My method signature in my .hlsl is
void Main_float(sampler2D SampleTexture, ....)

Still doing something wrong...

regal stag
# somber bolt

That's not a texture, it's a Vector4/float4, the colour sampled from the texture based on the UV coordinate passed in. It's already been sampled by the node

#

I also didn't realise you were using Shader Graph, probably should have asked, I would have suggested using the SRP macros instead like SAMPLE_TEXTURE2D(texture, sampler, uv);. But if you're already sampling it with a node that isn't needed.

#

With those inputs, the custom function should be something like void Main_float(float3 AbsoluteWorldPosition, float3 WorldNormal, float4 SampleTexture, out float4 Output)

somber bolt
#

Thanks again. I will keep plugging away. Goal is simply to make the texture available to my pixel shader in my Custom Function.

lapis hearth
#

I can't connect this to the normal vector?

regal stag
# lapis hearth I can't connect this to the normal vector?

The Normal From Texture node can only be used in the fragment shader stage, there should be a separate port for it if using the PBR/Lit graph.
Also, it's not for sampling normal map textures, instead it's intended for sampling heightmaps to convert them to normals. If you want to sample a normal map, use the Sample Texture 2D node set to Normal mode.

lapis hearth
#

@regal stag so should I connect the normal in the fragment shader?

lapis hearth
regal stag
lapis hearth
#

@regal stag thanks I was dumb I had accidentally created a unlit shader instead of a lit. Thanks for the help tho

abstract stirrup
#

Hello, is there a way to get mesh's shadow texture?

stone ibex
#

is there some way to pass data other than position/normal/tangent from VS to PS with shadergraph?

#

(i need uv/color at least)

sly breach
#

is there a way to expose the keyword in inspector or do we need to make custom editors for this ?

#

( i want to control whether or not DITHER will be included in this material or not ) - @regal stag

ebon lotus
#

It should be bisible if you did that

amber saffron
regal stag
regal stag
stone ibex
#

yeah, i'm using DrawProceduralIndirect so I don't have a mesh ๐Ÿ˜ฆ

sly breach
#

trying to convert this to shader graph

v2f vert(appdata v)
{
  v2f o;
  o.vertex = UnityObjectToClipPos(v.vertex);
  o.uv = v.uv;
  return o;
}
#

it says in the docs that the clip function is equivalent to mul(UNITY_MATRIX_MVP, float4(pos, 1.0))

#

which is = Current model * view * projection matrix

#

but i can't seem to find those nodes, the closest i got to is this :

#

not sure what to make of this

#

the shader that is written in HLSL is a simple fade animation [ feature ] for the forward renderer

#

( the hlsl works well for vr as well )

regal stag
sly breach
#

do all of the shaders share this part ?

#

( default shaders that are made in shader graph )

regal stag
#

All shaders that are for rendering meshes should be using UnityObjectToClipPos or the equivalent. It's important for converting the mesh vertex positions into positions on the screen

sly breach
#

does it mean that a feature in the forward renderer is also using a mesh not a filter of the final output image per eye ?

regal stag
#

If you're referring to a feature using a Blit, then yes, it renders a quad to the screen with the input texture

sly breach
#

i see ,thanks cyan

#

also all it took to convert the to shader graph was

#

...

somber bolt
#

@regal stag Thanks again. Finally have something working. The differences between DX9 and DX11 syntax were the cause of my problem. My assumption now is that if I am feeding a texture to a Custom Function node the tex2D method should NOT be used for sampling because Shadergraph assumes DX11 style HLSL.

bright flicker
#

hey guys, I'm new in the shader world, does anyone have an idea on how to make a aquarelle effect in shader graph?

noble bobcat
regal stag
# somber bolt <@!357936113983291393> Thanks again. Finally have something working. The differe...

Correct, you can use Texture2D & SamplerState inputs, and the macro SAMPLE_TEXTURE2D(texture, sampler, uv);. In both Shader Graph, and writing HLSL shader code for URP/HDRP.

Depending on which URP/HDRP/shadergraph version you're in there may be different methods too. In v10.3 newer structs for texture types have been introduced, for example UnityTexture2D, which passes the texture/sampler objects through together. https://github.com/Unity-Technologies/Graphics/blob/master/com.unity.render-pipelines.core/ShaderLibrary/Texture.hlsl

The same SAMPLE_TEXTURE2D macro can still be used. The advantages of using the newer structs is it allows you to obtain the .samplerstate and .texelSize (for texture2d only) connected with the texture, which isn't something you can do prior to v10.3. I believe the newer structs also might provide proper support for GLES2 platforms (as they only support the older sampler2D syntax it seems).

regal stag
regal stag
# bright flicker hey guys, I'm new in the shader world, does anyone have an idea on how to make a...

I've done some watercolour-like experiments for 3D objects in shader graph, I wrote about it here, mostly shadows and a distorted edge detection screen effect. Also decal-like things but I wouldn't really recommend the exact method I used for those. Not sure how useful it'll be.
https://cyangamedev.wordpress.com/2020/10/06/watercolour-shader-experiments/

I'd also suggest this, but the website appears to be down for me at least. Maybe check back later?
https://www.bruteforce-games.com/post/watercolor-shader-devblog-13

bright flicker
#

I'm looking for something like this

leaden radish
#

hey is it possible to add shader to a particular area

#

if my 2D waterfall image is like this

#

won't the ground with it will also have t he shader effect

sly breach
#

@leaden radish u can set a material for an image , and change its tiling or animate the water there

#

im guessing u r using tiles, from the look of it , u don't need to apply the same shader everywhere so the ground won't wobble

#

.


i got a math question.
trying to wrap my head around sin / cos ranges , the input value between 0 and 1/4 will do half a turn , while the rest 3/4 will do the second half - i could try and remap this - but that just seems wrong

leaden radish
#

ok i will try that

#

i was not sure how to do that

sly breach
#

from the looks of it there should be no difference on the first quoter and the rest

#

@leaden radish what do you use ?

#

2d tiles ?

#

if so maybe try sprite sheet animations

leaden radish
#

i am going to do make use of spriteshapes

#

tiling is hectic