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

Image-based lighting #7172

Merged
merged 103 commits into from
Dec 19, 2018
Merged
Changes from 1 commit
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
948b768
Load env map from dds and load cube maps + mipmaps.
bagnell Sep 25, 2018
692bf7b
Use custom cube for showing env map. Use shader to access lod.
bagnell Sep 26, 2018
f645625
Add IBL to models. Reowrk setup code.
bagnell Sep 27, 2018
59fb605
Functioning octahedral projection
Oct 1, 2018
6a4f965
Created octahedron map unpacking example
Oct 2, 2018
3a189e5
Fix orientation of cubemap temporarily. Add initial SH code.
bagnell Oct 2, 2018
af047fc
Pack mips with 1 pixel border
Oct 3, 2018
87f34eb
Make texture big enough
Oct 3, 2018
8c26eb9
Update spherical harmonics.
bagnell Oct 3, 2018
8a34bcc
Merge pull request #7107 from OmarShehata/ibl
bagnell Oct 4, 2018
2285282
Merge branch 'hdr' into ibl
bagnell Oct 4, 2018
487329a
Fixes after merge.
bagnell Oct 4, 2018
501450c
Fixed artifacts with octahedron projection
Oct 5, 2018
d378a3a
Merge pull request #7117 from OmarShehata/ibl
bagnell Oct 5, 2018
9c30528
Initial integration of octahedral projection.
bagnell Oct 5, 2018
9010669
Fix Octahedral sampling artifacts
Oct 8, 2018
ec89263
Experimental HDR procedural sky
Oct 8, 2018
9036674
Merge branch 'ibl' of https://github.com/OmarShehata/cesium into ibl
Oct 8, 2018
59068ef
Revert "Experimental HDR procedural sky"
Oct 8, 2018
e98524f
Store correct number for max mip level
Oct 8, 2018
d6c9894
Merge pull request #7122 from OmarShehata/ibl
bagnell Oct 8, 2018
b0b3708
Some clean up.
bagnell Oct 8, 2018
d253e7a
Revert cubemap changes to load mip levels and request WebGL 1.
bagnell Oct 8, 2018
e095567
Add doc. Fix typos.
bagnell Oct 8, 2018
eddbb9a
Reverse Z axis in cubemap
Oct 9, 2018
1a781a8
Better LOD choosing in octahedral
Oct 9, 2018
006d859
Add trilinear filtering to octahedral lod selection
Oct 9, 2018
5dca2a0
Only do bilinear filtering if texture_float_linear isn't supported
Oct 10, 2018
06080ba
Merge pull request #7126 from OmarShehata/ibl
bagnell Oct 10, 2018
ef321f8
Add CIE Clear Sky model to procedural environment
Oct 10, 2018
7562570
ACtually add the luminance
Oct 10, 2018
9eec64e
Merge pull request #7126 from OmarShehata/ibl
bagnell Oct 10, 2018
f190bea
Fix banding at lower mips
Oct 11, 2018
64faa12
Fix banding at lower mips
Oct 11, 2018
06ad9e4
Update KTX loader to load cube maps and mip map levels. Use RGBM for …
bagnell Oct 11, 2018
fb79863
Merge pull request #7142 from OmarShehata/fix-banding
bagnell Oct 11, 2018
9f67f79
Merge pull request #7126 from OmarShehata/ibl
bagnell Oct 10, 2018
cdb21d5
Update KTX loader to load cube maps and mip map levels. Use RGBM for …
bagnell Oct 11, 2018
fa73474
Merge pull request #7126 from OmarShehata/ibl
bagnell Oct 10, 2018
8da4636
Merge remote-tracking branch 'upstream/ibl' into ibl
Oct 15, 2018
14483ea
Added comment to shader
Oct 15, 2018
d521740
Fix linting errors
Oct 15, 2018
ffe83bf
Made luminance a uniform
Oct 16, 2018
ea67be3
Cleaned up luminance model
Oct 16, 2018
403cfe2
Typo with file import
Oct 17, 2018
321175b
Fix decoding for RGBM textures which is different for the tool used t…
bagnell Oct 17, 2018
8039c66
Fix loadKTX tests
Oct 17, 2018
46c2134
Use shader constants and style tweaks.
bagnell Oct 17, 2018
a89d869
Add luminance when recreating shader
Oct 17, 2018
425ee75
Temp fix for swapped +/-Y face of RGBM files.
bagnell Oct 17, 2018
b02d663
Fix mipmap padding when loading KTX files.
bagnell Oct 18, 2018
7a0c3f7
Add IBL example.
bagnell Oct 19, 2018
bbc256e
Fix specular map orientation.
bagnell Oct 19, 2018
9c93d05
Merge branch 'hdr' into ibl
bagnell Oct 19, 2018
79bc2c7
Merge pull request #7134 from OmarShehata/ibl
lilleyse Oct 22, 2018
890630c
Merge pull request #7165 from OmarShehata/ibl-tests
bagnell Oct 22, 2018
83ac2e1
Merge branch 'hdr' into ibl
bagnell Oct 23, 2018
70dfda0
Fix after merge.
bagnell Oct 23, 2018
7b99191
Add model IBL tests.
bagnell Oct 23, 2018
172a188
Add Sandcastle example image.
bagnell Oct 23, 2018
b4055af
Remove temp +Y/-Y swap
Oct 24, 2018
1c0d10e
Add octahedral map test
Oct 24, 2018
7080b92
Merge branch 'hdr' into ibl
bagnell Oct 24, 2018
7c8f53d
Add option to disable luminanceAtZenith and fix failing tests.
bagnell Oct 24, 2018
7c1541a
Merge branch 'hdr' into ibl
bagnell Oct 24, 2018
0f410d7
Add octahedral sampling test
Oct 26, 2018
30090e1
Note why we can't use scene.renderForSpecs
Oct 29, 2018
070ffa7
Fix spec name
Oct 29, 2018
78e3bf8
Refactor context render function
Oct 29, 2018
93a7b4b
Remove unnecessary clear.
bagnell Oct 30, 2018
d634e3b
Merge pull request #7183 from OmarShehata/ibl
bagnell Oct 30, 2018
409fe64
Merge branch 'hdr' into ibl
bagnell Oct 30, 2018
546efb5
Fix test after merge.
bagnell Oct 30, 2018
b01e0f0
Fix eslint errors.
bagnell Nov 1, 2018
289e388
Merge branch 'hdr' into ibl
bagnell Nov 2, 2018
58e8628
Doc typo
Nov 5, 2018
335430b
Add links to Sandcastle demo
Nov 5, 2018
e4d9ccd
Add comments to Sandcastle example
Nov 5, 2018
2d2a0d3
Remove diffuseIrradiance
Nov 5, 2018
950f102
Updated IBL docs
Nov 5, 2018
eb39ee7
Add some context
Nov 5, 2018
b34e329
Merge pull request #7231 from OmarShehata/ibl
pjcozzi Nov 5, 2018
62c1846
Fix tests.
bagnell Nov 5, 2018
80bf34e
Merge branch 'hdr' into ibl
bagnell Nov 8, 2018
8367088
Small fixes
lilleyse Nov 9, 2018
bd72208
Add a texture cache. Use the texture cache for projected textures. Ot…
bagnell Nov 13, 2018
7c1998e
Merge branch 'hdr' into ibl
bagnell Nov 13, 2018
5e1559c
Add support for batched and instanced 3D Tiles.
bagnell Nov 13, 2018
6162e47
Add default IBL options to scene.
bagnell Nov 16, 2018
a5bf4db
Merge branch 'master' into ibl
bagnell Nov 16, 2018
ae342b3
Add doc.
bagnell Nov 19, 2018
d8f8183
Merge branch 'master' into ibl
lilleyse Nov 20, 2018
4a62071
Cubemaps must have the y-axis as the up axis. Remove TODO.
bagnell Nov 20, 2018
646a3d9
Fix lighting for models in fixed coordinates.
bagnell Nov 30, 2018
aa6da4f
Change default luminance at zenith.
bagnell Nov 30, 2018
ba03cc6
Fix texture cache issue.
bagnell Dec 1, 2018
ecd4284
Merge branch 'master' into ibl
lilleyse Dec 6, 2018
401e6b5
Fix reflection vector.
bagnell Dec 18, 2018
e6543d0
Use pawns model instead of spheres.
bagnell Dec 18, 2018
60c85f7
Merge branch 'master' into ibl
bagnell Dec 18, 2018
e98e0f6
Fix tests after merge.
bagnell Dec 18, 2018
16a5761
Merge branch 'master' into ibl
bagnell Dec 19, 2018
e37e417
Update the IBL Sandcastle example iage and CHANGES.md.
bagnell Dec 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 92 additions & 17 deletions Apps/Sandcastle/gallery/Hello World.html
Original file line number Diff line number Diff line change
@@ -34,7 +34,16 @@
scene.moon = undefined;
scene.globe = undefined;

