1 module evael.graphics.Vertex; 2 3 import std.conv : to; 4 5 import evael.graphics.GL; 6 7 import evael.utils.Math; 8 import evael.utils.Color; 9 10 alias Vertex2PositionColor = VertexPositionColor!2; 11 alias Vertex2PositionColorTexture = VertexPositionColorTexture!2; 12 alias Vertex2PositionColorNormal = VertexPositionColorNormal!2; 13 14 alias Vertex3PositionColor = VertexPositionColor!3; 15 alias Vertex3PositionColorTexture = VertexPositionColorTexture!3; 16 alias Vertex3PositionColorNormal = VertexPositionColorNormal!3; 17 18 struct ShaderAttribute 19 { 20 int layoutIndex; 21 int type; 22 int size; 23 bool normalized; 24 } 25 26 struct VertexPositionColor(int positionCount) 27 { 28 // Name in shader, type of data, count of data, normalized ? 29 @ShaderAttribute(0, GLType.Float, positionCount, false) 30 public Vector!(float, positionCount) position; 31 32 @ShaderAttribute(1, GLType.UByte, 4, true) 33 public Color color; 34 } 35 36 struct VertexPositionColorTexture(int positionCount) 37 { 38 @ShaderAttribute(0, GLType.Float, positionCount, false) 39 public Vector!(float, positionCount) position; 40 41 @ShaderAttribute(1, GLType.UByte, 4, true) 42 public Color color; 43 44 @ShaderAttribute(2, GLType.Float, 2, false) 45 public vec2 textureCoordinate; 46 } 47 48 struct VertexPositionColorNormal(int positionCount) 49 { 50 @ShaderAttribute(0, GLType.Float, positionCount, false) 51 public Vector!(float, positionCount) position; 52 53 @ShaderAttribute(1, GLType.UByte, 4, true) 54 public Color color; 55 56 @ShaderAttribute(2, GLType.Float, 3, true) 57 public vec3 normal; 58 } 59 60 struct VertexPositionColorNormalTexture 61 { 62 @ShaderAttribute(0, GLType.Float, 3, false) 63 public vec3 position; 64 65 @ShaderAttribute(1, GLType.UByte, 4, true) 66 public Color color; 67 68 @ShaderAttribute(2, GLType.Float, 3, true) 69 public vec3 normal; 70 71 @ShaderAttribute(3, GLType.Float, 2, false) 72 public vec2 textureCoordinate; 73 } 74 75 struct TerrainVertex 76 { 77 @ShaderAttribute(0, GLType.Float, 3, false) 78 public vec3 position; 79 80 @ShaderAttribute(1, GLType.UByte, 4, true) 81 public Color color; 82 83 @ShaderAttribute(2, GLType.Float, 3, true) 84 public vec3 normal; 85 86 @ShaderAttribute(3, GLType.Float, 2, false) 87 public vec2 textureCoordinate; 88 89 @ShaderAttribute(4, GLType.Float, 3, true) 90 public vec3 tangent; 91 92 @ShaderAttribute(5, GLType.Float, 3, true) 93 public vec3 bitangent; 94 95 @ShaderAttribute(6, GLType.Float, 1, false) 96 public float textureId; 97 98 @ShaderAttribute(7, GLType.Float, 1, false) 99 public float blendingTextureId; 100 } 101 102 struct IqmVertex 103 { 104 @ShaderAttribute(0, GLType.Float, 3, false) 105 public vec3 position; 106 107 @ShaderAttribute(1, GLType.UByte, 4, true) 108 public Color color; 109 110 @ShaderAttribute(2, GLType.Float, 3, true) 111 public vec3 normal; 112 113 @ShaderAttribute(3, GLType.Float, 2, false) 114 public vec2 textureCoordinate; 115 116 @ShaderAttribute(4, GLType.UByte, 4, false) 117 public ubvec4 blendIndex; 118 119 @ShaderAttribute(5, GLType.UByte, 4, true) 120 public ubvec4 blendWeight; 121 } 122 123 struct Instancing(int layoutIndex) 124 { 125 @ShaderAttribute(layoutIndex, GLType.Float, 4, false) 126 public vec4 row1; 127 128 @ShaderAttribute(layoutIndex + 1, GLType.Float, 4, false) 129 public vec4 row2; 130 131 @ShaderAttribute(layoutIndex + 2, GLType.Float, 4, false) 132 public vec4 row3; 133 134 @ShaderAttribute(layoutIndex + 3, GLType.Float, 4, false) 135 public vec4 row4; 136 }