-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Upgrade FXAA #5200
Upgrade FXAA #5200
Changes from 5 commits
ab9ac5a
54ad83f
9b5fc9c
19d88ea
5d19711
94e1489
6831fbe
85369c2
f4c2208
2b36361
70066a9
4591db0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', | ||
'../Shaders/PostProcessFilters/FXAA3_11' | ||
], function( | ||
BoundingRectangle, | ||
Cartesian2, | ||
|
@@ -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; | ||
|
@@ -50,6 +60,11 @@ define([ | |
owner : this | ||
}); | ||
this._clearCommand = clearCommand; | ||
|
||
this._qualityPreset = 39; | ||
this._qualitySubPix = 0.5; | ||
this._qualityEdgeThreshold = 0.125; | ||
this._qualityEdgeThresholdMin = 0.0833; | ||
} | ||
|
||
function destroyResources(fxaa) { | ||
|
@@ -85,7 +100,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) { | ||
|
@@ -119,7 +140,15 @@ define([ | |
} | ||
|
||
if (!defined(this._command)) { | ||
this._command = context.createViewportQuadCommand(FXAAFS, { | ||
var fs = | ||
'#define FXAA_PC 1\n' + | ||
'#define FXAA_WEBGL_1 1\n' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there WebGL 2 optimizations that we should roadmap in #797? If so, please update that issue. |
||
'#define FXAA_QUALITY_PRESET ' + this._qualityPreset + '\n' + | ||
'#define FXAA_GREEN_AS_LUMA 1\n' + | ||
FXAA3_11 + '\n' + | ||
FXAAFS; | ||
|
||
this._command = context.createViewportQuadCommand(fs, { | ||
owner : this | ||
}); | ||
} | ||
|
@@ -137,13 +166,22 @@ 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; | ||
}, | ||
u_fxaaQualitySubpix : function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These three aren't used, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I forgot those as well. Removed. |
||
return that._qualitySubPix; | ||
}, | ||
u_fxaaQualityEdgeThreshold : function() { | ||
return that._qualityEdgeThreshold; | ||
}, | ||
u_fxaaQualityEdgeThresholdMin : function() { | ||
return that._qualityEdgeThresholdMin; | ||
} | ||
}; | ||
} | ||
|
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.
Should these be packed into a
vec4
or just constants in the shader?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 made them shader comments. I wasn't sure if we would expose them. I'm leaving
_qualityPreset
which is a preprocessor constant because we may expose it or change it for mobile. The possible values are 10-15, 20-29 or 39 (Its documented in a shader comment).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.
Sounds good, but did you forget a commit to remove the three properties below?
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.
Yup, thanks.