How do you create a 2D texture array using multiple views from the model? I saw the example at Texture Arrays but it’s loading the textures from a file. I want to dynamically create the textures, where each one is a different camera angle of the model, and then I want to pass the 2D texture array into a shader. It would be more convienent using the 2d sampler array rather than passing in a bunch of 2d sampler/texture objects into the shader.
I can’t find very many 2D texture array examples on the internet so any help would be greatly appreciated!
Am I correct in thinking that the problem here is that of how to render to texture?
If so, then I believe that it may be done something like this:
bufferWidth = 256 # Or whatever size you intend
bufferHeight = 256 # Or whatever size you intend
surfaceBuffer = base.win.makeTextureBuffer("surface buffer", bufferWidth, bufferHeight)
surfaceCamera = base.makeCamera2d(surfaceBuffer)
# Set up the camera as desired, such as parenting it to render or some other NodePath.
texture = surfaceBuffer.getTexture()
Thanks but I’m more asking if it’s possible to take a list of textures and then pass it into a shader as a sampler2DArray.
Rather then doing something like this:
for i in range(len(textures)):
render.setShaderInput("viewTextures%d" % i, textures[i])
I’d like to be able to just pass in a list of textures:
Unfortunately when I try the latter, I get a black window that appears to be hung (I can’t close it).