#archived-shaders

1 messages · Page 51 of 1

toxic bluff
#

Hi guys! So... any good good intellisense plugin to work with shaders? Or maybe just some good reference material for HLSL functions, it's kinda confusing working with shader codes

regal stag
waxen verge
#

Hello again ^^' can someone explain me the "deformation part" in this tutorial ?

actually i have this but i don't how to deform my noise with the texture of the deformation part of the video

if i try to add my noise with deformation texture, i don't after how to connect it with the rest of the shader

nimble dirge
#

Could you send me the horizontal thing?

tropic badger
#

- Will shader be discarded if it reads data from a not initialized structured buffer? Something like null ref error in c# when referencing an empty array

#

- Context: my shader works properly in editor, but doesn't render at all unless buffer is updated in build

sleek granite
#

It depends on what you mean by initialized. You will get an error if the buffer wasn't bound, allocated correctly or whatever.
If it was bound and allocated correctly, but you didn't copy any actual data over, then you will typically get default values from reading from it

tropic badger
#

- Well, i don't get any errors. After i change my shader to return fixed color value without relying on the buffer, it works properly in build. I will try to force 1 as the alpha value tomorrow and see if my shader outputs black colours. But why do behaviours differ in editor and build?

mental lake
#

Is the stencil feature in the fullscreen shader graph bugged? When I set the reference to non-zero and the comparison to equal, the shader still executes

lunar valley
#

what are you trying to do?

icy cairn
#

Just spend the last 3 days figuring out how to add biomes to my infinite terrain (no tutorials apart from the intitial terrain by Sebastian Lague) using default cg shaders. It was difficult but my solution was pretty satisfying.

cedar glen
#

Hello

#

The standard way to make hair for 3d game characters is to populate the head with lots of transparent hair cards, but wouldnt this massively slow down performance since there is a lot of transparent objects stacked onto each other?

tacit parcel
#

might be easier if done using normal map

lunar valley
gloomy thistle
#

Hi, just wondering if anyone more experienced with shaders could give this a look over and tell me if there are any obvious pitfalls here? (Other than it being a geometry shader of course - I did attempt to implement the same by compute shader but found all sorts of issues and limitations, such as having no way to make the object pickable in scene view, the buffers being unassigned on every save or hot reload, being unable to make a prefab without crashing the editor...)

This URP shader takes a mesh representing a point cloud, and then for every vertex takes its screen space position and draws two tris forming a diamond around it.

#

I'm doing a bit of a comparison between different render pipelines and rendering modes to render point clouds in VR

meager pelican
#

Additionally, consider in your data structure pre-calcing all those offsets and such, trading off table-space for calc time and benchmark it all. Maybe building the calcs INTO the data and having more data is faster than calcing all these verts every frame. Hard to tell, because you'd have memory bandwidth to consider, but faster is faster so I'd benchmark both ways. IDK your use-case though and how often the points "move" relative to world space.

gray harness
#

I am trying to generate random numbers on gpu, I found the following code

float random (float2 uv)
{
    return frac(sin(dot(uv,float2(12.9898,78.233)))*43758.5453123);
}
#

I wanted to ask if the vector its dotted is somehow special. I need similiar function for vec3 & vec4 inputs.

brazen furnace
#

I have a very reflective material shader, but I wanna ignore the skybox in the reflections, how do I do that?

meager pelican
gray harness
#

i have around 80 000 particles in 3D space and need some randomness to add to them

#

the 0-1 range was for convinience

meager pelican
#

Do you want the values to vary every frame or to be "constant" based on the position of the particle?

gray harness
#

all of them move every frame, I dont care if they are constant or not at the same position

meager pelican
#

OK, so take the local-space positions, or world-space positions and screw with them, for example add the z value and the w value into the float2. Or whatever. But the dot product in the calc wants some vector to operate on. Doesn't matter much what it is, I would think. Try it.

#

There are a number for ways, like I said some based on time.

meager pelican
gloomy thistle
# meager pelican Without digging into your details, a couple thoughts: 1) VFX graph may be a bett...

Thanks, but the VFX graph, at least how I've managed to implement it, is an order of magnitude slower than my geometry shader implementation, along with a host of other issues (points randomly flicker in and out of existence even on low-res clouds, there's an asynchronous delay on loading the cloud so I can't switch in multiple LODs because there's a gap between them, I can't seem to get it to render more than 5m points without failing to compile, the number of points has to be set per VFX asset rather than per instance so either I need separate assets for different ranges of numbers of points or I need all point clouds to reserve the memory for the worst case point cloud).

Here's a quickly hashed together frame time graph for my shader (blue) vs VFX graph (orange, cut off at 4.7m verts since I can't render more than that). x axis is frame count, y is frame time, boxes are the number of verts in the scene being rendered, 72fps/13.9ms is target on Quest 2.

I'd be interested in learning more about the other methods you're suggesting - one thing that had come to mind was to use a compute shader, instead of regenerating all the geometry every frame, to generate 3x intersecting diamonds per point once at start, then never touch the geometry again after that - obviously that's 3x the geometry, but no cost to re-generate it every frame. I don't know how that would compare but there's only one way to find out 😛

#

The other thing I'm confused about is how performance tanks as the size of points increases (in both my shader and VFX graph) - there's no extra geometry involved but bigger points quicky become unusably slow and it appears to have something to do with the amount of overdraw, which feels to me like it can only be being caused by the fragment shader since the only thing increasing is the number of pixels - but I would have thought that the fragments which are obscured by other points would have been discarded? Or perhaps just the expense of testing and discarding so many fragments becomes a significant performance hit when you've got 5m+ overlapping faces...

tight phoenix
#

I have a billboard shader from the net, but the in-scene mesh's rotation is off by 90 on the X axis.
At what point in the graph should I add 90 to where to rotate it? Before the transform matrix? After? Other?

tropic badger
#

- This pisses me off. My shader works properly in editor, but not in build. See vids. Many solutions on the internet didn't help

steep gull
#

Hello I come from unreal and I use a texturing method in there called “Layered Materials” it essentially allows you to create separate materials (E.G damaged gold, chrome, leather etc) like you would in substance painter and then blend those separate materials together using a mask or vertex colors to make one overall material. I haven’t seen anything similar and was wondering if it could be written in shader graph or even hlsl?

grand jolt
#

are there any 3rd party (preferably CLI) tools for building shaders to be packed in assetbundles?

#

i need to compile and include shaders without using unity editor

#

