Question by
oxygen77 · Jan 13, 2020 at 03:09 AM ·
c#shader programmingsurface shader
color array in Unity Surface Shader causing weird aliasing
I am tring to use color array in my surface shader, the code is
Shader "Custom/HexInteract"
{
Properties
{
_Alpha("Alpha", Range(0, 1)) = 1
}
SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
LOD 200
Offset -1, -1
CGPROGRAM
#pragma surface surf Standard noshadow vertex:vert alpha
#pragma target 3.0
#include "ShaderData.cginc"
#include "Interact.cginc"
struct Input
{
float4 splatColor : COLOR;
float2 uv_MainTex;
float4 cellParameter;
float testFloat;
};
float _Alpha;
UNITY_INSTANCING_BUFFER_START(Props)
UNITY_INSTANCING_BUFFER_END(Props)
void vert(inout appdata_full v, out Input data)
{
UNITY_INITIALIZE_OUTPUT(Input, data);
**data.testFloat = 1;**
}
void surf (Input IN, inout SurfaceOutputStandard o)
{
**o.Albedo = InteractColor[IN.testFloat];**
o.Alpha = _Alpha;
}
ENDCG
}
FallBack "Diffuse"
}
but it causing weird aliasing result rather than a pure color:
what could be the reason causing this problem??
aliasing.png
(10.3 kB)
Comment
const fixed4 InteractColor[] =
{
fixed4(0, 0, 0, 0), //prefered
fixed4(0.5, 0.5, 0.5, 0.5), //natural
fixed4(1, 1, 1, 1) //negtive
};
Your answer
Follow this Question
Related Questions
highlight selected object 0 Answers
Outline Shader in VR 0 Answers
,Help Changing a "Doom" Style Billboard Shader to a Surface Shader 0 Answers
Problem with surface shader using uv2 1 Answer
GPU Instancing with Surface Shader 0 Answers