Skip to content

Depth rendering in AWSIM #393

@tomasz-naklicki

Description

@tomasz-naklicki

Hi! I'm trying to add a depth camera simulation to AWSIM as part of a university project. I prepared a shader based on a different project that involved depth rendering I found on the internet, and it works for this version of Unity (tested in a blank project). This is what the shader looks like:

Shader "Hidden/DepthShader"
{
    Properties
    {
        _MainTex ("", 2D) = "white" {}
    }

    SubShader
    {
        CGINCLUDE
        float4 Output(float depth01)
        {
            float k = 0.25;
            return depth01;
        }

        ENDCG

        Tags { "RenderType" = "Opaque" }
        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            struct v2f
            {
                float4 pos : SV_POSITION;
                float depth : TEXCOORD0;
                UNITY_VERTEX_OUTPUT_STEREO
            };

            v2f vert(appdata_base v)
            {
                v2f o;
                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
                o.pos = UnityObjectToClipPos(v.vertex);
                o.depth = COMPUTE_DEPTH_01;
                return o;
            }

            fixed4 frag(v2f i) : SV_Target
            {
                return Output(i.depth);
            }
            ENDCG
        }
    }

    Fallback Off
}

The problem is, it doesn't seem to work inside AWSIM project - my guess is that it's because of the render pipeline. Since I'm not familiar with the render pipeline used in AWSIM, are there any tips or ways to make the shader work inside AWSIM project? Or are there other recommended ways to generate a depth image in Unity, more suitable for AWSIM? Any help is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions