#archived-shaders

1 messages Β· Page 76 of 1

regal stag
#

Arrays must have size hardcoded on both sides yeah. If you try to set it smaller on C# side the array may be defined smaller but then can't change, so would need to pad with zeros.

muted depot
#

I do currently pad with 0 and hardcode on both sides yeah

#

I was just wondering if there's a way to read it from shader side

#

so I don't have to manually synchronize it if I ever want to change that value

ruby sonnet
#

when i try to define UnityPerDraw buffer it says that im redefining it, but i cant access it

muted depot
#

there is some weirdness with URP includes where it complains about redefines, it complains about _Time redefine for me even if I just take their code examples, so I'm not sure, I haven't tried to access UnityPerDraw

regal stag
ruby sonnet
regal stag
#

What do you mean by access it, what are you trying to do?

ruby sonnet
#

im trying to get a value with a name "unity_ObjectToWorld"

#

and also the value should be a matrix

regal stag
#

URP usually uses UNITY_MATRIX_M macro instead I think but either should work assuming you've included URP's Core.hlsl too.

ruby sonnet
#

where is the UNITYCG.cginc located?

regal stag
#

UnityCG.cginc is for the Built-in RP, not URP

ruby sonnet
#

oh

muted depot
regal stag
muted depot
#

I do

#

even literally taking example given by unity I get error about redefining _Time

#

the only way I've been able to fix that is by adding include guards around includes, but it seems to be error is in the headers themselves, they should guard against redefining? it seems to me when compiling unity automatically includes some of the headers but if I don't add includes it complains about missing stuff, it's weird

#

unity 2023.2 / urp 16.0.6 I think

ruby sonnet
#

i have problems because after defining Core.hlsl instead of UNITYCG, it doesnt regonize the return keyword???

muted depot
#

what do you mean?

ruby sonnet
#

k fixed it

regal stag
muted depot
#

this happened whenever I tried to include any of the urp hlsl headers

#

and the error was in unity console, not in IDE

regal stag
#

Mmm yeah. Probably an issue with includes then. Though all ShaderLibrary files should already have guards like that so shouldn't be an issue if they are defined multiple times.

#

I think the only case where I've seen redefinitions is if you're trying to use a mix of BiRP and URP includes.

#

It's a little different for ShaderGraph as it has it's own version of the ShaderLibrary too, so you usually need to surround pipeline-specific stuff with #ifdef SHADERGRAPH_PREVIEW to avoid redefinitions there.
The guards around the file itself is also to prevent functions being redefined if you use the same include file in multiple Custom Function nodes.

ruby sonnet
#

how to get vertex color in URP ShaderLab?

muted depot
#

I think you should be able to add float4 color : COLOR; to vertex shader input and pass it to fragment shader? but I'll see if it works in urp

#

yeah, it worked

#
struct Attributes
{
    float4 positionOS   : POSITION;
    float4 color        : COLOR;
    float2 uv           : TEXCOORD0;
};
struct Varyings
{
    float4 positionHCS  : SV_POSITION;
    float4 color        : COLOR;
    float2 uv           : TEXCOORD0;
};
Varyings VertShader(Attributes IN)
{
    Varyings OUT;
    OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
    OUT.color = IN.color;
    OUT.uv = TRANSFORM_TEX(IN.uv, _MainTex);
    return OUT;
}
half4 FragShader(Varyings IN) : SV_Target
{
    return IN.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv);
}

an example

chilly robin
#

Would it be feasible to use vertex color as an opacity mask as opposed to a texture? Thought I'd ask before I dived into it

limber merlin
#

How can i prevent these weird visuals on the bridge? i think it has to do with mipmaps or something related to textures.

grand jolt
#

I mess around with toon shader by unity technologies i made a script to toggle transparency on and off and change transparency level.. but in play mode those 2 work only when material properties are expanded in inspector and not folded and when i click play it is automatically folded.. but idk why this issue causes bugs

kind juniper
hollow loom
tacit parcel
#

Or you can try activating pixel perfect option in the camera, but I doubt it will help much

chilly robin
#

Is there any method for improving the dither node when used as an alpha threshold?

#

In particular, there is a lot of banding

toxic flume
#

I have used a srp compatible shader. In frame debugger, it shows just 15 but in stats in profiler, batch count is high.
My characters are 2d spine skeleton and I use a srp compatible shader for them.
If I don't use srp compatible shader and instead, apply standard spine shader, in frame debugger, I see high frame count

muted depot
#

is there any documentation on URP shader macros and functions?

#

other than just reading through hlsl includes

kind juniper
dim yoke
# kind juniper Not sure about the profiler, but stats window is very unreliable in terms of bat...

Afaik the stats window does actually show the amount of draw calls but it just doesn't really matter because SRP batcher isn't meant to reduce the draw call count but rather make them super cheap. The Frame Debugger on the other hand should show the SRP batch count which is different (much smaller) from the amount of draw calls. The SRP batch count is pretty much the amount of different shader variants used so it is more or less useless anyways

royal pier
#

Hey, I hope someone can help me out with this. I use URP and I have holes which need to be cut out of a mesh. I am using URP to do this. It seems to work perfectly, but when I look at it from below, from the outside it's also gone and it just looks odd. Is it possible to make this work purely on one face?

#

Was hoping for this to be possible with a shader. Maybe a stencil buffer. Not really familiar with shaders.

ruby sonnet
#

how to get Vertex Color in ShaderLab (URP)?

dim yoke
muted depot
#

yes, : COLOR works

ruby sonnet
broken sinew
#

ugh, anyone has any idea how to make prefabs with custom shaders render proper previews?

sour gale
broken sinew
#

yeah, I wrote a raymarching shader that requires a bunch of uniforms, so in an attempt to satisfy the prefab preview I set default values to proprties in shaderlab's proeprty block and to required uniforms in the hlsl

#

for example the prefab looks like this

#

(everything is raymarched here)

#

but prefab preview shows nothing (empty as in "empty object")

#

the material that I added as a sub-asset to the prefab also has no preview

#

although the properties with their values are displayed normally in the material inspector

#

and the shader looks mostly like this:

Shader "New SDF scene (generated)" {
  Properties {
    ...        
    [Header (root)]
    _1_root_BlendFactor ("Blend factor", Float) = 0.3
    
    [Header (root_combine)]
    _1_0_root_combine_BlendFactor ("Blend factor", Float) = 1.0
    
    [Header (root_combine_sphere)]
    _1_0_0_root_combine_sphere_Radius ("Sphere radius", Float) = 0.084241
    
    [Header (root_GameObject_minus_box)]
    _1_2_1_1_root_GameObject_minus_box_BoxExtents ("Box extents", Vector) = (1.888734, 0.751022, 0.5, 0.0)
    // ... and others
  }
  SubShader {
    Tags {
      "RenderType" = "Opaque"
      "Queue" = "Geometry+1"
      "IgnoreProjector" = "True"
      "LightMode" = "ForwardBase"
    }
    ZTest [_ZTest]
    Cull [_Cull]
    ZWrite [_ZWrite]
    Pass {
      HLSLPROGRAM
      #pragma target 5.0 
      #include "UnityCG.cginc" 
      #include "Packages/me.tooster.sdf/Editor/Resources/Includes/raymarching.hlsl" 
      #include "Packages/me.tooster.sdf/Editor/Resources/Includes/util.hlsl" 
      #include "Packages/me.tooster.sdf/Editor/Resources/Includes/operators.hlsl" 
      #include "Packages/me.tooster.sdf/Editor/Resources/Includes/matrix.hlsl" 
      #include "Packages/me.tooster.sdf/Editor/Resources/Includes/primitives.hlsl" 
      #pragma vertex vertexShader 
      #pragma fragment fragmentShader 
      
      float _1_root_BlendFactor;
      float4x4 _1_root_SpaceTransform = { { 1.0, 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0, 1.5 }, { 0.0, 0.0, 1.0, 0.0 }, { 0.0, 0.0, 0.0, 1.0 } };
      float _1_0_root_combine_BlendFactor;
      // ... includes, vertex, fragment shader
      ENDHLSL
    }
  }
}
open quarry
#

hi, does anyone know the best way to do something similar to urp "render objects" or hdrp custom pass, but in BIRP?

lean lotus
#

so with compute shaders, supporting multicompile, why when I put the #pragma multicompile in a cginc file, and then in the origional computeshader file, use #include_with_pragmas cgincfile, it stops any #includes put lower from working?

#

aka
globaldefines has the #pragma multi_compile DX11
when I do it this way, suddenly functions found in "Materials.cginc" are missing
if I put the #pragma multicompile inside this shader itself instead of the cginc file, its fine though

#

interestingly, functions found in "commondata" are not producing errors

kind juniper
lean lotus
#

when unity compiles

copper shoal
#

im implementing a dithering/pixel shader with URP and i got a nice shader graph setup however when I try to implement it I just get a purple screen and I dont know why

unreal stream
#

I have an HDRP shader question with a lot of weird restrictions. I'm making a mod, in this mod I am spawning a cube with CreatePrimitive, and setting its material dynamically via script. Because it is a mod, I don't have access to making my own assets, I only have the ability to modify things from script, thus why I am making a material through script.

My end goal is to have the cube only display when it is behind other things. When looking at it directly (when it is in front of other things) it should be invisible. Currently I'm using this code:

        Material m = new Material(Shader.Find("HDRP/Unlit"));
        m.SetColor("_UnlitColor", Color.yellow);
        m.SetInt("_ZTest", (int)UnityEngine.Rendering.CompareFunction.Less);
        m.SetInt("_ZWrite", 0);
        m.renderQueue = 0;

So the cube is unlit, and yellow...but I've been changing those last three values with all kinds of combinations, and it never fails, either the cube is simply invisible, or the cube is "normal" (ie: visible when in front of things, not visible when behind things).

I've tried render queues from 0 to 5000, I've tried ZTest less and greater. I know this is probably possible but maybe the Unlit shader does not support those keywords? I don't know. Can anyone help me out?

unreal stream
#

I found my problem, for whatever reason _ZWrite was changed to _ZTestDepthEqualForOpaque in this shader. 😐

toxic flume
tacit parcel
# royal pier Was hoping for this to be possible with a shader. Maybe a stencil buffer. Not re...

