mgsx-dev / gdx-gltf

GLTF 2.0 3D format support and PBR shader implementation for LibGDX
Apache License 2.0
214 stars 50 forks source link

Loading cubemap from image display only blackcolor #89

Closed ronjunevaldoz closed 1 year ago

ronjunevaldoz commented 1 year ago

Sample output (My sample cubemaps) display only black color: image

Sample output (Night cubemaps) working as expected: image

Below is the example environment cubemaps.

val fileHandle = InternalFileHandleResolver()
val basePath = "data/textures/environment/day/"
val environmentCubemap = EnvironmentUtil.createCubemap(fileHandle, basePath, ".png", EnvironmentUtil.FACE_NAMES_FULL)

val defaultLight = DirectionalShadowLight(
    1024 , 1024,
    100f, 100f, 0.1f, 1000f
)
// light direction based on environment map SUN
defaultLight.direction.set(-.5f, -0.9f, -.7f).nor()
defaultLight.color.set(Color.WHITE)
defaultLight.intensity = 1f
defaultLight.updateColor()

sceneManager.setCamera(camera)
sceneManager.environment.add(defaultLight)

val iblBuilder = IBLBuilder.createOutdoor(defaultLight) 
val diffuseCubemap = iblBuilder.buildIrradianceMap(256)
val specularCubemap = iblBuilder.buildRadianceMap(10)
iblBuilder.dispose()

sceneManager.setAmbientLight(1f)
sceneManager.environment.set(PBRTextureAttribute(PBRTextureAttribute.BRDFLUTTexture, brdfLUT))
sceneManager.environment.set(PBRCubemapAttribute.createSpecularEnv(specularCubemap))
sceneManager.environment.set(PBRCubemapAttribute.createDiffuseEnv(diffuseCubemap))

val skybox = SceneSkybox(environmentCubemap)
sceneManager.skyBox = skybox

back bottom front left right top

mgsx-dev commented 1 year ago

one of your image is 512x511 (bottom face), others are 512x512, some missing pixels makes it unusable.