#archived-shaders

1 messages · Page 95 of 1

terse sedge
#

Ok. Just tell me a proper shader for cubemap mirror... Ripping was my only choice, as i tried "skybox" method

warm pulsar
#

i wonder if the albedo color's alpha gets clamped to 0..1

#

given that it's not an HDR color, typically

#

Are you writing a surface shader here?

dull magnet
terse sedge
#

How to make a cubemap reflection

rare wren
terse sedge
#

I tried using cubemap skybox but surface just vanished

terse sedge
rare wren
#

I think there is a Sample Cubemap node iirc..not fully sure on thay

#

Likely also findable on google

terse sedge
#

I want to make a mirror

rare wren
#

Hmmmm maybe calculate the direction the mirror goes in than?
Like calculate the bounce angle

stray orbit
#

What include do i need for Linear01Depth in URP when using HLSL? i am not really familiar with shaders. I am trying to convert the depth of a depth texture to a linear value and output it on screen so i can clearly see objects further away change color.

#

This is my shader so far. With the Linear01Depth i get an error about no matching 1 parameter function found i think. so i assume it doesn't find the Linear01Depth function

Shader "Hidden/Test"
{
    SubShader
    {
        Tags
        {
            "RenderPipeline" = "UniversalPipeline"
        }

        Pass
        {
            Name "Test"

            ZTest Always
            ZWrite Off
            Cull Off
            Blend Off

            HLSLPROGRAM

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"

            #pragma vertex Vert
            #pragma fragment Frag

            float4 Frag(Varyings input) : SV_Target
            {
                // better performance?
                UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);

                float depth = SAMPLE_TEXTURE2D(_CameraDepthTexture, sampler_CameraDepthTexture, input.texcoord);

                float linearDepth = Linear01Depth(depth);

                return float4(linearDepth, 0.0, 1.0, 1.0);
            }

            ENDHLSL
        }
    }
}
regal stag
copper flint
#

I'm trying to learn shaders in unity and am trying to apply a rendertexture to a WaterMesh that I have that has it's own material. The game is a 2D platformer and from what I've heard you need to create a second camera, set the output texture to your new rendertexture with the layer pointing to the water and exclude it from main camera. But I'm stuck at the part where I can see the water rendered with both cameras since there isn't many resource about it online.
Any ideas?

kind juniper
# terse sedge I have cubemap

You'll need to explain better what you want. Is it just a normal mirror? If you can't explain, share a video/screenshot showing what kind of effect you want to implement.

kind juniper
copper flint
#

I have a water mesh that am trying to make look pixalated. So I have assigned it to a "Water" layer. It's the only layer on culling masks for the "Water" camera and it's excluded from the normal camera. But now that the camera is outputting it to a texture renderer. Is there a smart way to display it on the same location and size where the "Water" mesh is supposed to be

kind juniper
untold mantle
#

Does anyone know how to integrate a splatmap into a shader graph? The way I have it is I isolate each color using smoothstep and/or subtract, and then multiply that with the texture, and add all textures back together for the final product, but the result is terrible and extremely pixelated for the base color, and utterly broken for the normals. I know it's more straightforward with terrain tools, but I'm using my own procedural terrain implementation.

civic lantern
#

Normals can be blended with Normal Blend node

#

You need to use Normal Strength on its inputs to have correct weights

untold mantle
civic lantern
#

Nope, not sure what that is about, maybe show the shader that you tried?

#

Looking at my shader now, I made a subshader like this for the blending:

#

And in the main shader I just chain those:

civic lantern
#

Oh and the SampleTerrain subshader just samples the three textures

#

This setup supports 5 texture layers, first one is the base layer (at zero splatmap 0, 0, 0, 0), and the next 4 are blended according to R, G, B, A

#

Can be extended to use more too. I just didn't need that yet

untold mantle
#

the splat map is 2K

civic lantern
#

Which I suppose is this

untold mantle
#

blue is sea, clear is desert, cyan is lakes and rivers, green is grassland, red is swamp, yellow is mountains, and white is icy mountain peaks.

civic lantern
#

It seems to have very sharp edges, so I'm not surprised that smoothstep does not give a smooth result

#

Oh I just opened it in browser, it is indeed pixel sharp

#

And huge

untold mantle
civic lantern
#

It's a bit hard for me to follow the logic in your shader. But I suggest trying the consecutive lerping method that I also used

untold mantle
#

i guess I should separate both workflows

civic lantern
#

Your splatmap is 4096*4096 actually

#

Or are the pixels larger

#

I think they are

untold mantle
#

but ithey're identical

civic lantern
#

Looking at the 4k texture, looks like each pixel is actually 5 pixels wide

#

(just put it into paint and drew those lines for measure)

civic lantern
#

What if you just toss it into something like Gimp or Photoshop and blur it?

#

If you want some smooth transitions

#

Because, sharp large pixels don't get you any smoothness

untold mantle
civic lantern
#

I can't really comment on the shader logic

#

Takes too much brain power right now to understand it

#

Smoothstep is probably a decent way to do this, but it doesn't make sense when you don't have any smooth transitions in the splatmap

#

I would try something like this
Image 1 = original
Image 2 = +median blur (4 pixels)
Image 3 = +gaussian blur (3 pixels)

untold mantle
#

But I think there are still problems with the logic, since it gives the borders this purple color, and some of the mountain peaks are detected as sea around the edges

civic lantern
untold mantle
civic lantern
#

I know but still. Would be easier to see it in context.

untold mantle
#

ok

untold mantle
fast igloo
#

I wanna blur harsh lines from the vornoi cells but I don't know the node for it in shader graph

stable copper
#

I see that Unity Toon Shader URP is not compatible with Unity 6, can you please recommend me the alternative that is compatible with Unity 6?

stray orbit
#

I would like to get the worldspace position of the pixel, is this correct or does the depth need to be linearized? i am not sure how i can best test if it's correct for shaders.

float depth = SAMPLE_TEXTURE2D(_CameraDepthTexture, sampler_CameraDepthTexture, input.texcoord);
float3 worldSpacePosition = ComputeWorldSpacePosition(input.texcoord, depth, UNITY_MATRIX_I_VP);

I think this is probably right, i just find it hard to verify if it's correct.

terse sedge
#

Just a mirror

#

I know about camera method but i need cubemap for better performance

kind juniper
# terse sedge Mirror

You Can probably just use a reflection proble and a completely reflective surface.

terse sedge
#

But i also need help with mirror-y surfaces

#

Ill send screenshot later

warm pulsar
terse sedge
#

This effect

#

And this mirror

#

They are made from cubemaps

#

I used assetexplorer

kind juniper
#

A cubemap is just a texture type. Reflection probes bake cubemap textures as well.
This doesn't tell anything about how they are rendered.

#

Luckily, unity standard shaders support reflection probes out of the box. Just use a reflective material.

terse sedge
#

Note: im using unity 2022.3.45.1f

kind juniper
terse sedge
#

+how to do hdri

#

you helped me alot, and i will be so happy if you tell me this lil thing

kind juniper
kind juniper
terse sedge
#

im not native english speaker

kind juniper
terse sedge
#

HDRI map is for reflections

terse sedge
kind juniper
#

As I said many times now. You can use a reflection probe with a reflective material.

terse sedge
#

can you please make a screenshot of mat properties

#

like where to put cubemap

#

i have cubemap

kind juniper
#

The santadard shader would use the cubemap generated by a reflection probe automatically

#

If you want to use a custom cubemap texture, you'll need to look up a shader that does that or create your own. Should be pretty simple with a shader graph.

kind juniper
#

There are probably some built-in (legacy or mobile) shaders that can use a cubemap texture directly, like legacy/reflective/diffuse or something

kind juniper
hardy juniper
#

God at some point you need to go learn about this properly yourself...

terse sedge
#

Legacy > reflective > Bumped (any)

untold mantle
lavish skiff
#

Hi, I need some help, been looking around the internet a lot already (and chatgpt).

I'm using a Scriptable Renderer Feature with the Render Graph API. In it I am currently only rendering vertex colors for my edge detection to a texture and use it later in a post processing shader made in Shader Graph. I'm using drawSettings.overrideMaterial in the render feature pass for this and it works well.