back on 4.6.3 editor compiled them into some intermediate format which could then be loaded as a string (still not exactly what i'd like but better than nothing). on 2020.3.26f1 that option no longer works

grand jolt
#

oh nvm it was base64 of the compiled shader

uneven drum
#

Hi! I am trying to create a feedback/fluid effect in shadergraph. I need to have one of the subgraphs to output a texture that can then be sampled by other subgraphs. I can't seem to find a way to do that. Is there a way? Are feeback/multipass shaders possible in shadergraph?

wise igloo
#

is there a way to make bright values brighter but keep the same darkness on this texture?

uneven drum
hearty obsidian
#

I have a shader that tiles the floor based on WS position. I want moving platforms that will retain their initial coordinates even when moving so that the tiles on the floor do not shift as the platform moves.

Can I somehow attain that goal without caching the start position / creating instances of the material?

#

I've been using WS so that everything tiles seamlessly

humble robin
#

how can i get normals from gbuffer for deferred light rendering

meager pelican
# gloomy thistle The other thing I'm confused about is how performance tanks as the size of point...

So...yeah, overdraw will cost you. Rasterizing larger areas will cost you too, since you invoke more frag() functions like you said.
To reduce overdraw you'd have to sort the point cloud from closest to farthest from the camera's view. You'd then write to the depth buffer and use an early-z test (ztest on) to NOT call the frag shader for things that are obscured. If you didn't sort them, you could be overdrawing them, and that's a lot of extra frag calls. The early-z test is in hardware during rasterization and it's pretty fast in comparison to manually testing it in the frag and early-exiting.

As to your earlier comment, you can use a compute shader if you want, but you probably don't even need that. But IDK your use case. You could generate that buffer in C# just as easily, depends on how often it changes and whether you need a compute shader or not. But you've got that idea. Also research "procedural geometry" without using the geometry stage...see unity docs on it. I'm a bit short on time today, sorry, or I'd dig up more for you.

tacit parcel
digital gust
#

Good day everyone. i was wondering, if its possible to use stencil inside a shader graph. Basically I want to blend between two colors based on another camera/render texture. I cant use the render object feature with two materials, because this will mess up depth information at some point. ANy ideas?

white siren
#

is there a way to apply a shader to a mesh that already has multiple materials to begin with? i got a shader from the store for object fade in but im having issues with figuring out how to apply it to my objects 😢

digital gust
white siren
#

i curreltly got a mesh with 2 materials, tile front (white) and tile back (yellow) and at some point ill want to add faces

#

is there something like a node based editor in blender where i can combine two shaders into one?

digital gust
white siren
#

👀

#

thanks

#

that sounds good

toxic flume
#

Hey, how can I resolve texture bleeding?
There is a texture array containing several texture atlases. If I set filter mode to point, it will be OK without any problem but for other filter modes (bilinear, trilinear), it shows narrow lines (1 pixel).
I would like to use bilinear or trilinear filter mode instead of point. Is there any better way to handle it?

digital gust
# toxic flume .

Did you try to increase the padding of the textures or give them some extra pixel, so you dont end on the edge of pixels?

toxic flume
digital gust
toxic flume
#

It is my code to calculate the uv for each

 int tileIndex = i.tileData.x;
                TextureData tile = _TextureData[tileIndex];
                int atlasIndex = tile.atlasIndex;
                int resolution = tile.resolution;

                float3 w = frac(i.worldPos / resolution);
                half3 normal = abs(i.worldNormal);
                float2 uv = lerp(lerp(w.xy, w.xz, step(0.9, normal.y)), w.yz, step(0.9, normal.x));
                float2 origin = i.uv.xy;
                float2 size = i.uv.zw;
#

It is worth noting it is a voxel game

toxic flume
digital gust
#

ah you generating the uvs yourself. will did you try to like clamp edge values to not include the "last" pixels on the edges

digital gust
#

Well thats something you have to test out yourself on your code you just sent. Maybe someone else can go deeper into this, got no time to code prototyping, sorry

toxic flume
#

I get, multiply by 100, frac and then divided by 100

#

I test it

frosty linden
#

Hello, I'm trying to merge two normap maps texture together using the normal blend node but it's not resulting like I think it should.

#

Shouldn't it stacks the blue parts together ?

#

It seems to only merge the overlapping parts ?

tropic badger
regal stag
#

Though it's a little odd the normals outside those regions are black/negative to begin with, so perhaps it's just something wrong with the input textures

humble robin
#

is it possible to get screen space normals using URP?

tight robin
#

hey guys,i want to change this material to new material i created.there is a lot of repeted object so dragging and dropping takes a lot of time.

#

so is there a way to change trash.002 material to new material i created?

gloomy thistle
#

@tight robin If you select the model in the Project window, you can see the import settings for the model. There's a tab for Materials - click on that, and then there are fields called "On Demand Remap". These replace material slots with a material you choose when the model is imported, and will apply to every instance of the model where you haven't overriden the material

#

Alternatively, you can make a prefab of the object, change the material there, and use the prefab in your scenes - I sometimes prefer doing that since it means if I make changes to the model and reimport it then I don't need to reassign the remapped materials every time I import it, but that's a minor thing

brazen kernel
low lichen
brazen kernel
digital gust
#

Just bumping my issue here with some changes in wording to maybe make it clearer. Is there anything like the SphereMask for ShaderGraph besides the spherical one? I am trying to mask out parts of material based on a mesh (or camera render texture if needed).

#

I am on URP btw

silk sky
#

I'm trying to setup a simple URP Alpha shader that basically takes a texture and and a mask to turn some parts alpha, but even with just the simple texture node the result seems broken compared to a defualt Opaque shader

#

Comparison (super cursed)

#

What could be wrong?

#

So far this is the graph, pretty simple

regal stag
regal stag
silk sky
#

Ok thanks

tight phoenix
#

What is the correct formula to push all of a mesh's vertexes away from a specific passed in position?

tiny forum
#

how can i form proper pixel circles

brazen furnace
#

I have a very reflective material shader, but I wanna ignore the skybox in the reflections, how do I do that?

tight phoenix
#

How do I alter this to push away from the offset point per the entire mesh instead of per individual vertex position? That is why I am using Object Position, but I have to replace that world space thing with something to make it push away uniformly instead of per vertex

regal stag
regal stag
brazen furnace
regal stag
# tiny forum how can i form proper pixel circles

Looks like a circle to me. I guess there's an extra pixel at the top & right that's outside the quad though... might need a half-pixel offset somewhere so it's centered properly? (Subtract (0.5/width, 0.5/height)). Not too sure off the top of my head.

regal stag
brazen furnace
#

Isnt there any way to do this in a shader specifically?

#

Trying to learn how to become pro at shadergraph, surely there should be a way right

tiny forum
regal stag
distant lagoon
#

Hi all, I'm having a bit of trouble getting an interaction shader working
I'm happy with the visual aspect of the shader, it just creates a highlight / outline around an object, sort of similar to in Half-Life 2.

The issue I'm trying to work around is that I'm not sure how to toggle it per interactable object.
When one door is targeted by the player, I'm currently just setting a bool in the shader to enable the outline.
However, the shader material parameters are global so every single door and every other interactable object using the shader material will also be highlighted.

Is there a way to make so only the currently targeted interactable will have a highlight?

amber saffron
distant lagoon
#

Ah ok thank you, would it be right to say the materials are instantiated at runtime per object and so you can individually set their parameters (if you target that specific objects material)

amber saffron
distant lagoon
#

Ah that's good to know, thanks :)

prime mist
#

Hey, I'm looking for good texture/shader resources for simple applications like houses... like simple paints, wood paneling, floors, metals for like chair legs... are there assess available outside teh Asses Store?

sour trench
#

Hey I’m trying not to pull my fucking hair out rn, for some reason literally none of my custom shaders work and I can’t figure out why with google

#

Does anybody know why the Shader keyword in a .shader file wouldn’t work

#

It’s my first day trying to figure this out btw pls don’t judge if it’s obvious

#

For some reason the program doesn't know what any of the underlined things mean. This is the example code generated by unity though so it should??

#

Somebody please help I have no idea what’s going on 😭

lunar valley
sour trench
lunar valley
#

so you have created a shader, didn't touch anything and unity is giving you errors?

sour trench
#

It doesn’t let me assign them to any objects though bc they’re bugged

sour trench
#

I can record it if you’d like, that’s exactly what I’m doing

#

@lunar valley

lunar valley
# sour trench

if that also happens to shader where you didn't have spaces in the names then idk

sour trench
#

It did. All shaders refuse to work

#

It doesn't know what the keywords are for some reason. The word Shader at the beginning of the program is seen as an unknown variable type

toxic flume
#

Hey, I get this error

ArgumentOutOfRangeException: Count must be in the range of 0 to 1023.

when running Graphics.DrawMeshInstance

sour trench
#

I think I have 2 versions of it but I don’t remember if unity is launching the new one or the old one

brazen kernel
#

What does the w component of ComputeGrabScreenPos() represent?

candid jewel
#

Sorry noob question. We're using URP.

We have a shader graph that utilizes emissives that are applied to foliage, with a timer going to make it shimmer/fade.
The question is, how would we make that timer "random", relative to the position of a mesh-in the world?
Currently, all the meshes glow and fade in sync with each other, but the goal is to have all the timers per grass instance separate/offset randomly. Is there a way to achieve that easily?

https://cdn.discordapp.com/attachments/1042231606657679441/1121148418434269295/image.png

toxic flume
#

So, should I call Graphics.DrawMeshInstance several times based on shape count (1023)?
Is there any alternative way?

regal stag
regal stag
regal stag
toxic flume
toxic flume
regal stag
toxic flume
#

Which one is more efficient? DrawMeshInstanceIndirect? I have many cubes more than 25000 cubes

ashen linden
#

got this bugs and it keeps referencing shaders, any idea of what is this?

#

Shader warning in 'Shader Graphs/TerrainSmartSurface_Shader': 'UnityMetaVertexPosition': implicit truncation of vector type at Project/Library/PackageCache/com.unity.render-pipelines.universal@14.0.7/Editor/ShaderGraph/Includes/Varyings.hlsl(131) (on d3d11)

Compiling Subshader: 0, Pass: Meta, Vertex program with <no keywords>
Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PASS_META UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: EDITOR_VISUALIZATION SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING

may of this bugs

#

Shader warning in 'Hidden/VFX/Slash_01_VFX/System/BrightSlashMid': pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them at line 3775 (on d3d11)

and some of these

#

some of my shadergraphs started to look like this

brazen kernel
#

Need some help dealing with screen space positions and aspect ratio. I'm trying to make a black hole effect (where the inner part will display the pixel at the middle of the black hole and the outer part displays the pixel at its position unaffected) and at square aspect ratio it works fine but at any other ratios it falls apart. (The only thing changed between the two pictures is the aspect ratio)

#
float2 screenUV = i.grabPos.xy / i.grabPos.w;
float2 offsetUV = (i.uv * 2 - 1) * _DistortionSize;
float dist = length(offsetUV);
float sdist = distance(i.middlePos, screenUV);
float val = inverseLerp(_Size, _DistortionSize, dist);
clip(1 - val);

float ild = (_Size * sdist) / dist;
offsetUV *= -lerp(ild, 0, val);

screenUV += offsetUV;

float4 col = tex2D(_BackgroundTexture, screenUV);

return float4(col.rgb, 1);
#

i.middlePos is the screen space position of the object (not the fragment)

frozen sapphire
#

hello trying to wrap my head around compute shaders atm and im struggling to understand how to deal with threadgroups.
So my understanding is that if i have something like
[numthreads(8,8,8)]
then my compute shader is running in parallel on 512 threads which make up a single threadgroup.
I can then specify how many threadgroups to run via the dispatch command. Something like
pointGridCompute.Dispatch(KERNEL_INDEX, 1, 1, 1);
is simply telling it to run one thread group. So in total the compute shader is exectued 512 times?

I thnk this makes ense to me but where i get confused is, what if i have to run 600 times? Most resources are telling me to simply dispatch 2 threadgroups but then how do i identify what data is among the first 600 that I am concerned with?

Some of the resources ive looked at mentioned consume and append buffers but im having difficuly finding any explations that i can actually understand

vast sail
#

Hey so I'm in unity 2019 on the built in render pipeline. I got a copy of the surface shader but all it does is call a metric ton of pragma functions. How would I go about doing something as simple as masking where the color effects the albedo texture. I can't find a single area where an insertion makes sense or a pragma function that even references the albedo.

#

here is an example from the standard shader

#

here is an example from a much more simple shader

#

I'm looking to create a function like this where I can modify the data without messing up the entire shader

#

I just want to add some basic color adjustments but keep the other features intact

frozen sapphire
# vast sail Hey so I'm in unity 2019 on the built in render pipeline. I got a copy of the su...

pretty sure its after u declare c and before the o.x assignments so like

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;


    //YOUR CODE GOES HERE
    //o is the output struct so assign our output to it accordingly


    // Metallic and smoothness come from slider variables
    o.Metallic = _Metallic;
    o.Smoothness = _Glossiness;
    o.Alpha = c.a;
}
ENDCG
vast sail
frozen sapphire
#

oh i see what u mean. in urp u would just replace one of the fragment functions with ur own

#

im guessing its probably the same here

#

but someone with more brp specific experience can probably give u a clearer answer

brazen furnace
#

How do I make the white part of this a bit alpha'd out/more gray? I basically wanna try setting the white part to be half white half black (a.k.a gray a.k.a. less opaque)

regal stag
brazen furnace
#

Thanks lol

brazen furnace
#

What does this even mean?

white siren
#

MONDO TV brings you the first ever English-language broadcast of a Japanese professional mahjong television program. Four of the best players in Japan battle it out to see who will become the 10th Mondo Women’s Champion. If you’re a fan of mahjong competitions, have heard of the game through popular comics like Saki or Akagi, or have played onli...

▶ Play video
#

interested in how you could achieve this milky smooth surface of a tile without resorting to subsurface scattering

toxic flume
#

Hey, maybe my question is vague but it is better to pass data to shaders for each vertex through vertex data and define them as TEXCOORD or use compute buffer?

white siren
amber saffron
brazen furnace
#

Help I get this error even when making new shader files from scratch...

That is a unity-made builtin unlit shader and it just shows these errors for no reason. I havent even edited the file :S Already tried deleting Library in the project

lone stream
#

anyone know how to Load/Sampling Directional Lightmap from shadergraph?

#

especially the lightmap UV part

#

oh nvm i got it

regal stag
grand jolt
#

does anyone know what the hell this error message means

#

i looked it up and got like. literally 6 search results total

#

none of which seem to have contained a solution

#

supposed offender is the last line here

#

upd apparently it's because variables can't be declared inside an if

#

it couldve had a clearer error message derpthink

regal stag
grand jolt
#

i can

#

it went away after i moved op definition out of the if's scope

regal stag
#

Oh okay. You also don't have {} after the if, so the scope is only that first line.

grand jolt
#

oh fuck

#

oh yeah THAT was the issue

#

i CAN declare variables in an if

humble robin
#
            ConfigureTarget(normal, rtCameraDepth);
            ConfigureClear(ClearFlag.Color, Color.clear);

            SortingCriteria sortingCriteria = renderingData.cameraData.defaultOpaqueSortFlags;
            DrawingSettings drawingSettings = CreateDrawingSettings(shaderTagsList, ref renderingData, sortingCriteria);
            drawingSettings.overrideMaterialPassIndex = 0;
            drawingSettings.overrideMaterial = viewSpaceNormalMaterial;
            
            context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);
            cmd.SetGlobalTexture("_ViewSpaceNormal", normal);

i am trying to get viewSpaceNormals in the game with this renderer feature pass, however this does not work with 2D sprites that have normal maps assigned to them. How can i make this work with them? How does URP 2D lights do it? Here is the shader.

Shader "Custom/ViewSpaceNormal"
{
    SubShader
    {
        Pass
        {
            CGPROGRAM    
            #pragma vertex vert
            #pragma fragment frag
            
            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float3 normal : NORMAL;
            };

            struct v2f
            {
                float4 vertex : SV_POSITION;
                float3 normal : TEXCOORD0;
            };

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.normal = normalize(mul((float3x3)UNITY_MATRIX_IT_MV, v.normal));
                return o;
            }
            
            fixed4 frag (v2f i) : SV_Target
            {
                return half4(i.normal * 0.5 + 0.5, 1.0f);
            }
            ENDCG
        }
    }
}
#

the cube and sphere are 3D objects however there is a 2D object here that i cant get normals from

#

the dummy is a 2D object and has a secondary texture as normal map, how can i also get its normals?

regal stag
# humble robin ```csharp ConfigureTarget(normal, rtCameraDepth); Config...

