Hi, please help me resolve next problems:
1) how to draw triangle list and line list (like this http://imageshack.us...capture2pu.png/)
with different colours from one vertex buffer? I have 1 buffer which contains points and colors. I have 2 index buffers for it (for line list and triangle list). I want to draw triangles with color from buffer and white (or black or whatever) lines.
2) I've tried to implement shaders to make different front and back triangle colors, but it doesn't work:
//drawing function:
private void RedrawPrimitives()
{
var effect = Effect.FromFile(d3dDevice, "Shader.fx", ShaderFlags.None);
var technique = effect.GetTechnique(0);
var pass = effect.GetPass(technique, 0);
d3dDevice.VertexFormat = myVertexFormat;
d3dDevice.VertexDeclaration = vertexDecl;
d3dDevice.Clear(ClearFlags.Target, SharpDX.Color.White, 1.0f, 0);
d3dDevice.BeginScene();
effect.Technique = technique;
effect.Begin();
effect.BeginPass(0);
d3dDevice.Indices = triangles;
d3dDevice.SetStreamSource(0, vertices, 0, Marshal.SizeOf(typeof(Vertex)));
d3dDevice.DrawIndexedPrimitive(PrimitiveType.TriangleList, 0, 0, totalPointsCount, 0, totalPointsCount / 2);
d3dDevice.Indices = lines;
d3dDevice.SetStreamSource(0, vertices, 0, Marshal.SizeOf(typeof(Vertex)));
d3dDevice.DrawIndexedPrimitive(PrimitiveType.LineList, 0, 0, totalPointsCount, 0, totalPointsCount);
effect.EndPass();
effect.End();
d3dDevice.EndScene();
d3dDevice.Present();
effect.Dispose();
technique.Dispose();
pass.Dispose();
}
//and shader (which doesn't work)
sampler s0;
struct VertexShaderInput
{
float4 Position : POSITION0;
float4 Color : COLOR0;
float4 face : VFACE;
// TODO: add input channels such as texture
// coordinates and vertex colors here.
};
struct VertexShaderOutput
{
float4 Position : POSITION0;
float4 Color : COLOR0;
// TODO: add vertex shader outputs such as colors and textureasdfasd
// coordinates here. These values will automatically be interpolated
// over the triangle, and provided as input to your pixel shader.
};
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
output.Position = mul(input.Position, input.Color);
output.Color=input.Color;
// TODO: add your vertex shader code here.
return output;
}
float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
{
float4 color = tex2D(s0, coords);
color.rgb = color.r;
return color;
}
technique Technique1
{
pass Pass1
{
VertexShader = compile vs_2_0 VertexShaderFunction();
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}