#Trying to implement skybox

62 messages · Page 1 of 1 (latest)

vagrant trench
#

I can see the while cube around the camera but texture is not being draw. I checked all log in console and the texture is being loaded fine. What I'm doing wrong?

tidal hinge
#

if you use the cubemap, then you need to use a shader

vagrant trench
#

I cannot make without shader?

tidal hinge
#

sure, but you don't use the cubemap channel

#

use diffuse and have a model that has the correct UVs

#

get a mesh that has the UV unwraps

vagrant trench
#

this mean I change this to difuse like this?

skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = LoadTextureCubemap(img, CUBEMAP_LAYOUT_AUTO_DETECT);  
#

wait

tidal hinge
#

that's part of it

#

do you understand how textures work on 3d models?

vagrant trench
#

no much yet

tidal hinge
#

basically you don't need a cube map

#

you just need a mesh that has the correct mapping to wrap your texture around it

#

you set that in the diffuse channel

#

DrawCube or GenMeshCube won't work

#

you will have to load it as a model

vagrant trench
#

I call it a progress XD

#

oh I see now

#

I need a model with the texture in the 6 sides inside it?

#

I was trying to use this texture for test

tidal hinge
#

yes, you need model that knows how to map that

vagrant trench
#

there is a way to map the texture direct in code?

tidal hinge
#

you'd have to define the mesh manually

#

raylib is not a modeler, it doesn't have functions for defining UVs

#

that's what the shader does in the example, it defines the UVs using the cube map on the GPU

vagrant trench
#

what models formats I can load?

tidal hinge
#

obj, glb/gltf, m3d, iqm

vagrant trench
#

after this I read this way?

Model skybox = LoadModel("cube.obj");
Texture2D texture = LoadTexture("skybox.png");
SetMaterialTexture(&skybox.materials[0], MATERIAL_MAP_DIFFUSE, texture);

because I'm getting a error

#

I already tried in 2 formats

tidal hinge
#

are you trying to do that before InitWindow?

vagrant trench
#

I'm trying after initWindow

tidal hinge
#

arethe paths correct?

vagrant trench
#

I think yes it even open this if I click the error message

tidal hinge
#

is the mtl file in the same folder?

#

obj is a crap fromat, I recomend glb

vagrant trench
#

yes the mtl is in same folder but I have same error with a glb

tidal hinge
#

are you trying to compile that file INTO your game code?

vagrant trench
#

what you mean? this model files are just files in the folder

tidal hinge
#

do you get that error on compile or on run?

vagrant trench
#

compile

tidal hinge
#

why is the compiler trying to read the file?

vagrant trench
#

this is the error
invalid or corrupt file: cannot read at 0x3AB

tidal hinge
#

the models should not be part of the build at all

#

did you add them to the .sln file or something?

vagrant trench
#

oh I though was to add I will remove

tidal hinge
#

yeah, they are not source files

#

they are not part of the compile

#

they are read off disk at runtime

#

if you are using the quickstart they'd go in the resources folder

vagrant trench
#

work now but my shaders dont like it XD

tidal hinge
#

did you disable depth mask and depth test?

vagrant trench
#

where is this option?

tidal hinge
#

they are funcitons in rlgl

vagrant trench
#

yes I will remove it

tidal hinge
#

look at the example

#

you need to disable depth when you draw the skybox

#

then flush the batch, and turn it on

#

and draw the box BEFORE anything

vagrant trench
#

thank you very much this is working now! ^^

tidal hinge
#

glad it worked out