#archived-shaders

1 messages · Page 102 of 1

sly delta
#

Hey guys, im having some trouble with a billboard shader graph.

What happens is that when i build the game, if i have the same sprites in multiple objects in the scene, those sprites dont render correctly unless the camera is around the same direction from all of them.

So, to fix that i've tried to enable GPU instancing (in my head, it creates a different instance of the material) , so that should make the billboard calculations per instance as well.

But no, while that fixes it on the editor, it doesn't change anything in the build.

I've also tried saving the material in variable(read around that forces the engine to create a copy of that material, idk), but it doesnt help eighter.

Apprecciate the help!

grizzled bolt
sly delta
#

Sprite Renderers

grizzled bolt
# sly delta Sprite Renderers

I don't know the specifics but I'd assume it's sprite batching not playing nice with your billboard shader
It might be a better option to do the billboarding with a script instead to avoid fighting it

ebon basin
#

dynamic batching doesnt like it when you touch with the verts

sly delta
#

the weird part is that it only happens on the build.

ebon basin
# sly delta the weird part is that it only happens on the build.

Was just mentioning it, but you can fix it by enabling SRP batching for sprite renders, but that option mysteriously disappeared with unity 6 from 2023+ but I theorize that disabling dynamic batching may force SRP if it's enabled but haven't looked into it much.

sly delta
#

well, is it a problem im using URP?

stoic phoenix
#

I have a question how can i fix shader errors like they are already fixed but when i come to unity there's red text showing that there's an error and it only goes away if i restart unity

stoic phoenix
#

also is there like an inbuilt noise function I can use in hlsl

past dune
#

one solution that I've found is to get both cameras depth buffers and use them to know when to render the overlay the problem is that it is extremely inefficient

#

because it samples two depths buffers , rendering two cameras both textures and depth buffers

smoky widget
#

Hello, I've created a texture2D through setting Color32 structs where each channel is a byte referencing an int. Basically it contains indices

#

How can I properly sample that on the shader?

vast wren
#

guys
i need some help

#

Is there any tutorial

#

or some course

#

that teaches 100% unity shading from scratch

#

I really need it

#

like this course is hosted by Indian Developers but its kinda too expensive for a monthly subscription

grizzled bolt
vast wren
grizzled bolt
vast wren
grizzled bolt
#

There are hundreds or thousands of different techniques, which courses can't realistically go over

vast wren
#

So i cannot fully learn Shading ever

grizzled bolt
#

If you find step by step tutorials how to make a specific effect, you can of course follow it without any prior knowledge to get that effect
You can do that many times and experiment to begin to understand what's happening and how to make your own effects

#

But it's a much quicker process if you know the theory

#

Especially if you want/need to code the shaders
Shader Graph makes shader creation much more approachable, but also hides the technicalities from you

vast wren
grizzled bolt
#

If you don't want to become a tech artist, just make some shaders, knowing all the technicalities may not be necessary as long as you use Shader Graph
But to look at an effect and intuitively understand the techniques and math used, that does require understanding the theory either from study or from a whole lot of practice

vast wren
#

I am more interested in learning shader languages since I plan on writing my own game engine too
So I should at least have some understand of them

grizzled bolt
vast wren
random sequoia
#

Hi! I have imported a character that has a beard. The textures provided are a Diffuse and a Opacity map. Do you know what material shall i use? (the unity project is in URP)

hardy juniper
#

really old things or stuff made for 3d software may still split alpha in its own tex but its an outdated practice

random sequoia
hardy juniper
#

you sure the hair doesnt have alpha already?
is it selected to be imported on the import settings?

#

when you click it, does it say RGBA at the bottom?

random sequoia
#

Both say sRGB

#

These are the import settings:

#

Then i have created a SRP Lit material and i have added the two textures:

#

But this is the result:

hardy juniper
#

im confused, you put one in base and one as metallic but i can see clipping working

#

therefore one has alpha and is working

#

If alpha source is set to something valid + alpha is transparency is true then you will have alpha

random sequoia
#

So the Diffuse should be the Base map

hardy juniper
#

yes

random sequoia
#

With alpha source and alpha is transparency

hardy juniper
#

remove metallic for now and then see how it looks
yea. transparent mode will use alpha from base map (a.k.a diffuse)

random sequoia
#

So there is no need of using a Blending mode?

#

This is what i have got

hardy juniper
#

yea additive is probably not ideal but mess around and see what you get

random sequoia
#

I should get this result

hardy juniper
#

try with alpha clip off too (if you want it on, mess with the threshold)

random sequoia
#

Thanks a lot

#

I will also check Krita

hardy juniper
#

not sure you need to do this but if alpha is really not there on the diffuse then yea krita can be used to add the transparency to it

#

add both as layers then convert one to "transparency mask"

plain urchin
#

Hi. I'm using URP, and will also use GPU Instancing
I generally use 1 texture for all objects containing the gradient atlas
https://itch.io/blog/797457/optimization-of-3d-texturing-for-mobile-games-definition-of-the-gradient-texturing-process-and-analysis-of-its-efficiency-and-performance-in-engine
And have shaders make use of vertex color for some effects

Regarding making variants/batching, if i want variants of the color by moving the UV in the atlas, if i edit the UV of some trees in runtime, will that break batching? Or even better edit only 1x, and use that mesh as the new variant for all trees that have different color?

Or is it better/more performant(?) to make a variant of a material instance? So, having a variable for the UV offset to get the desired color

Since it's URP, i read somewhere that MaterialPropertyBlock does not work here
So out of the 2 options above, which one is better?

ebon basin
#

As far as what I've tested with some voxel projects is that setting the UVs via Mesh API and using a texture array batched fine, but still something to test with the debug tools (the scene statistics aren't accurate for URP/SRPs)

#

Oh, for instancing I'm not entirely sure. Usually that method call is of a specific mesh and material

#

What you can do though is have a material that takes a seeded value that applies the variance to the trees without having to modify it outside of it.

#

kinda of how the terrain does it

stoic phoenix
#

Is there an inbuilt noise function in hlsl

kind juniper
stoic phoenix
#

So I need to write my own noise function?

kind juniper
stoic phoenix
#

Ah I see

stoic phoenix
#

can i like

#

import shadergraph

#

functions

#

into my hlsl or something

ebon basin
#

yes, click the link

kind juniper
#

You can copy it.

stoic phoenix
#

i did

kind juniper
#

I'm not sure you can include the files

stoic phoenix
#

that's not what i want

#

im just looking for libraries to include

#

so i don't have to copy them each time i write a new shader

ebon basin
#

you can include libraries yeah

stoic phoenix
#

ok so how do i download this library

ebon basin
#

Ive not really looked into the generated code from the shader graph. But try making a blank graph with a noise node and open the generated code

#

could be inside of a library, but probably a bunch of other bloat you dont need

kind juniper
stoic phoenix
#
v2f vert (appdata v) {
    v2f o;
    o.vertex = UnityObjectToClipPos(v.vertex);
    o.uv     = v.uv;
                
    // main
    float4 color = tex2D(_Texture, o.uv);
    o.vertex.y += color.x;
                
    return o;
}``` Can i somehow offset the y pos of the vertex based on color like this?
ebon basin
#

sure, why not

regal stag
#

You'd need to use tex2Dlod for sampling in vertex stage

stoic phoenix
amber saffron
stoic phoenix
#

Ah I see

dim yoke
#

In vertex stage, you can just sample at LOD level 0, the full resolution mip level.

past shoal
#

https://www.reddit.com/r/Unity3D/comments/18g4rok/updated_flame_demo_showing_the_movement_reaction/
Saw this cool reddit post of a flame/thruster shader. It looks like its a mesh of some kind but that is as far as I can determine of what this tech is doing.
But yeah, are there any tech savvy vfx artists who know whats going on here? I'm quite new to writing shaders so a lot of the tech is unknown to me.

Reddit

Explore this post and more from the Unity3D community

stoic phoenix
#

How do I create a screen shader for a camera rather than a material?

#

does anyone know

amber saffron
stoic phoenix
#

Yeah, I think it's that

#

how do i make a post processing shader?

amber saffron
stoic phoenix
#

I hate visual scripting ect.

amber saffron
# stoic phoenix Yeah, but not shadergraph

Are you using URP ?
If yes : shadergraph removes a lot of boilerplate code from writing shader in render pipelines, but a post process shader is pretty straighforward and you can probably use an unlit shaderlab shader.

If you are using built-in, there is also a custom post process example for the post processing stack.

stoic phoenix
#

I'm using in built render pipeline

#

also I need to dowload the post processing effects from the package manager right>

dusk sky
#

Why the direction of main light is not correct in scene view...

float4 frag(Varyings i) : SV_Target {
    return lerp(_BrightColor, _DarkColor, step(dot(GetMainLight().direction, i.normalWS), _Threshold));
}
```I'm using unity 6 with urp.
amber saffron
dusk sky
#

