[BUG] Compare (A > B) in/out ports change values types
Posted: Tue Apr 11, 2017 4:28 pm
Hi, I'm getting a strange bug when using the Compare (A > B) node. When the "True" and "False" ports are pluged with two colors, both "A" and "B" input ports change their types to Color (in my oppinion these shuld be unchanged), but if I want to compare two Floats, plug "A" or "B" with a Float node is enough to change its value back to Float (both A and B). The problem starts if I go back to edit my shader a second time the shader editor will swap the A and B ports back to Color type (since A is pluged with a const float the generated color will cast this value to float4).
Frist time I plug all the values:
generated code:
Closing, reopening the shader editor and then selecting the compare node will change its B value to a color type (float4):
thus changing the generated code to this:
The strange bit is this code generate artifacts in final result, the yellow bar in between the red and green colors should not be there.
I find also other inconsistencies, that made this same node output a single channel color (black and white) with both red and green colors pluged in the True and False ports.
Edit:
Why my wires aren't color coded?
This is my shader
Frist time I plug all the values:
generated code:
- Code: Select all
float3 temp_cast_0 = ( temp_output_48_0 + ( ( temp_output_34_0 > 0.5 ) ? _TargetFaceColor : _CurrentFaceColor ) );
Closing, reopening the shader editor and then selecting the compare node will change its B value to a color type (float4):
thus changing the generated code to this:
- Code: Select all
float4 temp_cast_0 = temp_output_48_0;
o.Albedo = ( temp_cast_0 + ( ( temp_output_34_0 > float4( 0.5,0,0,0 ) ) ? _CurrentFaceColor : _TargetFaceColor ) ).rgb;
The strange bit is this code generate artifacts in final result, the yellow bar in between the red and green colors should not be there.
I find also other inconsistencies, that made this same node output a single channel color (black and white) with both red and green colors pluged in the True and False ports.
Edit:
Why my wires aren't color coded?
This is my shader
- Code: Select all
// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "MyNamespace/Transition"
{
Properties
{
[HideInInspector] __dirty( "", Int ) = 1
_CurrentFaceColor("CurrentFaceColor", Color) = (1,0,0,1)
_TargetFaceColor("TargetFaceColor", Color) = (0,1,0,1)
_Transition("Transition", Range( 0 , 1)) = 0.5
_BlendingFactor("BlendingFactor", Range( 0.001 , 1)) = 0.05
}
SubShader
{
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" }
Cull Back
CGPROGRAM
#pragma target 3.0
#pragma surface surf Standard keepalpha addshadow fullforwardshadows vertex:vertexDataFunc
struct Input
{
float2 texcoord_0;
};
uniform float _Transition;
uniform float _BlendingFactor;
uniform float4 _TargetFaceColor;
uniform float4 _CurrentFaceColor;
void vertexDataFunc( inout appdata_full v, out Input o )
{
UNITY_INITIALIZE_OUTPUT( Input, o );
o.texcoord_0.xy = v.texcoord.xy * float2( 1,1 ) + float2( 0,0 );
}
void surf( Input i , inout SurfaceOutputStandard o )
{
float temp_output_39_0 = ( _Transition * ( _BlendingFactor + 1.0 ) );
float temp_output_24_0 = ( temp_output_39_0 - _BlendingFactor );
float temp_output_34_0 = ( ( clamp( abs( lerp( -1.0 , 1.0 , i.texcoord_0.y ) ) , temp_output_24_0 , temp_output_39_0 ) - temp_output_24_0 ) / _BlendingFactor );
o.Albedo = ( ( temp_output_34_0 > float4( 0.5,0,0,0 ) ) ? _TargetFaceColor : _CurrentFaceColor ) .rgb;
o.Alpha = 1;
}
ENDCG
}
Fallback "Diffuse"
CustomEditor "ASEMaterialInspector"
}
/*ASEBEGIN
Version=6001
142;203;1276;772;1140.299;170.1858;1;True;False
Node;AmplifyShaderEditor.RangedFloatNode;25;-2248.888,407.6957;Float;False;Property;_BlendingFactor;BlendingFactor;2;0;0.05;0.001;1;FLOAT
Node;AmplifyShaderEditor.SimpleAddOpNode;40;-1968.29,305.6659;Float;False;0;FLOAT;0.0;False;1;FLOAT;1.0;False;FLOAT
Node;AmplifyShaderEditor.TextureCoordinatesNode;5;-2155.088,-93.7033;Float;False;0;-1;2;0;FLOAT2;1,1;False;1;FLOAT2;0,0;False;FLOAT2;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.RangedFloatNode;3;-2259.71,133.5999;Float;False;Property;_Transition;Transition;2;0;0.5;0;1;FLOAT
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;39;-1851.886,143.6646;Float;False;0;FLOAT;0.0;False;1;FLOAT;0.0;False;FLOAT
Node;AmplifyShaderEditor.LerpOp;9;-1902.485,-94.60487;Float;False;0;FLOAT;-1.0;False;1;FLOAT;1.0;False;2;FLOAT;0.0;False;FLOAT
Node;AmplifyShaderEditor.AbsOpNode;10;-1734.485,-94.90546;Float;True;0;FLOAT;0.0;False;FLOAT
Node;AmplifyShaderEditor.SimpleSubtractOpNode;24;-1706.579,240.5968;Float;False;0;FLOAT;0.0;False;1;FLOAT;0.0;False;FLOAT
Node;AmplifyShaderEditor.ClampOpNode;21;-1529.379,95.29521;Float;False;0;FLOAT;0.0;False;1;FLOAT;0.0;False;2;FLOAT;0.0;False;FLOAT
Node;AmplifyShaderEditor.SimpleSubtractOpNode;32;-1320.996,96.06426;Float;False;0;FLOAT;0.0;False;1;FLOAT;0.0;False;FLOAT
Node;AmplifyShaderEditor.SimpleDivideOpNode;34;-1086.495,380.9645;Float;True;0;FLOAT;0.0;False;1;FLOAT;0.0;False;FLOAT
Node;AmplifyShaderEditor.ColorNode;1;-798.2981,-67.89948;Float;False;Property;_CurrentFaceColor;CurrentFaceColor;0;0;1,0,0,1;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.ColorNode;2;-795.5972,98.29967;Float;False;Property;_TargetFaceColor;TargetFaceColor;1;0;0,1,0,1;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.AbsOpNode;42;-683.2822,503.7646;Float;False;0;FLOAT;0.0;False;FLOAT
Node;AmplifyShaderEditor.SimpleAddOpNode;43;-559.0831,504.0647;Float;False;0;FLOAT;0.0;False;1;FLOAT;0.0;False;FLOAT
Node;AmplifyShaderEditor.SimpleSubtractOpNode;41;-839.9818,506.5649;Float;False;0;FLOAT;0.5;False;1;FLOAT;0.5;False;FLOAT
Node;AmplifyShaderEditor.LerpOp;51;-515.2081,140.9646;Float;False;0;COLOR;0.0;False;1;COLOR;0,0,0,0;False;2;FLOAT;0.0;False;COLOR
Node;AmplifyShaderEditor.SimpleAddOpNode;49;-189.4057,501.165;Float;False;0;FLOAT;0.0;False;1;FLOAT;0.01;False;FLOAT
Node;AmplifyShaderEditor.SimpleSubtractOpNode;48;-441.0061,502.2653;Float;True;0;FLOAT;1.0;False;1;FLOAT;1.0;False;FLOAT
Node;AmplifyShaderEditor.SimpleAddOpNode;47;-252.306,162.5649;Float;False;0;FLOAT;0.0;False;1;FLOAT;0;False;FLOAT
Node;AmplifyShaderEditor.TFHCCompareGreater;58;-473.299,-110.1858;Float;False;0;FLOAT;0,0,0,0;False;1;COLOR;0.5,0,0,0;False;2;COLOR;0.0;False;3;COLOR;0.0;False;COLOR
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;22.40005,161.8;Float;False;True;2;Float;ASEMaterialInspector;Standard;MyNamespace/Transition;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;0;False;0;0;Opaque;0.5;True;True;0;False;Opaque;Geometry;All;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;False;0;255;255;0;0;0;0;False;0;4;10;25;False;0.5;True;0;Zero;Zero;0;Zero;Zero;Add;Add;0;False;0;0,0,0,0;VertexOffset;False;Cylindrical;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0.0;False;4;FLOAT;0.0;False;5;FLOAT;0.0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0.0;False;9;FLOAT;0.0;False;10;OBJECT;0.0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;13;OBJECT;0.0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False
WireConnection;40;0;25;0
WireConnection;39;0;3;0
WireConnection;39;1;40;0
WireConnection;9;2;5;2
WireConnection;10;0;9;0
WireConnection;24;0;39;0
WireConnection;24;1;25;0
WireConnection;21;0;10;0
WireConnection;21;1;24;0
WireConnection;21;2;39;0
WireConnection;32;0;21;0
WireConnection;32;1;24;0
WireConnection;34;0;32;0
WireConnection;34;1;25;0
WireConnection;42;0;41;0
WireConnection;43;0;42;0
WireConnection;43;1;42;0
WireConnection;41;1;34;0
WireConnection;51;0;2;0
WireConnection;51;1;1;0
WireConnection;51;2;34;0
WireConnection;49;0;48;0
WireConnection;48;1;43;0
WireConnection;47;0;48;0
WireConnection;58;0;34;0
WireConnection;58;2;2;0
WireConnection;58;3;1;0
WireConnection;0;0;58;0
ASEEND*/
//CHKSM=D73986BA0D58769C53B1235CDDBC87C2DCCF06B9