#archived-shaders

1 messages · Page 101 of 1

kind juniper
#

You can confirm that with a frame debugger.

pulsar jacinth
#

I don't understand this, I do this: is this what you mean?

pulsar jacinth
#

I think I got it to work

#

but there is something happening that I did not expect, the image is blurry? Do you have any idea how? I assume because of the sampling?

#

Can you correct my understanding: I thought that this wouldn't change anything about the final image, as in my idea it would just return back the value at the point?

#

Hmm, maybe it has something to do with texel size...

#

in any case, you have been very helpful dlich! Thanks for taking the time. If you don't have answers to my final questions, don't worry about it.

pulsar jacinth
#

aiaiai

kind juniper
#

I mean, it should only return the color. Not modify it in any way.

#

If you need further help, share more info on your current setup and how you got it working.

pulsar jacinth
#

Okay, so I should have done something different before, because it works now by referenceing _ColorOpaqueTexture in my created _MainTex Texture2D and then Sampling that with the default Sampler Node using _MainTex.Sample(Sampler, uv.xy)

#

I put it in string mode for now to keep it simple

#

this is before and after applying, as you can see it becomes blurry

kind juniper
pulsar jacinth
kind juniper
kind juniper
pulsar jacinth
#

this is how I put it in the pipeline

kind juniper
#

Share the custom function node code and the whole shader graph.

pulsar jacinth
#

don't mind the other input vars

#

only thing that are being used you can see in the Body of the custom node

#

which is _MainTex, Sampler and uv

kind juniper
# pulsar jacinth
  1. Try setting the sampler filter to point.
  2. Check that the sampled texture and the render target have the same resolution in frame debugger.
#

There might be something in the custom node function too.

pulsar jacinth
#

point makes it look less, but still blurry

#

should look into how to use frame debugger

#

I'm going to bed dilch, thanks for the help though

pulsar jacinth
#

looked like _CameraOpaqueTexture had a smaller resolution

#

I used _BlitTexture, because I found it there, no clue what it is

#

looks to be fine now

#

@kind juniper just fyi

steep walrus
#

does someone had this problem before?, i dont know how to fix this and i dont know how this happens

obsidian meteor
#

hi im doing a project which requires a melting effect, like 3d words being melted into a pool of liquid, is there any free shader assets for this?

kind juniper
pulsar jacinth
#

still some bugs, but it's coming together:

steep walrus
#

since my project has alot of shaders

kind juniper
plain urchin
#

Hi all. I asked in ASE discord but, this is more about concept of shader itself so..

#

Im trying to do vertex offset. Is it possible for the offset value to get info of another pixel, given i know the pixel's uv coord?

amber saffron
#

This could be done with geometry shader, but it is not something that is implemented in ASE or Shadergraph.

What could be done though is to "bake" the offset direction/center into additional data on the mesh, like vertex color or an additional UV channel.

plain urchin
#

I tried to do that. The tut i followed does this, based on uv coords. Top left is xy -.5,+.5, bot right is +.5, -.5
But this requires each quad's uv to be fully square (like the result of blender's UV>Reset), but this requires all the quads to be "upright" when modelling

#

I guess it's still workable

grizzled bolt
plain urchin
#

Yes, the tut does the uv dictated direction. Needs to be upright
What i wanna do is instead, expand outwards, regardless of uv coord

grizzled bolt
#

Baking the center point of a polygon into custom vertex streams does not require using existing UVs to try to figure out where the center should be

inland adder
#

Hello! If anyone has the time, I'd be super grateful for some help with a shader I'm trying to create.

I'm not very good with shaders, but I'm trying to create a couple of shaders for use with a custom pass. I want wetness and rain drops and stuff to appear on objects and on the ground. I'm currently using a slightly modified version of a rain shader included in Shader Graph's Production Ready samples with a DrawRenderers custom pass for objects and props, and for the terrain I'm using a fullscreen custom pass with the fullscreen wetness effect found on this GitHub: https://github.com/alelievr/HDRP-Custom-Passes

I'd like the effects of rain drops and puddles that is currently on the props to be happening on the terrain as well, but simply using a DrawRenderers custom pass on the terrain wreaks havoc on all the trees and grass, and also doesn't seem to work on the terrain itself for some reason. The fullscreen wetness effect gets around this somehow, which probably has to do with how it only affects flat surfaces without rendering on top of specific objects, but this is very much where I start to get lost.

What I'd like to do is to get the rain drop and puddle effects from the productions ready samples "into" a fullscreen shader like the one I'm already using, so that it can be used on the terrain, but I can't really make heads or tails of the shader graph, and I was wondering if somebody could help me understand what needs to be done? I'm including both of the shaders here.

I understand if it's too complicated to help over text in Discord or if it's not possible to combine these effects per se, but I wanted to ask. Thanks in advance!

GitHub

A bunch of custom passes made for HDRP. Contribute to alelievr/HDRP-Custom-Passes development by creating an account on GitHub.

raven path
#

Why I don't see any preview in "Main Preview" like the tutorial I'm following please ? 🤔

#

This is the tutorial, he sees a sphere in the Main Preview, then he switches it to a custom model, when I try to do the same still nothing appears 🤔

inland adder
raven path
drowsy shuttle
raven path
# drowsy shuttle Actually, sometimes building a complex shader breaks the main previews or other ...

Here it's not even a complex shader, you can see the tutorial here : https://youtu.be/peY9VipZ74o

Learn how to make a Ghost Placement or Hologram Shader in Unity ShaderGraph. You'll learn how to create procedural scan lines as well as the edge glow (fresnel).

👨‍💻 The full project for the Chicken Defense Microgame is available on GitHub for FREE: https://github.com/llamacademy/chicken-defense

🏷️Save 25% on the ultimate C# IDE: JetBrains Rid...

▶ Play video
drowsy shuttle
raven path
drowsy shuttle
plain urchin
raven path
grizzled bolt
stiff nexus
#

I need to make a shader/effect that makes a trail for the ray of my radar, this is the ray in the UI, and I also show my current non-performant implementation. https://streamable.com/a9ui5i

How could I make a trail UI effect in Shadergraph? Would I need to save the previous texture to a texture, then access it in the next frame? How could I make sure there isnt a gap inbetween segments of the trail, or could I avoid segments altogether?

Watch "2025-03-18 21-00-36" on Streamable.

▶ Play video
keen hearth
#

My guess would be to make a 2d line texture with 1 point in the center and the other at the top that rotates based on a uv rotated by time * your speed modifier

steel notch
#

I have a shader that uses the dot product between the normal vector of a flat mesh and the camera view direction. When I look at the mesh from an angle of 0, the value is full intensity, and when I look at it from an angle of 90, the value is at 0. How can I make it so this rate is controllable? So for example, I rotate the camera 90 degrees and go from a value of 1 to 0. I want to be able to alter the rate in a way where I can go from 1 to 0 over 45 degrees instead.

stiff nexus
tacit parcel
# stiff nexus I need to make a shader/effect that makes a trail for the ray of my radar, this ...

One thing for sure, it cant be handled only in shader.
You can use rendertexture and trail renderer. But that might unnecessarily complicate things up.
You can also use texture blitting for the trail and make it fade, then you'll need make a radial shader that takes angle parameters to be used to determine how wide is the 'trail'

You can use existing radial progressbar as a start and modify it. There should be some laying around somewhere on internet

tacit parcel
ebon basin
#

https://i.imgur.com/MpCxh5O.png
So I'm trying to paint onto a texture mask, but I'm not understanding why the values of my brush here need to be greater than 1 if I'm working in UV space. Can someone correct me on this because even as is, it seems like I need extreme small values even after 1 to paint minor pixels.

#

BrushRadius here is brush pixels^

#

Ah, actually doing distance between vector4s seems to be the problem. Whoops

peak flame
#

Hey everyone, I'm trying to use vertex colors from Blender in Unity, but they are not showing up correctly.

#

how to solve it

frigid jay
peak flame
#

I used this setting while exporting from blender

keen hearth
#

(I’ve never actually tested this or similar but I’m confident that this would work)

#

Do you know how to use shadergraph or equivalent?

ebon basin
#

https://i.imgur.com/K1bSZb8.png
So I'm kinda scratching my head at this one. So my idea here is to use alpha values to determine if the painted values should be erased or not, but it seems that once I erase these values once, I'm not seeming to be able to paint again. It feels like I've values going into negative... can you even encode textures with negatives?

amber saffron
ebon basin
#

Yeah I just changed to a floating point so that must be what's happening

amber saffron
peak flame
#

Hey everyone! I'm currently participating in a game jam and still fairly new to game development. Today, I created a mesh in Blender and used vertex colors to blend materials. and in unity I did this after learning something from online , but its not working , can you guys help me with this?

thanks in advance!

amber saffron
peak flame
#

well , in blender I painted with blue and red , and its showing in unity , but I want to set one texture for the blue part and another for red , but none of them is showing up

amber saffron
#

If you have only two textures that you want to blend with the lerp node, use only the red channel, and consider that no red = tex1, red = tex2.
You need to take only the red value of the vertex color (from the split node).
And I recommend to expose the texture as properties (in the blackboard) of the shader.

amber saffron
#

Yes, and expose the textures as properties.

peak flame
#

right click -> convert to -> property ??

amber saffron
#

Yep

peak flame
#

still lookin like this

#

I mean after saving its becoming complete white

#

sorry my bad! I didnt assign those textures in inspector

#

thank you for the help!

quiet silo
#

Does anyone know how to use Texture2DMS in shaders?

Texture2DMS _BlitTexture;
SamplerState sampler_BlitTexture;

fixed4 frag (v2f i) : SV_Target
{
    fixed4 col = _BlitTexture.Sample(sampler_BlitTexture, i.uv);
    return col;
}

(Above code doesnt work because Texture2DMS doesnt have a Sample function)
I found the docs for Texture2D but not Texture2DMS
https://docs.unity3d.com/6000.0/Documentation/Manual/SL-SamplerStates.html

low lichen
quiet silo
#

Thanks for the doc link im trying to fix this error
"A multisampled texture being bound to a non-multisampled sampler. Disabling in order to avoid undefined behavior. Please use Texture2DMS in the shader."

#

but Load looks promising

low lichen
quiet silo
#

Im trying to get the depth texture into a material shader through the rendergraph

#

when I pass along the color texture it works fine

#

but for the depth texture I get that error

low lichen
#

When using MSAA, there is not a single depth value for each pixel, but multiple samples. 4 when using 4x, 8 for 8x, etc.

#

So you have to decide how you want to sample it. There's no one correct way. You could read all the samples and choose the closest depth. That would be conservative sampling. Or you could read a random sample or always the first sample.

quiet silo
#

The issue im running into rn is I dont even know how I can sample it in the first place

low lichen
quiet silo
#

Is there a way to turn off the msaa in code (its already turned off in the universal render pipeline asset)

#
    public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
    {
        UniversalResourceData resourceData = frameData.Get<UniversalResourceData>();
        UniversalCameraData cameraData = frameData.Get<UniversalCameraData>();

        if (cameraData.camera.cameraType != CameraType.Game)
            return;

        var desc = cameraData.cameraTargetDescriptor;
        desc.depthBufferBits = 0;
        desc.msaaSamples = 1;
        RenderingUtils.ReAllocateHandleIfNeeded(ref m_OutputHandle, desc, FilterMode.Bilinear, TextureWrapMode.Clamp, name: k_OutputName );
        

        Shader.SetGlobalTexture(m_OutputId, m_OutputHandle);

        TextureHandle source = resourceData.cameraDepth;

        TextureHandle destination = renderGraph.ImportTexture(m_OutputHandle);
        
        if (!source.IsValid() || !destination.IsValid())
            return;
        
        RenderGraphUtils.BlitMaterialParameters para = new(source, destination, m_Material, 0);
        renderGraph.AddBlitPass(para, "BlitToRTHandle_CopyColor");

        resourceData.cameraColor = destination;
    }

