#Trying to replicate the outline of 'return of the obra dinn'

1 messages · Page 1 of 1 (latest)

coral bluff
#

Hello, as a relative beginner I've been trying to replicate the content explained in the devlogs of return of the obra dinn, specifically the outline described in the posts made by the developer on the pages 2, 3 and 5 on the forum: https://forums.tigsource.com/index.php?topic=40832.80

I suppose I need 2 shaders for the effect. The first shader sections the different faces of the meshes, preparing them for outlining. The second one detects the edges on the resulting sections and creates outlines with a fullscreen pass.

I did manage to make the sectioning and the outlining work by following the instructions from the devlogs and getting help from LLMs. However, there is one part I really can't figure out about the sectioning and it makes me get unwanted lines when the faces do not have the same exact normal.

#

here is how my sectioning pass looks. All faces that do not share the exact same normals have different colors, and the outline pass just checks the color differences. so it makes sense why it creates those lines.

#

Here is how the original games sectioning pass looks.

#

the curved paths, like the cylinder at the left or the ramp i arrowed obviously have multiple faces that do not have the same normals, yet they are sectioned the same color, and I have no idea how it is done.

#

For the sectioning part the developer shares some chunk of code, and I am using the exact same thing. The solution for this is not shared, and I have no idea how that works.

#

Here is my sectioning code.

Shader "Custom/SectionColor"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    
    SubShader
    {
        Tags { "RenderType"="Opaque" "RenderPipeline"="UniversalPipeline" }
        LOD 100

        Pass
        {
            Name "SectionColor"
            
            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            
            struct Attributes
            {
                float4 positionOS : POSITION;
                float3 normalOS : NORMAL;
                float4 color : COLOR;
            };
            
            struct Varyings
            {
                float4 positionCS : SV_POSITION;
                float3 color : COLOR;
            };
            Varyings vert(Attributes input)
            {
                Varyings output;
                output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
                float3 origin = TransformObjectToWorld(float3(0.0, 0.0, 0.0));
                float3 area = float3(100, 100, 100);

                float3 cameraDir = mul((float3x3)UNITY_MATRIX_V,float3(0,0,1));
                float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
                normalWS *= input.color.r;
                float light = saturate((dot(normalWS, cameraDir) + 1.0) * 0.5);
                
                output.color = ((origin + area) * 0.5) / area;
                output.color.x *= light;
                output.color.y /= light;
                output.color *= input.color.g;
                output.color = frac(output.color * 100);
                
                return output;
            }
            
            float4 frag(Varyings input) : SV_Target
            {
                return float4(input.color, 1.0);
            }
            ENDHLSL
        }
    }
}

shell bronze
wispy latch
#

yeah, that looks like it's just vetex colors