• Create Account

### #Actualunbird

Posted 21 December 2012 - 07:08 AM

@Gavins: Thanks for the clarification about the normals.

@BornToCode: +1. That's what I approximately had in mind for a FFP setup.

I also find Gavin's idea with doubling the triangles quite nice. Just add the vertices twice (with different color), once as before, once in reverse order, that should do it. With an index buffer this is even easier and less wasteful.

Transparency - or any other special/custom form of final color mixing with the background - is called blending. You enable it through
device.SetRenderState(RenderState.AlphaBlendEnable, true);


There are a couple of render states for configuration.
E.g. the usual (nonpremultiplied) alpha blending is setup through:

device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);


Now you need to provide a sensible alpha channel, in your case through vertex color. An alpha of 255 (or 1.0 normalized) will give you full opacity, 128 will blend the color about halfway with the background.

This is relatively easy to setup, but can be hard to get right. Depending on your blending mode, you may also need to draw your objects/primitives ordered (farthest first). As a workaround: Use additive blending, this is order-independant.

Hmmmm, writing a shader mini-tutorial here ? Sorry, not in the mood . You should actually find quite plenty, just not especially for SlimDX.

Still: Highly advised in the long run, since it's the way to do real-time graphics for probably a decade now. It's really fun, since you are now programming the graphics hardware, which gives higher flexibility. But it's also harder to debug and sometimes cumbersome to get things right.

If time allows start now. I advise to use the effect framework, not raw shaders. I also advise to learn about index buffer and custom vertex format, aka VertexDeclaration (since the flexible vertex format is not really flexibel. The D3DX functions D3DXDeclaratorFromFVF, D3DXFVFFromDeclarator, D3DXGetDeclVertexSize will come in handy here, they are available in SlimDX.Direct3D9.D3DX).

Edit: Ah, sorry, you already are using a declaration.

### #1unbird

Posted 21 December 2012 - 07:03 AM

@Gavins: Thanks for the clarification about the normals.

@BornToCode: +1. That's what I approximately had in mind for a FFP setup.

I also find Gavin's idea with doubling the triangles quite nice. Just add the vertices twice (with different color), once as before, once in reverse order, that should do it. With an index buffer this is even easier and less wasteful.

Transparency - or any other special/custom form of final color mixing with the background - is called blending. You enable it through
device.SetRenderState(RenderState.AlphaBlendEnable, true);


There are a couple of render states for configuration.
E.g. the usual (nonpremultiplied) alpha blending is setup through:

device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);