#archived-shaders

1 messages · Page 248 of 1

kind juniper
#

Question about macros in hlsl:
Can you use a loop iterator as an argument for a macro?
Something like:

#define f(a) f##a

float f0
float f1
float f2
...

for(int i = 0; i < 4; i++)
{
  float f = f(i);
}

is it possible to somehow unroll the loop before the preprocessor processes the macro or is there a simpler way to do that?

white marsh
#

Remember that macros basically paste in code, its not a function.

meager pelican
kind juniper
#

But I guess, not too more complicated

#

Just thought I could use a little trick to make the code a bit prettier.

meager pelican
#

@kind juniperis correct, macros aren't a function, but that doesn't mean that your solution cannot be a function. Or even a function-like macro.

#

So instead of doing that extra-clever macro that would require unrolling, you could either call a real function or use a macro as:

f = DoWhatever(f1);
...```
meager pelican
# kind juniper Just thought I could use a little trick to make the code a bit prettier.

I guess try it. Use an [unroll] attribute and see if the macro substitution works out.

But...IMO...if I had to maintain your code, and there were only 4 iterations and not 100 of them, I'd be sending out some negative energy...for making me have to think about that macro rather than typing the line 3 more times (or better yet cut and paste + editing).

kind juniper
#

Hahah. True that. Guess I'll avoid the complication and save myself some time(there was indeed 4 elements only).

gilded ridge
#

Is it possible to use two shaders on the same object at the same time?

mental bone
#

Well yes if the object has two materials.

gilded ridge
#

I want it to affect the same material, cause I already made a curved world shader, and I want some kind of distortion on the object too so I wasn't sure if I can do it

cosmic prairie
#

That's not possible

#

You need to write a shader that combines both

gilded ridge
#

Doesn't seem that hard, thanks for the answer!

fast sierra
#

Tried to make some quad to billboard styilzed bushes but there seems to be a transparency sorting issue?
How can i fix it?

fast sierra
young fog
#

Guys what type of shaders should I create that's good for beginners?

south lichen
#

a psx shader

#

I actually made one myself

young fog
#

I'm following this tutorial but I can't make my effect show up in the Game view? I've followed everything this tutorial was doing, unless there's one step there that I missed, can't figure out what it could be though

https://www.youtube.com/watch?v=3Ccu3UtiSdw

Now you can easily add a Retro feeling to your game with this cool Shader Graph and Render Feature combination. With a few Post-Processing effects on top and that's it you got yourself a CRT / Old TV feeling. Enjoy!

Pixel Art Tutorial: https://youtu.be/JZDlCuIpq9I
Cyan Blit Render Feature: https://github.com/Cyanilux/URP_BlitRenderFeature

✦Rab...

▶ Play video
#

shader's complete, but the result is just...

well the effect just doesn't show up

#

cyan isn't online now but if they are here hope you can help!

#

Settings if you're wondering

#

I figured it out, I had to change stuff in the project settings, wasn't anything to do with the shaders, my bad, I didn't know about any of that

#

so I had to change stuff on my camera afterwards

meager pelican
#

Was it to enable the scene color option in the settings? He used the scene color node in the tut, but the option has to be enabled otherwise IIRC it just returns a grey for everything. Or maybe black.

meager pelican
fast sierra
young fog
#

I only figured that out after noticing my renderer was not showing up on the camera after looking for the issue

#

I want to pick your guys' brains for the single most impressive shader/material (wizardry) I've seen, it's not significant in the slightest, mostly as decoration for the theme of the place

merry oak
#

I'ver seen it used in certain tutorials, so I'm sure it's possible, but I never saw the code and I'm wondering if anyone knows how to fire a raycast in a shader.

young fog
#

so in Luigi's Mansion 3, you're in a mostly blank room with sand and a pyramid in the center, but the sand itself is incredibly impressive, you can walk on it, suck up the sand, blow your vacuum on the sand (this guy doesn't show it I don't think), how do you even perform this wizardry?

https://youtu.be/QIBAnyFbg0Y?t=112

Check out our Luigi's Mansion 3 Floor 10 Walkthrough tutorial to see the 100% 10F Tomb Suites guide, including how to get out of the Pyramid.

You’ve got to love Floor 10, Tomb Suites. Nintendo has a long tradition of sand-based levels and they manage to take all of that legacy and mix it with a good amount of something new to deliver a great ne...

▶ Play video
#

It's like a simple snowtracks shader, but 3 times more complex

#

I would really love to know your guys' takes on this cos I have a few thoughts but really don't know how you would ever do this lol

#

the most impressive part of all of this is this is running on a Switch

meager pelican
# merry oak I'ver seen it used in certain tutorials, so I'm sure it's possible, but I never ...

Well firstly, it is commonly done in shader based ray tracing/marching. There is a technique of uploading ALL triangle data (or SDF info) to the GPU in buffers so it has it all available at once. It is hella slow, and bulky, and impractical for real time data IF IF IF you want to know in the shader what object your ray has hit, like you'd know in C#.

HOWEVER, you can also do screen-space ray casting. In that, you use the depth buffer, and the camera and transforms and compute the world-space position of each pixel. You'd then know the position, color and depth of the nearest drawn pixel, along with any other things like normals, stencil information, or maybe motion vectors or anything else you managed to track in a special render texture tracked by all your shaders manually. For examples of this you may want to look into screen-space shadows, or maybe SS ambient occlusion.

Then there's ray-tracing in hardware on cards, for that you use an API, but I don't think you get per-object info in that either. I haven't really played with it, but I think it is more screen-space-ish than it is object-detail space.

:2 cents:

merry oak
meager pelican
merry oak
#

set up a mirror by calculating based on camera angles and normals and stuff, to cast a ray and get the colour.

#

there may also be a better system for a mirror, that's just what I thought of

meager pelican
#

First off, that's good creative thinking. 🙂

The challenge with that is (and IDK how the raytraced API's in cards do this, so I'll ignore that and if you want to use ray traced hardware you'll have to go to the API docs to see) that mirrors can show the BACK SIDE of things that were never rendered from the camera's view. So if your camera is looking at the front of, say, a sofa...the mirror on the back wall is reflecting the BACK side of the sofa...that was never drawn.

So you'd need all the scene detail and materials to "draw" those objects in the mirror using a ray casting method. I think the APIs do that somehow. But like I said above I'm unsure how they pull all that off...they even do some off-screen stuff.

BUT there's good news! The common way to make a mirror is to use a second camera (lower res usually) and re-draw the scene from that camera's perspective. Yikes! Double the draw time for the scene unless you use a lower res image. But it can be done.

This is often done with "TV Screens/Monitors" showing the area you're in and showing you, from a different angle.

merry oak
meager pelican
#

@merry oakYou may also want to research using reflection probes, that's what they are all about.

They're basically another camera, drawing the scene in a lower res image. And they can be set to fire off at different intervals. You might find that the combination of a reflection probe and a reflective surface is all you need, no fancy shaders required.

merry oak
#

Oh, alright I'll look into those thank you.

meager pelican
#

The thing with reflection probes is they draw a cube-map, so 6 camera shots, basically. But optimized for that. With a mirror, if that's all the reflection you want, all you need is one shot, not 6.

EDIT/ADDENDUM: the challenge for one camera might be getting the perspective/frustum correct for the mirror's view. The reflection probes hold the WHOLE scene view from each of the 6 angles with a camera at the probe's position, and then the reflection calcs in the regular scene's shaders take into account how the reflections map into that probe. BUT if you're doing portals, you may have encountered the perspective issue already and have a solution. You may even be able to create a custom frustum to auto-cull things that wouldn't be in the mirror's "view" while drawing it.

merry oak
#

That makes sense.

grand jolt
#

Did Unity ever address not being able to access the extra 4 textures in a HDRP Terrain shader? I can access the first 4 using the Control0 reference but there was no way to access a Control1 for the other 4 a while back, wondering if they ever let you access that

young fog
#

How do I do it now but not in a shader cos for some reason I can't do that @meager pelican

#

This works, but when I blit it it doesn't wanna work

#

I did this second blit wrong but I fixed it

#

still same issue, nothing changes on the render texture

#

A new tutorial series on how to create a snowtracks shader in CG language, within the Unity Engine.
You might want to make footprints in the sand, or snow. Or create a thick line of tire tracks, but also displace the terrain. With this tutorial you can do that, using tesselation. Learn step by step how to do it.

Created by Peter Olthof from Pee...

▶ Play video
young fog
#

Alright so I have been following it for a bit now, I have some problems though, my brush is set to red and is a simple faded tip, but it fills my splatmap (I called it trail map in my case) and it’s blue?

I’ll post what that looks like later

grizzled peak
#

Hello, I believe that my shader graph is bugged. I used to be able to open the Node selection menu, where I wanted to find the Custom Function node but I couldn't find it. and Suddently I am not longer able to open that node selection menu

#

I am using URP and the shader graph package is up to date

grizzled bolt
#

Or possibly both in conjunction

#

It looks so good because the texture adapts to the deformation, and the deformation is controlled to avoid extreme changes in elevation

amber vector
#

Sorry I'm a noob at shader graphs but I have no idea why this isn't working. Pressing view documentation just leads me to an missing page

vocal narwhal
amber vector
vocal narwhal
#

how have you applied it to the skybox, and what does the material look like?

amber vector
vocal narwhal
#

dragging it onto the scene view? Is there an object in there it can be applied to?

amber vector
#

I changed it to lerp and it works better in the preview but it's still just one plain color

amber vector
#

I went to check on lighting and it does changed to it

vocal narwhal
#

I'm not completely sure how the skybox shaders work, but I'm pretty sure they use UV coordinates, not geometry direction

amber vector
#

I see thanks, I'll continue to test things

vocal narwhal
#

Before you go further just make sure that the sky you're looking at isn't just inverted

amber vector
#

I checked but it's all still blue

vestal pelican
#

Shader Graph: Is there a way to call into the regular lit shader as if it was a subgraph? I basically only want to use the Shader Graph to construct an emissive map for the default lighting

grizzled bolt
#

@amber vector oh and another thing
Transparent and alpha clipping need to be disabled in graph settings for a skybox

amber vector
#

Thank you! I'll try that out

kind juniper
#

Anyone encountered an issue where unity complains of not disposing of an allocated compute buffer when you allocate it both at edit time and runtime? In the editor I allocate in OnValidate, but I'm not sure where I should dispose of it? Presumably somewhere before domain reload? Do I need to subscribe to some kind of editor-only event?🤔

#

Exiting play mode also yields the warning, which is weird, since I have dispose called in OnDisable

vocal narwhal
#

Surely it's the OnValidate one both times if you're not handling that one

kind juniper
#

Where should I handle it? I need it to live until the domain reload.

kind juniper
#

Hmmm... Doesn't seem to work in a MonoBehaviour

#

Weirdly enough, releasing the buffer in OnDisable doesn't seem to work either for some reason.🤔

grizzled peak
vocal narwhal
kind juniper
#

Not sure how to check that. I'm releasing the buffer if it's not null before allocating a new one. I imagine that should prevent from leaking previous buffers?

#

Not sure if it's the correction solution either. I feel like I should be reusing the same buffer as long as I can..?

vocal narwhal
#

log when you create them and make sure there's only the logs you expect

kind juniper
#

Hmmm... I guess it is the OnValidate. it seems to be called after OnDisable, but before Domain reload(presumably) sometimes.

vocal narwhal
#

I hate OnValidate and barely use it as it gets called all the damn time

kind juniper
#

pretty annoying. The solution I came up with is [ExecuteAlways] attribute. That seems to call the OnEnable/Disable methods at proper times, so I can have my shader render properly both in the editor and runtime. And the allocation warning is gone.

grand jolt
#

Did Unity ever address not being able to access the extra 4 textures in a HDRP Terrain shader? I can access the first 4 using the Control0 reference but there was no way to access a Control1 for the other 4 a while back, wondering if they ever let you access that

lapis ingot
#

Is there a list of Blender node equivalents for Unity?

white marsh
#

not as far as i know, but id love a list of anyone knows. i think you just need to know what the node does and find a node that does the same thing. like if i remember correcely the blender ramp node is basically a very convenient step() node

#

so they are often not named anything similar which kinda sucks

lapis ingot
#

ah, i would had never guessed ramp was called step

#

indeed, thats what makes it a hasle

white marsh
#

i had the opposite problem at some point and its painful trying to figure it out

#

though one thing i did figure out is that most of the time blender is simplified and in unity it would be more complex since blender does a lot more automatically

young fog
young fog
#

This is what my draw shader looks like

#

This is what my snowtracks shader looks like (the bottom left is my splatmap (trail map is what I'm calling it) and it's only blue because it clears on start

#

This is what my script looks like

#

so from all of this I don't know which part is wrong

amber vector
#

Is there a way to change the full rotation to not 6.285? I set it to a slider value because it lags/glitches when set to time

fossil cloak
amber vector
#

Rotation value required to make 1 full rotation is 6.285, is there a way to change that to maybe 360 so it's easier to set up?

#

And also so it's more accurate since the 6.285 isn't perfectly 1 full rotation XD

vocal narwhal
#

6.28318530718 would be the max value

#

because you have chosen radians

amber vector
#

I see, thanks

vocal narwhal
#

and that is Tau, the full rotation around a circle

#

or 2 PI

#

If you just switched your unit to degrees you would have what you wanted

amber vector
#

Oh I see

#

Thank you

night sequoia
#

Help, shader graph aint building

#

says theres a syntax eror

#

but how can there be a syntax error if i havent even touched the script yet?

echo flare
#

I'm trying to combine meshes to reduce draw calls. I need to make sure the new vertex positions end up in parent localspace because I proceed to do other calculations with the mesh using predefined boundaries meaning worldspace coordinates will almost always be out of range. Each CombineInstance accepts a transformation matrix so I pass local -> world. However if I then multiply that matrix with the parent's transform.worldToLocalMatrix I get weird results so I ended up transforming the position after the mesh has been combined. Does anyone know how I can avoid this?

        var fragments = GetComponentsInChildren<Fragment>();
        var combine = new CombineInstance[fragments.Length];
        var i = 0;

        foreach (Fragment frag in fragments)
        {
            var childMesh = frag.GetComponent<MeshFilter>();
            combine[i].mesh = childMesh.sharedMesh;
            combine[i].transform = frag.transform.localToWorldMatrix; // DOESN'T WORK (* transform.worldToLocalMatrix)
            i++;
        }

        var mesh = gameObject.GetComponent<MeshFilter>().mesh;
        mesh.CombineMeshes(combine);

        mesh.vertices = mesh.vertices.Select(v => transform.InverseTransformPoint(v)).ToArray(); // DOES WORK
young fog
kind juniper
#

Anyone knows if there's a special function for that formula?

floor(a * b) / b

so if a is in the range of 0-1 and b is something like 4, you'll get values 0, 0.25, 0.5, 075 and 1 for different ranges of a.

#

Also, does anyone know if there's a callback/event I can hook to on after shader compilation to bind the buffers again? Unity seems to unbind everything from the shader.

young fog
regal stag
young fog
#

I posted everything on the earlier posts

#

pass you said? Where's that?

regal stag
#

In your script. Try changing it to, Graphics.Blit(temp, trailMap, drawMaterial, 0)

young fog
#

I mean it doesn't add to it, it just has the brush size and strength in that position

grizzled peak
#

Hello, I believe that my shader graph is bugged. I used to be able to open the Node selection menu, where I wanted to find the Custom Function node but I couldn't find it. and Suddently I am not longer able to open that node selection menu

regal stag
grizzled peak
#

This is frustrating

young fog
#

sorry if I described it bad, this is what I meant

#

My brush shader graph doesn't have a texture on it

regal stag
young fog
#

I don't know how I missed that honestly

regal stag
young fog
#

so would the splatmap just be passed as the alpha?

grizzled peak
#

Ihave also tried to "recompile all" and deletin my libraries folder to force it to compile it again

kind juniper
young fog
#

I'm not sure how to apply what is on the shader to my shader graph like the alpha

#

The ones I selected are the new nodes I added, but it still does not work unfortunately @regal stag

#

reminder I'm new to shaders so if I've done something wrong my bad

kind juniper
#

col + drawcol

#

So you just need to sample a texture in the shader graph and add it's color to whatever you get from your brush

#

Need to set the texture from c# of course

grizzled peak
young fog
kind juniper
young fog
#

but it's not?

kind juniper
young fog
#

Same thing as in that gif I posted earlier

kind juniper
#

Might want to share the C# part as well then

regal stag
#

Did you set the property reference to _MainTex? (Under node settings tab while texture is selected)

young fog
#

I set the trail map in the shader graph

#

should I not be doing that?

kind juniper
#

Probably not. The point is that you need to feed the camera render texture into it if I get it right.

#

Not the camera.

#

But the results of the rendering of the shader. It's kinda like a recursion I think.

regal stag
#

Ideally no, as even if you set the texture to your trail render texture, that's the target you are blitting into. The whole point of the "temp" target is to avoid issues with reading/writing to the same target.
Use _MainTex instead. Unity will already pass the texture into that property when using Blit.

young fog
#

I know Unity has some like magic variables like _MainTex just didn't think I had to use them here

regal stag
#

It's only important when using Blit and SpriteRenderer iirc. Maybe UI Image too

young fog
#

don't know why" _TrailMap" wouldn't just work

kind juniper
#

Couldn't you use just any arbitrary texture names instead? 🤔

regal stag
#

It might, but you arent doing anything to set that property referemce. Unless you exposed it to the material.

kind juniper
#

If you set them in C# I mean?

regal stag
#

Can use Shader.SetGlobalTexture or material.SetTexture, depending on if it's exposed or not

simple violet
#

I accidentally took out legacy shaders from always include in build and now my ui looks pink only in build
anyway to tell which ones I need?

#

I'm on urp if that matters

young fog
regal stag
# simple violet I'm on urp if that matters

Maybe start a new project to see what the list defaults to.
Or revert it by deleting the file (in the ProjectSettings folder). But would need to reassign pipeline asset and maybe other stuff then

simple violet
#

ah it was the legacy shader/transparency

white marsh
#

anyone got any resource i can read to understand more of how to write macros?

#

i checked out the MS documentation though there arent any really great examples there

regal stag
#

I think Graphics.Blit is doing something similar behind the scenes, just with _MainTex

young fog
#

Shader Graph did not exist back then

#

this was uploaded in 2020, but I recall making this like in 2018-2019

kind juniper
regal stag
white marsh
#

oh, good thinking

#

thanks

young fog
#

never mind, I just fixed it, I added it after assigning temp, I was assigning it to start by accident

white marsh
#

ok im attempting to make some macros in a cginc file but i keep getting this

#

there is literally nothing in there yet

#

i dont really know what this error means

simple violet
#

Anyone know any good tips for cutting down shader variant compilation time?

#

Unity is doing like 20m

shadow locust
white marsh
#

ah, but what if i use it only for macros?

#

it seems like its working, but i dont like having that error there

shadow locust
#

not sure, I don't know enough about shader code to help with that

grand jolt
#

hello everybody! Does anyone know how to fix this error that pops up in my project when I try to run it? : Shader UI/Default shader is not supported on this GPU (none of subshaders/fallbacks are suitable)

jade hinge
#

how would i go about exposing the fragment variables in materials that are using a custom shader graph?

#

i think there's a switch somewhere i have neglected to flip

#

(URP if that makes a difference)

#

Do i need to make a custom exposed variable for each of these? (was hoping i could expose these directly)

#

shows up with these empty fields for some reason...

regal stag
#

You need to manually create and connect the properties

jade hinge
#

yea i managed to conclude that, but thanks!

#

now im stuck trying to figure out how to disable Z dept testing in a TMPro shader (or a variant i can create)

#

so that it renders on top for UI purposes

#

ah wonderful

#

they have a built in one

#

Distance Field Overlay it's called

ancient arrow
#

and the main texture its not a circle at all agony

grizzled bolt
#

@ancient arrow You're not using alpha clipping or transparency so it can't be anything but a square

grizzled bolt
ancient arrow
#

it becomes this

#

instead of

grizzled bolt
ancient arrow
#

k right, forgot

#

well

#

fixed the second problem

#

now i need to get rid of the grey color

#

any ideas?

tight phoenix
#

Does anyone know how to make a fake backface in shadergraph? Not actual transparency, but display on the surfaces "depth" of the opposite side of the cube

#

Sorta like a fake window or fake interior shader? Ill try googling those

ancient arrow
#

does anybody know how could i reproduce this shader

#

the outline

kind juniper
tight phoenix
kind juniper
#

Nice. Did you manage to get the effect that you mentioned in the beginning?

tight phoenix
#

Yeah, the above gif you see there, the cube is not transparent nor is it turned inside out, its just a default unity cube

#

but it looks like you can see the 'backfaces' of it

kind juniper
#

I mean, with the deeper parts of the cube getting darker

tight phoenix
#

OH, I've only got this far so far, that's a later step

#

On the todo to figure out

kind juniper
#

Alright. I'd love to see the final version. So keep it up. 😄

young fog
#

I got another effect I want to pick your guys' brains about

#

how would you achieve this?

#

Sorry if I ask too much about re-creating shaders, I just like to see this kind of detail, and I wanna hear how you guys would achieve this so I could learn from it

ancient arrow
#

why it wont show me

tight phoenix
#

the distance node is great for effects that need to be spherical but is there an easy way to get a cubic volume instead of a spherical one in shadergrapgh?

tidal prism
#

Hey I was following Unity’s flag waver shader tutorial but got this

regal stag
regal stag
meager portal
#

Can someone help me make a toon shader in URP shadergraph?

#

Both the shading and the outline

regal stag
tidal prism
regal stag
# tidal prism This is the result

Then may need to compare the graph to the tutorial. It's difficult for me to debug right now, maybe someone else can jump in.

I would also assume they use a plane mesh (subdivided quad) rather than a cube too as this doesn't have enough vertices to displace.

tidal prism
#

I compared mine to the tutorial a few times and everything was the same, and okay I will check the mesh thing later. Thanks

tidal prism
#

With G not connected to Add by the way

#

When G is connected it does less of a wave

tidal prism
#

I was googling something regarding shaders and I found your Twitter

#

Lol

kind juniper
#

Anyone knows how can I rewrite this so that the shader compiler does not throw an error?

    uint texIndexL = lastIndex / 4;
    uint channelIndexL = lastIndex % 4;
    
    float4 tWeight1 = 0;
    if( texIndexL == 0)
        tWeight1[channelIndexL] = weight1;

The error is

array reference cannot be used as an l-value; not natively addressable at kernel CSMain 

it's because I try to assign to a float4 component via an index. I'd write it manually, but I have 7 more float4's like that...

wraith tide
echo flare
kind juniper
#

Yeah, I ended up creating several functions.

echo flare
kind juniper
#

But in this case, I'm not sure how I can use a loop

echo flare
#

Not an expert, but It seems like the GPU expects a constant value to use for indexing when it goes to unroll

kind juniper
#

It's able to unroll if the number of iterations can be inferred at compilation time it seems.

echo flare
#

That makes sense if the work is being divided across multiple threads that do not share state

midnight crater
#

there's a nice overview here, maybe can give you some ideas

tight phoenix
dim yoke
#

Correct

#

Otherwise youd see massive fps drop with massive planes. All the triangles are clamped at the screen when rasterizing

ancient arrow
ancient arrow
#

k, question, is it better to write shaders with code instead of using shader graph

tight phoenix
regal stag
# ancient arrow k, question, is it better to write shaders with code instead of using shader gra...

Graphs tends to be easier for beginners as they do some of the setup for you and don't need to worry about code syntax. Personally I also find working with graphs quicker and more readable, but that'll be different per person.

But shadergraph does lack some features, e.g. Stencil operations (though can edit generated code or use overrides on RenderObjects feature in URP). No support for UI yet really. Probably more that I'm forgetting.
Well written code can likely also perform better than a graph.

tight phoenix
#

I know an inverted mesh can have that appearance but I can't use one in this specific circumstance

steel notch
#

Hey if I wanted to make my sprite 1 specific color while maintaining transparent pixels (like not tint the pixel, set it) what should I do?

#

In terms of shader graph?

regal stag
steel notch
#

Will that not make the whole quad that color or nah?

regal stag
#

Not with the alpha connected and graph set to Transparent (or using alpha clipping)

steel notch
regal stag
#

Can you show the graph

steel notch
#

literally just this for now

#

I assume I need to sample the _MainTex?

regal stag
#

Yes use a Sample Texture 2D node and connect its A output to Alpha

steel notch
#

for making sure it uses the texture from something like a SpriteRenderer

#

do I create a Texture2D property with a reference _MainTex

#

the answer is yes

#

working

#

ty

#

oh wait, hmm I still want the color field in sprite renderers to allow me to tint this whited out sprite

normal rose
#

does anyone know how to disable LOD only in the editor view

regal stag
ancient arrow
#

or whatever unity uses for shader language

regal stag
#

Yea, HLSL + ShaderLab. Bear in mind that the includes/functions varies for each pipeline. There's a good amount of code tutorials for Built-in RP. A few for URP (including one of my own, mentioned in pinned messages). Don't know about HDRP, I think using graphs are recommended there.

ancient arrow
#

ShaderLab?

regal stag
#

Sorry, on mobile. Can't type that fast

ancient arrow
#

dw, i have a lot of time

regal stag
# ancient arrow ShaderLab?

Yea it's a syntax unity uses for the shader file to separate exposed properties, subshaders (to support multiple platforms), and passes (which then contain hlsl). If you google for shader code tutorials it'll probably be the first thing you'll learn.

ancient arrow
#

is it hard to learn it?
im just getting confused with all this math operations and pixel rendering and so on

#

i just got used to work with "big" things, idk how to say that properly

regal stag
#

If you're confused about it in graphs it wont really be any easier in code

#

Unless you are more used to coding I guess

ancient arrow
#

coding is better for me ig

#

Visual scriptring or smth similiar to it, just confuses me

#

with all these node connections and so on

regal stag
#

Ah okay

ancient arrow
#

k so

#

ill start my learning process

#

from making a greyscale shader

#

Which one do i use for the sprite

#

Unlit?

regal stag
young fog
ancient arrow
#

why its isnt working

#

what im doing wrong

#

it just makes my image go completely white

#

but in theory it should be just the same image

#

@regal stag oh my god, i actually managed to write own grayscale shader

wide thicket
#

Hello! I need some help translating this Amplify shader into default shader graph nodes:

#

here's my old setup i was using, but it conforms to the objects normals and stretches at the ends of the screen:

wide thicket
sage locust
#

how do I access the render result of the previous pass?

sage locust
#

grabpass nevermind

brave pivot
#

How can I create a shader for what would create a seemingly distant planet which is a sphere that gets the sunlight direction and renders a solo outline using the fresnel effect along with some normal maps and a noise generators and also isn’t linked to the skybox

kind juniper
tacit parcel
#

That said, I think its actually overkill where a sprite with some custom masking could do the job too

grizzled bolt
#

@brave pivot The default transparent shader (particle shader in BiRP) with additive blending does pretty much that

meager portal
#

I tried making my own outline shader, but this weird thing happens from some angles. It shouldn't be black, it should just have a normal black outline, like at the top

#

this is how I made it

#

would anyone know how to help me remove that artifact? Or otherwise, if anyone knows of a toon shading + outline tutorial video, it would be greatly appreciated

#

I want ot make the outline without making a bigger duplicate of the model, and making that black

karmic hatch
# meager portal this is how I made it

What this method seems to do is take the surface normal, compare it to the view direction, and if they're close enough to orthogonal, it returns black, otherwise it returns white. So if you have a plane where the surface normal is uniform everywhere, it would return white with no outline, until you rotate it far enough and then it'd return black, again with no outline. If you have a smooth convex shape, it should usually work, as you're seeing, but any flat portion would act similar to the plane (as you're seeing).

Afaik, most toon/outline shaders create another mesh with the same vertices, shift it outwards (along the surface normals) a small amount, invert the normals, and paint it black. By shifting it outwards and then inverting the normals, they make the side in front invisible (since the normals are pointing away from you) but the back side is now visible, and a small bit of it extends around the object, creating an outline.

meager portal
#

I know but all the tutorials do that manually, I don't want to manually copy + paste every outlined object

#

would you know how to make a proper toon shader?

#

or, if it works, I have a toon shader that I used originally, until I went to universal render pipeline

#

if there's a way to use that with URP, I would gladly just use it

karmic hatch
#

you could try to do something where you calculate the curvature and the current angle between the normal and the view direction, then use that to estimate how close you are to the horizon of your object, and depending on that draw an outline or not

meager portal
#

the thing is I've never done shaders before, and don't really know how to do any of that

karmic hatch
#

it'd just be some messy maths

#

you could probably do it in shader graph

meager portal
#

oh ok

#

do you know of a good tutorial that would teach me how to properly use shader graph, and then I could do that?

karmic hatch
#

ig you could take the derivative of the normal/view dir dot product with respect to screen space position, then divide the current normal/view dir dot product by the magnitude of the derivative vector, which should give the screen space distance after which it reaches zero (the horizon)

#

if that distance is less than a threshold value, draw outline, if not, draw object

#

make sure to account for if the derivative is zero (either add a small amount or branch to color it as the object color)

karmic hatch
#

Btw you don't need to feed the position node into the vertex position output, it does that by default. You only need to feed something in if you want to change it

#

This is what I was thinking

#

(then in the branch, if true, it returns outline color, if false, it returns the main color)

#

Here it is on a planet

#

And on a sphere, capsule, cylinder, and tree respectively. It doesn't work if there's a sudden change in curvature so it doesn't work at the ends of the cylinder or bottom of the tree.

#

@meager portal

meager portal
#

Oh thx

amber saffron
meager portal
#

Oh thxI tried using that, sownloading the source code and using their shader

#

Howver it didnt show any of the values like body color and stuff

meager portal
karmic hatch
#

np :)

meager portal
#

one more thing, is there a simple way to make a toon shader, in the sense that all the shading is split into 3 or so solid colors across the body?

karmic hatch
meager portal
#

ok

#

thx

meager portal
drifting gyro
#

Any idea why its coming out as pink in the end?

#

the black center part is pink

amber saffron
drifting gyro
amber saffron
#

Ah sorry, I've didn't pay attention, it's the A input that is partily negative in the black area I think ?

drifting gyro
#

How can I figure that out? Idk tbh

amber saffron
#

Sine function returns a value in the range of [-1;1]

#

This is expected

drifting gyro
#

AH!

#

fixed

#

I just used clamp lol

#

thnx

brave pivot
#

Im trying to make a planet shader but I cant figure out one thing which is how do I make the fall off to transparent more like a gradient rather than a hard edge

#

This is more like what I'm going for

amber saffron
#

Also, you have NaN value at the power node because there is negative values in the A input

#

( this is why it's showing majenta )

brave pivot
#

But how can I fix it with out messing up the normal map

amber saffron
#

For the power node : add a saturate node before the A input

brave pivot
#

ok that fixed it

#

Lastly how can I make the sides of the light come to a point

#

or should it not matter

amber saffron
#

Connect directly the sample normal node in the A input of the dot product, and set it into world space.

brave pivot
#

it is

amber saffron
brave pivot
#

oh ok I changed it

#

still has the same look though

amber saffron
#

Can you show the current graph/result ?

brave pivot
amber saffron
#

Not what I said at all 😅

brave pivot
#

oh

#

sorry I'm new to the shader thing

amber saffron
#
  • change "space" of sample texture to "world"
brave pivot
#

theres only tangent and object

amber saffron
#

Ah, crap

#

Then keep tangent, and in between the sample and doc product, add a "transform" node:

  • from tangent
  • to world
  • type direction
brave pivot
#

ok

amber saffron
#

Is it giving better results in the scene ?

brave pivot
#

yes

#

but the directional lighting is way over exposing it

#

how can I change it just for the sphere

amber saffron
#

You could just change the base color to be darker

brave pivot
#

is there anything else I could do to make it look more distant

clear vector
#

I've read about % operator in HLSL and msdn tells that result of 1f % 2f is 0.5. This is strange for me. I'm trying to fix my shader code which uses %

float2 TilingAndOffset(float2 UV, float2 Tiling, float2 Offset, float4 UVBound)
{
  return TilingAndOffset(UV, Tiling, Offset) % UVBound.zw + UVBound.xy;
}
amber saffron
amber saffron
clear vector
#

yes, me too

amber saffron
#

What are UVBound here ? minXY & Max XY ?

clear vector
#

yes

#

i just passing (1,1, 0,0) Tiling and Offset values. So with my formula there should be no value change at all

amber saffron
#

Well, %0 seems quite dangerous

clear vector
amber saffron
#

i just passing (1,1, 0,0)

clear vector
#

it is Tiling and Offset, i then gets bound based on it

float4 GetUVBounds(float4 TexST)
{
                float2 rightBound = TexST.zw + TexST.xy;
                return float4(TexST.z, TexST.w, rightBound.x, rightBound.y);
}
amber saffron
#

But anyway, %1 will change your values, removing all integer part of the coordinates

clear vector
brave pivot
amber saffron
brave pivot
#

How?

#

isn't it already being changed by the shader graph

amber saffron
brave pivot
#

That just changes how much edge light is shown

#

Or am I not supposed to do it in the shader graph

amber saffron
amber saffron
brave pivot
clear vector
amber saffron
# brave pivot

Well, yes, reducing the value here will make the effect more faded, isn't this what you want ?

amber saffron
brave pivot
amber saffron
amber saffron
brave pivot
#

I like where the edge light is currently I just want to be able to see through to the skybox while still seeing the edge light

amber saffron
#

Ah.
Well, this is a bummer, as the skybox is displayed at a "virtually infinite" distance, so behind the planet, while in reality it is in front

brave pivot
#

that sucks

#

so I cant do this with my edge light effect on?

clear vector
# amber saffron From my understanding, you wanted to tile+offset the original UVs, then remap th...

I have sprite on atlas. So firstly i want to pass something called MainTexSTOnAtlas to get proper UV. But then i want to Tiling and Offset this resulting rect. But it already not in 0,0,1,1 rect but in some arbitratry rect. So I want to pass extra MainTexST and do Tiling and Offset inside bounds of resulting rect from previous step. Remaping works in editor, because sprite refer to it's original texture and not to atlas texure, but in playmode as a result i see whole atlas texture being rendered.

amber saffron
brave pivot
#

how can I do that?

amber saffron
brave pivot
#

ok

#

that just kind of ruins the material

amber saffron
amber saffron
brave pivot
#

well in the main preview

#

but when I changed to scene view it looked the same

clear vector
#

So to repeat value a want to get it's remainder and add it to min value. I'm not sure is this mathematically right

amber saffron
#

It makes it so you are working in the "sprite rectangle space"

clear vector
karmic hatch
amber saffron
#
  • Take UVs
  • Remap to 0-1 using the sprite rect value UVs are now in "sprite space"
  • Apply your additional tiling and offset
  • frac the value to have them repeat in the 0-1 range
  • remap again to the sprite rect UVs are transformed back into the sprite atlas
clear vector
#

So for example we have 0.5 0.5 UV coords and some 0.5, 0.5, 1, 1 sprite rect

  • Remap 0.5 0.5 to sprite rect will give us 0.75 0.75 right in the middle of sprite rect
  • Apply tiling and offset. we will get some value which now can land somewhere. For example i want to offset it by 0, 1.5, so result uv will be 0.75 2.25
  • frac it inside 0-1 range will give us 0.75 0.25 which is already outside of sprite rect
  • and then we want to take it back to sprite rect space by remaping it again. Which will give us 0.875 0.625 UV, but offset X was 0
amber saffron
#

So, remap the 0.5,0.5 to 0,0

clear vector
#

oh ok, i think i've got it

marble lance
#

Hello, does someone know how to get depth buffer of specific camera in shader? Similar to how you can get main camera's depth by using _CameraDepthTexture. I'm working on a game with prerendered backgrounds and i need to get depth of my reflection camera(used for planar reflections) to be able to discard parts of reflection behind prerendered objects

#

Or maybe i need to write my prerendered depth to reflection camera before it draws other objects so they can be automatically occluded. I'm using simple plane with shader outputting depth with SV_Depth for main camera and dont want to do same for reflection camera because it's created at runtime

#

Basically i don't know how to better do it. Draw fullscreen quad with sv_depth shader to my reflection camera or get depth of reflection camera and then discard pixels in shader by comparing with prerendered depth

#

Or maybe there is better ways...

white marsh
#

is there any equivalent to GetAdditionalLightsCount() in built in RP?

regal stag
white marsh
#

so instead i guess i could pass it in by hand with a script or something

clear vector
# amber saffron - Take UVs - Remap to 0-1 using the sprite rect value **UVs are now in "sprite s...

So as i can understand with 0.75, 0.75, 1, 1 rect and 0.5, 0.5 uv we will get -1, - 1 and this mean "where" current UV relatively to sprite atlas rect. Second step brings no questions. But how to repeat value in 3rd step? I mean frac will give us fractional part of a value, so in case of 1 we will get 0. + how negative values should be handled in this way? The final step should operate with [0,1] uv which relative to sprite rect and just remap it back to actual values.

delicate phoenix
#

Hello everyone.
How do I stretch only the top of the uv?

kind juniper
meager pelican
# white marsh so instead i guess i could pass it in by hand with a script or something

Maybe...
I mean, you can do custom lighting in BRP, and pass in an array/buffer of light data and use a loop in various stages, but the engine is really designed to pass lighting and do calcs in a certain way. So you'd have to "plug into" the various stages, such as using reflection probes and shadow maps in the right places. And regarding shadow maps, if you want then engine to generate shadow maps for you, you'd have to have "real" unity light objects that correspond to your array info, and perhaps mark them as "shadows only". And IDK what of 100 other things I didn't think of in this post.

But that's largely academic, since you could "just" use "real" lights in unity, custom light calcs if you need them, and let the engine do what it is designed to do...decide what lights are in range of your object, and call the lighting routines for them the "right way", and you conform to that.

If you simply need a list of lights for some reason, but aren't impacting colors, just pass the array. But if you want to impact colors, I'd conform to how the engine works and not fight it. Call me a conformist...

white marsh
#

so you suggest i should switch to URP then?

delicate phoenix
kind juniper
delicate phoenix
kind juniper
delicate phoenix
fallen crest
#

I am trying to implement a ocean shader made in built-in pipeline to HDRP. I don't know much about shader coding so I am trying to replicate it in shader graphs in HDRP from the code shader. But I am facing a lot of problems, can anyone please help me?

#

https://youtu.be/kGEqaX4Y4bQ
This is the shader I am trying to import to HDRP. The simulation part is working fine but the shader is the main problem. In HDRP the vertex displacement is still working, I can see it in wireframe mode but the surface shader is not working so it is looking pink. I am trying to replicate it in shader graph step by step and as a beginner I really need some help with this.

How does ocean waves simulation with Fast Fourier transform work?

Source code:
https://github.com/gasgiant/FFT-Ocean

Music:
https://soundcloud.com/igor_vaiman

Catlike Coding on Gerstner waves:
https://catlikecoding.com/unity/tutorials/flow/waves/
3Blue1Brown on Euler's formula:
https://www.youtube.com/watch?v=v0YEaeIClKY
3Blue1Brown on Four...

▶ Play video
kind juniper
tacit parcel
brave pivot
#

Did you do this in shader graph or with a custom script

tacit parcel
#

I use code unfortunately, but iirc you can use world position node for that

brave pivot
#

How did u get the fall off at the horizon or is it just the light direction

tacit parcel
brave pivot
#

do you know how I could implement it with the setup I have now or do you not mess with shader graph

tacit parcel
#

Here's using another light direction

tacit parcel
brave pivot
#

yeah that worked thanks

#

Lastly how did you get that nice edge light to get mine to look like that I had to lose a lot of detail

#

and how did you get it to blend into the skybox so well?

kind juniper
kind juniper
brave pivot
kind juniper
#

You need some transparency in the visible part too

tacit parcel
#

you need to clamp the world position y

brave pivot
#

what would the min and max be?

tacit parcel
#

0 and 1

brave pivot
#

Ok I got it to look a lot better but how can I get rid of this sharp squared edge

#

Heres with the light changed a bit

tacit parcel
#

I think it;s the fresnel node, I dont use fresnel btw
try to remove it

brave pivot
#

Is there an alternative to the fresnel?

tacit parcel
#

🤔 I think it has too steep gradient, try to lower the power values.
Or maybe plug the 1st multiply output directly into the one multiplying with position y instead

bold niche
#

Could anyone help me with Ciconia Studio (double sided shader asset), I am trying to make my model double sided. I added the shader to the material, then the material to the mesh. But even though the material color is set to white, it is gray in some parts and white in others.

brave pivot
#

but after doing that the material greyed out a bit

#

compared to yours which is the look I'm trying to go for

#

nvmd

#

I just had to change the sun positioning

#

thx

kind widget
#

did i do something wrong

#

uhh

#

need some help here

kind juniper
#

If it's birp, shader graph is not compatible with afaik.

kind widget
#

and what am i suppose to do now

kind juniper
# kind widget universal

Is it set up properly? If you add objects using urp materials/shaders to the scene, to they look pink?

kind widget
#

yes

#

they still look pink in the scene

kind juniper
#

Then it's not set up. Look up configuring your render pipeline in the docs.

kind widget
#

ok

regal stag
#

Depending on the unity version (2021.2+) you may be able to change the target to Built-in in the Graph Settings (tab in Graph Inspector window, toggled with button in top right of graph)

karmic hatch
fallen crest
# kind juniper Well, what do you have so far?

So I am trying to get the vertex shader first. I need to understand the code to get the displacement correctly in shader graph. The wave generator script creates a plane with LOD geometry and assigns 3 materials using keywords, "CLOSE" "MID" and another for the rest.

#

and the vertex displacement is working even in HDRP but rest is broken. So I need to make it in shader graph, I tried to modify HDRP lit shader code generated from a shader graph but that is too big and complicated for me.

#

My problem is

  1. How do I multi compile in shader graph using MID CLOSE keywords?
  2. I need to understand the vertex shader code properly to replicate it.
#

I tried using enum keyword but I dont know what to use the "reference".

kind juniper
#

Try making it work without the LOD first.

fallen crest
#

okk I tried. here's what I got.

kind juniper
#

Were?

fallen crest
#

wait sending pictures

#

I am not entirely sure I used right nodes.

#

you can see the displacement in the distance kinda looks like the original.

#

the "void vert{}" is what I am trying to get

#

I think the UV part is okay?

#

this is "worldUV" part. but what does o.worldUV = worldUV.xy translate to in shader graph?

kind juniper
#

o is output. It's a struct that moves the data to the fragment shader

fallen crest
#

oh I see. So it is for the fragment shader part.

#

now what does v.vertex in this line?

kind juniper
#

v is the input data of the mesh, so I'd assume it's the vertex position in object space

#

maybe in clip space.🤔 Not entirely sure

fallen crest
#

and unity_ObjectToWorld?

kind juniper
#

Btw, the fact that it's pink probably means that you divide by 0 somewhere. Or that you're on a render pipeline that's not compatible with shader graph

kind juniper
fallen crest
karmic hatch
grand jolt
#

I mean, I only use one node and route it anyway but was just wondering, if you use multiple of these nodes is shader graph declaring each of them using extra code? or does it use the function once and the nodes just act like pointers?

Basically, does SG use extra unnecessary code when you use more than one of the same node?

karmic hatch
#

If you copy the same code twice I would guess it recreates it

#

Subgraphs, idk

fallen crest
kind juniper
karmic hatch
#

it gets the vertex position in world space, then subtracts it from the world space camera position

fallen crest
#

world space camera position is this node right?

karmic hatch
#

yes the camera position node is in world space

#

iirc

#

though you could also take the depth and multiply by the normalized view direction

fallen crest
#

so the the highlighted line simply means this nodes right? the output of the subtract is the view vector. yes?

#

does this node do the same thing?

fallen crest
#

yes that is what I was wondering

#

what's the difference between these two?

amber saffron
fallen crest
#

okk got it

#

so in my case it will be the left one

fallen crest
#

okk now what are these variables?

#

they are not properties, where are they getting their values from? they are only used in some calculations.

kind juniper
#

They're probably set from C#

fallen crest
#

hmm but shouldn't they have a _ at start?

#

like these?

kind juniper
#

*identifier. You can name them whatever you want

fallen crest
#

okk so I can use them in reference name right?

kind juniper
#

reference name?🤔

fallen crest
amber saffron
#

Yes

kind juniper
#

Ah, yeah

fallen crest
#

great

amber saffron
#

If you don't expose them in shadergraph they will act the same as in the shader code

fallen crest
#

got it

#

output of the minimum node is lod_c0 .. did I get it right?

#

line 86

fallen crest
#

so this is the final line

#

this should be it right?

#

but it is not working

amber saffron
clear vector
#

When i'm using frac or % with UV in vertex shader sprite invisible in edit mode but completely fine rendered in play mode. But when using same instructions in fragment shader all goes well.
Should i handle UVs only in fragment shader?

fallen crest
#

@amber saffron so this?

amber saffron
#

yes

fallen crest
#

well still no luck 😦

#

the geometry is completely broken

#

this is how it should be

#

except the pink part ofc

amber saffron
#

I think I saw some issues in that last screenshot

#

It doesn't match the code

#

Divide the worldUV by LengthScale2, and use it to sample the texture, don't divide the result of the sample

#

I guess it's the same for the other samples

fallen crest
#

okk trying it

#

also I was trying to get the one of the cascades, there are 3 materials multi compiling. How do I get the keywords? there are 2 keywords "MID" "CLOSE" and using 3 materials.

amber saffron
fallen crest
#

enum or boolean?

#

yaaayyy got the displacement right. OMG you guys are god. Now I have to figure out the keyword part and then the normals.

tight phoenix
#

im following a shadergraph tutorial but the swizzle node in the tutorial and the swizzle node I have in unity are completely different, googling I cant find a reason why

#

I also dont have those colored bars, their interface in general is very different

amber saffron
fallen crest
amber saffron
tight phoenix
fallen crest
#

@amber saffron okk so what do I use in the reference name? I just used material cause I didnt find anything. Is this important?

amber saffron
#

It really is only a visual helper, and doesn't change the shader

tight phoenix
#

Oh I see

#

the doccumentation for the swizzle node for the version of shadergraph I have says it should have mask

#

but mine doesnt

amber saffron
fallen crest
#

hmm so if I keep the reference field empty?

amber saffron
tight phoenix
#

if I start substituting nodes, I have no way to keep following this tutorial or get the same results

#

he doesnt post what version of unity or shader graph he's using

amber saffron
#

You could even do this manually by using split and append nodes

tight phoenix
#

I see

fallen crest
#

@amber saffron so If do this, the keywords should be "_MID" "_CLOSE" right? do I have to change it in the other script that is enabling these keywords? or "MID" counts the same as "_MID"

amber saffron
#

For example, if your reference name is MYENUM and the desired entry is OPTION1, then you would call Material.EnableKeyword("MYENUM_OPTION1")

fallen crest
#

hmm then I think it is better to change them in the script and rename them there

#

so If I do this and use "M" in the reference field it should be working

tight phoenix
#

Can you see how mine is different from his in just those four nodes?

karmic hatch
#

The camera direction is by default (0,0,1)

#

Since you're taking the reciprocal of zero, it gives the pink texture

#

@tight phoenix

tight phoenix
#

He's doing it and it works completely, and all his further work compounds on this so I have to get it working

karmic hatch
#

Looks like he's not showing the previews at all, and it would be if it were shown

tight phoenix
#

I updated to latest unity and it still doesnt work

karmic hatch
#

In game it's unlikely your camera will align exactly along any one axis

#

So it's unlikely to give an infinity

tight phoenix
#

Thats not the problem, hold on

#

The end appearance and behaviour of the shader is completely different

#

this it show it should look

#

following his graphs, this is his preview

#

mine is a broken mess

#

but our node graphs are identical to the best of my observation

tight phoenix
#

here is a link to the finished tutorial

#

im really struggling to see why its different

#

I followed the tutorial step by step identical, so why arent the results the same

#

why does nothing ever work for me, why am I such a stupid failure that Iliterally cannot succeed at even the most basic copy paste

karmic hatch
tight phoenix
#

I dont understand why we are hitting the same nail with the same hammer and getting completely different results

tight phoenix
tight phoenix
#

Ill try posting to unity reddit and unity forums, maybe someone there will know why the shader graph behaves totally different

shrewd crag
regal stag
# tight phoenix

Your last Multiply on the right is using the wrong B input. It should be the other Multiply with (1,1,-1), not the one after the reciprocal

karmic hatch
#

Good spot!

grand jolt
#

Hey I am looking to create a custom shader that will go on a LineRender. I want to make it so the texture I use on the material dynamically tiles based on the length of the line. Is this possible? I was thinking it might have something to do with the length of the quad the Line creates.

regal stag
grand jolt
#

Oh jeez... There is

#

Welp, my solution just got infinitely easier

#

thank you

shrewd crag
#

can i somehow sample the mip level choice / anistropic filtering distance in shader graph?

#

as opposed to depth?

grand jolt
#

Well another issue I am having is that my custom shader is overwriting the color of my Line Renderer. So is it possible for my shader to inherit the LineRenderer's color?

tight phoenix
#

fixing that fixed the output to be as expected as well

grand jolt
#

Oh sweet

#

I figured it out

#

Line Renderer is setting the vertex color

#

I can use that 👀

regal stag
brave pivot
#

Is there a way for me to make a material not affected by fog in the shader graph?

#

Like with a custom node

regal stag
brave pivot
#

In the custom function node what should the outputs be?

regal stag
#

Depends where you connect it. Vector3 in and out is probably easiest, connected to Base Color.

#

The function shouldn't edit the value, just pass it through so that the code is included in the generated shader.

brave pivot
#

I haven't connected anything yet and I'm getting an error

#

nvmd I fixed it

#

And I should connect it to the base color option on the fragment?

regal stag
brave pivot
#

yep I got it all connected

regal stag
#

Hopefully that works then?
If not may need to try File mode instead, as the #undefs might need to be outside the function scope.

brave pivot
#

I changed the format to file but am getting a weird error

regal stag
#

Also remove B input

grand jolt
#

Got a cool effect with my line renderer

tight phoenix
#

I have a shader that is centered on object center, but I need it centered on object bottom left corner
Is there an easy way to translate every value over by 0.5? to move them all over?
I tried adding 0.5, and multiplying by 0.5, neither worked
I tried plugging it into tiling+offset but that destroyed the values

#

how do you "move" values in shadergraph?

brave pivot
tight phoenix
#

How do I write what tiling and offset does without using that node? Because its also destroying my values and I dont know how to correct that

#

top is what it should look like, bottom is what it does look like

#

how do I retain the top look and then offset it

#

I need to move the fact that it intersects at the dead center to intersecting at the corner

regal stag
tight phoenix
tight phoenix
regal stag
#

You would need to offset before the Fraction

tight phoenix
#

I am still getting a very tiny ammount of distortion at the extreme edges and im not sure why, but otherwise its centered right now

grand jolt
#

I am using a Panner and I want to randomize my UV offset for each of object using my shader, so that the scrolling effect looks less repetitive. Is there some sort of input I can use to randomize my offset?

#

I don't want to use world position because these objects will move, and if I randomize the offset based on world position it'll look janky

regal stag
grand jolt
#

Will that work per individual object?

regal stag
tight phoenix
brave pivot
grand jolt
#

Or will that cause all objects to just update to the same offset

regal stag
grand jolt
#

What's the performance cost of this?

regal stag
#

You also should destroy the clone in OnDestroy

grand jolt
#

Im using it for the line renderer and will have several dozen lines

tight phoenix
regal stag
regal stag
grand jolt
brave pivot
#

URP

grand jolt
#

This is also not working

#

It's just setting all the materials to the same thing

#

Oh wait no

#

it is working but the number isnt properly randomizing

brave pivot
regal stag
grand jolt
#

derp

#

its _RandomSeed

brave pivot
regal stag
#

@grand jolt Just thought, but maybe you could pass a seed in via the alpha channel of vertex colours, if you aren't using transparency

grand jolt
#

Wouldnt that seed be the same every time?

regal stag
#

Not sure what you mean. Can set it from C# by adjusting the mesh data

#

Actually no, it's a LineRenderer, just use it's .color

#

Would mean you can stay with a single material though for the dynamic batching purposes that I assume LineRenderers use

grand jolt
#

hmm

#

I might have to use instances anyways if I wanna animate each line

#

with some sort of shader effect

regal stag
#

Okay, just an idea 👍

grand jolt
#

I got the individual instances to work

#

color didnt work unfortunately

#

Thank you tho :p

sly breach
#

anyone knows how to get a mid point for a flipbook node ?

tranquil jackal
#

anyone have to share their shader stripping code (as my URP lit takes..... 160MB :D)? I am too beginer to learn it from "extensive" unity documentation about that which leads to one good blog without any examples 😄 (all exmaples links are dead)

#

I would imagine you make ShaderVariant, or log all shaders you use in run time. (did that), then make a list of those shaders somehow (did not did that) and remove all others on build..... making the list of them in correct format is still a mistery for me

strong plank
#

im trying to make a steak cooking shader(the cook-ness can be changed with float value) and it's kinda f*cked up

amber saffron
#
  1. Look at how to do custom lighting
  2. Make a single point light
  3. step 2 , two times more

Or, why don't you simply use a lit shader with 3 point lights ?

wicked prawn
#

hi guys

#

does anyone know a website or source from where i can download free textures

#

containing albedo and normal map

#

preferrably some grass, or underwater ground texture

wicked prawn
brave quartz
#

hey friends

#

does anyone know how to get rid of this transparency bug

#

the fins in the back are rendering ontop of the blob in the front

regal stag
karmic hatch
#

Is there any way to make a transparent shader graph still write to the depth/scene color buffers?

karmic hatch
#

f

#

that is annoying

strange fox
#

hello guys !
A question about Hdrp and Decal projector. Does it work on transparent materials like glass ?

amber saffron
# brave quartz

This is how regular transparency works, if the most part of your object is opaque and a small part transparent, favor the use of two materials

amber saffron
amber saffron
# brave quartz

Else you need to do some trickery like transparent depth prepass

strange fox
#

@amber saffron Ok, thanks for your reply. Where is this " decals on transparent" ? inside the "HDRPRenderPipelineAsset" inspector ?

strong plank
strange fox
#

@amber saffron Thank you again, i've checked every boxes, excepted this one... ^^'

forest hearth
#

Hello, I am using the pixel perfect camera from URP. When I try to get the camera height inside of a shader graph, I get the same value everytime even if I change the orthographic size of the camera (using cinemachine & the CinemachinePixelPerfect extension)

#

The value changes inside the inspector, but not in my shader

regal stag
tight phoenix
fallen crest
#

@amber saffron I fixed the displacement map yesterday. But I have a question about normal map now. Is this correct?

#

the highlighted func basically means this transform node right?

amber saffron
fallen crest
#

here's the full screenshot

fallen crest
#

@amber saffron something is not looking right, the white one is the correct one, but the other one looks similar but not quite.

amber saffron
fallen crest
amber saffron
fallen crest
#

the displacement is okay, not the normal.

amber saffron
tight phoenix
#

before I fall down a rabbit hole, is shadergraph capable of doing this? Im pretty sure its some form of raymarching

#

I have the hlsl file for that shader but I don't know how to read it to translate it over very well

topaz marsh
tight phoenix
topaz marsh
#

from what I know raymarching uses a lot of recursion (for loops with functions) and shader graph doesnt have that

#
  • input for the shader would be hell
tight phoenix
#

Hmm maybe this is an X/Y problem - I'm specifically looking for a way to make it seem like a cube is volumetrically transparent with inclusions that have depth to them
Visual example would be like a blob of resin filled with ink or glitter

#

And that shader there above is the only example file I could find that even remotely began to approach that - the idea of layers of suspended 'texture' within the mesh

tight phoenix
#

Yeah im trying to find a visual example that will explain it more obviously

quick flax
#

Hi, I'm trying to make a special shader where I try to imitate the 'sea sparkle' effect. So when a player takes a step, it kind of radiates a glow into the water. How would you go about it since I don't really know where to start.

tight phoenix
topaz marsh
#

ah

#

I see

tight phoenix
#

transparent object with volumetric 'texture' suspended in it - Im probably misusing the term volumetric

#

in comparison to the dice you can see why I thought this could do it

topaz marsh
#

honestly I cant rally think of a way to do it without just modeling it

#

unless you are ok with the current example and just would like to add transparency

tight phoenix
#

Well, there is a lot more I would want to do with it, all I am really trying to do is get a base line shader that I can then adjust to what I need it to do
I don't know what limitations there are but that looked like a good starting point

#

I've tried 3D noise nodes but the noise isn't 'within' the object, its just plastered on the outer surface

#

I've looked at Parallax Depth maps but I don't think they will work in this use case, since I want things to be behind things, its not just height map depth alone

topaz marsh
#

what kind of "modifications" would you want to do to it

#

the only other shader way of doing what you want would be to make a sort of volumetric cloud shader from the 3D noise u got

#

just really thick

tight phoenix
#

I can look into that, cloud shader

topaz marsh
tight phoenix
#

Yup I have it already

topaz marsh
#

nice

tight phoenix
#

thats the 3D noise I have that I was refering to

topaz marsh
#

ait

#

I though u had a 3D texture

tight phoenix
#

Ah naw textures arent 3D, at least not ones photoshop makes

topaz marsh
#

fair enough

tight phoenix
#

the text of the raymarch (along with a bunch of other superflouous stuff I don't care about like animating the blobs position and color)

topaz marsh
#

could u send me the whole thing

tight phoenix
#

Sure, 1 sec

topaz marsh
#

just a slight modification : )

#

but to make it look like there is resin around the blobs would be hard

tight phoenix
tight phoenix
# topaz marsh

Shader file won't even open in visual studio, getting this error

#

I'm not sure what you changed, this looks like its still a big long shader code thing, I am trying to translate it to shader graph so I can modify it in a way I understand, sorry if I wasn't clear about that

topaz marsh
#

thats odd

topaz marsh
#

got carried away

#

but yeah... not posible

#

but a cool shader tho

tight phoenix
#

Ill keep trying, I'm sure something close enough can be done

topaz marsh
#

Hello, so I'm trying to recreate the effect in this YouTube Short in VR with URP and shader grapth, but it seems that the viewdirection node is returning a vector that is pointing to the camera center and not the center of each stereo eye.

Here is the Short
https://www.youtube.com/shorts/uLN69rtiu4Y

And btw if this is possible to do only with a Shaderlab shader I'm fine with it as long as you point me to a function that returns the correct vector.
(I did not find it here: https://docs.unity3d.com/2020.3/Documentation/Manual/SinglePassInstancing.html)

These small lights hold a little secret; they don't contain anything at all! Another quick answer, a series on quick techniques too simple for a longer video.

Don't worry, longer videos are still coming.

🐦 https://twitter.com/JasperRLZ
💰 https://patreon.com/JasperRLZ
🤼 https://discord.gg/bkJmKKv
🌎 https://noclip.website

🎵 Mike Morasky - Porta...

▶ Play video
mental bone
topaz marsh
#

but the problem is not making the effect

#

problem is making it 3D

#

thus the question

mental bone
#

The parallax node should handle correct eye view direction I think.

grand jolt
#

Is it possible to have a semi-transparent mesh on a UI canvas that overlays on top of UI images?

#

Im trying to figure out the render type and queue but I am having no luck

grand jolt
#

Well I am just using the default Unity shaders, is it even possible to render any transparent mesh on a UI canvas? With proper depth

#

The only way I can think of doing this is to use a render texture and sort with that :\

meager pelican
# tight phoenix Hmm maybe this is an X/Y problem - I'm specifically looking for a way to make it...

Well, you've hit on the term, it's called "volumetrics" and there's tuts and shaders for that. It's basically ray-marching through a substance, and in your case doing refraction too. You're already on that track.

So IDK what more to tell you. You can look for other ideas in perhaps medical imaging where such is common, or in other "shader volumetric" things, like volumetric fog. But that's not helping you much. I mean, there's no magic bullet or technique here, just lots of GPU-expensive hard work. The cloud shader example was a good idea too.

https://www.youtube.com/watch?v=y4KdxaMC69w

Interactive Computer Graphics.
School of Computing, University of Utah.
Full Playlist: https://www.youtube.com/playlist?list=PLplnkTzzqsZS3R5DjmCQsqupu43oS9CFN
Course website: https://graphics.cs.utah.edu/courses/cs6610/spring2021/

0:00:00 Introduction
0:00:17 Applications
0:02:58 Volume Rendering for Visualization
0:28:49 Volume Rendering for ...

▶ Play video
tight phoenix
grand jolt
#

Hi, I'm having an issue, I cannot find a way to add a master node onto my shader, may I be missing something here? I'm really new to Unity

karmic hatch
#

In that case, you wouldn't need to do any marching anything

#

Looping wouldn't be too cheap but whatever

karmic hatch
grand jolt
#

ahhh

#

i see

#

thanks

karmic hatch
# karmic hatch Looping wouldn't be too cheap but whatever

Actually, thinking about it, you might be able to multiply your winnings by using grids of spheres instead of single ones (there's probably a way to check if you hit any sphere in a grid that doesn't cost much more than checking one)

karmic hatch
fervent spire
#

How could I make a shader graph that makes the object ALWAYS render behind a certain object?

scarlet crater
#

Some details seem to just pop in and out of existence when I change perspective. Does anyone have any idea what might be causing this?

grim bear
#

I'm new to shader programming so bear with me,
If i have this kind of texture

#

And i want to have a value from 0 to 1 (vertically) on each "white group", how do i achieve this in runtime?

west eagle
grim bear
# grim bear I'm new to shader programming so bear with me, If i have this kind of texture

from what i understand, what you are saying is not runtime calculation but using external application e.g. photoshop?

sorry for not being clear enough,
the original texture that i shared here is actually from a RenderTexture (from my camera, so it will move randomly on runtime)

and i want to calculate the value from 0 - 1 vertically on each "white group"

because the original texture will change on runtime, i don't think it's possible if i generate other texture using external app

west eagle
#

you have to use ur cpu to calculate dots out of texture then generate a texture with grayscale runtime

#

like iterate all pixels find the highest point of the dots and lowest...

grim bear
#

ahhh i see,
thank you so much

runic pendant
#

Hello, I have a UI rendering question:

#

When using a list view, what are the benefits of using object pooling?

#

Or maybe I am misunderstanding it. From my understanding, simply disabling the "RawImage" component takes it out of the drawcall anyway, so pooling is not a big deal???

west eagle
runic pendant
#

Sorry, I didn't really know where to put it. The ui-ux channel seemed to be artist focused so I asked here because I had a lot of custom shaders in my UI components

#

Wait so there is no point in pooling ui? @west eagle

west eagle
#

yeah,unless you generate bullet with ui

#

bullets like raining

runic pendant
#

Alright, thank you. I was about to spend a lot of time making a pooling system for my list

west eagle
#

do not make your own wheel

amber saffron
meager pelican
# grim bear from what i understand, what you are saying is not runtime calculation but using...

You'd have to use some algorithm to detect the "groups" where continuous shapes exist. You'd then have to pass over the groups and calc the min and max Y value. From that, you can do a simple calc to get the % height.

This can be done in shaders, or on CPU. Compute shaders come to mind in this case, and flood fills, with later passes to detect groups. So each "fill" would be a different value for detection. Then you can pass over and detect areas of unique values.

Maybe....

grim bear
fallen crest
#

do I have to mention anything specific in shader graph for 32bit texture inputs? 1st image is how it should look like, it is the R channel of 32bit image in built-in render pipeline. 2nd one is in HDRP, but it looks like less color depth. I need this for calculating normal and the normal looking less detailed as well.

#

2nd one is not "lit" btw.

fallen crest
#

1st how it should be and 2nd how it is looking in HDRP, see the peaks of waves are missing details

craggy chasm
#

Hi all can anyone help me convert the following into unlit shader to surface shader, I have tried but I dont know how combine the appdata and v2f struct as Input for surface shader.

Below is my unlit shader.

Shader "Custom/Dissolve"
{
 Properties
  {
    _MainTex("Texture", 2D) = "white" {}
    _DissolveTexture("Dissolve Texture", 2D) = "white" {}
    _DissolveY("Current Y of the dissolve effect", Float) = 0
    _DissolveSize("Size of the effect", Float) = 2
    _StartingY("Starting Y point of the effect", Float) = -10
   }

SubShader
{
 Tags { "RenderType" = "Opaque" }
 LOD 100
 Cull Off
 Pass
 {
 CGPROGRAM
 #pragma vertex vert
 #pragma fragment frag
 // make fog work
 #pragma multi_compile_fog

 #include "UnityCG.cginc"

 struct appdata
 {
   float4 vertex : POSITION;
   float2 uv : TEXCOORD0;
 };

 struct v2f
 {
   float2 uv : TEXCOORD0;
   float4 vertex : SV_POSITION
   float3 worldPos : TEXCOORD1;
  };

  sampler2D _MainTex;
  float4 _MainTex_ST;
  sampler2D _DissolveTexture;
  float _DissolveY;
  float _DissolveSize;
  float _StartingY;

  v2f vert(appdata v)
  {
    v2f o;
    o.vertex = UnityObjectToClipPos(v.vertex);
    o.uv = TRANSFORM_TEX(v.uv, _MainTex);
    o.worldPos = mul(unity_ObjectToWorld,      v.vertex).xyz;
    return o;
   }

   fixed4 frag(v2f i) : SV_Target
   {
     float transition = _DissolveY - i.worldPos.y;
     clip(_StartingY + (transition + (tex2D(_DissolveTexture, i.uv)) * _DissolveSize));

     // sample the texture
     fixed4 col = tex2D(_MainTex, i.uv);
     return col;
    }
   ENDCG
  }
 }
FallBack "Mixed Reality Toolkit/Standard"
}
tacit parcel
craggy chasm
tight phoenix