void LLDrawPoolAlpha::render(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_ALPHA); LLGLSPipelineAlpha gls_pipeline_alpha; if (LLPipeline::sFastAlpha && !deferred_render) { gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f); if (mVertexShaderLevel > 0) { if (!LLPipeline::sRenderDeferred) { simple_shader->bind(); pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask()); } fullbright_shader->bind(); pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask()); LLGLSLShader::bindNoShader(); } else { gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask()); gPipeline.enableLightsDynamic(); pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask()); } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy ? GL_TRUE : GL_FALSE); renderAlpha(getVertexDataMask()); if (deferred_render && current_shader != NULL) { gPipeline.unbindDeferredShader(*current_shader); } if (sShowDebugAlpha) { if(gPipeline.canUseWindLightShaders()) { LLGLSLShader::bindNoShader(); } gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); glColor4f(1,0,0,1); LLViewerImage::sSmokeImagep->addTextureStats(1024.f*1024.f); gGL.getTexUnit(0)->bind(LLViewerImage::sSmokeImagep.get(), TRUE); renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); } }
void LLDrawPoolAlpha::render(std::vector<LLSpatialGroup*>& groups) { LLGLDepthTest gls_depth(GL_TRUE); LLGLSPipelineAlpha gls_pipeline_alpha; gPipeline.enableLightsDynamic(1.f); renderAlpha(getVertexDataMask(), groups); if (sShowDebugAlpha) { glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); glColor4f(1,0,0,1); LLViewerImage::sSmokeImagep->addTextureStats(1024.f*1024.f); LLViewerImage::sSmokeImagep->bind(); renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD, groups); } }
void LLDrawPoolAlpha::render(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_ALPHA); LLGLSPipelineAlpha gls_pipeline_alpha; gGL.setColorMask(true, true); if (LLPipeline::sFastAlpha && !deferred_render) { mColorSFactor = LLRender::BF_ONE; // } mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow mAlphaSFactor = LLRender::BF_ZERO; mAlphaDFactor = LLRender::BF_ZERO; // block (zero-out) glow where the alpha test succeeds gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f); if (mVertexShaderLevel > 0) { if (!LLPipeline::sRenderDeferred) { simple_shader->bind(); pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask()); } fullbright_shader->bind(); pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask()); LLGLSLShader::bindNoShader(); } else { gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask()); gPipeline.enableLightsDynamic(); pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask()); } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy ? GL_TRUE : GL_FALSE); mColorSFactor = LLRender::BF_SOURCE_ALPHA; // } regular alpha blend mColorDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } mAlphaSFactor = LLRender::BF_ZERO; // } glow suppression mAlphaDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); renderAlpha(getVertexDataMask()); gGL.setColorMask(true, false); if (deferred_render && current_shader != NULL) { gPipeline.unbindDeferredShader(*current_shader); } if (sShowDebugAlpha) { if(gPipeline.canUseWindLightShaders()) { LLGLSLShader::bindNoShader(); } gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); glColor4f(1,0,0,1); LLViewerImage::sSmokeImagep->addTextureStats(1024.f*1024.f); gGL.getTexUnit(0)->bind(LLViewerImage::sSmokeImagep.get(), TRUE); renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); } }
void LLDrawPoolAlpha::render(S32 pass) { LL_RECORD_BLOCK_TIME(FTM_RENDER_ALPHA); LLGLSPipelineAlpha gls_pipeline_alpha; if (deferred_render && pass == 1) { //depth only gGL.setColorMask(false, false); } else { gGL.setColorMask(true, true); } bool write_depth = LLDrawPoolWater::sSkipScreenCopy || (deferred_render && pass == 1) // we want depth written so that rendered alpha will // contribute to the alpha mask used for impostors || LLPipeline::sImpostorRenderAlphaDepthPass; LLGLDepthTest depth(GL_TRUE, write_depth ? GL_TRUE : GL_FALSE); if (deferred_render && pass == 1) { gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); } else { mColorSFactor = LLRender::BF_SOURCE_ALPHA; // } regular alpha blend mColorDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } mAlphaSFactor = LLRender::BF_ZERO; // } glow suppression mAlphaDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); if (mVertexShaderLevel > 0) { if (LLPipeline::sImpostorRender) { fullbright_shader->bind(); fullbright_shader->setMinimumAlpha(0.5f); simple_shader->bind(); simple_shader->setMinimumAlpha(0.5f); } else { fullbright_shader->bind(); fullbright_shader->setMinimumAlpha(0.f); simple_shader->bind(); simple_shader->setMinimumAlpha(0.f); } } else { if (LLPipeline::sImpostorRender) { gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); //OK } else { gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK } } } if (mVertexShaderLevel > 0) { renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2, pass); } else { renderAlpha(getVertexDataMask(), pass); } gGL.setColorMask(true, false); if (deferred_render && pass == 1) { gGL.setSceneBlendType(LLRender::BT_ALPHA); } if (sShowDebugAlpha) { BOOL shaders = gPipeline.canUseVertexShaders(); if(shaders) { gHighlightProgram.bind(); } else { gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); } gGL.diffuseColor4f(1,0,0,1); LLViewerFetchedTexture::sSmokeImagep->addTextureStats(1024.f*1024.f); gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sSmokeImagep, TRUE) ; renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); pushBatches(LLRenderPass::PASS_ALPHA_MASK, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); pushBatches(LLRenderPass::PASS_ALPHA_INVISIBLE, LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, FALSE); if(shaders) { gHighlightProgram.unbind(); } } }
QuillImage LoadFilter::apply(const QuillImage &tile) const { if (priv->fileFormatQt.isEmpty() && !priv->isInvalid) const_cast<LoadFilter *>(this)->detectFormat(); if (priv->isInvalid) return QuillImage(); bool isNew = !reader || (filterAddress != this) || !priv->bufferInitialized || !tile.isFragment() || (priv->fileFormatQt != reader->format()) || (!tile.targetSize().isEmpty() && (tile.targetSize() != tile.area().size())); filterAddress = const_cast<LoadFilter*>(this); priv->bufferInitialized = true; if (priv->iODevice) { delete reader; reader = new QImageReader(priv->iODevice, priv->fileFormatQt.toAscii()); if (!priv->fileFormatQt.isEmpty()) reader->setFormat(priv->fileFormatQt.toAscii()); } else { if (isNew) { delete reader; reader = 0; if (!const_cast<LoadFilter*>(this)->readFileToByteArray()) return QuillImage(); buffer.seek(0); priv->orientation = readOrientation(); reader = new QImageReader(&buffer, priv->fileFormatQt.toAscii()); if (!priv->fileFormatQt.isEmpty()) reader->setFormat(priv->fileFormatQt.toAscii()); } else { buffer.seek(0); } } QuillImage input = tile; if (input.fullImageSize().isEmpty()) input.setFullImageSize(reader->size()); if (input.area().isEmpty()) input.setArea(QRect(QPoint(0, 0), input.fullImageSize())); QImage newImage; QSize targetSize = input.targetSize(); QSize fullImageSize = input.fullImageSize(); QRect area = rotateArea(fullImageSize, input.area(), input); if ((priv->orientation == Exif_Orientation_Rotated90) || (priv->orientation == Exif_Orientation_Rotated270)) { targetSize.transpose(); fullImageSize.transpose(); } /* Resetting reader for ScaledSize and ClipRect. This resetting will make sure that the reader will have all the options set correctly if the same reader has been used previously. Does not do the calculation in all cases since it is time consuming. */ if (reader->scaledSize().isValid() || reader->clipRect().isValid()) { QSize readerSize = reader->size(); reader->setScaledSize(readerSize); reader->setClipRect(QRect(QPoint(0,0),readerSize)); } if (!input.isFragment()){ fullImage = QImage(); if (!targetSize.isEmpty()) { reader->setScaledSize(targetSize); } newImage = readFromReader(); } else if (!targetSize.isEmpty() && (targetSize != area.size())) { // Both cropping and scaling have been requested // Current implementation: ask plugin for the scaled image, then crop // This can be later optimized with a plugin that effectively // supports the ScaledClipRect option. reader->setScaledSize(QSize(targetSize.width() * fullImageSize.width() / area.width(), targetSize.height() * fullImageSize.height() / area.height())); newImage = readFromReader(); newImage = newImage.copy(input.area().left() * input.targetSize().width() / input.area().width(), input.area().top() * input.targetSize().height() / input.area().height(), input.targetSize().width(), input.targetSize().height()); newImage = QuillImage(input, newImage); } else if (reader->supportsOption(QImageIOHandler::ClipRect) && // Standard Qt now supports ClipRect with a too slow // implementation, so we use the ScaledClipRect information // to reject the standard Qt Jpeg plugin. // TODO: This needs to be removed if Qt becomes faster. !reader->supportsOption(QImageIOHandler::ScaledClipRect)) { fullImage = QImage(); //if it is real a tile, we then reset reader, otherwise we consider it as a full image if(!area.isNull()){ //set the scale size again here because preview sets the preview scale size already. reader->setScaledSize(area.size()); // clip rect support in image reader reader->setClipRect(area); } newImage = readFromReader(); } else { // no clip rect support: preserve whole full image as a tile cache, // uses a lot of extra memory if (isNew || fullImage.isNull()) fullImage = readFromReader(); newImage = fullImage.copy(input.area()); } QImage convertedImage; if (newImage.hasAlphaChannel()){ convertedImage = renderAlpha(newImage, priv->backgroundColor); } else{ convertedImage = newImage.convertToFormat(QImage::Format_RGB32); } QuillImage ret_value; if (!input.targetSize().isEmpty() || !input.fullImageSize().isEmpty() || !input.area().isEmpty()) { ret_value = QuillImage(input, convertedImage); } else{ // full image ret_value = QuillImage(convertedImage); } if (priv->iODevice) { delete reader; reader = 0; } return ret_value; }
void LLDrawPoolAlpha::render(S32 pass) { LLFastTimer t(FTM_RENDER_ALPHA); S32 mode = gViewerWindow->getMaskMode(); LLGLSPipelineAlpha gls_pipeline_alpha; if (deferred_render && pass == 1) { //depth only gGL.setColorMask(false, false); } else { if(mode == MASK_MODE_RIGHT) { gGL.setColorMask(false,true,true,true); } if(mode == MASK_MODE_LEFT) { gGL.setColorMask(true,false,false,true); } if(mode == MASK_MODE_NONE) { gGL.setColorMask(true, true); } } if (LLPipeline::sAutoMaskAlphaNonDeferred) { mColorSFactor = LLRender::BF_ONE; // } mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow mAlphaSFactor = LLRender::BF_ZERO; mAlphaDFactor = LLRender::BF_ZERO; // block (zero-out) glow where the alpha test succeeds gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f); if (mVertexShaderLevel > 0) { if (!LLPipeline::sRenderDeferred) { simple_shader->bind(); pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); } if (fullbright_shader) { fullbright_shader->bind(); } pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); LLGLSLShader::bindNoShader(); } else { gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask()); gPipeline.enableLightsDynamic(); pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask()); } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } LLGLDepthTest depth(GL_TRUE, LLDrawPoolWater::sSkipScreenCopy || (deferred_render && pass == 1) ? GL_TRUE : GL_FALSE); if (deferred_render && pass == 1) { gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f); gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); } else { mColorSFactor = LLRender::BF_SOURCE_ALPHA; // } regular alpha blend mColorDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } mAlphaSFactor = LLRender::BF_ZERO; // } glow suppression mAlphaDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); if (LLPipeline::sImpostorRender) { gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); } else { gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } } if (mVertexShaderLevel > 0) { renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX); } else { renderAlpha(getVertexDataMask()); } if(mode == MASK_MODE_RIGHT) { gGL.setColorMask(false,true,true,false); } if(mode == MASK_MODE_LEFT) { gGL.setColorMask(true,false,false,false); } if(mode == MASK_MODE_NONE) { gGL.setColorMask(true, false); } if (deferred_render && pass == 1) { gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); gGL.setSceneBlendType(LLRender::BT_ALPHA); } if (sShowDebugAlpha) { if(mVertexShaderLevel > 0) { // KL we are using anything above basic shaders so use this ... as we are most likely batching textures renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXTURE_INDEX); } else { // KL This is the old method gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); glColor4f(1,0,0,1); LLViewerFetchedTexture::sSmokeImagep->addTextureStats(1024.f*1024.f); gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sSmokeImagep, TRUE) ; renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); } } }
void LLDrawPoolAlpha::render(S32 pass) { LLFastTimer t(LLFastTimer::FTM_RENDER_ALPHA); LLGLSPipelineAlpha gls_pipeline_alpha; if (deferred_render && pass == 1) { //depth only gGL.setColorMask(false, false); } else { gGL.setColorMask(true, true); } if (LLPipeline::sFastAlpha) { mColorSFactor = LLRender::BF_ONE; // } mColorDFactor = LLRender::BF_ZERO; // } these are like disabling blend on the color channels, but we're still blending on the alpha channel so that we can suppress glow mAlphaSFactor = LLRender::BF_ZERO; mAlphaDFactor = LLRender::BF_ZERO; // block (zero-out) glow where the alpha test succeeds gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); if (mVertexShaderLevel > 0) { if (!LLPipeline::sRenderDeferred || !deferred_render) { simple_shader->bind(); simple_shader->setAlphaRange(0.33f, 1.f); pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); } if (fullbright_shader) { fullbright_shader->bind(); fullbright_shader->setAlphaRange(0.33f, 1.f); } pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); //LLGLSLShader::bindNoShader(); } else { gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.33f); //OK gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); pushBatches(LLRenderPass::PASS_FULLBRIGHT_ALPHA_MASK, getVertexDataMask()); gPipeline.enableLightsDynamic(); pushBatches(LLRenderPass::PASS_ALPHA_MASK, getVertexDataMask()); gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK } } LLGLDepthTest depth(GL_TRUE, (LLDrawPoolWater::sSkipScreenCopy || (deferred_render && pass == 1)) ? GL_TRUE : GL_FALSE); if (deferred_render && pass == 1) { gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); } else { mColorSFactor = LLRender::BF_SOURCE_ALPHA; // } regular alpha blend mColorDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } mAlphaSFactor = LLRender::BF_ZERO; // } glow suppression mAlphaDFactor = LLRender::BF_ONE_MINUS_SOURCE_ALPHA; // } gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor); if (mVertexShaderLevel > 0) { if (LLPipeline::sImpostorRender) { fullbright_shader->bind(); fullbright_shader->setAlphaRange(0.5f, 1.f); simple_shader->bind(); simple_shader->setAlphaRange(0.5f, 1.f); } else { fullbright_shader->bind(); fullbright_shader->setAlphaRange(0.f, 1.f); simple_shader->bind(); simple_shader->setAlphaRange(0.f, 1.f); } } else { if (LLPipeline::sImpostorRender) { gGL.setAlphaRejectSettings(LLRender::CF_GREATER, 0.5f); //OK } else { gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); //OK } } } if (mVertexShaderLevel > 0) { renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX); } else { renderAlpha(getVertexDataMask()); } gGL.setColorMask(true, false); if (deferred_render && pass == 1) { gGL.setSceneBlendType(LLRender::BT_ALPHA); } if (sShowDebugAlpha) { BOOL shaders = gPipeline.canUseVertexShaders(); if(shaders) { gObjectFullbrightNonIndexedProgram.bind(); } else { gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); } glColor4f(1,0,0,1); LLViewerFetchedTexture::sSmokeImagep->addTextureStats(1024.f*1024.f); gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sSmokeImagep, TRUE) ; renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0); if(shaders) { gObjectFullbrightNonIndexedProgram.unbind(); } } }