this is the ScriptableRenderPass code

low lichen
quiet silo
#

I fixed it by using resourceData.cameraDepthTexture instead of resourceData.cameraDepth

stiff nexus
stiff nexus
#

The reason I want to make a trail is because when the radar first becomes enabled, the ray isnt moving, and this current ray texture looks like it has a trail, even when its at rest.

keen hearth
#

Yeah I see

#

This does seem to be a bit more complicated than I thought lol

low lichen
sudden anchor
#

For terrain, why can a shader not be put into a Mesh Renderer component like a plane or cube?
Also now that I applied a shader onto my terrain, Adding a layer and trying to paint the terrain with it doesn't do anything

lean phoenix
#

Hey guys

#

What is the right way to build a shader from this?

grizzled bolt
#

All render pipelines already support PBR mapped shaders, give or take some features

stiff nexus
low lichen
# stiff nexus how would I use a radial gradient?

Looks like it's sometimes called a conic gradient. If you think of the trail as the start of the gradient and just rotate it to follow the ray, then you can just pick how long to make the trail by scaling the gradient.

lean phoenix
low lichen
# stiff nexus You mean like this?

Yes. Now you just need to rotate it, either by rotating the UVs first or maybe there's some other way to do it. Then, scale and clamp the value and apply a color to it

stiff nexus
#

Found something that works

#

but it requires negative numbers

#

which decrease the size

#

Screen works better

low lichen
low lichen
#

Yes. You might need a Saturate node after Inverse Lerp to avoid negative values.

stiff nexus
low lichen
stiff nexus
#

Oh I get it.

#

Now I kinda just need a way to change the length variable via c# script.

grizzled bolt
# lean phoenix and how do I properly assemble the texture?

You have most of it there already
Smoothness is mildly tricky because it's inverted roughness, and must be on specular map alpha channel (or base map alpha, or metallic map alpha)
Meaning you need to use an image editor or a channel packer to invert roughness and store it into one of those alpha channels, depending which one is set to be in use

lean phoenix
grizzled bolt
lean phoenix
grizzled bolt
lean phoenix
#

Wall_Paint_qj2luvs0_2K_Specular I open it in photoshop?

#

and then I add Wall_Paint_qj2luvs0_2K_Roughness to the alpha channel. ???

keen hearth
#

I am trying to overlay a texture onto another, and it literally works fine, but most of my sprites are packed (resource type "multiple") and it overlays the texture over the whole texture pack instead of over the visible area, how do I overlay the texture over just the visible part?

lean phoenix
keen hearth
magic meteor
#

Does anyone know whether "Fadeout to Grey" improves performance when textures are viewed at from a distance if used on all normal maps?

#

In the documentation it says it's used for detail maps, but gives no clue about whether this is mainly about visuals or saving performance. I would assume or hope that if the texture is just displayed as grey, it does not have to be rendered anymore, but since it's a transition and it's not mentioned anywhere I am not so sure.

kind juniper
#

There might be a condition or something, under which it doesn't sample the texture at all, but honestly switches might be worse than sampling a texture performance wise. So I'd think it's just sampler always.

slender ore
#

Is it intended that Unity's Gradient noise generates values that can go below 0, or is it just something that got fixed in more recent versions. (using 2022.3.40f1)

amber saffron
grizzled bolt
# lean phoenix maybe there's some kind of video?

I'm sure there are tutorial videos for editing the alpha channel in photoshop
Like I said it requires using the alpha mask operation
And don't forget to invert so the roughness becomes smoothness

amber saffron
#

Indeed

slender ore
#

aight, that's what I wanted to know

amber saffron
slender ore
amber saffron
#

Yeah, it would be weird if it was the case, that's why I want to double check 😅

steel notch
#

Is there any preferred resolution for Gradient textures?

amber saffron
hardy juniper
analog fable
#

Hey, I'm super new to Unity, following a tutorial for some blood effects and having some issues. Here's the video: https://www.youtube.com/watch?v=0PY5oV7yU4Y

At about 3:30 he starts making a UV thats connected to Alpha Clip Threshold to give the particles a "death" time, and when I do everything like in the video literally NOTHING changes. I'm on unity 2022 and did have some trouble finding everything that he uses in his 2019 version, but I got URP and found all the needed settings. Anyone have any idea how to fix this?

I take blood showers every morning and I highly recommend you to do the same! In this video you will learn how to create your own spectacular blood fountain with the use of PBR Shader graph and particle system. No textures required (beside the default Unity particle sprite as a mask), everything is done proceduraly. Don't forget to have fun!

SU...

▶ Play video
ebon basin
#

Is it possible to update the name of the outputs of subgraphs when embedded into other graphs?

#

Oh, ok there it goes. Had to recompile the shader

still orbit
past dune
#

I'm mostly new to unity with background in programming, and after I read the documentation about shaders, I wanted to challenge myself to do a postprocess in built in pipeline, in which some particles move around on the screen. the first idea that I had is to use a compute shader where I pass a buffer of particles properties( like the position) and compute the update , and then update the particle buffer of the postprocess shader in preRender image, but I was wondering if there is a more efficient method because I think with this approach I pass a buffer gpu to cpu and then gpu again every frame. is there a way to update the buffer on Gpu and then just use the buffer already in gpu inside the shader

kind juniper
#

Just make sure the compute shader is done by that time.

#

Ideally you'd need to use barriers (assuming unity doesn't do it for you).

past dune
#

mm I don't quite get the binding concept, if it is ok for you can you guide me to some documentation on the matter especially in unity context, I'm prone to learn and search by myself

#

and by pixel shader you mean the shader that handles the post process effect?

amber saffron
past dune
#

ohh, I didn't know that there was a concept of reference with set buffer

#

the documentation doesn't seem to state this fact

past dune
stray gorge
#

I have no idea why my shader creates border when i use Lookup table.
There is no mipmap/ anti alias/ compresion , used point filter
tried both .asset (RGBAFloat 0-255) and .png ( RGBFloat 0-1)

amber saffron
stray gorge
amber saffron
stray gorge
#

this is idTexture (in both type: asset/png. I tried both)

#

In my general image. There is no anti alias/ mipmap or anything like that to create border like above. I dont know why it create borders between color zones

amber saffron
#

You could also try to force the sampler stater to point/repeat in shadergraph with an inline sampler node.
Or force the LOD using the SampleTexture2DLOD node.

stray gorge
#

Do u know why Lod make it different ? Like in vertex animation or in this case. It is just different for no reason.

amber saffron
stray gorge
amber saffron
#

So when sampling it, at the borders of the flat color zones, the UV varies greatly and it goes to sample a lower mip level.

#

IDK how you got that texture without import settings. Did you generate directly a texture and store it as an asset file ?

stray gorge
#

i also use code to convert from .png to .asset

amber saffron
stray gorge
amber saffron
#

I think something in the process did add mips again then. Anyway, you got your solution 🙂

solemn narwhal
#

Hey, I cannot get my vertex colors to show up in unity after painting them on a mesh in Blender and exporting as an fbx. I've tried all the tutorials making custom shaders, and making shader graphs to link the vertex colors but nothing seems to work. Does anybody have any experience with that?

#

not sure where to go next

#

hm maybe this has something to do with it

primal hatch
solemn narwhal
primal hatch
#

You should see something like this

#

Click on the Shaded drop-down. I think there's a vertex colour in there

solemn narwhal
#

@primal hatch Not seeing the model like you have for some reason

primal hatch
solemn narwhal
#

Oh my gosh there it is

primal hatch
solemn narwhal
#

hm yeah the colors are there

primal hatch
#

Wish I could help you with the shader part but I'm not great there.

solemn narwhal
#

All good, thank you for the help at least I know the data is actually there

regal stag
solemn narwhal
#

using shader graphs

#

just need to figure out why theres no shadows or anything

#

quite tragic, must be a setting with the material that gets rid of the lighting

#

crikey i did it, just had to change from unlit to lit. ty all

stray orbit
#

I am learning a bit about using compute shaders. Does the Load function on a Texture2D have the ability to provide a mip value? so to give which mip to load from? i can't find info about that.

Below is my shader so far. I am trying to create it for downsampling the depth texture into lower resolution mip maps.

#pragma kernel CSMain

Texture2D<float> Source;
RWTexture2D<float> Target;

[numthreads(8, 8, 1)]
void CSMain(uint3 id : SV_DispatchThreadID)
{
    int2 targetPos = id.xy;
    int2 sourcePos = targetPos * 2;
    float p1 = source.Load(int3(sourcePos, 0));
    float p2 = source.Load(int3(sourcePos + int2(1, 0), 0));
    float p3 = source.Load(int3(sourcePos + int2(0, 1), 0));
    float p4 = source.Load(int3(sourcePos + int2(1, 1), 0));
    
    float minDepth = min(min(p1, p2), min(p3, p4));
    
    Target[targetPos] = minDepth;
}
stray orbit
# regal stag Yes, would be the third component in the int3. Currently you only use mip level ...

ok thanks, so it should be possible to read from, for example mip 1 and write to mip 2, of the same texture at the same time or probably not?
I have been trying to get the depth texture mips to generate properly for a while now but it's not really going well. I am not really experienced with this area.
The result would be texture where each mip holds the closest depth of the previous mip.

serene condor
#

ok, i THINK i'm on the right track but not certain. I'm trying to make a disintegration shader that goes from the mesh's rear (-Z to it's front +Z). I want there to be a section of noise that makes it look like it's burning and then the section behind this "tail" should be completely invisible -- i'm going to add a particle effect too but for now i just need to get the "paper burning" and alpha clipping worked out.

Here's the graph so far

#

and this is my running theory, is that right?

#

i can get the "hiding" part to work, and im only using the base color to visualize what i'm doing. i'm not really sure what nodes i'm looking for but i THINK i need to re-code the Z position value back to blue so i can use some color masks? i think

serene condor
#

nvm got it

modern jay
#

Is there any way to sample a color that’s off screen?

civic lantern
#

What are you trying to solve?

kind juniper
modern jay
modern jay
#

But maybe there’s a diff way to do it

kind juniper
#

Or clamp. Or just use some predefined color

#

It's kind of a design choice.

modern jay
orchid summit
#

Has anyone made a template for a custom URP lit shader yet?

modern jay
orchid summit
#

An actual hlsl shader though, not a shader graph because shader graph doesn't work for some use cases

#

I'm planning to copy the LitShader, each of the pass headers and a few other headers
then adjust material properties, and make it possible for a single hlsl file to provide the specific shader vertex attributes, varyings and vertex and fragement functions

#

But from what I gather, this is the same thing anyone who needs custom shaders without shader graph is forced to do currently, I don't want to reinvent the wheel if I don't have to

stray orbit
#

With rendergraph is it possible it doesn't really handle loops well like below? I have a computeshader that samples from a mip level and can write to a different mip level. i also make it swap the colors rgb -> brg for example to debug. I have made 3 passes that downsample to the next mip outside of a loop. those work fine. but the passes called inside the loop seem to fail.

int mipCount = 1 + Mathf.FloorToInt(Mathf.Log(Mathf.Max(cameraData.cameraTargetDescriptor.width, cameraData.cameraTargetDescriptor.height), 2));

for (int mip = 1; mip < mipCount; mip++)
{
    using (var builder = renderGraph.AddComputePass($"ComputePass", out ComputePassData passData))
    {
        // pass code here.
    }
}

Can it be the loop being the problem?

#

I think i might have found my issue. i am using the incorrect mip levels sometimes because of confusion.

mortal sable
#

why is this happening, i thought it would make the black parts white only?

#

apparently i can switch the color and now it works as expected, but i want the other way around

