Happy new year.
I am going to create walls for my FPS game using createObjectBox() command. At present I am using this function to create a larger texture with small images repeated sizeX*sizeY times, in order to texture the walls:
function createTextureFromImage(imgFromID as integer,sizeX,sizeY)
imageFromWidth as integer
imageFromHeight as integer
imageToWidth as integer
imageToHeight as integer
mBlockImageFrom as integer
mBlockImageTo as integer
createdTextureID as integer
i as integer
j as integer
j1 as integer
srcFrom as integer
srcTo as integer
numBytes as integer
offset as integer
imageFromWidth=GetImageWidth(imgFromID)
imageFromHeight=GetImageHeight(imgFromID)
imageToWidth=imageFromWidth*sizeX
imageToHeight=imageFromHeight*sizeY
mBlockImageFrom=CreateMemblockFromImage(imgFromID)
mBlockImageTo=CreateMemblock(12+4*imageFromHeight*imageFromWidth*sizeX*sizeY)
SetMemblockInt(mBlockImageTo,0,imageToWidth)
SetMemblockInt(mBlockImageTo,4,imageToHeight)
SetMemblockInt(mBlockImageTo,8,32)
for j=1 to sizeY
for i=1 to sizeX
offset=(j-1)*imageToWidth*imageFromHeight*4+(i-1)*imageFromWidth*4
for j1=1 to imageFromHeight
srcFrom=12+imageFromWidth*(j1-1)*4
srcTo=12+offset+(j1-1)*imageToWidth*4
numBytes=imageFromWidth*4
copyMemblock(mBlockImageFrom,mBlockImageTo,srcFrom,srcTo,numBytes)
next j1
next i
next j
createdTextureID=CreateImageFromMemblock(mBlockImageTo)
DeleteMemblock(mBlockImageFrom)
DeleteMemblock(mBlockImageTo)
endfunction createdTextureID
The images I am using are small (32x32 or 64x64) but the composite texture is big and I suspect that this approach is very memory consuming and performance affecting,
I cannot use milkshape3D, blender or other programs to create a scaled texture. In fact, I have not got an obj file, but an in-memory object created using a buit-in AppGameKit command.
Moreover, I have tried the tool tile texture mapper of Milkshape3D with cubic mapping, exported an obj and applied the texture, but no correct tiling is produced.
I have understood that by using a shader, we could do everything, but it is currently too time consuming to learn how to write a shader.
One way to optimize things, is to reuse the textures for different walls that have the same size, but this does not solve the issue at the roots.
Have you got any suggestion for me?