overrideMaterial overrides the material including it's properties, but you can use overrideShader (assuming Unity 2022.2+) to only override the shader and keep the current properties (like the sprite textures), which you could then sample in the ViewSpaceNormal shader.
(Note overrideShader doesn't play nice with the SRP Batcher but since these are sprites that shouldn't matter. Hopefully they'd still batch fine...)

#

If the shader used by the sprite already contains a normals pass you could also use that instead of overriding, by specifying it in the shaderTagsList. (Looks like URP/2D/Sprite-Lit-Default has a "NormalsRendering" pass?)

haughty siren
#

quick question, what are these types of methods that return a var called? idk what to google since idk they're name

            {
                return x*(1-a)+y*a;
            }```
regal stag
grand jolt
#

Hey there, is there a way to make a shader that assembles the tiles of this ground texture one by one? (For a cool ground build up effect). I have something like this in mind: https://youtu.be/iovdVlZgRls?t=120

Merge Cooking:Theme Restaurant | Level 1-4 Part 1

Do you know you can enjoy the food around the world without traveling?
Do you know you can master the secret of cooking with just a few simple steps?
Tie your apron and put your chef hat on!
In Merge Cooking, you can cook anything!

  • Welcome, Chef!
    Your assistant Lea is waiting for you to start...
▶ Play video
haughty siren
humble robin
humble robin
regal stag
# grand jolt Hey there, is there a way to make a shader that assembles the tiles of this grou...

Not really from a texture, but if the tiles are separate objects you can move them with C# or displacement in vertex shader. Similar to some "Bastion-style" shader effects. e.g. https://www.patreon.com/posts/31938500 (or ShaderGraph version : https://www.patreon.com/posts/32245525)

If tiles are separate pieces of geometry, but in the same mesh still, you can also bake pivot data for each tile to an additional UV channel. Then use that in vertex shader calculations. Similar to this fracturing effect of mine : https://www.cyanilux.com/tutorials/fractured-cube-breakdown/

blissful marlin
#

I'm using a slightly janky system for projecting decals onto a material by rendering it to a render texture on it's own pass whenever a decal is applied.

This has been working well, but when I make a webGL build, the UV coordinates seem to no longer align (the position of the decal is inverted along the edges, but when applied in the dead middle, is correct). This doesn't happen in editor or on windows build

I'm losing my mind, any suggestions as to what could possibly cause the difference between the two?

regal stag
tight phoenix
#

In URP shadergraph how do I correctly define a skybox? My attempt to sample a cubemap is causing doom hall of mirrors effect

#

this is the whole 'shader'

regal stag
tight phoenix
#

Is the environment tab not where/how I should assign that?

regal stag
#

Saved graph? Does the material have the cubemap assigned?

tight phoenix
regal stag
#

You might also need to attach the Position node to the Dir port, by default it uses View Dir iirc

tight phoenix
#

Oh that might have been it

#

I see something now

cobalt patrol
#

I'm trying to recreate this effect in Unity. The left side is my current shader in Unity and on the right is Unreal and what I am trying to achieve is a shader that only effects the Normals of the materials below it and not the color / other properties.

The white lines in the left picture, are trim sheets that I only want to effect the normals of the underlying object without effecting color. So right now they are white, but those lines should be the same color. This Yellow panel has 4 multi-sub-object materials. One is the yellow, one, for metal, then 2 for the trim sheets. One trim sheet for normals, and one for color and normals.

I can't seem to find a way to have a shader that just does normals without color.

dusty creek
#

how do I turn this into a hard cut-off? I just want black and white, no gray

teal hornet
#

use step node

dusty creek
#

ah thanks

tight phoenix
#

question about rendering orders and stencil buffers in URP - is there a value or setting that I can use to make my stencil buffered geometry render overtop of geometry that otherwise is occluding it? Pictured I'd like to see the entire box, but its overlapped by the mesh behind it

#

the cube itself is only visible because the interior frame is an invisible stencil buffer

#
Shader "Custom/URPStencilMask" {
    Properties {
    [IntRange] _Stencil ("Stencil Ref", Range(0,255)) = 0
    }
    SubShader {
        Tags { "RenderType"="Transparent" "Queue"="Geometry-10" }
        Pass {
            Stencil {
                Ref [_Stencil]
                Comp Always
                Pass Replace
            }
            ColorMask 0
            ZWrite Off
        }
    }
}```
the stencil itself is a very basic from one of Cyan's posts, looking at more lengthy versions others have made to see if they support what I am refering to
#

I guess the two ways this can be achieved is culling rendering of meshes on the layer behind the stencil hole,
or somehow overdrawing the meshes in the stencil hole ontop of the things that'd otherwise be culling them?

regal stag
# tight phoenix question about rendering orders and stencil buffers in URP - is there a value or...

You can use different ZTest modes when rendering those objects (like the cube), though that's going to look a bit weird with different meshes that have overlapping faces. Unless you render it in two passes maybe, one to override the depth buffer values (ZTest Always, ZWrite On and ColorMask 0), then render again like you have currently. Can probably do that with a couple Render Objects features.

Or I guess you could override the depth values for the stencil-window itself, by using the SV_Depth shader output to set it back to the far plane so any objects rendered after can render over it. Render the stencilled objects, then render the window again with the correct depth values (so future objects ZTest correctly still).

Another option could maybe be use a second camera & render texture instead of stencils.

cerulean mauve
#

how can i do math with those 2 to make scrolling shader?

regal stag
cerulean mauve
#

but which node connect those 2

tight phoenix
regal stag
cerulean mauve
#

all i got for now

#

is there anything that connect those 2, cuz i've been sitting here for like 30 minutes and couldn't do anything...

regal stag
#

Though that likely is a bit more expensive

tight phoenix
regal stag
tight phoenix
#

I could use a second camera set to Overlap if I could figure out what combination of settings would subtract out the orange mesh

#

so far I've only managed to show the orange mesh only inside of the frame, or always completlely, and that was only by accident

#

yeah trying to get the opposite of this 🤔

regal stag
#

Do you even need that face of the monitor there, couldn't it just be a hole?

tight phoenix
#

the reason its not a hole is because the screens in front of it aren't even attached to that mesh, and they resize

#

I could do a bunch of modeling but this all needs to move around a lot, and I might add or remove screens at runtime in ways that makes it less feasable to have a single bespoke mesh

cerulean mauve
tight phoenix
#

I am guessing that I just need to flip one single value somewhere, so that instead of 'only renders in here' I get 'only doesnt render in here'

#

I can set stuff to 'keep''

#

but 'discard' is not an optiopn

#

I think my real problem is I have no real comprehension of stencils or stencil tests, I'm still a novice at shaders and im a less than a novice at stencils

regal stag
#

You don't want to discard stencils anyway, it's the depth that is the problem no?

tight phoenix
#

Maybe? Its the orange mesh not having a hole in it is the problem, or not being able to render geo arbitrarily 🤔

#

ideal final output is computer screen where geo can perspectively have impossible depth ala every single stencil buffer shader

regal stag
tight phoenix
cerulean mauve
#

can someone explain this?

tight phoenix
#

hrmg yeah right away an issue 🤔

#

I was hoping to use an overlay camera of the monitor so that I could move the actual main screen camera around inside of the 'monitor'

#

hm wait

#

I think I know what the problem is, its my massive black backdrop meshes

#

Yup that was it

#

screens on screens 😱

hollow wolf
#

idk about yours unity version tho

lunar valley
cerulean mauve
grand jolt
#

why do I not get the color in the end...

#

i closed and reopened unity, and this is what happpened

#

(urp and shader graph are installed)

grizzled bolt
grand jolt
#

yes

#

it is a urp2d project

grand jolt
#

thank you

sweet burrow
#

Hello,
I'm trying to do some custom lighting, but "#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl" make Shadergraph's compiler complain about redefinition of "_Time". Is that a deprecated file, does it require more include, or is the problem something else?

regal stag
sweet burrow
#

Then the problem is why the compiler can't find **TransformWorldToShadowCoord ** on its own - it is supposed to be in shadows.hlsl, which is why I tried to explicitly include it

regal stag
sweet burrow
#

Thank, the shader compile now.
... now to find why everything is black. I will take a look at that repo.

blissful marlin
#

any idea why rendering to the command buffer might look incorrect when multiple monitors of different sizes are running the game? It only happens on builds

dapper arrow
#

How to fix this issue where the grass details get way too dark or bright at slopes and hills?

#

Probs can be fixed by making a small change to the built in grass shader

#

I want the grass to sorta sample the terrain normals or stuffs and tint itself to blend well with the terrain

#

But I just never tried shaders at all

#

Would be helpful if someone can help me out and lmk how exactly can that be done

#

Also is there some open source overall more efficient terrain 2d grass details shader available for mobile, cause the built in grass shaders are very outdated.

cosmic prairie
#

?

#

if details I think you need to set render mode to grass for it to follow terrain normal

dapper arrow
#

2d grass details

cosmic prairie
#

looks like its in render mode

dapper arrow
#

Thanks

#

I'll look into it

#

Appreciate you alot man

#

Alright I am using 2d grass textures as details

#

So that wouldn't work

#

I would need the billboarding and performance advantages

cosmic prairie
dapper arrow
#

It almost always looks ok but not on slopes

violet quail
#

how do I create a "URP Sample Buffer" node

#

there is nothing for me here

regal stag
violet quail
#

thanks man, I've been struggling for hours

spring fox
#

im having issues with a custom function, earlier today i was sampling Linear01Depth just fine with this line color += Linear01Depth(SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv * scale + center), _ZBufferParams);, now, i dont know what happened, but this exact same line doesnt work anymore, instead of actually returning depth it just returns 1. and let me be clear with this, i changed NOTHING. please let me know if you got any ideas my sanity is rapidly declining hshshshshhshshs

#

its supposed to look like this

#

but now i just see this

#

and again, i didnt change anything, it just stopped working??

spring fox
#

lemme send the whole function

#
    float blurStart = 1.0;
    

    float2 uv = fragCoord.xy / iResolution.xy;
    float4 color = 0;
    uv -= center;
    float precompute = blurWidth * (1.0 / float(nsamples - 1));

    for (int i = 0; i < nsamples; i++)
    {
        float scale = blurStart + (float(i) * precompute);
        color += Linear01Depth(SHADERGRAPH_SAMPLE_SCENE_DEPTH(uv * scale + center), _ZBufferParams);
    }
    color /= nsamples;
    Out = color;
#

its a radial blur on the depth texture

#

i opened unity to change it up a bit but then i noticed it just stopped doing what it was supposed to do

spring fox
lunar valley
#

can you just sample the depth normally just to be sure it doesn't have anything to do with the blurring, also check if the camera is actually rendering depth

spring fox
#

yes, when i sample depth normally it works

#

the issue is within the function

#

sampling linear01 depth with the scene depth node

#

but then when i use the custom function its just blank

#

maybe something is up with the uv im generating in the func, but again, i havent changed anything since it was working beforehand

lunar valley
spring fox
#

alr

#

lemme try just sampling it normally in the function, no uv offset

lunar valley
#

thats what I was proposing 👍

spring fox
#

lovely.

#

alr

#

so it just isnt getting depth

#

reading the docs, it is correct?

#

i need to sample depth within the function to get the uv offset in the loop

#

so when i sample depth in this function, it acts like the mat is opaque?

#

even tho its transparent

#

rahh im so confused

#

lemme write a new function that just grabs depth and see if that works

lunar valley
spring fox
#

seems like my exact issue Thumsup

#

it says to have a dummy scene depth node

#

but i have one?

#

OH

#

I SEE

#

thank you sm lmao

grave vortex
#

I'm doing some custom shadow mapping stuff in URP, would any shader wizard nearby happen to know what kind of depth render is produced by shadows in URP? Is it linear?

#

I'm reading the source code, and I think It's just clip space eye depth

#

But I don't really feel I understand the full system and might be missing something

stable flare
#

How do you make a faded infinite black hole effect like in Zelda's shrines? I tried with particles, but i feel like drawing a lot of smoke-like particles just to make them stay on the bottom is pretty unperformative

regal stag
regal stag
# grave vortex I'm doing some custom shadow mapping stuff in URP, would any shader wizard nearb...

Assuming the main light shadowmap, that's orthographic so should be linear depth, in a 0-1 range. Likely not the same clipping planes as the main camera though.

