Skip to content

Commit

Permalink
Merge pull request #4747 from AnalyticalGraphicsInc/depth-stencil
Browse files Browse the repository at this point in the history
Use depth-stencil for FXAA
  • Loading branch information
pjcozzi authored Dec 13, 2016
2 parents 6d3afb2 + 574b663 commit 56aebfc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Change Log
* Fixed tooltips for gallery thumbnails in Sandcastle [#4702](https://github.com/AnalyticalGraphicsInc/cesium/pull/4702)
* Fixed `Rectangle.union` to correctly account for rectangles that cross the IDL [#4732](https://github.com/AnalyticalGraphicsInc/cesium/pull/4732).
* Fixed texture rotation for `RectangleGeometry` [#2737](https://github.com/AnalyticalGraphicsInc/cesium/issues/2737)
* Fixed an bug that caused `GroundPrimitive` to render incorrectly on systems without the `WEBGL_depth_texture` extension. [#4747](https://github.com/AnalyticalGraphicsInc/cesium/pull/4747)

### 1.28 - 2016-12-01

Expand Down
1 change: 1 addition & 0 deletions Source/Renderer/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ define([

// Override select WebGL defaults
webglOptions.alpha = defaultValue(webglOptions.alpha, false); // WebGL default is true
webglOptions.stencil = defaultValue(webglOptions.stencil, true); // WebGL default is false

var defaultToWebgl2 = false;
var webgl2Supported = (typeof WebGL2RenderingContext !== 'undefined');
Expand Down
32 changes: 16 additions & 16 deletions Source/Scene/FXAA.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ define([
*/
function FXAA(context) {
this._texture = undefined;
this._depthTexture = undefined;
this._depthRenderbuffer = undefined;
this._depthStencilTexture = undefined;
this._depthStencilRenderbuffer = undefined;
this._fbo = undefined;
this._command = undefined;

Expand All @@ -55,13 +55,13 @@ define([
function destroyResources(fxaa) {
fxaa._fbo = fxaa._fbo && fxaa._fbo.destroy();
fxaa._texture = fxaa._texture && fxaa._texture.destroy();
fxaa._depthTexture = fxaa._depthTexture && fxaa._depthTexture.destroy();
fxaa._depthRenderbuffer = fxaa._depthRenderbuffer && fxaa._depthRenderbuffer.destroy();
fxaa._depthStencilTexture = fxaa._depthStencilTexture && fxaa._depthStencilTexture.destroy();
fxaa._depthStencilRenderbuffer = fxaa._depthStencilRenderbuffer && fxaa._depthStencilRenderbuffer.destroy();

fxaa._fbo = undefined;
fxaa._texture = undefined;
fxaa._depthTexture = undefined;
fxaa._depthRenderbuffer = undefined;
fxaa._depthStencilTexture = undefined;
fxaa._depthStencilRenderbuffer = undefined;

if (defined(fxaa._command)) {
fxaa._command.shaderProgram = fxaa._command.shaderProgram && fxaa._command.shaderProgram.destroy();
Expand All @@ -77,8 +77,8 @@ define([
var textureChanged = !defined(fxaaTexture) || fxaaTexture.width !== width || fxaaTexture.height !== height;
if (textureChanged) {
this._texture = this._texture && this._texture.destroy();
this._depthTexture = this._depthTexture && this._depthTexture.destroy();
this._depthRenderbuffer = this._depthRenderbuffer && this._depthRenderbuffer.destroy();
this._depthStencilTexture = this._depthStencilTexture && this._depthStencilTexture.destroy();
this._depthStencilRenderbuffer = this._depthStencilRenderbuffer && this._depthStencilRenderbuffer.destroy();

this._texture = new Texture({
context : context,
Expand All @@ -88,20 +88,20 @@ define([
pixelDatatype : PixelDatatype.UNSIGNED_BYTE
});

if (context.depthTexture) {
this._depthTexture = new Texture({
if (context.depthStencilTexture) {
this._depthStencilTexture = new Texture({
context : context,
width : width,
height : height,
pixelFormat : PixelFormat.DEPTH_COMPONENT,
pixelDatatype : PixelDatatype.UNSIGNED_SHORT
pixelFormat : PixelFormat.DEPTH_STENCIL,
pixelDatatype : PixelDatatype.UNSIGNED_INT_24_8
});
} else {
this._depthRenderbuffer = new Renderbuffer({
this._depthStencilRenderbuffer = new Renderbuffer({
context : context,
width : width,
height : height,
format : RenderbufferFormat.DEPTH_COMPONENT16
format : RenderbufferFormat.DEPTH_STENCIL
});
}
}
Expand All @@ -112,8 +112,8 @@ define([
this._fbo = new Framebuffer({
context : context,
colorTextures : [this._texture],
depthTexture : this._depthTexture,
depthRenderbuffer : this._depthRenderbuffer,
depthStencilTexture : this._depthStencilTexture,
depthStencilRenderbuffer : this._depthStencilRenderbuffer,
destroyAttachments : false
});
}
Expand Down

0 comments on commit 56aebfc

Please sign in to comment.