-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Image-based lighting #7172
Changes from all commits
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 692bf7b
Use custom cube for showing env map. Use shader to access lod.
bagnell f645625
Add IBL to models. Reowrk setup code.
bagnell 59fb605
Functioning octahedral projection
6a4f965
Created octahedron map unpacking example
3a189e5
Fix orientation of cubemap temporarily. Add initial SH code.
bagnell af047fc
Pack mips with 1 pixel border
87f34eb
Make texture big enough
8c26eb9
Update spherical harmonics.
bagnell 8a34bcc
Merge pull request #7107 from OmarShehata/ibl
bagnell 2285282
Merge branch 'hdr' into ibl
bagnell 487329a
Fixes after merge.
bagnell 501450c
Fixed artifacts with octahedron projection
d378a3a
Merge pull request #7117 from OmarShehata/ibl
bagnell 9c30528
Initial integration of octahedral projection.
bagnell 9010669
Fix Octahedral sampling artifacts
ec89263
Experimental HDR procedural sky
9036674
Merge branch 'ibl' of https://github.com/OmarShehata/cesium into ibl
59068ef
Revert "Experimental HDR procedural sky"
e98524f
Store correct number for max mip level
d6c9894
Merge pull request #7122 from OmarShehata/ibl
bagnell b0b3708
Some clean up.
bagnell d253e7a
Revert cubemap changes to load mip levels and request WebGL 1.
bagnell e095567
Add doc. Fix typos.
bagnell eddbb9a
Reverse Z axis in cubemap
1a781a8
Better LOD choosing in octahedral
006d859
Add trilinear filtering to octahedral lod selection
5dca2a0
Only do bilinear filtering if texture_float_linear isn't supported
06080ba
Merge pull request #7126 from OmarShehata/ibl
bagnell ef321f8
Add CIE Clear Sky model to procedural environment
7562570
ACtually add the luminance
9eec64e
Merge pull request #7126 from OmarShehata/ibl
bagnell f190bea
Fix banding at lower mips
64faa12
Fix banding at lower mips
06ad9e4
Update KTX loader to load cube maps and mip map levels. Use RGBM for …
bagnell fb79863
Merge pull request #7142 from OmarShehata/fix-banding
bagnell 9f67f79
Merge pull request #7126 from OmarShehata/ibl
bagnell cdb21d5
Update KTX loader to load cube maps and mip map levels. Use RGBM for …
bagnell fa73474
Merge pull request #7126 from OmarShehata/ibl
bagnell 8da4636
Merge remote-tracking branch 'upstream/ibl' into ibl
14483ea
Added comment to shader
d521740
Fix linting errors
ffe83bf
Made luminance a uniform
ea67be3
Cleaned up luminance model
403cfe2
Typo with file import
321175b
Fix decoding for RGBM textures which is different for the tool used t…
bagnell 8039c66
Fix loadKTX tests
46c2134
Use shader constants and style tweaks.
bagnell a89d869
Add luminance when recreating shader
425ee75
Temp fix for swapped +/-Y face of RGBM files.
bagnell b02d663
Fix mipmap padding when loading KTX files.
bagnell 7a0c3f7
Add IBL example.
bagnell bbc256e
Fix specular map orientation.
bagnell 9c93d05
Merge branch 'hdr' into ibl
bagnell 79bc2c7
Merge pull request #7134 from OmarShehata/ibl
lilleyse 890630c
Merge pull request #7165 from OmarShehata/ibl-tests
bagnell 83ac2e1
Merge branch 'hdr' into ibl
bagnell 70dfda0
Fix after merge.
bagnell 7b99191
Add model IBL tests.
bagnell 172a188
Add Sandcastle example image.
bagnell b4055af
Remove temp +Y/-Y swap
1c0d10e
Add octahedral map test
7080b92
Merge branch 'hdr' into ibl
bagnell 7c8f53d
Add option to disable luminanceAtZenith and fix failing tests.
bagnell 7c1541a
Merge branch 'hdr' into ibl
bagnell 0f410d7
Add octahedral sampling test
30090e1
Note why we can't use scene.renderForSpecs
070ffa7
Fix spec name
78e3bf8
Refactor context render function
93a7b4b
Remove unnecessary clear.
bagnell d634e3b
Merge pull request #7183 from OmarShehata/ibl
bagnell 409fe64
Merge branch 'hdr' into ibl
bagnell 546efb5
Fix test after merge.
bagnell b01e0f0
Fix eslint errors.
bagnell 289e388
Merge branch 'hdr' into ibl
bagnell 58e8628
Doc typo
335430b
Add links to Sandcastle demo
e4d9ccd
Add comments to Sandcastle example
2d2a0d3
Remove diffuseIrradiance
950f102
Updated IBL docs
eb39ee7
Add some context
b34e329
Merge pull request #7231 from OmarShehata/ibl
pjcozzi 62c1846
Fix tests.
bagnell 80bf34e
Merge branch 'hdr' into ibl
bagnell 8367088
Small fixes
lilleyse bd72208
Add a texture cache. Use the texture cache for projected textures. Ot…
bagnell 7c1998e
Merge branch 'hdr' into ibl
bagnell 5e1559c
Add support for batched and instanced 3D Tiles.
bagnell 6162e47
Add default IBL options to scene.
bagnell a5bf4db
Merge branch 'master' into ibl
bagnell ae342b3
Add doc.
bagnell d8f8183
Merge branch 'master' into ibl
lilleyse 4a62071
Cubemaps must have the y-axis as the up axis. Remove TODO.
bagnell 646a3d9
Fix lighting for models in fixed coordinates.
bagnell aa6da4f
Change default luminance at zenith.
bagnell ba03cc6
Fix texture cache issue.
bagnell ecd4284
Merge branch 'master' into ibl
lilleyse 401e6b5
Fix reflection vector.
bagnell e6543d0
Use pawns model instead of spheres.
bagnell 60c85f7
Merge branch 'master' into ibl
bagnell e98e0f6
Fix tests after merge.
bagnell 16a5761
Merge branch 'master' into ibl
bagnell e37e417
Update the IBL Sandcastle example iage and CHANGES.md.
bagnell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"> | ||
<meta name="description" content="Use image-based lighting to light a model."> | ||
<meta name="cesium-sandcastle-labels" content="Showcases"> | ||
<title>Cesium Demo</title> | ||
<script type="text/javascript" src="../Sandcastle-header.js"></script> | ||
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script> | ||
<script type="text/javascript"> | ||
require.config({ | ||
baseUrl : '../../../Source', | ||
waitSeconds : 60 | ||
}); | ||
</script> | ||
</head> | ||
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html"> | ||
<style> | ||
@import url(../templates/bucket.css); | ||
</style> | ||
<div id="cesiumContainer" class="fullSize"></div> | ||
<div id="loadingOverlay"><h1>Loading...</h1></div> | ||
<div id="toolbar"> | ||
<table><tbody> | ||
<tr> | ||
<td>Luminance at Zenith</td> | ||
<td> | ||
<input type="range" min="0.0" max="2.0" step="0.01" data-bind="value: luminanceAtZenith, valueUpdate: 'input'"> | ||
<input type="text" size="4" data-bind="value: luminanceAtZenith"> | ||
</td> | ||
</tr> | ||
</tbody></table> | ||
</div> | ||
<script id="cesium_sandcastle_script"> | ||
function startup(Cesium) { | ||
'use strict'; | ||
//Sandcastle_Begin | ||
var viewer = new Cesium.Viewer('cesiumContainer'); | ||
|
||
var environmentMapURL = '../../SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx'; | ||
var modelURL = '../../SampleData/models/Pawns/Pawns.glb'; | ||
|
||
// This environment map was processed using Google's Filament project. To process your own: | ||
// 1 - Download the Filament release (https://github.com/google/filament/releases). | ||
// 2 - Run `cmgen --type=ktx --deploy=/path/to/output /path/to/image.hdr`. Other formats are also supported. Run `cmgen --help` for all options. | ||
// 3 - Take the generated coefficients and the KTX file and load them in CesiumJS as shown below. | ||
|
||
var L00 = new Cesium.Cartesian3( 0.170455150831422, 0.163151083190219, 0.196966760289763); | ||
var L1_1 = new Cesium.Cartesian3(-0.066550267689383, -0.022088055746048, 0.078835009246127); | ||
var L10 = new Cesium.Cartesian3( 0.038364097478591, 0.045714300098753, 0.063498904606215); | ||
var L11 = new Cesium.Cartesian3(-0.014365363312810, -0.026490613715151, -0.050189404066020); | ||
var L2_2 = new Cesium.Cartesian3(-0.051532786917890, -0.050777795729986, -0.056449044453032); | ||
var L2_1 = new Cesium.Cartesian3( 0.043454596136534, 0.046672590104157, 0.057530107646610); | ||
var L20 = new Cesium.Cartesian3(-0.001640466274110, 0.001286638231156, 0.007228908989616); | ||
var L21 = new Cesium.Cartesian3(-0.042260855700641, -0.046394335094707, -0.057562936365585); | ||
var L22 = new Cesium.Cartesian3(-0.004953478914091, -0.000479681664876, 0.008508150106928); | ||
var coefficients = [L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22]; | ||
|
||
var height = 0.0; | ||
var hpr = new Cesium.HeadingPitchRoll(0.0, 0.0, 0.0); | ||
var origin = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height); | ||
var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, hpr); | ||
|
||
var model = viewer.scene.primitives.add(Cesium.Model.fromGltf({ | ||
url : modelURL, | ||
modelMatrix : modelMatrix, | ||
minimumPixelSize : 128 | ||
})); | ||
|
||
model.readyPromise.then(function(model) { | ||
var camera = viewer.camera; | ||
|
||
// Zoom to model | ||
var controller = viewer.scene.screenSpaceCameraController; | ||
var r = 2.0 * Math.max(model.boundingSphere.radius, camera.frustum.near); | ||
controller.minimumZoomDistance = r * 0.5; | ||
|
||
var center = Cesium.Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere.center, new Cesium.Cartesian3()); | ||
var heading = Cesium.Math.toRadians(230.0); | ||
var pitch = Cesium.Math.toRadians(-20.0); | ||
camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, r * 2.0)); | ||
camera.lookAtTransform(Cesium.Matrix4.IDENTITY); | ||
|
||
model.sphericalHarmonicCoefficients = coefficients; | ||
model.specularEnvironmentMaps = environmentMapURL; | ||
|
||
// The viewModel tracks the state of our mini application. | ||
var viewModel = { | ||
luminanceAtZenith : model.luminanceAtZenith | ||
}; | ||
// Convert the viewModel members into knockout observables. | ||
Cesium.knockout.track(viewModel); | ||
|
||
// Bind the viewModel to the DOM elements of the UI that call for it. | ||
var toolbar = document.getElementById('toolbar'); | ||
Cesium.knockout.applyBindings(viewModel, toolbar); | ||
|
||
function subscribeParameter(name) { | ||
Cesium.knockout.getObservable(viewModel, name).subscribe( | ||
function(newValue) { | ||
model[name] = newValue; | ||
} | ||
); | ||
} | ||
|
||
subscribeParameter('luminanceAtZenith'); | ||
|
||
Sandcastle.addToggleButton('Use procedural image', false, function(checked) { | ||
if (!checked) { | ||
model.sphericalHarmonicCoefficients = coefficients; | ||
model.specularEnvironmentMaps = environmentMapURL; | ||
} else { | ||
model.sphericalHarmonicCoefficients = undefined; | ||
model.specularEnvironmentMaps = undefined; | ||
} | ||
}); | ||
}).otherwise(function(error){ | ||
window.alert(error); | ||
}); | ||
//Sandcastle_End | ||
Sandcastle.finishedLoading(); | ||
} | ||
if (typeof Cesium !== 'undefined') { | ||
startup(Cesium); | ||
} else if (typeof require === 'function') { | ||
require(['Cesium'], startup); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some things that would improve this demo:
luminanceAtZenith
. The property references this demo but the demo does't set it.imageBasedLightingFactor
andlightColor
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not? The idea is to show how the image-based lighting changes when the metallic/roughness parameters change. I think it might be better to have a model and change those parameters, but I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we just try to stray away from test models in general. For PBR we switched from the the sci-fi helmet to the ground vehicle for this reason. I just realized we don't have any boat models. Maybe there is a good one out there that has a good mix of metallic and roughness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was browsing Sketchfab and this helicopter model seemed pretty good. It has smooth metallic areas which is nice. We would probably want to shrink some of the textures and apply Draco compression though.
https://sketchfab.com/models/dca5ae065c584817bf59c53a0920f785.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more suggestions for the demo
imageBasedLightingFactor
andlightColor
to get the full sweep of lighting effects.