scene.context.throwOnWebGLError = true;
//scene.context.throwOnWebGLError = true;

var height = 5000000.0;
var heading = 0.0;
var pitch = 0.0;
var roll = 0.0;
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);

var origin = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, hpr);

//var envMapURL = '../../SampleData/models/EnvMap/rustig_koppie_envDiffuseHDR.dds';
var envMapURL = '../../SampleData/models/EnvMap/rustig_koppie_envSpecularHDR.dds';
@@ -44,8 +53,8 @@
}).then(function(buffer) {
var mipLevel = 0;
var dds = parseDDS(buffer, true);
var width = dds.mipmaps[0].width;
var height = dds.mipmaps[0].height;
var width = dds.mipmaps[mipLevel].width;
var height = dds.mipmaps[mipLevel].height;
var mipmapCount = dds.mipmapCount;
var sources = {
positiveX : { arrayBufferView : dds.mipmaps[mipLevel].data, width : width, height : height },
@@ -58,6 +67,8 @@
var mipLevels = new Array(mipmapCount - 1);
for (var i = 0; i < mipmapCount - 1; ++i) {
mipLevel = i + 1;
width = dds.mipmaps[mipLevel].width;
height = dds.mipmaps[mipLevel].height;
mipLevels[i] = {
positiveX : { arrayBufferView : dds.mipmaps[mipLevel].data, width : width, height : height },
negativeX : { arrayBufferView : dds.mipmaps[mipLevel + mipmapCount].data, width : width, height : height },
@@ -67,25 +78,81 @@
negativeZ : { arrayBufferView : dds.mipmaps[mipLevel + 5 * mipmapCount].data, width : width, height : height }
};
}
scene.skyBox = new Cesium.SkyBox({
cubeMap : new Cesium.CubeMap({
context : scene.context,
source : sources,
mipLevels : mipLevels,
pixelDatatype : Cesium.PixelDatatype.FLOAT

var cubeMap = new Cesium.CubeMap({
context : scene.context,
source : sources,
mipLevels : mipLevels,
pixelDatatype : Cesium.PixelDatatype.FLOAT,
sampler : new Cesium.Sampler({
minificationFilter : Cesium.TextureMinificationFilter.LINEAR_MIPMAP_LINEAR
})
});

var boxGeometryInstance = new Cesium.GeometryInstance({
geometry : Cesium.BoxGeometry.fromDimensions({
vertexFormat : Cesium.VertexFormat.POSITION_NORMAL_AND_ST,
dimensions : new Cesium.Cartesian3(500000.0, 500000.0, 500000.0)
})
});

var customAppearance = {};
customAppearance.vertexShaderSource =
'attribute vec3 position3DHigh;\n' +
'attribute vec3 position3DLow;\n' +
'attribute vec3 normal;\n' +
'attribute vec2 st;\n' +
'attribute float batchId;\n' +
'\n' +
'varying vec3 v_positionEC;\n' +
'varying vec3 v_normalEC;\n' +
'\n' +
'void main()\n' +
'{\n' +
' vec4 p = czm_computePosition();\n' +
'\n' +
' v_positionEC = (czm_modelViewRelativeToEye * p).xyz;\n' +
' v_normalEC = czm_normal * normal;\n' +
'\n' +
' gl_Position = czm_modelViewProjectionRelativeToEye * p;\n' +
'}';
customAppearance.fragmentShaderSource =
'uniform samplerCube u_cubeMap;\n' +
'varying vec3 v_positionEC;\n' +
'varying vec3 v_normalEC;\n' +
//'varying vec2 v_st;\n' +
//'\n' +
'void main()\n' +
'{\n' +
' gl_FragColor = textureLod(u_cubeMap, normalize((czm_inverseModelView * vec4(v_positionEC, 1.0)).xyz), 5.0);\n' +
'}\n';
customAppearance.isTranslucent = function() { return false; };
customAppearance.getRenderState = function() {
return {
depthTest : {
enabled : true
}
};
};
customAppearance.getVertexShaderSource = function() { return this.vertexShaderSource; };
customAppearance.getFragmentShaderSource = function() { return this.fragmentShaderSource; };
customAppearance.material = {
update : function() {},
_uniforms : {
u_cubeMap : function() {
return cubeMap;
}
}
};
scene.primitives.add(new Cesium.Primitive({
geometryInstances : boxGeometryInstance,
appearance : customAppearance,
asynchronous : false,
modelMatrix : modelMatrix
}));
});

var modelURL = '../../SampleData/models/Spheres/MetalRoughSpheres.glb';
var height = 5000000.0;
var heading = 0.0;
var pitch = 0.0;
var roll = 0.0;
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);

var origin = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height);
var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, hpr);

var model = scene.primitives.add(Cesium.Model.fromGltf({
url : modelURL,
@@ -178,12 +245,20 @@
var src = 0;
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
/*
var b = srcBuffer[src];
src++;
var g = srcBuffer[src];
src++;
var r = srcBuffer[src];
src++;
*/
var r = srcBuffer[src];
src++;
var g = srcBuffer[src];
src++;
var b = srcBuffer[src];
src++;
var a = srcBuffer[src];
src++;
byteArray[dst] = r;
6 changes: 5 additions & 1 deletion Source/Renderer/CubeMap.js
Original file line number Diff line number Diff line change
@@ -194,8 +194,8 @@ define([

var mipLevels = options.mipLevels;
if (defined(mipLevels)) {
gl.generateMipmap(textureTarget);
var mipLevelsLength = mipLevels.length;
gl.generateMipmap(textureTarget);
for (var j = 0; j < mipLevelsLength; ++j) {
createFace(gl.TEXTURE_CUBE_MAP_POSITIVE_X, mipLevels[j].positiveX, j + 1, preMultiplyAlpha, flipY);
createFace(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, mipLevels[j].negativeX, j + 1, preMultiplyAlpha, flipY);
@@ -204,6 +204,7 @@ define([
createFace(gl.TEXTURE_CUBE_MAP_POSITIVE_Z, mipLevels[j].positiveZ, j + 1, preMultiplyAlpha, flipY);
createFace(gl.TEXTURE_CUBE_MAP_NEGATIVE_Z, mipLevels[j].negativeZ, j + 1, preMultiplyAlpha, flipY);
}
this._hasMipmap = true;
}
} else {
gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, pixelFormat, size, size, 0, pixelFormat, pixelDatatype, null);
@@ -375,6 +376,9 @@ define([
* });
*/
CubeMap.prototype.generateMipmap = function(hint) {
if (this._hasMipmap) {
return;
}
hint = defaultValue(hint, MipmapHint.DONT_CARE);

//>>includeStart('debug', pragmas.debug);
4 changes: 2 additions & 2 deletions Source/Scene/SkyBox.js
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ define([
modelMatrix : Matrix4.clone(Matrix4.IDENTITY),
owner : this
});
this._cubeMap = options.cubeMap;
this._cubeMap = undefined;

this._attributeLocations = undefined;
this._useHDR = undefined;
@@ -135,7 +135,7 @@ define([

var context = frameState.context;

if (defined(this.sources) && this._sources !== this.sources) {
if (this._sources !== this.sources) {
this._sources = this.sources;
var sources = this.sources;

5 changes: 2 additions & 3 deletions Source/Shaders/SkyBoxFS.glsl
Original file line number Diff line number Diff line change
@@ -4,8 +4,7 @@ varying vec3 v_texCoord;

void main()
{
//vec3 rgb = textureCube(u_cubeMap, normalize(v_texCoord)).rgb;
vec3 rgb = textureLod(u_cubeMap, normalize(v_texCoord), 8.0).rgb;
//rgb = czm_gammaCorrect(rgb);
vec3 rgb = textureCube(u_cubeMap, normalize(v_texCoord)).rgb;
rgb = czm_gammaCorrect(rgb);
gl_FragColor = vec4(rgb, czm_morphTime);
}