You'd typically transform a world position into the shadow space using matrices (_MainLightWorldToShadow array), then compare the depth in the shadowmap with shadowCoord.z. This is done automatically when using the SAMPLE_TEXTURE2D_SHADOW macro. Maybe also see : https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl

grave vortex
#

I'm asking since I've been having self shadowing issues, where surfaces parallel to the light direction are erroneously shadowed. Right now I'm trying to make sure to use a linear depth format as is highly recommended in this article. https://developer.nvidia.com/gpugems/gpugems3/part-ii-light-and-shadows/chapter-8-summed-area-variance-shadow-maps

#

Though I doubtlessly have separate problems contributing to the self shadowing (Biasing Issues maybe?), I still want to ensure my depth map is linear

tropic osprey
#

currently working on a custom shader that i'll use so sprites get affected by 3d lighting, i'm trying to flip the normals of the object if the displaying face is the back face

#

but i cant seem to attach "Is Front Face" to the predicate in the branch

#

despite the fact that its a bool?

#

i'm a bit confused

tropic osprey
#

i'm basically trying to avoid this behaviour where if i flip a sprite on the x or y axis the lighting gets all wonky

misty cargo
#

I'm getting an error about not including INTERNAL_DATA.... but it's included?

            struct Input {
                float3 worldPos;
                float3 worldNormal;
                INTERNAL_DATA
            };

            void surf(Input IN, inout SurfaceOutputStandard o) {
                // Calculate the triplanar weights based on the world normal
                float3 weights = abs(IN.worldNormal);
                weights /= dot(weights, 1);

                // Sample the textures using the world position scaled by _Scale
                float3 uvw = IN.worldPos * _Scale;
                float4 tex = 0;
                float3 nrm = 0;
                // Use the grass texture and normal map for the top plane
                tex += tex2D(_GrassTex, uvw.xy) * weights.y;

                nrm += UnpackNormal(tex2D(_GrassNormalMap, uvw.xy)) * weights.y;

                // Use the rock texture and normal map for the other two planes
                tex += tex2D(_RockTex, uvw.yz) * weights.x;
                tex += tex2D(_RockTex, uvw.xz) * weights.z;
                nrm += UnpackNormal(tex2D(_RockNormalMap, uvw.yz)) * weights.x;
                nrm += UnpackNormal(tex2D(_RockNormalMap, uvw.xz)) * weights.z;

                // Output the final color and normal
                o.Albedo = tex.rgb;
                o.Normal = nrm.rgb;

            }
regal stag
toxic flume
#

Can I mask shadows based on col.a? I want it for sprite shadow

slender wren
#

does anyone know how to apply fullscreen shaders only on tagged gameobjects?

regal stag
toxic flume
regal stag
#

Would be clip(alpha - threshold); in code

toxic flume
#
 UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"

Built in shader

#

I have shadows for sprites but it uses meshes not sprite alpha

regal stag
#

You'd need to copy/rewrite the ShadowCaster rather than using a UsePass

#

Unless it already implements alpha clipping with keywords / specific property names

regal stag
toxic flume
regal stag
toxic flume
#

They are transparent

ZWrite Off
regal stag
#

I mean use the ShadowCaster from it, not swap the entire shader

toxic flume
regal stag
#

Oh, seems the pass name does need to be all caps. So SHADOWCASTER instead.

toxic flume
slender wren
toxic flume
regal stag
toxic flume
toxic flume
#

It is like //UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"

#
  UsePass "Legacy Shaders/Transparent/Cutout/VertexLit/CASTER"
regal stag
#

You'll need the properties it expects - _MainTex, _Cutoff and _Color

#
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5

Make sure you have these in your Properties section

wintry geyser
#

Is there a way to make a procedual wave in shader graph, that wraps around a circle?

wintry geyser
# regal stag Something like this?

Oh, somewhat. Do you see my profile picture? Im trying to make waves go up and down within the circle, serving as a sort of audio visualizer. Not actually representing the frequencies, just a general move whjen sound is played

#

Ive been trying to achieve this effect for ages, but I never really manage to. My shader graph knowledge is limited, and I have no ide ahow complex it would be to get that

regal stag
wintry geyser
regal stag
#

I don't do DMs

feral quest
#

How to have the texture/color on the backside of my object instead of transparent?

regal stag
regal stag
# feral quest And where do i find it?

If you're in the Built-in Render Pipeline, afaik Unity doesn't provide one but if you google "double-sided Standard shader" you'll probably be able to find one.

If you're in the Universal Render Pipeline, the URP/Lit shader should already have a Render Face dropdown.

feral quest
humble robin
#
        private RTHandle source;
        private RTHandle depthRenderTexture;
        private RTHandle colorRenderTexture;

        public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
        {
            source = renderingData.cameraData.renderer.cameraColorTargetHandle;

            RenderingUtils.ReAllocateIfNeeded(ref depthRenderTexture, colorDesc, name: "_PDepthBuffer");
            RenderingUtils.ReAllocateIfNeeded(ref colorRenderTexture, colorDesc, name: "_PColorBuffer");
        }
        public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
        {
           cmd.Blit(source, colorRenderTexture, colorBufferPixelizeMaterial);
           cmd.Blit(source, depthRenderTexture, depthBufferPixelizeMaterial);
        }

When my mouse is pointing at a material of spriterenderer or meshrenderer in the inspector i get assertion failed error. I removed the blits in the execute function and noticed the error was gone. I am guessing that it is because of the source, since i am getting cameraColorTargetHandle. How can i prevent this from happening?

regal stag
humble robin
dusty creek
#

if an object already has a material, how do I add a shadergraph material ontop of that instead of replacing it?

grizzled bolt
dusty creek
#

so if I want to put an effect over a material I have to take in the old material / texture as a variable? :c

grizzled bolt
#

Otherwise I might swap the object's material to a material instance with the effect and pass properties like texture and color with a script

dusty creek
#

I'm just trying to learn more about shaders

#

I'm just thinking about how I would do some things in shadergraph (or HLSL if I get into that) like a character having a dusty effect overlay over their basic skin and clothing material

grizzled bolt
cosmic prairie
dusty creek
#

that's 1 effect, what if I want multiple? xD

grizzled bolt
# dusty creek that's 1 effect, what if I want multiple? xD

Same deal, you'd have to either include them all in your shader at the risk of making it costly, or making more shaders to use with the replacement script
It's technically possible to do another shader pass on the same submesh but from what I understand that's not recommend for performance or workflow reasons

tropic osprey
tropic osprey
#

i'm having multiple difficulties getting this to work properly

#

https://youtu.be/764si-ArcIU
idk if it means anything but i'm trying the fix stated here

In a short follow-up to my previous tutorial on Sprite lighting, I'll show you how to achieve the same effect with the Unity's HDRP.

Standard Renderer Shader - https://youtu.be/flu2PNRUAso

Follow me and my game "Destiny Break" on Twitter - https://twitter.com/SayAllenthing

