I want to draw a cube to a RenderTexture and then display that texture somewhere else (UI primarily)
This cube needs to be able to support anti-aliasing.
The issue I’m running into is that the edges of the cube get anti-aliased with the “Clear Flags” color of the camera, leaving a nasty edge artifact when displaying the image on a different color background.
Exact setup:
-
Camera
-
Clear Flags: Solid Color
-
Background: RGBA 255 255 255 0
-
Target Texture: RenderTexture
-
RenderTexture
-
Anti-aliasing: 8 samples
-
Cube - drawn by camera above
-
Shader: Custom shader (see below)
-
45° rotation on all axes
-
Color: RGBA 98 112 140 255
-
Plane - outside camera, only visible in editor
-
Material created by dragging the RenderTexture onto the plane
-
Shader: Unlit/Transparant
Custom shader:
Shader "Unlit Color Only" {
Properties {
_Color ("Color", Color) = (0,0,0,0)
}
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend One OneMinusSrcAlpha
Color [_Color]
Pass {}
}
}
The edge artifact result:
The color of the edge is derived from the clear color of the camera.
How can I get rid of these edge artifacts while maintaining anti-aliasing transparency?