This is how (GetMainLight().direction looks like in scene view.
Everything looks fine in game view.

amber saffron
dusk sky
#

Oh wait

dusk sky
ripe sedge
#

Hello everyone, is there any intellisense plugins/tools I can use that specifically includes Unity's built-in intrinsic variables? So far the only leads I have are paid options through the asset store.

quartz sail
#

I have a player character made up of multiple meshes, but it’ll like to apply a vfx/shader graph that I need a skinned mesh renderer, I realized when going to add the mesh component I can only add one single part of the mesh, is there anyway to have the entire player character without joining them all together

I considered importing in a 2nd joined player character then use that mesh for main player character… but the player has multiple hair options and I think if I used the combined mesh it wouldn’t look correct when only having one hair selected

Does that make sense? Is there a solution outside of applying the shader to each part because that won’t give the look I’m hoping for

hardy juniper
solar current
#

I have a question about the performance of branching in vert and frag functions, here's an example that illustrates what I'm trying to do.
Assuming that the three "DoStyle" methods are long and complex, I want to avoid having all three methods processed for each vertex given that the vertex can be set to any combination of the three styles (or none of them). Is the usage of [branch] going to have the intended effect on performance, or is it more computationally expensive to use the [branch] compared to letting the compiler dynamically branch the code?

struct vertdata {
    float style1;
    float style2;
    float style3;
};

StructuredBuffer<vertdata> vertbuffer;

v2f vert(uint id : SV_VertexID, appdata a) {

    v2f o;
    o.vertex = a.vertex;
    o.uv = a.uv;
    o.color = a.color;

    o.texcoord1 = float3(float(id) / float(MaxBufferSize), 0.0, 0.0);

}

fixed4 frag(v2f IN) : SV_Target {

    float4 color = IN.color;

    int id = round(IN.texcoord1.x * MaxBufferSize);
    vertdata v = vertbuffer[id];

    [branch]
    if (v.style1 == 1) {

        color = DoStyle1(color);

    }
    
    [branch]
    if (v.style2 == 1) {

        color = DoStyle2(color);

    } 
    
    [branch]
    if (v.style3 == 1) {

        color = DoStyle3(color);

    }

    return color;
}
kind juniper
# solar current I have a question about the performance of branching in vert and frag functions,...

It might make it more performant. The GPU executes many threads at the same time in what's called "waves"(usually 32 or 64 threads). Even if only one thread in a wave enters your if statement, all the other threads in the wave will have to wait for it, regardless of using the branch keyword or not.
So, [branch] would only help if all the vertices that enter the branch are in the same wave(close together in the vertex buffer I'd assume).

tacit parcel
steep zephyr
#

Hello ! i'm quite new to unity, and i searched on how to activate the UPR when this problem arise but i can't figure it out (i'm a dummy :c). If someone has an answer i'll gladly take it !
For context: I'm making a VR game but i can't figure how to activate the post process to implement some bloom in my game

echo ermine
#

i was messing around with some shaders from shader toy i ported and must have messed something up bad i got a random D3D device lost error but my question is when writing shaders do you have to be careful so you dont brick your computer cause now im scared to mess with shaders completely lol

ebon basin
violet crater
#

can anyone smarter than me tell me which what i should set these rotation numbers of the directional blend to if i want to effectively switch where the grass and rainbow appear so that the rainbow appears on the flatter area while the grass appears on the more sheer area

violet crater
#

I need to find some way to either
Change which texture set is located where in this directional blend
or just find a way to make the detail map be associated with the secondary texture not the first

echo ermine
#

question what should i avoid so this doesnt happen again?

ebon basin
#

Similar coding concepts apply; make sure you're exiting your loops, not dividing by zero, not using null/uninitialized values, ect

#

beyond that it's up to what the graphic APIs and your device supports

haughty lichen
#

Hi guys ! I'm having a hard time making Graphics.RenderMeshIndirect work in HDRP.

I used to use Graphics.DrawnMeshInstancedIndirect but now I need to use light layers and so I'm upgrading the function to Unity's new system.

From the documentation (https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Graphics.RenderMeshIndirect.html)
I should add these directives in my shader

#define UNITY_INDIRECT_DRAW_ARGS IndirectDrawIndexedArgs
#include "UnityIndirect.cginc"

And this in the vertex shader

InitIndirectDrawArgs(0); // pass SV_DrawID semantic value here for multi-draw support

The issue is that it doesn't seem to work in Shadergraph, and I didn't manage to create a simple HDRP-compatible HLSL Lit shader to modify myself...

Does anyone have experience with this ?

low lichen
untold cobalt
#

Hi Guys! I'm having a hard time making TMP Text (in world Space) to only be visible under a light source, otherwise It should blend into darkness. I did write the logic in a duplicate shader copy of TextMeshPro/Mobile/Distance Field. Then I created a material of this shader and drag-dropped into the text gameObject. It didnt totally replace the LiberationSansSDF Material but its parent is referencing to the shader I created. Still I see no such effect working. I did use light position and light range where light position gets updated wherever light moves. Any ways to debug this and find where is the problem? Because right now I am having a hard time understanding what might be going wrong and why nothing is working?

 // Torch visibility calculation
 float distToTorch = distance(input.worldPos, _TorchPosition.xyz);
 float torchFactor = saturate(1.0 - distToTorch / _TorchRange); // 1 when close, 0 when far
 c.a *= torchFactor; // Apply torch effect to alpha
sly delta
#

Hey guys, this sequence is part of a billboard shader for 2.5D style game.

Im using a lit shader graph to be able to use 3D lighting and shadows on these objects. The material goes into a sprite renderer and as such, i cant really use the FlipX property on the sprite renderer to mirror for different directions.

So what im doing is that im multiplying the UV.x by -1. Thing is the sprite gets totally out of center (well.. i am offsetting the UV right). So how would i go about doing this correctly?

ebon basin
hollow cedar
#

I’ve got a quick shadergraph question

Am I able to use shadergraph to actually edit a texture? So for example, sampling individual points on a texture and saving those samples into a new texture? And if so, does anyone know of a guide or any documentation to look at in this regard?

I’m honestly a little fed up with shadergraph and the documentation (or lack thereof) and might just teach myself HLSL (good idea long term for sure) so that I have a better understanding of what shadergraph is actually doing

ebon basin
#

assuming you a need for the shader graph that is

low lichen
hollow cedar
ebon basin
#

it runs for every pixel but doesnt mean you cant logic yourself a way to only select those pixels

hollow cedar
ebon basin
#

right, like think of a mask you multiply with a color and if that mask is 0, then the color output is 0

low lichen
ebon basin
#

well, every nth pixel would be somewhat of a problem

#

not impossible as it's up to how you mask it all

#

more of a job for compute shader though

hollow cedar
# low lichen If you explain what you want to do, we can give you a better answer.

What I’m trying to do could be accomplished on the CPU, but I’m trying to do it on the GPU because of it being time sensitive and the CPU running other critical processes

In essence, I have a texture (not in front of my project so I can’t remember the dimensions for sure, but let’s call it (4000x4000), and I’m trying to sample the texture in polar coordinates with the center of the texture being the origin, and it sampling every .5 degrees and have a radius of 1840. Then it would create a new texture (I know the dimensions this time) 720x1840 (720 for each theta and 1840 for each pixel along the radius at each sampled theta)

#

I was hoping to use UVs in some way to make Unity handle sample points that were between pixels

low lichen
#

Then you just need to calculate the correct coordinate to sample the source texture for every pixel of the destination texture.

hollow cedar
#

Well I understand what you’re saying 😂 I’ll see if I can figure out how to do it lol

Do you happen to know of any code or an existing graph somewhere that I can look at for inspiration? If not, I’ll just make an attempt when I get home and I’ll message here where I get stuck.

I’m a complete novice at shaders and decided to give shader graph a try since it looks like it could help simplify shaders. Clearly not quite the case

untold cobalt
low lichen
hollow cedar
# low lichen It's best to just think about one pixel when creating the shader. Think about ho...

I get that. Where I’m hung up at is that not every pixel will get used, since I’m basically degrading the texture, so it’s difficult to think of the logic in the kind of way.

The two mental hurdles that I have is that:

  1. I’m not sure how to set up logic to tell shader graph when a pixel is relevant or not. So how do I eliminate one pixel or keep another when the shader is being run for each pixel? Would it be as simple as setting up a range of the only relevant coordinates and seeing if the pixel in question meets those relevant coordinates?

And 2) I’m relying on Unity’s interpolation for relevant coordinates between pixels, so I really wanted to use UV coordinates to get “pixels” between pixels. But that way of thinking flies in the face of restricting my thinking to one pixel

low lichen
hollow cedar
low lichen
#

Then there will be no unused pixels for the shader to worry about. You only have 720x1840 pixels to calculate values for, and that's how many shader programs will be invoked.

#

What pixels in the source texture end up getting sampled doesn't matter.

hollow cedar
low lichen
#

Each pixel in the 720x1840 texture is going to figure out what coordinate to sample from the 4000x4000 texture, sample it, and return it (i.e. write it to the 720x1840 texture).

hollow cedar
low lichen
#

Imagine if the shader is just this C# code:

public Color GetColor(Vector2 uv, Texture2D sourceTexture)
{
    // todo
}

How would you implement that? Probably convert the UV to polar coordinate, to then sample the source texture and return it.

#

You can worry about other specifics later, such as what sort of filtering you want to use when downsampling. Bilinear filtering is easy, as long as the source texture has it enabled and you stick to float UV coordinates (in 0-1 range) instead of integer pixel coordinates.

hollow cedar
# low lichen You can worry about other specifics later, such as what sort of filtering you wa...

The filtering isn’t actually important to me on the source side. I guess I should mention what I’m doing. I’m building a proof of concept for a bigger project.

I’ve essentially gone into photoshop and created a fake weather radar image like what the picture I attached (without the map underneath). US radars get data every half a degree and have a range of 460k km (but each data point along that range accounts for 250m), so that comes out to 1840 data points per half a degree rotation. So I am attempting to “scan” the image I made in the same way US radars scan, and export that data into the 720x1840, where the 0,0 pixel would be the 0 degree rotation and 0m-250m data. The 0,1 pixel would be the 0 degree rotation and the 250m-500m data. The 1,0 pixel would be the .5 degree rotation and the 0m-250m data. Etc etc.

Doing it this way gets it into a format that would be similar to what I will eventually use for real data. But first I need to make my fake data look real.

Since I’ve basically already done the “interpolation” when creating the image. And now I’m blocking it up the way a radar would to eventually display it in the way that we traditionally display radar data

#

My final shader will have the 720x1840 texture wrapped into a circle and interpolated using a nearest neighbor interpolation

#

@low lichen you good with moving this convo to a thread?

sly delta
hardy juniper
#

@sly delta remember that sprite renderers make a mesh with uvs specially to fit the sprite in the spritesheet so inverting uvs by doing 1 - uv.x wont work.
It can work if you provide the min/max range to the shader and inverse lerp then lerp back.

main totem
#

So I was working in shadergraph on the built in pipeline, and I noticed these nodes. What the heck are they? Does anyone know?

#

Specifically Reflectance and Specular Occlusion. Never seen them before

grand jolt
#

can someone help me the shader is stretching on the bottom and top im using the shader graph

royal aurora
#

AAA games would have you cough up a big $20 for this.

main totem
#

So I know this might seem like an odd question, but does anyone know which blend mode is most similar to the mix blend mode in Blender?

ebon basin
#

We talking about the mix node? It's most likely a lerp yeah

untold cobalt
#

Hi Guys! I'm having a hard time making TMP Text (in world Space) to only be visible under a light source, otherwise It should blend into darkness. I did write the logic in a duplicate shader copy of TextMeshPro/Mobile/Distance Field. Then I created a material of this shader and drag-dropped into the text gameObject. It didnt totally replace the LiberationSansSDF Material but its parent is referencing to the shader I created. Still I see no such effect working. I did use light position and light range where light position gets updated wherever light moves. Any ways to debug this and find where is the problem? Because right now I am having a hard time understanding what might be going wrong and why nothing is working?

 // Torch visibility calculation
 float distToTorch = distance(input.worldPos, _TorchPosition.xyz);
 float torchFactor = saturate(1.0 - distToTorch / _TorchRange); // 1 when close, 0 when far
 c.a *= torchFactor; // Apply torch effect to alpha
steel notch
#

In what cases would you NOT enable mipmaps 🤔

leaden mason
#

Hello,
I am using shader graph in URP.
I am loosing my mind here.. I'm trying to have a linear gradient from the top to the bottom of an object. Nothing crazy. I need it to be independant of the orientation of the object (otherwise I would just use the object space Y).
My logic is that I would get the world space position, split the Y and remap it from (MinBounds.Y, MaxBounds.Y) to 0 to 1.
But I get a magenta output. Clearly I am doing something wrong, but I have no idea what ..

shadow kraken
leaden mason
#

the preview in the graph is magenta, probably because I have min and max set to the same value.
But it doesn't work in game either .. it returns purue black, no matter the object I choose (default primitives too).
I'm using 17.0.3 of URP ..

hardy juniper
#

nvm i cant read

leaden mason
shadow kraken
#

Huh that's interesting

flat hedge
#

Is there a way to ignore the object scale in a canvas shader urp?
As you can see, it's supposed to be a rectangle with equal edges but gets stretched as I change width/height/scale.

keen hearth
#

Use a tiling and scaling node

#

Set tiling to be whatever the scale ratio of your object is

flat hedge
#

I tried this but it only resulted in weird tiling:

flat hedge
#

Yeah, I have no clue what I'm supposed to do.
This is the closest I've got to a proper looking shape, however, it clearly goes out of bounds and is still deformed :/

ebon basin
#

otherwise keep the aspect ratio the same

flat hedge
#

can this be done with a shader or do I have to have a sprite that I apply a shader on top of?

ebon basin
#

Actually not too sure. It does seem like the rounded rectangle generates something relative to your UVs, but maybe it's not refined enough to really give you those edges

dreamy surge
#

I was wondering if someone might be able to get me pointed in the right direction for this. I use Enviro 3 fog, but only one wall doesn't seem to account for the fog distance. I don't see anything different about the material or shader that would give this result though.

#

Please let me know if I should post this in a different channel.

#

Game objects are set to static. I haven't tried baking lighting yet.

ebon basin
#

Maybe check if you're writing to depth as well

keen hearth
main totem
# hardy juniper Lerp?

It appears to be a similar effect, thanks. Now I gotta figure out why the material seems abnormally dark. Would the add module be the same as the add shader module if I'm doing it on a per channel basis? Like adding the diffuse and normals together?

hardy juniper
#

but why would you add diffuse and normals

hollow cedar
#

Is it possible to take two different UV maps in shader graph, split the channels of one and remap it to act as a variable in an equation done on the first UV map?

So for example, if I want to have an equation for my first UV map of:

x = .5 + r * cos(theta)

Could I use a separate UV to bound r? So take the R channel of the second UV and remap it so the R channel goes between .000271 and .5?

hollow cedar
#

Dope, thanks

hardy juniper
#

its just vectors and numbers so you can do whatever

#

you can sample a texture with any vector2 so you can change things as you wish

ebon basin
#

You can also encode your model with multiple UV maps and export it, but if you're baking light then you shouldn't bake to UV channel 1

hardy juniper
#

encode? but yes models can contain multiple uvs and you can pick what you want in your shader

main totem
#

Also I was referring to the vector add node in Unity and the Add Shader node in Blender.

hardy juniper
#

You can for sure sample 2 diffuse and combine them how you want and do the same for normal maps (I forget the best way to combine normals however)
Both are just colours that are combined to a new colour

dreamy surge
main totem
hardy juniper
sly delta
#

Hey guys. im having a strange problem happen.

Im using unity 6.0.19f1 and i created a shader graph that gives me the following error :

if i close the project, clear the library folder then open it back up it works fine. It also works with the error, but i'd rather not have this polluting my console. Does anyone know what to do?

main totem
main totem
#

I think the Normalize does the same thing, but for vectors, it maintains the direction but clamps the value to 1

#

Actually the way its worded it always has a length of 1

hardy juniper
#

when you sample your normal tex it will be in the range 0-1 till you do xy * 2 - 1

#

Though i presume in shader graph you dont do this step

hollow cedar
#

Just to confirm a suspicion of mine, by manipulating UVs in specific ways, I should be able to create custom interpolations, right? Like for example, if I knew exactly where each data point in a texture was, I could make the corresponding UV pixels blend with the pixels around them in a way that would be the same as an inverse distance weighted interpolation, right?

iron scroll
#

greetings esteemed shader wizards, I would like to learn what's the best/most performant way to shade a small sprite so we can animate it like this:

#

I figured I would need at least 2 float inputs, but no idea how to create a shader graph that would correctly render this in a flexible way

#

any help is greatly appreciated!

ebon basin
iron scroll
#

we are talking like 10k-100k instances, as this is DOTS stack. that's why I'm asking, as I don't have any intuition on how to make it performant

#

actually one way is to have hardcoded texture frames for every possible combination (assuming some max width) and just animate UVs switching to the correct frame that has desired number of red/yellow pixels

#

but that's ugly and not flexible for sure, although super easy on the shader I guess

ebon basin
# iron scroll we are talking like 10k-100k instances, as this is DOTS stack. that's why I'm as...

https://www.stevestreeting.com/2019/02/22/enemy-health-bars-in-1-draw-call-in-unity/
This was kind of the idea back in built-in, but MaterialPropertyBlock isn't something you use with SRPs. The SRP batcher may be fine such that creating multiple materials would be batched by it assuming they're similar enough, but otherwise I'd go with an instancing approach and look into using the graphic's API with methods like https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Graphics.RenderMeshIndirect.html

#

Not entirely sure about DOTs though and tying it all together

lean phoenix
#

Hey guys, how to write a pixel art shader for a 3d game?

iron scroll
hardy juniper
limpid yew
#

why do vertex colors show on the object?

#

instead of the red there's supposed to be an another texture

kind juniper
#

Ah, the uvs are from the tiling and offset node. Still looks weird to me.

#

It's like it doesn't do anything at all

#

Can you not just get rid of the split and the tiling nodes?

torn palm
#

I'm trying to sample a texture on top of a tilemap that use auto tiling rule. I almost did it but the texture seems blurry.

In my screenshot, you can see the difference using the same exact texture.

kind juniper
torn palm
#

Ok so I am creating a processor to handle the shader.

I am pasting the shader on top of my tilewalls.

I am detecting for the background tile to determine which texture to apply on the tilewalls.

That's the summary of what I am trying to achieve.

I also am trying to use 4 differant texture per tilewalls that will be placed based on X and Y position.

After that I want to apply a blending effect that will determine if the texture above, below, and on both side are crustrock or dirt and the crustrock tilewall will apply a "blending" effect that transition from crustruck to dirt texture. But I'm not doing this part until I can see the texture without a blurry effect.

As you can see the texture I show above, the texture on the top is already doing that blending effect, later I will try to do the same with tilewalls that are, for now, blurry.

Processor:
https://pastebin.com/5Eg3Qc1b
Shader:
https://pastebin.com/g3aPqwmF

#

I have done a lot of debug and testing too.. Idk where to start with that

#

I noticed applying the shader on other tile that aren't using auto tiling rule don't have this blurry effect.

#

I got a feeling the problem is not the shader

#

But then again, without using the shader the auto tilemap was having normal texture, no blurry effect.

#

1: Auto tilling rule with the shader cause blurry
2: Auto tilling rule without shader has no problem
3: Shader without auto tilling rule has no problem

little wing
limpid yew
#

its still red

boreal totem
#

i have a displacement matrix for my object
how do i actually move the object based on it
it's bot left node (GetInstancingPos(out Matrix4x4))

jolly pulsar
#

I have a problem with my scrolling UVs shader, for some reason it won't make my texture show up no matter how high or low the tiling is set. These two errors are showing up, idk what they mean and i'm not finding comprehensible answers on internet. The Uvs are fine (as shown in 3dsMax) and the shader looks like this. any tips ?

iron scroll
#

the top part is compressed but it's just padding

copper falcon
#

Question around TexelSize. Unity insert _MainTex_TexelSize and _BlitTextureTexelSize which according to BingChat contains this.

I can not find any sources for that. Any sources are someone says thats what it is.
What it this as a technical term? Is that documented? Can't find things about TexelSize in the Unity Manuel and the ShaderGraph Manual explains that it ises uses z and w as node outputs.

copper falcon
eternal crater
#

For some reason my render feature looks pink in the .exe but in the editor it looks normal

kind juniper
eternal crater
#

Thanks! I'll try that

steel notch
#

If you guys had to make a gradient texture for gradient mapping, what resolution would you pick?

neon mason
#

Has anyone used the new shader graph samples (UGUI Samples)? I have a question about UI blur. I have a panel with a material with a shader and a subgraph that should do blur. The panel should be dark, that is to darken what is behind it and blur at the same time. The problem is that if its color is black, the blur does not happen, and if white - everything is fineUnityChanwow

hardy juniper
regal stag
#

Branch nodes use ternary operator though which in hlsl always computes both sides, so should be fine

steel notch
regal stag
steel notch
regal stag
hardy juniper
#

I read recently that this is not the case with open gl so tbh i dont fully know how the branching will be on some platforms

teal igloo
#

hello how can i make so this is between one color and another? in shader graph

#

actually never mind that since i can just plug it into the opacity of the blend, but if someone knows it would be usefull for the future, thanks

steel notch
teal igloo
#

i think i could by just blending it, but that would be +1 blending in the shader so i will just plug this into the opacity i guess

hardy juniper
#

you can use the gradient output to lerp between 2 colours

#

or multiply red against the output

steel notch
teal igloo
#

one more question, how could i make so that this is different for every single object? so i dont need to make a material for each seed and so on

#

also ignore that random UV node up left, forgot u dont need to make one lmao

ebon basin
#

Built-in you'll want to use materialpropertyblocks

teal igloo
grand jolt
#

Hi, I'm trying to make an object outline shader with shader graph and can't get to show the object in front of the outline. I've seen a couple of tutorials but didn't find any over complicated solutions that ended up with visual artifacts or the outline hidding between outlined objects. Could I, please, get advice or a working tutorial link? thx in advance

karmic hatch
#

so vertex normal -> -vertex normal

raven forge
#

I been trying to find/create a lit PSX shader in unity, with pixel snapping and all those things to make stuff look like ps1, but i can't find anything related to that, someone knows how can i make something like this for unity 6? Doesn't matter if it's shadergraph or just a .shader file UnityChanSalute

iron scroll
hardy juniper
grand jolt
hardy juniper
#

Sometimes we can avoid a branch by using lerp or other mathematical operations to produce the result

karmic hatch
#

(which should then cull the front face, since it's inverted)

iron scroll
#

btw any ideas on how to render text in a shader? is it possible to generate any sequence of digits? or is it better to procedurally create submeshes for each digit and set UVs to render correct digit?

hardy juniper
#

That is what tmp does

#

This explains it and goes over his complex way
https://youtu.be/SO83KQuuZvg?si=wD5EcCZ83bbe1x3W

This... is text! Let's figure out how to draw it.
Starring: Bézier curves and (oh so many) floating point problems.

Source code: https://github.com/SebLague/Text-Rendering
If you'd like to support my work (and get early access to new projects) you can do so here:
https://www.patreon.com/SebastianLague
https://ko-fi.com/sebastianlague

Resource...

▶ Play video
short orbit
#

https://www.youtube.com/watch?v=FACSX6cxv4c
I made a tutorial on how to make a "retro filter"

Easy way to add a retro effect in your game, pixelization, dithering and a color palette!

【🟩 Assembly Required】https://pxldev.itch.io/assembly-required

【🟥 Shader & Palettes】https://pxldev.itch.io/easy-dithering-and-color-palette

【🟦 Bayer Matrix】https://github.com/tromero/BayerMatrix

#gamedev #shadergraph #unity6

▶ Play video
crystal sky
#

can someone tell my why unity is not showing textures correct?

hardy juniper
crystal sky
#

Yes it not the same

kind juniper
grizzled bolt
#

The main difference I see is that blender's bloom tints towards white, while Unity's is pure cyan
Which might just indicate the emission intensity is not high enough in Unity, or the color is too saturated

low lichen
left pecan
#

hey guys, quick question
we know UnityObjectToClipPos(vertex) converts from object space to clip space
but if all objects are all centered in (0,0,0) in object space, how can UnityObjectToClipPos(vertex) know that one's center is in a place and the other's is in another?
if we are talking about the same vertex of 2 different cubes with the same rotation, wouldn't these vertices have the exact same object space position, thus being mapped to the exact clip space position (even if they are very far from each other)?

low lichen
# crystal sky fr?

Try it. 1/255 red will hardly change the color, but it will bloom to white like in Blender.

low lichen
#

So if you're calculating world position in your vertex shader for other reasons, it's more efficient to convert that directly to clip space than to use UnityObjectToClipPos.

left pecan
#

oh, so the secret is the Model matrix, right?

#

I had in mind all matrices were the same for all vertices but looks like the Model matrix is object-specific (e.g. each mesh has a different Model matrix)

#

but View and Projection matrices are the same for all objects

#

is that correct?

low lichen
#

Yes

left pecan
#

thanks! makes much more sense now 😄

summer yacht
#

Hi guys does anyone know hot do i apply an unlit shader to TMP text? I've tryied literally everything and can't get it to work...

low lichen
# left pecan thanks! makes much more sense now 😄

Dynamic batching can mess with the model matrices though. When it combines the meshes, it moves the vertices in world space, so in that case you can have what seems like the same model in different places but with the same model matrix. That can mess with shader effects that rely on accurate model matrices.

low lichen
summer yacht
#

Ok thanks, then i guess that i'll have to mess with hlsl code

summer yacht
#

Ok, I managed to get this to work. I copied the shaders used by TMP and modified them to get the result I wanted. The only problem is that the TMP script, for some reason, automatically replaces my custom material with the default one. I modified the TMP_BaseEditorPanel.cs and somehow managed to avoid this issue, but Unity is literally warning me not to modify asset packages because they can revert changes without any warning.

#

I'm wondering why I have to go through all this hassle to achieve something so basic

hardy juniper
#

Are the included HDRP and URP lit/unlit shaders not enough?

hardy juniper
low lichen
hollow cedar
#

Quick question, are shaders on materials, specifically ones that edit how a texture is displayed, run just once or are they run each frame?

hardy juniper
low lichen
summer yacht
low lichen
hollow cedar
low lichen
#

If you are using a Custom Render Texture with a material like I suggested last time, then it depends on the update mode setting you have on it.

hardy juniper
hollow cedar
low lichen
hollow cedar
# low lichen There must have been some additional context in those threads that prompted thos...

That was kind of my assumption too, so I was confused. Not sure what they meant. The most ready example I have is from stackexchange: https://stackoverflow.com/questions/5109404/use-shaders-to-compare-images

#

But it is a fairly old thread, so perhaps that was when GPUs were less advanced

hollow cedar
low lichen
#

You can create a thread here if you like. If I have something useful to say, I'll say it in the thread. If not, hopefully someone else will.

hollow cedar
#

Awesome, thanks!

low lichen
#

It would be wrong in 2011, too.

#

At best, you could argue that if you don't already have these textures on the GPU, then the extra overhead of setting up a GPU context just to do this comparison is not worth it. Especially if the textures are relatively small. But that nuance is not expressed in the answer or the question.

hollow cedar
#

And just to verify the solution I have in my head, am I safe in my assumption that the polar coordinates node has the theta values in the R channel and the radius coordinates in the G channel?

low lichen
hollow cedar
low lichen
elder halo
#

Hello, I cannot get rid of this subtle background and edges in shader graph, It works fine with unlit material, but i want a lit one, i tried with alpha channel and without, i tried alpha clipping, im unsure how to get rid of it

grizzled bolt
queen stream
#

ive got this graph that does a little distortion effect fresnel. from some angles the fresnel looks correct, but at other angles, the fresnels size gets larger

hardy juniper
#

My first thought was not correcting the colour to a pos from the normal tex but the node may do this for you already in "Normal" mode 🤔

queen stream
#

that might make it a little clearer with how the normal texture changes

regal stag
queen stream
#

that did it!

regal stag
#

Shouldn't need to add to the normal vector, that's already handled in the transform

#

But I guess might adjust strength (if that's what you want might be better to use Normal Strength node in-between the sample & transform)

queen stream
#

oh so it does

golden copper
#

Has anyone played with vertex animations for characters and if so do you know of any plugins or tutorials on getting started in Unity, I feel like I'm missing something and just not finding the info right now

hollow cedar
#

Is it possible to have shader graph tell you what the min and max values of a channel are, as opposed to it just showing you the gradient when you preview the channel?

waxen ridge
#

I am using unity 2022 with URP.
I need to switch from Forward rendering to Forward+, since I am building an rpg where I need to support MANY lights.
Unfortunately, some of my objects are flickering HEAVILY if I do so.
I tried adjusting the cameras near / far clipping planes to no avail. From what I can tell, many of the materials / shaders that are flickering have been made with Amplify shader. Is there anything I can do to fix the problem?

harsh mirage
#

Hi everyone i am having trouble with the unity TerrainDemoScene HDRP. I am getting this error on the speed tree shader graph

copper falcon
waxen ridge
copper falcon
copper falcon
# waxen ridge yeap 🙂

For every technical problem there's a youtuber form india to solve it.

This guy shoes how to write a *.shader for URP that works for both forward and forward+
It is for Unity6, documentation about it was kinda "not good" during previous versions, but it can maybe teach you how to rewrite the light loop to forward+ directly in your shaders.
https://www.youtube.com/watch?v=B9fNaAAADnE

In this Unity 6 shader tutorial, I will show you how you can write lit shaders using Universal rendering pipeline aka URP. Furthermore I will also show you how to cast and receive shadows on the geometry.

This is the third episode of "Shaders for Programmers" series. https://youtube.com/playlist?list=PLaE0_uENxXqsd-Ys_Hl2A83axiyTBVsRc&si=x19Zt-...

▶ Play video
teal igloo
#

has anyone made any shader for outline? i tried a lot of methods but none work, i dont want fullscreen, im trying to make it only one object

waxen ridge
ebon basin
teal igloo
ebon basin
#

Silhouette Buffer is relatively easy and probably the best looking for the least effort since the quality of the model also matters in the equation usually

#

you just dont get the benefit of inner/rim outlines

teal igloo
#

sorry im pretty new to shaders, if you maybe already did it or anything it would be very helpful, ive been struggling with making a outline shader for a long time, my old method was just rendering the object but back, but that had a lot of bad things

ebon basin
#

There's plenty of these you can find around on blogs or youtube. Nothing that uncommon

teal igloo
ebon basin
gilded nest
#

I made a custom shader, employing similar lighting to URP simple lit. It works good in game and prefab editing mode, however the prefab thumbnail shows it completely dark lighting. However, clicking on it and looking at the other preview that shows in the inspector panel, shows correct lighting.

I tried a hacky fix: implement a minimum ambient light field. This did work to make the prefab thumbnail appear less dark, but I want to try fix the root problem without weird workarounds.

Anyone else encounter a similar issue and manage to fix it? (I tried restarting Unity, reimporting assets, but didn't resolve issue)

cedar sand
#

how does one pass a Texture2DArray into a HLSL function using a custom function node and sample it in HLSL?

hardy juniper
regal stag
hardy juniper
#

Oh i may be thinking of other types

#

I wanted once to have a vec4 array

regal stag
#

Or SAMPLE_TEXTURE2D_ARRAY_LOD(tex, tex.samplerstate, uv, sliceIndex, lod) if sampling in vertex stage

cedar sand
regal stag
cedar sand
#

I do know a maximum length, so which would be preferred in that case? I was not familiar with the those tags

cedar sand
#

nevermind, it was an oversight on my end. Thank you for the help!

muted laurel
#

so I got this thing where I want to place various buildings - what's the best way to do a shader that highlights the preview green if it's a valid placement and red if not?

hybrid flax
#

I'm very new to HLSL. Is there a reason why const float pi = 3.1415; works inside a function but when I put it outside the function it acts like it is a zero?

hybrid flax
gilded nest
#

Does anyone know the best way to approach if we have multiple small grass tiles, but we want to apply a single seamless texture across all of then (make them not look like individual tiles), what's the best way to do that?

My only idea was to sample from world-space rather than individual object position. This works great, but has the issue if the grass section object moves down in game, the texture looks statically painted on it.

The only workaround I can think of is to introduce a _WorldOffset into the shader, and then use C# code to change that accordingly to how the grass section object is moving down in game.

While it works, would there be any better way that wouldn't require any C# code?

round geyser
#

hi gang i am using a shader graph -> hdrp lit material; how does one do displacement?

#

i'm aware of the parallax mapping nodes but idk wth to do with the output

amber saffron
amber saffron
muted laurel
#

how can I highlight objects? lets say... make them glow green or red based on whatever my mouse is pointing at?

strange prairie
muted laurel
strange prairie
#

That's URP - although I don't think it matters

low lichen
# muted laurel

Okay, URP has a Renderer Feature called Render Objects, which can be used to implement a highlighting feature in a simple way.
The idea is to draw a second pass on top of highlighted objects to add a transparent glow on top. You can add fresnel or whatever you want to make it look interesting.

#

The Render Objects feature can be configured to draw all renderers with a certain rendering layer again, but with a different material. That would be your transparent highlight material.

strange prairie
#

What do you want the glow to look like?

muted laurel
#

ok - so lets say I can raycast and get the gameobject that I'm looking at in a variable like GameObject highlightObject, then I can add this second pass at runtime to the renderer of the object? or something like that?

strange prairie
#

It'd be a material property

low lichen
muted laurel
# strange prairie What do you want the glow to look like?

right now it's pretty open ended... there's actually two spots in my game that would probably need a feature like this - one is just perhaps either outlining the object under cursor or literally highlighting it to be like 1.2x brighter or whatever, and the other is placing buildings in a grid, and if it's placeable it should be tinted green, and red otherwise

#

so nothing too crazy i think

strange prairie
#

Right. I'd just use the emissive property that's probably on your default material already. Then the bloom effect to make it glow.

#

But the renderer feature approach sounds more flexible

muted laurel
#

I am unfortunately still confused about render features

#

is it possible to make a shader graph and just apply it to a gameobject at runtime

strange prairie
#

Sounds like a good opportunity to learn then

strange prairie
muted laurel
#

models can comprise multiple materials though right?

strange prairie
#

That's true. But you could swap them all

muted laurel
#

mm okay, that also sounds like I'll lose all the texture information and whatever if I do this

#

so like just brightening the object won't work that way (if I understand correctly)

strange prairie
#

It's better done as a property on the material, I agree

#

But you could theoretically assign the texture as well

muted laurel
#

ooo so ok

#

I've added this to my renderer

#

and I put the layer mask to the layer I want

#

and if I drop a shader graph into the material in the Overrides section, it'll use that instead? or on top of the previous pass

strange prairie
muted laurel
#

the field as in variables inside my shader graph?

strange prairie
#

Yes

#

It's probably _MainTex

muted laurel
#

oh wow it works

#

excellent

#

thanks guys

#

how would I add bloom on top of this? just by increasing the emissive intensity in my shader?

strange prairie
#

Yeah, bloom works with a threshold. If the brightness of something increases the threshold it'll glow

#

This requires HDR rendering

muted laurel
#

oh uh

#

how would I access the shader parameters from my script

strange prairie
unborn sable
#

I get this error when trying to build with the full screen renderer feature. Does anyone know the solution? I've already tried:

  • Changed the computer language and region.
  • Tried it in another version (I'm using Unity version 6000.0.44f1).
muted laurel
#

I got it to work, but only with global parameters in the shader, which I guess makes sense. If I needed to have it work by individual object e.g. highlight one a specific color, another object a diff color (simultaneously) I suppose a renderer feature wouldn't actually work im guessing

heavy sinew
#

Hi all! Does anyone know of a way to change texture filter mode globally for all textures at runtime? I'd like players to get to choose between point and bilinear. I could not find any material on google

glacial chasm
#

Has anyone here had any luck making a wire frame shader for use on vr only projects (so compatible with android builds)? i've got one that works on pc builds, but when I do an android build, it is just green and white lines flashing around the screen like a strobe show. lol.

compact bronze
#

Hi, does anyone know how data from terrain layers is transferred to (HDRP) TerrainLit shader? I'm making a terrain shader from scratch and I cant find the math of fragment function as the TerrainLit shader is completely filled with #include directives. So, how do I get terrain layer data in my shader?

amber saffron
strange prairie
#

You'll need to do it yourself though if you want more than 8

#

Texture2D is equivalent to:

#define TEXTURE2D(textureName)                Texture2D textureName

on DirectX

harsh mirage
solemn narwhal
#

does anybody know why in blender my material looks fine but in unity all the vertical ones are stretched out? It is properly UV'd

regal stag
solemn narwhal
#

Oh on the texture itself, it is on repeat already :(

#

that's weird under the UV checker it's all messed up

#

bruh somehow there was 2 UV maps in blender it's fixed now

ancient nebula
#

using unity 6 urp

gilded nest
#

For making a custom HLSL shader, what's the best approach to make it copy the same lighting as URP Lit/Simple Lit? Is there an easy way we can "inherit" from URP Lit shader, or pass it off to URP Lit at the end, to avoid needing to write extra lighting code to mimic URP Lit lighting?

For now I used https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/Shaders/SimpleLit.shader source code as a reference to implement into my shader, but just curious if there's any easier way.

GitHub

Unity Graphics - Including Scriptable Render Pipeline - Unity-Technologies/Graphics

topaz swan
#

hello, I am new to urp shader graphs and I was tryng to make a fullscreen shader graph that posterized the screen, but it just turbed pink and blue. could anyone help me with this?

ebon basin
#

which is a render texture of the frame

ebon basin
#

no

topaz swan
#

its like the camera effects there where it limits the amount of colors on the screen at once

#

i will try the scene color one though thanks

ebon basin
#

Ah, I've made something similar before. Not entirely sure how the node works, but I would just lerp a range of color values

signal garden
#

I am trying to raycast from each pixel in the fragment shader. Does anyone know how to calculate the ray direction for each pixel?

tough lichen
#

Hi, I have an issue with my UI shader in Unity that's supposed to generate a dot pattern based on the RectTransform size of an Image. It works fine when I use a sprite with Sprite Mode set to Single, but when I switch to a sprite from a spritesheet (Sprite Mode: Multiple), the pattern gets messed up and doesn't render as expected. Any idea why this happens or how to make it behave the same with sprites from a spritesheet?

frosty linden
#

Hi, using HDRP and building my game, is it normal for shader compilation to be so slow ? It's currently increasing by ~17 each 15 seconds... So so slow... Is this normal ??

#

now it moved to forward hdrp lit and again 17 each 15 sec. It's crazy slow!

frosty linden
#

I've canceled and restarted the build, why does it says 3m / 7m? what does those numbers represent ?

grizzled bolt
wispy abyss
#

How do I fix this problem?

#

The shaders seem to be the problem, but I don't know how to fix them.

grizzled bolt
wispy abyss
grizzled bolt
# wispy abyss It's the second one, but is there a fix to it?

If it's one of Unity's built in shaders, Unity's material converter can swap it or you can swap it by hand to an equivalent default shader
If it's a custom shader, there's no conversion process so your first option would be to find a version of the shader made for your project's RP

#

Asset store assets often include a package inside them for specific render pipelines, if they officially support them

wispy abyss
#

Ok I'll try it thank you very much!

grizzled bolt
# wispy abyss Ok I'll try it thank you very much!

If it is a third party asset and there is no alternative shaders so it's simply incompatible with your RP, you are short on options
The only way to truly convert it would be to effectively make the shader from scratch for your specific RP
You can always swap the shader for one your RP's default shaders and it'll work but you lose any custom shader effects

wispy abyss
#

I know

#

Thanks

frosty linden
#

And it's compiling the shaders again for each platforms, windows, linux and mac :/

#

1h each time to compile. On a small project using only built in shaders, that's really weird

#

My project is currently on a HDD but windows is on a SSD. Will it be faster if I move the project to the SSD? Or only unity needs to be on the SSD?

amber saffron
# frosty linden 3m shaders? How is that possible?

3M variants of the HDRP/Lit shader.

The number of variants is based on the keywords permutations and combinations of the shader. The HDRP/Lit shader is quite complex and has a lot of options, so depending on how you use it on the various materials in the project, the number of needed variants can increase exponetially.

grizzled bolt
#

Correct me if I have misconceptions but the idea is that a variant must be made for every combination of disabled/enabled shader feature
Because a shader must always run every calculation, a whole another shader variant is required to exclude unnecessary calculations at runtime

amber saffron
#

Yep

grizzled bolt
#

HDRP Lit is particularly hefty, but graphics settings lets you disable shader features and graphics APIs supported by the application to reduce the necessary variants

#

Also, it won't generate them from scratch for every build if you've built and generated the variants once already

#

Having the editor and/or project on an SSD is always more helpful than not but I'd guess this process is almost entirely up to CPU speed

kind juniper
#

And in general, developing without SSD is a nightmare.

#

Compiling involves a lot of small read/write to disk operations, so hdd can be a huge bottleneck.

strange prairie
#

Well, you can share the actual lighting function but you'll need to duplicate a lot.

strange prairie
frosty linden
kind juniper
#

Not possible and neither that would help, as most of the intermediate files that unity read/writes are in the library folder.

frosty linden
#

Built game is 1Gb. The unity folder is 14Gb :/

kind juniper
#

Developing has some requirements. Like disk space

frosty linden
#

And that's a small scale project :x

kind juniper
#

Or maybe a lot of assets

#

But generally, 14 GB is very little in game dev context

#

Some projects could go to hundreds GB or even terrabytes

frosty linden
frosty linden
kind juniper
#

Different platforms require different binary code. This is true for all the compiled code. Not just shaders.

hollow cedar
#

What does the length function in HLSL do? There’s not great documentation on what it does mathematically

hardy juniper
hollow cedar
#

Gotcha, so if it inputs a vector 2, it outputs a vector 2 with the magnitude at each point?

hardy juniper
#

its return is size 1 so it would be float/single/half or whatever the num type was

hollow cedar
hollow cedar
# hardy juniper should be the magnitude of a vec2/3/4 I think 🤔

Okay, follow up question then, does length get called for each pixel and it outputs the magnitude as a float of each pixel?

Particularly, I’m looking at the Polar Coordinates node in shader graph and it uses length to calculate the radius, but I don’t see how it manages to iterate through all possible radius values if length only outputs a float

hardy juniper
low lichen
hollow cedar
low lichen
#

It's even better than that, a modern GPU has thousands of shader cores, so it can execute thousands of shaders in parallel.

hardy juniper
#

err not fully, the gpu can execute many fragment/vert shaders in parrallel

vast quiver
#

ok i think this counts as a shader thing, im trying to get this effect (1st screenshot) where i can see an object through a flat model with a fractal/kaleidoscope shader on it, but im having this issue where you can see another object with the same shader through it (2nd screenshot). what would be a good way to go about doing this

hollow cedar
#

Just coding side wise, even if that’s not how the architecture actually works

hardy juniper
low lichen
#

A better equivalent in CPU code would be Parellel.ForEach or a IJobParallelFor in Unity.

hollow cedar
hardy juniper
#

you are not transforming the pixel but i presume using polar coordinates instead a traditional 2d UV to sample a tex or do something different.

hollow cedar
hardy juniper
#

If you check the unity node code they correct the center in theirs to be 0.5, 0.5

#

the doc page for ALL shader graph nodes show the code they use

hollow cedar
hardy juniper
#

oh sorry i miss understood

hollow cedar
#

So pixel 0,0 is the center when I need the output center to be .5,.5

#

I’ve built my polar coordinates equation on paper

hardy juniper
#

do abs(uv - (0.5, 0.5))

#

without abs if you want negative

hollow cedar
#

That’s the same code they use though without abs

Their code is UV - Center (where center is a vector2) so if my center is (.5,.5), it would be what the polar coordinates node defaults to

hardy juniper
#

you can correct it before, then correct back after

hollow cedar
low lichen
# hollow cedar I get that my “it’s a for loop” is an oversimplification, and outright wrong in ...

Sure. A small improvement to your for loop equivalence is to think of it like this:

for (int x = 0; x < width; x++)
{
    for (int y = 0; y < height; y++)
    {
        Vector2 uv = new Vector2((float) x / width, (float) y / height);

        outputTexture[x, y] = MyShader(uv, inputTexture);
    }
}

public static Color MyShader(Vector2 uv, Texture2D inputTexture)
{
}

All of your shader code would be in this MyShader function, a static method where all the input is given and it must be a pure method, meaning it cannot mutate any state except in specific objects, like read/write textures.

hardy juniper
#

e.g. to scale a uv around 0.5, 0.5 but keep it 0-> 1 still:

float2 ScaleUV(float2 uv, float2 center, float2 scale)
    {
        float2 scaled = uv - center;
        scaled *= scale;
        scaled += center;
        return scaled;
    }
hollow cedar
low lichen
vast quiver
#

alright

verbal moss
#

can anyone help me to create this type of shader in unity ?

#

edge blurry and black

#

wanted to use on 3D models

grizzled bolt
#

Unlit shader set to transparent will do the job at minimum

verbal moss
#

i already have URP/Unlite material on objects

grizzled bolt
verbal moss
#

but it's too sharp

#

the character and railing itself is shadows so i dont wanted to be too sharper

#

👀

grizzled bolt
#

The material and texture are ok, but what kind of result are you expecting

verbal moss
#

see this railing

grizzled bolt
#

Even if the texture has something blurry in it, it's not capable of blurring the edges of your mesh
It will be wrapped around it according to mesh UV maps, like any texture

verbal moss
#

edges must be blurry corners

#

for player and railing

grizzled bolt
#

Blurring would be a whole different operation, you cannot achieve it with materials and textures alone

verbal moss
#

then how can i achieve that effect ?

grizzled bolt
# verbal moss then how can i achieve that effect ?

The only included way is the Depth of Field post processing effect (note that it only works on opaque materials)
Beyond that you would have to go look for third party blur implementations, which usually are custom post processing effects or custom UI shaders

verbal moss
grizzled bolt
verbal moss
#

I think I have to keep it as it is.

flint hinge
#

What unit is Material.mainTextureOffset in? I have a scrolling background that's moving via
bgRenderer.material.mainTextureOffset += new Vector2(0, scrollSpeed * Time.deltaTime);
and I wanna sync up a moving object in the foreground to the speed of the background so it looks like it's moving on the ground. But just using the same scrollSpeed leaves it several times too slow, so how can I relate the Texture offset to Unity units?

grizzled bolt
#

Which is not easy or practical to determine
If you know the exact length of your mesh and that area of your mesh covers the whole UV map exactly, then you can assume it's that distance

flint hinge
#

The texture is on a quad that exactly fills the screen, and exactly four times the screen height in pixels.

grizzled bolt
#

Then you know it's your screen's length or width
Assuming it doesn't change when the display size is different

hardy juniper
#

a quad scaled to fill the screen still has a uv range of 0,0 -> 1,1

flint hinge
grizzled bolt
#

Yes

flint hinge
#

Thanks. That helped me figure it out.

hollow cedar
hardy juniper
hollow cedar
hollow cedar
#

Excuse the fact that my circle looks more like an oval 😂 I’m not an artist

#

The r equation up top is what I’ve mathematically worked out to be the polar coordinates equation of that circle

#

Now I’m just trying to translate that over to shader graph

#

Looking through the documentation of the PC node, it seems like I’ll have to write theta in terms of x and y

modern gazelle
#

Hello, I started learning Unity last week, but I have some trouble getting around some problems I encounter. My project uses HDRP, I made a Custom Pass Volume using shader graph, and it is dependant on the "Scene Depth" node. Everything's working fine, except that transparent materials are not taken into account into the Scene Depth "pass" (sorry if I don't have the right lingo). Is there a way to make transparent materials visible into the scene depth? Here is a screenshot to show my problem

hardy juniper
modern gazelle
#

Thank you for answering. I wanted to try that, but I didn't find a way to make it work. Maybe I'm not looking at the right place, but I cannot use alpha clipping on an opaque surface, and when enabling the "write depth" checkbox on a transparent surface with alpha clipping, it doesn't work either

strange prairie
modern gazelle
#

I've been looking for it for hours now and it was just under my eyes all along 😭😭 thanks

ebon basin
hollow cedar
#

Am I able to use if statements within shader graph's custom functions node?

fierce wave
#

Im trying to make an effect like in the video, a soul/flame 2d effect. I can't seem to get it to effect the whole orb with the mask that im moving since it is bigger at bottom and smaller at top. Would anyone be able to help me achieve this effect?

fringe karma
#

Is there a difference between the value returned by Shader Graph's Instance ID node, and Object.GetInstanceID()? I've been doing some testing but because the IDs seem to change whenever the scene is saved or materials are updated, it's hard to tell if I'm getting the same IDs

ebon basin
fringe karma
#

I want to write an array of data to a buffer for each renderer every frame, then have my shader search through that array for the bit of data that corresponds to it

#

I'm making a shader where the values update based on script data on an object the renderer is a child of, but I can't do it just by changing the material values because this is going to be an overlay effect

#

the IDs don't need to save between sessions

ebon basin
#

I would expect them to change when you do save the scene on the editor, or dirtying up some components, but otherwise I would expect them to stay similar throughout the runtime, but again i don't trust them ;p

fringe karma
#

I tried a test with 3 cubes in the scene, with a custom shader where the instance ID is directly read as the output colour (so they're all either black or white). Each one also has a script attached that prints the renderer's GetInstanceID() value. But while the rendered objects are one black and two white, all 3 of the printed IDs are well into the negatives. If those values matched up, then all 3 cubes would be black.

#

So I don't know if I'm doing something wrong, or if those two IDs aren't the same.

#

How would I figure out what the Instance ID node would produce for a particular renderer, but within a C# script?

ebon basin
#

Not enitrely sure about shader graph IDs, but if I ever want to keep track of renders using instancing I would always just send in my own IDs as a parameter to those buffers too and then have a struct of this information on the CPU side that I would keep track of

#

I do it a lot for the VFX graph so I can control everything independently if I needed to

fringe karma
ebon basin
#

Well, I can selectively grab the renderer by matching IDs through some of the APIs unity provides, but otherwise vfx graph particles I just make some circular buffer and rotate the IDs

#

lot of tools for those graphic buffers

fringe karma
#

which APIs?

ebon basin
#

Provided with vfx graph. It's such a good medium for general tooling even if not for particles

#

it's like blenders geometry node tool if I would compare it to something

#

Don't think it would be impossible to create some script to access those instances otherwise, I've been just content on what unity has provided lol

fringe karma
#

also hm turns out vfx graph doesn't have proper urp support yet, at least not on the version of unity I'm using

ebon basin
#

Unfortunate as it just keeps getting better... honestly one of the actual tool that unity has been updating consistently

steel notch
neon mason
#

How to get directional light realtime shadowmask texture in HDRP?

tall chasm
#

does anyone know what node is this in shader graph?

grizzled bolt
tall chasm
#

THANKS!!

amber saffron
neon mason
amber saffron
neon mason
#

nvm, I got the GetDirectionalShadowAttenuation, but I still can't find the context

amber saffron
neon mason
#

I think I found it

#

in "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"

amber saffron
#

Typically, LightLoopContext looks like a struct, use github search for "struct LightLoopContext " and you should find where it is declared.

fringe karma
fierce wave
fringe karma
#

A noise effect made from 3 spliced together voronoi noise values, that increases in intensity from the bottom to the top. Plus another vertex effect that raises the vertices on the top half (all calculated using an 'up' vertex'). Then the colour is calculated by lerping between two values, plus a proprietary stepping node that divides a smooth gradient into steps. There's also a wacky thing that uses the dot product and power to shift the centre slightly downwards

#

The noise intensity and 'centre' shifting downwards is obtained by taking the full dot product between the normal and up, and using inverse lerp to turn it to a 0-1 value

fierce wave
fringe karma
#

that 0-1 value is one minused then powered to affect the value determining the colour, which is then multiplied back up

#

one issue I have to deal with is that from the top it just looks entirely red

regal stag
# steel notch Hey just following up on this. I don't exactly know the implications of this. Is...

Would likely depend on what code is running in each branch, and what keywords are used by materials/scene. If you have materials using different shader variants, swapping those keywords out for dynamic branching might work better (or no branch at all if the code isn't that expensive). Maybe something you'd have to profile per use-case

Personally I only really try to use keywords in cases where I'm designing a shader that might be reused in multiple projects and needs various toggleable features to alter the appearance - but only one combination/variant would actually be used in each project

fringe karma
#

I did some changes but here's the fragment side

#

I'm still tweaking it to make it look really good, so I can put it on my portfolio

fierce wave
#

So my goal would be to take the top texture 2d and make the bottom texture 2d apply to that mask to the shape of the top one, would you know how to do that?

hollow cedar
#

@hardy juniper @low lichen I figured out the polar coordinates problem I was having, thank you both so much for your help!

hushed maple
#

Hello, I am getting started in creating custom shader but i am stuck on a problem. I have a script attached to the camera and a shader that shows all red. When I click on the render texture in the inspector i see that its indeed a 256x256 red image but i doesnt show on the game screen when i press play. Any clues as to what I'm doing wrong ?

plain urchin
#

Hi all. I'm doing some stress test. Using ProPixelizer and GPUInstancer, shadergraph to make the swaying tree shader
The pic is when zoomed in (25 fps) and zoomed out (5-10 fps)
I'm looking into frame debugger, rendering debugger. But not sure where to start
I see some numbers change between the 2 views, but not sure which to tackle and how

#

I'm using URP

hardy juniper
plain urchin
#

There are 250 bamboo prefabs, each has 6 mesh renderers

#

They're registered in GPU Instancer

#

Without GPU on, it'd be 60 million tris

#

On play, with GPUI, it's down to 55k tris total

#

As i zoom in/out, there's a definite threshold where the fps just drops considerably

#

So it must be some object starting to enter the camera view

#

Among others, when zoomed close enough, there's only 14 shadow casters
Zoomed out just from this threshold, it jumps to 83

hardy juniper
#

but whats taking 85ms then when zoomed out?

#

check via the profiler

hushed maple
plain urchin
fair lion
#

so i only see this happen on standard lite

hardy juniper
sudden jolt
fair lion
hushed silo
#

wondering if anyone can help me with some optimisation. I have this in my graph.
The "reality" custom interpolator is any value 0-1. the bit in the red circle is applying a fancy blend between 0.05-0.95.... Essentially when reality value is 0 or 1 (full or zero), which is MOST of the time, I would like it to not even be thinking about this stuff at all.

#

like, early exit the realityborder subgraph if reality==0 or ==1

hardy juniper
#

you can branch but is not ideal as both sides get calculated still and one is discarded.
If the work is minimal it may be fine.
sometimes it just needs to be that a certain value is reduced to 0 to not have a visible effect

round geyser
#

I have a vfxgraph spawning a shadergraph mesh particle

#

It’s a big tornado

#

It gets derendered when the origin point (the centre bottom) of the mesh isn’t in camera view

#

I’m sure there is some culling setting somewhere

#

But I have no idea where to look

#

Whether it’s a mesh import issue, shadergraph issue, vfxgraph issue etc.

ebon basin
neat orchid
#

OK so tessellation displacement destroys this mesh, but only on the inside

#

it works on meshes made with a different workflow...why?

neat orchid
#

nvm, fixed. Forgot to shade smooth in blender

muted laurel
#

I got this weird problem:

#

first is in game

#

second is in Scene view

#

so the object becomes invisible in game but I can see it in scene view and I'm not sure why

civic lantern
muted laurel
civic lantern
#

In the camera's settings. Don't know what exactly it is called, depends on your render pipeline

muted laurel
#

oh ah I found it

#

I think I found it

#

let me find out

#

ok thank you! you were right

plain urchin
#

Oh, this might be the time i implement an aggressive LOD ing

grand jolt
#

Hey does anyone know if it might be possible to create a shader or something like that for object specific pixilation?

plain urchin
#

Try ProPixelizer

grand jolt
#

Thanks!

hardy juniper
hollow cedar
#

Anyone know how to recolor a grayscale texture using a gradient in shader graph?

I figured out how to do it by importing a gradient texture, by using the luminosity as uv values when sampling the gradient texture. But does anyone have guidance on how to do it using the gradient node?

#

Nvm, figured it out

hardy juniper
#

Hopefully you are learning it's all just numbers!

daring wind
#

Anyone here really good with the stencil buffer? This is driving me insane and tutorials online are not working for me.

I need to render a mesh ONLY when it is behind a plane. But I also only need to render the part that fails the depth test.

#

^ Only this part should render

#

Same here

hardy juniper
# daring wind

What are you doing rn for the plane and ball? I should remind you that transparent objects render after opaque which may be making things be out of order (i dont remember when stencil writes happen)

daring wind
#

The plane will be a liquid shader

#

the ball will be a transparent ice cube that suspends itself above the water

#

because of transparency sorting issues, I had an idea to fake the ice cube beneath the liquid by rendering an opaque version of the ice cube beneath the liquid

#

it would essentially be a duplicate of the ice cube mesh with a stencil for the liquid, and rendering only beneath the liquid as well

hardy juniper
daring wind
#

The liquid will wave around and have vertex offsets so I cannot rely on referencing a fixed Y value

#

this is essentially what I want, except this happens (mind you this is currently without the stencil buffer)

#

This is just ZTest Mode set to greater

#

and the opaque sphere's render queue is 2850, above the plane which is 2800

#

I technically have another issue too, the effect I am using for my liquid shader - which is a depth fade, doesn't like working with transparency

#

That, and the transparent ice cubes act as if the liquid doesn't exist

#

Transparency sorting issues I believe

hardy juniper
#

transparent things dont usually write to depth so there is nothing there to use for the effect

#

You would need the cube to fade itself based on the frag world pos

full socket
#

does anyone know how to

#

implment

#

mutiple shaded

#

cel

#

like a 3 tone lit shader

grizzled bolt
full socket
#

there is a cel shading

#

like preset

#

or sum

grizzled bolt
# full socket or sum

Yes
Might not include every light calculation but most of them, and demonstrates how such a stepped light ramp is implemented

grizzled bolt
full socket
#

oh i found it

full socket
#

this right

#

do you know which one contains the cell shader

grizzled bolt
full socket
#

😢

grizzled bolt
ebon basin
# daring wind

Should be possible but you need to use an opaque mask if you want to cull the opaque geometry outside of the mask, then just overlap it with the transparent layer

ebon basin
# daring wind

And this like rob said that you're trying to blend using depth but won't work unless you specify which is rendered first, but you can probably manage something if you do the 'blend' inside of the shader itself

full socket
#

a few hour on this

#

I have no clue how to use shader graph lol

#

but i managed to make something

grizzled bolt
plain urchin
full socket
grizzled bolt
neon mason
#

I use stencil to draw my shadow effect only on layers I need, but the problem is that the shadows start to flicker for some reason. I use the HDRP DrawRenderersCustomPass and a simple Stencil shader with a Stencil block. On the first screenshot the block in the stencil shader, and on the second screenshot the block in the shadow shader. Why does this happen? HDRP

stray orbit
#

Is the depth buffer hyperbolic? I am trying to make a custom screen space reflections shader using some resources online but keep getting confused when i actually want to test my ray's z with the depth buffer i know i can use the lineareyedepth and linear01depth functions but i need to ensure my ray is also in the actual same space.

hushed silo
#

I'm trying to return two colors out of an hlsl shader graph custom node, which I guess is bad practice...? Anyway, it used to be a subgraph which allowed 2 outputs.

#

I think the outputting of both outputA and outputB isn't working, only one, can anyone see why?

regal stag
plain urchin
grizzled bolt
# plain urchin Is it normal to want to have billboard tree sway?

It's not unreasonable, if there's so much sway it would be noticeable if it was missing
Generally you can do it using the same techniques as with non-impostor trees, animate the vertices and/or animate the UVs of the texture
But it's important to note the sway will easily look different since the geometry will be different

#

I guess imposters don't have to be billboarded planes necessarily, I've seen some use the term for non-billboarded planes, octahedrons or other simpler geometry that captures the object's appearance

gilded nest
# amber saffron If the issue is with moving up/down, using a world XZ coordinate shouldn't affec...

Here's the issue I'm talking about. The problem makes sense since it samples the texture from world-space, so individual objects placed together appear to have one seamless texture, but of course it causes a weird effect since I need the ground objects to move in-game.

My only idea to fix it, is introduce _WorldPosAnchor into the shader, and in C# have the parent that holds the multiple ground objects to update _WorldPosAnchor accordingly to in-game position. This works, but I'm curious if there's any more elegant solution to this problem.

hushed silo
harsh marsh
#

Trying to draw repeating 1 pixel width lines in a shader.

I can draw a repeating gradient across the y axis like this:

float2 uv = (IN.screenPos.xy / IN.screenPos.w)*30;
float2 l = frac(uv.y);

But I have no idea how to modify this to ensure it will always be 1 pixel line no matter the resolution or whether or not I'm using orthographic or perspective projection. I've tried using smoothstep, step, etc but can never get the lines to only be 1 pixel. It's also important that this line has no anti-aliasing at all.

I tried reading this https://bgolus.medium.com/the-best-darn-grid-shader-yet-727f9278b9d8 but it didn't help.

Medium

For as long as I’ve been writing shaders, there’s been one specific shader I’ve always tried to write…

hushed silo
amber saffron
gilded nest
amber saffron
gilded nest
# amber saffron Yes, indeed, if you want to have consistancy between objects of a same "group", ...

However, I'm not sure how good this will be for performance. I think for each grass section parent in the scene, I need to instantiate a clone material to use for the children sections, to prevent the offset from affecting other unrelated grass sections in the scene.

So I'm thinking maybe I should abandon this idea and try to do something else? Perhaps the best choice is combining all the individual grass sections into one combined mesh, and then I think simply using object position will work?

amber saffron
harsh marsh
#

I just can't figure out what the r g channels could be used for. Using them for UV coordinates results in a glitchy mess

hollow juniper
#

HDRP here. Stack Lit shader

#

In the photo you can see the objec behind it (the interior)

#

for some reason objects unrelated to the car paint material can be seen through it.

#

Any ideas? I may have set up the material improperly but I am scratching my head at this point

dusty temple
#

anyone know how to fix this

#

i cant figure out how to combine the tree and the shader and when i put it in the terrain painter it has a black shade when i back up

grizzled bolt
# harsh marsh I just can't figure out what the r g channels could be used for. Using them for ...

Each horizontal line has its origin in the center of the cell in screen space
R and G store the vector to the center
Comparing the UV and RG per fragment can tell you exactly where the center is in screen space
Dot product can tell you how horizontal the vector is, to get a line instead of a circle
Comparing the vector's length to a variable that changes over time can animate the length
Screen space derivatives can ensure the width of the line measures in screen pixels, if necessary

grizzled bolt
hollow juniper
grizzled bolt
harsh marsh
harsh marsh
#

no idea what I'm doing

float2 rg = waveTex.rg;
float2 uv = waveTexUV; // same UV used by the wave texture
float2 dir = rg - uv;
#

no clue if this is correct

grizzled bolt
#

There may be an error in my logic

#

And I don't fully understand what kind of vector the RG channels are storing
Might not be the vector to relative center, exactly
Nevermind I just don't understand vectors suddenly

harsh marsh
#

oh okay

#

anyway i emailed the creator and his response was "uhh idk i just programmed until it worked" man this is so fun

#

Is there a way I can convert the RG positions from UV-space, or whatever coordinate space they're in, into a more useful coordinate system?

#

here's a version of the texture with just the R G channels

vernal nacelle
#

this is the Minecraft of the sky

harsh marsh
#

amazing reply to a 2 month old post

harsh marsh
#

still just not sure what to do

harsh marsh
#

I tried opening up material maker and trying to remake the material to better understand it but I couldn't. Best attempt was this

#

THey seem to be making the UV coordinates spherical

#

the uvs seem to be polar coordinates in the original texture?

keen hearth
#

Sorry I don’t think I understand your question

hollow juniper
grizzled bolt
#

I couldn't figure out the right math to compare the encoded vector to screen position though

harsh marsh
#

was able to get something slightly similar but only using the B and A of the shader

#

draw a 1 pixel wide grid using the partial derivatives and then use the alpha and blue channel as a mask

#

Here's what it looks like without masking

float2 dx = ddx(waveUV);
float2 dy = ddy(waveUV);
float invDet = 1.0f/(dx.x*dy.y - dx.y*dy.x);
float2 toX = float2(dy.y, -dy.x) * invDet;
float2 toY = float2(-dx.y, dx.x) * invDet;

float2 fromZero = frac(waveUV + 0.5f) - 0.5f;
float2 transformed = float2(dot(fromZero, toX), dot(fromZero, toY));

float on = 1.0f;
on *= (transformed.y > -0.5f) * (transformed.y <= 0.5f);

return float4(on.xxx,1);
harsh marsh
#

My only issue is that it isn't aligned with the texture

round geyser
#

Hi gang I am trying to make a hitscan gun tracer using shadergraph -> vfxgraph

#

It would be easiest if I can just scale the output mesh to however long it should be until the shot hits something

#

But obviously that stretches the texture out and looks ass

#

is there any way to have it tile instead?

#

like... repeat the uvs along the length of the mesh

harsh mirage
#

i am using the the unity demo enivonment for hdrp and when running a build i am getting these errors

there is about 24 errors regarding speedtree_branch

Shader error in 'ComputeShader-VertexSetup': undeclared identifier 'varyings' at kernel VertexSetup at SpeedTree_Bark.shadergraph(1286) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(13465) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(13466) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(13473) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(13474) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(14016) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(14017) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(14026) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(14027) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(14027) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(14028) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(17177) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(17187) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(17188) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(17345) (on d3d11)

Shader error in 'HDRP/Nature/SpeedTree_Branch': Opcode CalculateLOD not valid in shader model lib_6_3(anyhit). Opcode CalculateLOD not valid in shader model lib_6_3(closesthit). at Assets/TerrainDemoScene_HDRP/ShaderGraphs/SpeedTree_Branch.shadergraph(17346) (on d3d11)


harsh marsh
#

||Rephrasing my question from earlier||

Given this texture, how can I draw lines going through the center of each cell

#

this is basically what I'm looking for

#

Some important things to note are:

  • Line MUST be 1 pixel wide with with no discontinuities (gaps, etc)
  • One line per cell
kind juniper
#

I guess you could try inferring it from the color of the pixel

grand jolt
#

anyone how to fix this

#

it says no cameras rendering but obiously the camera is there

torpid vault
#

Hoi hooo
Question for you shader folk. Any good recommendations on the best tutorial / learning series for getting started in HLSL shader coding?
I've found a few but everything I can dig up is either very old, unfinished, or just a single video going over the very basics

tacit parcel
tacit parcel
grand jolt
#

ok

#

nvk fixed it

still lodge
#

Do materials and shader function differently in 2d and 3d

languid prism
#

Hey I'm super new to Unity but I was trying to set up a PCG script and everything and I'm almost done but I've encountered one final snag and I cannot figure out how to deal with it. It's regarding using a blank shader so that my heightmap gradient works. I can send more screenshots if need be.

ebon basin
# languid prism

Make sure you're targeting the correct pipeline in the shader setting there

languid prism
#

I believe i am

languid prism
ebon basin
#

Well, unless vertex colors break if the mesh doesn't have those colors, but I would expect it to be at least black

kind juniper
#

Likely targeting a different render pipeline.

languid prism
#

So what would the solution be here then?

kind juniper
languid prism
kind juniper
languid prism
#

Alright I'll see to it.

trim forge
#

i had some cool shaders but theyre now transparent, anyway to fix?

#

i thought opening amplify and saving might force a recompile and fix them or something

#

actually theyre purple not transparent

keen hearth
#

It’s helpful to send a ss of your code, instead of “i have a thing that is broken, what’s wrong?”

#

Or any context, like “I updated x”

trim forge
#

yeh sorry, its so hard to follow what i did, basically upgraded unity then downgraded

plain urchin
#

Hi all. What's this in shadergraph?

regal stag
wet frigate
#

Hey! We're having an issue with a traffic light model in Unity. Instead of just changing the light color, the whole model changes. We're unsure if it's a shader problem, a scripting issue, or something with UV mapping and FBX export. If anyone has insights, please let me know (or DM me if that's easier). Thanks! If this is the wrong place to ask, I apologize in advance.

hardy juniper
wet frigate
hardy juniper
wet frigate
hardy juniper
#

i already said and asked for what I think is needed to help so im good

#

share whatever you think you need to and someone can reply and help

harsh marsh
grand jolt
#

Im trying to restrict lighting to the individual pixels on my texture rather than screenspace. How would I go about that?

#

Ive asked chatgpt and it suggested using texel size

#

Trying to go for this look

golden haven
#

im new to unity and just downloaded a texture from polligon how can i apply it?

grand jolt
# grand jolt Trying to go for this look

The image attached is an object using a pixelart texture, but what Id like is to be able to set a flat color or a flat colored texture for the object and then shade based on the texture's pixels to achieve a similar look

grand jolt
#

Thats exactly what I want, thank you!

royal hollow
#

Hey folks. I am working in Unity 6 and trying to make a color replacing shadergraph for sprites. In the Shadergraph editor everything works great. I have exposed several colors and those correctly swap out the colors in the input texture and the Main Preview looks good. But in the editor it is not changing anything when applied to a spriterenderer. If I make the Range = 1 on one of the color replacers, the Main Preview shows the entire sprite changing to the input selected color, as expected. The sprite in the Editor however, only has some of its pixels change. I've done a Tint shader before which worked fine. I'm not sure what I must be missing here?

#

Here is how it works quite well in the Shadergraph editor.

#

In game however, nothing is changing.

eager folio
#

Were there any errors in the compiled shader?

lunar iron
#

i created this shader gragh works fine. i created a material out of it and asigned it to a raw image and i get this

#

in game view

#

and this in scene mode what am i doing wrong

royal hollow
#

I've been trying to recreate it piece by piece to see if I can sort it out. Short-circuiting the chain of color replacers also isn't working. How do I check for shader compile errors?

#

Also, would the Main Preview still work if the Shader wasn't capable of compiling?

eager folio
#

Check the inspector for the graph file

royal hollow
#

Looks fine to me?

#

This isn't working either. Seems too simple, I must be making a dumb mistake?

hardy juniper
#

Dont know if it matters but I name the texture MainTex so its ref becomes _MainTex

royal hollow
#

The ref is _MainTex

#

So if I make the RANGE=1 on the color replacer, most of the color applies to the entire sprite.

#

Its like something is just all mixed up with itl

#

So this makes sense. The Range=1 opens it up to most of the sprite outside of the white areas.

#

In the game though, its not doing that.

#

This is an unlit sprite so there shouldn't be any external influences.

hardy juniper
#

fyi vertex colors are applied always to sprite shader graphs

#

i experienced this bullshit today

royal hollow
#

I'm a total novice in this stuff, how might that be affecting me here?

hardy juniper
#

the sprite colour property is set as the vertex colours, and these vertex colours are multiplied against the colour after your input

royal hollow
#

So I'm not working directly on the texture that gets rendered to the quad? There's a post-step taking place?

hardy juniper
#

if you change the graph to urp unlit does it change?

#

(change it to transparent after too)

royal hollow
#

Well I began with a URP Unlit Sprite Shadergraph as my base

regal stag
# royal hollow

I'm assuming the "ArmorOrig" here property is only set in the blackboard? If so, you should just hardcode the value with a Color node, don't use a property. Or at least make it exposed.
Unexposed properties are assumed to be global values and default to zero in scene/game, you would need to set via script with Shader.SetGlobalColor to actually assign a value.

royal hollow
#

Otherwise the fragment would contain quite a bit more things.

#

Oh. I didn't realize unexposed properties get zero'd out. No wonder.

#

Damn tutorials.

#

They mentioned you can choose not to expose them, and it helps making setting them easier by grouping them

regal stag
#

Newer SG versions kinda clarify it by renaming the "Default Value" field to "Preview Value" when set as global

royal hollow
#

That is likely the issue then. Much appreciated.

#

Yup, totally fixed it. ::shakes fist at the tutorials::

#

I anticipate doing a few dozen of these, one material replacer for each sprite sheet really. As such, it would help to have them all exposed on the side dock of the blackboard. Is there any performance impact by making them all exposed, even if I don't plan to change most of them?

hardy juniper
#

I do wonder if it will be noticable perf wise doing soo many colour changes per fragment 🤔

royal hollow
#

Yeah I look at old C64 games. The GoldBox games. And how they allowed you to change 12 color fields on each sprite. Granted, it wasn't fully animated or anything. But crazy how much effort it takes to do something similar in a modern engine today.

#

Thankfully this isn't a real time game so even if there is a performance hit it likely won't be noticeable. Saving memory/space is more important to be honest.

hardy juniper
#

old graphics hardware was tile based and tiles had "pallettes" due to not being able to show many colours
This made color swapping easy as you just changed pallette. Now we have graphics hardware and sdks suited for 3D with per pixel shading with many colours and many textures

#

A efficient way now would be to use a compute shader to change the textures when needed once

kind juniper
# harsh marsh Voronoi isn't generated a runtime.

So the original texture is generated separately?
If so, then there aren't many options left. All you can do is try to infer the correct positions by color, but that might be extremely unreliable.

harsh marsh
#

Direct quote:

One night I decided to stay up until 3 AM crafting a method for world-space, view-aligned, horizontal lines for the little animated waves. The texture below is the result of that journey. This was a time where I felt that I was truly doing technical art. Boiling it all down to a texture read, utilising all the color channels for aspects of direction, variance, and timing. I’d like to thank Material Maker for the excellent procedural tooling.
kind juniper
#

It looks like a normal map,so perhaps they get a dot product with the camera view direction, and perhaps they discard the pixel based on some other channel(alpha?).

harsh marsh
#

it looks like a normal map but it's absolutely NOT a normal map or anything similar

#

the B channel contains a 'random' value per cell, that's it.

vast quiver
#

i have this shaderforge grabpass shader i got from Github, and i'm trying to use it in VR, it displays fine in Single Pass Instanced and Multipass rendering, but doesn't display properly with Single Pass Stereo rendering. i want to make it compatible with Single Pass Stereo, but i'm not sure how

shut remnant
tacit parcel
#

uv are in 0-1 range typically. zooming in/out will still result in the same origin (0) so it will be shifted diagonally

#

well, you can also try to shift the uv to the center (by subtracting with vector2(0.5, 0.5)), do the zoom, and shift back the uv by adding back vector2(0.5, 0.5), at least in theory its possible

shut remnant
#

what exactly the node that cantrol vertices ?

harsh marsh
#

Not sure if this is useful for understanding how to get the final effect better

steel notch
#

Does setting a new texture through material property blocks break batching?

humble geyser
steel notch
#

How often are TextureArrays used?

#

Haven't really seen much of them.

humble geyser
steel notch
humble geyser
kind juniper
flat hedge
#

Hi, I am working with the URP shader graph.
I was wondering if it's possible to somehow not render stuff inside of boxes/colliders etc.
Closest thing I can think of is this feature of the HDRP Fog Volume where you can hide parts of it:
https://youtu.be/gfzExrNySrw?t=220
I am not sure what to look into so I'd appreciate any info I can get.
Thanks in advance and please @ me!

lunar iron
#

hi this is my current shader gragh. can some one please tell me why this wont work on a ui raw image please unless i change my canvas to screen space camera? dont really want to use that option

hardy juniper
#

You can try changing this shader to transparent and disabling depth writing but i doubt it will work.

regal stag
ebon basin
#

Did canvas shaders (w/ graph) not work before? I'm pretty sure I had them working on some android project with built-in

hardy juniper
#

in 2022 its not an option and the existing options are just not compatible with overlay rendering.
I just do shaders manually for UI

dim yoke
brazen berry
#

Hi, does anyone have any idea on how to properly use shaders for FX on UI Elements? I tried using a canvas shader for a glitch effect and as soon as I use stretching my Texture gets cut off because there is no vertex expansion in canvas shaders...

lunar iron
hardy juniper
runic oxide
#

got this shadergraph for the yellow circle, which serves as some sort of cooldown period. It takes 5 seconds to go from 1 to 0 (full to empty) but instead of staying on 0 it jumps to 1 instantly at the end. I feel like this should be an easy one but I cant figure out why

steel notch
runic oxide
woeful knot
#

Unity 6 :
Is there a good Tutorial to create a Auto Tiling Shader with in input the Albedo, Normal map and Ambient Occlusion map ?

Thanks :D

amber saffron
woeful knot
#

like the texture auto tile depending on the Gameobject size, instead of needing to scale by hand

hardy juniper
#

tri plannar shaders would do this as they use world units, but you can also just sync scale to the main tex scale on the material

woeful knot
#

ok thx i will try

harsh marsh
#

Still trying to recreate this effect of view-space horizontal lines seen in this video, supposedly done with a single texture fetch and read

#

this texture was supposedly used "for all aspects" of the effect. Direction of the line, timing, and fading

#

What I currently know is that the B and A channels are masks used for fading the lines in and out. Still have no idea how the lines are actually drawn

woeful knot
#

Ok, i found something that work well for the ground, but for the walls it go crazy...
Any idea How to fixe it ?
(I can create another shader just for the walls of course)

hardy juniper
#

My thinking is there must be a reason for there to be some kind of 2d vec in the tex