- Home /
Additional blending when using properties rather than hard-coded values for colors
TL;DR - Hard-coding a color value and using the same value via a property produces different results -- why?
I'm trying to understand shaders right now, and I've run into what seems like an anomaly while writing a CGPROGRAM. I've written the following, using a hard coded value for red:
...
vertexOutput vert(vertexInput vi){
vertexOutput vo;
if (vi.normal.x > .9f)
vo.color = float4(255,0,0,255);
vo.vertex = mul(UNITY_MATRIX_MVP, vi.vertex);
return vo;
}
...
And the results looked like this:
I then re-wrote the same code, but used a property to contain that value rather than hard code it
...
Properties {
_Color_Normal_1_0_0 ("Color_Normal_1_0_0", color) = (1.0,1.0,1.0,1.0)
}
...
vertexOutput vert(vertexInput vi){
vertexOutput vo;
if (vi.normal.x > .9f)
vo.color = _Color_Normal_1_0_0;
vo.vertex = mul(UNITY_MATRIX_MVP, vi.vertex);
return vo;
}
...
Using properties:
Why would the two be different if they contain the same value?
Your answer
Follow this Question
Related Questions
How to update a materials' shader properties using JavaScript 2 Answers
Shaders: Constant register limit exceeded - what does it mean? 2 Answers
BlendOps on mobile not supported? 1 Answer
Tool for blending maps for Unity materials 0 Answers
Alpha Blending for projectors on transparent/cutout materials 0 Answers