- Home /
Logical BlendOp not working
I am attempting to voxelize the scene through a logical blending operation using the dx 11.1 blend ops referenced here. However, this appears to have no effect in viewing the rendered result.
I am using the dx 11 option in the player settings, and other blend modes, such as Min, Max, etc. seem to work fine. Any ideas or suggestions on what might be causing the problem are greatly appreciated.
Thank you!
Shader Code:
Shader "Hidden/T_Voxelize"
{
Properties
{
_MainTex("Base (RGB)", 2D) = "black" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
};
struct v2f
{
float4 vertex : SV_POSITION;
float vdist : TEXCOORD0;
};
uniform sampler2D _MainTex;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MV, v.vertex);
o.vdist = -o.vertex.z;
o.vertex = mul(UNITY_MATRIX_P, o.vertex);
return o;
}
float4 frag (v2f i) : SV_Target
{
int shift = floor(i.vdist / _ProjectionParams.z * 127 + 0.5);
float rshift = shift > 31 ? 0 : 1 << shift;
float gshift = shift > 63 || shift < 32 ? 0 : 1 << (shift - 32);
float bshift = shift > 95 || shift < 64 ? 0 : 1 << (shift - 64);
float ashift = shift < 96 ? 0 : 1 << (shift - 96);
return float4(rshift, gshift, bshift, ashift);
}
ENDCG
SubShader
{
Pass
{
Fog { Mode Off }
ZTest Always Cull Off ZWrite Off
Blend One One
BlendOp LogicalOr
CGPROGRAM
#pragma target 5.0
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
}
Comment
Correct, although it does not work in linear either.