Copying my comment into the answer section.
MATLAB converts textures to an intermediate format (RGBA of unsigned char) before uploading them to the GPU. If you use uint8 arrays in MATLAB there should be no overhead. However, because you are trying to overlay transparent textures, the overhead will be due to the way MATLAB API accepts color and alpha data through separate channels.
Here is example code snippet that does similar stacking of textures. Note that I use surface object because it provides an easy interface to create texturemapped quadrilateral.
for i = 1 : 10,
s = surface(1:2,1:2,i*ones(2),...
'EdgeColor','none',...
'FaceColor','texturemap',...
'CData',uint8(255*rand(10,10,3)),...
'FaceAlpha','texturemap',...
'AlphaData',uint8(255*rand(10,10,1)));
end
This could be a good starting point for you.
Also, MATLAB uses deferred rendering for resolving transparency in the scene. If you only wish to render these textures in a certain order, you need to set SortMethod property on the axes. Please refer to Axes sortmethod property for more information.
2 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/285016-matlab-opengl-3d-rendering#comment_371495
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/285016-matlab-opengl-3d-rendering#comment_371495
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/285016-matlab-opengl-3d-rendering#comment_371559
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/285016-matlab-opengl-3d-rendering#comment_371559
Sign in to comment.