regal stag
mortal sable
#

how do i make it so the white parts appear

#

smaller and with more amount

#

in larger planes

#

but quite the opposite in smaller planes if u get what i mean

#

right, i can just turn the values into properties and change as i like

steel dagger
#

hello. i am making a 2d unity game with pixel art sprites. im currently using a material for the sprites with the Sprites/Default shader. ive recently needed to use a custom-made shader, however, i need to be able to use the "pixel snap" feature that is on the Sprites/Default shader. how do i add that feature to a custom shader?

modern jay
#

whats the best way to apply different distortions to different layers in 2d? Previously i only had 1 distortion so i made everything that needs to be distorted be rendered first, applied the distortion using camerasortinglayer texture, then rendered everything else on top. now, however, i need certain layers to have 1 distortion, certain layers to have a different one, and certain layers to have none at all

grizzled bolt
steel dagger
grizzled bolt
steel dagger
steel dagger
grizzled bolt
# steel dagger

This is a built-in render pipeline sprite shader feature, which I'm not really familiar with
The shader works in URP but it's not officially supported
What's it meant to "snap"? I can't find any documentation or examples about it
A point filtered sprite by its nature snaps its texels to screen pixels anyway, but without pixel perfect rendering neither type of snap seem to be able to guarantee correct appearance

#

The source can be found here, and someone better at shaders than me might be able to parse what it does exactly

#

According to forum users the function can be copied and implemented in an URP shaders and it'll work
But I'm still a bit confused because multiple people cite Sprite Atlas as a solution that works instead

#

Which has nothing to do with any type of snapping

#

But it does include a padding option, which does eliminate a specific type of color bleed issue for tilemaps

#

Sprite Atlas is not required for padding either though, but it's convenient that the tool is there

summer shoal
#

Hi, when I try to build my game, one of my shadergraphs throws this error message:

Program 'frag', error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Negate modifier not allowed for operand #5 of opcode #267 (counts are 1-based). 
Compiling Subshader: 0, Pass: Universal Forward, Fragment program with PROCEDURAL_INSTANCING_ON
Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF1 UNITY_PLATFORM_SUPPORTS_DEPTH_FETCH UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: DEBUG_DISPLAY DIRLIGHTMAP_COMBINED DOTS_INSTANCING_ON FOG_EXP FOG_EXP2 FOG_LINEAR INSTANCING_ON LIGHTMAP_ON SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING USE_LEGACY_LIGHTMAPS _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 _SAMPLE_GI _SCREEN_SPACE_OCCLUSION _WRITE_RENDERING_LAYERS
mortal sable
#

i thought this would move my plane up and down continously but thats not happening, any help?

#

i fixed it by using a sine function, but i want to know why sine function was able to fix it

warm dome
#

I installed URP into my project, assiged URP pipline asset. I created a standard surface shader, but when I open it it is all errors. How do I make coding a shader compatible with URP?

grizzled bolt
thin phoenix
#

I want to make a shader that can stack all the textures into a single texture for character customizations.
I have six parameters: Top, Middle, and Bottom textures, along with three colors. I know I can apply color to each texture individually by multiplying them, but how do I combine all the textures into a single texture at the end?

smoky widget
#

Is there any way to extract a depth buffer at a certain step? Like if first opaque meshes are rendered an then alpha clipped ones, is there any way to extract the depth at the in-between point?

ebon basin
#

Sounds like depth-prepass. Not entirely sure how to go about that in the shader, but usually can grab that behaviour with pipeline render objects

elfin hemlock
#

Why do my teeth have weird boxes around them when I put a material on, I've highlighted their colliders so you can see it

orchid summit
#

I've copied the URP lit shader and modified it to use my own 'surface shader' code from a hlsl
but how would I actually go and hide all the boilerplate so making new shaders with this format becomes easy?
The shader itself is a mess of passes, includes and pragmas

grizzled bolt
orchid summit
#

Well unity does not seem to care to allow users to create custom shaders that work with URP without shader graph
Afaik the docs are barely existent and only explain basic unlit shading

Cyanilux did the work to make a template shader that works with URP (wish I knew that before manually wafting through unitys lit shader)
https://github.com/Cyanilux/URP_ShaderCodeTemplates/blob/main/URP_PBRLitTemplate.shader
If I copy this and go in and manually customize all the passes I can create a custom lit shader, but that's obviously a horrendous workflow

neon gale
#

Unity 6 URP Shader Graph
Unable to re-check 'Show In Inspector' after unchecking it

#

nevermind., had to select 'Per Material'. silly mistake

amber saffron
amber saffron
amber saffron
unborn thorn
#

hello can someone help to make a custom shader graph, i need to make a specific shader for my map the mesh don7t move stretch or anything, i hand painted a series of normal map and no built in shader can actually make them work

unborn thorn
#

im trying to make a custom shader graph for one of my material, the hand painted texture have been made in the object normal space, and unity built in feature doesn't render them correctly

amber saffron
unborn thorn
#

yes i did inport them as normal no worries but i dont want the shader to use the tangent space

#

i want the shader to use object is it possible ?

amber saffron
unborn thorn
#

really? arf

#

i never touched the hdrp ... lets see

amber saffron
#

Or just create a shadergraph ^^

unborn thorn
#

yeah i know how to create a shader graph but not for this very topic lol

amber saffron
#

Well, you just have to sample the normal and plug it into the normal output

#

And change this

unborn thorn
#

i made a mesh in the 3d software, i painted the normal map over there

#

i tried that also didnt work ...

#

raaa lets dive back in then

amber saffron
unborn thorn
#

nop i painted the normal map in the object space

amber saffron
#

Then, don't import it as a normal map, but default texture without sRGB

unborn thorn
#

actually i could bake it into any space possible but i want the object one

#

aaaa

#

my computer dont like the hdrp

#

not at all

#

mmm remy maybe it would be easier if i can show you?

amber saffron
#

Can't. But like I said, import the texture as default texture without sRGB, change the fragment normal space in the shadergraph, and it should work.

#

I can't do a screen share, but feel free to show screenshots of the importer/graph if this doesn't work.

unborn thorn
#

yep no not working ^^

#

its okay

amber saffron
#

It mean, that's a simple and "common" setup, and should work. If you share some screenshots of the setup I might be able to help fix it.

#

Oh, forgot to mention that the normal map also needs more nodes setup in shadergraph.

orchid summit
woven needle
#

anyone got an idea of how i can make a highlight shader, similar to how PPT Chapter 4 does it?

#

cuz i got small items in my game and in the dark its impossible to see, has to be visible in the dark. i dont want lighting to affect it

steel notch
#

Specifically how the light seems to sweep across the card.

#

Obviously do not want it to reflect something real.

grizzled bolt
# steel notch Obviously do not want it to reflect something real.

Most of what you see is achieved by specular reflections
You'll want a skybox or a cubemap of a room so there's something to reflect, otherwise they won't have any reflections
Then with the specular material workflow you can make a specular map and a smoothness map to control the color of the sheen and its sharpness
Normal maps probably aren't necessary but they would let you bend the reflections as you want
The holographic decals are trickier, for those I'd look into guides about making those specifically

steel notch
#

I just have a texture and a normal map for the symbols.

#

And then do a bit of dot product math with the normal map vector and the view direction to decide if they should be shining.

grizzled bolt
steel notch
grizzled bolt
steel notch
#

I know that Unity has a whole PBR shader graph reference project.

grizzled bolt
#

I could use it

#

I only know of the importable shader graph samples which include an incomplete one

steel notch
grizzled bolt
steel notch
#

think so

grizzled bolt
#

It has most of the lighting calculations but not all, and it was never intended to be a full breakdown

#

Maybe you don't need everything, but if you do you have to refer to the the Lit shader source and convert it to custom nodes

#

Cyan already did that work here, though I'm not sure how up to date it is, some features like APVs were added afterwards

steel notch
#

@grizzled bolt Wait so what's the flow here exactly? Cubemap to define what is being reflected, specular to handle how it's displayed, smoothness map to break up the cubemap texture?

grizzled bolt
steel notch
#

@grizzled bolt Unity has a "Legcy Cubemap". Is there any... non Legacy Cubemap?

grizzled bolt
#

The legacy cubemap is an asset type
Non-legacy cubemap is a texture import setting

steel notch
grizzled bolt
#

I assume legacy cubemap assets and modern cubemap textures are interchangeable

#

Both as properties and when sampling them

#

Legacy cubemaps have less features and cannot be compressed, there's not really a reason to use them

steel notch
#

@grizzled bolt If I want the "reflection" to be a tiling noise, do I really need a cube map?

grizzled bolt
#

Matcaps do that, but in their case if the texture doesn't resemble a sphere it won't really look like a reflection

steel notch
#

seems like they'll be seams somewhere

grizzled bolt
#

There would be, up to you if it's too noticeable

#

There's also a hacky solution to import a 2D texture as a cubemap and force it into one of the cube configurations, such as spheremap

#

There will be distortion but it depends on the case if it's problematic

#

Like the documentation says you can also generate cubemaps inside of Unity, so you could throw random meshes into your scene to approximate the environment you want reflected and generate a cubemap from that

keen hearth
#

Hey, was wondering how I could pixelate this sine wave to match my pixel art textures, anyone have any ideas?

#

I have done something similar before, but only when I was able to modify UVs. Now, with this sine wave effect there is no UV input, so I'm a bit lost

keen hearth
amber saffron
keen hearth
#

I’ll try this out, thanks!

#

This UV may be everything I need, because I have a subgraph that pixelates a UV to match a texture resolution

#

For some reason I was using a position node instead 😔

thorn vessel
indigo perch
#

When did unity take _Emission parameter out of the sprite-lit-default shader? In Unity 6 it seems to not be working

rain axle
#

is it still the case that you can't modify the vertex output for Canvas UGUI shaders? only pixel?

grizzled bolt
grizzled bolt
#

You only need nice assets with good materials, and an understanding of how to do good lighting and post processing

indigo perch
# grizzled bolt Did it have it before? For as long as I can remember the officially recommended ...

In the past I used the Brackey's tutorial (https://www.youtube.com/watch?v=WiDVoj5VQ4c&ab_channel=Brackeys) which uses _Emission on the sprite-lit-default shader graph. But that's not working now and the guides I am finding all seem to have bloom outright controlling the glow effect using a custom shader. But I haven't tried using the sprite custom lit shader type yet. As you mentioned, I want lighting to have a play, not just bloom

In this video we create an awesome Glow effect for extra flare!

► Check out Popcore! https://popcore.com/career

● Download the project: https://github.com/Brackeys/2D-Glow

● Get Gothicvania Church Pack: https://assetstore.unity.com/packages/2d/characters/gothicvania-church-pack-147117?aid=1101lPGj

● Learn more about 2D Shader Graph:...

▶ Play video
grizzled bolt
#

The nodes in the tutorial work for purely unlit sprites, but if you also want 2D lighting you need the custom lit method

indigo perch
grizzled bolt
#

If it appears wrong with lights iirc you also need to plug a Screen Position: Default into 2D Light Texture Sampler's UVs

little ravine
#

Hey people, I'm working on a compute shader that does the jump fill algorithm and I've gotten it successfully working on my main computer, problem is on my laptop where the output is just black.
Two things, The first part of the compute shader works normally, so I know that my laptop can use compute shaders, second the laptop is using integrated graphics and I know that might be producing the problems.

crystal monolith
#

Hello everyone, Im new to the whole Shader graph thing.. I followed a tutorial on how to make water in Unity, now, im facing this issue I cant find an answer for, can someone help me find out what the issue is??

The bottle, plane and capsule arent supposed to be there, its like a reflection

little ravine
#

I know it's a hardware issue I'm just not exactly sure where to look

#

I can provide the compute code if needed

#

ok nvm people i fixed it

#

I just had to change to texture format for some reason 😭

#

I guess the format isnt supported on this laptop??

civic lantern
lean phoenix
#

Hey guys, I downloaded the material from Fab.com

#

Now how do I build it properly in the URP shader?

keen hearth
#

How can I make this effect sample over the uvs of any particular sprite? If there is no simple & automatic way, I can add a vector2 offset that moves the effect on a material instance, but I would like to avoid that if possible for fear of jankiness

regal stag
keen hearth
#

never used the fraction node before, how does it help here?

hollow lotus
#

so I have a pipe system consisting of multiple game objects to form the curvature and what not. how would I go about creating a shader that simulates fluid motion that moves along the spline shape I made with these different game objects (the pipes i'm referring to)? i'm thinking using a shared material and using a world space shader but i'm not sure how to make it where each game object doesn't simulate different instances of the shader but rather all share one and form a clean fluid flow along the curves.

lean phoenix
neon raven
#

Is it possible to write a shader that automatically tiles to an object scale across all 3 axes using only UVs? Or do you have to get into world position for that

keen hearth
#

In shadergraph, the triplanar node should handle this for you (i think)

cunning thicket
#

is there a list of shadergraph blocks and their (mostly) equivalent HLSL code one would put?

ebon basin
cunning thicket
tiny bane
#

Hi guys, does anyone know how to make the shader graph scale and maintain size instead of stretching if that makes sense
I followed a tutorial and this is what it looks like, I tried changing the position node to World instead of Object but that didnt seem to work.

hollow bolt
#

how to make a UI outline glow? I cant find anywhere to start

cunning thicket
#

texture emissive perhaps?
where there is a UI texture, and its edges have emissive

tacit parcel
hollow bolt
#

I just added color to emission of a lit shadergraph and it kinda worked, but it doesnt respect the texture and the Image color

grizzled bolt
random inlet
#

has anyone had issues with custom shaders in VR before where they only render to one eye (in my case, left)

keen hearth
regal stag
#

But with the number of sprites in each row/column of the texture instead of (2,2)

keen hearth
plain urchin
#

Hi. I'm using Sin node, but what if i want a quick when up, slow when down kinda curve?
Kinda like this pic, but i guess more curved rather than sharp
It's for leaf sway effect
It's kinda a math question, but i guess people here know some math?

#

Anyone know some resource on making specific curves?

#

Or maybe i should bake this curve values onto a texture?

#

It would be so simple if there's AnimationCurve node in shadergraph/ASE...

amber saffron
# plain urchin Hi. I'm using Sin node, but what if i want a quick when up, slow when down kinda...

Baking into a texture is a solution, and if you wanted to you could implement animation curve into shadergraph. But the first option is a bit costly as it needs a texture sample, that can have a negative performance impact depending on the further use, and the animation (so, curve key points sampling) needs loop logic..;

The best is to find a formulat that can reprensent the curve that you want.

For example, you could get something similar with two square curves : https://www.desmos.com/calculator/p40t44dpza

steel notch
amber saffron
steel notch
amber saffron
# steel notch Assuming I'm building something up from Unlit 😛

Well, still cubemap is the easy solution, but if the effect is specifically this you can make it simpler :
Since the camera is fixed, the cards are 100% flat, you can hack the reflection by using a flat texture mapped to screenspace UVs, and offset the UV with the view normal of the card.

steel notch
steel notch
# amber saffron Something like this :

I've seen something similar with View Direction in View Space. Makes sense, will give it a try. Any suggestions on how to blend this "reflection" texture with the main texture to get a soft streak like that?

amber saffron
steel notch
#

Damn alright.

amber saffron
steel notch
plain urchin
amber saffron
steel notch
amber saffron
steel notch
amber saffron
steel notch
#

Is there a way to specify the mip level of the sampler?

#

Is it the LOD version?

amber saffron
amber saffron
steel notch
amber saffron
amber saffron
steel notch
#

Turned up that mult to like 70

steel notch
amber saffron
# steel notch Turned up that mult to like 70

Well, the LOD input is a full number that goes from 0 to log2(texture size).
The bigger the texture, the more lod/mips.

And the unsaturated value of the color is probably not so much contrasted, so it needed a high multiplier to have effect.

As for why white areas result in lower resolution : white area = higher mip level sampled = blurier texture

steel notch
amber saffron
steel notch
#

So I imagine that actual smoothness textures don't just plug into the LOD of another texture?

amber saffron
#

But at the "root" of it, it is this logic.

#

btw, if you want something more independant of the reflection texture size, you can use a custom function to get the texture mip count :

cunning thicket
#

how do I shift the line up and down?

amber saffron
cunning thicket
#

ah ok

verbal stag
#

Guys, who has good tutorial of done shader graph (screenshot) of vertix waving flag? I am tired. All tutorials don't work. I want to cry😭

dim yoke
# verbal stag Guys, who has good tutorial of done shader graph (screenshot) of vertix waving f...

That's not really how it works. If "none of the tutorials worked", screenshot is not gonna work either. Very rarely the tutorials are wrong themselves so it's more likely you did something wrong. Us giving you a screenshot is likely going to run into those same problems. It would be much better if you followed a tutorial of your choice and asked here once you had a specific problem we could help with.

verbal stag
#

thx for answer

nocturne flint
#

If anyone here is more familiar with shaders I'm curious if the common approach is to just add more and more features to your main shader if you want to do things like fade out objects with a certain pattern.

I'm using a shader that I didn't make myself and was curious if there was a way to do such things without modifying the main shader I'm using (I don't want to break anything and haven't learned much about shaders yet).

kind juniper
nocturne flint
#

So if an object is using that shader I imagine there is no option but to modify that shader if I want to have a variable I can use to control a fading effect, correct?

nocturne flint
#

This would be something like a dot pattern of transparency that is applied across the mesh with its density increased till full transparency

nocturne flint
kind juniper
steel notch
#

I have some bloomed out regions in my texture that do... this?

#

Any idea what might be causing this?

kind juniper
steel notch
#

Like shouldn't it just... get brighter?

kind juniper
#

Is it hdrp?

steel notch
#

no URP

kind juniper
#

Hard to say. It would be helpful to know what values are there.

#

I don't remember if you can inspect the pixels in the frame debugger, but maybe start by looking at it.

steel notch
kind juniper
#

It's possible that at some point there's an invalid value produced, like Inf or NaN

#

That's why I hate HDR in rendering. It's just so messy...

steel notch
kind juniper
#

Yeah, I'm not saying to get rid of it.

steel notch
#

It's possible I'm making the shader in a way where it's hard to keep track of the bloom value.

steel notch
#

Not that I needed it to but, eh.

hollow cedar
#

Noob shader question here:

Do UVs just describe how the texture (or any other feature) is displayed? So for example, if I convert a rectangular UV to a circle, will the texture assigned to it wrap into a circle?

#

I’ve seen videos of people wrapping UVs into a circle just to show you that you can, but they never dig deeper and say why you might want to do that

#

I’m more or less trying to wrap a 1840x720 texture into a circle and am wondering if I’m headed in the right direction.

kind juniper
kind juniper
kind juniper
steel notch
#

Do those operations all expect 0-1 values?

kind juniper
kind juniper
#

Graphics is a pain in the ass. Especially when dealing with different platforms.
Ideally, it's all low level worries, so the engine should be taking care of it, but there's just so much factors, it can't account it all.

hollow cedar
kind juniper
#

Basically, you should think like that:

  • take the original uv at that vertex(let's say 0,0)
  • do whatever math you need on it (let's say it turns the final value to 0.5, 0.5)
  • that's the position in the texture that would be rendered at that specific vertex position.

The pixel shader does this for all the pixels on the screen that this mesh occupies producing the final image.

astral locust
#

Anybody mind explaining to me why my image texture doesnt render?

dim yoke
mossy sun
#

Hey there! I need some help real quick. I have that shader here... its from an plugin for 3D webviews. And i wanna write an ICanvasRayCastFilter that detects whether the pixel is transparent or not. Is that possible? My code does not work... im out of ideas.

#

Glad for any help!

amber saffron
mossy sun
mossy sun
# amber saffron How did you implement this shader with the ICanvasRayCastFilter ?

As far as i understand shaders (my knowledge is limited), the shader above has a mainTexture. I try to extract that mainTexture, copy it to a local Texture2D copy and then i basically just extract the pixel at that position.
But it does not work as intended, the pixelColor is always the same, wheverer i point to. What am i missing? or is my calculation wrong?

#

Imagine that the shader displays the web content on an canvas. And this filter above should detect whether the displayed web content is transparent or not.

#

Glad for any help ^^ i cant figure out what i am doing wrong for hours

amber saffron
mossy sun
amber saffron
mossy sun
#

GetPixel always returns: Color: RGBA(0.804, 0.804, 0.804, 0.804)

amber saffron
#

genaray raycasting on texture

hollow cedar
# kind juniper Basically, you should think like that: - take the original uv at that vertex(let...

So what you’re saying is that to wrap my 1840x720 texture, I would have to go through and convert each pixel to the polar coordinate value on the UV? So for example, the origin being at (.5, .5) on the UV (assuming that is where the center of a typical UV map is), I would go through on the texture and run a slightly altered polar coordinate conversion to place the origin pixel at (.5, .5) on the UV?

kind juniper
hollow cedar
hollow cedar
#

Thanks for your help!

hard moss
#

im using the ui blur shader for from the new shader graph ugui samples but it doesnt work with masking. how can i fix it?

verbal stag
#

they have same shaders

amber saffron
steel notch
#

Hold the phone I feel so dumb. This tab right here, it exposes Tiling and Offset fields.

#

I assume this happens at the node itself, right before sampling?

verbal stag
livid kettle
#

Bug with shadergraph makes my character look way edgier lmao, i think the issue may be caused by the texture itself brb

#

yeah problem solved by leaving 1 pixel of transparency on the edges of the image

neon raven
keen hearth
#

Theres gotta be a way to use object space instead of world for rotation

neon raven
#

had a crack at that but couldn't figure it out, fortunately its not that important :]

fathom lily
#

how do I get transparents to render with a fullscreen shader? I don't want to set the render order to render the screen shader before transparents because I want the shader effect to be applied to transparents, although right now it just makes anything transparent invisible

haughty plover
#

How do i make an outline / highlight shader graph i tried making it but nothing works for me i also tried youtube, gpt but the outline just doesnt work

kind juniper
fathom lily
kind juniper
kind juniper
# fathom lily

Can you provide some commentary? Not just screenshots. I don't know what your scene looks like and what is wrong with it. I don't have your project in front of me.

fathom lily
#

in the first 2 images, transparents are invisible, in the second two, they are visible

regal stag
#

If so, should use the URP Sample Buffer node set to BlitSource instead

#

That's the only thing I can think of which would cause transparents to not appear, since Scene Color relies on the opaque texture

steel notch
#

Hey so I'm trying to create an effect like this.

#

I imagined it working by producing a normal map to represent all these different viewing angles.

#

How would I produce a normal map shaped like this >_>

dawn junco
# steel notch

The rainbow part you could do like an iridescent shader. In shader graph, that'd be a fresnel effect node fed into a sample gradient node. Where the gradient is a rainbow.

For the normal map, some metallic paint flake normal maps look similar. Or you could create in blender by spawning a bunch of triangles as particles. And then bake a normal map from that.

fathom lily
#

saturate node is useless here, I just have it to visualize

steel notch
dawn junco
#

oh yeah, you could feed the voronoi into "normal from height" node

fathom lily
#

then change the colour based of the angle of reflection

steel notch
#

Like what is that data?

fathom lily
#

It’s what’s in the saturate node in the screenshot I sent

#

Solid colours of the voronoi, I assume you wouldn’t want the spherical gradient looking one for what you’re doing

plain urchin
#

Hi i'm trying to recreate an ASE shader to using SG
1st pic is in ASE, 2nd in SG
I'm mainly wondering what is the equivalent of "View Matrix" in ASE, in SG?

#

And what's the difference between View Vector and View Direction?

lime cloud
#

https://www.youtube.com/watch?v=YJSal0UocLY
Hello everyone, so am trying to make a 3D pixel art game. and i like how things look here. but i have a problem. is there a way to make this have more shading?, as in the video there's only 1 solid grass color, and 1 solid shadow'ed grass color. would it be possible if i made it more than 1 color?, like some sort of linear pixel gradient?

Date of Recording: 2020-11-02

Today I worked out a procedural day/night cycle system for my pixel art engine. The material colors are blended by interpolating between different variants of the materials for day, night, golden hour, and twilight depending on the angle of the sun. This gives the artist full control over the color palette for spec...

▶ Play video
#

Basically not make it look as soft as seen
And another thing, would it be possible to add outlines and maybe make animations more choppier to deliver the hand crafted pixel art feel?

#

(Just to clarify, i have not made anything close to this in Unity. am asking to determine whether the effect i have in mind is possible or not, if that's not the case then i have to pick up pixel-art)

mossy sun
#

Anyone here with a little shader experience?
Having a problem and chatgpt cant help me. I wanna write a ComputeShader that detects if a pixel in the passed Texture2D (linear, Y-Flipped) is black or not. How the heck do i do this? Chatgpt only outputs crap... this is my current code:

// Each #kernel tells which function to compile; you can have many kernels
#pragma kernel CSMain

Texture2D<float4> _MainTex;
RWBuffer<int> _Output;  // 0 = transparent, 1 = blockiert

int _PixelX;
int _PixelY;

[numthreads(1, 1, 1)]
void CSMain(uint3 id : SV_DispatchThreadID) {
    float4 color = _MainTex.Load(int3(_PixelX, _PixelY, 0)); // Pixel-Farbe abrufen
    bool pixelIsBlack = all(color.xyz < float3(0.15, 0.15, 0.15));
    _Output[0] = pixelIsBlack ? 0 : 1; // Alpha-Wert prüfen
}

Which kinda works, but is wrong. I do not get desired results, probably because it does not know that the texture is y flipped and linear. Can anyone help me real quick? ^^

amber saffron
#

As for beeing in linear or gamma space, that's not an issue since black is (0,0,0) in both cases.

mossy sun
# amber saffron If the texture is Y flipped, simply invert the Y coordinate 🤷‍♂️

Hmm... and what about the linear input texture part? Is that an issue?
The thing is, when i run that shader the result is weird (its not even y-flipped). For example, i have a button at the bottom from the inpute texture. The shader does not flip yet, so i aspect to get a valid color at the opposite, the top. However thats not the case, the only space i get an valid result from is a tiny space on the left for some reason. So im not even sure if thats the problem.

lapis oar
#

hi, i'm recreating a vertex shader from another game, but i've had some trouble trying to figure out how to get this object to render through these individual wall and floor tiles

#

the tiles and the sprite use seperate layers, sprites are Transparent and tiles are Transparent-1

dapper arrow
#

Under structure Varyings
Would it be any better to do
This: half fogFactor : HALF;
instead of This: half fogFactor : TEXCOORD0;

#

Just outta curiosity

mossy sun
#

So i have a compute shader reading an input texture to determine transparent/black parts. When the input location is black or transparent it should return 0. The input-texture is located on an canvas.
Thats the shader:

#pragma kernel CSMain

Texture2D<float4> _MainTex;
RWBuffer<int> _Output;  // 0 = transparent, 1 = blockiert

int _PixelX;
int _PixelY;
int _TextureHeight;

[numthreads(1, 1, 1)]
void CSMain(uint3 id : SV_DispatchThreadID) {
    
    // Y-Koordinate umkehren
    int flippedY = _TextureHeight - 1 - _PixelY;
    
    float4 color = _MainTex.Load(int3(_PixelX, flippedY, 0)); 
    bool pixelIsBlack = all(color.xyz < float3(0.15, 0.15, 0.15));
    _Output[0] = pixelIsBlack ? 0 : 1; 
}

called like this:

RectTransform rectTransform = rawImage.rectTransform;
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, screenPos, eventCamera, out var localPoint);

var rect = rawImage.rectTransform.rect;
var normalizedPos = new Vector2((localPoint.x - rect.x) / rect.width, (localPoint.y - rect.y) / rect.height);

int texX = Mathf.Clamp((int)(normalizedPos.x * texture.width), 0, texture.width - 1);
int texY = Mathf.Clamp((int)(normalizedPos.y * texture.height), 0, texture.height - 1);

// Prepare shader
int kernel = alphaCheckShader.FindKernel("CSMain");
alphaCheckShader.SetBuffer(kernel, "_Output", outputBuffer);
alphaCheckShader.SetTexture(kernel, "_MainTex", texture);
alphaCheckShader.SetInt("_PixelX", texX);
alphaCheckShader.SetInt("_PixelY", texY);
alphaCheckShader.SetInt("_TextureHeight", texture.height);

alphaCheckShader.Dispatch(kernel, 1, 1, 1);
outputBuffer.GetData(result);

However the shader or my calculation is wrong. See the attached image. It only detects black/transparent pixeels in the small red rectangle. All the other space it says its not blakc/transparent.

Why could this happen? Any ideas? Im stuck.

#

Thats the flipped input texture. My compute shader already flips the y-value

#

Any help appreciated, this drives me crazy

ebon basin
amber saffron
mossy sun
amber saffron
mossy sun
amber saffron
#

I'm out of ideas.

mossy sun
# amber saffron I'm out of ideas.

I did some tests. The input texture has the white area on top right? So i ran the computeshader with _PixelX = 100 and _PixelY = 1200 (since theres white). The compute shader returned that theres black. Looks like the damn compute shader does not do what it should, but why? I tested every corner, every combination like X 100, Y 1200, X 1200, Y 100 and it just returns black... some corner should be white in theory since the white label. But it is not

amber saffron
#

Can you maybe share the project ? I can give it a quick look, maybe I'll find what is happening

plain urchin
#

Hi. How come i can't connect a node to another in SG? This is for vertex position. If i recreate the nodes, it can connect all the way, but still can't let me connect to the final vertex position spot

mossy sun
low lichen
hardy thicket
#

Hi people!
Do you know any way to rotate this geometry in 3D space?🤨

ebon basin
#

Can you even rotate uvs?

#

Well, in a 3D space

hardy thicket
#

oh, you are right. but I was thinking there was some "trap" for fake it, because RGB could be "3 Axis".
Anyway I fake it!😁 👍 🙏

plain urchin
#

Hi all. I'm doing bottom path, but i thought the top path (using Transform node, Object to World) would be the same? They behave differently (the top path is incorrect billboard effect)
What's different?

earnest cliff
#

How do I stop the black sphere from clipping through because they are both set to transparent surface

regal stag
heady coyote
#

how can i write shaders to attach it to the camera?

steel notch
#

So I have a series of textures (count can vary) that need to be applied in the same way with different values. Is there any way to just loop through all of these textures? I've seen some shaders that seem to have like, "expandable/addable" regions? Is that a custom editor thing?

ebon moss
#

can someone epxplain why my implementation of a normal map isnt working?

#

It still doesnt work even if I put both spaces to object

steel notch
#

Does anyone have a repository of interesting normal map patterns? Something like this.

ebon basin
#

I just insert w/e fastnoise spews out at me

steel notch
steel notch
#

Is there any way to get the Primitive ID in Shader Graph?

fair cape
#

#if SHADOWS_SCREEN
float4 clipPos = TransformWorldToHClip(Position);
float4 shadowCoord = ComputeScreenPos(clipPos);
#else
float4 shadowCoord = TransformWorldToShadowCoord(Position);
#endif

Light light = GetMainLight(shadowCoord);
Color = CalculateCelShading(light, s);

int pixelLightCount = GetAdditionalLightsCount();
for (int i = 0; i < pixelLightCount; i++) {
light = GetAdditionalLight(i, Position, 1);
Color += CalculateCelShading(light, s);
}

#endif
}
somoeone can help
i tried to chane this script to work also with foward rendering but it doesnt work some expert ?'

winged radish
#

hey i am very new to shaders but i want to make the ground brigde effect from tfp

#

can anyone guide me

snow depot
#

Is there a premade hatching shader anywhere like this? Obviously the one in the picture but I can't find any place which actually provides it to be used.

rich ridge
#

I have a problem where the tilesets i'm making aren't connected, how can I fix it?

plain urchin
#

Hi all. I need advise on art asset management, specifically about UV sets, shaders, vertex color. For context, i'm doing the no texture, gradient atlas style

#

I'm just making a shader for sway. What's the common way to define sway-ness for a mesh?
I thought of making another UV set, and have the 0-1 in Y in the UV space to define how sway-y that vertex is
But should i use vertex color for this info?

#

What are the options of where i can store/author data in a mesh?
There's UV, and vert color. Anything else? Why are some things better suited for others, what examples, etc?

plain urchin
#

UV is a float4. So, is vertex color and UV the same thing, but edited differently?

plain urchin
plain urchin
#

I'm also wondering if, rather than relying 100% on painting the sway influence on vert color, maybe there should also be a programmatical way to define the sway influence. Like Y height, and/or XZ distance from origin

#

But could also be... vertex ID? I see SG has that node too

#

Hopefully there's a way to re-order vertex ID from a centerpoint pos, in blender

plain urchin
#

I'm figuring out what is "safe" to do, concerning batching/draw calls etc
I'm using URP. In this case i'm making a bamboo
I'm using GPU Instancer and considering if the unit of instance type should be a whole bamboo tree, or break it down to like 3: bamboo shoots, bamboo segments, bamboo mid leaf. Then with nested prefabs, assemble the variations in unity
Then i'd probably want the meshes in each prefab parts to register unto itself a bit of info of the whole tree's origin, for the shader to use for the sway

#

If i put this info to, maybe the 1st vertex of the mesh as a xyz (maybe in world space?), and do this register process in Awake, would this break mesh batching?
But it will not break material batching?

#

Perhaps making just a few variants of bamboo as single mesh (or, the parts have same origin point), is simpler for batching purpose?

fair cape
#

// Get main light
Light light = GetMainLight(shadowCoord);
Color = CalculateCelShading(light, s);

// Additional lights loop (For Forward+)
#if USE_FORWARD_PLUS

  UNITY_LOOP for (uint i = 0; i < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); i++)
  {
      light = GetAdditionalLight(i, Position);
      Color += CalculateCelShading(light, s);
  }

#else
// Standard additional lights loop (for non-Forward+)
int pixelLightCount = GetAdditionalLightsCount();

for (uint i = 0; i < pixelLightCount; i++)
{
    light = GetAdditionalLight(i, Position);
    Color += CalculateCelShading(light, s);
}

#endif
#endif
}
why foweer plus doest work ??

