public unsafe void WritePixel(Vector2Int *uvs, int pixelCount, GenericVector <T> color) { for (int i = 0; i < pixelCount; i++) { _pixels[UVToIndex(uvs[i].X, uvs[i].Y)].Write(color); } }
public void WritePixel(Vector2Int[] uvs, GenericVector <T> pixel) { for (int i = 0; i < uvs.Length; i++) { _pixels[UVToIndex(uvs[i].X, uvs[i].Y)].Write(pixel); } }
public void Initialize(int width, int height, int channelCount) { if (_initialized) { throw new Exception("RenderBuffer has initialized"); } Width = width; Height = height; _pixels = new GenericVector <T> [width * height]; for (int i = 0; i < _pixels.Length; i++) { _pixels[i] = new GenericVector <T>(channelCount); } _initialized = true; }
private static char GetColorChar(GenericVector <float> color) { int index; switch (color.Length) { case 3: index = (int)((color.R * .299f + color.G * .587f + color.B * .114f) * COLOR_CHAR_COUNT); break; default: float sum = 0; for (int i = 0; i < color.Length; i++) { sum += color[i]; } index = (int)(sum / color.Length * COLOR_CHAR_COUNT); break; } return(COLOR_CHAR[index == COLOR_CHAR_COUNT ? index - 1 : index]); }
public unsafe Model(Vector3[] vertices, int[] indices, Vector2[] uvs = null, Vector3[] normals = null, Vector4[] colors = null) { Vertices = vertices ?? throw new Exception("Vertices are required"); Indices = indices; UVs = uvs; Normals = normals; Colors = colors; _verticesData = new GenericVector <float> [vertices.Length]; Bound = Cuboid.NegativeMax; for (int i = 0; i < _verticesData.Length; i++) { _verticesData[i] = new GenericVector <float>(sizeof(ShaderInOutPatternDefault) / sizeof(float)) { vertices[i], 1f, uvs != null ? uvs[i] : Vector2.Zero, normals != null ? normals[i] : Vector3.Zero, colors != null ? colors[i] : Vector4.Zero }; Bound.ExtendToContain(vertices[i]); } }
public void WritePixel(int u, int v, GenericVector <T> pixel) { _pixels[UVToIndex(u, v)].Write(pixel); }