Hi,
I am trying to make a volume renderer in color. To do that, I implemented a shader :
#define EPSILON (0.001)
half4 main(
half3 uvw : TEXCOORD0,
half4 col : COLOR,
uniform sampler3D data,
uniform sampler1D colortable) : COLOR
{
half4 value = tex3D(data, uvw);
half4 color = tex1D(colortable, value.a);
return color;
}
I can see my volume but it in grayscale and not in color.
The variable data refers to my volume :
gl.glTexImage3D(GL.GL_TEXTURE_3D, 0, GL.GL_RGBA, width, height, depth, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, data);
The variable colortable refers to the transferfunction :
gl.glTexImage1D(GL.GL_TEXTURE_1D, 0, GL.GL_RGBA, TF_TABLE_SIZE, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, m_pColorTable);
and this is how I build my transfer function :
int[][] colorTable = new int[4][256];
for (int j = 0; j < seuil1; j++) {
colorTable[0][j] = j;
colorTable[1][j] = 0;
colorTable[2][j] = 0;
colorTable[3][j] = j;
}
for (int j = seuil1; j < seuil2; j++) {
colorTable[0][j] = 0;
colorTable[1][j] = 0;
colorTable[2][j] = 0;
colorTable[3][j] = 0;
}
for (int j = seuil2; j < 256; j++) {
colorTable[0][j] = j;
colorTable[1][j] = 0;
colorTable[2][j] = 0;
colorTable[3][j] = j;
}
int tmp = 0;
for (int i = 0; i < 256; i++) {
m_pColorTableR.put((byte) colorTable[0][i]);
m_pColorTableR.put((byte) colorTable[1][i]);
m_pColorTableR.put((byte) colorTable[2][i]);
m_pColorTableR.put((byte) colorTable[3][i]);
}
m_pColorTableR.rewind();
Does somebody have an idea ?
Thank you