mighty mango
#

this is the shader i have for shadow for sprite but issue is i got shadow but not actual sprite, how i get both sprite and shadow both.

amber saffron
# mighty mango

What render pipeline are you using ?
URP and HDRP don't support multi-pass shaders. (or more precisely, they don't draw all the passes simultaneously and need specific implementation for that)

mighty mango
#

@amber saffron Thanks for replay,I use URP. well i am not actually good at shaders and graphs. basically i want result like this.

amber saffron
ebon basin
#

You can also do like a half-half workflow where you've got a textures in places that need that fine detail like faces, then use vertex colors on the rest of the models - vertex colors to color fill then use textures to overlay the model.

vestal bolt
#

Hi, guys! Have been using a shader from asset store for a while. Did not update anything including unity version and started to get this error during making a build: ’ maximum ps_5_0 sampler register index (16) exceeded ’. Why is it happening? I cant make only 1 build, than have this error untill i restart pc

fair cape
#

// Get main light
Light light = GetMainLight(shadowCoord);
Color = CalculateCelShading(light, s);

// Additional lights loop (For Forward+)
#if USE_FORWARD_PLUS

  UNITY_LOOP for (uint i = 0; i < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); i++)
  {
      light = GetAdditionalLight(i, Position);
      Color += CalculateCelShading(light, s);
  }

