Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cubemap prefilter #143

Merged

Conversation

Projects
None yet
3 participants
@guycalledfrank
Copy link
Contributor

guycalledfrank commented Jan 9, 2015

Added cubemap filtering utility.
Fixed RGBA32F DDS loading.
RGBA32F textures now can be transparently used for reflection/skybox.

Added new properties to texture:

  • rgbm: specifies that texture is RGBM encoded;
  • fixCubemapSeams: specifies that cubemap is prepared for seam fixing.

Removed hdr property from texture. Now texture can be considered HDR based on either format or rgbm property.

Filter utility syntax is:
pc.prefilterCubemap(device, sourceCubemap, method, samples, options, chromeFix)

Usage example:

var options = {
    filtered: null,
    filteredFixed: null,
    filteredRGBM: null,
    filteredFixedRGBM: []
};
pc.prefilterCubemap(app.context.graphicsDevice, cubeMaps[0], 0, 256, options, true);

options.filteredFixedRGBM will now contain mip levels as separate cubemaps. Those can be inserted into material.prefilteredCubemap* properties (which later might be concatenated together into a single mipmapped cubemap by engine depending on HW).

Source cubemap is better to be RGBA32F. It can be RGBM but then quality will suffer.

All options should be either null or empty array to be filled with cubemaps.
"Fixed" means applied edge fixup. This is required when WebGL is not emulated through DX11 (= almost always required).
filteredFixedRGBM is the version that should work on absolutely every browser.

There are currently 2 filtering methods: simple and blinn-phong importance sampling. Difference is on the pic.

Simple is fast (can be done in-game), but may produce a bit "flat" specular highlights. Usually 256 samples is enough for it.

Importance sampled requires more samples, 4096 looks fine, and it takes 1-2 sec, but looks much closer to reference.

cubez2

guycalledfrank added some commits Jan 8, 2015

Added cubemap filtering utility:
Fixed RGBA32F DDS loading.
RGBA32F textures now can be transparently used for reflection/skybox.
Added new properties to texture:
- rgbm: specifies that texture is RGBM encoded;
- fixCubemapSeams: specifies that cubemap is prepared for seam fixing.
Removed hdr property from texture. Now texture can be considered HDR based on either format or rgbm property.
@@ -660,9 +660,11 @@ pc.extend(pc, function () {

if (this.cubeMap) {
this.setParameter('texture_cubeMap', this.cubeMap);
this.setParameter('material_cubemapSize', this.cubeMap.width);

This comment has been minimized.

Copy link
@willeastcott

willeastcott Jan 9, 2015

Contributor

Any reason this isn't called texture_cubeMapSize? It's a texture property rather than a material property. It's internal so it's not a big deal...

willeastcott added a commit that referenced this pull request Jan 10, 2015

@willeastcott willeastcott merged commit b4138b6 into playcanvas:master Jan 10, 2015

@Maksims

This comment has been minimized.

Copy link
Contributor

Maksims commented Jan 10, 2015

Method has 6 arguments, and one of them is options, why not to fit all of them or at least most of them in options and use just object inside?

pc.prefilterCubemap(options);

guycalledfrank added a commit that referenced this pull request Nov 25, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.