I'm working with shaders, where I want to provide a
Texture3D as input to the shader. To do so I need to define the data in the
Texture3D. But I'm having troubles doing so.
First I create my image, and set the value of its only pixel to
var image = Image.new()
image.create(1, 1, false, Image.FORMAT_RGB8)
image.set_pixel( 0,0, Color(0.7, 0.0, 0.0, 0.0))
When I check the pixel value, it seems to have worked, as
image.get_pixel(0,0) gives me
Then I try to use the image to define data in a Texture3D
var texture = Texture3D.new()
texture.create( 1, 1, 1, Image.FORMAT_RGB8 )
But when I check the pixel value, it has suddenly changed.
0,0,0,1 as output. And it doesn't seem to work to set the pixel value after it has been entered into the texture:
texture.data['layers'].set_pixel(0,0, Color(0.7, 0.0, 0.0, 0.0))
does not work as it gives the error
set_pixel: Image must be locked with 'lock()' before using set_pixel().
So, why isn't the above working? And a more open question is: how would one properly define the data in a Texture3D?