#else
// Standard additional lights loop (for non-Forward+)
int pixelLightCount = GetAdditionalLightsCount();

for (uint i = 0; i < pixelLightCount; i++)
{
    light = GetAdditionalLight(i, Position);
    Color += CalculateCelShading(light, s);
}

#endif
#endif
}
Someone guys can help i dont know why foward plus part of my cell shading dosentt work??

storm garnet
#

Anyone has experience making custom shaders in ShaderGraph for Unity's canvas?
I have a UI effect that need some custom shader, but I want it to still be driven by Button & Image components Tint.
Getting the texture from Image from easy enough since it's just "_MainTex", but I can't find how the color variable is named.
Tried "_Tint", "_Color", "_TintColor", etc.

tight phoenix
#

Im having some issues with the Overlay blend mode in my shader
I THINK the problem is that my input texture isnt in linear colorspace so the Overlay calculation is all wrong? But how do I save a photoshop png as linear color space?

If I pass in pure white I am expecting results like the left, but I am getting results like the right

#

is the problem that my texture isnt linear colorspace? How do I save a photoshop png as linear color space values? It needs to have the grey be EXACTLY 128 for this to work

#

I tried both of these implementations of overlay, but neither looks the same as it does in photoshop

#

Argh looks like all my problems were caused by colorspace conversion errors between linear and gamma

#

the results didnt look the same because I wanted gamma space overlay

snow depot
#

Can anyone help with finding shilloute edges using a compute shader? I'm really lost. I can (sorta, had to rely on ai a bit for the code) find edges but for some reason I just can't get it working with finding the shilloute edges once the edges are found.

kind juniper
snow depot
#

Oh I thought it had to be done via compute shader

#

Ok cool thanks

kind juniper
snow depot
#

There aren't really any tutorials so I just kinda asked an AI how I should even try going about creating it.

kind juniper
#

There must be some resources online touching on it. I'd recommend looking them up first. AI can be quite unreliable with something as complex.

snow depot
snow depot
#

Yeah that one. It didn't work when I added it so I think it doesn't work with newer versions. And it also never worked with skinned meshed which are pretty important.

snow depot
kind juniper
kind juniper
sour tide
#

Hey guys, I'm having issues with Pixel Art shaders and upscaling textures. In my current project, I'm trying to create interactable foliage and a shader that gives my grass a way to "flow" in the wind. However, I'm having issues with how its being rendered.

I've attached an image of how the shader is rendering the foliage, it's very wavy and not pixel shaders at all. I am using this video's shaders and have no clue why this isnt' working right. I do have Pixel Perfect Camera on and its set to upscale render texture.
https://youtu.be/ecYWvfMoRIM?si=X0PudysgELvWi_G1

steel notch
#

Still cant believe after all these years Shader Graph doesnt let you set Stencil operations

steel notch
#

Actually, do you guys end up going the HLSL route with most of your shaders, or do you lean more towards graphing/shader node tools?

mental bone
#

I have pretty much 100% transitioned to shadergraph and use custom function nodes for things not easily achieved with nodes

#

When block shaders come out we shall see

#

But right now the boilerplate for srp based shaders is too much

keen hearth
#

How would I make a shader that creates scrolling (in the y dir) diagonal lines

#

I need to be able to control their thickness as well

#

right now i have a strangely tiled line that has a slope of -1, while I want a slope of +1

#

maybe theres a way of filling in these "gaps?"

#

Maybe I should use a sine wave that is offset based on x?

#

And step the peaks ofc

regal stag
#

Optional Multiply with R/G outputs with -1 to flip directions

#

For other angles could use Rotate node on the UV instead and just one of the channel outputs

keen hearth
#

👍

azure geyser
#

if I have one rgba value, how do I essentially overlay another rgba value over it?

spring abyss
#

Unsure of where to ask this, but how do I achieve this interaction circle in blender? I tried materials but it looks grainy 😦

#

I did it, looks good enough 🙂

sharp wadi
#

Hi there! I’m experiencing an issue with the UGUI Shader Graph example. In the “Meters” tab, when I adjust the meter value, the circle progress shader doesn’t change at all. Also, the dial meter shader briefly transitions from opaque to transparent. What could be causing these problems?

sour tide
novel tusk
#

Hello guys, I have an issue related to shader graph. I use multiple render pipelines in the Unity project due to assets I am using. And I cannot convert to URP. (Or HDRP)

Reason is that most of the materials and assets are old and I don't want to throw them away because of the Render Pipeline. (And the developer who maintains the package will not update assets to URP)

My problem is I wish to create a realistic water effect. (With Ripples, Reflections, etc.) I followed the tutorial and could manage to create a build in Shader Graph for water. It supports all of the features described. With one con problem.

It doesn't support transparency of the shader (in URP it supports it)

So, is there anyone who can help with setuping correctly nodes in the way it could support the alpha color of the shader? (So I could have more transparent water?

amber saffron
novel tusk
novel tusk
#

But I really stuck and don't know where to add the paramater of "color"

#

I could share the shader graph code if you need. I just literally don't know how to manage this stuff

amber saffron
#

Ok, I though that you wanted to have a shader ported from built-in to urp. But you want to stick to the built-in pipeline, right ?

WDYM by "just add alpha to the color" ? Isn't the alpha/opacity output of the graph what you want ?

novel tusk
#

to the left you can spot a fish

#

(of the second image)

amber saffron
#

Sooo .... you have two shaders, individually with features that you want, but can't "combine" them ?

amber saffron
#

And what prevents/blocks you to do it ?

novel tusk
#

All I want basically is to grab "Ripple" system from picture 1, and add it to picture 2

novel tusk
amber saffron
# novel tusk lack of knowledge in shader programming

Oh, so left is the current shadergraph, right is a coded shader ?

Almost all HLSL/GLSL functions that you can read in shader code are available as nodes in shadergraph, so you "just" have to redo the same logic.

Alternatively, you can use a "custom function" node to copy/paste the shader code, but it might need some adaptations.

novel tusk
# amber saffron Oh, so left is the current shadergraph, right is a coded shader ? Almost all HL...

Opposite. Sorry for the confusion.

The right image is the shader I was following but I reached to the point where it wouldn't render the "see through"

I googled around and find out that I had to set it as "Transparent" not "Opaque" I set it and alpha variable appeared.

I controlled it using the Float value and it worked out.

I also managed to integrate (somewhat) correct system of Ripple. But it is pixilated. The shader on the left make it smooth. I wish to somehow just implement the smooth ripple effect to the shader on the right.

I am very sorry for confusion. My shader on the right just should be as is with only good feature of "smooth ripple"

RESOLVED

random sequoia
#

I'm working on a VR project and looking for a water package that delivers both high visual quality and strong performance under VR conditions, do you have any suggestions?

amber saffron
random sequoia
novel tusk
#

Resolved, this is not the solution.

tight phoenix
#

I am having an issue with the Overlay blend more and Linear color space I am not sure how to resolve UnityChanThink

#

my goal: I am trying to do Overlay blend mode, but Overlay works as Multiply from >0.5 and Additive <0.5, Linear colorspace is messing it up

#

White works the eway I expect, but black doesn't UnityChanThink

#

I am looking to get a result like the result in photoshop, but I am working in linear colorspace
I thought converting my greyscale to linear colorspace values would fix it, but that wasn't the case

#

I have tried with this both off and on, but it looks wrong in a different way for both settings

#

I THINK the problem is that Overlay works in ranges of 0 to 1, with 0.5 being critical, but linear and gamma color space's grey value at 0.5 is completely different

#

How to I fix it to work the way I want/expect though?

#

What color values does this texture have to be to get a result that looks like that for white/black but in Unity instead of photoshop?

tight phoenix
#

ive done lots of experimenting and it seems like it just doesn't calculate colors above the 0.5 point correctly

tight phoenix
#

this is just an ugly hack to try to take control of the values

#

added power on top of that 🫠 this lets me control the output look as much as I want, though I didnt want to have to do this much tweaking in post just to make it overlay right

#

I am hoping maybe there's just a parameter wrong in here that would solve all of this to make the brights behave nicer

halcyon panther
#

Having trouble finding any sort of info on this so I figured I'd ask here...
Are their any alternatives in HLSL to a switch statement?

Reason I ask is because I have this dissolve shader I wrote yesterday which allows the end-user to specify what easing function to use for the dissolve effect duration via a property. I feel like this could be made more efficient without a switch statement but I'm not sure how. While it is clean, imo, shaders are all about performance after all. The shader works perfectly atm btw. This isn't a problem I'm bringing to light; more so just opening up for discussion into alternate methods for choosing what easing function to use while keeping it in the shader.

https://paste.myst.rs/7kx5vkxt

past dune
#

I'm trying to create a wall shader that creates a hole in it, so you can always see the player, and as you can see of the first image it works. But I have the problem that even when the player is in front of the wall the hole is visible, how can I fix it? I thought to simply render the hole only when the wall covers even a little the player, but I don't know how can I do that. For context the effect is achieved by shooting for each pixel a ray and check if it intersects with a sphere which position is updated to the player coordinates

keen ore
#

why do black colors get rendered as totally transparent regardless of the fragment shader alpha?

#

🤦‍♂️ never mind, it looks like particles are just getting rendered in front of this object

waxen ridge
#

hello, how do i scroll these pixels?

i know how to scroll a noise with tiling node + time, but here I also need to create a pixelated version of the noise my uv node is occupied. so how can i scroll the noise?

ebon basin
#

What's wrong with tiling (offset rather) it before the noise

somber zenith
#

Hello, any idea why I can't plug the SampleTexture2D R channel in the Combine G channel? (it's grayed out)

shy forge
#

hey I have a dumb shader noob question

#

so from googling it seems like you really can't apply multiple shaders to a single material

#

so does that mean in production code people's shaders are massive?

#

what i mean by that is, I have my terrain shader graph, it's got quite a few nodes just to handle coloring based on height and slope

#

if I now want to add some grass to that shader, it needs to be incorporated into that same shader?

#

just feel like it would get overwhelming trying to handle all that in one shader

ebon basin
#

can't really connect nodes between each other at different shader stages

ebon basin
#

For exceptions is stuff like outlines which you can do at the post-process stage

shy forge
#

right, I've seen references to that

ebon basin
#

built-in actually was easier to kinda do multiple shader passes pretty easily, but URP kinda encourages you stuff it all together

shy forge
#

wild, after these first few shader graphs I realized graph view isn't for me especially once it starts getting really complex so I've started learning HLSL

ebon basin
#

Unity's* HLSL is worse honestly. Unless you've some experience with GLSL/CG, you're going to be fighting against Unity's macro and libraries as you try to learn general shader coding.

#

but allows you to manipulate stuff like lighting/shadow and other features than what you can do in shader graph

somber zenith
#

maybe textures aren't valid in vertex stage ?

#

To not cause XY problem, I'm trying to use a render texture R channel to define the height of vertices on a plane

somber zenith
shy forge
#

so i was following this tutorial on how to do procedural snow layers

#

it's kinda working on my terrain, but you can clearly see seams between my terrain mesh tiles

#

my hunch is that it's related to the snow noise part of my shader graph

#

is there a way to get it to sample the noise in world space?

somber zenith
#

Seems like either a UV issue or the noise texture that is not tileable

#

to fix the UV's you have to make the terrain corner starts at 0,0 and the opposite corner ends at 1,1 like so:

#
        private void CreateUVs()
        {
            int resVertices = _res + 1;
            var uvs = new Vector2[resVertices * resVertices];
            int i = 0;

            for (int z = 0; z < resVertices; z++)
                for (int x = 0; x < resVertices; x++)
                    uvs[i++] = new Vector2((float)x / _res, (float)z / _res);

            _meshFilter.mesh.uv = uvs;
        }
#

If you want to edit the shader instead, I think you can plug the Position.XZ node in the noises UV pin

shy forge
#

thank you. I actually managed to get it to work by using these 3d noise nodes

amber saffron
# halcyon panther Having trouble finding any sort of info on this so I figured I'd ask here... Are...

I think there is no much to do here, the easeType value is constant on the material, so there won't be branching change per wavefront and performance should be good.
If you wanted to be sure to only evaluate a single option on the material the only other way is to use keywords and shader variants, but this will increase compilation time and break batches :/

But you can also approach it differently, since I see that the easing is for a constant progression accross the whole object :
Option 1: Move the calculation to the vertex shader, and store the result to an interpolator (ie. UV.z). Less work to do per pixel.
Option 2: Do the ease on CPU in c#, and pass the dissolveProgress value as a material property, as it is constant anyway.

halcyon panther
# amber saffron I think there is no much to do here, the easeType value is constant on the mater...

Option 2 was my next immediate thought aPES_Think
I just really wanted a way of containing all the easing in the shader since I'm making this shader (and a bunch of others) as a framework for other modders to use in RimWorld modding. So ideally they can just do <_EaseType>3</_EaseType> in XML to set which function to use and not have to worry about C# at all if they don't know the language and just want to use the shader for a cool effect.

Option 1 sounds like a pretty straight forward yet still nifty little trick. Can't believe I didn't think of that. Either way, like you said the performance is already fairly good and this isn't even going to be running concurrently for more than a few materials at any given time. RimWorld is simple in that regard, thankfully lol Thanks for the feedback though and pretty much confirming my suspicions about the switch!

#

One more thing, I'm trying not to just ping you right away too 😄 ... but, say the easeType is not constant and for some reason we update it for whatever reason during runtime via SetInt() or worse yet we do this continuously on a persistent material for some randomized visual pulsing where the easing function is different every _Duration; how would that affect performance?

amber saffron
halcyon panther
#

Ah, makes sense. Thanks again!

hidden lotus
#

Any legends out there with shaders want to help me brainstorm something?

#

I only know the basics for shaders but I have a concept for HDRP that i'd like to hash out and see if its possible or the best solution

#

its related to distance compaction and distance lod optimization. originally was going to use a matrix to warp/compress mesh but I figure it could be done better on the GPU at scale

hybrid flax
#

I’d like to create a custom vertex color interpolation function to get the shapes in the attached image, or a rough approximation of them. I already know how to create the hard edge, but am looking for ideas on how to round out the otherwise sharp diagonal. So far I have tried leveraging the calculated vertex normals and face normals generated on the fly with limited success. I do get some curvy shapes with that method, but not very accurate.

green lantern
#

I'm having a weird issue, i have a shader that allows fog and lighting to affect sprites but i also need z-depth within it and when i turn ZWrite on it creates an outline on some sprites that hides the fog behind the objects

plain urchin
#

Hi, what's the correct way to make a model with multiple UV sets, that can be used in shadergraph?

#

My model has "generate lightmap" on, and now the other UV set is just not found, no matter which UV set i use in SG

foggy topaz
ebon basin
ebon basin
#

but if you do have the UVs, I believe you don't want to touch UV 1 (or was it UV2?) because unity uses lightmap data on those if you're baking it

brave dagger
#

hey all! I made a custom shader for experimenting, and when i assign textures to it, the top is fine; 3 of the sides are fine; and the bottom is fine; but one of the sides is upside down!
any fixes?

ebon basin
#

Open the cube up in* blender and flip UV of that side

brave dagger
#

it is a unity cube

#

that would have been what i would have done if i imported it but kind of new to unity so dont rly know what to do here 😅

#

@ebon basin sorry for ping but any ideas

ebon basin
#

Not entirely sure but I assume there's some logic you're missing to fix that case here unless Unity cube does have some bad UVs

