Cubemap not working?

Blitz3D Forums/Blitz3D Programming/Cubemap not working?

Cubed Inc.(Posted 2013) [#1]
Whenever I try applying a cubemap flag (128) to a pre-rendered cubemap texture, it returns with an error saying that the texture doesn't exist. Why so?


Omnicode(Posted 2013) [#2]
Sometimes Blitz returns an error on such textures if you removed all the texture filters and then didn't reassign the texture color.
Texturefilter "",1

Is needed most likely.
Ran into that issue bout 3 days ago when I was messing around with some water code.


Cubed Inc.(Posted 2013) [#3]
Am I using this code right?

Global shadertexB=LoadTexture("cubemap.png",128)
TextureBlend shadertexB,3
TextureFilter shadertexB,1
SetCubeMode shadertexB,1

What should the cubemap look like if implemented correctly?


Omnicode(Posted 2013) [#4]
Blitz3d default texture flags are 1+8, meaning it has color and is mipmapped.
So usually (if you have a need to exclude certain flags from certain textures within your game) You'd clear the texture filters. Using the command 'ClearTextureFilters' and THEN making sure to do the 'Texturefilter "",1 so that all textures have color and will be loaded.

Well, for starters the texturefilter command needs to be executed before you load the texture, as it automatically adds flags (such as color, masking, alpha, etc) upon loading of any texture.

The texturefilter command applies whatever flag has been identified to all post-loaded textures.

Also, i'm not exactly sure if Blitz3d fully supports PNG as a cubemap texture. Perhaps try simply renaming it to a .BMP or .JPG file extension.

Note: that the texturefilter command does not require the textures handle.
It only requires a snippet of the texture filename in order to apply the flags.

So using 'Texturefilter "",1' would mean to apply to all textures loaded as "" is contained within every filename string.

Secondly, You don't really need to 'setcubeface' as that'll only draw the texture to the North Side of the cubemap.

Here is proper usage.

ClearTexturefilters
Texturefilter "",1
Global shadertexB=LoadTexture("cubemap.png",128+256)
TextureBlend shadertexB,3
;Apply your texture to whatever.

A proper cubemap is basically supposed to show all the objects around the object that is textured with the cubemap, like a mirror. But, your method will most likely generate an object that is shiny and the texture will apparently 'move' when the camera is moving around the object.


Cubed Inc.(Posted 2013) [#5]
Nope. Still says the texture doesn't exist.


Cubed Inc.(Posted 2013) [#6]
I don't know; no matter what I try I still can't get that damned cubemap function to work -_-


Cubed Inc.(Posted 2013) [#7]
REALLY irritating


Kryzon(Posted 2013) [#8]
What are the dimensions of the texture?

Loading cubemaps in Blitz3D has some specific requirements. Read the information at "flag 128" here: http://blitzbasic.com/b3ddocs/command.php?name=CreateTexture&ref=3d_cat


Cubed Inc.(Posted 2013) [#9]
For sake of reference, what would the typical cubemap texture dimensions be? I understand that they have to be by the power of two.


Kryzon(Posted 2013) [#10]
What are the dimensions of the texture you are using?


Omnicode(Posted 2013) [#11]
Hm, this is very strange. I'm assuming you have the source in the same path as the file? Or do you store your textures in a completely different folder associated with your media, if so you simply forgot to 'find' the actual file. So long as the dimensions aren't terribly crazy I doubt that wouldn't have much of an effect.

Occasionally PNG's have messed up for me, did you try simply saving the image as a different extension? i.e BMP, JPG.

-For a cube map texture to load.
1. Graphics3D needs to be initialized.
2. Texture must have 1 Flag assigned.
3. Must be file-pathed correctly.
4. All 6 images that comprise a cube map image must also be to a power of 2.

;---1---;
Graphics3D 800,600,32,2
Setbuffer Backbuffer()

;---2---;
;Default texture filters are color and mipmapped. (1+8) So i don't need to ;apply any since i haven't removed them with the clear texture filters ;function.

;---3--- AND ---4---;
;Here's an example of a relatively small cube map image/texture.

-Possible Dims- (Well, I don't think you'd need anything bigger than 512 tbh)
;Cell Size;
;2x2 (2*6) =12x2
;4x4 (4*6) =24x4
;8x8 (8*6) =48x8
;16 (16*6) =96x16
;32 (32*6) =192x32
;64 (64*6) =384x64
;128 (128*6)=768x128
;256 (256*6)=1536x256
;512 (512*6)=3072x512

So, unless you've got a freak of a texture as a cubemap. One of those sizes will do the trick. 6x1 is possible but thats just so low resolution there's no need for it.

Global shadertexB=loadtexture("Directory that leads to the file",128+256)
textureblend shadertexB,3
;Apply texture.


Cubed Inc.(Posted 2013) [#12]
Ah, I see now. My textures weren't going by that certain size pattern.


Omnicode(Posted 2013) [#13]
Glad to have helped haha.