adam41, Thanks for replying.
Quote:Setting alpha to 0 will only remove the pixel if alpha blending is enabled, and the pixel shader does something with that per vertex alpha value (which will get interpolated between vertices).
I checked that by changing the code to:
if (MyByteValue==0) // instead of: "MyByteValue>0"{ Particle.Diffuse.a=0;}
and now the geometry disappears. That means MyByteValue is definitely zero and the test code is correct.
Quote:Can you post the whole shader (in [ source ] tags)?
Here's an outline of my shader:
VS_OUTPUT Main( float4 startPosition : Position0,float4 startVelocity: Position1,float1 lifetime: TEXCOORD0,float1 illuminationTime: TEXCOORD1,float1 brightness: TEXCOORD2,float1 particleSize: TEXCOORD3,float1 timeOffset: TEXCOORD4,float1 mass: TEXCOORD5,float4 color: Color0,float4 variousData: Color1{ float localTime=Time+timeOffset; VS_OUTPUT Particle; if (localTime>lifetime || localTime<illuminationTime) { Particle.Position.xyzw=-12345; Particle.Diffuse=(float4)1; Particle.Size=Particle.tex0=0; } else { Particle.Position = ...; Particle.Position = mul(Particle.Position, WorldViewProjection); Particle.Diffuse = ...; Particle.Size = 3; int myByteValue = (int)(variousData.x*255.0); if (myByteValue==0) { Particle.Diffuse.a=0; // if I comment out this line, the geometry is visible. } } return Particle;}
This shader makes the geometry disappear. If I comment out the test code (see above), the geometry is visible. IMHO, myByteValue must be zero.
And my vertex declaration is correct, isn't it?
.., new VertexElement(0, 48, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0), new VertexElement(0, 52, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 1), ..
Color takes 4 bytes, and 48+4 = 52.
I tried using the TEXCOORD semantic, but same result. I also tried reversing Color0 and Color1 inside the vertex structure.
Any other ideas?