if (absN.y >= absN.x && absN.y >= absN.z)
{
    texColor = (n.y > 0.0) ? grass : bottom;
}```
ebon basin
#

Really I'd just go make your own cube in blender and flip it and be done

brave dagger
#

yeah honestly atp i might as well

hazy leaf
#

Im currently implementing blur to my UI and I can't believe there's no easy solution for this simple freature. So far it's working great blurring the background gameplay..

However I also need to blur UI elements behind the blurring panel. I'm using UGUI Screen Space Overlay canvas and I know that you can also use screen space camera but I'm really bound to Overlay couse many scripts rely on the UI scaling :/

Is there a way to access the canvas when the blurring panel gets rendered or another way (preferrably a shader that runs on the GPU and isn't too demanding as we're already struggeling to maintain performance) ?

Edit: using HDRP unity 6

plain urchin
tepid pebble
#

i tried to make a shader with dither effect but mine has color but its supposed to not show the colors .is the problem with the shader graph itself or is it the renderer?

steel notch
#

If I told you I had a shader that needed 14 textures, how would you look at me?

vale turtle
#

someone ever did glowing eyes on a 2D animated characters?
I've been trying for weeks! I get my character to glow, but when I add my emissive texture then it doesn't glow anymore...

#

that's about as far as I was able to get

halcyon panther
autumn goblet
#

is there a way to programmatically place shader nodes in shadergraph using c#?

#

i don't want to create shader, but i want programmatically place,connect,disconnect,and delete shader node

vale turtle
snow depot
#

Does anyone know how to edit a shader's code to make it work with terrain?

ebon basin
#

You don't. ;)

halcyon panther
#

"Work with terrain" is an incredibly broad statement..

sleek radish
old cradle
ebon basin
#

That's actually pretty neat

hollow wolf
#

in the doc it said i can define the scope of my shader keywordhttps://docs.unity3d.com/Packages/com.unity.shadergraph@17.2/manual/Keywords.html

#

but i didnt found such settings, Unity 6.0.31 URP

halcyon panther
#

Are you on version 17.2.0 for shader graph though?

#

The version of Unity itself isn't the issue here

hollow wolf
#

i am on 17.0.3

#

i mean, the image that they used both is the same

#

https://docs.unity3d.com/Manual/shader-keywords-scope-fundamentals.html

When you declare a set of keywords, you choose whether the keywords in the set have local or global scope. This determines whether you can override the state of this keyword at runtime using a global shader
keyword.

By default, you declare keywords with global scope. This means that you can override the state of this keyword at runtime using a global shader keyword. If you declare keywords with local scope, this means that you cannot override the state of this keyword at runtime using a global shader keyword. For more information and a code example, see Using shader keywords with C# scripts.

Note: If a keyword with the same name exists in a shader source file and its dependencies, the scope of the keyword in the source file overrides the scope in the dependencies. Dependencies comprise all Shaders that are included via the Fallback command, and Passes that are included via the UsePass command.

#

not sure if it's correct tho, probably didnt bother to update the doc

halcyon panther
#

You still only showed documentation for one version prior 😄

hollow wolf
#

should i scrrenshoot every version?

#

fine

halcyon panther
#

That's...... not at all what I said or was even hinting at lol

#

You are on version 17.0.3 but you showed the docs for 17.0.4

#

Look at the 17.0.3 docs for starters to make sure you can do this in your version

hollow wolf
#

here;s from 2021 - 2023

#

there's no way they decide to change only the 17.0.3 and then suddnely backtrack on the next version

halcyon panther
#

That's not the point. Look at the docs for the version you are on for starters. That's what makes sense. Don't look at the docs for different versions if they don't apply to you. aPES_Sip

hollow wolf
#

ok then how do i access my current vesion? clicking "documentation" on the package redirect me to 17.0.4 version

brave flax
#

Hello, does anyone know how I could configure one material to reflect another? This is a vtuber/vrchat model, so I was trying with MToon and Poiyomi but I couldn't find a solution. I want the skin to reflect the shadow of the hair

amber saffron
brave flax
amber saffron
#

Isn't it just regular shadows ? Like, does the light in the scene have shadows enabled ?

onyx coral
#

(just a good guy making good shaders)

tepid pebble
halcyon panther
#

You could use a RenderTexture. Is this a full screen, post-processing shader you're making or what?

queen stream
#

I'm trying to create a 3D texture to store a density value that I can sample inside a compute shader. I'm not sure if this is the proper way to do that

void InitDensityTexture()
{
  Texture3D tex = new(Size.x, Size.y, Size.z, TextureFormat.RFloat, false);

  float[] densityData = new float[_voxelData.Length];

  for(int i = 0; i < _voxelData.Length; i++)
  {
    densityData[i] = _voxelData[i].Density;
  }

  tex.SetPixelData(densityData, 0);
  tex.Apply();
  CS.SetTexture(0, "_DensityTexture", tex);
}```
this is going to be used like a volume
#
  public struct VoxelData
  {
    public int3 Position;
    public float Density;
  }```
#

the purpose is to make something like this. Once i have the volume, I write vertices to a buffer, and those will sample the density at their position, which will be used for marching cubes

green lantern
ebon basin
#

Unless there's some specific DOF post-processing for 2D I'm not aware of

#

To me, it seems the outline is the transparent quads that are writing to depth so you need a way around that

green lantern
#

im just gonna do a work around and have a seperate camera for Background objects (a camera for main ground and foreground and seperate cameras for close background and for far background with different blur post processing on them)

pure flax
#

I am using HDRP's built in water system along with my own buoyancy system and the issue is that if i put a large object onto the water it reacts too violently to the waves and i could just up the drag a ton but it wont feel how i want it to, is there some way to match some sort of sine wave to the waves to create a smoother wave (i am not at all good at shaders)

south linden
terse bough
#

Sorry if this is a stupid question, but how can I pixelate the fresnel effect using my pixel-ify setup? (I haven't used unity in forever)

steel notch
#

Why does this not actually result in ints in the inspector?

#

Like I know they're floats under the hood.

stray orbit
#

If you create a compute shader to handle some effects, you need to manually pass in the projection matrices right? So like for example in a surface shader unity_matrix_i_p is automatically set but in a compute shader i assume you need to make a variable for it and pass it from the c# side where you dispatch it?

sour tapir
#

so i see, decal dosent always update and theres no option for that to enable
is it possible to make it always update and render?

kind juniper
#

And while we're at that postprocessing effects usually don't use compute shaders either.

versed dew
#

I'm not sure if this is the right channel for this. I'm guessing it's shader related. I have a spell that spawns a prafab under the players transform. As shown in the video, the prefab clips through the floor if on any elevation. Is there a shader or something that can make it follow along the terrain? I hope that makes sense

hollow wolf
versed dew
#

Thanks. I'll look into that once I've finished what I'm doing

fresh flame
#

I'm trying to implement beard customization, created seperate transparent texture that matches the same uv map and only has beard, blended them together like this and it works. However beard texture has a lot of empty spaces specially for other body parts. What can I do here?

amber saffron
fresh flame
# amber saffron Do you need a full texture for the beard ? If the base texture doesn't need alph...

No it doesn't. I added base texture, created another layer for beard and painted, then exported the beard. This way when I blend it goes where it belongs. Idk if that makes sense sorry.
I dont think base needs alpha at the moment so I can use that, do you mind explaining a bit more about the beard mask? Also would using the base alpha work with multiple customization parts like eyes and beard etc. together?

amber saffron
fresh flame
shadow kraken
amber saffron
# fresh flame Ah, gotcha. Yeah that wouldn't work then...

Basically, to make this work, for each part you need to lerp between the previous "layer" (starting with the base color) and the part color, by the part mask.

If done naively, this mean you need an individual texture for each customizable part.

But of course it can be done in better ways 🙂

Here is my suggestion, it needs some image editing skills but shouldn't be that hard :
In a single texture, use 3 channels to store 3 different informations for the customization :
Red : the ID of the part that is customized.
Green : the mask
Blue : a greyscale "light/shadow" for the part that can be applied as overlay blend to add details.

Then in the shader you replace each ID value by the matching color, overlay the light/shadow and blend with the basemap with the mask.

versed dew
fresh flame
#

I'm even ok with keep lerping for each part but what can I do about the empty part for beard for example? If I create a 32x32 beard and lerp it it wouldn't position itself to where it supposed to go

amber saffron
amber saffron
fresh flame
#

Ahh got it now

#

Thanks a lot

hollow wolf
#

in BIRP i think you can use stencil to make this work

#

not sure with the setup tho

versed dew
hollow wolf
#

some game that wont render player would just turn the ZTest to always, but if you have hand or weapon and dont want the particle to be render on top of it then i think using render feature would be the best way to do it

#

or use camera stacking, that could work as well

versed dew
#

Ok. I'm here to tackle this now :p

versed dew
hollow wolf
#

tbh stencil is hard to impelement bcs :
1.shadergraph doesnt have stencil
2.unity build in particle shader doesnt have stencil
3.you can inject stencil via render feature but's it's confusing

#

but that's just my opinion

#

except point 1 and 2, those are fact Laugh2

versed dew
#

brrrr. I tried changing the height of the spawned prefab relative to the terrains height... It was awful. I want the circle shown in the video to bend with the terrain. so if there's a slop and im on the edge of it (on the flat area) it'll be flat where i am then bend up the slop. meh

hollow wolf
#

if you are beginner to render feature and shader, i think camera stacking should be the easiest way to do

versed dew
#

I'll do this quickly and see how that goes. I'll send an update shortly

#

Thank you. Learned something new so that's sick ^^

hollow wolf
# versed dew It's way better

another way you can make the "area" effect as decal, and only use camera stack for the particle that flaying around, but yeah, you will need to fix the decal when it's near terrain that very steep, anyway congrats, happy learning Thumbglass

versed dew
static star
#

very inexperienced with shaders... but how can I accomplish this? and 2nd... would this degrade performance or no?

#

Left Photo = Current Shader | Right Photo = How it looks rn

#

basically I want it so the sides and the back of the camera would dissolve the object... but the front view would keep it solid at all times

stray orbit
autumn goblet
#

How are much are you guys willing to pay for a addon that makes it easy to bake texture in blender and automatically map those texture to any material

random hull
#

Hi! I'm a beginner to shader graph but I need to make an animated gradient background for a proyect. Can someone guide me on how I could achieve this?

steel notch
#

Alright this is going to sound insane cause I think I'm going crazy.

#

I have 2 textures.

#

They have semi-transparent regions.

#

How do I alpha blend them normally in shader graph?

#

And by alpha blend I mean imagine these 2 textures/sprites were just on top of each other in the scene view.

regal stag
steel notch
regal stag
ripe sedge
#

Any chance of using arrays in shader graph?

regal stag
#

Might be easier to stick to Texture2D

last flare
#

hello, if I need to process an array of input in a compute shader, would it be better to iterate on the cpu or pass it as a buffer array and do it in the shader?

steel notch
last flare
steel notch
last flare
#

ohhh didn't knew that, sorry to hear that lol

sour tapir
#

how do you guys even do shockwave on ground 😔

ebon basin
sour tapir
#

i mean like decals or smt for bomb shockwave

#

i realize decal dosent always update

ebon basin
#

They should. You can specifically make decal shaders

arctic iron
#

can anyone guide me on how to remake this shader in unity? i did the model + blade shader in blender before I realized the shader graph from blender is not importable to unity.. 😭

ebon basin
toxic flume
#

I use urp and shader graph to implement a custom sprite shader. My sprites are packed in some atlases. It seems I need to handle sprite uv adjustment manually in the shader, right?
So, I should pass the sprite origin/offset and the size in the atlas?

little sedge
#

idk where to post this but this channel seems right,so i made a room in blender and imported on unity and this wall was affected by face culling and was invisible,i made a work around by creating a material variant cause i couldnt change the variables in the shader component and it ended up like this how can i disable face culling without making the wall look like that?

gritty minnow
#

Is there a way to stop a shader graph shader from receiving reflections from probes? it's water with custom planar reflection / URP

regal stag
gritty minnow
#

omg that worked tysm!

#

i knew it would be something simple like that

zenith dragon
#

https://youtu.be/-07OX-gNarc?si=d1QBK0V51FXKe36D Does anyone know some tricks to achieve a similar visual style to the game "Antichamber" ? It has extremely "flat" graphics with almost hand-drawn style outlines on the models. Is it done with shaders or what?

A full no commentary playthrough of Antichamber

Game: Antichamber
Release Date: January 31, 2013
Platform: PC
Developer: Demruth

Antichamber is a first-person puzzle-platform game created by Australian developer Alexander "Demruth" Bruce. Many of the puzzles are based on phenomena that occur within impossible objects created by the game engine...

▶ Play video
hybrid flax
#

I'm sure I'm missing something really simple here, but I am trying to write my own frac() implementation to allow for offsetting, and for some reason input - floor(input) is giving me very different results from frac(input).

queen stream
#

would be an unlit shader + outline shader

solid scaffold
hybrid flax
#

I am pretty new to writing shaders, but I was wondering if there is a way to apply one to the entire scene and modify every vertex on the GPU? Possibly as a post processing layer. I have seen this done in Minecraft, warping the world like in Inception, but it’s possible the whole game world uses a single shader. Not sure.

kind juniper
#

In fact, it's not possible to affect vertices of any object in a pp shader.

plain urchin
#

Hi all. I'm using the Object node in shadergraph, mainly the Bounds size. But the value seems to change based on the camera distance, between the correct ( i guess?) value and a very high value. In the scene view, the value changes between these 2 in an interval. In game, it seems only between distance of 3-4 from object root does this, and any other distance outside of 3-4 is fine
Anything i'm misunderstanding here? Is it LOD related?

regal stag
hazy leaf
#

I'm making a custom pass for hdrp, does anyone know how the ScriptableRenderContext.CreateUIOverlayRendererList() method works?
Im using the DrawRendererList (line 96) to draw the overlay ui to a custom buffer, which works, but is there a way to only draw specific UI overlay elements (CreateUIOverlayRendererList draws the entire UI into the buffer)?

plain urchin
#

It's not SRP batching. Apparently on mine it's already off

#

If it's on, my mesh is always with that high value in every distance, actually

#

Oh wait maybe that's the other way around

#

The high value is the correct value

grizzled bolt
# little sedge idk where to post this but this channel seems right,so i made a room in blender ...

The correct solution would be to have normals pointing into the room, or duplicate the faces if you need normals in both ways (preferably give the walls some thickness too)
Disabling culling doesn't change the normals, so the lighting is calculated with negative normals
Though it's mostly visible with environment reflections, disabling them isn't a true fix because other parts of the lighting calculation are affected as well

little sedge
#

tnx

past dune
#

Hi guys, I'm trying to phade in/out a previous room in my isometric game, my approach consists of using a second camera that uses layer culling to render the previous room, render it to a renderTexture and then with a shader post process it on top of the main camera using OnRenderImage , it works but this approch does not respect the depth buffer, so my second camera overwrites the main camera and viceversa. How can I fix it so that the depth culling is handled properly? Do I get somehow the second camera depth buffer and pass it to the main camera post process shader or there is a better way

stoic phoenix
#
fixed4 frag (v2f i) : SV_Target {
    return float4(1, 0, i.uv.x, 1);
}```Can someone please explain why in my hlsl shader the color is only being outputed as red and not a gradient as it should be?
regal stag
stoic phoenix
#
v2f vert (appdata v) {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);

                return o;
            }```I mean I guess I don't know much but i'm pretty sure here unity does it for me on default
stoic phoenix
regal stag
#

Sure, using tiling from texture. Maybe that's set to 0,0 on material? Would also want to make sure the mesh is UV mapped

stoic phoenix
#
Shader "Unlit/WaterShader" {
    Properties {
    
    }

    SubShader {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

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

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

            sampler2D _MainTex;
            float4 _MainTex_ST;

            v2f vert (appdata v) {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);

                return o;
            }

            fixed4 frag (v2f i) : SV_Target {
                return float4(1, 0, i.uv.x, 1);
            }
            ENDCG
        }
    }
}
```Here's the full shader
#

i think i'm not doing anything w the texture at all

regal stag
#

Then that's likely the problem, remove the texture and TRANSFORM_TEX (just o.uv = v.uv;), or add the texture property back at least (so _MainTex_ST can be set correctly)

stoic phoenix
#

Ok I will try just removing it then

stoic phoenix
#
fixed4 frag (v2f i) : SV_Target {
    float target = cos((i.uv.x + _Time.y) * 25);

    return target;
}``` Why does it move at like 0.1fps
#

if i multiply the time value no matter how it will still have a gross and choppy framerate

regal stag
past dune
#

I used this to render the second camera renderTexture to the main camera```cs
//main Camera
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
this.UpdateTexture();
Graphics.Blit(source, destination);
// Then draw the overlay with alpha
if (this.material != null)
Graphics.Blit(this.renderTexture, destination, this.material);

}``` Should I somehow get the second camera depth buffer and manually compare depths in the shader or is there a better approach
hushed silo
#

I want to have a starry sky skybox, I’m currently using a cubemap but would love a way to get it crisp without very high resolution image (it’s for mobile). Are there any performant ways?

#

I dunno something like a noisemap multiplied by view angle and just taking peaks or something….

stoic phoenix
#

I was having a lot of issues

#

is there a reason it's not like that on default

regal stag
#

Probably to improve editor performance

meager veldt
#

i was editing a shader graph and for some reason the preview isnt showing anything, just a transparent sphere. some of the nodes look weird as well. but the material i made out of it looks fine. i tried restarting unity but the preview and nodes still dont show properly. how do i fix this?

regal stag
meager veldt
#

your a genius 😭

#

thank you

#

cant believe i didnt realise that

#

wtf

#

so you just looked at those pics

#

and understood what the shader was doing in like 30 seconds

regal stag
#

Kinda yea, mostly from the result in inspector and since it's named Grid

meager veldt
#

🤣 fair enough

#

and yes i know i couldve probably just used the sample grid they gave and just modified it a bit

#

but this is my first time and i thougt it would be interesting to try it myself

steel notch
#

Let's say I have a sprite sheet texture that's broken up into many frames. I want to tint each frame of the sprite using a gradient across its Y axis.

#

When I use the UVs in shader graph, the UV values change since we're moving through the sprites on the texture.

#

So how do I do this? Any tips?

grand jolt
#

using the urp, however when importing urp materials they show up as pink for some reason

#

and i know the project is correctly made as URP, as when given the offer to change material shaders, it offers to change them TO URP

#

nevermind i fixed it turns out i replaced the URP asset by accident which unsynced the two

hushed silo
#

it looks like canvas render targets got added to urp in 16.... is it not possible then to do this kinda thing even on a world space canvas in 2022?

#

I'm particularly wanting to use it on something that uses the radial 360 mode with fill

regal stag
hybrid flax
#

For reference this is how I am calculating normals. I tried adjusting the offset, but it doesn't seem to be related to the banding:

    float2 e = float2(1e-2, 0);
    
    float3 n = GetDist(p) - float3(
        GetDist(p - e.xyy),
        GetDist(p - e.yxy),
        GetDist(p - e.yyx)
    );

    return normalize(n);
}```
hushed silo