web overlays and entities are always nonAA

This commit is contained in:
SamGondelman 2017-08-24 14:23:21 -07:00
parent eb9436ba96
commit 4a49801217
7 changed files with 15 additions and 62 deletions

View file

@ -26,8 +26,7 @@ Base3DOverlay::Base3DOverlay() :
_isSolid(DEFAULT_IS_SOLID), _isSolid(DEFAULT_IS_SOLID),
_isDashedLine(DEFAULT_IS_DASHED_LINE), _isDashedLine(DEFAULT_IS_DASHED_LINE),
_ignoreRayIntersection(false), _ignoreRayIntersection(false),
_drawInFront(false), _drawInFront(false)
_isAA(true)
{ {
} }
@ -39,7 +38,6 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) :
_isDashedLine(base3DOverlay->_isDashedLine), _isDashedLine(base3DOverlay->_isDashedLine),
_ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection), _ignoreRayIntersection(base3DOverlay->_ignoreRayIntersection),
_drawInFront(base3DOverlay->_drawInFront), _drawInFront(base3DOverlay->_drawInFront),
_isAA(base3DOverlay->_isAA),
_isGrabbable(base3DOverlay->_isGrabbable) _isGrabbable(base3DOverlay->_isGrabbable)
{ {
setTransform(base3DOverlay->getTransform()); setTransform(base3DOverlay->getTransform());
@ -191,13 +189,6 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
needRenderItemUpdate = true; needRenderItemUpdate = true;
} }
auto isAA = properties["isAA"];
if (isAA.isValid()) {
bool value = isAA.toBool();
setIsAA(value);
needRenderItemUpdate = true;
}
// Communicate changes to the renderItem if needed // Communicate changes to the renderItem if needed
if (needRenderItemUpdate) { if (needRenderItemUpdate) {
auto itemID = getRenderItemID(); auto itemID = getRenderItemID();
@ -253,9 +244,6 @@ QVariant Base3DOverlay::getProperty(const QString& property) {
if (property == "parentJointIndex") { if (property == "parentJointIndex") {
return getParentJointIndex(); return getParentJointIndex();
} }
if (property == "isAA") {
return _isAA;
}
return Overlay::getProperty(property); return Overlay::getProperty(property);
} }

View file

@ -43,14 +43,11 @@ public:
bool getDrawInFront() const { return _drawInFront; } bool getDrawInFront() const { return _drawInFront; }
bool getIsGrabbable() const { return _isGrabbable; } bool getIsGrabbable() const { return _isGrabbable; }
virtual bool isAA() const { return _isAA; }
void setLineWidth(float lineWidth) { _lineWidth = lineWidth; } void setLineWidth(float lineWidth) { _lineWidth = lineWidth; }
void setIsSolid(bool isSolid) { _isSolid = isSolid; } void setIsSolid(bool isSolid) { _isSolid = isSolid; }
void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; } void setIsDashedLine(bool isDashedLine) { _isDashedLine = isDashedLine; }
void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; } void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; }
void setDrawInFront(bool value) { _drawInFront = value; } void setDrawInFront(bool value) { _drawInFront = value; }
void setIsAA(bool value) { _isAA = value; }
void setIsGrabbable(bool value) { _isGrabbable = value; } void setIsGrabbable(bool value) { _isGrabbable = value; }
virtual AABox getBounds() const override = 0; virtual AABox getBounds() const override = 0;
@ -75,7 +72,6 @@ protected:
bool _isDashedLine; bool _isDashedLine;
bool _ignoreRayIntersection; bool _ignoreRayIntersection;
bool _drawInFront; bool _drawInFront;
bool _isAA;
bool _isGrabbable { false }; bool _isGrabbable { false };
QString _name; QString _name;

View file

