Shader shadow effect in coplete darkness

Hello,

I want to achieve the same shadowing as seen in the picture without using lights at all.

Is it even possible?

at the moment I have a shader that applies color only on faces that are a dot of center vector and normal vector at the distance from the radius, lerping to full transparent as seen in the second picture, but I can’t figure out how to make the shader ignore all verts that are"hidden" behind other verts of other objects.

edit.: I am using ortographic projector pointing downwards to apply material with the shader.

I’m thankful for any ideas on how_to.

the shader looks like this:

Shader "Custom/CircularScanning" {
    Properties {
        _ScannerPosition ("Scanner Position", vector) = (0, 0, 0)
        _Color ("Color Tint", Color) = (1, 1, 1, 1)
        _Radius ("Real Time Radius Value", float) = 0
        _ScanDistance ("Scan Distance", float) = 15
    }
    SubShader {
        Pass {
            Tags {
                "RenderType"="Opaque"
            }
            Blend SrcAlpha OneMinusSrcAlpha
      
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            float4 _ScannerPosition;
            float4 _Color;
            float _Radius;
            float _ScanDistance;

            struct v2f {
                float4 pos : SV_POSITION;
                float3 worldPos : TEXCOORD1;
                float3 normal : NORMAL;
            };

            v2f vert(appdata_base v) {
                v2f o;
                o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
                o.normal = v.normal;
                return o;
            }


            fixed4 frag(v2f i) : COLOR {
                float distFromCenter = distance(_ScannerPosition, i.worldPos);
                float3 toCenter = _ScannerPosition - i.worldPos;
                half dir = dot (normalize (toCenter), i.normal);
                dir = dir > 0 ? 1 : dir;
                float4 tintColor = _Color * dir;

                if (_Radius > 0 && _Radius <= _ScanDistance){ // scanner check - we're scanning; _Radius is more than 0
                    if (distFromCenter >= _Radius - 10 && distFromCenter < _Radius){ //  Inside the scanner circle: outer edge (fading into tintColor)
                        tintColor = lerp(float4(0, 0, 0, 0), tintColor, (distance (i.worldPos, _ScannerPosition)-(_Radius-10)) / 10);
                    }
                    else if (distFromCenter < _Radius - 10){ // Inside the scanner circle: inner circle
                        tintColor = float4(0, 0, 0, 0);
                    }
                    else if (distFromCenter > _Radius){ // Outside the scanner circle
                        tintColor = float4(0, 0, 0, 0);
                    }
                }

                else if (_Radius > _ScanDistance || _Radius <= 0){ // scanner check - If we're not scanning, make everything fully transparent
                    return float4(0, 0, 0, 0);
                }

                return tintColor;
            }

            ENDCG
        }
    }
    FallBack "Diffuse"
}

I am not very good with shaders, if you see some performance hammers in the code please feel free to point them out.

For shadows you need shadow maps. For shadow maps the easiest way to get them is to have a light (just because Unity does it for you). Otherwise you have to generate your own shadow maps.

Shadow maps are depth maps rendered from the point of view of the light, or in the case of point lights 6 views. So for a point light to cast shadows it has to render the scene 6 additional times. You can do the same using scripting and rendering to render textures with replacement shaders.

So, it’s possible, it’s just not as simple as adding some extra code to a shader.

Would you mind educating me a little more about the topic? I knew I’d have to make shadow maps, but most of the things I am finding is openGL documentation.

It’s a large topic requiring a fairly in-depth understanding of shaders, Unity’s script based rendering systems, and vector math.

You can try searching for custom Unity shadow map rendering, or you can attempt to pick apart the free Lab Renderer on the asset store, or the custom character shadows from the older Blacksmith demo (also on the asset store for free).