Now, I also need to include a single integer/float that is different per game object, it's essentially an ID and I need to render it into a texture along the vertex colors (ex. R channel is vertexColor.x, G channel is vertexColor.y and B channel is the new ID). The problem is I've no idea how to properly pass this ID from the game object (or it's base material) to the pass inside the renderer feature.

  1. I tried MaterialPropertyBlock, but it doesn't work with the batcher.
  2. I tried to use drawSettings.overrideShader to keep the base material properties, but it was glitchy and didn't work with the batcher.
  3. I didn't try just constantly having 2 copies of each game object with different materials on different layers and rendering them separately, but this seems to be a giant hack (but still may be more performant than the property block).

Any help? 🙂

devout quarry
#

What’s the ID for? What value will you give it? You can do a hash based on world position maybe?

#

Or encode ID in vertex color G channel, depends on what you use the other vertex color channels for.

#

Or MPB + GPU instancing if you have many of the same meshes.

lavish skiff
#

ID is actually a "group id" (so edges will apprear between two groups of game objects in my edge shader) and it may change per object at runtime (so writing it into the vertex color is no). Instancing may help a bit. I guuess I really need to some wonky stuff.

devout quarry
#

So object position won’t work?

#

So edges will appear between game objects.

inland adder
#

Hey there! HDRP's fullscreen sample shaders cause this error to appear:

A BatchDrawCommand is using the pass "DrawProcedural" from the shader "HDRPSamples/EdgeDetection" which does not define a DOTS_INSTANCING_ON variant.
This is not supported when rendering with a BatchRendererGroup (or Entities Graphics). MaterialID: 761 ("Belt"), MeshID: 2855 ("Hand_watch"), BatchID: 3.

As far as I can tell, Unity expects these shaders to be DOTS-compatible, which they're not, even though I'm not using DOTS? Is this a bug, or does anyone know a solution?

devout quarry
#

How do you know Unity expects them to be DOTS compatible? If they are just a HDRP sample?

inland adder
#

Because of what the error message says? I also tried googling it and it seems to be what others suspect too

devout quarry
#

Ah you’re not using DOTS, missed that

inland adder
#

Yeah, when i try to use the materials associated with them in the scene, the materials break and this error appears for each mesh renderer that tries to use the material

grizzled bolt
inland adder
#

I'll try that, thanks

inland adder
#

Seems something has change in Unity 6 which meant my Custom Pass setup somehow caused the error. Thanks for the help anyway!

buoyant geyser
#

Is there a way to set up a camera that only captures shadows? I've tried a shitload of different setups, but no matter what I can't figure out a way to capture the shadows of a renderer to a render texture. Setting the renderer shadows only always culls it from my camera. I need a way to create a mask texture from the occluders in my scene. Making these occluders visible but excluding them from the culling masks of my main cameras isnt an option because if i did, they wouldn't be able to cast actual shadows in those cameras

#

im trying to set up a raymarched shadow shader and to do that i need an accurate mask of the occluders in the scene drawn to a texture so that i can test intersections with that mask

onyx cargo
#

Sorry for necro'ing this... what kind of node is the "SpecularAO" node?

grizzled bolt
broken sinew
#

yo

#

is debugging with renderdoc possible for unity in vulkan mode?

kind juniper
steel notch
#

Are there any techniques to get pseudo-normal maps?

#

Either generate them from the source texture or something else?

#

Just something to get a sense of curvature along an image.

tacit parcel
# steel notch Are there any techniques to get pseudo-normal maps?

just get the difference between current height and neighboring height
you'll need atleast 3 samples, current, nextHorizontally and nextVertically.
It should be fast (iirc, opengl es2 can sample up to 8 textures simultanously), I managed to run it smoothly even on my old samsung galaxy a02 phone

steel notch
tacit parcel
steel notch
#

Higher fidelity model or something and we slap it onto a lower poly one?

grizzled bolt
# steel notch Are there any tools that help with the generation of normal maps? I'll be honest...

Typically high poly to low poly baking
Generating them from textures is for when you don't need to capture exact normal detail or if the surface is relatively flat and the pattern is generic
Gimp has a very simple height to normal filter, which I like to use with its mean curvature blur if I want something quickly that looks pleasant but accuracy isn't that important
XNormal is a very powerful tool for pretty much all types of normal map generation
Blender can bake normals from meshes as well, and you can implement your own setup for baking them from heightmaps as well which gives you more precise control and lets you easily use Blender's procedural geometry for making normal details

#

But I guess it depends on what you mean by "pseudo-normal maps" and "sense of curvature along an image"

civic lantern
#

(I think you have to invert R to make it OpenGL format)

grizzled bolt
#

That one looks to have the same algorithm as Gimp, but has more generators in it
At least the grainy artifacts are the same, which the mean curvature blur is useful for removing while preserving the shape

steel notch
#

This effect can appear on hundreds of items and behaves the same way. I was thinking to myself there's no way they created normal maps for every item?

civic lantern
#

Are those 3D rendered or hand painted images originally? Hard to tell with that resolution

#

If 3D rendered, the normal map can just be rendered in another pass when rendering/baking the image

steel notch
#

The second item from the left is "enchanted" with a shield effect.

#

That one I can see as just being powered by a mask.

civic lantern
#

Could be 3D rendered and hand painted on top, using the normal map from the 3D layer

#

Or even AI generated 🤷‍♂️ (The normals I mean)

steel notch
#

Even this shield effect is kind of impressive.

#

It has an outline to it.

#

Idk I just can't imagine multiple masks being made for each of the hundreds of items in the game?

civic lantern
#

It can be automated if they used a 3D render as the base

#

Rendering out normal maps, depth textures and whatnot

steel notch
civic lantern
#

Not saying that's for sure what they did, it's just what makes the most sense to me

civic lantern
#

The 3D can be used to render out the needed maps

steel notch
#

Oh like the creature in the frame is actually 3D and they just draw over it >_>

civic lantern
#

Yeah

steel notch
#

Idk we see these frames rotate a full 180 in game and I don't really see anything 🤔

#

Though I guess it could be slight?

civic lantern
#

It wouldn't be true 3D in game

#

Just a flat 2D texture with some shading

steel notch
#

Oh just for the normal map gen.

#

I see. Hmm.

grizzled bolt
#

They all look pretty far from 3D so it's more likely the normals are generated
Though, the sheen is not consistent with what you'd get just by generating from grayscale
So it could be offset by a diagonal gradient or similar in the shader
Or the normals could be AI generated

tacit parcel
steel notch
steel notch
civic lantern
grizzled bolt
sacred hull
#

Hi! I am making a dissolve shader graph, and for some reason the mesh's shadows are rendered on top. Is there a way to fix this?

civic lantern
sacred hull
civic lantern
#

Yeah

#

It will fix those sorting issues too

#

Should, at least

broken sinew
sacred hull
#

It doesn't look invisible

#

Well, not when it's in front of the water anyway

civic lantern
#

You made it opaque, right?

sacred hull
sacred hull
#

The threshold value was too low

#

Thank you so much 🙏 ♥️

steel notch
#

Hey just to make sure I'm not crazy, when setting up a normal map in shader graph, you need to set the texture type to Normal Map (in import settings) and set the sample type to Normal in the Sample Texture 2D node, right?

civic lantern
#

Sounds correct to me

steel notch
#

Hmm. Double checking these settings, it just seems related to cleanup/storage.

#

Making sure values are normalized and stored in optimal channels.

#

I can just use the map raw if I wanted.

sacred hull
#

I have a shader I want to use when the player "spawns" objects. There is a value in the shader that I want to continually change for 1 second in my script when an object is spawned. This makes the object look like it is appearing out of thin air. What if the player spawns another object during that 1 second? Will the new object and the old one share the same material? Is there a way to create a new instance of the material, so that I can update their values individually?

hardy juniper
#

mesh renderers should instance anyway automatically or when you access via .material.

terse sedge
#

what is shader graphs

neat orchid
#

The normal vector range is different in a normal map thab other maps (-1 to 1 instead of 0 to 1)

#

Even if you do normal reconstruct after the texture, it won't look as good because marking it as normal changes the compression setting to one that is special for normal maps

#

The only thing you can do i use the alpha channel of the normal map for something else because alpha channels are uncompressed

copper flint
#

Hey, I'm trying to make the edges for the water mesh match the aesthetics of the game by making it look pixealated. I'm lost on how I should go on about doing it since I'm new to shaders and I can't seem to find any resources online doing it either. Here is my shader graph is anyone is interested

smoky widget
#

Hellou, I made this method, which is nice, but interlock add slows it down

[numthreads(GROUP_SIZE,1,1)]
void Count(uint3 id : SV_DispatchThreadID)
{
    if(id.x >= _MaxInstances) 
        return;
    

    uint index = _ReducedIndices[id.x];
    uint LodValue;
    uint Transition;
    uint ShadowTransition;

    uint VisibleNormal;
    uint VisibleShadow;
    UnMask(_TargetLODs[index], LodValue, Transition, VisibleNormal, ShadowTransition, VisibleShadow);

    if(VisibleNormal > 0){
        if(Transition > 0)
            InterlockedAdd(_Counters[LodValue].countTrans, 1);
        else
            InterlockedAdd(_Counters[LodValue].countBase, 1);
    }
}

I was thinking to modify it so that in an for loop insead each thread i handle multiple of those cases, and only call one interlock add at the end, essentially making part of it sequential. THe method is fast enough that it could work. However, is there any better way to reduce the amount of IntterlockedAdds? like some kind of global variable in the thread group or something like that

hardy juniper
copper flint
hardy juniper
#

yea thats another way to write it i just gave an example of reducing a 0-1 value to 265 possible values only.

copper flint
#

oh i see! i did try doing that on the line calculation already but it still didn't work. should it be applied to every single UV maybe?
Here is the example i tried:

hardy juniper
#

yea if you want it to affect something then ofc it needs to be applied?
you can also do a custom function to make it a bit cleaner or group it

copper flint
#

ye i meant i applied it but visually it didn't really change, it looks the same

hardy juniper
#

what thing specifically do you want to make "pixelated"? Texture sample?

copper flint
#

I want to go from img2 to img 1:

hardy juniper
#

can you be specific

copper flint
#

first image has edges when the line is "curving" while image 2 just curves so it doesn't have that pixealated look

#

it gives it more of that retro 16 bit look while the other looks vectorized

hardy juniper
#

reduce the depth to make the "steps" larger

copper flint
#

you mean here?

hardy juniper
#

dunno what you have before but you want the position to be reduced in depth

steel notch
#

Anyone have a good SDF generator?

amber saffron
low lichen
#

And what do you consider "good"? Does it need to run in real time or just in editor? Does it need to be exact or is performance more important?

copper flint
steel notch
#

Like contour represents 0.5 etc etc

smoky widget
# smoky widget Hellou, I made this method, which is nice, but interlock add slows it down ```...

So i got this now

[numthreads(GROUP_SIZE,1,1)]
void Count(uint3 id : SV_DispatchThreadID)
{
    if(id.x >= _MaxInstances) 
        return;
    
    uint index = _ReducedIndices[id.x];
    uint LodValue, VisibleNormal, VisibleShadow;
    UnMaskBasic(_TargetLODs[index], LodValue, VisibleNormal, VisibleShadow);    
    
    _sharedCounters[LodValue] = 0;
    GroupMemoryBarrierWithGroupSync();
    if(VisibleNormal > 0){
        InterlockedAdd(_sharedCounters[LodValue], 1);
    }
    GroupMemoryBarrierWithGroupSync();
    InterlockedAdd(_Counters[LodValue].countBase,_sharedCounters[LodValue]);   
}

the problem is that it doesn't compile, so im not sure what would be the appropiate way to write back to the global buffer?

amber saffron
desert orbit
#

@dapper heath Don't cross-post.

dapper heath
#

my bad, I wasn't asking the same question, I was asking a new question using the original as reference

#

I originally asked about the source of my camera jitter, then someone answered me and I realized it was a camera matrix issue, so I asked here about camera matrices and how to round them with a rotated camera axis

desert orbit
dapper heath
#

that is true, I read up and realized camera matrices are probably not a shader thing

#

apologies

#

do you happen to know anything about matrices

desert orbit
#

I mean the people are still trying to help you there

dapper heath
#

I got the impression they were more interested in telling me that I crossposted than the problem at hand

dapper heath
#

yeah that's what I'm referring to

#

I read through his chat history and figured he probably wouldn't be able to help with the matrix thing

#

but I didn't want to be rude and say that

sick kernel
#

Hello, need a tip. I'm in the default renderer 2D (so not URP), trying to write in HLSL (which I don't know that well).

I currently have a lot of objects consisting of 2 sprite renderers, so I can combine 2 sprites with different colors for tons of variations with little graphics data. Now to get better performance I thought about combining both sprites into one spriterenderer with some cool shader which takes in a texture, 2 colors and 2 vector4 (or similiar) to draw the 2 sprites combined. I can manage the sprite combination and coloring, but the UV mapping? I can hardly make sense of it with SpriteRendrer...

Any tips on how to calculate UV stuff from a Sprite reference in C# and then render that sprite in a shader using a texture and a vector4? Thanks 🙏

hardy juniper
sick kernel
#

and to be clear we're talking 10k objects, having 10k less gameobjects in the scene helps a TON

#

(of course the best solution is to use GPU instancing, but I am too noob and I think I can get away with this if I optimize other areas too)

hardy juniper
sick kernel
hardy juniper
#

If you want to go this route you need to calculate the uv min/max for the other sprite and set it on the material for use.
If the sprite renderer is already showing another sprite from a sheet, you need to provide this sprites uv too so you can correctly calculate the final UV

sick kernel
#

or do invidividual sprites somehow generate their own texture? That sounds very strange though

hardy juniper
sick kernel
hardy juniper
#

the sprite renderer component generated the mesh so unless you change it there it probably wont get updated correctly

sick kernel
hardy juniper
sick kernel
#

Im gonna test it out

hardy juniper
sick kernel
deft remnant
#