@ -309,9 +309,9 @@ void Web3DOverlay::render(RenderArgs* args) {
batch.setModelTransform(transform); batch.setModelTransform(transform);
auto geometryCache = DependencyManager::get<GeometryCache>(); auto geometryCache = DependencyManager::get<GeometryCache>();
if (color.a < OPAQUE_ALPHA_THRESHOLD) { if (color.a < OPAQUE_ALPHA_THRESHOLD) {
geometryCache->bindTransparentWebBrowserProgram(batch, _isAA); geometryCache->bindWebBrowserProgram(batch, true);
} else { } else {
geometryCache->bindOpaqueWebBrowserProgram(batch, _isAA); geometryCache->bindWebBrowserProgram(batch);
} }
geometryCache->renderQuad(batch, halfSize * -1.0f, halfSize, vec2(0), vec2(1), color, _geometryId); geometryCache->renderQuad(batch, halfSize * -1.0f, halfSize, vec2(0), vec2(1), color, _geometryId);
batch.setResourceTexture(0, nullptr); // restore default white color after me batch.setResourceTexture(0, nullptr); // restore default white color after me

View file

@ -231,11 +231,10 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
batch._glColor4f(1.0f, 1.0f, 1.0f, fadeRatio); batch._glColor4f(1.0f, 1.0f, 1.0f, fadeRatio);
const bool IS_AA = true;
if (fadeRatio < OPAQUE_ALPHA_THRESHOLD) { if (fadeRatio < OPAQUE_ALPHA_THRESHOLD) {
DependencyManager::get<GeometryCache>()->bindTransparentWebBrowserProgram(batch, IS_AA); DependencyManager::get<GeometryCache>()->bindWebBrowserProgram(batch, true);
} else { } else {
DependencyManager::get<GeometryCache>()->bindOpaqueWebBrowserProgram(batch, IS_AA); DependencyManager::get<GeometryCache>()->bindWebBrowserProgram(batch);
} }
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f, 1.0f, 1.0f, fadeRatio), _geometryId); DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f, 1.0f, 1.0f, fadeRatio), _geometryId);
} }

View file

