Encoding Texture in Unity setting negative values to 0
Hello, I'm trying to encode a texture in unity to act as a lookup texture. Right now, when I set pixels in unity, negative values revert to 0. Can anyone tell me what I'm going wrong?
This code calls the texture generation function: LookupTextureGenerator.GenerateVertexPositionTexture( new Vector3[,] { {new Vector3(-0.5f, -0.5f, 0) }, { new Vector3(0.5f, 0.5f, 0) }, { new Vector3(0.5f, -0.5f, 0) }, { new Vector3(-0.5f, 0.5f, 0) } } )
This code generates the texture public static Texture2D GenerateVertexPositionTexture( Vector3[,] positions ){ Texture2D new_tex = new Texture2D(positions.GetLength(0), positions.GetLength(1), TextureFormat.RGBAFloat, false, true); // using linear colorspace
for(int y = 0; y<positions.GetLength(1); y++){
for(int x = 0; x<positions.GetLength(0); x++){
new_tex.SetPixel( x, y, new Vector4( positions[x,y].x, positions[x,y].y, positions[x,y].z, 1));
}
}
return new_tex;
}
I apologize for the bad formatting. $$anonymous$$y markdown didn't render the way I expected.
What is important above is this. new_tex.SetPixel( x, y, new Vector4( positions[x,y].x, positions[x,y].y, positions[x,y].z, 1));
I am passing negative values to my Vector4. But the texture takes any negative value and makes it 0.
Your answer
Follow this Question
Related Questions
Change Texture 0 Answers
Shadergraph same texture different result 0 Answers
Copy texture data from one Sprite to another 0 Answers
Very Low Quality In Game Mode 2 Answers
Lighting and texture problem 0 Answers