Skip to content

Instantly share code, notes, and snippets.

@rms80
Created July 4, 2018 16:58
Show Gist options
  • Save rms80/11f680a32bd36b3c82ef572bb3c18982 to your computer and use it in GitHub Desktop.
Save rms80/11f680a32bd36b3c82ef572bb3c18982 to your computer and use it in GitHub Desktop.
Setting face colors in mesh shader
//int N = 256;
//Texture2D tex = new Texture2D(N, N, TextureFormat.RFloat, false);
//float[] buffer = new float[N * N];
//foreach (int tid in startMesh.TriangleIndices()) {
// int v = tid / N;
// int u = tid % N;
// int n = 0;
// Vector3d c = startMesh.GetTriCentroid(tid);
// if (c.x > startMesh.CachedBounds.Center.x)
// n++;
// if (c.y > startMesh.CachedBounds.Center.y)
// n++;
// if (c.z > startMesh.CachedBounds.Center.z)
// n++;
// Color col = new Color((float)n, 0, 0, 1);
// buffer[tid] = (float)n;
//}
//tex.LoadRawTextureData(FloatToByte(buffer));
//tex.Apply();
//wireframeShader.SetTexture("_FaceIndexMap", tex);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment