Skip to content

Commit

Permalink
Merge pull request #5200 from AnalyticalGraphicsInc/fxaa-upgrade
Browse files Browse the repository at this point in the history
Upgrade FXAA
  • Loading branch information
pjcozzi authored Apr 13, 2017
2 parents dd8583c + 4591db0 commit d6bc1ac
Show file tree
Hide file tree
Showing 8 changed files with 709 additions and 254 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Thumbs.db
/Source/Shaders/*.js
/Source/Shaders/*/*.js
/Source/Shaders/*/*/*.js
/Source/ThirdParty/Shaders/*.js

/Specs/SpecList.js

Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Change Log
* Added `disableDepthTestDistance` to billboards, points and labels. This sets the distance to the camera where the depth test will be disabled. Setting it to zero (the default) will alwasy enable the depth test. Setting it to `Number.POSITVE_INFINITY` will never enabled the depth test. Also added `scene.minimumDisableDepthTestDistance` to change the default value from zero. [#5166](https://github.com/AnalyticalGraphicsInc/cesium/pull/5166)
* Fixed issue with displaying `MapboxImageryProvider` default token error message [#5191](https://github.com/AnalyticalGraphicsInc/cesium/pull/5191)
* Added a `depthFailMaterial` property to line entities, which is the material used to render the line when it fails the depth test. [#5160](https://github.com/AnalyticalGraphicsInc/cesium/pull/5160)
* Upgrade FXAA to version 3.11. [#5200](https://github.com/AnalyticalGraphicsInc/cesium/pull/5200)

### 1.32 - 2017-04-03

Expand Down
6 changes: 3 additions & 3 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ https://gist.github.com/banksean/300494
>
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
### NVIDIA Image-Based Anti-Aliasing
### NVIDIA GameWorks Graphics Samples

https://developer.nvidia.com/nvidia-graphics-sdk-11-direct3d
https://github.com/NVIDIAGameWorks/GraphicsSamples

> Copyright 2011 NVIDIA Corporation
> Copyright 2016 NVIDIA Corporation
>
> BY DOWNLOADING THE SOFTWARE AND OTHER AVAILABLE MATERIALS, YOU ("DEVELOPER") AGREE TO BE BOUND BY THE FOLLOWING TERMS AND CONDITIONS
>
Expand Down
39 changes: 31 additions & 8 deletions Source/Scene/FXAA.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ define([
'../Renderer/Renderbuffer',
'../Renderer/RenderbufferFormat',
'../Renderer/RenderState',
'../Renderer/Sampler',
'../Renderer/Texture',
'../Shaders/PostProcessFilters/FXAA'
'../Renderer/TextureMagnificationFilter',
'../Renderer/TextureMinificationFilter',
'../Renderer/TextureWrap',
'../Shaders/PostProcessFilters/FXAA',
'../ThirdParty/Shaders/FXAA3_11'
], function(
BoundingRectangle,
Cartesian2,
Expand All @@ -27,14 +32,19 @@ define([
Renderbuffer,
RenderbufferFormat,
RenderState,
Sampler,
Texture,
FXAAFS) {
TextureMagnificationFilter,
TextureMinificationFilter,
TextureWrap,
FXAAFS,
FXAA3_11) {
'use strict';

/**
* @private
*/
function FXAA(context) {
function FXAA() {
this._texture = undefined;
this._depthStencilTexture = undefined;
this._depthStencilRenderbuffer = undefined;
Expand All @@ -50,6 +60,8 @@ define([
owner : this
});
this._clearCommand = clearCommand;

this._qualityPreset = 39;
}

function destroyResources(fxaa) {
Expand Down Expand Up @@ -85,7 +97,13 @@ define([
width : width,
height : height,
pixelFormat : PixelFormat.RGBA,
pixelDatatype : PixelDatatype.UNSIGNED_BYTE
pixelDatatype : PixelDatatype.UNSIGNED_BYTE,
sampler : new Sampler({
wrapS : TextureWrap.CLAMP_TO_EDGE,
wrapT : TextureWrap.CLAMP_TO_EDGE,
minificationFilter : TextureMinificationFilter.LINEAR,
magnificationFilter : TextureMagnificationFilter.LINEAR
})
});

if (context.depthTexture) {
Expand Down Expand Up @@ -119,7 +137,12 @@ define([
}

if (!defined(this._command)) {
this._command = context.createViewportQuadCommand(FXAAFS, {
var fs =
'#define FXAA_QUALITY_PRESET ' + this._qualityPreset + '\n' +
FXAA3_11 + '\n' +
FXAAFS;

this._command = context.createViewportQuadCommand(fs, {
owner : this
});
}
Expand All @@ -137,13 +160,13 @@ define([

if (textureChanged) {
var that = this;
var step = new Cartesian2(1.0 / this._texture.width, 1.0 / this._texture.height);
var rcpFrame = new Cartesian2(1.0 / this._texture.width, 1.0 / this._texture.height);
this._command.uniformMap = {
u_texture : function() {
return that._texture;
},
u_step : function() {
return step;
u_fxaaQualityRcpFrame : function() {
return rcpFrame;
}
};
}
Expand Down
11 changes: 8 additions & 3 deletions Source/Shaders/CompositeOITFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* - http://jcgt.org/published/0002/02/09/
* - http://casual-effects.blogspot.com/2014/03/weighted-blended-order-independent.html
*/

uniform sampler2D u_opaque;
uniform sampler2D u_accumulation;
uniform sampler2D u_revealage;
Expand All @@ -15,12 +15,17 @@ void main()
vec4 opaque = texture2D(u_opaque, v_textureCoordinates);
vec4 accum = texture2D(u_accumulation, v_textureCoordinates);
float r = texture2D(u_revealage, v_textureCoordinates).r;

#ifdef MRT
vec4 transparent = vec4(accum.rgb / clamp(r, 1e-4, 5e4), accum.a);
#else
vec4 transparent = vec4(accum.rgb / clamp(accum.a, 1e-4, 5e4), r);
#endif

gl_FragColor = (1.0 - transparent.a) * transparent + transparent.a * opaque;

if (opaque != czm_backgroundColor)
{
gl_FragColor.a = 1.0;
}
}
Loading

0 comments on commit d6bc1ac

Please sign in to comment.