Merge branch 'master' of git://github.com/Shyotl/SingularityViewer

This commit is contained in:
Lirusaito
2012-12-20 09:25:21 -05:00
13 changed files with 121 additions and 60 deletions

View File

@@ -25,6 +25,7 @@
*/
#include "linden_common.h"
#include <boost/filesystem.hpp> //First, because glh_linear #defines equivalent.. which boost uses internally
#include "llshadermgr.h"
@@ -53,6 +54,17 @@ LLShaderMgr * LLShaderMgr::sInstance = NULL;
LLShaderMgr::LLShaderMgr()
{
{
const std::string dumpdir = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"shader_dump")+gDirUtilp->getDirDelimiter();
try
{
boost::filesystem::remove_all(dumpdir);
}
catch(const boost::filesystem::filesystem_error& e)
{
llinfos << "boost::filesystem::remove_all(\""+dumpdir+"\") failed: '" + e.code().message() + "'" << llendl;
}
}
}

View File

@@ -54,6 +54,7 @@ LLResizeBar::LLResizeBar( const std::string& name, LLView* resizing_view, const
mAllowDoubleClickSnapping(TRUE),
mResizingView(resizing_view)
{
setFollowsNone();
// set up some generically good follow code.
switch( side )
{
@@ -87,6 +88,8 @@ LLResizeBar::LLResizeBar( const std::string& name, LLView* resizing_view, const
BOOL LLResizeBar::handleMouseDown(S32 x, S32 y, MASK mask)
{
if (!canResize()) return FALSE;
// Route future Mouse messages here preemptively. (Release on mouse up.)
// No handler needed for focus lost since this clas has no state that depends on it.
gFocusMgr.setMouseCapture( this );
@@ -240,7 +243,7 @@ BOOL LLResizeBar::handleHover(S32 x, S32 y, MASK mask)
handled = TRUE;
}
if( handled )
if( handled && canResize() )
{
switch( mSide )
{

View File

@@ -52,6 +52,7 @@ public:
void setResizeLimits( S32 min_size, S32 max_size ) { mMinSize = min_size; mMaxSize = max_size; }
void setEnableSnapping(BOOL enable) { mSnappingEnabled = enable; }
void setAllowDoubleClickSnapping(BOOL allow) { mAllowDoubleClickSnapping = allow; }
bool canResize() { return getEnabled() && mMaxSize > mMinSize; }
private:
S32 mDragLastScreenX;

View File

@@ -1093,6 +1093,15 @@ BOOL LLScrollListCtrl::addItem( LLScrollListItem* item, EAddPosition pos, BOOL r
addColumn(new_column);
}
S32 num_cols = item->getNumColumns();
S32 i = 0;
for (LLScrollListCell* cell = item->getColumn(i); i < num_cols; cell = item->getColumn(++i))
{
if (i >= (S32)mColumnsIndexed.size()) break;
cell->setWidth(mColumnsIndexed[i]->getWidth());
}
updateLineHeightInsert(item);
updateLayout();
@@ -3898,7 +3907,11 @@ LLScrollColumnHeader::~LLScrollColumnHeader()
void LLScrollColumnHeader::draw()
{
BOOL draw_arrow = !mColumn->mLabel.empty() && mColumn->mParentCtrl->isSorted() && mColumn->mParentCtrl->getSortColumnName() == mColumn->mSortingColumn;
std::string sort_column = mColumn->mParentCtrl->getSortColumnName();
BOOL draw_arrow = !mColumn->mLabel.empty()
&& mColumn->mParentCtrl->isSorted()
// check for indirect sorting column as well as column's sorting name
&& (sort_column == mColumn->mSortingColumn || sort_column == mColumn->mName);
BOOL is_ascending = mColumn->mParentCtrl->getSortAscending();
mButton->setImageOverlay(is_ascending ? "up_arrow.tga" : "down_arrow.tga", LLFontGL::RIGHT, draw_arrow ? LLColor4::white : LLColor4::transparent);
@@ -4014,6 +4027,7 @@ BOOL LLScrollColumnHeader::handleDoubleClick(S32 x, S32 y, MASK mask)
if (canResize() && mResizeBar->getRect().pointInRect(x, y))
{
// reshape column to max content width
mColumn->mParentCtrl->calcMaxContentWidth();
LLRect column_rect = getRect();
column_rect.mRight = column_rect.mLeft + mColumn->mMaxContentWidth;
setShape(column_rect,true);
@@ -4308,6 +4322,7 @@ void LLScrollColumnHeader::handleReshape(const LLRect& new_rect, bool by_user)
// tell scroll list to layout columns again
// do immediate update to get proper feedback to resize handle
// which needs to know how far the resize actually went
mColumn->mParentCtrl->dirtyColumns(); //Must flag as dirty, else updateColumns will probably be a noop.
mColumn->mParentCtrl->updateColumns();
}
}

View File

@@ -60,7 +60,7 @@ void main()
/// Gamma correct for WL (soft clip effect).
frag_data[0] = vec4(scaleSoftClip(color.rgb), 1.0);
frag_data[1] = vec4(0.0,0.0,0.0,0.0);
frag_data[1] = vec4(vary_HazeColor.a,0.0,0.0,0.0);
//#define PACK_NORMALS
#ifdef PACK_NORMALS
frag_data[2] = vec4(0.5,0.5,0.0,0.0);

View File

@@ -53,6 +53,13 @@ uniform vec4 glow;
uniform vec4 cloud_color;
float luminance(vec3 color)
{
/// CALCULATING LUMINANCE (Using NTSC lum weights)
/// http://en.wikipedia.org/wiki/Luma_%28video%29
return dot(color, vec3(0.299, 0.587, 0.114));
}
void main()
{
@@ -151,6 +158,7 @@ void main()
// At horizon, blend high altitude sky color towards the darker color below the clouds
vary_HazeColor += (additiveColorBelowCloud - vary_HazeColor) * (1. - sqrt(temp1));
vary_HazeColor.a = pow(clamp(luminance(vary_HazeColor.rgb)-.5,0,1),2);
// won't compile on mac without this being set
//vary_AtmosAttenuation = vec3(0.0,0.0,0.0);
}

View File

@@ -332,10 +332,11 @@ void main()
col = atmosLighting(col);
col = scaleSoftClip(col);
col = mix(col.rgb, diffuse.rgb, diffuse.a);
col = mix(col, diffuse.rgb, diffuse.a);
}
else
{
bloom = spec.r;
col = diffuse.rgb;
}

View File

@@ -29,6 +29,8 @@ out vec4 frag_data[3];
#define frag_data gl_FragData
#endif
uniform float custom_alpha;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
@@ -38,7 +40,7 @@ void main()
{
vec4 col = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy);
frag_data[0] = col;
frag_data[0] = vec4(col.rgb,col.a*custom_alpha);
frag_data[1] = vec4(0,0,0,0);
//#define PACK_NORMALS
#ifdef PACK_NORMALS

View File

@@ -297,14 +297,13 @@ void main()
float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
vec4 diffuse = texture2DRect(diffuseRect, tc);
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec3 col;
float bloom = 0.0;
if (diffuse.a < 0.9)
{
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
float scol = max(scol_ambocc.r, diffuse.a);
float ambocc = scol_ambocc.g;
@@ -344,6 +343,7 @@ void main()
}
else
{
bloom = spec.r;
col = diffuse.rgb;
}

View File

@@ -54,7 +54,7 @@ LLPointer<LLImageRaw> LLDrawPoolWLSky::sCloudNoiseRawImage = NULL;
static LLGLSLShader* cloud_shader = NULL;
static LLGLSLShader* sky_shader = NULL;
static LLGLSLShader* star_shader = NULL;
LLDrawPoolWLSky::LLDrawPoolWLSky(void) :
LLDrawPool(POOL_WL_SKY)
@@ -113,6 +113,8 @@ void LLDrawPoolWLSky::beginRenderPass( S32 pass )
LLPipeline::sUnderWaterRender ?
&gObjectFullbrightNoColorWaterProgram :
&gWLCloudProgram;
star_shader = &gCustomAlphaProgram;
}
void LLDrawPoolWLSky::endRenderPass( S32 pass )
@@ -123,6 +125,7 @@ void LLDrawPoolWLSky::beginDeferredPass(S32 pass)
{
sky_shader = &gDeferredWLSkyProgram;
cloud_shader = &gDeferredWLCloudProgram;
star_shader = &gDeferredStarProgram;
}
void LLDrawPoolWLSky::endDeferredPass(S32 pass)
@@ -182,6 +185,15 @@ void LLDrawPoolWLSky::renderSkyHaze(F32 camHeightLocal) const
void LLDrawPoolWLSky::renderStars(void) const
{
// *NOTE: we divide by two here and GL_ALPHA_SCALE by two below to avoid
// clamping and allow the star_alpha param to brighten the stars.
bool error;
LLColor4 star_alpha(LLColor4::black);
star_alpha.mV[3] = LLWLParamManager::getInstance()->mCurParams.getFloat("star_brightness", error) / 2.f;
llassert_always(!error);
if(star_alpha.mV[3] <= 0)
return;
LLGLSPipelineSkyBox gls_sky;
LLGLEnable blend(GL_BLEND);
gGL.setSceneBlendType(LLRender::BT_ALPHA);
@@ -198,26 +210,16 @@ void LLDrawPoolWLSky::renderStars(void) const
glPointSize(2.f);
}*/
// *NOTE: we divide by two here and GL_ALPHA_SCALE by two below to avoid
// clamping and allow the star_alpha param to brighten the stars.
bool error;
LLColor4 star_alpha(LLColor4::black);
star_alpha.mV[3] = LLWLParamManager::getInstance()->mCurParams.getFloat("star_brightness", error) / 2.f;
llassert_always(!error);
gGL.pushMatrix();
gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f);
// gl_FragColor.rgb = gl_Color.rgb;
// gl_FragColor.a = gl_Color.a * star_alpha.a;
//New
gGL.getTexUnit(0)->bind(gSky.mVOSkyp->getBloomTex());
gGL.pushMatrix();
gGL.rotatef(gFrameTimeSeconds*0.01f, 0.f, 0.f, 1.f);
// gl_FragColor.rgb = gl_Color.rgb;
// gl_FragColor.a = gl_Color.a * star_alpha.a;
if (LLGLSLShader::sNoFixedFunction)
if (gPipeline.canUseVertexShaders())
{
gCustomAlphaProgram.bind();
gCustomAlphaProgram.uniform1f("custom_alpha", star_alpha.mV[3]);
star_shader->uniform1f("custom_alpha", star_alpha.mV[3]);
}
else
{
@@ -230,11 +232,7 @@ void LLDrawPoolWLSky::renderStars(void) const
gGL.popMatrix();
if (LLGLSLShader::sNoFixedFunction)
{
gCustomAlphaProgram.unbind();
}
else
if (!gPipeline.canUseVertexShaders())
{
// and disable the combiner states
gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
@@ -261,8 +259,15 @@ void LLDrawPoolWLSky::renderSkyClouds(F32 camHeightLocal) const
void LLDrawPoolWLSky::renderHeavenlyBodies()
{
LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor(), gSky.mVOSkyp->getMoon().getDirection().mV[2]);
if (color.mV[VW] <= 0.f)
return;
color.mV[VW] = llclamp(color.mV[VW]*color.mV[VW]*4.f,0.f,1.f);
LLGLSPipelineSkyBox gls_skybox;
LLGLEnable blend_on(GL_BLEND);
gGL.setSceneBlendType(LLRender::BT_ALPHA);
gPipeline.disableLights();
#if 0 // when we want to re-add a texture sun disc, here's where to do it.
@@ -279,33 +284,31 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
LLFace * face = gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON];
if (gSky.mVOSkyp->getMoon().getDraw() && face->getGeomCount())
if (gSky.mVOSkyp->getMoon().getDraw() && face->getGeomCount() && face->getVertexBuffer())
{
// *NOTE: even though we already bound this texture above for the
// stars register combiners, we bind again here for defensive reasons,
// since LLImageGL::bind detects that it's a noop, and optimizes it out.
gGL.getTexUnit(0)->bind(face->getTexture());
LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor());
F32 a = gSky.mVOSkyp->getMoon().getDirection().mV[2];
if (a > 0.f)
{
a = a*a*4.f;
}
color.mV[3] = llclamp(a, 0.f, 1.f);
if (gPipeline.canUseVertexShaders())
{
gHighlightProgram.bind();
// Okay, so the moon isn't a star, but it's close enough.
star_shader->uniform1f("custom_alpha", color.mV[VW]);
}
else
{
gGL.getTexUnit(0)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_VERT_COLOR);
gGL.getTexUnit(0)->setTextureAlphaBlend(LLTexUnit::TBO_MULT_X2, LLTexUnit::TBS_CONST_ALPHA, LLTexUnit::TBS_TEX_ALPHA);
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color.mV);
}
LLFacePool::LLOverrideFaceColor color_override(this, color);
face->getVertexBuffer()->setBuffer(LLDrawPoolWLSky::STAR_VERTEX_DATA_MASK);
face->getVertexBuffer()->draw(LLRender::TRIANGLES, face->getVertexBuffer()->getNumIndices(), 0);
face->renderIndexed();
if (gPipeline.canUseVertexShaders())
if (!gPipeline.canUseVertexShaders())
{
gHighlightProgram.unbind();
gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
}
}
}
@@ -336,7 +339,7 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
gDeferredStarProgram.bind();
star_shader->bind();
// *NOTE: have to bind a texture here since register combiners blending in
// renderStars() requires something to be bound and we might as well only
// bind the moon's texture once.
@@ -346,13 +349,14 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass)
renderStars();
gDeferredStarProgram.unbind();
star_shader->unbind();
gGL.popMatrix();
renderSkyClouds(camHeightLocal);
gGL.setColorMask(true, true);
//gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
}
@@ -373,6 +377,8 @@ void LLDrawPoolWLSky::render(S32 pass)
LLGLSquashToFarClip far_clip(glh_get_current_projection());
gGL.setColorMask(true, false);
renderSkyHaze(camHeightLocal);
LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
@@ -380,6 +386,8 @@ void LLDrawPoolWLSky::render(S32 pass)
gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]);
if(gPipeline.canUseVertexShaders())
star_shader->bind();
// *NOTE: have to bind a texture here since register combiners blending in
// renderStars() requires something to be bound and we might as well only
// bind the moon's texture once.
@@ -388,6 +396,9 @@ void LLDrawPoolWLSky::render(S32 pass)
renderHeavenlyBodies();
renderStars();
if(gPipeline.canUseVertexShaders())
star_shader->unbind();
gGL.popMatrix();
@@ -395,6 +406,8 @@ void LLDrawPoolWLSky::render(S32 pass)
renderSkyClouds(camHeightLocal);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.setColorMask(true, true);
}
void LLDrawPoolWLSky::prerender()