Sections:
Intro: (0:00)
Lighting Sprite: (0:18)
Fixing Backfaces: (1:2...

▶ Play video
#

i'm using URP for the render pipeline in this case

#

the issue is basically that one of the faces of my sprite if i set the render face to both end up with some weird lightingn artifacts

#

if anyone knows a good fix for this i'd be much obliged, because i'm in a bit of a roadblock rn

i think it might indeed have to do with the normal of the object on the fragment stage as Cyan stated

#

but no combination of normals and isFrontFace is working

#

ok nevermind, this does actually work, i can rotate the sprite object and it keeps its correct look

#

altho now flipping the sprite causes both sides to have the wrong color, which iirc is just because the scale is set to -1

slender wren
#

@regal stag How would I use a layermask to write to a texture via a custom render feature only objects with the tag to the texture?

ebon basin
#

Oh yeah that's pretty interesting, I think I've ran into a similar issue but when it comes to 2.5D you usually billboard your stuff so it's always rendering the front

regal stag
slender wren
#

what does the function do?

tropic osprey
#

and then flip the side and cornver views for the other missing sides

frosty linden
#

Hello, I'm trying to load a texture located in my streamingasset folder in linear colorspace using UnityWebRequestTexture

#

I've read I just need to use ImageConversion.LoadImage(tex, tex.GetRawTextureData()); to convert from sRGB to RGB

#

This texture is channel packed with albedo in red, normal x in green, normal y in blue and alpha in alpha

#

When loaded, it appears the colorspace is still not set to linear.

#

When I put this texture in the root asset folder and disable sRGB in the texture importer, I get this

#

Which is correct and when I replace the web texture by the one from my asset folder, I get the desired result.

#

How can I get my UnityWebRequestTexture loaded texture to be the same as the texture importer ?

frosty linden
#

Ok, to answer my own question, it appears I was using the wrong bytes[] source.

#

It's working fine with ImageConversion.LoadImage(tex, uwr.downloadHandler.data);

warm rapids
#

how do I get tesselation factor as an option in my shader graph? I'm following this video that has it in the vertex space but I'm not sure how to get it for myself

warm rapids
#

can it be done in another way outside of hdrp

regal stag
#

Not really for Shader Graph, but can add tessellation to shader code

warm rapids
#

thought so. not very experienced in shader code yet unfortunately

grim bloom
#

How to achieve something like this

#

Ignore that skull

#

Should I do gradient node then split alpha?

cosmic prairie
grim bloom
cosmic prairie
#

nice

open patrol
#

Hey can can someone help me

#

i wanna create outline shader

#

like in tutorial

#

i have my own object

#

heart

#

this is how i set my shader

#

when i apply it on object it doesn't do anyhting

grim bloom
#

Will this shader work now? I have URP 2021

cosmic prairie
cosmic prairie
cosmic prairie
#

you have 81 set as your scale

#

thats way bigger than your object

#

probably want to reduce that

#

also, if your normals are smooth you should base your outline on normals

#

and not scale up the object

grim bloom
tight phoenix
#
void Unity_ColorspaceConversion_RGB_HSV_float(float3 In, out float3 Out)
{
    float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
    float4 P = lerp(float4(In.bg, K.wz), float4(In.gb, K.xy), step(In.b, In.g));
    float4 Q = lerp(float4(P.xyw, In.r), float4(In.r, P.yzx), step(P.x, In.r));
    float D = Q.x - min(Q.w, Q.y);
    float  E = 1e-10;
    float V = (D == 0) ? Q.x : (Q.x + E);
    Out = float3(abs(Q.z + (Q.w - Q.y)/(6.0 * D + E)), D / (Q.x + E), V);
}```
I am having a problem with unity's colorspace conversion formula. The problem is that when Value is zero, Saturation also becomes zero. This is causing bugs further down the line that expect a saturation of 1 when the color value is on the fully saturated side 🤔
#

I havent found some way to fix the bug, and forcing the value to be nonzero is only causing even more bugs in different places

#

or something? I'm poking and prodding but I can't seem to figure out where this color problem is coming from, somehow red is becoming not red and its so frustrating to debug because I can't just extract a @#$@^ float balue from the red channel to tell EXACTLY how much and where its coming from 💢

#

I found this online

#

be productive instead of angry mad

violet quail
#

How do i add a valid keyword? If I change size, it increases the size of invalid keywords instead

#

Or is there any other way to set these shader keywords in unity 2021

#

Oh, I got it

#

These keywords just appear in the material properties

leaden mason
#

Hello,
I'm making a shader with a top-down world space texturing.
It's quite a simple one, but I am missing something and my normal maps look wrong.
I assume there is an easy way to fix it, but I simply don't know how.
Can anybody help?

regal stag
# leaden mason Hello, I'm making a shader with a top-down world space texturing. It's quite a s...

Assuming it's the typical tangent-space normal map (the bluish ones), ShaderGraph will transform that from tangent into world space using the tangent & normal vectors stored in the mesh data. Those tangents are aligned to the mesh UV0, hence why it might look wrong when using different UV coords.
I think in this case you can just Swizzle the "tangent" space normal (RGBA result of the Sample Texture 2D set to Normal mode). "xzy" should work.
For a Lit Graph, under the Graph Settings you'd change the "Normal Fragment Space" to "World" then connect your output to the "Normal (World Space)" port in the Fragment stack.

leaden mason
#

@regal stag that actually works! Thank you so much!

storm cloud
#

having foilage render both faces only checks if the sun hits on one side forcing me to have it rotated towards the sun to look right, and i think having duplicate faces (giving each grass like this 8 quads total) would be kinda costly with the wind shader? what can i do about this?

#

I can't really have it rotate toward the player because plants like the one on the right needs to be static

#

Also just having it be unlit would make it look glowing in shadows

amber saffron
storm cloud
amber saffron
storm cloud
#

oh, i might

regal stag
#

Would look like this in newer SG versions, in case that helps

amber saffron
#

I don't think you have to set the fragment normal to world space, tangent should still work

#

If you also set the "normal vector" to tangent of course

#
  • keeping tangent makes it easier to work with imho
storm cloud
#

I'm using unity 2021.3 so I'm on a bit older version, my fragment doesn't have as many nodes

regal stag
amber saffron
#

But yes

regal stag
#

Yeah I meant negate, not one minus

storm cloud
#

Found that i can add blocks to the fragment node, but they grey out what i connect to them

regal stag
#

It looks like you're using an Unlit graph

#

Should be able to switch to Lit in graph settings

storm cloud
#

oh wow, oops

regal stag
#

I guess it is easier to swap out later if you want to add one though

amber saffron
placid timber
#

Hey, I was wondering if someone could help me. I've created this shader. It's suppose to put the gravel texture on the bottom of the Object. But right now it's set on goble coordinates, so it doesn't proplery work on on other objects which don't share the same height level as this one. But if I change the Position node to object space there is only one texture shown

#

I'm new to this would be great if some could help

glacial chasm
#

Anybody familiar with the Unity Shaders Bible? I've been working through it and have a question about a specific section about rotating the UVs. Not sure if it would be acceptable to post like 3 or 4 pages from the book, so if someone else has it and can look up the page numbers I've got questions on that would be helpful!

tight phoenix
#

For example, does any of those parameters mean 'render all of the faces, no culling anything' ?

frozen sapphire
#

Hello
Im trying to figure out how to write shaders for the new FullScreenPass Render Feature in 2022LTS. With the old way of writing a custom render feature we could use any old unlit material and it would just work. So something like:

Shader "Unlit/Test"
{
    Properties {
        _BaseColor ("Example Colour", Color) = (0, 0.66, 0.73, 1)
    }
    
    SubShader {
        Tags {
            "RenderPipeline"="UniversalPipeline"
        }
        
        HLSLINCLUDE
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
        ENDHLSL
        
        Pass{
            Name "ColorInversion"
            
            HLSLPROGRAM
            #pragma vertex ColorTestVert
            #pragma fragment ColorTestFrag

            struct Attributes
            {
                float4 positionOS   : POSITION;
                float2 uv           : TEXCOORD0;
                float4 color        : COLOR;
            };
            struct Varyings
            {
                float4 positionCS   : SV_POSITION;
                float2 uv           : TEXCOORD0;
                float4 color        : COLOR;
            };

            float4 _BaseColor;
            
            Varyings ColorTestVert(Attributes IN)
            {
                Varyings OUT;

                VertexPositionInputs positionInputs = GetVertexPositionInputs(IN.positionOS.xyz);
                OUT.positionCS = positionInputs.positionCS;
                OUT.uv = IN.uv;
                OUT.color = IN.color;
                return OUT;
            }

            half4 ColorTestFrag(Varyings IN): SV_Target 
            {
                return _BaseColor;
            }
            ENDHLSL
        }
    }
}

Gives the expected output of a cyan screen when tested with Cyanilux's blit render feature. But if i use the same material with the new FullScreenRenderPass it wont do anything.

#

I know that the shader is running because the frame debugger shows the that it was used

dim yoke
frozen sapphire
#

so i added that as a property to see if that had any effect

Shader "Unlit/Test"
{
    Properties {
        _BaseColor ("Example Colour", Color) = (0, 0.66, 0.73, 1)
        _BlitTexture("BlitTexture",2D) = "white"{}
    }
    
    SubShader {
        Tags {
            "RenderPipeline"="UniversalPipeline"
        }
        
        HLSLINCLUDE
        #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
        ENDHLSL
        
        Pass{
            Name "ColorInversion"
            
            HLSLPROGRAM
            #pragma vertex ColorTestVert
            #pragma fragment ColorTestFrag

            struct Attributes
            {
                float4 positionOS   : POSITION;
                float2 uv           : TEXCOORD0;
                float4 color        : COLOR;
            };
            struct Varyings
            {
                float4 positionCS   : SV_POSITION;
                float2 uv           : TEXCOORD0;
                float4 color        : COLOR;
            };

            TEXTURE2D(_BlitTexture);
            SAMPLER(sampler_BlitTexture);
            
            float4 _BaseColor;
            
            Varyings ColorTestVert(Attributes IN)
            {
                Varyings OUT;

                VertexPositionInputs positionInputs = GetVertexPositionInputs(IN.positionOS.xyz);
                OUT.positionCS = positionInputs.positionCS;
                OUT.uv = IN.uv;
                OUT.color = IN.color;
                return OUT;
            }

            half4 ColorTestFrag(Varyings IN): SV_Target 
            {
                return _BaseColor;
            }
            ENDHLSL
        }
    }
}

it didnt, the texture never even got set according to the frame debugger

#

any guidance would be appreciated

regal stag
# frozen sapphire Hello Im trying to figure out how to write shaders for the new FullScreenPass Re...

The easiest way is to use the new Fullscreen Graph as that feature is written with that in mind.
But if you do want to use shader code, the vertex shader can't use the regular object->clip conversion with the Fullscreen Feature. You should include Blit.hlsl (#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"), and use the vertex/fragment programs there or copy & edit them.
https://github.com/Unity-Technologies/Graphics/blob/master/Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl

frozen sapphire
#

hmm tho im still confused as to why that would affect the texture being used or not?

regal stag
frozen sapphire
regal stag
#

The Fullscreen feature is still showing in the frame debugger isn't it?

#

If you aren't using the texture in the fragment shader it's probably being removed by the compiler though

frozen sapphire
#

oh i see yea thats what i was curious about. Thats why it isnt showing the texture in the debugger

#

thankyou that clears things up!

robust lynx
#

lit/universalpipeline doesnt work and whenever I adjust the slider it goes transparent and I cant see it
I used pp double sided and it works fine, but I want to use lit for the lighting because it looks better

#

AHHHHH found it

#

its fine ignore it

tight phoenix
#

I am working on a transparent plastic shader and hitting some early snags I'm not sure how to resolve 🤔 All the blending modes and alpha I've tried using have the same problem - the more front/back faces the mesh has, the more opaque it becomes which is directly opposite how it works in real life where material's thickness is what builds up opacity, and not the number of faces passed through

Can new Blending Modes be written and added to shadergraph, beyond Multiply, Additive, Premultiplied Alpha, Alpha?

#

I am using a lego brick as my reference material since it's the only example of the kind of transparent material look I am shooting for that I have easy to find practical examples to compare against

vocal narwhal
tight phoenix
pale python
#

hey,
i keep getting this error that is pointing to a commented line

Shader error in 'Test/TestShader1': Unterminated conditional expression. at line 378

Compiling Subshader: 0, Pass: <Unnamed Pass 0>, Vertex program with <no keywords>
#

line 378 is a comment and when I remove it it just pick another line ( sometimes commented and others are not ) and just throws errors that doesnt make sense, what is that ?

leaden mason
#

Hello,
I am looking for some tutorials about writing shaders in Unity but not with ShaderGraph. I have experience with Godot shaders, and I managed to translate most of my shaders to Shader Graph but the node system makes everything very messy and hard to follow. Especially with more complicated shaders.
Can anybody point me to some good resources for learning shaders for URP in unity in the traditional way?

regal stag
regal stag
fervent blade
#

Is the Rider Unity extension might to provide auto-complete, tab completion etc. for shaders? Mine recognises when I have typed out a reserved keyword, but that's about the extent of any IDE features I get when writing them out

lunar valley
fervent blade
#

Hmm, I guess a good'ol uninstall reinstall is in order

mental rampart
#

How can i make such kind of shaders? is there any tutorial for this type of games

rare wren
ancient prawn
#

idk if i put this here or somewhere else

#

rn im just turning on or off the emitter based on if the drift key is being held down

solid bison
#

(there is also some kind of line detection on the sides etc but I'd say that's separate)

#

this example mainly looks like some untextured meshes with a standard PBR shader with some smoothness and baked lighting (including GI and reflection probes)

eager plover
#

helloo I need a little URP shadergraph help
I have a shadergraph that applies a texture to an Image, and I need the texture to display independent of the Image's scale. Do I need to scale the SampleTexture2d somehow?
see here the same material/shader applied to different images of different scale. I want the texture to appear the same scale behind both of them

rare wren
eager plover
#

I tried setting the tile based on the scale from the object but that didn't work so not sure if I did it wrong

rare wren
#

You gotta share the graph if you need help with that

eager plover
#

In the image I don't have anything connected to the tile node

#

Because I couldn't get that to work

grand jolt
#

could someone help understand why the left-hand texture looks brighter than the right-hand one?

the latter is an actual Texture2D put together using a Photo-Editing software, while the other is supposed to be an identical copy of it...

the process of making a clone is done via a C# script -> https://paste.ofcode.org/GyHybyDrkjEREFHEVqzwbf
that sets the originating values to a User-Defined shader -> https://paste.ofcode.org/HR3KmbPub5GsczVUWrd6Yh (it's an Unlit shader),
where there's a predefined amount of range properties (48 one), each 3 representing the RGB channels of a given color, all channels range from 0 to 255.

byte values conversion is done by dividing range by 255F aka:

// NOTE: `uint` instead of `byte` since there's no such data type in ShaderLab.
float ByteToFloat(uint value) => value / 255.0;```
is the above function the reason why the end result isn't quite as accurate?
and if so, what else am I recommended to do?

otherwise, could you hint me where am I making the mistake?
amber saffron
rare wren
#

Or hook up scale somewhere with the tiling and offsets

grand jolt
#

sex!

amber saffron
# eager plover

You could also use the screen coordinates as UV input for the hash texture

amber saffron
#

@ocean orbit To put it short, retrieving an arbitraty value of a pixel from a shader is not an easy task. Why do you want to do that specifically ? What is the intend ?

ocean orbit
#

In fact it's useless, I built a complex shader to generate a map more easily but now I need the result in a c# script. But as realize I won't need this shader as a shader I have to convert it to C# it will be better...

amber saffron
#

Storing height/biome/color .... whatever values you want in the 4 available color channels

ocean orbit
#

Yes I'm not sure which is faster...

#

Can I tell a camera to render only one object ?

amber saffron
#

Or command buffers, but that's a bit more advanced

ocean orbit
#

It's culling mask ?

amber saffron
#

Yes

ocean orbit
#

Thanks I'll try

thorn obsidian
#

Hello, I am trying to make a procedural skybox using shadergraph but I keep getting seams in the skybox like these:

#

I have looked online and although their are solutions to smilair problems none of the results create a seamless skybox

amber saffron
#

Can you share a screen of your graph ?

thorn obsidian
#

right now its only a gradient noise attached to an unlit shader base color

#

just so i could screenshot to show

#

here is an example solution I found but even it doesnt solve the problem

amber saffron
#

The gradient noise is using a 2D coordinate input, and output a 2D noise, for nice 3D noise you would need a 3D verison of it, with 3D coordinates input (view direction i.e.)
Or use some form a triplanar mapping.

As for the small white seam in the middle of your image, I think it is cause by the UV inversion resulting in undefined noise value ? Or maybe the noise is not so great and is just white at the edge, try to offset a bit the UV value.

tropic badger
#

- I need to make options for shaders, which is usually done with toggles, #ifdef and pragma. Can this be applied to enum field as well? I.e. can i check for specific entry of an enum field with ifdef, or should i work this around with N toggles and custom inspector to hide them behind the enum field?

thorn obsidian
#

Here's some more pictures

#

I'm having trouble in general understanding how uv mapping works mathematically in shadergraph

#

but its resulting in things warping in ways I dont think they should be

amber saffron
compact drift
#

Hello, I am trying to get a Vignette effect but for some reason, the shader doesn't take the colour I assign. Here is the script: https://hastebin.com/share/sedojabeku.cpp

This is what happens when I give it red. I want the white part to be red too

compact drift
vocal narwhal
#

vignette = saturate(vignette)

compact drift
vocal narwhal
#

Yes. Nothing changed? You definitely saved? I can't think of what else could cause it. What happens when you use _VignetteColor.rgb instead of the whole lerp, do you get the color you expect?

compact drift
#

Oh that fixed it

#

Thank you!

vocal narwhal
#

It's because most shader functions are unclamped. Saturate is clamp01 for shaders
So what was happening is that on the edge of the alpha where lerp was 1 the color was perfect, but after that it interpolated past and went into white and hdr colors

thorn obsidian
#

How would I go about making a skybox shader with no horizon? I am trying to make a procedural skybox which is all made of stars but am having trouble uv mapping it and texturing it without stretching.

tropic badger
#

- I get this shader error while the indicated line is completely empty. Googling didn't help. What could it be?

#

upd: it turns out parethesis was the cause. Solved

hollow wolf
#

so, i just create compute shader to spawn mesh, but instead of activate it right away i spawn it later using unity timeline, but it always crashing the unity editor, already tried to decrease the spawn to only 100 mesh but it still crash (i use simple sphere from unity as a mesh)

#

anyone know other solution?

tropic badger
amber saffron
#

Also, in builds be sure to have the shader variants with the keywords you need compiled, else it will not work

tropic badger
#

- How can i make sure that i have these?

shell fable
#

The following HLSL code, which works fine in URP's Forward rendering, produces flickering in Forward+.
What do I have to change to correctly read light data in Forward+?

int pixelLightCount = GetAdditionalLightsCount();
for (int i = 0; i < pixelLightCount; ++i)
{
    Light light = GetAdditionalLight(i, WorldPosition, 1);
    // light.color flickers
}
amber saffron
shell fable
#

Thank you, I'll try it out blushie

compact drift
#

It's just a blank white image

tropic badger
amber saffron
#

Else ... Hum doc is definitively fuzzy on this, but I think that adding the collection asset in the resources folder is enough

frosty linden
#

Hello, I'm having an issue with my model where it simply won't show in play mode.

#

But in preview mode, the model loads fine

#

Out of the 15 hair styles I've imported, 2 of them have this problem.

#

I use the same method to import all of them so I can't figure out why 2 of them simply don't work :x

#

When I add it directly in the scene, it seems to work??

#

I've checked the position and scale to make sure I didn't mess up. I also ticked the "Update when Offscreen" jsut in case but still nothing.

#

I've tried replacing the instanced materials by the original ones but still no luck

#

Any ideas what could cause the problem?

frosty linden
#

It's also not a problem with fully transparent color

tropic osprey
#

Slight question because I don't know how this channel/the server feels about it.

Thoughts on reverse engineering a shader?

Ror2 (2019.4) has a shader that it uses to draw damage numbers on the screen using a particle system and a shader, been thinking about trying to reverse engineering that for my game

#

I can give more details on what I know, assuming reverse engineering is ok, lol

#

The shader itself has a texture (where in the case of ror2 it's a sheet of 4x4 distinct symbols (0 1 2 3 4 5 6 7 8 9 KMB!)). And it has a color parameter for tinting, tinting the final results is easy since that would be just multiplying the color with the texture

#

The issue arises at how it would build the numbers, it uses the particle system's custom data module to give it a Vector4 of values, 0, 1, damageAmount, b where damageAmount I'd the final number that gets displayed on the material and b wether or not it should re-multiply with a "critical" color for critical his

#

I am unsure if this would be possible to recreate using shadergraph nodes

regal stag
tropic osprey
#

If damageAmount is for example, 132.45f, the displayed value is just "132". For bigger numbers, if it's larger than a thousand, it uses the first three digits and appends a K, larger than a million, it uses the first three digits and appends an M

tropic osprey
#

The use came with reconstructing or stitching different numbers

#

Mainly because afaik there isn't a way to like, "move" the pixels taken from the flip book node

#

Or resize them

#

Neither something that would allow stitching, with nodes that is

#

Was thinking about doing this as a shader because well, it's extremely performant as it's just on the GPU side, and doesn't Involve objects at all appsrt from a single manager that has the particle system itself

regal stag
tropic osprey
#

Ohh, nice

#

I did see some debug ones for regular hlsl

#

Didn't know there where ones for just shadergraph

tropic osprey
#

Specially if I make it open source and MIT later chad

#

The only issue I'm aware is that this doesn't work with split screen, but that doesn't matter since my game is single player only

regal stag
#

Why wouldn't it work for split screen? 🤔

tropic osprey
#

oh, sorry i mean the "particle system" aproach

#

idk how the server as a whole feels about unity game modding, but as a hobby i like to mod ror2, which is why i know fairly well how it's aproach works, appart from the shader since there is no way i could decompile it or see how it works due to limitations

#

at least in ror2 modding, splitscreen coop mods fail to properly render the damage numbers, i dont know why personally

#

another reason why i wouldnt want to use just textmeshpro is because there is no text mesh billboard shader

#

so to make it feel like one i have to constantly call lookAt the camera object

#

which again, is more strain on the cpu

#

thats bloody massive

#

well it does work

#

thanks for the insight @regal stag

#

i'll see what i can cook up

prime mist
#

Just trying to apply very simple textures... and running into this.. I want it to map over the entire surface, but some object it seems to just go, "nope"... The object is single mesh

regal stag
# prime mist

Should look into "UV unwrapping" in whatever modelling program you used to make the mesh

prime mist
#

Ok, it was Blender and I looked at teh Normals... the texture was applied in Unity

prime mist
#

....anyone?

sterile wave
#

anybody using toonchan? i wanna add some vertex displacement, so i thought of copying some shadercode, so it still fits with the environment

sterile wave
shadow kraken
prime mist
#

Thank Ole.... I'll need to read more into UV mapping I suppose, perhaps you can give me a leg up though? Are we talking the UV Mapping for the object in Blender? As far as I knew, the object is just a mesh in Unity... which is where I was applying the texture

shadow kraken
#

yes, the UV map of a 3D object determines how a texture is applied to it, regardless of the software

#

The UVs are part of the mesh data

hollow cargo
#

Hi,
I'm using a shader for raising mountains, but the meshes are not uniform in shape

From the Y axis, how do I make it so the vertices closer to the borders are less influenced, until the very edge is a Y of 0?

#

side image for clarity. I'd want the edges to be touching the tile beneath.
Alternatively I'd be willing to do the same by just editing the mesh itself (in code), but again, I'm not really sure how to determine how close to an edge the vertex is as it's not a uniform shape and each mesh used for mountains can be a different shape

mental rampart
#

and also like this map and objects

#

I am newbie in unity i want to make this style games

#

Searching for a tutorial to create scene like the image i sent

hollow wolf
#

is there anyway to create tessellation in shadergraph urp?

drowsy coral
#

Hey guys, I'm wondering how I'd shift the color palettes of some basic materials textures using shaders.

#

Ideally it would go from 1 to 2 to 3 interchangeably with some smoothing/interpolation.

#

I'm currently using built in render pipeline, but I'm down to switch to URP to get the job done.

#

I just have no idea where to start: Complete beginner with shaders.

meager pelican
# hollow cargo Hi, I'm using a shader for raising mountains, but the meshes are not uniform in ...

Create a texture the same size as that "island" or whatever it is....the stuff inside that orange outline.
Using a paint/texture editor, create it such that you have a MASK texture that represents the scale values you want...for example white in the mostly-center areas, tapering off to black at the edges. Use blurs, gradients, whatever to create this.
Assuming it is UV mapped to your island, use that texture to scale the offsets (multiply).

#

You might also manually calc it using a distance field, assigning distance from center values to the mesh verts.

hollow cargo
# meager pelican Create a texture the same size as that "island" or whatever it is....the stuff i...

I've seen people saying they're using heightmaps and such on their maps. But, for the level of detail needed for the gradient, would the texture not need to be quite large?
Lets assume the map is 100x100 hexes in a rectangular format, with the top left being UV 0,0 and the bottom right being UV 1,1
How large should I expect the texture to be? maybe ~30 pixels per square, so 3000x3000? is that reasonable?

hollow cargo
#

The heightmap sounds more plausible, I'm just not sure if I should expect it to be ~3000 squared

#

(or if there is a more efficient method)

meager pelican
#

If you're stuffing it into mesh data the last thing you'd want to do is calc that every frame...maybe you could use a compute shader to get it done, and then read the data back, and then stuff in into the mesh in C#, and do that ONCE per change of the mesh. All other frames would just read it.
Or you can do it in C# ONCE and unless it changes, you don't have to calc it again. Don't do it every frame.

hollow cargo
#

Yeah, you're right. I'll probably do it with a heightmap, without the shader for verts. My only issue is going to be that since it's generated terrain, I'll need to figure out how to generate the heightmap texture based on terrain types

#

(with fading gradients, etc)

meager pelican
#

Also, if it is a gradient, it might not be too bad to use a smaller texture and let interpolation handle the in-betweens. As long as you get it mapped to the right shape so that the edge pixels match up.

hollow cargo
#

Yeah, so long as the mountains match up in general. The downside is each tile is it's own mesh, except mountains atm. Since most tiles are only 6 triangles, with mountains scaled up in tris, I may just try combining it all into one mesh once generated anyway

#

Uh, only mentioning this in terms of the edges lining up and normals appearing correct

meager pelican
#

I think some mobile has a limit of 2048 in both the x and y dimensions of the texture. But that's pretty old hardware. See Unity docs in texture importer.

#

Yeah, IDK then. If you re-use meshes across hex tiles.

hollow cargo
#

I'll experiment with a heightmap in any case, it sounds like my best bet

meager pelican
#

If you don't reuse meshes (each is its own unique instance) you can still assign height values to a UV set.

hollow cargo
#

Yeah, each hex is generated in code atm, so they are all unique

#

I appreciate the replies. Heading to bed, but I'll give heightmapping and altering the mesh verts in c# tomorrow

tropic osprey
#

ok so, i've found a guide on GameDeveloper.com that does exactly what i wanted, which would be making a shader that displays text to use on stuff like damage numbers

#

i'm working on translating the shader code itself into shadergraph

#

however, one of the methods theyre' using is UnityObjectToClipPos(), i dont think this helper function is included in shadergraph by default...?

silk wharf
# prime mist

I dont understand your question, but I assume you want to have a different texture for the sides and for the top, if that´s the case, create another material with the texture you want to apply and assign it to the first or second slot of your mesh renderer materials

untold wagon
#

Hey, I got some shaders and such optimized for android, and they look great in unity, but when i put them onto my meta quest, all the quality goes. Is there a setting I can change to keep the quality as normal?

#

Wait, I might've misunderstood something, forget it lol

rare wren
#

Look up how to make plastic / clay materials/shaders maybe if you want something more custom

frosty linden
#

Hello, is it possible to channel pack grayscale albedo, normal map (X & Y then use reconstruct Z node) and alpha into one texture?

#

Reading about it, albedo and trans seem to be in gamma colorspace while normals are in linear, which would prevent them from being packed together?

#

Or since albedo and trans are both grayscale, would it matter if they are also forced to linear ?

#

So I've been teting this around. Left node is my not packed normal map. Middle is the combine node getting the green/blue channels from the packed texture. Right node is the reconstruct Z.

#

From what I see, if Combine has the Z at 1, it gives the same result as the reconstruct node. So does the reconstruct node simply set Z to 1?

#

Second question, the original normal is more blue-ish than the reconstructed one. Why is that?

regal stag
#

You probably don't even need the Normal Reconstruct Z. You'd usually put it through a Normal Unpack node that'll do the remapping and reconstruct for you

regal stag
regal stag
frosty linden
#

Oh, I didn't know there was such a node. Good to knowindeed

#

Is it important for the texture file to be tagged as sRGB or RGB for this node to function properly?

regal stag
#

It can convert both ways

frosty linden
#

But does the sampler give a different result if a texture is tagged as sRGB or RGB ?

#

I'm using a script to pack stuff together and can change the resulting colorspace but I had the impression it didn't affect anything?

regal stag
frosty linden
#

Changing to a normal unpack node does give the intended blue ish but there is some black in the final result strangely.

#

I was using the wrong original normal texture by the way, I updated to the actual normal one. Actually, I only have a bump map and was using Unity bump to normal feature which seems to give a better result thant the software I use to convert bump to normal. Is there a way to save the Unity converted bump to normal once it's done?

regal stag
regal stag
frosty linden
regal stag
frosty linden
#

Got it, thanks

#

Great! That worked! Not 100% the same result obviously but close enough for my need. Thanks again for your help!

slim steppe
#

How could I save multiple values in the stencil?

tropic osprey
#

And also uhh, what would be the best way to replicate the for loop? Was thinking on doing it in a custom function

regal stag
tropic osprey
#

Awesomesauce

#

Thanks for the insight, as always

regal stag
slim steppe
low lichen
#

In a stencil block, you can set the ReadMask and WriteMask to read from and write to only specific bits.

#

But just note that you can't use the increment or decrement operations on bitshifted numbers.

#

Or at least, it won't do what you expect most likely, since it will still try to increment with the ignored bits.

slim steppe
low lichen
# slim steppe Great, thanky you! I dont quite understand how to calculate anything inside the ...

The operations you can do with the stencil buffer are limited to the fixed functions provided to you. You can't modify it with your own shader code (or at least not easily). So it's similar to blending operations or depth operations in that regard. You specify the input variables, like Ref, ReadMask, WriteMask and then you specify what comparison operation to use to compare Ref with the current value in the stencil buffer, then you specify what you want to happen under different conditions. All predefined and limited operations you can do.

slim steppe
#

Oh, so I cant do the increment part myself?

low lichen
#

Fixed functions. You can only specify the rules and some input variables, with those rules being limited to whatever some committee at Khronos/Microsoft picked for their graphics libraries decades ago.

#

But I believe DirectX 12 and maybe Vulkan allows for shader access to read and write to the stencil buffer.

#

But it also comes with performance overhead, since the hardware can no longer predict what the stencil value is going to be ahead of time.

slim steppe
#

Do you know how bad it is?

#

Would there be any other way to achieve something similar that might be better?

low lichen
slim steppe
#

Should I explain the whole problem I'm trying to fix or keep it short(Just say what I'm trying to do)?

low lichen
low lichen
#

Storing multiple numbers in stencil buffer

split oyster
#

uhm, hi, I'm having a problem with compute shaders

#

I've to find a way to parallelize this thing

element[i].x = element[i].x - element[id.x].x
#

I have to execute in this way:
when all x threads are finished to execute increment i (i= i+1)
and then execute them again
for calculate the next element[i].x

blissful marlin
#

I think I'm confused about how depth works in URP. I've got a depth only pass (ZWrite On, Cull Off, ColorMask 0, with a frag output) and my actual shader pass. How can I make sure the actual shaderpass is masked by the frag output of the depth pass?

regal stag
#

Also are you doing anything to render that depth only pass? You might need a RenderObjects feature

blissful marlin
#

I guess explaining the problem more broadly might be helpful
I'm trying to render hair (which is on it's own object) with transparency (not alpha clipping). I've got the aforementioned depth pass, and my main pass, but in the main pass, which has Blend SrcAlpha OneMinusSrcAlpha, ZWrite On, and ZTest LEqual, and Cull Off the hair renders on top of itself when viewed straight on
(I need to render both sides of the plane)