@ -1923,7 +1923,7 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) {
return a.getRaw() == b.getRaw(); return a.getRaw() == b.getRaw();
} }
static void buildWebShader(const std::string& vertShaderText, const std::string& fragShaderText, bool blendEnable, bool isAA, static void buildWebShader(const std::string& vertShaderText, const std::string& fragShaderText, bool blendEnable,
gpu::ShaderPointer& shaderPointerOut, gpu::PipelinePointer& pipelinePointerOut) { gpu::ShaderPointer& shaderPointerOut, gpu::PipelinePointer& pipelinePointerOut) {
auto VS = gpu::Shader::createVertex(vertShaderText); auto VS = gpu::Shader::createVertex(vertShaderText);
auto PS = gpu::Shader::createPixel(fragShaderText); auto PS = gpu::Shader::createPixel(fragShaderText);
@ -1939,43 +1939,23 @@ static void buildWebShader(const std::string& vertShaderText, const std::string&
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
if (isAA) { PrepareStencil::testMaskDrawShapeNoAA(*state);
blendEnable ? PrepareStencil::testMask(*state) : PrepareStencil::testMaskDrawShape(*state);
} else {
PrepareStencil::testMaskDrawShapeNoAA(*state);
}
pipelinePointerOut = gpu::Pipeline::create(shaderPointerOut, state); pipelinePointerOut = gpu::Pipeline::create(shaderPointerOut, state);
} }
void GeometryCache::bindOpaqueWebBrowserProgram(gpu::Batch& batch, bool isAA) { void GeometryCache::bindWebBrowserProgram(gpu::Batch& batch, bool transparent) {
batch.setPipeline(getOpaqueWebBrowserProgram(isAA)); batch.setPipeline(getWebBrowserProgram(transparent));
} }
gpu::PipelinePointer GeometryCache::getOpaqueWebBrowserProgram(bool isAA) { gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent) {
static std::once_flag once; static std::once_flag once;
std::call_once(once, [&]() { std::call_once(once, [&]() {
const bool BLEND_ENABLE = false; buildWebShader(simple_vert, simple_opaque_web_browser_frag, false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipelineNoAA);
buildWebShader(simple_vert, simple_opaque_web_browser_frag, BLEND_ENABLE, true, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipeline); buildWebShader(simple_vert, simple_transparent_web_browser_frag, true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipelineNoAA);
buildWebShader(simple_vert, simple_opaque_web_browser_frag, BLEND_ENABLE, false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipelineNoAA);
}); });
return isAA ? _simpleOpaqueWebBrowserPipeline : _simpleOpaqueWebBrowserPipelineNoAA; return transparent ? _simpleTransparentWebBrowserPipelineNoAA : _simpleOpaqueWebBrowserPipelineNoAA;
}
void GeometryCache::bindTransparentWebBrowserProgram(gpu::Batch& batch, bool isAA) {
batch.setPipeline(getTransparentWebBrowserProgram(isAA));
}
gpu::PipelinePointer GeometryCache::getTransparentWebBrowserProgram(bool isAA) {
static std::once_flag once;
std::call_once(once, [&]() {
const bool BLEND_ENABLE = true;
buildWebShader(simple_vert, simple_transparent_web_browser_frag, BLEND_ENABLE, true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipeline);
buildWebShader(simple_vert, simple_transparent_web_browser_frag, BLEND_ENABLE, false, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipelineNoAA);
});
return isAA ? _simpleTransparentWebBrowserPipeline : _simpleTransparentWebBrowserPipelineNoAA;
} }
void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool transparent, bool culled, bool unlit, bool depthBiased) { void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool transparent, bool culled, bool unlit, bool depthBiased) {

View file

@ -166,11 +166,8 @@ public:
static gpu::PipelinePointer getSimplePipeline(bool textured = false, bool transparent = false, bool culled = true, static gpu::PipelinePointer getSimplePipeline(bool textured = false, bool transparent = false, bool culled = true,
bool unlit = false, bool depthBias = false, bool fading = false); bool unlit = false, bool depthBias = false, bool fading = false);
void bindOpaqueWebBrowserProgram(gpu::Batch& batch, bool isAA); void bindWebBrowserProgram(gpu::Batch& batch, bool transparent = false);
gpu::PipelinePointer getOpaqueWebBrowserProgram(bool isAA); gpu::PipelinePointer getWebBrowserProgram(bool transparent);
void bindTransparentWebBrowserProgram(gpu::Batch& batch, bool isAA);
gpu::PipelinePointer getTransparentWebBrowserProgram(bool isAA);
static void initializeShapePipelines(); static void initializeShapePipelines();
@ -459,10 +456,8 @@ private:
static QHash<SimpleProgramKey, gpu::PipelinePointer> _simplePrograms; static QHash<SimpleProgramKey, gpu::PipelinePointer> _simplePrograms;
gpu::ShaderPointer _simpleOpaqueWebBrowserShader; gpu::ShaderPointer _simpleOpaqueWebBrowserShader;
gpu::PipelinePointer _simpleOpaqueWebBrowserPipeline;
gpu::PipelinePointer _simpleOpaqueWebBrowserPipelineNoAA; gpu::PipelinePointer _simpleOpaqueWebBrowserPipelineNoAA;
gpu::ShaderPointer _simpleTransparentWebBrowserShader; gpu::ShaderPointer _simpleTransparentWebBrowserShader;
gpu::PipelinePointer _simpleTransparentWebBrowserPipeline;
gpu::PipelinePointer _simpleTransparentWebBrowserPipelineNoAA; gpu::PipelinePointer _simpleTransparentWebBrowserPipelineNoAA;
static render::ShapePipelinePointer getShapePipeline(bool textured = false, bool transparent = false, bool culled = true, static render::ShapePipelinePointer getShapePipeline(bool textured = false, bool transparent = false, bool culled = true,

View file

@ -167,7 +167,6 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location, visible) {
parentID: this.tabletEntityID, parentID: this.tabletEntityID,
parentJointIndex: -1, parentJointIndex: -1,
showKeyboardFocusHighlight: false, showKeyboardFocusHighlight: false,
isAA: HMD.active,
visible: visible visible: visible
}); });
@ -453,10 +452,6 @@ WebTablet.prototype.onHmdChanged = function () {
this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties);
// TODO -- is this still needed? // TODO -- is this still needed?
// Entities.editEntity(this.tabletEntityID, tabletProperties); // Entities.editEntity(this.tabletEntityID, tabletProperties);
// Full scene FXAA should be disabled on the overlay when the tablet in desktop mode.
// This should make the text more readable.
Overlays.editOverlay(this.webOverlayID, { isAA: HMD.active });
}; };
WebTablet.prototype.pickle = function () { WebTablet.prototype.pickle = function () {