Discussion:
Point Sprites and Clipping or Culling
(too old to reply)
kg
2010-02-09 16:22:01 UTC
Permalink
I am thinking that I might be missing something simple. I am actually using a
farly modified verion of the World Wind 1.4 C# SDK and created a new point
sprite plotting layer. So far, we have managed to get very good preformance
with very large point counts.

Now, my new issus is when rendering with terrain, points get terrain mapped,
however, when rotatting the view, there is no clipping or culling occuring,
so the points are always visible, even behind the terrain.

The following is the relevent part of the render call:

drawArgs.device.RenderState.Lighting = World.Settings.EnableSunShading;
drawArgs.device.RenderState.ColorVertex = true;
drawArgs.device.RenderState.AlphaBlendEnable = true;
drawArgs.device.RenderState.AntiAliasedLineEnable = true;
drawArgs.device.VertexFormat = SpriteVertexFormat.Format;
drawArgs.device.VertexDeclaration = this.myPointSpriteVD;

drawArgs.device.RenderState.PointSpriteEnable = true;
drawArgs.device.RenderState.PointScaleEnable = true;
drawArgs.device.RenderState.PointScaleA = 100f;
drawArgs.device.RenderState.PointScaleB = 0f;
drawArgs.device.RenderState.PointScaleC = 0f;
drawArgs.device.RenderState.PointSize = 32.0f; // point
sprite pixel size
drawArgs.device.RenderState.PointSizeMin = 1.0f;
drawArgs.device.RenderState.ZBufferEnable = true;
drawArgs.device.RenderState.ZBufferWriteEnable = true;
drawArgs.device.RenderState.Clipping = true;
drawArgs.device.RenderState.ColorVertex = true;
drawArgs.device.RenderState.AlphaBlendEnable = true;
drawArgs.device.RenderState.AlphaSourceBlend = Blend.One;
drawArgs.device.RenderState.AlphaDestinationBlend =
Blend.One;

Matrix translationMat = drawArgs.device.Transform.World *
drawArgs.WorldCamera.ViewMatrix * drawArgs.WorldCamera.ProjectionMatrix;

pEffect.Technique = pEffectTechnique;

pEffect.SetValue("xWorldViewProjection",
translationMat);
pEffect.SetValue("xNorthHeading",
-((float)drawArgs.WorldCamera.Heading.Degrees));
pEffect.SetValue("xPointSpriteTexture", pTexture);
pEffect.SetValue("xPointScale",
myPointSizeMultiplier);
pEffect.SetValue("xOpacity", (float)myOpacity);

drawArgs.device.SetStreamSource(0,
this.myVertexBuffer, 0);
//drawArgs.device.SetTexture(0, myTexture);

int numpasses = pEffect.Begin(0);

for (int i = 0; i < numpasses; i++)
{
pEffect.BeginPass(i);

drawArgs.device.DrawPrimitives(PrimitiveType.PointList, 0, myVertexSize);
pEffect.EndPass();
}

pEffect.End();


So, I guss I have two questions:
1. Is it possible to have culling or clipping on textured Point Sprites?
2. If Yes to 1, is there an example ? :)

Thanks for any help!
kg
2010-02-10 02:09:01 UTC
Permalink
Never mind, I was clearing the zbuffer, just missed it.
Post by kg
I am thinking that I might be missing something simple. I am actually using a
farly modified verion of the World Wind 1.4 C# SDK and created a new point
sprite plotting layer. So far, we have managed to get very good preformance
with very large point counts.
Now, my new issus is when rendering with terrain, points get terrain mapped,
however, when rotatting the view, there is no clipping or culling occuring,
so the points are always visible, even behind the terrain.
drawArgs.device.RenderState.Lighting = World.Settings.EnableSunShading;
drawArgs.device.RenderState.ColorVertex = true;
drawArgs.device.RenderState.AlphaBlendEnable = true;
drawArgs.device.RenderState.AntiAliasedLineEnable = true;
drawArgs.device.VertexFormat = SpriteVertexFormat.Format;
drawArgs.device.VertexDeclaration = this.myPointSpriteVD;
drawArgs.device.RenderState.PointSpriteEnable = true;
drawArgs.device.RenderState.PointScaleEnable = true;
drawArgs.device.RenderState.PointScaleA = 100f;
drawArgs.device.RenderState.PointScaleB = 0f;
drawArgs.device.RenderState.PointScaleC = 0f;
drawArgs.device.RenderState.PointSize = 32.0f; // point
sprite pixel size
drawArgs.device.RenderState.PointSizeMin = 1.0f;
drawArgs.device.RenderState.ZBufferEnable = true;
drawArgs.device.RenderState.ZBufferWriteEnable = true;
drawArgs.device.RenderState.Clipping = true;
drawArgs.device.RenderState.ColorVertex = true;
drawArgs.device.RenderState.AlphaBlendEnable = true;
drawArgs.device.RenderState.AlphaSourceBlend = Blend.One;
drawArgs.device.RenderState.AlphaDestinationBlend =
Blend.One;
Matrix translationMat = drawArgs.device.Transform.World *
drawArgs.WorldCamera.ViewMatrix * drawArgs.WorldCamera.ProjectionMatrix;
pEffect.Technique = pEffectTechnique;
pEffect.SetValue("xWorldViewProjection",
translationMat);
pEffect.SetValue("xNorthHeading",
-((float)drawArgs.WorldCamera.Heading.Degrees));
pEffect.SetValue("xPointSpriteTexture", pTexture);
pEffect.SetValue("xPointScale",
myPointSizeMultiplier);
pEffect.SetValue("xOpacity", (float)myOpacity);
drawArgs.device.SetStreamSource(0,
this.myVertexBuffer, 0);
//drawArgs.device.SetTexture(0, myTexture);
int numpasses = pEffect.Begin(0);
for (int i = 0; i < numpasses; i++)
{
pEffect.BeginPass(i);
drawArgs.device.DrawPrimitives(PrimitiveType.PointList, 0, myVertexSize);
pEffect.EndPass();
}
pEffect.End();
1. Is it possible to have culling or clipping on textured Point Sprites?
2. If Yes to 1, is there an example ? :)
Thanks for any help!
Loading...