#archived-shaders

1 messages Β· Page 31 of 1

cobalt totem
#

I'm rendering using a custom material, I'm guessing I need a shader that uses transparency

#
 [SerializeField] private Material _rmat;
...
private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        source.filterMode = FilterMode.Point;
        Graphics.Blit(source, destination, _rmat);
    }
#

Right now I'm using the `Unlit -> Texture' shader, I'm guessing that's the wrong one to use

regal stag
#

You may be able to adjust the Render Queue (or Sorting Priority) on the shader/materials

jolly hatch
lunar valley
cobalt totem
lunar valley
bronze cove
#

How would I combine these 2 nodes so the brown dirt part gets on top of the base texture?

regal stag
rapid galleon
#

Made some progress. Despite the right includes, instance id seemed to be returning 0. Eventually figured out almost all instancing logic is locked behind UNITY_INSTANCING_ENABLED which, oddly, isn't true at the same time as UNITY_PROCEDURAL_INSTANCING_ENABLED. Eventually just wrote a custom expression to read the instancing id:

// Standard behaviour is to only return unity_InstanceID for UNITY_INSTANCING_ENABLED.
// Caveat: You'd think otherwise, but just because UNITY_PROCEDURAL_INSTANCING_ENABLED is true, doesn't mean UNITY_INSTANCING_ENABLED is.
// In fact,UnityInstancing.hlsl makes these mutually exclusive.
#if defined(UNITY_INSTANCING_ENABLED) || defined(UNITY_PROCEDURAL_INSTANCING_ENABLED)
    return unity_InstanceID;
#endif

return 0;
bronze cove
cobalt totem
#

@lunar valley For some reason I can overwrite the black with red, but changing the alpha doesn't do anything:

#
Shader "Unlit/DownSampCutout"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

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

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

            sampler2D _MainTex;
            float4 _MainTex_ST;

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

            fixed4 frag (v2f i) : SV_Target
            {
                // sample the texture
                float4 col = tex2D(_MainTex, i.uv);

                if (length(col.xyz) < 0.01) {
                    col.r = 1;
                    col.a = 0.2;
                }
                
                return col;
            }
            ENDCG
        }
    }
}
regal stag
regal stag
rapid galleon
#

Anywho, thanks for the help!

lunar valley
regal stag
hidden kindle
#

Hi all, Unity beginner here. Is it possible to use opaque and transparent rendering in the same shader? I'm trying to design a shader that makes peeled areas of an apple completely transparent

regal stag
hidden kindle
#

Oh interesting, this sounds exactly like what i need!

#

I'll look into this, thank you πŸ™‚

rapid galleon
#

Or if the surface of the apple is the same in peeled and unpeeled state (i.e. no bites), you might get away with lerping between two textures and you might avoid transparency or alpha clipping entirely? Depends a bit on the use case.

regal stag
#

Yep that also makes sense, assuming you can find a way to determine the peeled state in the shader. e.g. editing vertex colours on mesh, or painting on a render texture using model uvs / cylindrical projection.

flat swift
#

hello, i need help, i'm looking for a node in shadergraph that makes black switch to white (not fraction), and i can't find it's name... help me please

regal stag
flat swift
#

arf, no i don't know how to explain it, it's like the fraction node with time, but it swiches to white very sharply, and i want it to switch to it very smoothly

regal stag
flat swift
#

YES ITS SINE

#

thanks a lot!!!!!!

smoky vale
#

alright

bronze cove
#

For some reason the white mask (which is now red on the right side) lacks so much detail in comparison to the left node (original white mask)?

cobalt totem
regal stag
bronze cove
#

Whoops my bad-

#

But still looks kinda weird :/

rapid galleon
# flat swift YES ITS SINE

Hit my head too often one this one: sine waves normally go from -1 to 1. Make sure to use absolute values if you just want a smooth back and forth between black and white :p

cobalt totem
#

I can clip specific colours but then the colouring goes weird

regal stag
cobalt totem
#

This is how I'm rendering to a texture:

public class HoloLens : MonoBehaviour
{
    private RenderTexture m_volumeRenderingTexture = null;
    [SerializeField] private Material _rmat;

    private void OnEnable()
    {
        m_volumeRenderingTexture = new RenderTexture((int)(Camera.main.pixelWidth * .5), (int)(Camera.main.pixelHeight * .5), 24, RenderTextureFormat.ARGB32);
        Camera camera = GetComponent<Camera>();
        camera.targetTexture = m_volumeRenderingTexture;
 
    }

    private void OnPreRender()
    {
        Camera camera = GetComponent<Camera>();
        camera.targetTexture = m_volumeRenderingTexture;
    }

    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        source.filterMode = FilterMode.Trilinear;
        Graphics.Blit(source, destination, _rmat);
    }

    private void OnPostRender()
    {
        Camera camera = GetComponent<Camera>();
        camera.targetTexture = null;
       //  Graphics.Blit(m_volumeRenderingTexture, null as RenderTexture, _rmat);
    }
}
#

Where _rmat is rendered using the shader I just made

regal stag
# bronze cove

What is the colour property set to? I assume it's currently set to a red colour. Should be able to change it under the node settings while that property is selected

cobalt totem
#

(Also, I can set a colour like red to clip out, however it looks like this:)

#

Nice soft edges, but isn't the right colour

bronze cove
#

Yup it's currently red

regal stag
# bronze cove Yup it's currently red

It might also be that the values in the mask aren't high enough. (1 should mean it'll be completely red, but the result here seems like partial transparency)
Maybe try multiplying the mask by a value (e.g. 2) then Saturate (to clamp between 0 and 1), before connecting to Opacity.

regal stag
cobalt totem
#

I have it set to red currently

bronze cove
#

The mask then comes out pixelated :/

cobalt totem
#

If I set the transparency on the camera clear colour, it changes the transparency of the entire image

#

(This is it set to white with some transparency for example)

regal stag
# cobalt totem

Is this still with the shader editing the values? I'd comment out this section for now

// sample the texture
float4 col = tex2D(_MainTex, i.uv);
//if (length(col.xyz) < 0.01) {
//      col.r = 1;
//      col.a = 0.2;
//}
return col;
cobalt totem
#

Yeah I've commented that out, and set the blend mode to alpha

#

Blend SrcAlpha OneMinusSrcAlpha

#

The camera renders to a temporary render texture, then it's upsampled back to screen size, background colour is set by the camera

regal stag
regal stag
cobalt totem
#

I think the shader I'm using is set to Premultiply

#

Hmm, changing it to alpha didn't make any difference

#

If I don’t use a render texture then transparency works, but then I can’t rescale it

snow forge
#

Is there a node in the HDRP shader graph that will allow you to blur an image?

amber saffron
snow forge
#

Hmm. Okeydoke, thanks.

bronze cove
#

Hmm how would I combine all these 4 nodes?

forest mason
#

Hi guys, how can I make this an island (with erosion value) while keeping blue noise (sea) outside the island?

snow forge
#

Radial gradient on the alpha channel maybe? ((Very much guessing, still getting my head around The shader graph stuff))

forest mason
#

