but0n / Ashes

WebGL2.0 3D Engine - Global Illumination - RayTracing
https://codepen.io/but0n/pen/jddYoX
MIT License
328 stars 16 forks source link

How to apply an IBL texture with any file name? #45

Closed cx20 closed 4 years ago

cx20 commented 4 years ago

I tried applying an IBL texture to glTF using Ashes. https://cx20.github.io/gltf-test/examples/ashes3d/index.html?category=tutorialModels&model=BoomBox&scale=100&type=glTF

IBL texture can be load with the following file names, but is it possible to use other file names?

helipad/<pos|neg><x|y|z>.hdr

I want to use the following files for IBL textures.

https://github.com/ux3d/glTF-Sample-Environments/tree/4eace30f795fa77f6e059e3b31aa640c08a82133/papermill/specular

before after
helipad/posx.hdr specular/specular_right_0.hdr
helipad/negx.hdr specular/specular_left_0.hdr
helipad/posy.hdr specular/specular_top_0.hdr
helipad/negy.hdr specular/specular_bottom_0.hdr
helipad/posz.hdr specular/specular_front_0.hdr
helipad/negz.hdr specular/specular_back_0.hdr
but0n commented 4 years ago

You can customise file names by modify Asset.cubemapOrder

https://github.com/but0n/Ashes/blob/master/src/asset.ts#L284-L291

cx20 commented 4 years ago

Thank you for telling me how to change the IBL texture. However, the result of the applied IBL texture seems incorrect.

image

image

image

cx20 commented 4 years ago

The cause is probably due to mistakenly specifying the same texture as specEnv for diffEnv. Although not strictly correct, an improvement was seen by specifying the same texture as helipad instead of papermill in diffEnv. Ashes + IBL result: image

cx20 commented 4 years ago

I modified the sample because I found a diffuse texture for papermill. https://github.com/ux3d/glTF-Sample-Environments/tree/4eace30f795fa77f6e059e3b31aa640c08a82133/papermill/diffuse

Ashes + IBL result: image

Is this the right way to use it?

but0n commented 4 years ago

Thanks for your feedback!

Is this the right way to use it?

I think this is the right way to use it, but the result is still not strictly correct because of the blur level of specular environment texture, which is a known issue. It will be improved by using different blur cube textures in next version.

cx20 commented 4 years ago

Thank you for telling me how to use IBL correctly. I will wait for the next version for specular environment texture issues.

BTW, Please tell me another one. How can I apply a CubeMap Texture to the background using Ashes instead of IBL as follows:

image

If that is feasible, I would like to update the gltf-test sample to use CubeMap like other libraries.

but0n commented 4 years ago

Do you mean visual the skybox in the scene? I will handle this feature in next version!

cx20 commented 4 years ago

I want to test again when the next version comes out. This issue is closed because I understand how to use the IBL texture.

but0n commented 4 years ago

This example shows how to create background using Ashes. Source: https://github.com/but0n/Ashes/blob/master/demo.html#L104

Also, the HDR specular environment texture issues should be fixed in 0.3.1.

let bg = new Background(screen);

image

let bg = new Background(screen, skybox);

image