View File

@@ -32,7 +32,6 @@
#include "llviewerprecompiledheaders.h"
#include <boost/filesystem.hpp> //First, because glh_linear #defines equivalent.. which boost uses internally
#include "llfeaturemanager.h"
#include "llviewershadermgr.h"
@@ -308,18 +307,6 @@ void LLViewerShaderMgr::setShaders()
return;
}
{
const std::string dumpdir = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"shader_dump")+gDirUtilp->getDirDelimiter();
try
{
boost::filesystem::remove_all(dumpdir);
}
catch(const boost::filesystem::filesystem_error& e)
{
llinfos << "boost::filesystem::remove_all(\""+dumpdir+"\") failed: '" + e.code().message() + "'" << llendl;
}
}
LLGLSLShader::sIndexedTextureChannels = llmax(llmin(gGLManager.mNumTextureImageUnits, (S32) gSavedSettings.getU32("RenderMaxTextureIndex")), 1);
static const LLCachedControl<bool> no_texture_indexing("ShyotlUseLegacyTextureBatching",false);
if(no_texture_indexing)
@@ -1514,12 +1501,14 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (success)
{
gDeferredStarProgram.mName = "Deferred Star Program";
vector<string> shaderUniforms(mWLUniforms);
shaderUniforms.push_back("custom_alpha");
gDeferredStarProgram.mShaderFiles.clear();
gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredStarProgram.mShaderFiles.push_back(make_pair("deferred/starsF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredStarProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
gDeferredStarProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gDeferredStarProgram.createShader(NULL, &mWLUniforms);
success = gDeferredStarProgram.createShader(NULL, &shaderUniforms);
}
if (success)

View File

@@ -1425,6 +1425,7 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, cons
LLStrider<LLVector3> normalsp;
LLStrider<LLVector2> texCoordsp;
LLStrider<U16> indicesp;
LLStrider<LLColor4U> colorsp;
S32 index_offset;
LLFace *facep;
@@ -1481,7 +1482,7 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, cons
if (!facep->getVertexBuffer())
{
facep->setSize(4, 6);
LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolSky::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB);
LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWLSky::STAR_VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); //Singu Note: Using LLDrawPoolWLSky::STAR_VERTEX_DATA_MASK on purpose.
buff->allocateBuffer(facep->getGeomCount(), facep->getIndicesCount(), TRUE);
facep->setGeomIndex(0);
facep->setIndicesIndex(0);
@@ -1491,6 +1492,7 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, cons
llassert(facep->getVertexBuffer()->getNumIndices() == 6);
index_offset = facep->getGeometry(verticesp,normalsp,texCoordsp, indicesp);
facep->getColors(colorsp);
if (-1 == index_offset)
{
@@ -1516,6 +1518,11 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, cons
*indicesp++ = index_offset + 2;
*indicesp++ = index_offset + 3;
*(colorsp++) = LLColor4::white;
*(colorsp++) = LLColor4::white;
*(colorsp++) = LLColor4::white;
*(colorsp++) = LLColor4::white;
facep->getVertexBuffer()->flush();
if (is_sun)

View File

@@ -931,16 +931,26 @@ void LLPipeline::createGLBuffers()
GLuint resX = gViewerWindow->getWorldViewWidthRaw();
GLuint resY = gViewerWindow->getWorldViewHeightRaw();
if (LLPipeline::sRenderGlow)
{ //screen space glow buffers
const U32 glow_res = llmax(1,
llmin(512, 1 << gSavedSettings.getS32("RenderGlowResolutionPow")));
glClearColor(0,0,0,0);
gGL.setColorMask(true, true);
for (U32 i = 0; i < 2; i++)
{
mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE,FALSE);
if(mGlow[i].allocate(512,glow_res,GL_RGBA,FALSE,FALSE))
{
mGlow[i].bindTarget();
mGlow[i].clear();
mGlow[i].unbindTarget();
}
}
allocateScreenBuffer(resX,resY);
}