public class VertexColorShader : IPixelShader { float3[] vertexColors = new[] { new float3(1.0f, 0.0f, 0.0f), new float3(0.0f, 1.0f, 0.0f), new float3(0.0f, 0.0f, 1.0f), }; public float3 GetColor(float3 barycentric, int screenX, int screenY, int frame) { float amount1 = MathF.Cos(frame * 0.02f) * 0.5f + 0.5f; float amount2 = MathF.Sin(frame * 0.02f) * 0.5f + 0.5f; float3 c1 = new float3(vertexColors[0].x * amount1, vertexColors[0].y * amount1, vertexColors[0].z * amount1); float3 c2 = new float3(vertexColors[1].x * amount2, vertexColors[1].y * amount2, vertexColors[1].z * amount2); float3 color = barycentric.x * c1 + barycentric.y * c2 + barycentric.z * vertexColors[2]; // if((int)(screenX + MathF.Cos(frame * 0.02f) * 30) % 5 == 0 && (int)(screenY + MathF.Sin(frame * 0.02f) * 30) % 5 == 0) color += new float3(0.0f, 0.25f, 0.0f); if((int)(screenX) % 5 == 0 && (int)(screenY) % 5 == 0) color += new float3(0.0f, 0.25f, 0.0f); return color; } }