#

there's no issue with the hair rendering relative to what's underneath it, just the fact that it "doubles up" on itself

#

I was experimenting with reading the alpha of the texture during the depth, but no matter what the fragment shader output in the depth, there was no effect (I could return 0 or 1 and nothing would change)

regal stag
frigid jay
#

It is possible that you will require "AllMemoryBarrierWithGroupSync" function instead, depending on your algorithm.

split oyster
#

oh, that's new stuff, I'm gonna take a look to these functions, thanks

tight phoenix
#

I am looking for keywords to help me google search a specific shader effect - URP.

I want to do a sorta 'scrub reveal' shader, as in a position is dragged around which writes to a stencil buffer which is used to then reveal a material. The material I want to reveal is one of Freya's Shapes assets so I can't write a custom material for the reavealed thing itself to take in a texture to use as alpha, so I have to do it in the stencil buffer

What is this effect called? In my mind I think 'some kind of pencil draw shader' but 'Draw' and 'Pencil' have totally different shader connotations, I can't find anything close to what I am trying to do on google

#

like imagine you are physically manually scratching off a scratch and win ticket, that but to the stencil buffer

low lichen
# tight phoenix I am looking for keywords to help me google search a specific shader effect - UR...

The closest thing this reminds me to is this:
https://www.youtube.com/watch?v=LnAoD7hgDxw
Doesn't seem related at first, but I think the gradient mask texture is similar to what you are thinking of. However "gradient mask" doesn't seem to be a keyword people use.

In this Visual Case Study, we use shaders to recreate the various screen transitions seen in Pokemon and other RPGs.

Support me on Patreon:
https://www.patreon.com/DanMoran

Unity Documentation - Platform specific rendering differences:
http://docs.unity3d.com/Manual/SL-PlatformDifferences.html

Get the Assets for this Video here:
http://danjoh...

▶ Play video
tight phoenix
placid timber
#

Hi, I'm new to shader. Can anyone tell if I'm doing something wrong here? The shader won't display the normal map...?

untold wagon
#

Hey, so if my water shader has a fade depth of sorts, would that case performance issues? How about vertex waves? How can I optimize it?

torpid plank
#

Not sure if this is possible but, i have a door frame and would be cool to make walls transparent inside it, can be done with shaders?

tropic osprey
#

aight so my first attempt at recreating the hlsl shader has failed

tropic osprey
#

oh my graph is just straight up wrong

#

lol

tropic osprey
#

ok so i need some sanity checks.

i'm trying to re-create this shader inside shadergraph using URP, i think i've managed to get most of the structure working, however, when i try to use the shader ingame i see absolutely nothing, i'm unsure what's wrong in this shader so i'd like some insight or help on trying to figure out what's going wrong

i'm leaving both the source shader, a texture atlas an the shadergraph here in case someone wants to help. if you want to set this up you can use this guide here #archived-shaders message

#

i'll try to condense the shadergraph on my end so i can take some pictures

#

the first step i thought on replicating was the source shader's v2f vert (appdata v) method, which from what i understand it calculates some UV related changes

#

the second part is a lot more complicated, but it's the source shader's fixed4 frag (v2f v) : SV_Target method. Regarding the two custom functions there, this is the source code for them:

Getsum: https://hastebin.com/share/laxajicuru.ini
ForLoop: https://hastebin.com/share/likeleqaye.python

#

(well "partially", since that flickering number shouldnt happen, no idea what causes it but thats not the issue i want to tackle rn)

tropic osprey
#

If anyone needs more info on the subject lmk and I'll happily oblige

trail kindle
#

Hello, it nice to found international Unity Discord group, I dont know where to post this kinda large project but I wrote multi-platform custom SRP targeting toon stylistic. Hope you like it https://www.artstation.com/artwork/LRr2BP

ArtStation

Realtime Unity renderer created with SRP targeting toon and illustration stylistics. Optimized for consoles and low-end devices. Test scene inspired by artworks of Blue Turtle Design.

split oyster
# frigid jay Algorithm: 1. Calculate increment 2. Call "GroupMemoryBarrierWithGroupSync()"; ...

so... I took a look at these functions, and I want to understand what is the meaning of shared accesses in this context, is it possibly that is referring something like all threads of a group accessing to the same variable?
kinda threads 1,2,3 are accessing the array at index i "array[ i ]" and when they're done accessing it and have reached the call, the program says "stop everything"
am I right?

unreal verge
#

What's a good way to get the world space motion vectors of vertices in a URP shader?
I'm using this for a material that will highlight moving objects that I want to apply globally in a Render Objects Feature.
I don't want to BLUR the objects, I just need to know the object's speed, and not just it's XY speed relative to the camera, but its ABSOLUTE speed.
I've been looking at the depth/motion buffer, but that only gives 2D motion vectors, and what's worse, is it's mixed in with camera motion.

#

It seems that the motion vectors buffer is created with a special render pass using an internal shader: "Shaders/ObjectMotionVectors.shader", which is then written to a specific buffer

#

I was able to find this shader within the packages, and its full name (used to reference it) is: "Hidden/Universal Render Pipeline/ObjectMotionVectors"

#

the Attributes struct (presumably used for verts) uses the TEXCOORD4 semantic to hold the prior position of the vertex but I don't know what populates that

#

like, I dunno if querying TEXCOORD4 on any vertex shader will get you the old XYZ position (noting that it is a float3, and not a float4 like position)

#

this is where I hit a dead end

#

There's this line.... but it says "legacy Unity" which has me doubting

#

I also dug through MotionVectorRenderPass.cs, but I don't see anything that mentions where prior vertex positions are stored (and passed on to the motion vectors shader)

#

I thought there'd be some sort of buffer that stores prior vertex positions

#

damn, I feel like I need to talk to the Unity engineer responsible for motion blur

#

https://forum.unity.com/threads/how-to-access-motion-vector-data-in-shader-without-rendering-motion-vectors-using-camera.1115077/ hmmmm there's this forum post... and apparently texcoord4 gives the previous local coordinates of a vertex for any skinned mesh renderer (and only skinned mesh renderers...)

tacit parcel
#

tl:dr, you need to set camera depth texture mode to motionvector
cam.depthTextureMode = DepthTextureMode.MotionVectors

unreal verge
#

After some simple tests, with https://github.com/Estradel/URP-Simple-Per-Object-Motion-Blur/tree/main I determined that there's a compatibility issue with ECS-instanced entities -- they register intermittent motion even when stationary! So until Unity fixes this, I think it's best if I shelve the feature for now and move on.

GitHub

A simple implementation of a Per-object motion blur effect for Unity URP (v14+) - GitHub - Estradel/URP-Simple-Per-Object-Motion-Blur: A simple implementation of a Per-object motion blur effect for...

meager pelican
# unreal verge Thank you