Still not working ^^ (maybe I'm doing it wrong)

snow forge
#

@bronze cove Blend Nodes? Using the b/w mask image you've got on there plugged into the blend opacity?

#

@forest mason gimme a sec.

#

I don't think you need the multiply, just plug the gradient straight into the W channel on your vector 4 node?

forest mason
#

Same result

snow forge
#

Hmm.......Not sure tbh, in my head that should work. But like I said, new to shader graph stuff.

#

try.....adding a solid colour (blue of your water), and then add a blend node, green&blue in the first input, solid blue in the second and then add in the radial gradiant into the Opacity (might need the first two inputs reveresed.

#

@forest mason

forest mason
#

Ok let my try

regal stag
# forest mason

Adjusting the w/a component isn't going to do anything as the Base Color is a Vector3, which ignores that component.
I believe you'd want to Multiply the output of the One Minus and the noise, (perhaps even with some additional remapping), before putting it through the Sample Gradient.

mossy crest
#

hi, can someone confirm if urp decals doesn't work on mobiles (android/ios)?

forest mason
#

That's better

snow forge
#

Yaaay, progress. I helped. lol.

#

If you want a sharper edge, just tighten up the gradient?

forest mason
#

(I'm on the good way ^^)

snow forge
#

Don't know it exists as a node, but if it does, maybe some distortion on the gradient to 'roughen' up the edges?

regal stag
bronze cove
forest mason
#

How can I replace the noise color ? ^^

#

Without using Sample graient I mean

#

My attempts :

bronze cove
regal stag
# forest mason

Put the noise into the T port on the Lerp instead, set A and B to colours

bronze cove
#

Cant you just do this?

forest mason
#

(and what is that?? 🀣 )

bronze cove
#

Or am I wrong

forest mason
#

You are right! Thank you!

cosmic prairie
forest mason
cosmic prairie
#

Does it help with coding?

forest mason
#

Not so much...^^

forest mason
#

Another solution without gradient and simplier

forest mason
#

Maybe it can help someone:

#

SubGraph to add sea to islan

#

Subgraph to create island

#

Final

frigid galleon
#

hiring shader artist, where would be an appropriate channel to post?

cobalt totem
#

I'm really really really close to getting the desired effect now! I just need to share a depth buffer between two cameras. It works like this: Camera 1 renders to the screen (colour and depth), Camera 2 needs to render to the screen with its own colour target, but using the depth from Camera 1

#

I don't know whether I should set Camera 1 to have Camera 2's render texture as a target for the depth buffer

#

Or, set Camera 2 to use the depth buffer from Camera 1

#

Using camera.setTargetBuffers()

spare ermine
raven frigate
#

Need some insight here. A good shader to make something look its pulsating/moving. Its for the identity disk.

raven frigate
#

I tried to put a gif but it would not let me put it here

lunar valley
# cobalt totem Using `camera.setTargetBuffers()`

I usually let each camera have their own depth and color buffer, except if the two cameras render the exact same thing but then i don't know why you need to cameras. If I need the depth buffer from the other camera, then I simply reference it and pass it over to the shader normally

forest mason
#

Hi guys! Anyone has an idea how to get a float from a noise? (I'm looking for a way to get a random float without using "Random Range")

lunar valley
snow forge
#

I think you'd need to sample a random point on the noise? But I have no idea how to do that in ShaderGraph. πŸ˜•

forest mason
snow forge
#

hlsl is the 'original' shader format iirc

lunar valley
forest mason
lunar valley
#

time to learn them then

forest mason
#

Ho ok I got it. But I'm using Shader Graph to avoid writing shader code πŸ˜‹

snow forge
#

The way I usually get a random number is set the seed to the current system time (that way it's always different when the code is run), and if the number needs to be very random (yes I know that sounds weird), set the range to something massive. (0-1000000)

forest mason
#

Thank you for the suggestion. The point is I don't really want to get a true random point. I want to get the height variation value from a single point in a gradient noise

#

(by height value I mean white value)

snow forge
#

Aaaah, okay. Gimme a sec, there's an idea in my head.

forest mason
#

(For a perlin noise, it would be the same as PerlinNoise(float x, float y);)

snow forge
#

Still learning myself, so this might be completely wrong. Vector2 (for your point location)-> Noise node (UVinput) -> should output a solid greyscale colour?

#

Not sure how you're generating your noise, but this is what I just threw together.

forest mason
#

Yep that works!

#

Thank you πŸ™‚

snow forge
#

No probs πŸ™‚

#

As frustrating as I'm finding ShaderGraph, this is kinda fun. lol.

forest mason
#

Haha yep^^

snow forge
#

So, I'm trying to come up with a Terrain Shader for kind've a specific use as I have yet to see the functionality I want in any of the terrain system available (I might be wrong, but I'm not forking out the money if they end up being useless. lol.)

But, I've applied my material to the terrain but getting this notice and can't for the life of me find where this option is.

Could anyone point me in the right direction please? πŸ™‚

lunar valley
snow forge
#

Yeah.

lunar valley
#

is it shader graf?

snow forge
#

Yep.

lunar valley
lunar valley
snow forge
#

Yeah I already read through that one. Doesn't really help tbh. And if completely honest, I really don't want to have to spend the time learning both hlsl AND Shadergraph just for this. πŸ˜• It's okay, I can live with it. lol.

lucid wave
#

Hello, I am looking for some help with materials and shader properties. I'll try to make it short and to the point:

I have modified a default TextMeshPro shader to duplicate its text so it creates the illusion of having an outline. For setting the outline color, I have added an _Outline property.
This shader also has a _ColorArray property that based on the red value of the vertex color, it will output one specific color of the _ColorArray. The same should happen with the _Outline property.

Basically, I would like to make the _ColorArray global for all of the instances of a specific material, and _Outline should be defined in the Editor and is set per object.

I have a PaletteManager that iterates through all of the "shared" materials and correctly sets their _ColorArray. However, I believe that if I want a material to have an individual _Outline property, I need to make an instance for it, and therefore updating the shared material doesn't change anything in the instance.

Is this correct? Is there a way to apply some kind of "inheritance" where an instance of a material inherits properties from a base material, and then modifies some other for each instance?

I'm on 2020.3, if that's relevant!

sick knot
#

How do you combine shaders? I'm trying to put a CGProgram from one shader into another shader. I did it by inserting CGPROGRAM into the other shader's Pass, like below. Is this not a valid structure? Would I need to put it into a separate Pass code, or something?

SubShader
{
Tags { "RenderPipeline" = "UniversalPipeline" "RenderType" = "Transparent" "Queue" = "Transparent" }

    Pass
    {    
        Name "ForwardLit"
        Tags { "LightMode"="UniversalForward" }

        Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha
        ZWrite [_ZWrite]
        Cull [_Cull]            
        ZTest LEqual

        HLSLPROGRAM
        `blahblahlotsofcodehere`
        ENDHLSL

        `i put CGPROGRAM here like this:`
        CGPROGRAM
        `blahblahlotsofcodehere`
        ENDCG
        }
}

CustomEditor "SW2.MaterialUI"
Fallback "Hidden/InternalErrorShader"    

}

To show actual code, I'm trying to put this shader https://pastebin.com/k900b95Z into this shader https://pastebin.com/fWSTRhR2 . The first shader is a water shader I like. The second shader is from a tutorial that adds a ripple effect to water.

haughty moat
#

I'm not sure that CGPROGRAM and HLSLPROGRAM can coexist in the same shader (and if they can, it should be in different pass, with different renderpipeline tags). CGPROGRAM/HLSLPROGRAM are I think the same, but one is for built in renderpipeline, the other for SRPs. Depends what you want to "combine".
Edit: I checked the links. you can't really assemble shaders like that, they are not as modular as OO classes. You can MAYBE extend one of the shader with the features you want from the other one if you know enough hlsl.

sick knot
haughty moat
#

I came for a question to this channel initially. Anyone using Rider knows if there is a way to get autocompletion in hlsl to run inside ifdef blocks referring to multicompile keywords (Rider seems to assume that all keywords are disabled by default)?
edit: like this, for multi compile keywords: https://github.com/JetBrains/resharper-unity/wiki/Switching-code-analysis-context-for-hlsl-cginc-files-in-Rider

GitHub

Unity support for both ReSharper and Rider. Contribute to JetBrains/resharper-unity development by creating an account on GitHub.

vague wolf
#

Hi!
I'm trying to use these lines in webgl but they have no effect. The chrome console does not report any warnings. In editor they work fine. Any suggestion? Thank you

        Graphics.Blit(renderTexture, textureSupport, mMaterial);
        Graphics.Blit(textureSupport, renderTexture, mMaterial);
celest flame
#

hey not sure if i should be asking this here or in the URP section but are there any good resources for working with URP 2D Shaders? or am i fine just learning with the 3d materials to get started? both use shaderlab+hlsl so they would be similar in that respect at least but i think 3d shaders would be working with verts while the 2d shaders are working with sprites

urban iris
#

I have an "overlay" blend mode shader that is based on photoshops formula. It works as expected when project is in in gamma color space, but when in linear it doesn't look like it's able to go brighter than the texture.

Here is the overlay blending part:

float4 texColor = tex;
float4 vertColor = i.color;
float greyColor = (texColor.r + texColor.g + texColor.b) / 3;
float4 finalColor = texColor * i.color;
                
if(greyColor > 0.5)
  finalColor.rgb = (1 -( 1 - 2 * (vertColor.rgb - 0.5)) * (1 - texColor.rgb)) ;
else 
  finalColor.rgb = ((2 * vertColor.rgb) * texColor.rgb);
    
surfaceData.albedo = finalColor.rgb;

Anyone know if there's something that could be done? I'm guessing linear won't "over expose" when blending in that way?

lunar valley
urban iris
#

It's seems that the opposite is happening. I'm adding the vertex color (sprite) and if gray is over 0.5 it should make brighter - but it doesn't get brighter in linear.

lunar valley
urban iris
#

Isn't it the other way around? Either way, that was a decision made by the team.

lunar valley
urban iris
#

I think linear is default for URP
From the manual:
"While a linear workflow ensures more precise rendering, sometimes you may want a gamma workflow (for example, on some platforms the hardware only supports the gamma format)."

lunar valley
#

Β―_(ツ)_/Β―

swift loom
#

Can I check if a buffer is null or not in HLSL? Or do I have to set a variable that indicates that the buffer is allocated

young rampart
#

Does unity cache the values of keywords and global values and only update them if they changed, or should I check internally it's different before setting them?

warped yarrow
#

so I'm trying to do some custom pass stuff on my secondary camera. It's lower resolution than the main camera which is causing it be scaled weirdly, I've tried to scale it around a bit but its still a bit stretched/offset. Any ideas why?

    float4 _Scale;
    float4 SampleBuffer(float4 color);
    float xOffset;
    float yOffset;
    float xScale;
    float yScale;
    float2 textureResolution;
    float2 handleScale;
           
    
    float4 FullScreenPass(Varyings varyings) : SV_Target
    {
        UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(varyings);

        PositionInputs posInput = GetPositionInput(varyings.positionCS.xy, _ScreenSize.zw, 0, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
        
        textureResolution.x = _ScreenSize.z / xScale;
        textureResolution.y = _ScreenSize.w / yScale;
        handleScale.x = _RTHandleScale.x * xScale / yScale;
        handleScale.y = _RTHandleScale.y * yScale / xScale;
        float2 uv = posInput.positionNDC.xy * _RTHandleScale.zw;
        uv /= float2(xScale, yScale);
        //uv.y = _RTHandleScale.y - uv.y;

        // Load the camera color buffer at the mip 0 if we're not at the before rendering injection point
        float4 color =  float4(CustomPassSampleCameraColor(uv, 0), 0);
        if(varyings.positionCS.x > xOffset && varyings.positionCS.x < 1 / _ScreenSize.z - xOffset)
        {
            if(varyings.positionCS.y > yOffset && varyings.positionCS.y < 1 / _ScreenSize.w - yOffset)
            {
                color.rgb *= 0.125f;
                color.a = 1;
            }
        }
        return SampleBuffer(color);
    }
#

update: removing the * RT_HandleScale.zw and uv /= float2(xScale, yScale); bits somehow made it work? should that have happened?

honest bison
#

Any good tutorials on DrawMeshInstancedIndirect and shadergraph URP?

regal stag
honest bison
#

Any idea why my GPU fan comes on whenever I draw instances in game mode, while in editor it never does?

shadow locust
#

if you have unlimited framerate it will draw frames as fast as physically possible

#

if your game is GPU-Bound that means your GPU will go to 100% utilization

#

in the editor there's a ton of CPU overhead for the editor itself so the GPU gets a rest

honest bison
#

I have managed to pass through a TRS matrix, but now working on the color.

#

Appreciate Cyan's link.

sick pulsar
#

is it possible to make a shader that colors the edges of whatever it's material is attached to

sly forum
#

Hello, can someone tell me if is too hard add an cull "off script" to a shader? I have been trying to figure out but my knowledge of scripting is almost nothing, if someone can help me please.

lunar valley
lunar valley
valid elk
#

After switching from Android to Windows I get this when building my project, happens only in build. Any idea? It's a default plane

meager pelican
valid elk
meager pelican
#

Well, since you're in a shader section of discord, maybe tell us what shader is on that plane? Show shader.

#

Also VR info is new, so that may lead you to some answers from someone.

#

Maybe show us the whole screen so we know the context of the plane?
Is there a post-processing thing going on (is that a full screen quad, or just some plane in the scene somewhere?)

valid elk
valid elk
#

also this is the full screen, it's just a plane in an empty scene

#

it does that with any material I apply, the colour just changes a bit but the pattern is the same

#

does it on other objects also, not just the plane

valid elk
#

forgot to precise that I don't have the issue in VR build

sly forum
#

This is where I putted

lunar valley
# sly forum

it needs to be in the subshader, not in the pass

#

same with the tags, put them out of the pass

regal stag
#

As for Cull, it might also work in SubShader but usually goes in each Pass. So this should work. If it isn't, then perhaps there's a different pass or shader being used.

lunar valley
#

hm, my bad

#

the cull works in the subshader as well tho

#

I sinserely apologize

chilly robin
#

I'm trying to work on an eye parallax refraction in shader graph and I'm running into an issue

#

The refraction doesn't seem to be starting from the center of the UV. It's offset a bit and I can't figure out why.

#

The custom function is using the refraction method found here

cobalt totem
#

I'm using some HLSL code within my shadergraph shader, however it returns this error:

Shader error in 'Shader Graphs/NGTornadoDebris': 'tex2D': cannot implicitly convert from 'Texture2D<float4>' to 'struct UnityTexture2D' at Assets/CustomAssemblies/NextGenRayMarching/ngmarchdebris.hlsl(142) (on d3d11)

Here is the problem line of code:
float nonlin_depth = tex2D(_CameraDepthTexture, sPos).r;

How can I sample _CameraDepthTexture within my HLSL code attached to my Shader Graph node?

cobalt totem
#

sPos is from the Screen Position node

#

I've managed to rewrite it like this, but now nothing renders:

#
float nonlin_depth = SAMPLE_TEXTURE2D(_LastCameraDepthTexture, sampler_LastCameraDepthTexture, sPos);
depth = LinearEyeDepth(nonlin_depth) * length(rayDirection);
lunar valley
chilly robin
lunar valley
cobalt totem
#

My code is using a custom HLSL function so I don't have the frag() function to access i.uv

lunar valley
lunar valley
chilly robin
lunar valley
chilly robin
#

Yeah, but they've all ended in failure haha. I feel like I'm missing something simple but I can't figure it out.

lunar valley
lunar valley
cobalt totem
lunar valley
cobalt totem
#

The trees and buildings etc are properly excluded from the rendering, but in the wrong place:

#

It's half way up the funnel, instead of at the bottom where the overlap actually is

chilly robin
#

@lunar valley Thanks for trying to help. I gave up on my approach and decided to just go with a standard parallax method. I might revisit this again sometime but I think it's good for now.

lunar valley
swift loom
#

Am I doing something wrong here? This is just a snippet but I'm trying to update this buffer every frame.

        computeObjDataNArray = computeObjDataBuffer.BeginWrite<ComputeObjData>(0, LoT_ObjectList.Count);
        computeObjDataBufferCount = 0;

        for (int i = 0; i < LoT_ObjectList.Count; i++)
        {
            if (LoT_ObjectList[i].objData.visionType > 0)
            {
                computeObjDataNArray[i] = new ComputeObjData
                                                (
                                                    LoT_ObjectList[i].flooredPosition * 100f,
                                                    LoT_ObjectList[i].currentBuildingNr,
                                                    LoT_ObjectList[i].behindBuildingNr,
                                                    LoT_ObjectList[i].currentRoomID
                                                );
                computeObjDataBufferCount++;
            }
        }

        computeObjDataBuffer.EndWrite<ComputeObjData>(computeObjDataBufferCount);
        cShader.SetBuffer(0, "_ComputeObjData", computeObjDataBuffer);
        cShader.SetInt("_ComputeObjDataBufferCount", computeObjDataBufferCount);

But it just will not update after the first batch of data is sent

#

this is set before the dispatch

#

being set in the main thread too

#

My structs, left c# right hlsl

#

Should I not have it set to subupdates? I thought that was the right mode. Dynamic?

granite grotto
#

Hello everyone, I'm new to the discord.

sly forum
granite grotto
#

Thanks!

lunar valley
granite grotto
#

I'm just a 3d Artist. I know nothing about writing shaders. I want to know if there is a Layered Lit shader for Unity 2019.4 standard Render pipeline. My employer are not willing to change render pipelines because our project folder is so big.

#

I need to create a layered mask on the ground texture but I'm locked out of shader graph.

lunar valley
granite grotto
#

Any ideas please? Thanks a lot.

strong bear
#

bruh help

granite grotto
granite grotto
lunar valley
#

right?

lunar valley
granite grotto
lunar valley
granite grotto
strong bear
#

how to to fix

#

?

lunar valley
#

or show it to me with a screenshot

strong bear
lunar valley
# strong bear

the shader is probably not made for your render pipeline, but you can convert your materials under that tab-> Window > Rendering > Render Pipeline Converter

strong bear
lunar valley
# strong bear

yeah might not be in there because it is using a custom shader

#

if you can't code shaders you are probably screwed

strong bear
#

is not working

lunar valley
#

I noticed

granite grotto
lunar valley
#

then thats what you should do

lunar valley
grizzled bolt
#

@strong bear if your tree assets are from an asset pack, check if they have a version that's compatible with your render pipeline

lunar valley
# strong bear is not working

if it is not compatible you will need to find one that works for yours or change the shader so that it works with your pipeline

strong bear
lunar valley
# strong bear

could you check in the asset store if it is even compatible with your pipeline ^^

granite grotto
strong bear
lunar valley
granite grotto
#

I will look into it. The default terrain has layers but that's too heavy for what we are trying to do so I need a material that I can mask on a custom ground mesh using high fidelity textures.

#

That can be used with the standard render pipeline

grizzled bolt
granite grotto
kind spear
#

Is it possible to add a custom pass to unity shader graph in URP ?

swift loom
#

Nah I cannot figure out how to update my structured buffer. I've tried using buffer.SetData on an immutable structuredbuffer and on a dynamic buffer and it doesn't seem to update at all, while a SubUpdate buffer with .BeginWrite only seems to update once... idk what's going on.

swift loom
#

Tried setting it to a RWStructuredBuffer too didnt help

#

I think I fixed it somehow?? It works but not sure how

#

Maybe my stride was too LOW making it not work but giving no error??

fervent garnet
#

Hi all, I'm trying to use the Scene Depth Node in with a 2d renderer, I enabled the depth/stencil buffer option in the renderer but I still just get a gray value from the node
What could I be missing?

cobalt totem
#

Sorry this has probably been asked loads, but I have a float3 which is a vector in world space, and I need to convert it to object space (actually texture space, so bottom left corner is (0,0,0)

#

float3 samplingPos = mul(unity_WorldToObject, rayOrigin);

#

Doesn't seem to do what I had hoped

regal stag
#

That said, object space is also not necessarily the same thing as "texture space". Would depend on the mesh.

cobalt totem
#

It was working with shader graph's TransformWorldToObject() function, but now that I'm not using shader graph I have to do the conversion myself

#

It looks like they used UNITY_MATRIX_I_M, but it isn't defined for me for some reason

#

I've tried this: float3 samplingPos = mul(unity_WorldToObject, float4(rayOrigin.xyz, 1)).xyz + float3(0.5, 0.5, 0.5); but I think I may have made a mistake somewhere else

wanton grove
#

How do I read the result of a CustomRenderTexture into a Texture2D asynchronously? Whenever I try and use AsyncGPUReadback I'm getting gpu errors and I don't know why.

cobalt totem
#

Oh πŸ€¦β€β™‚οΈ I've mismatched a whole bunch of variable names so they're all defaulting to 0

#

I'll fix it tomorrow I need to sleep

inner hare
#

Hey guys, I'm new to shaders and not sure what I'm doing wrong. This is supposed to be a simple shader that scrolls my texture.

karmic hatch
inner hare
#

That definitely did something -- but is the problem with my texture or something? It all still comes up with these solid colored boxes, despite me putting in my texture

#

Here's the texture Im using

karmic hatch
regal stag
regal stag
inner hare
#

This is the tiled texture im trying to scroll

karmic hatch
#

As Cyan said if you switch it to Wrap it should loop properly

inner hare
#

oh crap, i have no idea how that got switched back

#

Thanks! that worked out well πŸ™‚

#

I'm wondering now, is there a node that can be used to give these waves a little wiggle? I'm trying to play around with Gradient Noise, for example, but no matter where I hook it up, it really distorts the waves to the point that theyre incomprehensible. Maybe I should have it move over a normal map or something?

#

I'm trying to replicate this πŸ™‚ https://www.youtube.com/watch?v=-V_Nfs5kKLM

Largest collection of Sand, Sandy, Seabed, Underwater stock video footage. https://www.naturefootage.com/video-clips/DLA191229_0002/underwater-sand-with-ripples-of-light-on-the-seabed--natural-scene-Β mediterranean-sea--spain
Underwater sand with ripples of light on the seabed, natural scene,Β Mediterranean sea, Spain

β–Ά Play video
inner hare
#

Okay, I can't figure this out haha. The closest I got was adding the value of a position node and the previous chain to cause some distortion effect. Doesn't seem to tile properly anymore, though. Do I need another texture just for the distortion? A bit confused here. I tried watching the first few Unity Learn tutorials (which is where I got the position node idea from) but it doesn't seem to agree with me.

lunar valley
inner hare
#

Sorry it's my first day with shaders so it's actually hard for me to explain

#

Oh wait, I think I am trying to create caustics. I just looked up what that means lol.

digital gust
#

Oh you want the light on the ground? Did I get you right there? πŸ˜„

inner hare
#

Yes! I do haha. Wow I'm getting a lot more google results now that I know this word hahaha.

lunar valley
inner hare
#

Exactly haha. This will help so much. I spent probably 2 hours trying to look for "2D Water Distortion Shader" and any variation of that πŸ˜‚ πŸ˜‡

digital gust
#

Let us know what you found out. I would just do a shader with two textures above moving in the speed of the waves above, but there might be something more precise in terms of lighting

inner hare
#

Will do! And great tip, that might very well be what I end up doing :).

grizzled bolt
# inner hare I *think* I'm just trying to displace the vertices. I don't even really need it ...

You most likely don't want to offset vertices if you're in 2D space because sprites and tilemaps use them very specific ways
If you want to distort a texture with shaders, you would add a value (or a texture) to the initial texture's UV coordinates
To let the distortion happen in all directions the distortion texture should be in -1 to 1 range (rather than 0 to 1 like textures usually) and contain different information on the two relevant color channels

#

If you want light caustics specifically, those are usually rendered additively below the water surface on a different sprite with an additive material or on the ground material

inner hare
#

I'll have to try some of your suggestions here -- would you say trying to render additively like you said would be the appropriate approach?

grizzled bolt
#

But it's an artistic choice to go either way

inner hare
#

It's actually just a 2d plane I'm trying to render it on, no foam, no water. Just the light (no edges or anything). I think you've given me a pretty good direction to go for tomorrow πŸ™‚ Thanks again haha

forest mason
#

Hi guys, I am looking for some advice concerning heightmap generation with Shader Graph.
A color in Shader Grap is represented by a float from 0 to 1 for each channel (rgba), corresponding to the range 0-255 (if I'm not wrong).
That means I can only create 255 height levels. What can I do to have a better height resolution?
I've tried to use the three channels (rgb) to combine them. For example, I use the blue channel for sea height variation, the green channel for land height variation and the red channel for mountains height variation.
Am I doing right?
But in this case, I have another problem. Since I want to generate islands heightmap, how can I make the blue channel (sea) not taken into account when the green channel (land) is set, but while keeping the gradient between blue and green channel (beaches)? In other terms, is there a way to apply an outline gradient to my island shape?
I don't know if it's clear for you, tell me and I'll clarify.
Thanks!

lunar valley
inner hare
digital gust
#

256 rather said, so times 3 is your resolution if you stick to rgba

#

oh yeah, you could also use Alpha as another factor if you need πŸ˜„

forest mason
#

Yep so I'm right using all channels πŸ™‚ πŸ‘πŸ»

lunar valley
forest mason
#

But the real problem is the overlying levels

inner hare
digital gust
#

So you want to distort the texture with like the good ol photoshop wiggle filter

inner hare
#

At this point I'm trying to get it to be one, tiled texture of the wave lights that doesn't move (no scrolling) aside from the gradient underlay

digital gust
#

take that πŸ˜„

inner hare
#

oh hello

#

Too bad the download 502's! time to build this by hand

lunar valley
lunar valley
inner hare
#

Maybe I don't haha. I'm going to re-read, then.

digital gust
#

Ah yeah, he might be thinking, blending is the visual additive blending. what @lunar valley means is, you lerp between texture one and two, so visually its morphing from state A to state B, which are your textures. Did I get that correct?

lunar valley
#

yes I did not mean to just add the textures together

digital gust
#

But in the shadergraph they are using only one texture and distort the UVs, as far as I can see

inner hare
#

Oh okay I totally misunderstood, my bad.

digital gust
#

There is no texture blending in the example I posted, or I am missing it πŸ˜„

lunar valley
#

I am on my phone and I can't really see the nodes

lunar valley
#

to create the distortion effect

#

jesus these nodes are tiny on my phone

inner hare
#

Mm yeah I kind of see it in the visual example, that might cause issues for players.

digital gust
inner hare
#

It works, just need to figure out how to get this to effect the entire thing and not just individual tiles

digital gust
inner hare
#

And I will learn about THAT tomorrow πŸ˜‚. I feel like everyone's first day with shaders is a big day.

How lucky am I that I have 2 or 3 people stepping in a 4 am, solving this in 30 minutes when I've been at this for 6 hours. Honestly thank you guys so much hahaha

digital gust
inner hare
#

Well I wont ping you when I'm up struggling again at 4 am YOUR time, promise hahaha

lunar valley
#

hehe

inner hare
#

You two are beasts, have a great night πŸ‘Œ

#

And you too spazi

snow forge
#

Mornin' all.

Soooo, playing around with something new today in URP ShaderGraph. I'm following along with a tutorial to make a 'shockwave' type effect but almost immediately have come across an issue.

I've matched everything the guy has done perfectly, but getting a different 'behaviour' than what's on the tutorial.

In the image attached the SmoothStep output has a hard edge, where the tutorial is showing a soft/feather edge, and I'm a bit baffled as to why it's different. πŸ˜•

Would anybody have any ideas?

#

And just for comparison, screengrab of the tutorial I'm following for the same step.

lunar valley
snow forge
#

Yeah I know, so bloody annoying, gimme a sec.

#

He keeps moving his cam window. lol.

lunar valley
#

he multiplied with .1 at the first node you only with one but that will almost definitelly not change anything

snow forge
#

Yeah, that just slows down the effect. He only changed it to 0.1 for a few seconds in the vid.

lunar valley
#

yeah..

lunar valley
snow forge
#

I shall give that a go. Baffled as to why mine is behaving differently tbh. Although having said that, with the frequency in which Unity changes things I'm not surprised. lol.

lunar valley
#

tbh. these nodes should not have changed and probably will behave the same

snow forge
#

Yeah that's what I figured. Just very confusing. lol.

forest mason
#

Hi again. I have a shader graph that gives me this. How can I adjust the gradient outlining the shape? Like a blur effect.

#

Expected result:

amber saffron
lunar valley
forest mason
forest mason
amber saffron
lunar valley
forest mason
lunar valley
#

basically with the method of that tutorial the more nodes the more samples the more blur

forest mason
#

Ok thank you, I'll try after work

cobalt totem
#

This is weird, not sure what I've done here:

#

The image is what I want, but it's being drawn on each face of the cube, instead of inside the volume

#

Key bits of code:

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

struct v2f
{
     float2 uv : TEXCOORD0;
     float4 vertex : SV_POSITION;
     float3 viewVector : TEXCOORD1;
};
#
 v2f vert (appdata v)
{
     v2f o;
     o.vertex = UnityObjectToClipPos(v.vertex);
     o.uv = v.uv;
     float3 viewVector = mul(unity_CameraInvProjection, float4(v.uv * 2 - 1, 0, -1));
     o.viewVector = mul(unity_CameraToWorld, float4(viewVector, 0));
     return o;
}
#
Cull Off ZWrite Off ZTest Always
Blend SrcAlpha OneMinusSrcAlpha
Tags { "RenderType" = "Transparent" }
amber saffron
cobalt totem
amber saffron
#

That's what I was suspecting from the message, but the image shows otherwise ^^

cobalt totem
#

What’s rendered to the surface looks correct, it just should be inside the cube

#

If I move the camera inside the cube I can move through the individual tornadoes

digital gust
#

You know how shaders and UVs and stuff work, right?

#

There is no mesh "inside" your cube. The mesh consists of the 6 individual faces

#

You can of course make a shader react to screenspace position and camera, but not sure that is actually what you putting on the faces then right now

cobalt totem
digital gust
lunar valley
cobalt totem
karmic hatch
lunar valley
# cobalt totem

ok I am on my phone right now so I didn't take that good of a look on it, but I can see that you are trying to do some sort of rayCube intersection shader

#

is this correct?

cobalt totem
#

I’m calculating the bounds as: position +/- (scale * 0.5)

lunar valley
#

And also are you making some clouds ?

lunar valley
cobalt totem
#

Also yes I'm rendering clouds, specifically in this case a tornado, but the "material" is the same

cobalt totem
regal stag
# cobalt totem ``` v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.v...

If this is being drawn to a cube mesh I'm a little confused at why the viewVector is based on uv coords like this.

float3 viewVector = mul(unity_CameraInvProjection, float4(v.uv * 2 - 1, 0, -1));
o.viewVector = mul(unity_CameraToWorld, float4(viewVector, 0));

I think this would only make sense if rendering to a fullscreen quad / blit?
For a mesh in the scene, I imagine you'd want a vector from the vertex position to camera. That would be :

o.viewVector = (_WorldSpaceCameraPos - mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1)).xyz);

(or perhaps negated, depends which direction you need to raymarch in)

#

With the samplingPos, that should also use float4(rayOrigin.xyz, 1) if it's a position, as mentioned yesterday : #archived-shaders message
Though, I imagine it may also be more performant to move your calculations to object space if you don't need the world ones. Then you don't need to do WorldToObject matrix multiplications in the loop.

#

Possible there's other problems but those are the ones I've noticed

cosmic prairie
cobalt totem
#

Thank you! I just need to check the other calculations that are being done

#

@lunar valley Cyan helped me out and it looks like I'm making good progress, just thought I would let you know to save you some time! πŸ™‚

lunar valley
lunar valley
sick knot
lunar valley
#

is that what you are asking?

sick knot
lunar valley
#
       _Color("SomeColor", Color) = (1, 1, 1, 1)```
#

and then in the pass do this:

#
float4 _Color;
lunar valley
regal stag
sick knot
#

Finally working, thank you.

cobalt totem
#

Okay so it turns out one of the assets I'm using has downsampled depth textures, potentially saving a ton of work

#

uniform UNITY_DECLARE_SCREENSPACE_TEXTURE(_CameraDepthTextureEighth);

#

That is in an external include file, I've included it using #include "../../../ExternalAssemblies/WeatherMaker/Prefab/Shaders/WeatherMakerCoreShaderInclude.cginc"

#

But how do I now access the texture?

#

The result so far BTW

lunar valley
cobalt totem
#

I'm rendering the tornado at 1/8th resolution, it drops rendering times from 30ms to about 7

lunar valley
cobalt totem
lunar valley
cobalt totem
#

Yeah, I’m just not sure if I need to prefix it or something to reference the texture

lunar valley
#

why don't you just try it out first

cobalt totem
#

I've just given it a go but get an undeclared identifier error

#

I've added the declaration UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTextureEighth); to get rid of the error, but it doesn't look like it's having any effect, one issue may be that I'm sampling with i.uv but I need a screen space coordinate instead

solar musk
#

is it possible to open this .shader file? visual studio doesn't recognize it

solar musk
#

never mind i got it

cobalt totem
#

I think I've got it working! 60fps at full HD resolution, previously it was only 20!

#

Now I just need to find a way to smooth out that aliasing from the depth buffer

sly forum
regal stag
sly forum
regal stag
sly forum
lunar valley
regal stag
cobalt totem
lunar valley
cobalt totem
lunar valley
#

Also, LastCameraDepth texture is kinda a bit unreliable, I tend to not use it

cobalt totem
#

I only render the tornado on one camera, so there’s no other scene objects if I use _CameraDepthTexture

lunar valley
cobalt totem
#

Yeah, it lets me downsample only the tornado and then upsample again

#

Or put better, render at 1/4, 1/8th resolution and upsample

lunar valley
#

aight

cobalt totem
#

Unless there’s a way to do the same on a single camera? I’m guessing that wouldn’t be as easy though

snow forge
#

I'm having a weird brain thing (it's late and it's been a very long day. lol.).

How do I get vertex height in HDRP Shadergraph?

karmic hatch
regal stag
snow forge
#

Thaaat's the one. Thanks. lol.

regal stag
#

Whether that's the "height" depends on the space, whether the object is rotated, etc.
Can use world space but then you may want to subtract the objects origin too (position from Object node)

snow forge
#

I'm doing it for a terrain just had a weird brain block. lol.

honest bison
#

How would I get started designing a compute shader to perform lods and culling on instances?

cursive jewel
#

Guys I made a shader using shader graph.. its working fine in editor.. but when I build for android its turning purple...
While building console is showing like this.

violet urchin
#

Im trying to create ground on my simple game. Is there any shader or texture setting which allows me to randomly mirror/not mirror my texture ? With U mirror and V repeat it still looks a bit repetitious.

cosmic prairie
violet urchin
cosmic prairie
#

otherwise you could round up the texture coordinates, sample a noise map with 2 channels, and sample like: texcoord.x = texcoord.x * noise.x -texcoord.x * (1 - noise.x)

#

do that with the y aswell

#

if you need further details let me know

violet urchin
lunar valley
violet urchin
cosmic prairie
lunar valley
#

and then we smooth out the edges so that there is no hard edge between the tilles but instead blends between the rotated tiles

cosmic prairie
#

Ah, I see, ty!

ionic brook
#

[Question]
Does anyone have an Idea how i could render the same object differently in two cameras? Eg. in one camera the object is lit by directional light and in the other camera the object does not get lit up by directional light?

lunar valley
snow forge
#

@lunar valley I found that channel last night and dear lord I love that guy. lol.

snow forge
#

Is it possible to colour a mesh based on the grey values of a B&W image instead of using the height of vertices?

lunar valley
snow forge
#

Black and White πŸ™‚

lunar valley
#

oh

lunar valley
snow forge
#

I've got a heightmap that I'm using that I exported out of Gaea, and have a PNG version of it to, and was just wondering if/how I'd go about using that to drive the different texture layers.

#

For example, from a height (gotten from the image) of 0 to 0.2, there would be sand, from 0.2 to 0.4 would be soil etc. etc.

lunar valley
snow forge
#

Right okay. Been trying for a while but appear to be getting nowhere. lol. (using HDRP shader graph btw). I know I need to 'normalise' the values coming out of the 'split' node, and from what I know the saturate node does that. Is that correct?

lunar valley
snow forge
#

Ah okay, but yeah I need the value coming out of the sample node to be between 0 and 1, so that makes sense πŸ™‚

lunar valley
snow forge
#

ah okay

violet urchin
lunar valley
lunar valley
violet urchin
lunar valley
fervent garnet
#

Hi all, searching for a way to mask out all of intersection with the mask, that is get a result will all of the intersections and not just cut them out like multiply would leave, cant think of anything

rigid sandal
#

Could anyone help me fix this issue?

fervent garnet
#

So in this case I want to keep all of the noise blobs that intersect the triangle

rigid sandal
shadow locust
#

so what would you expect other than an error?

rigid sandal
#

dunno

#

im new into this stuff

shadow locust
#

you can't use variables that don't exist

rigid sandal
#

okay, thanks

amber saffron
iron rain
#

Hi, i have A 2D shader but i don't know how i can output the Final processed texture for now i use that but don't work

hearty obsidian
#

Q for you all, I'm rendering my enemies line of sight. The LoS(line of sight) is a procedural mesh which I'm rendering with a default unlit transparent material. The current behaviour is that when enemies are in proximity of one another, multiple LoS renderers are drawn on top of one another and I'll get varying opacity.

Now my desired behaviour would be that all LoS are rendered as one and the opacity is the same, regardless of whether or not multiple LoS are rendered on top of one another.

How can I accomplish this? (Below is SS of current state, varying opacity of the LoS)

errant bay
#

Hello Guys, I have a problem. My texture have shapes with this thickness but in Shader graph Sample Texture 2D note see this much bigger. Could u help me? Additionaly I'm sending a screenshot of importing settings.

amber saffron
amber saffron
amber saffron
iron rain
#

and not that test image

amber saffron
iron rain
amber saffron
#

Any compilation error in the console ? Did you save the shadergraph ?

hearty obsidian
amber saffron
amber saffron
amber saffron
iron rain
amber saffron
iron rain
#

how do i do that

hearty obsidian
#

@amber saffron worked like a charm, thank you

iron rain
amber saffron
# iron rain

Please do some effort and read the page, everything is in there.
You need a "RenderPipelineAsset" to assign in this field.

snow forge
#

Okay, so this is now driving me absolutely insane.

In my head, the simple node setup I have SHOULD create a gradient-ish surface texture on the terrain (going from red to blue). But it's coming out solid red.

Been staring at this graph for so long I have no doubt I'm missing something really bloody obvious. Anyone have any ideas?

iron rain
#

my bad sorry i got to fast

#

Thank you !

amber saffron
#

If it's a unity terrain

snow forge
#

If I plug the texture I'm trying to use to drive the colouring directly into the Albedo, it fits perfectly.

amber saffron
#

And the texture is B&W, right ?

snow forge
#

Yeah.

amber saffron
#

Aaand, on the material, the two color properties are set correctly (not two reds) ?

snow forge
#

lol. So I just tried plugging a position node instead of the texture aaaaand....

#

Yeah, one blue, one red.

amber saffron
#

What happens, if you, let say, use UV.X as input for the lerp ?

snow forge
#

1 sec

amber saffron
#

Ok, so, clearly UVs are correct. But no blue ?

snow forge
#

yeah, 1 sec.

#

Okay, plugged the UV Y in.....and the 'node' preview works fine.

amber saffron
#

But not in the scene ?

snow forge
amber saffron
#

This makes me just think that the blue color property is actually set to black on the material.

snow forge
#

Oooookay. Stupid Unity. For some reason the colour wasn't changing to blue (I'd edit it, but it'd revert back to black. lol.)

#

Yaaaaay

amber saffron
#

Changing on the graph won't update on the material once it was created, as the graph is the "default" value and the material overrides it.

snow forge
#

Oh no, I meant in the inspector of the material. It just kept reverting to black. lol.

#

Taken me nearly all bloody day to get this far. lol. Thanks for the help though, really appreciated. πŸ™‚

#

Well holy poop. I appear to be making progress. lol.

idle jacinth
snow forge
#

lol....nice

snow forge
#

Uuuuh.....okay, well I appear to have broken something. lol.

Ah well, calling it a day for now, far too tired to carry on.

karmic hatch
lapis agate
#

Hello, I'm trying to use shader graph for the first time and I can't figure out why it's not working. Please let me know if this is the correct place to ask questions like this or if they should be posted somewhere else. Thank you

I'm trying to get shadows working like in this video.
https://www.youtube.com/watch?v=d_OBjV7c1CY

I've installed URP, did the debug thing to enable shadows, downloaded the shader graph and put it in the game, created a material, and placed it on the player. I've tried this in a completely separate project too and it was the same issue. So I'm thinking maybe the video is outdated or I'm just completely missing something obvious

Casting shadows from your sprites is as simple as pie. For some reason, Unity hides this by default, but I'm here to abuse the system and show you how to turn it on.

URP Shader link: https://bit.ly/34c0ttF

Original source: https://hananon.com/how-to-make-2d-sprite-cast-and-receive-shadow-in-3d-world-using-unity-shader-graph/

❀️ Become a Taro...

β–Ά Play video
rare charm
#

Is it possible to have different shader variables assigned to each mesh? Say I have a shader with a field Foo, make a material, and assign that material to two separate objects. If I change Foo on one object it changes on both.

meager pelican
#

OK, there's a couple of ways, but details vary a bit by pipeline. What pipeline are you using?

#

The easiest way is to make different material instances. So for material "MyMat" you'd have instances MyMat1 and MyMat2, and then you could assign different values for "foo" on each instance.
This gets unwieldy, though, if you need 100 or 1000 instances. So you'd want a different method. You'd want to research "Material Property blocks" in Unity's documentation. This is a GPU instancing method.

#

URP wants you to make different material instances, as it batches not by material instance but by shader.
BiRP on the other hand wants you to use one material instance and use MPB's.
MPB's may work in URP, but it would require hand-written shaders AFAIK.

rare charm
#

@meager pelican Yeah that's what I meant. I am using URP but I'll look into MPB's and see if they can be shoehorned into what I'm doing. I just don't want to have 100 materials that are different by one small value. Seems very unwieldy.

snow forge
#

Yep, the saturate node being missing was the issue.@karmic hatch Thanks for that. πŸ™‚

sick knot
#

Hi, I have a question about shaders. For a shader whirlpool effect (like https://twitter.com/i/status/1131883139301859329), would it work to add whirlpools on a plane that already has its own water shader? I'm confused on whether or not you can just visually 'overlay' shaders in Unity... if that question makes sense. I'm already using a third-party water shader and it would be nice if a separate whirlpool shader magically allowed me to add whirlpools on top of the water shader i'm already using.

scarlet pulsar
#

Hi. I want to read vertex color and pass it into my custom function of light. BUT main problem i need that vertex color should be in int32 because im using bit operation in my custom function. Is there any solution how to use custom vertex attribute format in shader graph?

lunar valley
meager pelican
#

Last I knew, Shader Graph doesn't support instancing of a variable except perhaps the BaseColor tining value.

iron rain
#

i wanna change the color per sprite how can i do it ?

cosmic prairie
regal stag
# rare charm <@573586703202254878> Yeah that's what I meant. I am using URP but I'll look int...

As Carpe has mentioned, you want to use material instances in URP (with MeshRenderers/SkinnedMeshRenderers at least). MPBs will break the SRP batching compatibility.
Creating those materials in editor may be unwieldy but you can also create them at runtime by accessing Renderer.material (which creates a copy - just be sure to destroy it along with the object in OnDestroy). Should be able to find some tutorials that explain how to use it correctly.

regal stag
# sick knot Hi, I have a question about shaders. For a shader whirlpool effect (like https:/...

In most cases you'd need to combine the shaders manually. But there are potentially some tricks that could be used, e.g. :

  • using the stencil buffer to cut out a circular portion of the water, and place a separate whirlpool object inside that.
  • or could likely render the whirlpools as separate objects, straight after the water with ZTest Always so they still appear above the water plane.
    In these cases the whirlpool would probably be a circular mesh or a quad with alpha cutout (or transparency) rather than having water around it.
regal stag
scarlet pulsar
regal stag
# scarlet pulsar anyway. reading Vertex Color im doing right using custom interpolator?

The interpolator is set to Float so only passing the red channel through. I don't know if that's what you intended (so I can't say if it's correct or not)
But if you just use the Vertex Color node (-> Split -> into the custom function) shader graph will handle interpolating for you too. A custom interpolator is more useful when you need to move a calculation to the vertex stage.

scarlet pulsar
#

Okay, I just need pas vertex color (float4) as is into my custom function. Should i still use interpolator (with type float4) ?

regal stag
iron rain
regal stag
# iron rain i wanna change the color per sprite how can i do it ?

The message at the bottom suggests a MaterialPropertyBlock is being used (perhaps by the SpriteRenderer internally, idk? I don't do much 2D). If this screenshot was taken during play mode, might be able to change them in edit mode?

Otherwise if a MPB is being used then perhaps you can use a script to change those property values. Something like

public Color replacedColor1;
public Color color1;
public Color replacedColor2;
public Color color2;

void Start(){
    UpdateColors();
}
void OnValidate(){
    UpdateColors();
}

void UpdateColors(){
    MaterialPropertyBlock mpb;
    Renderer renderer = GetComponent<Renderer>();
    renderer.GetPropertyBlock(mpb);
    mpb.SetColor("_ReplacedColor1", replacedColor1);
    mpb.SetColor("_Color1", color1);
    mpb.SetColor("_ReplacedColor2", replacedColor2);
    mpb.SetColor("_Color2", color2);
    renderer.SetPropertyBlock(mpb);
}

Check property names match, it's the "Reference" field in shader graph under the Node Settings not the actual name.

Though you'd need to be careful as this may break the dynamic batching the sprites use (which would affect performance). Can check Frame Debugger.
To keep batching, could try enabling GPU Instancing on material, but may need to move your properties into an instancing buffer inside a custom function rather than using the blackboard. https://www.cyanilux.com/faq/#sg-gpu-instancing

cobalt totem
#

Sorry I know I'm asking a million questions on here, I am trying everything I can think of before asking. I have a parent camera and a child camera, where the child camera uses the depth texture of the parent camera. This works fine, but if I disable the parent camera or gameobject, then re-enable it, the child starts rendering over the parent and seems to ignore the depth texture

iron rain
#

its was not running

cobalt totem
#

Wait.. I just fixed it. I had both tagged as MainCamera, tagging just the parent as MainCamera seems to resolve the issue

#

Setting the child to Untagged did the trick

#

Really really happy about this! πŸ˜„

cosmic prairie
#

locate the script and change the values there

#

also why do people use replaceColor like it's some magical thing

#

a colormask would be way better for changing the crewmate color

regal stag
cosmic prairie
#

I guess so... πŸ€”

regal stag
#

I know MinionsArt has a good one https://www.youtube.com/watch?v=4dAGUxvsD24

cosmic prairie
#

I'll check on it to make sure when my laptop boots

regal stag
#

Though I think sprites can also use GPU Instancing, in which case it would be using an instanced property (_RendererColor?) rather than vertex colours, since the mesh needs to be the same for each instance

cosmic prairie
valid island
#

Hello, I was wondering if someone could point me in the right direction to creating a shader that would have a similar effect to this, where the edges of the surface would be a second texture

cosmic prairie
regal stag
cosmic prairie
regal stag
#

(That assumes the ground is meshes, not unity's terrain though)

valid island
#

So there's no way of just doing it automatically with a shader?

#

The edge in my usecase is similar to this, on a mesh

cosmic prairie
#

You could do something similar, but the visual quality of it won't be as good as if you had defined them manually on the UV map from a texture

valid island
#

If it has to be done with uv mapping then that's fine, I just assumed it would be possible by doing some trickery with an outline or something

#

Yeah that's fine

#

It doesn't need to be great

#

Could you point me in the direction to accomplish that?

#

I'm not entirely sure what I'd use for it

cosmic prairie
#

I'll try to come up with something similar, gimme a few minutes

regal stag
#

In the past I've done some experiments to handle this kind of thing automatically.
Using normal vector to blend between textures. Can use triplanar mapping if no mesh uvs are available, but that is more expensive.
For the transition (grass edge), can combine normal with noise projected from above (sampled using worldPos.xz)
But manual uv mapping + texture would give you more freedom.

valid island
#

I see tioThink thank you

cosmic prairie
#

yeah that's the kind I wanted to make too, ofc you can still have different textures for the grass & stone

#

and it could use a bit of shadow when the grass transitions to stone

dull hornet
#

If i want to change the color value of Color_Skin how would I do that my current code is playerVisual.SetColor("Color_Skin", Color.red); but it doesn't work

regal stag
#

Perhaps even with a parallax effect to make it look less flat.
Though not sure if these would be possible with the method I used. Might need to play around with this πŸ€”

regal stag
dull hornet
#

it worked cheers

wide quartz
#

can someone help me please?
I want to have a rotated line from my texture 2D... like you see the red line that I drew?? I want to know how to make such a line..

regal stag
wide quartz
regal stag
wide quartz
#

and I also tried to feed it into the UV and then into the rotate.. still no

regal stag
#

You need to do it in the other order. You rotate the coordinates that go into the UV port on the Rounded Rectangle.

wide quartz
#

OOOOOOOOH

#

THANK YOU

#

if I may ask another question how do I move it up... I am now trying to move it up

#

OK FIGURED

regal stag
wide quartz
#

now I am seeing things differently

#

thank you @regal stag πŸ˜„ i am learning as i am doing things !

cosmic prairie
#

That's what I came up with @valid island

#

It's all triplanar tho and kindof expensive

regal stag
#

Nice πŸ‘

cosmic prairie
#

But this is pretty much what you can achieve

valid island
#

Oh wow, thanks lol
I wasn't asking for someone to make it for me, but I appreciate it nonetheless StellaSmile

cosmic prairie
valid island
#

It looks really nice

cosmic prairie
#

It also uses 2 power nodes besides the triplanar sampling, could maybe use a lookup texture for that

valid island
#

It's impressiveeee tamamoSmile

cosmic prairie
#

Meh, if someone has time to either manually create the transition or create a script that procedurally does it, it could look way better πŸ˜„ and a lot less computationally heavy

snow forge
#

You could (I think) add an LOD node to whatever you're using as a blending mask? Not perfect, but should let you blur the mask a bit (not looked at the graph so not sure how you're doing it)

sinful magnet
#

Hey guys, is there any way to automatically expose the values of a shader graph used in a VFX graph without creating those properties in the VFX graph itself?

snow forge
#

Would anyone have any idea what this error means? πŸ˜•

I've got a graph as a subgraph (to create a normal map from the normals of the seperate texture files). The albedo subgraph works fine. The Normals subgraph (seperate SubGraph with image type set as normal) craps out with this error when I attach it to the normal Input of the fragment shader.

snow forge
#

Aaaah, interesting

#

Thanks πŸ™‚

turbid perch
#

does anyone have an idea on how you might recreate the sokpop "joepie" shader (https://youtu.be/XatLA5SGgAs) in shadergraph? im currently just displacing the vertex posions on a timer, which kinda works for some meshes, but on cubes for example theres very visible seams where two faces split apart - as you can see in the video they dont seem to have this problem. heres a pastebin (https://pastebin.com/LZk9RHty) for the original script, which unfortunately doesnt work in URP

#

(skip to 1:40)

#

to clarify the unlit effect is of course super simple - im just running into problems with the wobble aspect of it

vital lily
#

How do i fix this? I'm going for a old school game with pointy graphics and i have dark terrain cuz the game occurs in the night,but i have this happening. How do i fix it?

#

I think this is a shader problem.

#

I have been trying for like what the past 2 hours trying to search for this but i cant get what exactly this is

turbid perch
vital lily
turbid perch
#

can you take a pic of the material youre using as your skybox?

vital lily
#

Solid black

#

Solid color,watched a tutorial how to make dark environments

#

went to settings enivorment and bla bla

turbid perch
#

the material might not be set up properly to handle being a skybox - i would create a new material to test

#

specifically like this

#

you can also just drag the material onto the sky - no need to go into settings or anything lol

regal stag
# turbid perch does anyone have an idea on how you might recreate the sokpop "joepie" shader (h...

If you're displacing vertices using noise you'd need to make sure the same coordinates are used when sampling. If it's based on mesh UVs for example those may be different for each face, (so sampling different areas of the noise, hence it splits apart)

In that original shader, you can see that they are using a Sine to handle the displacement.

v.vertex.x += sin(v.vertex.y * _YDiv + round(_Time.y * _TimeInfluence)) * _NormalOffset;
v.vertex.y += sin(v.vertex.x * _YDiv + round(_Time.y * _TimeInfluence)) * _NormalOffset;
v.vertex.z += sin(v.vertex.y * _YDiv + round(_Time.y * _TimeInfluence)) * _NormalOffset;

v.vertex here is the Position node in Object space. You'd need to Split and reconnect into a Vector3 or use a Swizzle node to reorder the components as "yxy" (or "grg")

turbid perch
#

oo thanks! that sounds very complicated and very interesting lol

#

ive only recently started to get into shadergraph and its honestly such a cool piece of tech

vital lily
#

Do i make it like normal material?

#

Or set it to skybox mobile

turbid perch
turbid perch
#

again ty

vital lily
#

Do i change the camera?

turbid perch
#

idk - is it fixed?

vital lily
#

let me test

#

Its fixed,tysm dude

turbid perch
#

nice! im happy to be the one answering for once lol

regal stag
#

I imagine as a skybox wasn't assigned it was using the Background colour there instead, which has 0 alpha as shown by the black bar. Setting it to (0,0,0,1) should also fix it, but assigning a proper skybox is probably better πŸ‘

sullen fox
#

I am completly lost on this shader. I am making a wave to a plane using sine waves. But my wavelenght is making the whole wave weird(see picture) It is only making a good result if i put 6.28 as the wavelenght value

#

amplitude set to 1 and wavelenght 10

#

Right i changed a value, in the sine wave node i changedes the x from 0.5 to a smaller number and that solved it but i dont understand why

karmic hatch
# sullen fox I am completly lost on this shader. I am making a wave to a plane using sine wav...

you want the separation between vertices in your mesh to be smaller than the wavelength/2, probably even smaller than the wavelength/4. If the separation is > wavelength/2, you get aliasing effects which basically just make it look identical to a wave with a (well-chosen) longer wavelength. If the separation is very close to the wavelength/2, neighbouring vertices will be in antiphase (so one will be up, the next will be down, and so on).

meager pelican
# regal stag The message at the bottom suggests a MaterialPropertyBlock is being used (perhap...

@rare charm This post ^^ that @regal stag put together might work for your issue if you have 1000 instances of a material that you'd need to create....you could instead use what Cyan is talking about here...GPU instancing working in URP with shader graph. If I read him right.

BUT...IDK about what properties you can and cannot use on the blackboard. I get that the instanced property would NOT be on the blackboard. But IDK about other material properties, I was unclear on that. I would assume that if they are the same properties across all the instances that use a material, that it would be OK, and that only the instanced-property need be in the "hacky" property block being forced into SG. And of course you'd need to use DrawProcedural or DrawProceduralIndirect.

#

BTW, @regal stag , nice blog post. πŸ™‚

rich seal
#

Hey guys, i have some experience with scripting shaders in unreal, but was curious if i can just use my simple shader in unity as well, but i get this error now (works fine in unreal so i think the script is ok).

/* Simple Toon Outline Shader for Unity
 * made by [---], CC-0
*/

// Calculate the angle between Camera and VertexNormal with some additional properties to manipulate the masked range
if (step(StepCount, cos(2 * PI * Period * (dot(VertexNormal, normalize(CameraPosition - Position))))))
{
    // Add additional functionalities here

    return (OutlineColor);  // RBGA Color for the Outline
}
return (FillColor);```

I use URP Lit Shader Graph
regal stag
rich seal
#

Ah okey thanks. I will change that.

regal stag
#

Also unsure if you'll be able to use if (step(StepCount, ...)) as steps returns a float, not a bool. Might be able to cast or use if (StepCount >= ...). Perhaps even specify [Flatten] before that so it doesn't create a branch.

rich seal
#

yea, looks like i have to make some little adjustments. Thank you for the informations, this definitely helps me.

thorn rover
#

anyone know where to find the "Property Sheet" ?

#

its making my shader appear pink instead of the effect i added to it

dense flare
#

Project files : https://www.patreon.com/posts/41567701
Today I am going to do a little experiment on how to render waterline, a split view of above water and underwater when we place the camera at the water level. Here what I intend to have is above the water line, there should be a normal rendering of the surrounding and under the waterline, th...

β–Ά Play video
novel garden
#

Can anyone tell me why i can do something like Cull [_Cull] in my shader to make culling mode a variable, but i cant do same with Lighting parameter?

karmic hatch
karmic hatch
#

here

dense flare
#

ive been trying to find ways to do this for like 3hours

scarlet pulsar
#

Does Shader graph has concept of executing on vertex shader or fragment like in classic approach? I have function which should execute in vertex shader and then pass data into fragment. Should i pass data through custom interpolator?

lunar valley
dense flare
dense flare
#

is it because im using a blit feature?

meager pelican
# scarlet pulsar Does Shader graph has concept of executing on vertex shader or fragment like in ...

Yes.
That's why there are two "stages" to shader graph. The Vertex inputs and the Fragment inputs. At least there are if you're using a fairly recent version.

Custom interpolators are used to pass values from vert to frag in shader graph (SG). SG will create a v2f type of structure internally. So some things like SV_Position and such are "automatic" as it can tell if it needs them from what you design. But if you need to pass a custom value from a calc in your vert() logic, that's where the custom interpolator comes in.

It's basically creating a member variable in the internal v2f that SG uses between vert and frag. Just make sure that the "connections" you make between nodes for your calc are all going in the vertex side so that "branch" of logic in the logic tree is in the vert() function and sets the value of the custom interpolator that you created in the vertex master stack. Don't try to drag frag() side stuff into the calc for that vertex() side stuff. Pretty sure SG enforces this and won't let you connect frag stuff to vert stuff. Also see limits and warnings here:
https://docs.unity3d.com/Packages/com.unity.shadergraph@13.1/manual/Custom-Interpolators.html
Note that some nodes aren't available on the vert side, but that probably won't be a problem for you as it sounds like you're converting existing working code that is designed for a vert() stage. Things that use ddx/ddy are not available in the vertex stage because rasterization hasn't been done yet. LOD levels and MIP maps come to mind, as well as the ddx/ddy functionality.

dense flare
karmic hatch
#

You already have something that cuts the water effect so it's only in the bottom half

#

So you just need to modify it so the position of the cutoff is slightly different

dense flare
karmic hatch
#

Can you post a pic of your current graph

dense flare
dense flare
#

and this is the one that cutsoff but doesnt change when rotating the camera

karmic hatch
#

can you post a bigger image; i can't read the text

dense flare
#

oh sorry

karmic hatch
#

thx

dense flare
karmic hatch
# dense flare so?

i am opening up unity, will try to make something myself and hopefully it will work

dense flare
karmic hatch
karmic hatch
#

this works and tracks where the water is cut off by the near plane; i think (except for swapping negate -> step (In) for step (Edge), which are equivalent if the other argument is 0), it is identical to before

karmic hatch
karmic hatch
# dense flare huh? what you mean?

the water is some plane, where it gets too close to the camera, it stops being rendered (where it intersects with the camera's near plane) and so the shader calculates which parts of the screen are below or above that intersection line

dense flare
#

Work*

dense flare
#

It works

#

But all i need now is for the clipping to follow with the waves

#

So i gotta digure that out

#

Figure*

karmic hatch
dense flare
dense flare
#

To like add

#

To the clipping

#

?

#

Or no

#

Cus like i saw it on the unreal engine tutorial

karmic hatch
dense flare
#

Project files : https://www.patreon.com/posts/41567701
Today I am going to do a little experiment on how to render waterline, a split view of above water and underwater when we place the camera at the water level. Here what I intend to have is above the water line, there should be a normal rendering of the surrounding and under the waterline, th...

β–Ά Play video
dense flare
#

Like 40minsnin the video

karmic hatch
#

It looks like there they're using just a plane for the water, with no waves?

#

(aside from a normal map)

karmic hatch
dense flare
karmic hatch
#

True; they could be using a vertex displacement of sine(time*frequency) and then copying that over to the cutoff part, or they could be moving the mesh with a script and having that script write to a water height property

#

But it doesn't look like it's position-dependent which is the part that would make it messy

dense flare
#

But idont know how well that will translate to shader graph

#

Im also not on my pc so i cant test it now

still orbit
#

Hey, can anyone here give me some pointers on something procedural? Basically just like the procedural rectangle node in shadergraph, but with a linear gradient out to UV edge. Either of the two outputs pictured are acceptable. Grid lines represent the width/height parameters (pictured would be 4,4).

Either shader graph or code examples are very much appreciated!

regal stag
ionic brook
still orbit
prime shale
#

Preload shaders

dense flare
still orbit
dense flare
still orbit
#

LinearEyeDepth from the depth texture for the depth of the previous fragment. screenpos.z for the current drawing one

dense flare
#

I mean yes but also no

#

I dont knwo how to check if the camera is above or underwater in shadergraph

dense flare
still orbit
#

Ah okay, as in a semi submerged camera

dense flare
#

I know how to translate shader code to shader graph so it isnt a problem

dense flare
dense flare
#

Normal*

dense flare
karmic hatch
still orbit
still orbit
#

Ill let Cyan respond, Im just guessing and only responding because I misunderstood the question πŸ™‚

regal stag
# dense flare How do you make your waterline effect?

I used a similar technique to the one described in this twitter thread, https://twitter.com/_staggart_/status/1411339746828226561
In short, using a C# script to generate a subdivided plane at camera near(ish) plane, using shader that roughly matching the water displacement.
They render this to a separate small res buffer and use it for post-process, but I just render that mesh itself, with a shader that reconstructs world pos from depth buffer to add fog/caustics/etc.

Some background on how I'm rendering the water line, because it's almost arcane πŸͺ„ #unity3d

The key goal is figuring out if a certain pixel on the screen is above, or below water. This in turn can be used to apply effects to a specific part of the screen.

Likes

832

Retweets

147

smoky flume
#

I'm studying shaders more in depth.

  1. Are projects mostly made with SRP nowadays or still built-in rendering pipeline?
  2. If in SRP, do most people use the visual node graph tool or mainly just stick to the shader source files
gusty horizon
cobalt totem
#

I've tried using Graphics.Blit(source, destination, _customMat) but it just results in a solid colour being output?

#
public class CameraVHSToggle : MonoBehaviour
{
    public RenderTexture _VHSRT;
    private Camera cam;
    [SerializeField] private Material _VHSMat;

    private void Start()
    {
        OnEnable();
    }

    private void OnEnable()
    {
        if (cam == null)
            cam = GetComponent<Camera>();
    }

    private void OnPreRender()
    {
        cam.targetTexture = _VHSRT;
    }

    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        Graphics.Blit(source, destination, _VHSMat);
    }

    private void OnPostRender()
    {
        cam.targetTexture = null;
    }
}
#

_VHSMat uses a shadergraph shader

regal stag
cobalt totem
#

Thank you, I've given it a go but it looks like there are other issues, I'm going to rewrite my VHS effect shader as a "real" shader as well

subtle cove
#

Hey, does anybody know how to make a shader with a 2d texture as input, that simply project that texture on the material but is based on the camera direction, position, etc. (Like in Valorant)? (And if possible for URP?)

#

(So that no matter where the camera is or how it's rotated, the texture looks the same and like 3 dimensional)

snow forge
#

Bit of a random one, but is/has anyone had any trouble with the URP Lit shader recently?

All of a sudden when making a build it's started to crap out on me (this is the default URP lit shader, no changes etc.)

And afterwards the shader disappears from the list, restart Unity and URP is completely broken (Package cannot be found).

thorn rover
#

I literally just opened this why is i already pink dude how do i fix this

static shore
#

What sort of shader would I need to use to achieve the flat look that these environments have?

#

If it’s something other than shaders used to create this look, I’d love to know what

subtle thicket
#

At what point do you need to start being concerned about shader performance? In an otherwise pretty non-demanding game in which there could potentially be ~20 max instances of the shader running.

#

Asking because I'm doing the outline shader hack where you sample four copies of an animated sprite and translate them in all four directions to make an outline

subtle thicket
#

Hm well if I'm reading the profiler correctly, I guess shaders have very little impact on performance

uneven fox
uneven fox
subtle thicket
#

Samping?

uneven fox
#

yes Sampling

#

It's probably not a big deal, just test your game on real device and see where it goes

hollow wolf
#

hi, did anyone know how to fix this (texture not seamless in cylinder and sphere)

#

nvm, i fix it (instead 2d text, i use triplanar instead)

lone dagger
#

There must be some irony in that compiling shaders for a build is run entirely on the CPU and its really slow

median timber
#

hey why is my thing purple whenever i make it fresh its purple but all the tutorials im following dont have this issure help?

lone dagger
#

Are you using URP?
if you are using HRDP or SRP the URP Shader graph will show pink instead of the correct oclor

proven sail
#

This is just a blank 'lit' shader that I just created, why is Unity messing with the geometry and the position?

median timber
lone dagger
median timber
#

no

lone dagger
#

not sure then.
You clicked run and it shows pink? and this is a new project setup with URP?

median timber
#

oh my god it was in the stuff i deleted

#

:(

proven sail
#

moving it around doesn't move the giant version either

#

it seems independent

lone dagger
#

is it a sprite?

proven sail
#

I've tried across several unity versions, reinstalled the shader graph several times, etc

#

no

lone dagger
#

so it is a mesh.
if you change meshes does this happen?

proven sail
#

similar/same issue no matter which mesh it's applied to

#

it's a shader thing

#

and any shader I make with the shader editor, even if it's just the default and I change nothing, throws a bunch of errors.

lone dagger
#

does the scaling issue also happen with default shaders?

#

it looks like there is some invalid transformation of the object's Matrix. Does it always stay at the origin point?

proven sail
#

just shadergraph ones

proven sail
#

Never really worked with shaders before so I'm a bit lost here. Shadergraph hasn't had these issues before either.

lone dagger
#

is your Shadergraph shader touching the Vertex properties?
messing with those can cause matrix issues.

proven sail
#

nope

#

It's just the default Lit shadergraph with a texture in the base color slot

#

considering switching to Amplify

#

I've heard good things

meager pelican
# proven sail It's just the default Lit shadergraph with a texture in the base color slot

Using SG in BiRP is kind of a "new" thing.
The errors/warnings you showed were related to instancing.
Try turning off GPU Instancing on the material, just a wild shot in the dark.
Also check the material in the inspector for other issues. Otherwise might be a bug in SG version.
If you switch the material to use the standard shader, does it fix the problem?

proven sail
#

so I needed something with a bit more customization

#

Amplify worked fine

meager pelican
#

I get that, it was just a debug action to test.

proven sail
#

I can check

meager pelican
#

Cool

proven sail
#

I'll switch it back

meager pelican
#

You've got alpha clipping now too. πŸ™‚

proven sail
#

Indeed, I didn't get that far with the shader graph

#

just created a default shader and it started freaking out so I had to pause for a bit

meager pelican
#

lol

proven sail
#

I don't see an option for GPU instancing in the shader graph, where is that?

#

usually it's just on the material for the built-in unity ones

meager pelican
#

It's on the material, set in the inspector.

proven sail
#

maybe I'm missing something

#

but I aint seeing it

meager pelican
#

huh, OK. My bad I guess.
The shader has to support instancing for it to show up, so maybe BiRP generated with SG don't? IDK

#

Maybe that's why there's warnings.
Are you on the latest version of SG?

#

I use surface shaders in BiRP, not SG.

proven sail
#

And I tried SRP and URP, both had the same issue

meager pelican
#

Wow. That shouldn't be. I'm at a loss.

#

PS URP is an SRP.

#

SRP isn't a thing in itself. It's a category.

#

Perhaps you mean HDRP?

#

I'm at a loss, I'd put that SG shader on a basic quad and see what it does.

sick knot
#

Hi, does anyone know how you'd use stencil buffers to hide everything above an intersection point? https://i.imgur.com/KwYAOig.gif Right now I have 2 planes intersecting, and I want the vertical plane to only render below the 'waves' of the horizontal plane.
or an alternative way to achieve the effect of creating color beneath a plane with moving waves? I've tried a few things but keep getting stuck.

grizzled bolt
dense flare
karmic hatch
#

the height (or minus the height) goes into the other input in the Step node

dense flare
karmic hatch
#

in the step node, in the other input, put in e.g. (amplitude*sine(time*frequency))

dense flare
#

ohh ok

dense flare
quaint coyote
#

Hello everyone! Can someone guide me/refer links on some good reads about lighting in games? Something that describes if a lighting buffer is used and other computations?

dense flare
dense flare
#

if not its fine i just wanna ask

karmic hatch
dense flare
karmic hatch
dense flare
dense flare
karmic hatch
#

try putting the property into the top slot and the thing from the add into the bottom slot; at 0:46 it looks almost there and you just need to flip which side the water is on i think

dense flare
#

orrrr

#

the edge?

#

nvm

karmic hatch
#

Which part says how high the waves go?

dense flare
karmic hatch
dense flare
#

the split node?

karmic hatch
#

however it calculates the height at some position

#

so in the shader when it was flat, it was just 0 in the other side of the step, now put your height [or perhaps minus the height] into that slot instead

dense flare
#

here is the code for the gerstner waves if its even relivant to the problem

#

@karmic hatch

karmic hatch
dense flare
#

ok

#

it works

#

but

#

its flat

#

no more wavese

#

its broken if i negate the value

karmic hatch
#

in the version where it was flat, the Add node just before the Step has the position of the points on the near plane; calculate the height of the waves from that, and then plug that into the other side of the step

dense flare
karmic hatch
dense flare
dense flare
karmic hatch
#

green is the wave height (plug in whatever wave height you want), blue is the color i've set it to; the output of the step is just 0 on one side and 1 on the other

karmic hatch
# dense flare the heck is that?

the quad has the shader applied, then i put two planes with a wave in their vertex shader. Where they're cut off is the near plane of the camera.

dense flare
karmic hatch
#

i'm sure the blit feature makes it more convenient to follow the camera and stuff; I'm just using a quad because it's a mockup for test purposes and i didn't want to set up anything complicated

dense flare
#

it works on the blit feature

#

but

#

the waves change depending on the camera rotation

karmic hatch
#

depending on camera rotation the near plane could intersect with different parts of the waves

#

two images with the same camera position, just different angles

dense flare
dense flare
dense flare
dense flare
sick knot