FreshRSS

Normální zobrazení

Jsou dostupné nové články, klikněte pro obnovení stránky.
PředevčíremHlavní kanál
  • ✇Recent Questions - Game Development Stack Exchange
  • Unity shader invalid subscript worldPosWestMansionHero
    I am trying to write a shader for Unity that replicates Splatoon's painting system, but I cannot get the shader to compile. It has an error on line 41 stating invalid subscript 'worldPos' at line 41 (on d3d11). I'm unsure what this means, and my research came up short. I tried a few different things but nothing worked. I switched my shader to unlit which solved another problem with the v2f not being recognized, but now there's this problem. Below is the code. Shader "Unlit/TexturePaintingMechani
     

Unity shader invalid subscript worldPos

I am trying to write a shader for Unity that replicates Splatoon's painting system, but I cannot get the shader to compile. It has an error on line 41 stating invalid subscript 'worldPos' at line 41 (on d3d11). I'm unsure what this means, and my research came up short. I tried a few different things but nothing worked. I switched my shader to unlit which solved another problem with the v2f not being recognized, but now there's this problem. Below is the code.

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

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

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

            struct v2f
            {
                float2 uv : TEXCOORD0;
                UNITY_FOG_COORDS(1)
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;

                v2f vert(appdata v)
            {
            v2f o;
            o.worldPos = mul(unity_ObjectToWorld,v.vertex);
            o.uv = v.uv;
            float4 uv = float(0,0,0,,1);
            uv.xy = (v.uv.xy * 2-1) * float2(1,_ProjectionParams.x);
            o.vertex = uv;
            return o;
             }

        float mask(float3 position, float3 center, float radius, float hardness)
        {
            float m = distance(center,position);
            return 1- smoothstep(radius * hardness,radius,m);
        }

        fixed4 frag(v2f i) : SV_Target{
            float m= mask(i.worldPos, _PainterPosition,_Radius, _Hardness);
            float edge = m * _Strength;
            return lerp(float4(0,0,0,0), float4(1,0,0,1),edge);
        }

            ENDCG
        }
    }
}
❌
❌