Trying to recreate mapping from blender in unity, so far so good, it's based on screen, but it changes it's size when I move closer/further (blender one is too being shown on screen, but the size of the pattern stays constant, I tried multiplying by distance from camera, but it's not really it
Any suggestions? Using Built-In, ver. 2022.3.9f

viscid root
#

hey, I'm following a URP shader tutorial and trying to adapt it to BiRP
TransformObjectToHClip() is a URP function, and I don't know how it works, how do I replicate it in BiRP?

warm pulsar
#

That ought to be the UnityObjectToClipPos function

viscid root
#

thanks

copper flint
#

Hey, I'm still trying to solve my pixealated water shader issue and have now made the waves move in a pixealated way. My next step is to make the lines the 16 bit edges retro styled. I have tried pixealting the UV by multiplying it then rounding it then dividing it but the line height size seems to be the only thing affected and nothing else. This is my current image together with its shader graph and the one next to it is my goal image:

#

(Line Length: 0.92, Bits: 16)

#

Any help is appreciated!

#

I think I figured out! It seems like since I am using a mesh that is procedurally generating the mesh when I resize the mesh the pixels also get resized along with it. That way it doesn't become "pixealated" anymore.

Does anyone know a way around that? Maybe something with vertex position?

hardy juniper
#

The mesh will need to be created in a way to do this I think judging on how its working rn.
If the water height was all in the shader then it would work with the prev method

copper flint
#

Maybe transforming object to world would remap the pixels?

#

I would like it to be dynamic since I will be reusing that material

hardy juniper
#

I think as long as you use the mesh to define the top its going be hard to do this effect nicely
If you can split the water into some horizontal sections then you can maybe do something? im not sure at this point

eager adder
#

helo im new to unity in the shading department and i was trying to learn shadergraph to make a simple hologram shader but i dont quite know what im doing, i was trying to follow a person on YouTube (https://www.youtube.com/watch?v=wVmhqzzkFYE) explaining how one can create one but i cant seem to figure out some of the stuff he shows as he was using a diferent version of shadergraph and a different version of unity it seems because some of the stuff he shows does not appear there for me and i was wondering if anyone was willing to take a few minutes and explain to me a few things. sorry to bother anyone

In the last video, we created holograms in Shader Graph. This time, we're adding distortion and noise effects to add a bit of imperfection - it's like making the effect look worse, in a good way!
✨ Read on my website: https://danielilett.com/2020-07-21-tut5-10-urp-hologram-2/

💻 Get the source on GitHub: https://github.com/daniel-i...

▶ Play video
hardy juniper
eager adder
#

well my first problem came to the property he called _RECEIVE_SHADOWS_OFF and how when i go look at the debug menu to add it, it shows a different thing than what he showed and when i try to add valid keywords it always adds then to the invalid keywords

#

I also dont quite understabd what funccion it does as i cant see any shadows in said materials

hardy juniper
#

to be clear, its to disable shadows rendering ON this shader itself

#

shadow casting is different

thorny owl
#

and this is shader I am using:

#
 mesh.SetVertices(vertices);
 mesh.SetColors(meshColors);
 mesh.SetUVs(0, uvs);
 mesh.SetUVs(1, meshScales); // Scale
 mesh.SetUVs(2, meshOpacities); // Opacity
 mesh.SetUVs(3, meshRotations); // Quaternion rotations
 mesh.SetIndices(indices, MeshTopology.Triangles, 0);

I have all this data that I pass in the code, however in reality don't use most of it yet at all. As I apply most of data on vertices data.

mighty nebula
#

new to shader graph, trying to make a full-screen blur effect,
Can someone explain why I can't connect the URP Sample now to the shader I found?
It won't let me connect the output to the first input of the shader

hardy juniper
# thorny owl and this is shader I am using:

cant really see the graph clearly but from the video it looks like normals are inverted and with you setting custom mesh data its probably not recalculated.
try recalculating those and tangents and see if it helps. Best idea i have rn anyways

hardy juniper
civic lantern
hardy juniper
#

the node must sample the texture inside it, if its yours modify it to accept any color vec3/4

mighty nebula
# hardy juniper the node must sample the texture inside it, if its yours modify it to accept any...

here is the code

{
    float4 col = float4(0.0, 0.0, 0.0, 0.0);
    float kernelSum = 0.0;

    int upper = ((Blur - 1) / 2);
    int lower = -upper;

    for (int x = lower; x <= upper; ++x)
    {
        for (int y = lower; y <= upper; ++y)
        {
            kernelSum ++;

            float2 offset = float2(TexelWidth* x, TexelHeight * y);
            col += Texture.Sample(Sampler, UV + offset);
        }
    }

    col /= kernelSum;
    Out_RGB = float3(col.r, col.g, col.b);
    Out_Alpha = col.a;
}```

COuld you point me how to update this?
hardy juniper
#

Ah i just realised this wont work unless you can access the raw texture/buffer as that node is only to sample it.

#

otherwise you will need to re create this in nodes to work with it

mighty nebula
#

hmm. I can't find much about this, do you know a good tutorial for creating full-screen effect? I need to create a guassian blur that affects just the top part of the screen. Unity's documenation about the "URP Sample Buffer" is extreamly limited

thorny owl
# hardy juniper cant really see the graph clearly but from the video it looks like normals are i...

I will try to do so, but doesn't normal shouldn't be effecting it, if it is being rendered both sides? As if I change it to opaque it renders it correctly. I will try recalculating anyways, but just to make sure.

While normalize does not effect it at all. If I flip vertices array, it displays another side correctly. So it is about order of vertices indeed. So I need to find a way how to either manually change order in run time depending on distance to camera, or somehow use depth buffer and let unity handle it. But neither I know how to do exactly

eager adder
#

small question regarding shader graph vector one refers to a normal float?

civic lantern
eager adder
#

ok thank you

#

also im not sure if i followed said video right as the mesh of the material appears on a difernt space

#

never mind i did something wrong i fixed it

#

is there a way to use this shader that is showed in the video but to make it so if the mesh has overlaping stuff it wont do this?

kind juniper
eager adder
#

and where would i add the depth test

kind juniper
#

In your pixel shader. Though you'll probably need an additional pass to render the depth to a texture. You'll probably need a custom depth texture if it's a transparent material.

#

Might be easier and more performance friendly with a stencil buffer🤔

eager adder
#

im sorry i dont quite know what a stencil buffer is

kind juniper
#

You'll need to learn it then.

eager adder
#

ok something to add to the list, ill study it tomorrow thanks tho guys this helped me a bunch

fair badge
#

2D URP sprite shadergraphs seem always multiply SpriteRenderer color with the color I passed to fragment base color in my shader graph. I there anyway to ignore this behaviour?

#

please check this simplified example. I expect the output is white(HitColor) but is green(SpriteRenderer color)

hardy juniper
regal stag
worthy grail
#

Does anyone know how to pixelete this shader?

amber saffron
worthy grail
rigid halo
#

Texture Atlases and UV makes me very annoyed. (just venting.)

steep wigeon
#

I have been working with unity for 3 years, but thw thing is, i have 0 knowlage of shaders.

Is there any resource where i can learn how shaders work? Like, any recomendations?

kind juniper
rough lotus
#

glsl is virtually identical to hlsl too which is quite helpful

dull magnet
#

if I update mesh.uv4 in a C# script, and I have a HLSL shader that has texcoord3 in the appdata struct (so I read it from the vertex shader to the fragment shader), is the fragment shader going to get the updated value?

civic lantern
civic lantern
#

Show the C# part where you change the uvs

dull magnet
#

1 sec

dull magnet
# civic lantern Show the C# part where you change the uvs

in start():

    void Start()
    {

        mesh = GetComponent<MeshFilter>().mesh;

        var uv4 = new List<Vector2>();


        for (int i = 0; i < mesh.vertexCount; i++)
        {
            uv4.Add(Vector2.one*2);
        }

        mesh.uv4 = uv4.ToArray();

in frag:

       fixed4 frag(v2f i) : COLOR
                {
                    if (i.uv4.x >= 1.9 && i.uv4.x <= 2.1) discard;

in vert:

 o.uv4 = v.texcoord3.xy;

in hlsl:

              struct appdata_t
                {
                    float4 vertex : POSITION;
                    fixed4 color : COLOR;
                    float3 normal : NORMAL;
                    #if SHADER_TARGET >= 40
                    centroid float2 texcoord : TEXCOORD0;
                    #else
        float2 texcoord : TEXCOORD0;
                    #endif
                    float3 worldPos : TEXCOORD1;
                    uint id : SV_VertexID;
                    float4 texcoord3 : TEXCOORD3; // <-- this is uv4 right

                    UNITY_VERTEX_INPUT_INSTANCE_ID
                };

                struct v2f
                {
                    float4 pos : POSITION;
                    float4 color : COLOR;
                    #if SHADER_TARGET >= 40
                    centroid float2 texcoord : TEXCOORD0;
                    #else
        float2 texcoord : TEXCOORD0;
                    #endif
                    float3 worldPos : TEXCOORD1;
                    uint id : TEXCOORD2;
                    float2 uv4 : TEXCOORD3;

                    UNITY_VERTEX_OUTPUT_STEREO
                };
eager shadow
civic lantern
#

Cool!

potent coral
#

How do I fix this issue? I'm trying to get the blue mesh to wrap around the car, but I get these holes in the mesh.

civic lantern
#

It's a common issue with this technique

potent coral
civic lantern
#

Maybe there's a library or built in function for welding vertices of a mesh together. The shading would look different then, though

#

Maybe a post-process/fullscreen effect is more suitable here

potent coral
civic lantern
#

You mean RecalculateNormals? It isn't supposed to work on hard edges

#

Unity creates duplicate vertices for hard/sharp edges so they have different normals per each face

dim yoke
# potent coral How do I fix this issue? I'm trying to get the blue mesh to wrap around the car,...

If having two versions of the model, one with flat shading and one with smooth shading is not an option, I would definitely look for post procsessing outline effects like Osmal suggested. The extruded mesh outline method is limited to smooth shaded meshes (no split edges) and even when you get it working, it cannot guarantee constant width outlines (normals affect the direction and therefore the distance each vertex will move on screen. The edge quality is also limited by the amount of vertices the model is made of). Post processing outline with jump flooding algorithm (or even brute force) can guarantee perfect outlines with constant width

dim yoke
#

I would argue that edge detection outline post prcosessing is often the best for very thin (around one pixel) outlines, mesh extrusion outlines are good for somewhat thin outlines ( < 10 pixels mby) with low fidelity requirements and jump flood or blur based post processing outline is the way to go for anything else. The mesh extrusion outline may work very well on some specific models (like sphere or smooth shaded cube) but may do poorly on some other types of meshes. Now that I think about it, the smooth shaded normals could be stored on the same mesh as vertex colors for example to be able to use the same mesh for the base mesh and the extruded outlines. This just requires doing this for all of the models using the outline in a modelling software or editor extension of some sort. Smooth shading an model for the outline mesh is suboptimal still though because this will make the normals change very rapidly on the corners and can cause issues such as uneven outline thickness

gloomy tendon
#

But it requires some clever coding...

#

or use 3d tool to make separate mesh to expand

potent coral
#

It's not really perfect honestly

#

public void SmoothMeshNormals(Mesh mesh)
{
// Get vertices and normals
Vector3[] vertices = mesh.vertices;
Vector3[] normals = mesh.normals;

// Create a mapping of shared vertices
for (int i = 0; i < vertices.Length; i++)
{
    for (int j = i + 1; j < vertices.Length; j++)
    {
        if (Vector3.Distance(vertices[i], vertices[j]) < 0.001f)
        {
            // Average normals for shared vertices
            Vector3 averageNormal = (normals[i] + normals[j]).normalized;
            normals[i] = averageNormal;
            normals[j] = averageNormal;
        }
    }
}
dim yoke
dim yoke
fossil cloak
#

Hey!
I am working on a shader to apply a LUT on my textures.
For this i added a Custom Fuction Node to Shadergraph.
Sadly its throwing an Error.
To Debug it, i created a second Custom Node with some very basic Code.

float3 ApplyLUT_Test(float3 color) { return color; }

But i still get the error shown in the Screenshot.
Whats wrong there?

potent coral
kind juniper
#

It should not have a return type. The outputs should be an out parameter. Check the docs for details.

fossil cloak
desert orbit
#

@ancient plaza You've be informed already that this is not a place to advertize. If you want to learn how to do something, ask an appropriate question.

ancient plaza
#

i dont know what questions to ask since i have no idea how to use shader code 😭

devout quarry
#

You can store it in UV8 channel for example then use that smoothed direction to extrude the vertices. Works well in my project!

potent coral
stoic flint
#

anyone got a unity's terrain.SampleHeight but in HLSL (compute) ?

amber saffron
stoic flint
#

so, simple sampling from the heightmap texture isn't enough

amber saffron
#

I don't think that terrain.SampleHeight works differently.

#

(Maybe it does, but I have some doubts)

stoic flint
#

you don't understand the problem here is that it produces VERTS then into TRIS, sample height doesn't do that. its simple bilinear filtering based on a step size. that DOESNT produce accurate heights on the unity terrain (slightly above and slightly under) this is due to UNITY tris being NOT a single point, but a 3d PLANE in space.

#

does that make sense ?

amber saffron
#

Yes I understand.
I did indeed give the "rough" answer.
From what I see in the code provided in the dicussions post, it should work in HLSL if you provide all the necessary informations.

Now, it could be even more complex than that as the sampled height of a triangle can vary with the terrain settings and view distance ...

stoic flint
# amber saffron Yes I understand. I did indeed give the "rough" answer. From what I see in the c...

of course, but can you have a look at my code?


float3 GetVertexLocalPos(int x, int y)
{
    const float heightMapResolution = 2048;
    
    float heightValue = heightMap.Load(int3(x, y, 0)).r;
    // Calculate and return the vertex local position based on the height value
    return float3(
        (float) x / (heightMapResolution - 1) * terrainWorldSize,
        heightValue * terrainWorldHeight,
        (float) y / (heightMapResolution - 1) * terrainWorldSize);
}
float SampleHeight_UNITY(float2 worldPos)
{
    const float heightMapResolution = 2048;
    
    float2 localPos = worldPos - terrainCenter.xz;
    
    // Calculate normalized texture coordinates in the terrain
    float2 sampleValue = float2(
        localPos.x / terrainWorldSize,
        localPos.y / terrainWorldSize);
    
    float2 samplePos = sampleValue * (heightMapResolution - 1);
    
    int2 sampleFloor = int2(floor(samplePos));
    float2 sampleDecimal = samplePos - float2(sampleFloor);
    
    // Determine if the upper-left triangle is chosen (based on the decimal values)
    int upperLeftTri = sampleDecimal.y > sampleDecimal.x ? 1 : 0;

    // Get the three vertices of the triangle at the sample position
    float3 v0 = GetVertexLocalPos(sampleFloor.x, sampleFloor.y);
    float3 v1 = GetVertexLocalPos(sampleFloor.x + 1, sampleFloor.y + 1);
    
    int upperLeftOrLowerRightX = sampleFloor.x + 1 - upperLeftTri;
    int upperLeftOrLowerRightY = sampleFloor.y + upperLeftTri;
    float3 v2 = GetVertexLocalPos(upperLeftOrLowerRightX, upperLeftOrLowerRightY);
    
    float3 n = cross(v1 - v0, v2 - v0);
    
    float localY = (-n.x * (localPos.x - v0.x) - n.z * (localPos.y - v0.z)) / n.y + v0.y;
   
    return localY;
}
#

maybe i missed something

#

ive been in here for 6 hours now.. any little help is appreciated

amber saffron
#

float2 localPos = worldPos - terrainCenter.xz;
Should subtract the minimum of the terrain AABB, not the center. Something like
float2 localPos = worldPos - terrainCenter.xz + terrainWorldSize.xx * 0.5;

stoic flint
#

honestly doesn't matter since terrainCenter.xz is 0. (its supposed to be terrainOffset, bad naming on me), either way its not offsetting the problem. look

#

something with sampling seems to be the problem

#

height is off

amber saffron
#

Hum, visually it looks like the terrain min and max Y is not properly applied to the sampled value (if all the samples are properly aligned on XZ)

stoic flint
#

yes

#

but why

low lichen
amber saffron
#
  1. I don't see a line that matches worldPos.y = localY + terrainAABB.Min.y; , I guess you ignored it because the minimum of the terrain is 0 ?
  2. Does terrainWorldHeight match the terrain height value set on the terrain component ?
stoic flint
#

1- yes 2- yes

amber saffron
#

Double check 2.

The last thing that could come to mind (but it wouldn't make sense for an heightmap texture) is that some linear/gamma correction is necessarry on the sample value.

#

You could try to add
heightValue = pow(heightValue, 2.2);
or
heightValue = pow(heightValue, 1/2.2);

in the GetVertexLocalPos function.

stoic flint
#

sadly no

amber saffron
#

None of those did even get close ? 😅

stoic flint
#

if it helps anyhow, it seems that this terrain is more accurate than this

#

first seems to produce more accurate results

stoic flint
amber saffron
drowsy shuttle
#

how can I randomise the movement of my trees I made a vertex displacement shader using shader graph how can I calculate the vertex displacement in world space. all trees are moving in One Direction looks kind of awkward

kind juniper
#

Calculate a random direction vector and pass it to the shader. Or use some kind of random function on the gpu side and only provide a seed for every tree

amber saffron
#

@drowsy shuttle
Unsolicited support requests via DMs are prohibited by the community rules.

drowsy shuttle
#

I just friend requested

amber saffron
#

You did send me a fried request, and that's probably for DMing me...

stoic flint
#

@amber saffron i fixed it. seems like unity is doing something to the png. i directly read raw file and it worked.

amber saffron
stoic flint
orchid hedge
#

i gave a question about my shader i made. It looks like this. Now i want the layers to be more see through but if i change the surface type from opaque to transparent in the shader editor nothing changes.

devout quarry
orchid hedge
#

yeah i have a part of my shader which decreases the height of the cylinder through the alpha

devout quarry
#

So which value is the alpha?

orchid hedge
#

so i guess for the bottom 1 and the rest 0 but even if i remove the component and make the alpha lower to like .3 the cylinder just dissapears

devout quarry
#

Surface Type is opaque?

orchid hedge
#

no its transparent here

#

ok i changed it on the material itself i think you ment this idk why it doesnt apply it to the material it works now

#

but it now looks very weird

devout quarry
hardy juniper
azure geyser
#

Does anyone know how to view the code of a built-in editor shader?

I'm trying to view the code for Hidden/Handles Circular Arc

potent coral
#

Not sure if this is the right place to ask, but is there a way to properly discard a generated mesh when you're done using it or is that properly handled by garbage collect?

hardy juniper
shell cradle
#

Could someone explain how to use the rerfract node in shader graph to me? (https://docs.unity3d.com/Packages/com.unity.shadergraph@14.0/manual/Refract-Node.html) I'm trying to implement snalle's window (https://en.wikipedia.org/wiki/Snell's_window), which would be dependent on the angle from the camera to whatever point on the plane we're currently referring to in the shader (which should be veiw direction from my understanding), and I believe the IOR for the source, which is underwater, is ~1,33, the IOR for the medium is air, which is 1, and the normal vector would be just the normal of the plane. However, beyong that I get a little lost. Is the output of the refract node is the modified direction of the light after it hits the plane?

mortal osprey
#

how can I use vertex shading in urp?

#

I want to create gouraud shading, is it possible?

astral turret
#

looking at using a newer version of something akin to this:
https://toqoz.fyi/thousands-of-meshes.html

I have been changing it over to Unity 6.0, and ran into an unfamiliar error when attempting the instanced and instanced indirect versions of the shader code

#

this stuff did work in 2022 unity, but for a number of reasons I'm trying to modernize it. and the shader code is just from the "toqoz" article. I'm guessing there's a format issue with having SV_InstanceID used or declared that way?

I'm curious if anyone is familiar with this at all.

devout quarry
#

In non shader graph as well of course.

uneven inlet
dim yoke
amber saffron
# uneven inlet

I think the question is

Why isn't my fan rotating like it is intended to ?
And the answer would probably be
Change the rotation axis, probably to (0,0,1)

uneven inlet
uneven inlet
dim yoke
# uneven inlet just wanted to share it here

When you want to ask about specific issues, make sure to add written description of your issue to make it clear it's an issue you need help with. Btw. one tip on working with different coordinate systems: Red Green Blue is the standard coloring for the axes X Y and Z. You can see the axis system unity uses from the top right corner, they seem to be named too so you don't even need to remember them

uneven inlet
warm pulsar
#

which is not in that screenshot!

#

Figuring out exactly where the problem is coming from can be a bit of a nuisance...

#

I guess I would rename the vertex stage to something else and see if the warning message changes, though

#

because I do not see anything else named "vert" in that article

#

might as well do a sanity check

astral turret
#

gotcha. will try that out! - new to shaders so utterly new to sanity checking it

warm pulsar
#

Also, which step are you on? DrawMeshInstanced or DrawMeshInstancedIndirect?

#

I guess this would just be DrawMeshInstanced

#

I don't get any warnings using the DrawMeshInstancedDemo script to render a bunch of quads with the corresponding shader. Unity 6000.0.33f1 (with the HDRP, go figure!)

#

I only get that warning if I, say, move o.vertex = UnityObjectToClipPos(i.vertex) into the #ifdef region

#

Okay, yeah, it does just say the output variable is named "vert".

#

I guess Unity winds up inserting your vertex stage function into another function that assigns its result to an out variable

astral turret
#

I'm on DrawMeshInstancedIndirect. I'm updating from unity 2022 to 6 because I was having trouble getting things i wanted working - I'm trying to extend this for sprite functionality - so I've gone through the basic coloring step in Instanced w/o any trouble. However I did add a little bit of code from the demos. I'm trying to see what I can toss.

Right now I'm at work, but I will be off in 6 hours XD so then I'll be able to get back to you on more

warm pulsar
#

But it should still compile properly

astral turret
#

strange that it wasn't. also it was so late (and I'm getting sick) that I may have posted the wrong block, heh.

warm pulsar
#

you've mixed together the DrawMeshInstanced and DrawMeshInstancedIndirect shaders here

#

Notably, you're still trying to use the UNITY_SETUP_INSTANCE_ID macro, but its argument, i, isn't a valid variable name

#

can you share the entire shader file? !code

echo moatBOT
astral turret
#

ah, yep because I added in the IN. but I haven't run/used this yet... this was after I tried to solve the initial error by pivoting

warm pulsar
astral turret
#

the code I just posted was just me trying to solve it before going to zzz

warm pulsar
#

I can't reproduce the warning after editing the vertex stage to match your original screenshot

#

Perhaps you modified the v2f struct?

#

but it looks fine in the file you sent

astral turret
#

agreed. and from the looks of my edits no (I used some undos to get back to that point - the very next edit is me posting in the link to code I was looking at as a framework to pivot)

#

I can try the file I just sent or... well, anything I can find. will see tonight if I get more errors

warm pulsar
#

yeah, I see no reason for that warning to have come up. There must have been some difference that got lost.

astral turret
#

thanks for taking a look. will update as I can

naive grail
#

is it good practice to use shaders in place of material references or should i make a material for each shader? (using shadergraph, 2d game, built-in pipeline if that matters)

warm pulsar
#

i'm not sure what that would entail

#

a material uses a shader

dim yoke
naive grail
#

when assigning materials in code / inspector

#

materials can be used as well as shaders without a material

#

i'm assuming from the response that they basically have a material automatically created for them which i kinda thought but wasn't quite sure about

thin crown
#

Hey yall, im currently trying to cook up gerstner waves with the help of chatgpt as there aren't many tutorials that explain it well enough for me to understand it, is there anyone here that made gerstner waves before that could help me a lil with it? I got abt 95% done, the sin texture is done, just need to make it gerstner wave instead of sinus wave.

(Ping me with replies btw bc i don't really check the unity discord that often)

warm pulsar
#

Getting the normals right was a bit of a nuisance. I got my axes mixed up an embarrassing number of times

dim yoke
# naive grail when assigning materials in code / inspector

Assigning materials? To where? How? Materials and shaders are not the same thing and I cannot think of a situation where they would work interchangeable, neither in code nor in inspector/editor. I have no idea what you are referring to with "assigning materials". Screen recording of what you mean could be very helpful

timid jolt
#

just found this, i think i’m gonna make this and then change the distortion / ripple effect to be more like water rather than the swirl that is there now. hopefully this works 😄

https://youtu.be/jdAbVkre8cw?si=00jci4VTNKsoOduz

A shield effect using Unity Shader Graph and a bit of c# code.
Implements the hit effect distortion.

Download the project: https://github.com/abitofgamedev/shields

Support me on Patreon: https://www.patreon.com/abitofgamedev
Follow me on Twitter: https://twitter.com/steffonne
Follow me on Instagram: https://www.instagram.com/abitofgamedev/

Un...

▶ Play video
muted pecan
#

I need some help finding out whats going on with my project shaders :v

Im making a VR game in unity 6, for some reason when i play on the vr, all my shader graph materials just become purple :/
If i play without the VR it works fine the shaders, also the shaders give the error of "Out of memory while Parsing", but that doesnt make sense since ive checked multiple times and my memory is never full.

What can i do?

rare wren
astral turret
#

hm. it looks like the shader works without error now. huh

muted pecan
#

I checked the memory through the task manager

rare wren
astral turret
muted pecan
rare wren
#

To check, disable it and see

muted pecan
#

Ok give me a sec

muted pecan
rare wren
#

Is Unity updated?
Do you do anything screen space in the shader?
Do default shaders work?

muted pecan
#

I found how to get the errors. there are multiple on different shaders

Compilation failed (other error) ''
Compiling Subshader: 0, Pass: Universal Forward, Vertex program with STEREO_INSTANCING_ON
Platform defines: SHADER_API_MOBILE UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_RGBM_ENCODING UNITY_NO_CUBEMAP_ARRAY UNITY_NO_DXT5nm UNITY_NO_RGBM UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PLATFORM_SUPPORTS_DEPTH_FETCH
Disabled keywords: 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_ENABLE_DETAIL_NORMALMAP UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_PBS_USE_BRDF1 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_VIRTUAL_TEXTURING USE_LEGACY_LIGHTMAPS _SAMPLE_GI

#

there is this one too

out of memory while parsing
Compiling Subshader: 0, Pass: Universal Forward, Fragment program with EVALUATE_SH_VERTEX STEREO_INSTANCING_ON _MAIN_LIGHT_SHADOWS _SHADOWS_SOFT
Platform defines: SHADER_API_MOBILE UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_RGBM_ENCODING UNITY_NO_CUBEMAP_ARRAY UNITY_NO_DXT5nm UNITY_NO_RGBM UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PLATFORM_SUPPORTS_DEPTH_FETCH
Disabled keywords: DEBUG_DISPLAY DIRLIGHTMAP_COMBINED DOTS_INSTANCING_ON DYNAMICLIGHTMAP_ON EVALUATE_SH_MIXED FOG_EXP FOG_EXP2 FOG_LINEAR INSTANCING_ON LIGHTMAP_ON LIGHTMAP_SHADOW_MIXING PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 SHADER_API_GLES30 SHADOWS_SHADOWMASK UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_DETAIL_NORMALMAP UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_PBS_USE_BRDF1 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_VIRTUAL_TEXTURING USE_LEGACY_LIGHTMAPS _ADDITIONAL_LIGHTS _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHT_SHADOWS _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3 _FORWARD_PLUS _LIGHT_COOKIES _LIGHT_LAYERS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN _REFLECTION_PROBE_BLENDING _REFLECTION_PROBE_BOX_PROJECTION _SCREEN_SPACE_OCCLUSION _SHADOWS_SOFT_HIGH _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _WRITE_RENDERING_LAYERS

#

im pretty sure its some dumb setting i messed up, im a bit confused still with the new pipeline workflow in unity 6

rare wren
#

Could it be you're out of GPU memory?

#

Otherwise I am not too sure. You could file a bug report for this as well to get it fixed

muted pecan
muted pecan
rare wren
#

Then you're good yeah haha
I'd file a bug report if there are no other errors and post to the forums as well

#

It's in help - file a bug report

muted pecan
#

Thanks 😉 i think i will mess around a bit more before sending a report, but good to know how to make one.

#

Ok like i think ive fixed it, but i still dont understand exactly what was causing the issue.

Like the build platform was on android and i switched to windows and it started working again

#

¯_(ツ)_/¯

astral turret
#

hrm. so this is what I get with a random tile with a white color tint...

glacial lantern
#

Hey how are we doing 3D noise shader nodes these days for unityy version 6? All the others are giving errors in the console.

ruby maple
#

hello , im trying to use stencil buffers , where i want to hide an cube object with a shader graph material with a plane which stencil buffer material. how do i get the object to work like the other sphere object with another stencil buffer material set to comp eqal

analog tendon
#

Hi, I have a question in regards to attempting to pick shaders for a 3D Terrain. I'm trying to pick the "Nature/Terrain/Standard" shader, but the Unity Editor isn't allowing me to pick it due to this shader being grayed out to "Universal Render pipeline/Terrain/Lit". Does anyone know how to fix this, or if the change is possible?

kind juniper
kind juniper
glacial lantern
# kind juniper What errors? And what "all others"?

By all others I mean these dont work for me (I assume cause of unity version 6):

and by errors I am seeing errors like "cant open include file #####" and its trying to open an hlsl file that is definitly there
I also installed it with the package manager using url git so it should work and to get errors means something is up

GitHub

Adds various noise generation nodes to Unity Shader Graph, including 3D noise nodes. - JimmyCushnie/Noisy-Nodes

Use the Simple 3D Noise tool for your next project. Find this and more particle & effect tools on the Unity Asset Store.

kind juniper
kind juniper
#

Simple, Gradient and Voronoi

glacial lantern
# kind juniper Also, there seem to be some noise nodes in the shader graph already: <https://do...

ok so I was in the middle of writing a response to your messages and something happened. Basically long story short, the nodes in unity already use UV to sample. Its 2D noise. Not 3D. Very VERY important difference. However, the error that showed up before is not showing up now and the 3D node is working this time. I think it must have installed incorrectly and or there is some bug that happens that needs a restart of the editor. So I am all good.

But yeah the nodes unity provides use UV coordinates which means its basically useless for vertex displacement on a 3D mesh inb 3D space in a 3D engin LOL

analog tendon
#

@kind juniper Actually, do you happen to know if Nature/Terrain/Standard is part of Built-in Render Pipeline? I created a bunch of new projects, some with 2D BIRP and 3D BIRP, and they have Nature/Terrain/Standard as their shader, even if there is no material. However, projects that are Universal 2D and Universal 3D default to URP/Terrain/Lit

kind juniper
analog tendon
#

gotcha. Do you happen to know what's the URP version of the Nature/Terrain/Standard shader? or do you mean that the URP version of Nature/Terrain/Standard is the URP/Standard/Lit?

kind juniper
analog tendon
#

gotcha

#

thanks for the help

placid belfry
#

Hello guys, Shouldn't the finished product's alpha affected by the noise? it isnt doing anything or am i doing anything wrong.

#

Thanks!

devout quarry
placid belfry
kind juniper
hardy juniper
#

Captain D has a great video on alpha (the concept in general and how pre/non pre multiplied alpha works): https://www.youtube.com/watch?v=XobSAXZaKJ8

quiet osprey
#

Anyone know a remedy for sporadic errors such as Error in '<random shader>': Compilation failed (other error) 'out of memory during compilation' They seem to happen quite frequently since upgrading to Unity 6.
The errors comes and goes when switching scene view post processing etc on/off

civic lantern
quiet osprey
#

Its either the out of memory error. Or a parsing error such as:

Shader error in '<random shader>': out of memory while parsing at Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl(264)
#
Shader error in '<random shader>': out of memory while parsing at Development/Library/PackageCache/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl(854) 
#

Disabling or enabling renderer features sometimes makes the error go away for a few minutes. But its back quite often

hollow wolf
#

adding this to shadergraph fix the node, but the "warning" still there

regal stag
#

Assuming you are writing a shader for the Custom Render Texture asset

#

If you're trying to sample a RT in a shader you just use Texture2D property & Sample Texture 2D

hollow wolf
#

yeah been trying to learn about customRT

#

thanks cyan

fresh flame
thin crown
#

hey yall, im working on gerstner waves rn and its looking pretty cool in the shader graph but i cant seem to get it to work in the actual game.
The add node in the top is basically the gerstner wave logics, the bottom area is what im guessing is the master node? (im kinda wild guessing stuff, looking up tutorials and that sorta stuff)
atm the plane this is put on renders invisible when i attach it in the most idiot way possible (which will give yall a headache bc its super incorrect im sure) but i cant seem to connect the add directly to anything regarding the object position or smth.

im doing too much rambling, pls help

This is made on Univeral 3d (URP)
Im using unity 2022.3.44f1

warm pulsar
#

well, presumably, you want to add a displacement to the original object-space position

#

if you just plug the result of "Add" into the Position output, you'll be setting the X/Y/Z coordinates of each vertex to the same value (whatever Add spat out)

tidal wind
#

How would I achieve this style in Unity? Besides stylized textures, is there custom shading/lighting happening here? I’m a programmer that recently started learning the shader graph so I don’t have a good eye for this stuff yet.

astral turret
#

It's a limited color range but I have no clue what's going on regardless. If it's only one pixel per box, or some other error

modest zealot
#

I am going out of my mind...I need a world space hexagon grid shader. to put on a plane. It feels like it should be easy but it is not. I also cannot find anything online that does what I want. THis is the closest I have gotten. https://hastebin.com/share/ejadikolox.cpp

#

I even ran it through several AI systems looking for fixes, but all of them gave me garbage in return'

steel notch
#

I have a greyscale flare texture here. I want the outer rim to be kinda yellowish but the main shape to be mostly white. I imagine you usually solve this by just applying a color gradient based on the value of the texture. How do you apply a gradient on a material by material basis? Obviously I can just feed in a texture, but generating and modifying a texture is a lot more tedious than messing with Unity's gradient tool.

#

Do people use any toolings to quickly generate gradient textures?

frank coyote
steel notch
frank coyote
#

Just so i get it right

#

What you're trying to achieve is something like this?

steel notch
#

exactly

#

how you do that?

frank coyote
#

Solid yellow in overlay mode

#

I'm sure there' must be a way to use blending modes in shader code, either a library of something of the sort, if not, every blending mode is simple-ish maths so it's not that complicated to code it yourself

#

This way it'd be easier to do something dynamically since you only need a v3 parameter instead of a gradient

steel notch
frank coyote
#

Define complicated

steel notch
frank coyote
#

Honestly, depending on what you're doing i'd just expose a gradient to the inspector and do it the same overlay

#

or are you talking about doing to radially?

#

as in:

#

^ This or This v

steel notch
frank coyote
#

Sure you can, i don`t remember how exactly, but sure you can

kind juniper
astral turret
grizzled bolt
#

Or if you only need a two color gradient, add two exposed color fields to lerp between using your source value

#

The source value can be your texture's greyscale, or for a radial gradient it could be distance to its center
You could also store various shapes of gradients in any of the texture's color channels to control it precisely
A monochrome particle usually needs no more than one color channel to store its color value which doubles as opacity

astral turret
steel notch
opaque condor
stoic flint
#

can someone tell me why this vert (addeed to surf shader) makes my model completely disappear ?


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

nvm, unity generating pragma exclude_renderers d3d11

teal igloo
#

rendering backwards, how could i fix this issue when object is big
and also if u go inside u see it like this ig

teal igloo
rare wren
#

I am not sure if that's possible, since its object based. You might be able to convert the object space position to world space position and use that?

To be pixel perfect you might need a full screen effect

teal igloo
#

let me try and convert

rare wren
#

Ah got it

teal igloo
#

uhh, not gonna work i guess

devout quarry
#

Also this page gives some better options than scaling using object position

https://ameye.dev/notes/rendering-outlines/

teal igloo
devout quarry
#

No not with modulo, just modulate as in manipulate using

unreal egret
#

Hi guys! I'm working on a flying/dogfighting game and I came across this tutorial for a shader-based jet exhaust when I was building the last iteration: https://www.youtube.com/watch?v=WvHXKBwoQVM

He essentially defines the shape with a 3d object and some specific UV mapping, which is not the hard part, and then combines perlin noise x offset x time with an opacity gradient and some color to achieve a nice result.

He was using Amplify, but I wanted to do it with shadergraph and while I'm certain I could apply the same concepts, my execution left something to be desired. I also wanted to add a thrustInput, such that as thrust is increased, the exhaust plume would be larger.

I don't really want my exhaust to look exactly like his, but I'm struggling to understand how to make the colors look "flamey", and for certain shadergraph nodes, I have no idea what I'm doing. I'm just trying things. So my hope is that someone can look at my shadergraph and identify where my ignorance is hindering me. Another struggle I have is that the shader is applied to all the thrusters with the same noise offset at the same time. Seems like this would be great from a performance perspective, but since my sci fi craft has 4 right next to each other, it ends up being really noticeable.

Any advice would be greatly appreciated.

Hello and welcome back,

In today's lesson we're sticking with the Amplify Shader Editor to create a jet engine VFX shader that can be tweaked to produce a range of different visuals.

♥ Patreon for source files: https://www.patreon.com/polytoots
♥ Twitter: https://twitter.com/PolyToots

● Get Amplify Shader Editor: https://tinyurl.com/ycpeo7sp...

▶ Play video
smoky widget
#

I have two diferent compute shaders that both write to the same compute buffer, but at diferent parts of the data. Like compute shader 1 works on variable A of the compute buffer, and compute shader 2 works on variable B of the compute buffer.

Im launching them via Graphics.ExecuteCommandBuffer(bf); so the execution should be sequential right?
because i think im having artifacts because both shaders are running at the same time, which I don't understand why would be the case

smoky widget
#

alright, issue on my end, thank god its easy to solve

warm pulsar
#

Annoyingly, I'm pretty sure the unlit shader graph mode doesn't allow for HDR color output

#

Depending on your render pipeline and tonemapping settings, that may be needed to get very bright colors

#

(and it can cause bloom to happen, of course)

#

The base of the exhaust cone needs to be a lot brighter

#

Even if the plume is red, it should still be near-white at the start

grand jolt
#

does anyone know how i can make the pbr still be visible without a light source lighting it up?

mortal osprey
#

I'm using Polybrush and I wanted to know how to paint the textures darker and lighter. I used a shader that they provide but the shader seems to be Lit, and it's kind of faded because I'm not using any light. Would it be right to use an Unlit shader and paint some areas with a transparent black? How can I do this?

serene condor
#

Would a shader be the right way to go about this: the inner edge of the arm I want to pulse an emmissive LED from the cockpit to the end of the arm on either side. I think maybe a simple texture graphic that’s a gradient from white to full alpha 1-0 over like 8 pixels tip top to bottom.

Would a shader be able to animate that led pulsing from one end to the other while idle and then during charge up for an attack, I want it to act as a progress bar filling fully white from the cockpit to the end of the claw. Is that obtainable via a shader or am I looking for something else

#

BIRP also

tepid knoll
#

Custom shader I made using shader graph, any suggestions on how I should improve it

potent coral
#

I'm trying to do the outlining most anime games do, but I'm using render objects to do this. How do I obtain the color of the object so that I can make the outline a darker version of the color

#

Essentially, I want the red car to have a red outline and the blue car to have a blue outline

grizzled bolt
# grand jolt does anyone know how i can make the pbr still be visible without a light source ...

"The PRB still visible" doesn't really make sense
PBR is a convention to make a material react to incoming light in a particular precise way
In shadow there's only indirect light, so that's what it reacts to
It cannot react to light that's not there, if that's what you need then PBR is not what you want
You could increase the ambient light from lighting window, or decrease shadow strength of the directional light I suppose
Otherwise you need a shader that does custom lighting in some different way

tacit parcel
grizzled bolt
#

Helps to give the lights an UV island size of 0, but there's fun ways to use different UV mappings with this technique too

simple panther
#

Hello. I am trying to make na "underwater haze effect" and I am following a course which says I should do it in a way like in screen. However I am not completely understanding what I am doing, would any good soul explain me what I am doing here?

From what I understand is that scene position node probes pixel position as float4 and the "w" (or "alpha" in shader graph) component is depth of the pixel from the camera. But I am not 100% sure why I need to use "raw mode" there and why I need to subtract that from Scene Depth node with sampling set to "eye". I'd love to understand what is happening there.

#

Oh and disclaimer, the graph works properly and I am getting effect as expected (of course I refine the result later on but thats what I wanted to achieve) - i just dont understand why.

hardy juniper
#

its probably because you want to calculate this fog from the frag position so it doesnt change based on cam distance

grizzled bolt
grizzled bolt
simple panther
#

Oooh I see now. Yeah it makes sense, screen position float4 is a position of surface (thing I am shading) and scene depth is what is already written to the depth buffer, that is geometry below my surface as it was rendered during opaque queue. I am thinking right?

grizzled bolt
simple panther
#

Thank you, now it makes sense!

stray orbit
#

With rendergraph, i am trying to copy a texture target to the resourceData.cameracolor but when i do i get errors.
It seems to me as if the resource i want to copy is already discarded?

#

I have put my current code on pastebin: https://pastebin.com/sM2FXufN
I did not include the part with the texture to the cameracolor but it basically is the code below i would like to add after the secondpass so at the end of the function:

renderGraph.AddCopyPass(secondPassTexture, resourceData.cameraColor);

I just can't get it to work, i am not really faimiliar with shaders and also not this code to set up a screen space effect.

#

The errors i get are rendergraph execution error and Found rogue context, with a question did you call EndRenderPass?

#

I am not sure but i feel like it has to do with the texture being discarded before i want to copy it to the cameracolor

warm pulsar
#

Perhaps you need to add a more interesting ambient light source -- which is determined by your skybox

serene condor
grizzled bolt
serene condor
#

Ok I think I have a clear vision now thanks

grizzled bolt
#

The advantage of a shader on the other hand is that you don't need any scripts, but you need a new shader

#

If you have a lot of objects that need scrolling then having a shader for that purpose for all would be the most convenient
That way you can also let material properties control the scroll speed, direction and other features
So different styles of scrolling can use the same shader

stray orbit
astral turret
#

hm. onto the hardest part - working with alphas. interestingly, I am getting a blue/gray field into the 0 alpha pixels. I thought it was related to not having a background or due to accumulation, but when I dropped the population down from 1000 to 10 I still got the same haze
https://cdn.discordapp.com/attachments/702266715819475074/1330291514898776189/image.png?ex=678e1ac4&is=678cc944&hm=88205b7ae717a1d195052e06bed128e081d8ec3ca0b8e94d129125ea0f653cec&
https://cdn.discordapp.com/attachments/702266715819475074/1330365773905920020/image.png?ex=678e5fed&is=678d0e6d&hm=08764d03f80ee638e7feefa9f43b1babd562a5f82681a07b9bae6803387ce972&
it's not ordering I don't think - I set my test to fill the matrix out incrementally for the z position and got the same. it's not a background issue, I created a white quad behind it and still got the same.
so I'm scratching my head since this isn't a quantity-of-alphas-overlaying issue. like it's not a bunch of 0.00012 alpha accumulating.
shader code: https://paste.mod.gg/wxzlbrhkyrgd/0
source code, trimmed: https://paste.mod.gg/iaisffdabbwb/0

basically trying to build a mass sprite display with as much versatility as I can put in. will be attempting shader graph as well, but trying to get as good as I can in my understanding of what the behavior is. easiest way I can do that is with code.

so what might be happening here? why are my alpha pixels showing up as blue/gray? what's a good fix for this?

warm pulsar
astral turret
#

one of the links was to an old copy of the C# I think

#

been watching someone's video on 'hacking in' instanced indirect support to shader graph. can't get that working either. but one thing at a time...

warm pulsar
#

hm, Blend SrcAlpha OneMinusSrcAlpha is correct

#

I'd try manually setting the alpha to 0.5 (or 0, or whatever) in the fragment stage

#

One thing that comes to mind, though

#

You didn't set a render queue, so you're probably at 2000

#

This could mean that you're blending with old garbage from the color buffer

#

the skybox is drawn after 2500 and before 2501

#

This will cause a "hall of mirrors" effect where you see the last frame's color

astral turret
#

Ahh. I did not, and that's a behavior I wasn't familiar with

#

I'll try out the alpha change and see what output I get. then I'll mess with the render queue - it's 2000 in the material

astral turret
#

@warm pulsar
Interesting how the orange sprite (bottom left) doesn't get rendered underneath the pink sprite in the center. hacked it in like that.

don't think it's a race condition - it's not flickering. I am generating the list of test blocks by incrementing the z position.

I'll try setting the render queue to higher than 2501 then?

astral turret
#

hrm. doesn't seem to improve much at 2502. it's more transparent, though. interesting.

though, it does make me think. maybe the issue is with the mesh settings somehow? ie- I think I recall something, years ago, to get sprites drawn on a mesh where the edges of the mesh are transparent was... tricky.

#

that time wasn't even for partially transparent sprites (which this time I'm trying to do). that was indirectly related to shadows and sprite meshes however... I'll have to see if I can dig that up

hardy juniper
#

I think i had this before where the sprite colour was not pre multiplied (against alpha) so doing it yourself in shader fixes it

astral turret
hardy juniper
#

and glad that fixed it. Im not sure why sprites are like this and require alpha multiplication in shader.

astral turret
#

and you were right about ZWrite. I set it to off

#

and thus now it works! thanks so much for helping me getting across the finish line with this part

primal kite
#

why i have this in blender, but when i export it to unity it changes to this

warm pulsar
#

Unity triangulates the model on import

primal kite
#

i can change it?

#

i want to use polybrush but it is imposibble if the model is triangulated

warm pulsar
#

there is an option called "Keep Quads"

#

that should do it

#

look at the mesh importer settings

#

Note that the center piece is an n-gon

#

it's a 20-ish sided shape

#

I would expect that to get chopped up

primal kite
#

okey

#

im going to see it

#

tysm

astral turret
hardy juniper
astral turret
#

AH. So that's just a visual effect that'll always happen because of the camera. that's fine in that case

#

next comes the semi translucency test

#

actually, no, weird. it does show things in the back overtop things in the front even on the dead-on camera angle

#

I wonder why that's happening...

unreal egret
astral turret
#

Render Queue position is 2502

astral turret
#

the meshes in the video are being drawn with Instanced Indirect... perhaps its completing some of them out of order? But if so, why would it keep on drawing it in the same order?

warm pulsar
#

Perhaps you need to depth-sort them yourself

astral turret
#

I did, that's the odd part

#

as per the posted code, this is a test where I'm creating a bunch of meshes in a native array. and when I'm filling out the positions, I just increment the z point

#

or did I

#

ew. how embarrassing. so I was not, I had the line in a different block. but fixing the sorting didn't help

#

Vector3 position = new Vector3(UnityEngine.Random.Range(-range, range), UnityEngine.Random.Range(-range, range), ((float)i)*(range/(float)population) );
basically I'm writing the population out from z=0 to 1, cut up into pieces and ordered by i

#

then I toss the native array into an InstancedIndirect Draw mesh on update. is there a way I can/should manually depth-sort them?

#

beyond their position in the array

grizzled bolt
#

I don't think there's any kind of operation you could do in polybrush that could not be done on triangles but could be done on an n-gon

coarse crag
#

Hey! I need help, I want to make a material/shader/shadergraph (or something) which will allow me to see through one material, I have a window which has a glass model for it, and the model behind is to allow me to make an illusion of a room, Any idea how I could do that??

warm pulsar
#

this is a classic usecase for stencils

#

You'll have two shaders:

#
  • One shader on the window that sets a stencil bit
  • One shader for the interior that checks the same stencil bit
#

The second shader will not do a depth test, and will render after the first shader, as well as after all other opaque geometry

#

This was, the second shader will draw on top of the wall (which would normally block it from rendering)

#

It'll only draw where the stencil bit got set. This will prevent it from rendering in front of objects that are in front of the window -- they'll prevent the first shader from doing anything

ebon moss
#

do you have the ability to write to neighboring fragments in a shader?

coarse crag
warm pulsar
warm pulsar
coarse crag
warm pulsar
#

ShaderLab is the language that .shader files are written with

#

also, i have only used stencils in the built-in render pipeline

#

not sure what RP you're using here

ebon moss
ebon moss
#

i am using the inverted hull method to create an outline, but I want to vary the thickness of the outline slightly to make it look more "hand drawn".

warm pulsar
#

You'd need to deform the actual mesh then, yes

coarse crag
ebon moss
#

The issue is that there aren't enough verts to create a smooth outline when the thickness is varied, so I think maybe I'd need to look into some different methods of creating an outline. Maybe one that operates in clip space

warm pulsar
ebon moss
warm pulsar
#

You'd need a coherent way to randomize the thickness, though

#

maybe something based on the angle to the center of the object?

ebon moss
warm pulsar
#

I haven’t implemented it myself yet :p

astral turret
#

HM. I wonder if that effect is happening based on "Transparency Sort Mode" defined as distance-to-Camera... that could explain how I'd get that visibility glitch. if it's the game camera, that is (even in scene mode), that would explain why the glitch is 'stable'

#

yep, I bet the line to the camera is slightly shorter on the more centered items, which are behind the other ones by just a small amount

#

but that's also happening in the game viewpane - the incorrect ordering of sprites that is. shouldn't my use of a custom shader avoid that sorting?

#

rather, a custom shader + Graphics.DrawMeshInstancedIndirect?

#

in this case I am providing the array to DrawMeshInstancedIndirect pre-sorted

astral turret
#

so you can set that mode manually in Unity... but doing so doesn't solve the issue

#

although... if I swap the camera to the other side...

#

I'll give this a further test. huh

coarse crag
warm pulsar
#

I don't know what you're describing here

#

Is it that the interior objects are rendering at all times, not just through the window?

#

You'll still need to use stenciling here. I don't recall if the "render objects" feature has settings for that

#

would have to look at it again tomorrow

devout quarry
pastel grail
#

Not really expecting an answer since this is super niche, but out of curiosity : Is it possible to extend shader graph to be compatible with a custom RP without forking the shader graph package?

amber saffron
rigid halo
#

i think im starting to go a little ga ga...

i have this set up.
making a Tiling and offset calculation.
uv0_MainTex = v.texcoord0.xy * _MainTex_ST.xy + _MainTex_ST.zw;

then i have the texcoord1 sematic input that im using for particle uv manipulation.
uv0_MainTex += v.texcoord1.zw;

when i do this the texture is offset by +1 in the Y direction (X is at 0). which is strange as i do not have the custom vertex streams active.

what am i missing?
current build mode is Android btw if that does something to muck up the UV?

midnight lily
#

My mesh is a sphere made of quads, each quad is a full texture. but some front quads are drawing under the back quads, some are not. I'd guess it's mesh order.
How do I fix it? All my other transparent shaders work no issue, I can't figure out why this one is wrong.

`Shader "Custom/BushyShaderTest" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_Effect("Leafy Effect", Range(0,1)) = 0.0
_Options ("Options", Vector) = (0,0,0,0)
}
SubShader {
Tags {
"Queue"="Transparent" "RenderType"="Transparent"
}
LOD 200
Cull Off
Blend SrcAlpha OneMinusSrcAlpha

    CGPROGRAM
    #pragma surface surf Standard fullforwardshadows vertex:vert alpha
    #pragma target 3.0

    sampler2D _MainTex;

    struct Input {
        float2 uv_MainTex;
    };

    half _Glossiness;
    half _Metallic;
    fixed4 _Color;
    half _Effect;
    float4 _Options;

    // Vertex function to apply offset
    void vert(inout appdata_full v) {
        float3 UVOffset = float3(v.texcoord.xy * 2 - 1, 0);
        UVOffset = mul(UNITY_MATRIX_I_V, UVOffset);
        UVOffset = mul(unity_WorldToObject, UVOffset);
        UVOffset = normalize(UVOffset);
        v.vertex.xyz += UVOffset * _Effect;
    }

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

}`

#

I removed alpha and made it just cutout, and it somewhat worked

amber saffron
midnight lily
#

How weird, I vaguely remember transparent shaders just getting it right by default
Maybe I just never drew a transparent sphere with backfaces

#

But yeah, cutout with no transparency worked

twilit geyser
#

Hey all 👋 Can someone explain to me what I'm doing wrong here?

I have an object in the game world and pass the "Enemy Position" to the shader. This shader is used by a particle system and I'm trying to move this billboard particle towards this Enemy Object. There's one detail to it though, which is that I want to keep the particle on the same height as it was independent of the height of the Enemy Object.

What I don't understand is that this shader makes the particle rotate/stretch in weird ways that I don't understand. You can see that there's an unconnected Vector3 in there. If I use that for the multiply with the offset parameter it doesn't do this rotate/stretch behaviour.

Anyone who understands this math better than me, who can help me out here? 🤞

#

What I don't understand is that if I use the vector3 I can put any value for x and z and it will move the particle along that axis without any rotation/stretching. But when I use the part that's connected in the screenshot it starts behaving weird.

If I DO include the y information in the combine node it will move along the axis just fine. But I don't want to use the height information to keep the height the same at all times 😖

regal stag
twilit geyser
manic niche
#

can someone explain to me why this is happening? I am just outputting red onto a texture to draw the meshs uv map and it ignores half the uvs.
image 1 is a debug material, image 2 is the render texture, image 3 is the uvs in blender, image 4 is the fragment shader

civic lantern
manic niche
civic lantern
#

How are you rendering to the rendertexture?
Is half of the test cube (1st screenshot) black? I cant tell

regal stag
#

Some of the uvs might cause triangles to be backwards

manic niche
amber dove
#

if anyone could help that would be amazing, being trying for about a week now with zero success lol, shaders are so complicated

primal kite
#

someone have a SG to apply a texture to the top face?

regal spindle
#

How do i animate this type of liquid distortion warp using shader?

rare wren
rare wren
rare wren
grizzled bolt
#

Which you can also offset by a noise texture
And the noise textures can be animated, and of various types
So there's a lot of options with that technique

twilit geyser
tight warren
#

Hi everyone,
I'm working on a Unity project where I need to access the depth texture generated by a secondary camera. The idea is to use this depth texture in another rendering pass or shader for custom effects.

Does anyone have experience with this or know of any efficient workflows for sharing a camera's depth texture across multiple shaders or passes? Examples or insights would be greatly appreciated. Thanks!

dapper heath
#

heya, I'm having an issue with shader graph not matching the results I'm getting from a shader with the same code-

                float satDtLight = saturate(dot(grassNormal, light.direction));
                float satDtCamera = saturate(dot(grassNormal, viewDir));

                float lightPow = pow(satDtLight, 2);
                float cameraPow = pow(1.0f - satDtCamera, 1);

                float mult = lightPow; //* cameraPow;
                float multSmooth = smoothstep(0.1f, 0.9f, mult) * 2;
                float3 multSmoothColor = multSmooth * (alo.Color + o.lightColor);

I've purposefully disconnected the cameraPow part of this in both the shader and the graph. if I isolate just multSmoothColor (the equivalent of the far right multiply node + add node off screen), the shader's results match the graph. this feels like something super basic I'm missing, but as far as I can tell all my functions are 1:1

#

the only intentional difference is that I'm not negating the main light direction in shadergraph as it's unnecessary

#

you can see the issue visually here

warm pulsar
#

i don't get what the issue is!

#

Check that grassNormal is normalized, though

#

That would result in bogus results from the dot product, making it seem like the grass is more aligned with the light than it actually is

warm pulsar
neon gale
#

I have a very subtle outline effect, it is slightly modified code from a Git. As you see in the picture, the outline affect shows on the thigh, but not on the leotard. the Leotards material is set to Transparent, which is the cause of the failure.
I do not know where to start looking to make the effect work on transparent materials too.
It is a Full Screen Pass Render Feature. I have tried the available injection points, shown in image 2, with no luck. no combination of image 3 works either.
image 4 with the effect off, for comparison

warm pulsar
#

It probably looks at the depth buffer

#

Can you use alpha clipping on an otherwise opaque shader, or does the leotard material have to be transparent?

neon gale
#

Requires Normal and Color to work, sorry forgot to mention that

#

i did try alpha clipping, in this same material, and the issue persists

#

setting to opaque works

#

yes, this particular game with require the ability for clothing to be transparent/translucent

warm pulsar
#

You might be able to put the clothing material a bit later in the render queue and turn on ZWrite

#

although, I'd expect the body to still produce an outline, even if the clothing on top isn't picking it up

neon gale
#

the body does produce an outline, under the leotard, if i crank up the settings of the outline. right now, very little body exists under the leotard, so it would be quads around the edges, which does show.
As far as changing the order in queue, beyond playing with the settings shown, i do not know where to start looking to do that

#

researching your suggestions, thanks

neon gale
#

The shader is a mix of Shader Graph, and a custom function, HLSL. would the ZWrite you mentioned be accessible through the Graph Settings?

cobalt grove
#

I wanna have a similar effect that is just a circle/custom field around my playable area

neon gale
#

well, you could just place a large transparent dome over it, and use a masked material.. Oh, or do you mean, not just a round shape, but conforms to a 'random' map?

umbral panther
#

does it make sense to do dirty tracking to prevent calls to MaterialPropertyBlock setters? or does unity already do dirty tracking inside those? (Sorry if this isn't the right channel, it seemed more appropriate than a general scripting channel, since its a graphics question)

warm pulsar
#

what you have open there corresponds to ZTest

#

I don't know what outline effect you're using, though, which means i'm guessing here :p

#

Given that the custom pass is only marked as requiring color and normals, that makes me wonder if it even cares about depth

#

i know very little about the gory details of those

neon gale
#

Ok, thanks. that did not work, but it may have to do with the Lit shader in the first place, so i am attempting to adjust the Ztest on that. I copied lit, and made lit2, now hacking HLSL.

Here is the shader i am trying to get to work with transparency
https://github.com/federicocasares/cavifree

warm pulsar
#

ah, it's curvature based

neon gale
#

I am only using half of it, meaning i am only changing Cavity, not whitening Curves, but yes, two sides of the same coin

#

i spent way too much time and money on 'outline shaders' before finding this. this effect is what i was going for

tacit parcel
neon gale
tacit parcel
#

you mean the outline pointed by the arrow? that's because it's comparing the normal on the ~~thing ~~ thigh with the normal on the background. The outline seems missing on the left thigh, thats because the post process failed to detect changes in normal direction

neon gale
tacit parcel
#

I see, there are two arrows 🤦 . Sorry I missed that. Seems like what Fen said, the transparant doesnt write to normal so the post process failed to detect the line.

neon gale
#

No worries, you still had better theories than i did 🙂

neon gale
#

Do shaders i make in Shader Graph 'bake' down to HLSL, .. my end question is, are Shader Graph shaders as performant as HLSL/'real' shaders?

sullen kite
#

does anyone know why my reflections are all pixilated in my scene?

#

nvm it was a reflection of a reflection somehow -_-

ebon moss
#

The same algorithim in shader graph or written in HLSL is the same thing and will perform the same, but you have more freedom over the algorithim in hlsl which may make it perform better

kind juniper
# neon gale Do shaders i make in Shader Graph 'bake' down to HLSL, .. my end question is, a...

It depends. Depending on the shader graph "template"(or whatever they're called), unity might include a bunch of extra code that you don't want in the final shader. For example, the lit shader graph would include everything related to lighting and shadows. If you don't want to use that functionality or calculate lighting/shadows yourself, that's obviously gonna add a lot of redundant processing. The shader lab shaders can also add extra code, but it's more controllable and you could avoid it all together as it's not as "automatic" as in shader graph. Other than that, yes a shader graph shader can be as performant as one written manually.
If you have some concerns, you can look at the final hlsl code generated by the shader graph.

neon gale
plain urchin
#

Hi. Why would i make a texture atlas and mesh renderer? And the mesh have uv placed on certain parts of the part of the atlas?
Why not use sprite renderer and import the sprites individually, and pack it in editor?

The game is 3d environment

kind juniper
little ravine
#

hey, does anyone know how/if a shader can write to a rendertexture?

#

I can elaborate if im not making sense

kind juniper
little ravine
#

sorry i know it goes to the cameras normal buffer

#

i mean some other buffer

#

the one that that unity doesnt default to

#

oops

kind juniper
#

Well, the normal way to do it would be to specify the camera to render to a render texture.

little ravine
#

give me a second i think I can find an example

little ravine
#

I'm only assuming somewhere in the shaders they're writing to these buffers?

kind juniper
#

If you need more control, you can probably use a render graph as well

little ravine
#

I see, I think I've done that before, its just I remember having to put everything related on a certain layer so that those certain objects render

#

I'm not sure why exactly I don't like that approach, maybe just because I have to put things in the same layer but if I can't avoid it then oh well

kind juniper
little ravine
#

it was using the command buffer if I remember correctly

#

either way it was a renderfeature

kind juniper
#

Perhaps a different effect. But if it was rendering objects separately, it's not a full screen pass. Full screen pass usually takes full screen data(for example gbuffer) and renders to every pixel on the screen.

#

Normal rendering is when you take a mesh, pass it through the vertex shader to get it's projection on the screen, then render only the pixels within that projection in pixel shader. Not the full screen.

#

It can involve extra draw calls if you need particular data for objects. But the last step is a full screen shader.

little ravine
#

oh yeah it was that last part, I used the commandbuffer to render specific objects so I could process it to get the outline and blit it onto the rt for colour

#

it was fun figuring that out

#

I guess I'll stick to that method

errant bay
#

Hey guys. is it possible to create an outline that will hilight objects only when another Mesh Render interfere? (But only GameObject Mesh Renderer, I'm currently using this package: https://assetstore.unity.com/packages/tools/particles-effects/quick-outline-115488 and problem is that it activates also if I'm spawning meshes using Particle System or VisualEffect - and I wanna avoid it)

Use the Quick Outline tool for your next project. Find this and more particle & effect tools on the Unity Asset Store.

devout quarry
errant bay
#

And I want to avoid this because its adding unecessery visual noise

devout quarry
#

Ah I see but doesn’t this outline work by maybe adding an outline component? Can you just not add that component to the particle system? Or make it selective by using layers or something? I’m not sure how it works exactly for that specific asset.

errant bay
#

So that you have two materials (one - your selected; second - outline)

#

So I dont have any option for component to work only on specyfic layer

#

I have only option to limit on what type of object outline will be added

devout quarry
raven cosmos
#

How can I make the grid pattern on different cubes match?

errant bay
civic lantern
#

This will only look good on axis-aligned boxes/planes though (only 90 degree rotations)

turbid pivot
#

how can i get the noise to move along the x or y axis

#

and not the whole model

#

got something pretty good rn

civic lantern
turbid pivot
#

just not sure how to

civic lantern
turbid pivot
#

still a little confused

civic lantern
#

UV determines where the noise is sampled

#

It's a vector2/float2

#

So there's your X and Y coordinates

turbid pivot
#

works now ty ❤️

turbid pivot
#

pretty bad screenshot but i have a path going through

civic lantern
#

Path defined by a list of points?

#

I would probably do that in a compute shader, haven't really done such things in a regular shader

turbid pivot
civic lantern
#

So just a line?

turbid pivot
#

well i'd make it curved eventually

#

but ur right its probably best in a compute shader

rigid halo
#

i want to make a shader where i can overlay a shine effect that scrolls over a nine slice ui image. i have a hard time finding information about how i would do that though.

turbid pivot
#

try changing the color based on position and then offsetting that position with a time node

civic lantern
#

I was imagining a cartoony sort of line that moves over the image

#

That's definitely doable in a shader with a bit of math

rigid halo
# civic lantern That's definitely doable in a shader with a bit of math

yeah this is what im thinking. it is hard to do over a nineslice though and i havent found much info about the process of doing it.
i tried looking into the shiny effect for ugui repo but it seems to be using a parts of another repo that several years in the future compared to that one and i have not found the base class for the shine effect for example. which makes it hard to figure out the effect itself.

violet urchin
#

Is there a way to get the camera screen view in "Canvas Shader Graph" and use it as texture to create a simple blur effect ?

turbid pivot
#

anyone got good learning resources for compute shaders?

neon gale
sharp moat
#

hi there, im newish to shaders and was wondering if tutorials for unity from like 3-4 years ago would be deadly out of date, specifically for shaders?

#

wondering just before i start working and realise that a tutorial im using is giving me wrong info

#

also im basically wanting to create something like this, obviously not the quality of this but just similar

#

i assumed that their using a shader

cobalt grove
dapper heath
#

heya, I'm working on a water shader with a pixel art aesthetic (original I know) and I was wondering if there was a way to get a "static" version of depth? right now as my camera moves forward and back, the depth values change in this pond for instance, let me see if I can get a video

#

ideally I'd like it to stay the same so as you move around the water doesn't shift weirdly

neon gale
devout quarry
dapper heath
#

oh geez, thanks so much, this looks very helpful

dapper heath
#

ah, there we go

smoky widget
#

Hi @regal stag I've been following this https://www.cyanilux.com/faq/#sg-drawmeshinstancedindirect for how to use DrawMeshInstanced working in shadergraph. Did the same exact setup, but I've found a quircky issue, maybe you can help me understand what's wrong?

If i setup the matrices in #pragma instancing_options procedural:vertInstancingSetup as stated, the instances fly all around they just flicker everywhere on the screen like if Unity_instanceID was a single value per draw call, or there's something corrupt with the matrices. However, if I move that exact code into a single method called right after the instancing_options procedural: thing, things work as intended. Any idea on what could that be? or why

#

Here's the vertInstancingSetup btw


void vertInstancingSetup() {
#if defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)

    #ifdef unity_ObjectToWorld
    #undef unity_ObjectToWorld
    #endif

    #ifdef unity_WorldToObject
    #undef unity_WorldToObject
    #endif
    
    int instanceIndex = _Indices[_Counters[_LODValue].startBase+unity_InstanceID];
    InstanceData data = _PerInstanceData[unity_InstanceID];

    float4 rotation;
    float3 scale;
    UnpackRotationScale(data.quaternionScale, rotation, scale);
    float4x4 trs = transpose(MakeTRSMatrix(data.position, rotation, scale));

    unity_ObjectToWorld = trs;
    unity_WorldToObject = inverse(trs);
    
    #if SHADERPASS == SHADERPASS_MOTION_VECTORS && defined(SHADERPASS_CS_HLSL)
        unity_MatrixPreviousM = unity_ObjectToWorld;
        unity_MatrixPreviousMI = unity_WorldToObject;
    #endif
#endif
}
#

it's weird that it works in a standalone method, but here's also the matrix creation

float4x4 MakeTRSMatrix(float3 pos, float4 rotQuat, float3 scale)
{
    float4x4 rotPart = QuatToMatrix(rotQuat);
    float4x4 trPart = float4x4(
        float4(scale.x, 0, 0, 0), 
        float4(0, scale.y, 0, 0), 
        float4(0, 0, scale.z, 0), 
        float4(pos, 1));
    return mul(rotPart, trPart);
}

float4x4 inverse(float4x4 input)
{
    #define minor(a,b,c) determinant(float3x3(input.a, input.b, input.c))
    float4x4 cofactors = float4x4(
        minor(_22_23_24, _32_33_34, _42_43_44),
        -minor(_21_23_24, _31_33_34, _41_43_44),
        minor(_21_22_24, _31_32_34, _41_42_44),
        -minor(_21_22_23, _31_32_33, _41_42_43),
 
        -minor(_12_13_14, _32_33_34, _42_43_44),
        minor(_11_13_14, _31_33_34, _41_43_44),
        -minor(_11_12_14, _31_32_34, _41_42_44),
        minor(_11_12_13, _31_32_33, _41_42_43),
 
        minor(_12_13_14, _22_23_24, _42_43_44),
        -minor(_11_13_14, _21_23_24, _41_43_44),
        minor(_11_12_14, _21_22_24, _41_42_44),
        -minor(_11_12_13, _21_22_23, _41_42_43),
 
        -minor(_12_13_14, _22_23_24, _32_33_34),
        minor(_11_13_14, _21_23_24, _31_33_34),
        -minor(_11_12_14, _21_22_24, _31_32_34),
        minor(_11_12_13, _21_22_23, _31_32_33)
        );
    #undef minor
    return transpose(cofactors) / determinant(input);
}
#

it's like if unity_InstanceID was always 0?

#

ooooooh wait a sec, i think i see now

#

nope, i thought maybe it's not compatible with material properties

#

but I also tried the setting manually throguh set material and nope

smoky widget
#

so yeah, nothing is set, unity_InstanceID is 0 and the buffers have the wrong data

regal stag
smoky widget
#

It's really weird, honestly it just looks like when doing this call on the procedural isntancing options side, none of the data is set, but I can make it work just fine after.

#

Do you have any idea on what I could look into?

regal stag
#

If it works in a different function could just keep it there and ignore the instancing_options stuff

dapper heath
#

heya, is anyone aware of a way to exclude a given layer or object from being drawn to the opaque texture (without making it transparent)? as shown I've found a way to get pixel thin outlines on my water using viewspace normals, but if the shader is transparent, it doesn't write to the normals texture itself, and if it's opaque it blocks the stuff under it from being drawn to the opaque texture

#

alternatively, can I draw a transparent shader to the camera normals texture somehow?

smoky widget
dapper heath
orchid shadow
#

Hey for some reason with a full screen render pass I can't get any depth info. With simply

half4 frag(Varyings IN) : SV_Target
{
    return SampleSceneDepth(IN.texcoord);
}

And including Core.hlsl, Blit.hlsl, and DeclareDepthTexutre.hlsl, the return of SampleSceneDepth is 0 across the board.

I went into the frame debugger and the depth texture is visibly there in grayscale in _CameraDepthTexture so I have no idea why this isn't working.

I just have my custom shader linked to a material and that material linked as pass material on full screen renderer feature

kind juniper
manic fulcrum
#

Recently updated our engine to Unity 6 and a lot of our transparent materials are rendering in front now. Anyone know how to fix? This face shadow mesh is supposed to be behind that blue mask

kind juniper
manic fulcrum
#

I found out that transparency doesn't render to the depth buffer so I figured I'd just mess with any setting that had depth haha

raven cosmos
#

how to make simple water?

orchid shadow
#

Also when I remove the code SampleSceneDepth(IN.texcoord);, the frame debugger removes the depth texture image as an input.

Otherwise i get a depth texture as shown below allegedly being passed in as _CameraDepthTexture but then the sample still outputs 0.0 for every fragment. Very confusing

kind juniper
orchid shadow
kind juniper
#

What do you have in the vertex shader?

orchid shadow
#

I am relatively new to shader programming. I intended to use the Blit.hlsl include as the vertex and have my own fragment, so my pass is

{
            HLSLPROGRAM
            #pragma vertex Vert
            #pragma fragment frag

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"

            half4 frag(Varyings IN) : SV_Target
            {
                return half4(IN.texcoord, 0.0, 1.0);
            }
            ENDHLSL
        }
#

And vert is the name of the vertex shader in Blit.hlsl

#
Varyings Vert(Attributes input)
{
    Varyings output;
    UNITY_SETUP_INSTANCE_ID(input);
    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);

#if SHADER_API_GLES
    float4 pos = input.positionOS;
    float2 uv  = input.uv;
#else
    float4 pos = GetFullScreenTriangleVertexPosition(input.vertexID);
    float2 uv  = GetFullScreenTriangleTexCoord(input.vertexID);
#endif

    output.positionCS = pos;
    output.texcoord   = uv * _BlitScaleBias.xy + _BlitScaleBias.zw;
    return output;
}
kind juniper
#

Are you following some kind of docs that specify how to use these includes/macros/functions?

tough lion
#

Hey, im having the issue that when I create my own shader that I made with ShaderGraph and add it as a material to my character rig that uses Sprite Skin im getting the following warning:

WalkRig is using a shader without GPU deformation support. Switching the renderer over to CPU deformation.
UnityEngine.U2D.Animation.SpriteSkin:OnEnable () (at ./Library/PackageCache/com.unity.2d.animation/Runtime/SpriteSkin.cs:376)

When using CPU deformation(Not doing anything just letting the warning stay) the shader works kinda junky, the rig position is in the corner and the borders of the rig elements are scaled down to least edges, so not quite an option for me. So my question is how can I make my shader work with this "GPU deformation". My idea was just to see what the "Sprite-Lit-Default" makes and copy its nodes that are responsible for that and thats it, however im not quite sure on how to open the built-in shader with ShaderGraph and if its even possible. But open to other solutions too thinksmart

warm pulsar
#

Copying this over from the VRChat discord. It is very baffling.

I am writing a shader that reads the position of a light in the vertex stage (this is the only reasonable way to get an object's position in a shader in VRChat, since you can't write your own scripts).

To find the correct light, I check the alpha value of the light's color.

Two friends of mine with AMD GPUs are having problems seeing the effect. Here are two very similar blocks of HLSL:

bool alphaGood = distance(unity_LightColor[idx].a, 0.64) < 0.01;
bool rangeGood = distance(unity_LightColor[idx].a, 20) < 0.01;

bool which = alphaGood || rangeGood;

if (which)
{
    lightPos.xyz = float3(unity_4LightPosX0[idx], unity_4LightPosY0[idx], unity_4LightPosZ0[idx]);
    lightPos.w = 1;
    break;
}

This one works fine. 20 is a totally arbitrary number. I can choose any number I want that is not 0.64

bool alphaGood = distance(unity_LightColor[idx].a, 0.64) < 0.01;

bool which = alphaGood;

if (which)
{
    lightPos.xyz = float3(unity_4LightPosX0[idx], unity_4LightPosY0[idx], unity_4LightPosZ0[idx]);
    lightPos.w = 1;
    break;
}

This one does not work.

#

People with AMD GPUs always seem to wind up with which being false here in the second example

#

The first example compiles to this:

  14:   add r2.xy, l(0.640000, 20.000000, 0.000000, 0.000000), -cb0[r0.w + 7].wwww
  15:   lt r2.xy, |r2.xyxx|, l(0.010000, 0.010000, 0.000000, 0.000000)
  16:   or r1.w, r2.y, r2.x
  17:   if_nz r1.w

The second example compiles to this:

  14:   add r1.w, l(0.640000), -cb0[r0.w + 7].w
  15:   lt r1.w, |r1.w|, l(0.010000)
  16:   if_nz r1.w
#

This makes absolutely zero sense.

warm pulsar
#

I verified that only alphaGood is ever true by passing the result on to the fragment stage and outputting that

#

I guess I'm hoping someone has seen something like this before and can suggest why it's like this

potent coral
#

How do I get the terrain to accept more than 8 light sources? I'm using forward+ and I've got more up to 25 light sources from underglow and headlights on each car. As a result, the terrain is no longer illuminated by the sun

#

The road the cars traverse on is being illuminated properly by all the lights, the only thing being weird is the terrain

low lichen
low lichen
potent coral
low lichen
devout kayak
#

in shader graph
is there a way to apply the object space normal vector node as texture then offsetting it
just connecting object space normal vector node to base color it is applied like textures but I want to offset it to get the same effect of offsetted texture when you change its uv

potent coral
#

Okay, no. Something else is wrong with my scripts

#

I hate coincidences like these

#

Sorry and thank you for your time

low lichen
#

If you explain why you need this, what effect you're going for, maybe there is another way to achieve it.

devout kayak
potent coral
#

Can I take a video? Because I think I'm going insane

low lichen
devout kayak
low lichen
potent coral
low lichen
potent coral
potent coral
#

I've finally sent the video after fighting discord upload

low lichen
# potent coral Yeah

It's possible that multiple directional lights have not been fully implemented in Forward+. More than one directional light is not usually recommended. In Unity, only one directional light can cast shadows.