I SUSPECT (without looking, admittedly, so I shouldn't be typing this at all really) that it's all the "other way around".
That attributes struct contains the variable to hold the calculated result of the previous position to pass to the frag shader via interpolation. Calculated in the vert() function.

So the question isn't "how did Unity populate it" but "How do I calc it to populate that variable"? I think they're using the current position and grabbing the motion vector and calcing the previous position from that. In the vert stage. So setting camera motion vectors to on gives you that motion vector and its associated magnitude. That direction and magnitude gives you the previous position.

As to ECS jitters, I get jitters just thinking about it. 😉 IDK

unreal verge
#

Oh that makes sense. Then they don't have to store previous values. They just have some way of getting the current motion vector of moving objects... which is a bit of a black box to me. I'll have to take one more look at their code for the motion vector pass. If I can create my own custom pass for 3d motion vectors it'll be swell. But there is that ecs eccentricity.

hushed rune
#

I'm using URP

#

And I updated my unity version from 2022.1.14f1 to 2022.3.0f1

#

And now I'm getting this error and the screen is totally purple, but not the UI

frigid jay
karmic delta
#

Any idea why the shader preview is appearing as black? Also the light looks like its softer than it should be... I'm using Shader Graph in Unity 2022.2.1f1 Built-In

#

It's an unlit shader, but also occurs on a lit shader

amber saffron
#

Because in relatime 3D, all meshes are made of triangles, when exporting from blender the mesh get's triangulated and that's what it shows.
To have a similar wireframe as the one you see the easiest choice would be to bake the UV lines in the texture of the mesh.

split tangle
amber saffron
#

There is no such thing

split tangle
amber saffron
#

The page mentions that it removes diagonal edges.
I'm not 100% sure about how they do it, maybe just some filtering (you can still see some triangles), but really, shaders work with triangles and that's all

split tangle
#

mhm... okay thanks!

#

do you think this is what i'm looking for?

amber saffron
#

No sure. At the center of your mesh you have a n-gon that might be tricky

#

Like I said, baking the UV lines in a texture might be enough

split tangle
#

alright, gotcha!

tight phoenix
#

there is a small mistake in this shader that I am having difficulty tracking where its occurring.
Everything works except that its 'default' state is a range of 1 to greater than 1, where as I want its default state to be 0.
Every attempt to compress that default to 0 from 1 hasnt worked

#

Ive tried subtracting 1 at various stages but so far nothing i've done has made the mesh be 0,0,0 instead of 1,1,1 at its default

#

where do I subtract 1 to make the meshes be 0,0,0 at the end? Do I even subtract?

#

hm removing the add seems to do it but that might be just because its a sphere 🤔

#

gotta test other meshes

regal stag
#

Yeah, you're adding ontop of the original vertex positions so makes sense there's an initial size. Though if you want this to scale other meshes you should just Multiply against the Position rather than using the Normal Vectors.

tight phoenix
tropic osprey
regal stag
# karmic delta

It looks "softer" here because the project is using Gamma colour space rather than Linear. Should be able to change it under the Project Settings somewhere (I think under Player).
As for the Main Preview being black, not sure. Try dragging to rotate it, maybe the white side is facing away? Otherwise it's bugged - could try a different Unity version. Otherwise just save and preview in Scene/Game views, that's where it's important anyway.

violet quail
#

There is no point filter? Is it possible to define a custom filter?

grizzled bolt
violet quail
frigid jay
karmic delta
grizzled bolt
amber saffron
grizzled bolt
cosmic prairie
frigid jay
amber saffron
tight phoenix
regal stag
#

ok so i need some sanity checks

amber saffron
#

This would be even more valuable as other meshes with complex normal would react very differently than spheres

tight phoenix
slow spindle
#

Hey guys sorry to inturrupt but im making a tower fesne game and im tringto make a radius effect kinda like in Ballons tower dense when you place a money you can see its range.I was wondering howcould i achive an outline around a towers border in unity?Woud this be considered shaders?so see that irclecollider how could i highlight that or put a outline over it in game so i can see he towers range?this isalso unity 2d btw

unreal verge
#

Looks like you're in a situation that calls for vector graphics which involves procedural geometric modelling. Personally, I would use acegikmo's Shapes asset for that sort of task, especially if I had other hud elements that had to be vectorized but if you only have a few fixed radii then you could get away with sprites that indicate the radius, and not need any fancy geometry creation.

slow spindle
slow spindle
#

mycomputer is slow

grizzled bolt
#

Scalable circles can be made easily with a shader
The Shapes asset is good but totally overkill

slow spindle
#

it should do

#

@unreal verge is the asset free?

unreal verge
#

No it's a paid asset. Kind of expensive and if it's just for circles it would be overkill, as spazi said

slow spindle
#

no

#

im not buying this

#

ima justmake circles

regal stag
grizzled bolt
#

A shader in favor of a simple texture is necessary only if it's important to have a hollow or bordered circle with an absolute width edge

slow spindle
#

i see

#

well i added the circle so its good

tight phoenix
#

the end goal I want is a float value that increases the distance over which the effect lerps from 0 to 1

#

I havent gotten to the other suggestions people had from before yet, I am still trying to get this version working before I completely re-write it

regal stag
tight phoenix
#

I cant describe the way its broken so here is a gif of what I mean by it broke everything

#

oh I was using world postions instead of object positions, thats on me since the vertex normal was in object

tight phoenix
# regal stag Should be before the Saturate i think

the problem occuring is that this does the opposite of what I want

  • I have to saturate it or else the meshes turn inside out
  • I have to one minus it or else the effect is 0 at 000 instead of 1 at 000
  • but I cant multiply it because all that does is make it smaller range instead of larger
regal stag
#

You probably want a Divide instead of a Multiply here

tight phoenix
#

as in a 'distance' of 2 means the range becomes 0.5 to 0

tight phoenix
#

I always avoid using divides where I can since mult by 0 cant break like divide can

#

(not that this value should ever be 0)

#

made it a slider to prevent accidental divide by 0s

regal stag
#

I mean, you can keep using multiply but then you'd need to use values like 0.5 rather than 2. It's probably easier to keep it in terms of units rather than 1/units

tight phoenix
#

Yeah that worked, thanks again Cyan 👍

main fox
regal stag
# main fox Trying to do a basic shader, learning hsls. First image is how a single tile in ...

The Unlit Shader template is an Opaque shader so isn't really designed for sprites, which are typically Transparent and need to use the alpha channel of the texture. Could instead use the Sprites-Default.shader and UnitySprites as a basis - https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/DefaultResourcesExtra/Sprites-Default.shader
https://github.com/TwoTailsGames/Unity-Built-in-Shaders/blob/master/CGIncludes/UnitySprites.cginc

languid kelp
#

Hi, maybe this is a dumb question but even ChatGPT says this should be correct.
I'm trying to make a shader that reveals a gameobject only up to a specific height (usage in a 3d printer scene). I get the following error:
undeclared identifier '_Height'
In my opinion _Height is defined, what am I missing?
Shader "Custom/printerRevealShader"
{
Properties
{
_Height ("Height", Range(0, 1)) = 0.5
}
SubShader
{
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert
struct Input
{
float2 uv_MainTex;
float _Height;
};
void vert(inout appdata_full v)
{
// no changes required
}
void surf(Input IN, inout SurfaceOutput o)
{
o.Albedo = 1;
o.Alpha = 1;
float height = _Height * IN.vertex.y;
o.Position.y += height;
o.Normal = normalize(UnityObjectToWorldNormal(IN.normal));
o.Pos = UnityObjectToClipPos(v.vertex);
}
ENDCG
}
FallBack "Diffuse"
}
What am I doing wrong?

grizzled bolt
#

What am I doing wrong
Using chatgpt, at least

languid kelp
#

It's useful for learning new stuff, it helped me a lot, so I thought it could also help me learning how to make sharders

#

at least for fixing my shitty shader

dim yoke
#

Chatgpt can teach you some fundamentals but it will not fix your shitty shader, atleast the version 3.5 is not capable of doing so

unreal verge
#

And sometimes ChatGPT will make up solutions that contain things that don't even exist!
For the most part, I use it as a sort of search engine. The variant I use is called Phind, because it includes sources, and I often wind up following up on those sources.

latent rampart
#

Hey all, I'm trying to setup up my sprite with lighting. I went and created a normal map for my sprite, and I installed the universal pipeline, set it in project settings, created a material with the nromal map using the sprite-lit-default sahder. I then applied that to my sprite and.. well nothing. Oh I also created a light.

unreal verge
#

But ChatGPT 3.5 absolutely cannot be trusted to create a whole working shader from scratch because it jigsaws code together that could be for URP, HDRP and even BIRP, and doesn't take into account whether that shader needs to work for Single-Pass Instancing / XR, or whether that shader is a full-screen image effect or meant to be applied to a mesh.

latent rampart
#

lol speaking of, I tried to have GPT 4 create an outline shader... it didn't work very well

unreal verge
latent rampart
#

The sprite didn't change at all

#

no weird artifacting or anything

#

tried restarting since I just installed URP, that didn't help

latent rampart
#

oh normal lights odn't work

unreal verge
#

yeah... I remember something about 2D lights

#

I've never used them myself, but this came to mind

#

hope it works for you

latent rampart
#

they must be part of a package I don't have

#

it kind of indicates it's part of URP though

unreal verge
#

OH btw I linked an OLD version of the manual (link updated)

latent rampart
#

ahh, so I can add the light 2d component

#

but it throws a warning I don't have something set

#

that must be why

unreal verge
#

yeah your render pipeline asset needs some setup stuff as well. The manual page talks about some prep steps.

latent rampart
#

Yeah it's not selectable so I must be missing something there

#

got it, it was the setup stuff I needed, thanks 😉

#

not really viable for what I'm doing, but I wanted to see how it looked. I created a normal map from a height map.... that I made by hand.

meager pelican
unreal verge
#

I SUSPECT without looking admittedly so

tame coral
#

I've got a shader that is mostly working but I can't seem to get normal maps to work

#

I've verified the texture is being read correctly by applying it to the albedo, and ive double checked that it's setup with the correct texture type

#

I've also tried using UniversalFragmentBlinnPhong, both don't appear to be influenced by the normalTS surface data property at all. Am I missing something?

#

ugh, looking at the source, it appears i misread it and it expects the normal in the lighting info and not the surface data, guess the surface data normal is just not used :S

tame coral
#

Woo, its working, though i still gotta fix the smoothness of the mesh itself

magic gyro
#

how to make category like this

#

like whats the shortcut for it

regal stag
magic gyro
#

yeah

#

i know that

#

but is there a shortcut to move them into a category

regal stag
#

Should be able to drag them. There's no shortcut that I'm aware of

neat orchid
#

Anyone got a suggestion on how to make a magic cloud type of effect? Something with a little bit of movement, a little bit of twirling

restive lava
#

hello everyone, i'm wondering if it is even possible to create realistic blood splatter decals (the ones on the ground and walls) only using shader graph? if yes, then how, because as i've been experimenting with various noises, it still doesn't look quite realistic enough.

restive lava
#

so the answer is no?

low lichen
cosmic prairie
#

also, if you want further advice, post a pic of what you have, one of what you want, and another one for the background you are planning to use it against

#

otherwise there's so many looks blood can take on, could be dried, slimy, wet, smeared, droopy etc, there isn't just one "realistic" look

#

also, which rendering pipeline

restive lava
#

new version built-in, which as far as i'm aware supports both shaderlab and shader graph, since using PCSS shadows made for unity 2019 built-in version causes no problems, and so does my custom shader graphs

restive lava
#

yeah, i think i should just stick to textures, or perhaps it's possible to mix a bit of textures and the noise 😄

cosmic prairie
#

so maybe 1 low freq noise - 1 slightly higher freq noise, - 1 distance from the center * distance falloff ,

#

you also need to have a normal map for it, theres a height to normal node. I'd suggest using a gradient to control the height, as it's easier to replicate surface tension at the edges with that

#

the shinyness and environtment reflection is completely missing, grab a free skybox and bake the lighting for the scene along with a reflection probe

#

then add to the specular and metallic values with some random noise aswell

#

this doesn't have to be as accurate as the shape of the blood

#

the color is also way off, the blood on the bottom is waaay darker in the middle

restive lava
#

thanks, but since i'm a beginner i'll need some things cleared up: i really don't understand how to do that falloff that you mentioned, i found the height to normal node, so what do i put in the "in" node?

cosmic prairie
#

height is just a float value you calculate

#

so, grab 2 noises and subtract one from the other

#

ideally the one you subtract is higher in frequency

#

after that, grab the distance you have calculated for the circular falloff, and add it to the combined noise we just calculated

cosmic prairie
restive lava
cosmic prairie
#

oh then add instead of subtract I guess

#

just make sure your shape fits in the decal