Hey game dev enjoyers!

Here we are: the mighty tutorial about the stencil buffer that I’ve been working on for weeks now. I hope you’ll enjoy it ;)

WARNING: Please make sure to follow the instructions of the β€œIMPORTANT” chapter (it's only 30 seconds long no worries), otherwise you would not be able to use the stencil buffer.

The shader and ...

β–Ά Play video
#

But I think the better approach would be using boolean operation at realtime, I think I've seen some implementation somewhere on internet

royal pier
kind juniper
weary veldt
#

Is Anyone around who knows their way with Shaders? I think i am doing a big mistake and i am stuck but cant pinpoint what i am doing wrong.

I got my system setup to write an objects Mesh onto a GlowBuffer in a single Color. I want to use this to build an Effect around the Mesh. To get the Area "around" the mesh, i wanted to offset the input of the Glow Buffer. To get all angles, i offset it 5 times and added the Result together. Looking like the Screenshot. I have the Feeling, there is an easier way. Especially considering i dont want my Colors to overlap and be just a simple flat Orange (the color on the GlowBuffer Texture) and i need to subtract the original object (the non offset version) aswell.

dim yoke
# weary veldt Is Anyone around who knows their way with Shaders? I think i am doing a big mist...

The problem with your approach is that there's no blurring going and and the layers also accumulate together in unexpected ways ending up not looking that good. Is there some specific reason why you are not using the Bloom post processing effect to achieve glow around the object? If that doesn't work for you, I'd assume the best way to achieve that would be to do something similar yourself by rendering the object(/s) into the GlowBuffer as they are and do post processing on the buffer similarly to how Bloom works so you get the appropriate amount of blurring and intensity.

bronze cove
#

I'm using a custom shader to tile a texutre onto a line renderer, the only problem is that end caps have different UV's so it looks like this. Any way to fix this?

dim yoke
bronze cove
#

Looks like this when there are no end caps

dim yoke
bronze cove
#

Ugh I'm kinda bad with shaders, any directions on how would I do it?

#

The shader im using right now is made in the shader graph (urp pipeline)

dim yoke
bronze cove
dim yoke
# bronze cove That would be really great! πŸ˜„

I'll do the wrong thing here now and just paste my .shadergraph file here for you to use because I'm not sure I would be able to explain it anymore (it's some time since I made it). There's still apparently some issues with the shader if you need to look at the end caps from close and from angle ⬇️ . Basically how the shader works is to scale the uvs correctly to get the sphere shape by using the partial derivatives and then get one distance field for the line to get nice anti aliasing effect (which apparently doens't work perfectly)

tribal karma
#

Hi, I made a black and white mask for the emission input and i want to have a base color as well. My problem is, that the emission mask completely eradicates the base color and i dont know why. I thought emission would just show up on the non black parts. Thanks πŸ˜„

regal stag
tribal karma
dim yoke
#

@bronze cove this is the distance field I talked about (output of this ⏬ node)

tribal karma
bronze cove
weary veldt
dim yoke
bronze cove
clear skiff
#

Hi, I'm very new to shader graphs and shaders in general. If I make an outline shader that applies to all npcs, would I have to manually add a material with the shader to each npc or is there a more automatic way of doing so?
And what if I wanted to make a toon shader that applies to everything? Would I also have to manually add this shader to each object or is there a way to tell the camera to apply to everything or something like that?

regal stag
# clear skiff Hi, I'm very new to shader graphs and shaders in general. If I make an outline s...

If you use URP, a more automatic way of applying the outline materials may be to use the RenderObjects renderer feature (added to Universal Renderer asset). That can re-render objects on a specific layer with an override material.

As for applying a toon shader, in Forward rendering paths you'd indeed apply this manually to each Material used.
It is technically possible to apply a toon shading to a whole scene using a Deferred rendering path (if the target platform can support it), but that requires a very different shader setup and not beginner friendly.

clear skiff
# regal stag If you use URP, a more automatic way of applying the outline materials may be to...

thanks!
one more question, if I wanted for example to make a shader that changes the colors or add textures to an object, how do I apply this over the toon shading (which, after following a tutorial, requires me to supply a texture/color to it) considering that I only want it to apply on certain objects and not absolutely everything that uses my toon shader (and also considering that I might make a lot of effects)?

kind juniper
ebon moss
#

hey im trying to create a shader that filters out everything from an inputted texture except the purple. My approachj of subtracting and using compaisons is not working. Is there another way?

#

ive also tried dotproducting

weary veldt
#

Can anyone tell me why my Normals look so wrong on Round Surfaces?
Using a fullscreen shader that takes the Normal Vector of the World, multiplies it by 0.5f and then adds 0.5f, shouldnt my sphere look smooth ?

harsh spindle
#

can you have a .shader file in URP?

weary veldt
harsh spindle
#

wait

#

my mesh is just white

weary veldt
#

pink is the color of errors in the shader world

harsh spindle
#

its white tho ☠️

#

its supsed to be like red and blue

weary veldt
harsh spindle
#

alr so its pink 😭

weary veldt
harsh spindle
#

ok it should output black im p sure

#

butits giving pink

tacit parcel
harsh spindle
# harsh spindle

well ig i shoudl clarify can you have standard surface shaders in urp

weary veldt
weary veldt
weary veldt
harsh spindle
#

u can like basically do anything in shader graphs

#

that u can do in like hlsl right

weary veldt
harsh spindle
harsh spindle
#

i found a good tutorial

weary veldt
harsh spindle
weary veldt
# harsh spindle got it to work 😈

nice, congrats πŸ™‚ im sadly still struggeling πŸ˜„
I try to write the result of a Shader onto an extra GlobalTexture .. .but i dont get it to work with DrawingSettings

#

I know how to write single renderes onto a specific texture. But how do i write every renderer on a layer onto one? That confuses the hell out of me

mild loom
#

hey can anyone point me in the right direction as to how this style was achieved

#

to me it looks like color quantization with some sort of color palette and some dithering

#

but im not sure

winter arch
#

Is there anyway to turn entire sprite into one solid color with shader graph?

weary veldt
#

yeah, iterate over the sprite. If R+G+B > 0, draw your given Color.

winter arch
#

can I just take the ceiling in the shader graph?

mild loom
#

got my work cut out for me forsure

weary veldt
weary veldt
mild loom
#

not really

#

its close though

#

ill keep experimenting with it

mild loom
#

im guessing its not grayscale...

weary veldt
#

there are probably more post processing effects at work

#

its hard to pinpoint ... usually, i would recommend: find the dev on twitter and ask them πŸ˜„

winter arch
#

i dont know what I did but this worked for some reason

#

what does predicate really do?

kind juniper
dim yoke
kind juniper
#

Could be !=0. Depends on the platform I guess. Some would consider even negative numbers as true afaik.

snow forge
#

Mornin' all,

I'm messing about with a 'curved world' shader I found a video for. I'm trying to modify it so the 'curve' starts at a distance in front of the camera, now I've got that part working (currently the curving starts at 20m in front of the camera which is great, but it also curves 'behind' that position (pic attached for context).

I'm trying to figure out how to stop the curving 'behind' that point (so that the tunnel is straight between the curvature start point (20m in front of the camera) and the camera's position (0,0,0)

weary veldt
#

Can anyone help me out?
In Shadergraph, i need a Subgraph with 4 Inputs and 1 Return value that returns 1 if any of the inputs are non Zero, and returns 0 if all are Zero.
This sounds so basic but i am struggeling with it a lot.

snow forge
#

You may need comparison nodes going into your 4 branch nodes?

weary veldt
snow forge
snow forge
# weary veldt i am inputting Vector4s, so i need to combine them down ... somehow i am really ...

So basically you're taking in your Vector4 and splitting it into it's component parts and checking if there's a value greater than 0 in each part, then adding all of those 1's / 0's together, and then checking if the final value is greater than 0, which then goes into the final branch, leaving you with an output value of either 0 or 1, which you can check in your main shader graph using another branch. Again I think

shut radish
#

I'm currently working on a local multiplayer in a TRON like world. To bring the world more to live I want to create create a glitch effect on a text mesh pro text. My idea was to write a pixel displacement shader on top of a text mesh pro shader. Would that be a good idea and how could one go about implementing pixel displacement in a text mesh pro shader? Is that even possible?

fathom skiff
#

Is there any way to modify URP shader to built in shaders? or to use VAT on that RP?

snow forge
weary veldt
weary veldt
snow forge
weary veldt
#

nice, thank you! You helped me a ton!

shut radish
snow forge
#

Like I said, I might be using the Branch/comparison nodes incorrectly, so mileage may vary. lol.

weary veldt
snow forge
weary veldt
# snow forge Cool. Glad you figured it out πŸ™‚

yeah only one more Step for my Outline to be completed πŸ™‚ Then i have build my own, ready to use, Post Processing Shader using the SRP (Which i fell in love with. Such an amazing tool with so many options, and i only explored it for a day!)

snow forge
#

Hehe, nice.

weary veldt
#

just one more line of code that annoys me

                ConfigureTarget(normals.Identifier());

i know ConfigureTarget is obsolete, but i didnt figure out what to use instead so it works the same way

dim yoke
weary veldt
dim yoke
#

Afaik boolean algebra uses floats anyways on shader side so more than likely doing boolean ORs on shader code wouldn't save any performance either

regal stag
weary veldt
#

Can anyone tell me why the output of this Node is Darker when the alpha is lower even tho i completly ignore the alpha in the output?

#

This would solve all my issues πŸ˜„

weary veldt
#

This is my Screen output with alpha at 0.1

#

This is with Alpha 1.0

weary veldt
#

This does not make sense to me ... 😦

#

i think the problem is that the alpha gets multiplied into the color channel at some point ... but i have no clue where 😦 still new to SRP and the texture shown above comes out of a ScriptedRenderPass

regal stag
weary veldt
regal stag
#

Where are you changing the alpha?

weary veldt
#

in the shader that runs in the RenderPass to generate the Texture

regal stag
#

So not in fullscreen one right? If that other shader has a blend mode, e.g. Blend SrcAlpha OneMinusSrcAlpha), that's why the RGB channels of the target may also change. That's how transparency works.

weary veldt
#

i was hoping the 4 channels of the render texture are just 4 Data Streams i could use ... without unity messing with them

weary veldt
#

so i guess ...the blending mode here is the issue ?

regal stag
#

Unsure if that actually outputs the alpha or just uses it for the clip() function though

weary veldt
#

alpha is either 0 or 1, but the idea was pretty good

#

so i am stuck at a technicallity thats not solvable ... did i understand this correct ?

regal stag
#

May need to use shader code instead of a graph here

weary veldt
#

ugh, even tho its a graph with just a few nodes. I have no clue how to write HLSL code ... and exporting the Code out of the Shadergraph is a mess with 1,6k lines

tacit onyx
#

I'm making a mesh via code and want to add colours via code to the faces similar to below. I can see there are vertex colours built in but that puts the colour on the vertices. Is there a way to make just the faces the colour?

weary veldt
tacit onyx
#

would that work with the minimal vertices like above?

low lichen
weary veldt
weary veldt
low lichen
weary veldt
#

so i would assume so, yes.

low lichen
#

*edited to simplify.

#

*actually, the default blend mode is already assigned by the RenderStateBlock constructor.

#

The mask says we want to override the blend state, and since we don't change the blend state, the default state will be used, which happens to be what we want.

weary veldt
weary veldt
low lichen
weary veldt
#

Thank you so very much!

frosty linden
#

Hello, I'm trying to pack a greyscale albedo texture with its normal map and AO. I have the albedo in red, normal x in green, normal y in blue and ao in alpha. I can't get the normal reconstruct z to work properly so far and am looking for help.

#

Here I've made a simple shader to compare the reconstruct node with the default hdrp lit shader

#

But my shader graph normal doesn't work as intended

#

What am I missing ?

#

I've added another node to load the default unpacked normal map and the result is indeed different

#

I'm not sure how to fix that

low lichen
#

That has to be done before Z reconstruction.

weary veldt
#

so this is what a comparison for a Depth Comparison looks like ... i was hoping it would be pure white but somehow Unity does weird things, darn!

frosty linden
#

Still no luck :/ I've added another branch using a Vector2 instead of a combine since this link (https://danielilett.com/2021-05-20-every-shader-graph-node/) shown such example and the result is indeed different from combine but not the same as the real normal map

Daniel Ilett: Games | Shaders | Tutorials

Shader Graph ships with a lot of nodes. Over 200, as of Shader Graph 10.2! With such a vast array of features at your disposal, it’s easy to get lost when you’re searching for the perfect way to make the shader you have in mind. This tutorial shows you every...

#

I'll try to change from 0,1 to -1,1 with some multiply and substract node then

#

That's weird, the result seems to be forced clamped to 0,1?

#

If I try to replace the subtract node back to the the vector2 X, it stays black the whole way :/

#

Shouldn't the operation be a simple multiply by 2 subtract 1 to change from 0,1 to -1,1 ?

low lichen
frosty linden
low lichen
frosty linden
#

I've added a preview on the red and it's indeed black

#

Oh, ok, I'll check

frosty linden
low lichen
#

The colorspace conversion should happen before the Normal Unpack.

frosty linden
#

I've tried both actually, the result is the same :/

#

The main issue is that the unpack makes me lose the red and green channels

#

Why is that ?

#

Also, I can't put the colorspace conversion before unpack cause colorspace conversion OUT is a vector3 but unpack needs vector4 and I end up with a black result if I put it first actually :x

low lichen
#

Well, black preview might also be negative.

low lichen
frosty linden
#

Or did I mess somewhere ?

low lichen
frosty linden
#

it seems to do the same if I set to "Default" and unpack just after

dim yoke
# weary veldt so this is what a comparison for a Depth Comparison looks like ... i was hoping ...

Don't know what's the context here but in general I don't think this is about unity doing anything weird. It's more likely your graphics card doing "something weird". Those weird things are called floating point calculations which can cause inaccuracies in the result and therefore not end up being exactly equal. For example 0.1 * 3 does not equal 0.3 even on your C# code. Often times you would want to compare whether the values are close enough from each other instead of ==

frosty linden
#

So I thought I could skip the unpack step by setting the type to normal directly

weary veldt
dim yoke
low lichen
# frosty linden Still no luck, everything is black now :x

The only change that should be happening to XY after unpack is the remap. I've noticed the color is a dark yellow, which would suggest similar RG, near or below 0.5. That's close to or less than 0 after remapping, which would result in black.

frosty linden
#

I've double checked with my original normal that the layer matched and they do

#

I just moved the red and green from the original normal map to the green and blue of the packed map.

frosty linden
#

If I use the reconstruct node, it seems I don't lose the red and green channel but the result still doesn't match the original while it should

warm pulsar
#

I created a Sub Graph containing the HD Scene Depth node. This is producing a warning

#

Sub Graph at Assets/Visuals/Subgraphs/Scene Distance.shadersubgraph has 1 warning(s), the first is: Validation: HD Scene Depth Node is not allowed by Custom Render Texture implementation

#

I suppose this is because I could use this sub-graph in a shader graph that does support custom render textures..?

#

It was not warning me before I created a sub-graph

weary veldt
#

I guess its time to ditch my whole idea and solve my Occlusion problem in anotehr way ... there certainly is another way i am sure.

#

what i tried was, to render the Depth into the Alpha value and check, in my outline shader, if the current ScreenDepth would override the Object and then dont draw the outline. But that didnt work ... that didnt even work a little ... anyone has a better idea?
This sounds like an issue you might face more often than not.

regal stag
weary veldt
#

will try that

weary veldt
regal stag
weary veldt
regal stag
#

Should be able to swap that function out for the OnCameraSetup one instead then

public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) {
weary veldt
#

uhm ...

#

somethings broken ... now my URP Sample Buffer Blit Source returns an empty image and my screen only shows some green outlines (the effect that i want)

regal stag
#

Did you change anything else? The function should do the same thing, just provide access to renderingData iirc.

#

To clarify I meant only replace the function name/params, not the contents/body

weary veldt
#

wait, let me take a closer look what i changed

#
            public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
            {
                RenderTextureDescriptor normalsTextureDescriptor = cameraTextureDescriptor;
                normalsTextureDescriptor.colorFormat = RenderTextureFormat.ARGB64;
                normalsTextureDescriptor.depthBufferBits = 32;
                
                
                
                cmd.GetTemporaryRT(normals.id, normalsTextureDescriptor, FilterMode.Point);
                ConfigureClear(ClearFlag.All, new Color(0.0f,0.0f,0.0f,0.0f));

                ConfigureTarget(normals.Identifier());

            }

this i had before

#
            public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
            {
                RenderTextureDescriptor normalsTextureDescriptor = cameraTextureDescriptor;
                normalsTextureDescriptor.colorFormat = RenderTextureFormat.ARGB64;
                normalsTextureDescriptor.depthBufferBits = 32;
                
                
                
                cmd.GetTemporaryRT(normals.id, normalsTextureDescriptor, FilterMode.Point);
                ConfigureClear(ClearFlag.All, new Color(0.0f,0.0f,0.0f,0.0f));

                //ConfigureTarget(normals.Identifier());

            }

            public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
            {
                ConfigureTarget(normals.Identifier(), renderingData.cameraData.renderer.cameraDepthTargetHandle);

                base.OnCameraSetup(cmd, ref renderingData);
            }

Now i changed to this.

#

and the later code results in my Screen being blank. I guess i need to learn more about the system before jumping into it using it.

weary veldt
#

okay, nvm ... its fixed. I dont know why, but i will take a look again another day

ruby sonnet
#

how to make a fullscreen shader (i think its called post processing) in unity URP (shader graph)

weary veldt
#

you generate a new ShaderGraph, set the target to Fullscreen, let me take a lookl

#

In the Graph, in Graph Settings, the Material needs to be set to FullScreen

#

Then in your URPAsset_Renderer (idk how its named on your end, you will find it) you can click "Add Renderer Feature" and click "Full Screen Pass Render Feature" (i think thats whats its called), then you put your shader you made there and ... it should work.

#

@ruby sonnet

ruby sonnet
#

thanks

#

@weary veldt wdym the material needs to be set to fullscreen?

ruby sonnet
weary veldt
ruby sonnet
#

then i guess thats why

hexed sorrel
#

Anyone know what this refers to? I am currently using the 2D URP pipeline, is this only for the standard pipeline?

weary veldt
hexed sorrel
#

I am trying to create a shader for my tilemap to only display the tilemap's tile texture if there is a light overlapping it, so I need some sort of reference to lights in the scene :/

weary veldt
#

sadly that oversteps my knowledge about the topic by far 😦 still new

hexed sorrel
weary veldt
hexed sorrel
#

I am trying to do the same thing for lighting now, but this silly little message has thrown a little wrench in my progress ahah.

weary veldt
hexed sorrel
royal snow
#

hello everyone I'm sorry for interupting, I have task to make 3d character and render it in Unity. I have done the 3d model with albedo, roughness, metalic, and normal. But I dont know how to render with unlit shader. Can anyone help me by telling me how to do it properly?

#

I'm sorry cause I'm new in unity shader

hexed sorrel
#

Does anyone know of a way in 2D URP to dynamically reference current lights in the scene in a shader graph? I am trying to only reveal the texture of my 2D Tilemap based on if the light is overlapping it.

prime shale
#

when you select a mesh renderer in the scene (or you select a material asset), you'll be greeted with something that looks like this

#

this is a material on the object you selected (or the material asset file you selected directly)

#

to "render with unlit" you just switch the shader to unlit

agile token
#

I'm trying to create a shader that is "Always in front" of certain geometry (let's say "Enemy"), but is correctly occluded by everything else.

I have been experimenting with the Stencil Buffer (Something I know very little about). The plan was to have the "Enemy" shader write some unique value into the Stencil Buffer (Let's say "42"). Then have the "Always in front" shader follow conditional logic something like this...

if(the stencil value is 42 and the DepthTest fails)
{
Run the shader
}
else if(the DepthTest passes)
{
Run the shader
}

Looking through the available operation tags for Stencil Buffer in Shader Lab, I'm starting to think that it's not possible to set up this condition.

So my question is:

  1. Is it possible to do what I'm trying to do?
  2. If not, how do I achieve the "Always in Front" thingy, but only for certain geometry.
stiff nexus
#

I FIXED IT!! I reported it as a bug because I thought it was one, but it turns it the solution was super simple, it makes me kinda mad. All I had to do was use HD Sample Buffer instead of the Texture2D that SRP and URP uses. Now it works perfectly.

#

A unity developer found what I messed up and emailed me saying that it isnt a bug, I was just using the wrong sampling method.

deep moth
#

That's awesome!! thanks for sharing the fix

lost wasp
#

Anyone know a good way to offset tiling?
Like say I had a texture that tiles, but every vertical repeat, I wanted it offset on the X axis by a bit

chrome portal
#

What's the simplest way to have a zone on screen be unshaded?

If the entire game screen has a shader on it and I want a circular area around the player to be unshaded.

tacit onyx
#

Hi, im getting this burring issue when I add a super low quality image to my material

#

If i up the resolution it fixes itself to this

#

but im trying to figure out how to use as little pixels are possible. The mesh has as little vertices as possible and all the uvs are assigned correctly. And its using a PNG image

tacit parcel
tacit onyx
#

im getting hard lines now with point no filter and generate mipmaps off

limber warren
#

If we've downloaded assets from the Unity asset store that have shaders attached to them, is it recommended to enable strip #line directives for performance?

agile token
agile token
# limber warren If we've downloaded assets from the Unity asset store that have shaders attached...

I'm really not sure what that's about.
If it means what I think it means, then you should probably be careful with it. It kinda sounds like it might rip out all the pragmas and keyword related preprocessor conditions. If I were to guess, I would say that it's probably some sort of optimization to reduce the number of shader variants, in which case it wouldn't affect your performance but might affect your build time.
Sorry I don't have a solid answer for you. I hope someone here knows more than I do.

limber warren
#

That's what I'm assuming it is as well but I don't think I'll be messing around with it too much

tender marsh
#

Hey all I have the most noob question ever. How can I make it so the black and white are then changed to Colour 1 and Colour 2? I've tried replace colour but it's too fuzzy

#

Also would anyone know if I can recreate this without needing to input a circle texture. For whatever reason ellipse doesn't work with the tiling node

tacit parcel
tender marsh
#

Thank you!!

#

Also would you know any way I can adjust the dot size depending on vertex position (like in this image)?

pure tide
#

hey guys, is it possible to make a grid of white dots (filled circles) that only render on approximately vertical surfaces?
the shader should have transparent background

tacit parcel
keen egret
#

Can I GPU instance this? And if yes, how?

Shader "Custom/DepthMask" {
 
    SubShader {
    
        Tags {"Queue" = "Geometry-10" }
 
        ColorMask 0
        ZWrite On

        Pass {}
    }
}
regal stag
regal stag
# keen egret Can I GPU instance this? And if yes, how? ``` Shader "Custom/DepthMask" { ...

Probably need to add a CGPROGRAM/HLSLPROGRAM to the pass, using the instancing macros.
https://docs.unity3d.com/Manual/gpu-instancing-shader.html
That page should show examples for surface shader or vert/frag ones. Though may vary slightly depending on render pipeline. If you're using URP the SRP batcher might already be optimising somewhat too - whether gpu instancing will be more efficient likely depends on how many objects are being rendered with this shader.

weary veldt
#

I need someone to push my mind in the right direction.

I am currently working on an extended outline shader. What i want to do is, build a big outline (roughly double the size of the model) to be rendered above the model while fading out at the top part of it. I got a lot of it figured out, but i have no clue how to fade it out. Its a Screenspace PostProcessing effect.

weary veldt
#

Tried to Visualize the effect i am trying to do. Not so easy for me :3

hexed sorrel
#

I am currently attempting to create a dynamic lighting system for my 2d game and am currently struggling with light incorporation or alteration through shader graphs. My current objective is to create a shader for my "wall" tilemap where when overlapped by a scene light it will dissipate the light quickly but not block it all-together, so essentially the perceived "falloff" of the light is determined based on if it is travelling overtop my tilemap with the connected shader graph. I think my best bet has to be setting the light to "Multiply using (R) mask" but I am having mixed results with understanding whether or not that is a valid approach. My final goal is a lighting system similar to how Starbound or Terraria light their games without needing to actually calculate block light values and instead just rely on the geometry of the tilemap itself. If anyone has any insights as to how I could approach this ideally using GPU resources through shader graph, or even how I could just dissipate light overlapping with my tilemap that would be amazing, I will attach a labelled diagram below, thanks all!

#

the final solution will hopefully allow lights in the actual scene to cast through the wall and leave a shape of the geometry they initially passed through, I will give another visual example of what I mean below.

#

^ my current brain pseudocode is something along the lines of (foreach tileSizeToWorldDistance multiply the light falloff by 0.25 (or some easy divisible based on the light intensity left) until fully black)

#

This is my current solution however, I honestly have zero idea if this is the right approach to reference overlapping light through the (R) mask, the documentation is extremely limited upon my research unfortunately.

pure imp
#

why when I'm making directional light strengh below 100% light is clipping thrue walls? (baked, URP)

#

like this

#

example isnt baked but it works same when it is baked

grizzled bolt
pure imp
#

so how to make shadows less dark without this effext

grizzled bolt
pure imp
#

ok thanks

hexed sorrel
# hexed sorrel

I will compensate for anyone's time helping find the solution this problem has been driving me insane for almost 14 straight hours notlikethis
I am available to join in a vc to explain what exactly I am looking to do if it isn't very clear also, or a more in-depth text explanation works as-well!

deep moth
# hexed sorrel

This is a tricky one! With shaders you mostly wanna think about what a pixel / fragment knows about. In this case - looking at your image - a pixel would probably want to march back to the light source to figure out if it's occluded. It needs to know it's shadowed somehow. Ive got some time and would b happy to help you brainstorm.

hexed sorrel
deep moth
#

My one catch is I dont use 2D in my work! So I dont know what kinds of opportunities you have with a tilemap.

hexed sorrel
# deep moth My one catch is I dont use 2D in my work! So I dont know what kinds of opportuni...

Yeah, that does seem like a common problem with most online documentation on the shader graphs haha, essentially what I am determining is that if I can reference the scene lights in my shader graph, I could probably get my system I am envisioning to work. However when I add a light to the scene even outside the bounds of my tilemap with a lit shader it will blackout completely, I am thinking I need to somehow accomplish what a "lit" shader does by lighting the tilemap without it actually being a lit shader, to change the mask it applies.

deep moth
#

Are you in URP?

hexed sorrel
#

Sorry for the awful grammar ahah, I have a terrible headache from this whole ordeal

hexed sorrel
deep moth
#

No worries sounds like stepping away from this for a sec might b a good idea too haha

#

I think I'm starting to understand tho

hexed sorrel
deep moth
#

booting up a 2d scene to test

#

yep!

hexed sorrel
#

If you'd like my exact scene to replicate I can probably provide you with that as-well.

deep moth
#

That would be helpful!

hexed sorrel
# deep moth That would be helpful!

it probably won't save the tiledata so if you want I could also just screenshot the tiledata and you could use the tile palette to just draw a similar testing area also!

deep moth
#

its just a nook right ?

hexed sorrel
#

Yeah basically.

deep moth
#

the scene looks pretty simple just wanted to make sure there's nothing weird in there

hexed sorrel
#

don't mind what on earth happened here haha

#

I am just using a freeform light for testing, I'll send all the light data, although I doubt it'll really help as I've been adjusting it a lot.

hexed sorrel
# hexed sorrel

this is my current string of hope to not need to add a script to manage lights, if I can somehow use this and calculate the changes to the mask through my shader, that should be all the data I need to make any falloff/dissipation calculations when the light overlaps the tilemap!

#

I'm thinking this approach may be a bit of a pipedream unfortunately though.

#

This is all the relevant data for the sprites I'm using minus the texture.

deep moth
#

thank you! gonna play around a little and get back to you.

hexed sorrel
hexed sorrel
# hexed sorrel

this portion is also not all that important, if you can even get so much as just the light to dissipate while travelling over the tilemap that would mean the world.

#

Also will throw in my current "Improved" shader, although it really isn't very effective haha.

faint basin
#

maybe sounds like a stupid question, but how can I make a color node with inputs and not not only outputs?

hexed sorrel
hexed sorrel
faint basin
#

thanks!

deep moth
# hexed sorrel this portion is also not all that important, if you can even get so much as just...

Gave this some thought and I think the best way to go is actually to use the CPU!

To get this working on the GPU the way that I'm thinking through it I think you'd have to go through some big hoops:

  1. Come up with a way to store the transmission of each block.

  2. Render the scene with transmission colors to a render texture.

  3. The shader -- you would handle this in a fullscreen render pass which would loop over every light that could light a fragment. Then for each light you would sample repeatedly in the texture (how much light was absorbed this step? how much light was absorbed this step? etc..) to figure out how much light a fragment receives by the end of the function. This could end up being pretty slow.

Either way I think you need to come up with a way to store some data in the CPU.

I think the benefit of the CPU is if you used the jobs system you could just iterate through chunks instead of going pixel by pixel.

Sorry if this isn't helpful!

hexed sorrel
#

I really do appreciate you trying to find a solution in my weird and finnicky guidelines haha!

deep moth
#

Yeah! I dont think there's a good way around it! I was starting to think you could bake the distance from the edge to the center of the chunk.

#

which you could then use to bake absorption

#

might still work

hexed sorrel
#

and then determine distance based on the difference between the full black mask (0) and 1 for a fully lit mask

#

but I am not sure if referencing lights affecting a mask is even possible in a shader graph

sour gale
#

I wanna make the alpha map smaller. but where the texture touches the edges, it shrinks that part. is there a way to make it just smaller while keeping the edges clear?

hexed sorrel
#

I thought that approach was working really well until I realized by coincidence my desired effect was the default for a lit shader haha.

deep moth
#

Yeah I kept thinking about the lit shader! Transmission is pretty hard in 3D too.

hexed sorrel
sour gale
hexed sorrel
deep moth
#

Yeah I think in this case you're looking at a pretty challenging shader problem! might be better to start w/ some simple shaders to get an idea of the constraints.

#

I'm a big fan of the book of shaders for thinking like a shader

hexed sorrel
#

I was hoping for a shot in the dark to land which would save a ton of performance I assumed! But really who knows haha.

#

I've never referenced a script in a shader graph before so I was trying to avoid it like the plague haha.

deep moth
#

Yeah it can get hairy! but its super useful.

hexed sorrel
#

and passing in the light positions and intensities?

deep moth
#

Yep!

#

You can simplify it further by using global values

hexed sorrel
deep moth
#

Yeah that's good practice!

hexed sorrel
deep moth
#

SetGlobalVector will save you from having to set that in a million materials though

#

if you end up having lots of things that need to find that light position

hexed sorrel
#

Great suggestion! I'll definitely use that.

#

So would you recommend looping through all visible lights to the camera and passing them into the shader separately or how would that work?

#

I presume there's a way I could pass all the values as a whole in some way

deep moth
#

If you don't have many lights I think that's the way to go. If you do you'll want to find another way to render them since it won't scale to lots and lots of lights.

#

You can also use arrays to store things. Shadergraph doesn't support it out of the box though.

#

Nor looping. Probably because when you start to go down those rabbit holes you want to consider other options as well.

#

(but those are things you can use in shaders)

hexed sorrel
#

oof yeah, that's what I was a little afraid of πŸ˜…

deep moth
#

Yeah that stuff can get nasty in shadergraphs.

#

You're looking at a pretty challenging problem though.

hexed sorrel
#

well I'm not too sure about how I'll end up figuring that out but I'm sure I will eventually haha.

#

You've probably saved me a few days of work assuming I continued down that path.

#

The extreme lack of 2d lighting documentation in unity is painful to get started with haha, it seems like a lot of solutions are sort of a DIY project.

deep moth
#

yeah! It might be worth looking around to see if anyone online has made what you're looking for especially if you have budget for it. Worth giving some unity assets a shot.

#

Transmission might b a little niche but 2D lighting is something a lot of people deal w/.

hexed sorrel
deep moth
#

np!!

tepid knoll
#

Hey y’all genuine question, should I actually try and buy shaders I need because every shader/texture I’ve needed I’ve just found a shader graph tutorial for free on YouTube

hexed sorrel
sour gale
#

I usually make 3D games so not familiar with the 2D shader

deep moth
#

basic idea is to blur the shadowed parts and then mix that w/ the light

#

doesn't give u transmission tho!

hexed sorrel
#

those two give a good demonstration of the effect I am going for, and when the lights are animated themselves it gives a really beautiful effect!

deep moth
#

One approach would be to render lights as sprites to a camera and then blur that. Then multiply that with the blurred shadow blocks from before. Then you could have as many lights as u want!

hexed sorrel
#

Ohhh wait, can I reference the camera in the shader graph?

deep moth
#

Nono don't bother w/ shaders in this case all you need is a full screen shader that mixes the lights and another one for blurring

#

You would have a camera that renders the lights

#

To a render texture

#

Or some kind of buffer

#

Then blur that

hexed sorrel
#

mhm!

deep moth
#

And use a full screen shader to mix it together

hexed sorrel
#

would this be more performant than somehow passing each individual light?

deep moth
#

It's a tradeoff! There's a big memory footprint involved with storing an extra buffer for lighting

hexed sorrel
# deep moth To a render texture

I was trying to figure out how to do that but just passed it off because I assumed it'd be super poor for performance but I honestly had no idea haha

deep moth
#

It's also not awesome for mobile devices

#

Which usually want to just do all of the work in one render target and not switch.

#

I'd imagine u could get away w/ it tho!

#

As long as u use a cheap blur for the lights

hexed sorrel
#

Yeah I was thinking that!

#

See in my head the most ideal solution would somehow be getting the float data for each necessary variable, (vector3 position, intensity, color) then I wouldn't even need to bother spending the extra resources to blur I could ideally just adjust these variables directly onto the dissipation shader used by my block tilemap.

#

But again, that seems easier said that done as I've found out haha.

deep moth
#

The trick w/ that approach is it doesn't scale well! You kinda end up with the jump between deferred and forward rendering

#

Where deferred has a big overhead for all of the rendertexture

#

But let's u use tons of lights

#

Where in forward you loop over all of them

hexed sorrel
#

ahh.

deep moth
#

For every material

hexed sorrel
#

let me grab an example

#

if I set them to global values I'd only need to declare all of them once per lighting update frame right?

deep moth
#

Yep! You can save those too

#

As IDs

hexed sorrel
#

yeah I was looking into that a bit

#
for (int i = 0; i < maxLights; i++)
    {
        if (i < lights.Length && lights[i].isActiveAndEnabled)
        {
            lightsData.position[i] = lights[i].transform.position;
            lightsData.direction[i] = lights[i].transform.forward;
            lightsData.color[i] = lights[i].color;
            lightsData.intensity[i] = lights[i].intensity;
        }
        else
        {
            // If light is inactive or exceeds maximum lights, set default values
            lightsData.position[i] = Vector4.zero;
            lightsData.direction[i] = Vector4.zero;
            lightsData.color[i] = Color.black;
            lightsData.intensity[i] = 0f;
        }
    }
#
void UpdateShaderData()
{
    // Pass light data arrays to shader
    tilemapMaterial.SetVectorArray("_WorldSpaceLightPos", lightsData.position);
    tilemapMaterial.SetVectorArray("_WorldSpaceLightDir", lightsData.direction);
    tilemapMaterial.SetColorArray("_WorldSpaceLightColor", lightsData.color * lightsData.intensity);
}
#

would something like that be performant do you think?

deep moth
#

Very performant to set but you pay for the cost of lighting each pixel for every light this way

#

So you're limited in the amount of lights you can put in a scene

hexed sorrel
#

oh I literally just clued into that

#

yeah no that makes a lot of sense actually.

#

I forgot that you'd literally have to get the value of every pixel

deep moth
#

Which I think is why so many ppl end up w/ the blur approach

hexed sorrel
#

this is rough

deep moth
#

Yeah. Are you targeting mobile?

#

Cpus r fast w/ jobs system

hexed sorrel
# deep moth Yeah. Are you targeting mobile?

not directly but I would like Steam Deck to be supported and potentially switch as options, but it is a very early build so I am really just aiming for a performant solution.

#

I'm almost certain there's a way that I haven't stumbled across yet, and I am sort of looking for a breakthrough in my shader thought process haha.

#

if I could just render the lights to a lightmap texture per frame and reference them in my tilemap mask that seems like it could be a valid solution

#

I've seen use of emitters for tracking player movement for realistic foliage, and I'm sure you could get a lightmap system going in a similar fashion.

#

That way I can still maintain color, direction, and don't need to be calculating for every pixel.

#

My only concern is the performance hit of getting a lightmap texture for the area around the player and how fast that is, if it's gpu bound that could be very fast and easier to work with than floats in itself.

tawny skiff
#

Why does my shader work in editor, but not during runtime?

#

this is editor

#

runtime

#

this is my shader

hexed sorrel
tawny skiff
#

Urp

hexed sorrel
# tawny skiff Urp

yeah honestly I don't know it may very well be an error in code. But I'm also pretty new so I can't really add more than that

tawny skiff
#

its okay, Its all in shadergraph tho 😦

hexed sorrel
#

Dang, yeah I'd maybe look to see if you're getting any errors or warnings in your console?

kind juniper
#

By runtime you mean when you press play? What exactly doesn't work? Is it the plane at the portal entrance?@tawny skiff

hexed sorrel
#

I found this thread and you might be able to gather some useful info from it, seems like they are mostly using built-in rendering but you may see an issue you have stand out from that.

tawny skiff
#

thx, but im not using any code

#

im just using shadergraph

deep moth
#

what's the texture you're plugging in therE?

tawny skiff
#

its a material that mimics the camera

#

it works when the game isn't runing

deep moth
#

my best guess is that when you're getting into play mode something is up with that texture

#

i'd try seeing what happens w/ the texture on a simpler material

tawny skiff
deep moth
#

or see if the shader works w/ a static texture

kind juniper
#

Guess I'm being ignored...

kind juniper
#

We literally have no clue about your setup. Share more details

tawny skiff
#

okay

#

before

#

during runtime

deep moth
#

ya issue seems to be with the texture!

tawny skiff
#

ah...

#

hmm, thats so weird, the output texture for my camera has the material on it. But when I run the game, it becomes empty

#

thx πŸ™‚

kind juniper
#

Is that a render texture? What camera renders it? Is it enabled at runtime?

#

Material on a camera??🀨

tawny skiff
#

its a render texture *

#

It should be enabled at runtime because its on the camera beforehand

kind juniper
#

The render texture reference is lost? It's that what you mean?

tawny skiff
#

Yep, I think im resetting it here

#
 void Start()
 {
     if (cameraA.targetTexture != null)
     {
         cameraA.targetTexture.Release();
     }

     cameraA.targetTexture = new RenderTexture(Screen.width, Screen.height, 24);
     cameraMatA.mainTexture = cameraA.targetTexture;

     if (cameraB.targetTexture != null)
     {
         cameraB.targetTexture.Release();
     }

     cameraB.targetTexture = new RenderTexture(Screen.width, Screen.height, 24);
     cameraMatB.mainTexture = cameraB.targetTexture;
 }
kind juniper
tawny skiff
#

I want a plane that matches the screen width and height of a camera

#

so it changes the UVs to match that (I think)

kind juniper
#

I don't see how uvs are relevant here at all.
Do they create a render texture at runtime in the tutorial?

tawny skiff
#

no, But I wanted to create my own shader and put it onto a plane

#

Does the shader texture need to be called mainTexture?

kind juniper
#

It depends on how it's defined in the shader.

#

If it's a unity shader, mainTexture would work, as it just aliasing a string that unity uses to define main textures in their shaders.

#

I think you should start with inspecting your setup thoroughly at runtime. Make sure that the correct material is modified and the correct rt references are set both on the camera and the material. Make sure that the correct material is used on the plane.

tawny skiff
#

Sounds good

solar marsh
#

I have a quad mesh that doesnt occupy the full uv space, how can I make a circle that fits inside of the uv perfectly, I would like it to stretch to fit,

#

or really just trying to apply an outline

kind juniper
#

Anything beyond that would go out of the uvs range

#

Ah, it's not the radius of a cir le, but corners rounding?

#

If the issue is really with the mesh, you'll need to know the actual uvs is using.

true pendant
#

so i embedded my textures and materals into my model and only the shoes and sweater worked

tacit parcel
onyx cargo
#

having a really weird issue... i'm on built-in, 2022 LTS... any idea why all my unlit shaders would just stop working?

#

they're 100% transparent when i apply them to a renderer, no matter what i tweak

#

build target is android

kind juniper
onyx cargo
#

ya

kind juniper
#

The objects that have the issue, the renderers, materials, other components, scene view, hierarchy, etc

onyx cargo
#

huh... i fixed it i think.

#

I create a new mat... its just the one material that came with photon

#

if i set that material to Unlit/Color and apply it to anything, like a cube... its invisible

#

if i create a new material and use the same shader and apply it its visible

tacit onyx
#

Hi, im trying to figure out the best way to make a customisable road generation tool via creating meshes via code. So far I have it so each part of the road (maybe 2 lanes one way, divider in the middle, 1 lane the other way) is generated into one mesh like below. Only issue is that texture colouring of it only works if the texture is very high resolution else it does a weird banding. The colours in the image is green for a lane, grey for a divider, and debug blue/red for divider walls.

I was wondering if I should make each part of the road its own big mesh (each part can have different sizes, eg 10m wide lane vs 20m wide lane) like i currently have. Or if I should be making a template mesh for each part of the road (divider, lane, footpath etc) and join them together. The big mesh would have a custom texture per road (hence trying to have super low resolution textures (in this case it would be 7by1 pixels total)), and the multiple small meshes would have one globally used texture per part of the road.

Or is there a better way of doing this? I would like to stay away from having a GameObjects per part of the road as it leaves gaps between the meshes.

#

I get these issues when importing the low res textures

hexed sorrel
#

Hey! I was having the same issue yesterday and just want to confirm and see if anyone has a good/better solution, in Unity 2D using URP I am trying to get light overlapping the tilemap using a shader to dissipate or travel less far when overlapping it, the current solution is to render lights to a render texture and deal with it that way, however that method isn't very performant unfortunately. If anyone has any better solutions it would be more than amazing, thanks!

#

My final effect is ideally something similar to the way lighting in Starbound is handled which I will attach images of below.

#

As you can see light travels quite efficiently until it hits a wall which forces it to dissipate very quickly.

grizzled bolt
#

Shaders can't get the necessary information about nearby tiles to know whether the light should be dissipating or not

#

The types of Starbound and Terraria use some variety of a flood fill algorithm (or "flood fill light propagation") I believe
Starbound additionally uses raycasting for certain light types

hexed sorrel
#

if I could even just pass so much as the light's position efficiently, I could just calculate in the block shader how far any given light is and just convert tile size to world size and it'd be a simple division problem. But I really want to avoid having to calculate every pixel. It's definitely a tricky problem.

grizzled bolt
grizzled bolt
hexed sorrel
#

well the general way of using a render texture for this application seems to take all empty tiles and converts them to a render texture and simply adds a blur to fake that dissipating light, I'll get an example of what I am referring to.

grizzled bolt
#

URP 2D lighting does give you lights of various shapes and lets you use the resulting render texture in any way you wish
But it has very limited options for shadowing and no light propagation

hexed sorrel
#

I've heard that to be quite memory intensive but I definitely think a render texture is going to be my best option

grizzled bolt
hexed sorrel
grizzled bolt
#

You can't calculate light propagation with shaders
But you have various options for drawing lighting without it

hexed sorrel
#

My only concern with render textures is that I simply haven't used them before and I've been told it's quite computationally demanding, which I am also trying to avoid as best as I can. But again the rest of my game is very well optimized so I do think I have a bit of wiggle room.

hexed sorrel
#

Terraria specifically is using a light value which is stored in each individual block which is famously known for being extremely buggy and slow, Starbound seems to be doing something a lot more effective and has a lot better of a look imo.

tropic remnant
#

Hi! In a compute shader, is there a difference between these ways of getting values from a RWTexture2D? A: bool insideMask = InputMask[id.xy] > 0.5;
B: bool insideMask = InputMask.Load(int3(id.xy,0));

snow forge
#

Hi all, I was just wondering if anyone knew if it were possible to make a 'screen space' curved world shader? All the guides etc. that I've found are for 'object based' shaders, but for my idea I kinda need it to be screen space due to needing the collisions on the objects etc.

tropic remnant
low lichen
# tropic remnant

I am wondering if I need to do double buffering
The answer to that is almost always yes.
There are texture types and GPUs that support concurrent read and write, but there's no protection from race conditions.

#

Group barriers only help in this case if you limit each group to reading within a certain range, and no groups overlap each other.

tropic remnant
low lichen
tropic remnant
low lichen
#

I think the iterations are usually done as separate dispatches, not loops in the shader.

tropic remnant
tropic remnant
hexed sorrel
#

okay so this may seem like a really dumb question and it definitely is, however my tilemap is being affected as separate tiles, and I've fixed this before and I cannot replicate how I know a position node is required but it doesn't seem to be fixing my problem here.

regal stag
# hexed sorrel

It's likely the 2D Light Texture should be sampled in screen space (so using Screen Position node attached to UV port), but I don't know for sure.

hexed sorrel
#

I was just using the wrong position node ahah

snow forge
#

Or more likely offsetting vertices ?

neon mason
#

I deleted the Library folder and then half of my shaders broke. This black thing appeared. I tried to create a new project and move everything there - didn't help, tried to take an old version of the shader from my repository - didn't help. In the preview in the shader graph - everything is fine. I don't understand what's wrong at all. What can i do?

#

<@&502884371011731486>

snow forge
#

<@&502884371011731486>

tame topaz
#

!ban 415883320094621696 bot

echo moatBOT
#

dynoSuccess mrg3nius was banned.

snow forge
#

πŸ‘

neon mason
snow forge
worthy grail
#

Hey, could someone help me make a shader for trees, what I mean is that the higher the point on a sprite, the more the tree sways left and right, and at the very bottom it doesn't sway at all

hexed sorrel
#

the mask will prevent any movement on areas that are black and will slowly allow for more movement the closer the mask is to white, you can also use a gradient node if you want a constant vertical black to white mask

hexed sorrel
# worthy grail Hey, could someone help me make a shader for trees, what I mean is that the high...

Welcome to another devlog for Astortion - a 2D platform-adventure game that I'm currently working on.

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

Unified Interactive Physical Foliage - [UE4 Plugin Out Now]
by Elliot
https://youtu.be/9Fnj5zlcFdQ

UE4 - Tutorial - Interactive Foliage! (Update in Description)
by Dean Ashford
https...

β–Ά Play video
hexed sorrel
#

Hey, could someone help me make a shader

pallid parcel
#

Hey all, I'm a texture artist helping some friends with a game, but I've never used Unity before. I come from UE5 so Shader Graph is very clunky to me compared to Material Graph in unreal (not complaining about the software, just saying im unfamiliar with it so it's harder). I'm trying to apply my normal map to my asset and I have no idea where it goes. This is in an unlit shader currently, so I get why it wouldn't appear yet, but I just want to know where to plug it in so it's already there when I add my lighting

#

if there's any good tut's on the process in Unity that's kinda designed for people familiar with UE anyone can recommend maybe?

hexed sorrel
#

if I'm not mistaken

pallid parcel
#

I can't do it in unlit? We're trying to get a toon lighting effect so we're planninng to build our own lighting

#

unless tha'ts just not how it works in unity lol

hexed sorrel
pallid parcel
snow forge
hexed sorrel
# pallid parcel Yeah I only did it because there's engraving on the revolver and I didn't want i...

Lit shaders in Unity use physically based rendering techniques to model light as a function of an object's physical properties like smoothness, metallic, and albedo. Learn how to create Lit graphs in Part 6 of this tutorial series!

I'm using Unity 2022.3.0f1, although these steps should look similar in previous and subsequent Unity versions.
--...

β–Ά Play video
pallid parcel
low lichen
hexed sorrel
#

this will pretty well explain it

low lichen
#

But you need to convert it to world space first.

pallid parcel
#

sounds like a good starting point. I suppose worst case I can always make the engraving purely specular and hand paint it on

#

it's pretty subtle anyway

#

thanks gang

snow forge
hexed sorrel
snow forge
# hexed sorrel what exactly is the final objective you're looking to get?

Project is essentially an endless runner/arcade shooter hybrid where the player is travelling through a twisting/turning tunnel. My current solution is a 'donut' shaped tunnel that is constantly rotating towards the player/camera and 'swings' on it's Z axis giving the illusion of the tunnel twisting and turning, but it's a bit 'boring' and inelegant (if that makes sense).

low lichen
snow forge
#

Yeah, 99% of curved shaders I've seen reference animal crossing. lol.

hexed sorrel
snow forge
#

But I was thinking it might be possible to move the vertices instead of the pixels.

#

I did find one that is great, but because it's object based, when it bends the object(s), the colliders no longer line up .

#

If you give me a couple of minutes, I'll record some footage.

low lichen
#

As long as everything in your scene is curved by the same technique, it doesn't matter that the colliders don't line up. Everything will be "unaligned" the same way, so it looks correct.

hexed sorrel
snow forge
# low lichen As long as everything in your scene is curved by the same technique, it doesn't ...

That's the problem, not everything is, the players bullets etc. won't be affected.

I did have an idea to modify the curved shader that I've got to 'start' the curvature at the Z position that the enemies 'sit' when in their formation, but I couldn't figure out how to stop it bending 'behind' that position. (Video for reference)

https://streamable.com/kami3e

Watch "2024-04-26 17-18-02" on Streamable.

β–Ά Play video
#

But, then the problem becomes the collisions with the tunnel.

snow forge
#

Thanks πŸ™‚

#

Started off as a 'Space Harrier' type game. lol.

#

I'm an 80's kid, so the old arcade games a big deal to me and figured modernising them would be a cool project.

hexed sorrel
snow forge
#

Even came up with an idea (and started building it) where I take 10 'classic' arcade games, use each one as a level in a large story. lol.

hexed sorrel
low lichen
snow forge
worthy grail
#

Hello, could someone help me with the shader, I have 2 problems, the pixels are stretching on the left side, and the sprite is clipping on the right side

hexed sorrel
#

as it can't go outside of it's UV or it'll clip.

#

I forgot to mention that sorry!

#

I would add 6~ empty pixels to the sprite and it'll fix all of that!

worthy grail
hexed sorrel
plush relic
#

I'm experimenting with a planet atmosphere shader, but I'm having some issues. If the atmosphere is scaled up to be much larger than the planet, it looks just fine. However, as I reduce the scale (or move the camera closer) , a bunch of really weird artefacts start to appear, and as I continue, the effect just disappears completely. Anyone has an idea why this is happening?

pallid parcel
#

Okay so I've got my cel shader built as you can see in my project shelf, but I already have my model textures applied as a material to my asset. I want to layer the cel shader on top as my lighting, but I'm getting the warning regarding needing to set up multiple shader passes to save performance. What's the best way to do this? Should I be adding a submesh for every material, or should I be adding shader passes to my single mesh?

hexed sorrel
#

Hey, really I have a quick question about masking a texture from another (without the "to be clipped" texture needing to be greyscale ideally), in shader graph I would simply like the "Texture 1" (a Tilemap in my case) to clip out the Texture 2 square based on the tilemap's geometry, if anyone has a solution that'd be fantastic. I know it's probably very simple however, I cannot seem to get it to work. Any help or suggestions are welcomed with open arms, thanks! (Picture depiction below).

#

Ideally the "Ideal Result" texture should be texturally "clipped" so I can use it later on in the shader as a "clipped" texture.

#

*fixed ideal result screenshot

tired skiff
#

did ypou find any solution

#

for shock waves in hdrp

#

can anyone help with a shock wave radial shader for hdrp

#

distortion shader seems very difficult to control

half nebula
#

hello, so i have a URP project where textures are showing fine, but they turn pink after i build the game
i tried to reset the graphics settings but didnt work, any idea why

tacit parcel
half nebula
deep moth
#

if it doesn't u'll prob need to figure out how to get something like that

#

another thing you could use in this case is called a stencil

#

if you end up needing to cut geometry out of geometry

#

based on what you're showing you should be fine just multiplying alphas though

#

Unity's UI system, for example, is full of logic for stenciling and uses it heavily to mask things out.

tacit parcel
hexed sorrel
#

the second texture (blue in the example) would be a 2d light texture, so I'm not too sure how the alphas work but I'll certainly try that when I'm home!

deep moth
#

lmk how it goes!

half nebula
deep moth
#

im also curious what the shader is

#

shaders can be finnicky about platform support

#

you might wanna try flipping through different graphics apis to see if that changes anything in editor

tacit parcel
snow forge
elder crow
#

Weird question - Im on unity 2023.2.3f1, and Im writing a "meta" shader for use with the lightmap baker. It seems that the lightmap baker ignores properties set via MaterialPropertyBlock. Has anyone else experienced this? What would the workaround be?

#

eg: if I set "_Color" to red directly on the material, it shows up in the bake. If I set "_Color" via materialPropertyBlock it does not.

#

but the scene renders correctly with the propertyBlock color set, as does the preview windows like so

harsh spindle
#

what does this mean?

cosmic prairie
# harsh spindle

when you dispatched your compute shader you did not set the _SourceVerticies property

#

check for a typo or set the variable before dispatching

cosmic prairie
#

neither urp or hdrp supports them properly

#

it breaks batching

#

use separate materials for each object, even if they have totally different variables set

#

if you create a new material with the old material you dont have to copy properties

#

var newMat = new Material(oldMat);

#

i honestly have no clue if this would cause a memory leak in the editor, try setting material.hideFlags to DontSave and call Destroy on the material when the object is destroyed

#

would be worth to test if this is needed, I just do it to be sure

elder crow
#

"breaks batching" is a weird thing for unity to say, because using separate materials also breaks batching

#

unity has a weird relationship with what a drawcall is >_<'

cosmic prairie
elder crow
#

SRP batching is not drawcall reduction

#

it lowers cpu usage, which is good for consoles, but its bad for mobile

#

because mobile wants to reduce the number of actual final emitted drawcalls

#

which is something materialpropertyblocks let you do

cosmic prairie
#

check rendedoc

#

or frame debugger

#

the stats window lies

cosmic prairie
elder crow
#

sure, thanks for the heads up

#

(fwiw, you should check what SRP is doing, I think you'll be surprised)

cosmic prairie
cosmic prairie
#

like I have written custom renderer features but they just use a rendererlist draw command which is then passed over to the c++ black box afaik, could be wrong

cosmic prairie
#

Sorry but I can't check that

harsh spindle
#

wait oops

#

how do i send that in code blocs

cosmic prairie
#

like is it long?

harsh spindle
#

around 140 lines

cosmic prairie
#

ehh why

harsh spindle
#

lemme just look over this

elder crow
#

fyi

#

"The traditional way to optimize draw calls is to reduce the number of them. Instead, the SRP Batcher reduces render-state changes between draw calls."

#

its not a draw call reducer

#

which largely sucks for mobile

#

theres a lot of misinformation about srp batching :/

cosmic prairie
#

if you render the same mesh it will batch

#

idk if its instancing or what

#

but it does reduce drawcalls too

#

it won't combine different meshes

#

afaik

elder crow
#

no

#

sorry thats bad intel

#

ill get a cap to test though

#

yah, SRP doesnt reduce drawcalls

#

renderdoc says its calling DrawIndexedPrimitive once for each ball (dx11 pipeline)

#

Urp

#

and when you look at the frame debugger it says the same thing

#

Not saying the SRP "Batcher" is bad or anything, its just not actually a batcher

#

if you want to reduce the number of drawcalls, you have to break SRP Batcher compatibility and use GPU instancing compatibility instead, or manually merge stuff

steel notch
#

Is there any way to have Sorting Groups with Opaque objects?

#

Or is it just impossible given how opaque objects are rendered?

elder crow
#

If you have your own srp you can control that

steel notch
elder crow
#

When you invoke rendering of the opaque part of your scene in a srp, you get to set how it sorts it

#

Either obeying layers, optimize for batching, using various filters etc

#

I don’t think there’s any ui for configuring this but the code for changing it (assuming you can locate it for your srp) is just some enums

#
            RendererListDesc transparentDesc = new RendererListDesc(shaderTagId, cullingResults, camera);
            transparentDesc.renderQueueRange = RenderQueueRange.transparent;
            transparentDesc.sortingCriteria = SortingCriteria.CommonTransparent;
            RendererList transparentRenderList = context.CreateRendererList(transparentDesc);
            cameraCmdBuffer.DrawRendererList(transparentRenderList);```
#

so say your srp is doing something like that, you can switch out the sortingCriteria

#

if you're using the URP or HDRP, the source for this is in the package, just look for "SortingCriteria."

split sand
#

Hi everyone! is there a way to quickly make a scene dark? I want to preview the emission shader settings on a character.

livid kettle
#

change the light intensity i guess

#

on the Light object

split sand
#

But that leaves an ambient light. If I want total darkness there are more settings I need to press under lighting. I was just wondering of there was another way.

sinful bluff
#

Hey people! I'm working on creating a waving flag as part of the Creative Core pathway, after having completed the Junior Programming part. I have replicated what's in the course (they use PBR, https://unity-connect-prd.storage.googleapis.com/20210406/learn/images/3dd552b7-9e6a-4b2e-990d-6716bdae2821_3_UVnode.PNG) in my project using URP/Lit. Result should be like this: https://unity-connect-prd.storage.googleapis.com/20190819/learn/images/e00116d5-784d-4f5d-917b-002ab9da5561_ShaderGraph3.gif

You'll see my result is very different. Here's a video, and screenshot. Can someone help me along?

hearty igloo
#

@sinful bluffWhat is wrong with the video?

#

not smooth enough?

sinful bluff
#

(The white flag GIF is from the tutorial)

hearty igloo
#

you need a world to object node

regal stag
hearty igloo
#

add a world to object position node before the vertex position

sinful bluff
#

Thank you @regal stag and @hearty igloo I will try this now. Just setting the Space in Position to Object makes ripple effect disappear (like in the example GIF). I'll work on the other solutions now.

hearty igloo
#

Good

#

Is this the channel for HLSL shaders?

regal stag
#

May be some scaling differences too

regal stag
hearty igloo
#

Good, thanks.

#

My question: I'm using this nice grass shader https://www.youtube.com/watch?v=MeyW_aYE82s) in my project. It's fine, but I tried to add aspects like the ability to get lit. My problem is that I can't get my grass blades to get lit by additional lights. The HLSL code: https://github.com/HeRobrain3/unityPFI/blob/main/BotWGrass.shader

Breath of the Wild's grass is visually striking and helps to break up large areas of ground. In this tutorial, learn how to make stylised grass just like it in Unity URP using geometry and tessellation shaders!

πŸ‘‡ Download the project on GitHub: https://github.com/daniel-ilett/shaders-botw-grass

✨ Roystan Grass Shader: h...

β–Ά Play video
GitHub

Contribute to HeRobrain3/unityPFI development by creating an account on GitHub.

#

The grass blades unaffected by point light (flame):

#

Thank you in advance

sinful bluff
#

Hey folks! Could you have another look at my shader? This is the closest I've gotten to the result I want. But, it's not good. πŸ˜… Video and screenshot attached. And here's that GIF again it's supposed to resemble.

hearty igloo
#

you are moving the vertex on the y axis (vertical), you want x or z

#

take r or b not g

#

I think

sinful bluff
hearty igloo
#

R=x, G= Y B=Z

#

try split r to combine r and split g to combine G and split B to add and multiply out to B

hearty igloo
#

If the flag isn't attached to the rod, change the UV split output G to R or B

sinful bluff
#

Thanks. None of that works, or I don't understand what you're saying. I'm going to start over from scratch to get more familiar with the different nodes.

harsh spindle
regal stag
harsh spindle
#

Bruh 😭

regal stag
hearty igloo
# hearty igloo

remove the one minus to switch which side the flag stay immobile (fixed to the rod)

#

but the render mode to both and this is the rotation I used to test the shader :

sinful bluff
hearty igloo
#

use R

hexed sorrel
#

Would anyone by chance know how I could take the output of my "Multiply" node and pass it into another group of nodes to create a gaussian blur effect? // I've seen quite a few guides which recommend the tiling and offset node to create a sort of fake blur, however I cannot really pass a "Multiply" node into a Tiling and Offset node even if I were going with that approach. Any ideas would be amazing, thanks!

hearty igloo
sinful bluff
#

@hearty igloo I tried, but still not exactly what I'm looking for. Thanks so much for keeping helping me.

hearty igloo
#

good

#

rotate your flag to this (90,90,0)

regal stag
hearty igloo
hearty igloo
hearty igloo
#

keyword are added

sinful bluff
hearty igloo
regal stag
hexed sorrel
regal stag
hearty igloo
sinful bluff
#

And thanks for the continued help.

hearty igloo
hearty igloo
#

try the prefab and material inside the asset

sinful bluff
hearty igloo
#

and don't put as child of a scaled or rotated parrent

sinful bluff
#

Thanks I'm going to try that now!

hearty igloo
# regal stag ForwardPlus isn't a lightmode afaik. You should stick to `UniversalForward`

This is the modification I did on my shader and still nothing. Am I missing something?

`Name "GrassPass"
Tags { "LightMode" = "UniversalForward" }

        HLSLPROGRAM
        #pragma require geometry
        #pragma require tessellation tessHW

        #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
        #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS

        //#pragma vertex vert
        #pragma vertex geomVert
        #pragma hull hull
        #pragma domain domain
        #pragma geometry geom
        #pragma fragment frag`
#

also

#

this is my URP settings:

regal stag
#

For Forward+ you'll also want #pragma multi_compile _ _FORWARD_PLUS

#

May also need to set normalizedScreenSpaceUV in your InputData struct

#

I guess lightningInput.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(i.pos); in your case

hearty igloo
hearty igloo
#

Nice, I will notify later if I still have issues. Thank you.

hexed sorrel
#

does anyone know if it's possible to easily convert a RGBA to a UnityTexture2D easily using custom shaders? I currently have a blur hlsl shader I am trying to use with my light texture after a few passes which unfortunately means it is no longer a "UnityTexture2D" if anyone knows how I could convert this hlsl script to accomodate that multiply output that would be amazing! Thanks in advance.

// void GaussianBlur_float(UnityTexture2D Texture, float2 UV, float Blur, UnitySamplerState Sampler, out float3 Out_RGB, out float Out_Alpha)
void GaussianBlur_float(UnityTexture2D Texture, float2 UV, float Blur, UnitySamplerState Sampler, out float3 Out_RGB, out float Out_Alpha)
{
    float4 col = float4(0.0, 0.0, 0.0, 0.0);
    float kernelSum = 0.0;
 
    int upper = ((Blur - 1) / 2);
    int lower = -upper;
 
    for (int x = lower; x <= upper; ++x)
    {
        for (int y = lower; y <= upper; ++y)
        {
            kernelSum ++;
 
            float2 offset = float2(_MainTex_TexelSize.x * x, _MainTex_TexelSize.y * y);
            col += Texture.Sample(Sampler, UV + offset);
        }
    }
 
    col /= kernelSum;
    Out_RGB = float3(col.r, col.g, col.b);
    Out_Alpha = col.a;
}
#

*don't mind the error on the custom function that is just a result of me testing a few things to convert it.

hearty igloo
hexed sorrel
hearty igloo
#

void GaussianBlur_float(float4 color, float2 UV, float Blur, UnitySamplerState Sampler, out float3 Out_RGB, out float Out_Alpha)

hearty igloo
#

color go to Texture.Sample(Sampler, UV + offset)

hexed sorrel
#
// void GaussianBlur_float(UnityTexture2D Texture, float2 UV, float Blur, UnitySamplerState Sampler, out float3 Out_RGB, out float Out_Alpha)
void GaussianBlur_float(float4 Texture, float2 UV, float Blur, UnitySamplerState Sampler, out float3 Out_RGB, out float Out_Alpha)
{
    float4 col = float4(0.0, 0.0, 0.0, 0.0);
    float kernelSum = 0.0;
 
    int upper = ((Blur - 1) / 2);
    int lower = -upper;
 
    for (int x = lower; x <= upper; ++x)
    {
        for (int y = lower; y <= upper; ++y)
        {
            kernelSum ++;
 
            float2 offset = float2(_MainTex_TexelSize.x * x, _MainTex_TexelSize.y * y);
            //col += Texture.Sample(Sampler, UV + offset);
            Texture += // ^ undisclosed result
        }
    }
 
    col /= kernelSum;
    Out_RGB = float3(col.r, col.g, col.b);
    Out_Alpha = col.a;
}
#

would I need to do Texture += float2 offset?

hearty igloo
#

fk

#

my bad

#

I didn't saw the offset

hexed sorrel
#

it's UV plus offset

hearty igloo
#

can you make a wider screenshot of your graph?

hexed sorrel
#

essentially my tilemap's texture is above which's alpha multiplies with my light texture's alpha to cut out the overlap from the light texture

hearty igloo
#

can you blur before the multiply?. you blur node will act as sampler

hexed sorrel
#

then I reintroduce all color back to the light texture which I am trying to then blur

hearty igloo
#

I guess

hexed sorrel
#

because it needs to blur the "cut out" version

#

Because I would like the blur to push some of the light texture back over the main texture

hearty igloo
#

I see

hexed sorrel
#

Yeah :/

hearty igloo
# hexed sorrel Yeah :/

Can't you make the cutout part in code and put it in the guass code, so you can take T2 as input?

hexed sorrel
#

Let me think

#

in theory I'm sure that route does "work" but I'm sure it would be quite a bit more complicated than converting the unitytexture2d input to a float4, as cutting out then blurring overtop the same texture I started with would be quite confusing to get working I could assume

#

but if I can't find a solution in this initial route I'll probably need to do something like that

hearty igloo
#

float4 tmp = TextureLight.Sample(Sampler, UV + offset); col += tmp.a * TextureMainTexture.Sample(Sampler, UV + offset).a * tmp.rgb;

hearty igloo
hexed sorrel
#

I'll get a screenshot real quick

#

line 18: col += tmp.a * TextureMainTexture.Sample(Sampler, UV + offset).a * tmp.rgb;

#

I'm honestly not even seeing any float3 in the entire script ahah.

#

other than output*

hearty igloo
#

what is your custom node settings?

#

top left window

hexed sorrel
#

this?

hearty igloo
#

yes

hexed sorrel
#

oh wait

#

you're right I need to manually add the nodes

hearty igloo
#

float4 Texture to t2

#

You need 2 input texture for light and mainTex, Uv, float blur and a SS.

hexed sorrel
#

yeah I added those now

#

same error unfortunately

hearty igloo
#

copy you code

#

your

hexed sorrel
#
void GaussianBlur_float(UnityTexture2D TextureMainTexture, UnityTexture2D TextureLight, float4 Texture, float2 UV, float Blur, UnitySamplerState Sampler, out float3 Out_RGB, out float Out_Alpha)
{
    float4 col = float4(0.0, 0.0, 0.0, 0.0);
    float kernelSum = 0.0;
 
    int upper = ((Blur - 1) / 2);
    int lower = -upper;
 
    for (int x = lower; x <= upper; ++x)
    {
        for (int y = lower; y <= upper; ++y)
        {
            kernelSum ++;
 
            float2 offset = float2(_MainTex_TexelSize.x * x, _MainTex_TexelSize.y * y);

            float4 tmp = TextureLight.Sample(Sampler, UV + offset);
            col += tmp.a * TextureMainTexture.Sample(Sampler, UV + offset).a * tmp.rgb;
            //col += Texture.Sample(Sampler, UV + offset);
        }
    }
 
    col /= kernelSum;
    Out_RGB = float3(col.r, col.g, col.b);
    Out_Alpha = col.a;
}
hearty igloo
#

remove texture

hexed sorrel
#

the float4?

hearty igloo
#

float4 Texture, it's use less now. right?

hexed sorrel
#

well then I'm just completely ditching the cut out light texture no?

#

now this is just the uncut light texture and main texture

hearty igloo
#

the float4 is a color at a point. you get it via the samplers

hexed sorrel
#

Here's what my current shader graph provides

#

(just the white light is important)

hearty igloo
#

screenshot the error again

hexed sorrel
hearty igloo
#

and line 18 is?

hexed sorrel
#

col += tmp.a * TextureMainTexture.Sample(Sampler, UV + offset).a * tmp.rgb;

hearty igloo
#

I see now

hexed sorrel
#

I am trying to turn that first screenshot (what I have) to this:

hearty igloo
#

col += tmp.a * TextureMainTexture.Sample(Sampler, UV + offset).a * tmp;

#

remove rgb at the end

hexed sorrel
#

fixed the error

hexed sorrel
hearty igloo
#

col is still a float4

#

remove .rgb at the end in col += tmp.a * TextureMainTexture.Sample(Sampler, UV + offset).a * tmp.rgb;

hearty igloo
#

do you get a out put now?

hexed sorrel
#

but TextureLight.Sample is still my full light ("uncut")

hearty igloo
#

yep

hexed sorrel
#

I need that to be my cut light

#

before blurring

hearty igloo
#

but this is your cut version : tmp.a * TextureMainTexture.Sample(Sampler, UV + offset).a * tmp.rgb

hexed sorrel
#

so we're kinda a little where we started no?

hexed sorrel
hearty igloo
#

float4 tmp = TextureLight.Sample(Sampler, UV + offset); is just to do it once and not twice

#

tmp = no cut

hexed sorrel
#

mhm

hearty igloo
#

tmp.a * cutoff.a * tpm.rgba = cutoff

#

I guess

hexed sorrel
rain minnow
#

Hey! I'd like to use Unity to do some offline video processing. More specifically, I want to get a video file, apply a simple shader to each frame, and save the video back to a file. Anyone have any suggestions on how to achieve this? (On a side note, I'm sure there are other, perhaps more suitable, approaches to this. However, Unity's something I know how to use, and due to the project's details, I don't really have the time to learn something new. Despite that, do suggest other tools if you think they're worth it.) Thanks in advance for any help!

hearty igloo
#

tmp.a * TextureMainTexture.Sample(Sampler, UV + offset).a * tmp.rgb would be the texture input for before

#

if everything work

hexed sorrel
hearty igloo
#

tmp.rgba = tmp

#

was just for the demonstration