Merge remote-tracking branch 'singu/master'

This commit is contained in:
Aleric Inglewood
2013-10-30 21:57:39 +01:00
64 changed files with 1276 additions and 521 deletions

View File

@@ -26,7 +26,7 @@ if (NOT FMODEX_LIBRARY)
endif(WORD_SIZE EQUAL 32)
endif(FMODEX_SDK_DIR)
if(WINDOWS AND NOT FMODEX_SDK_DIR)
set(FMODEX_PROG_DIR "$ENV{PROGRAMFILES}/FMOD SoundSystem/FMOD Programmers API Windows")
GET_FILENAME_COMPONENT(FMODEX_PROG_DIR [HKEY_CURRENT_USER\\Software\\FMOD\ Programmers\ API\ Windows] ABSOLUTE CACHE)
if(WORD_SIZE EQUAL 32)
find_library(FMODEX_LIBRARY
fmodex_vc fmodexL_vc

View File

@@ -231,6 +231,7 @@ set(llcommon_HEADER_FILES
llstrider.h
llstring.h
llstringtable.h
llstaticstringtable.h
llsys.h
llthread.h
llthreadsafequeue.h

View File

@@ -41,7 +41,11 @@ public:
~LLAlignedArray();
void push_back(const T& elem);
U32 size() const { return mElementCount; }
void pop_back() { if(!!mElementCount) --mElementCount; }
bool empty() const { return !mElementCount; }
T& front() { return operator[](0); }
T& back() { return operator[](mElementCount-1); }
U32 size() const { return mElementCount; }
void resize(U32 size);
T* append(S32 N);
T& operator[](int idx);

View File

@@ -663,14 +663,6 @@ void LLPrivateMemoryPoolTester::operator delete[](void* addr)
#endif
#endif
LL_COMMON_API void ll_assert_aligned_func(uintptr_t ptr,U32 alignment);
#ifdef SHOW_ASSERT
#define ll_assert_aligned(ptr,alignment) ll_assert_aligned_func(reinterpret_cast<uintptr_t>(ptr),((U32)alignment))
#else
#define ll_assert_aligned(ptr,alignment)
#endif
//EVENTUALLY REMOVE THESE:
#include "llpointer.h"
#include "llsingleton.h"

View File

@@ -0,0 +1,82 @@
/**
* @file llstringtable.h
* @brief The LLStringTable class provides a _fast_ method for finding
* unique copies of strings.
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_STATIC_STRING_TABLE_H
#define LL_STATIC_STRING_TABLE_H
#include "lldefs.h"
#include <boost/unordered_map.hpp>
#include "llstl.h"
class LLStaticHashedString
{
public:
LLStaticHashedString(const std::string& s)
{
string_hash = makehash(s);
string = s;
}
const std::string& String() const { return string; }
size_t Hash() const { return string_hash; }
bool operator==(const LLStaticHashedString& b) const { return String() == b.String(); }
protected:
size_t makehash(const std::string& s)
{
size_t len = s.size();
const char* c = s.c_str();
size_t hashval = 0;
for (size_t i=0; i<len; i++)
{
hashval = ((hashval<<5) + hashval) + *c++;
}
return hashval;
}
std::string string;
size_t string_hash;
};
struct LLStaticStringHasher
{
enum { bucket_size = 8 };
size_t operator()(const LLStaticHashedString& key_value) const { return key_value.Hash(); }
bool operator()(const LLStaticHashedString& left, const LLStaticHashedString& right) const { return left.Hash() < right.Hash(); }
};
template< typename MappedObject >
class LLStaticStringTable
: public boost::unordered_map< LLStaticHashedString, MappedObject, LLStaticStringHasher >
{
};
#endif

View File

@@ -299,10 +299,15 @@ LLImageRaw::LLImageRaw(U16 width, U16 height, S8 components)
++sRawImageCount;
}
LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components)
LLImageRaw::LLImageRaw(U8 *data, U16 width, U16 height, S8 components, bool no_copy)
: LLImageBase(), mCacheEntries(0)
{
if(allocateDataSize(width, height, components) && data)
if(no_copy)
{
setDataAndSize(data, width, height, components);
}
else if(allocateDataSize(width, height, components) && data)
{
memcpy(getData(), data, width*height*components);
}
@@ -762,8 +767,17 @@ void LLImageRaw::fill( const LLColor4U& color )
}
}
LLPointer<LLImageRaw> LLImageRaw::duplicate()
{
if(getNumRefs() < 2)
{
return this; //nobody else refences to this image, no need to duplicate.
}
//make a duplicate
LLPointer<LLImageRaw> dup = new LLImageRaw(getData(), getWidth(), getHeight(), getComponents());
return dup;
}
// Src and dst can be any size. Src and dst can each have 3 or 4 components.
void LLImageRaw::copy(LLImageRaw* src)

View File

@@ -173,7 +173,7 @@ protected:
public:
LLImageRaw();
LLImageRaw(U16 width, U16 height, S8 components);
LLImageRaw(U8 *data, U16 width, U16 height, S8 components);
LLImageRaw(U8 *data, U16 width, U16 height, S8 components, bool no_copy = false);
LLImageRaw(LLImageRaw const* src, U16 width, U16 height, U16 crop_offset, bool crop_vertically);
// Construct using createFromFile (used by tools)
//LLImageRaw(const std::string& filename, bool j2c_lowest_mip_only = false);
@@ -204,6 +204,9 @@ public:
// Copy operations
//duplicate this raw image if refCount > 1.
LLPointer<LLImageRaw> duplicate();
// Src and dst can be any size. Src and dst can each have 3 or 4 components.
void copy( LLImageRaw* src );

View File

@@ -727,7 +727,8 @@ bool LLGLManager::initGL()
}
stop_glerror();
//Singu Note: Multisampled texture stuff in v3 is dead, however we DO use multisampled FBOs.
if (mHasFramebufferMultisample)
{
glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &mMaxIntegerSamples);

View File

@@ -91,11 +91,22 @@ LLShaderFeatures::LLShaderFeatures()
// LLGLSL Shader implementation
//===============================
LLGLSLShader::LLGLSLShader(S32 shader_class)
: mProgramObject(0), mShaderClass(shader_class), mActiveTextureChannels(0), mShaderLevel(0), mShaderGroup(SG_DEFAULT), mUniformsDirty(FALSE)
: mProgramObject(0),
mShaderClass(shader_class),
mAttributeMask(0),
mTotalUniformSize(0),
mActiveTextureChannels(0),
mShaderLevel(0),
mShaderGroup(SG_DEFAULT),
mUniformsDirty(FALSE)
{
LLShaderMgr::getGlobalShaderList().push_back(this);
}
LLGLSLShader::~LLGLSLShader()
{
}
void LLGLSLShader::unload()
{
stop_glerror();
@@ -103,6 +114,7 @@ void LLGLSLShader::unload()
mTexture.clear();
mUniform.clear();
mShaderFiles.clear();
mDefines.clear();
if (mProgramObject)
{
@@ -127,8 +139,8 @@ void LLGLSLShader::unload()
stop_glerror();
}
BOOL LLGLSLShader::createShader(vector<string> * attributes,
vector<string> * uniforms,
BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
std::vector<LLStaticHashedString> * uniforms,
U32 varying_count,
const char** varyings)
{
@@ -151,7 +163,7 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes,
vector< pair<string,GLenum> >::iterator fileIter = mShaderFiles.begin();
for ( ; fileIter != mShaderFiles.end(); fileIter++ )
{
GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second, mFeatures.mIndexedTextureChannels);
GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second, &mDefines, mFeatures.mIndexedTextureChannels);
LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL;
if (shaderhandle > 0)
{
@@ -217,7 +229,8 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes,
for (S32 i = 0; i < channel_count; i++)
{
uniform1i(llformat("tex%d", i), i);
LLStaticHashedString uniName(llformat("tex%d", i));
uniform1i(uniName, i);
}
S32 cur_tex = channel_count; //adjust any texture channels that might have been overwritten
@@ -290,7 +303,7 @@ void LLGLSLShader::attachObjects(GLhandleARB* objects, S32 count)
}
}
BOOL LLGLSLShader::mapAttributes(const vector<string> * attributes)
BOOL LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString> * attributes)
{
//before linking, make sure reserved attributes always have consistent locations
for (U32 i = 0; i < LLShaderMgr::instance()->mReservedAttribs.size(); i++)
@@ -309,6 +322,8 @@ BOOL LLGLSLShader::mapAttributes(const vector<string> * attributes)
if (res)
{ //read back channel locations
mAttributeMask = 0;
//read back reserved channels first
for (U32 i = 0; i < (S32) LLShaderMgr::instance()->mReservedAttribs.size(); i++)
{
@@ -317,6 +332,7 @@ BOOL LLGLSLShader::mapAttributes(const vector<string> * attributes)
if (index != -1)
{
mAttribute[i] = index;
mAttributeMask |= 1 << i;
LL_DEBUGS("ShaderLoading") << "Attribute " << name << " assigned to channel " << index << LL_ENDL;
}
}
@@ -324,7 +340,7 @@ BOOL LLGLSLShader::mapAttributes(const vector<string> * attributes)
{
for (U32 i = 0; i < numAttributes; i++)
{
const char* name = (*attributes)[i].c_str();
const char* name = (*attributes)[i].String().c_str();
S32 index = glGetAttribLocationARB(mProgramObject, name);
if (index != -1)
{
@@ -340,7 +356,7 @@ BOOL LLGLSLShader::mapAttributes(const vector<string> * attributes)
return FALSE;
}
void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> * uniforms)
{
if (index == -1)
{
@@ -349,11 +365,55 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
GLenum type;
GLsizei length;
GLint size;
GLint size = -1;
char name[1024]; /* Flawfinder: ignore */
name[0] = 0;
glGetActiveUniformARB(mProgramObject, index, 1024, &length, &size, &type, (GLcharARB *)name);
#if !LL_DARWIN
if (size > 0)
{
switch(type)
{
case GL_FLOAT_VEC2: size *= 2; break;
case GL_FLOAT_VEC3: size *= 3; break;
case GL_FLOAT_VEC4: size *= 4; break;
case GL_DOUBLE: size *= 2; break;
case GL_DOUBLE_VEC2: size *= 2; break;
case GL_DOUBLE_VEC3: size *= 6; break;
case GL_DOUBLE_VEC4: size *= 8; break;
case GL_INT_VEC2: size *= 2; break;
case GL_INT_VEC3: size *= 3; break;
case GL_INT_VEC4: size *= 4; break;
case GL_UNSIGNED_INT_VEC2: size *= 2; break;
case GL_UNSIGNED_INT_VEC3: size *= 3; break;
case GL_UNSIGNED_INT_VEC4: size *= 4; break;
case GL_BOOL_VEC2: size *= 2; break;
case GL_BOOL_VEC3: size *= 3; break;
case GL_BOOL_VEC4: size *= 4; break;
case GL_FLOAT_MAT2: size *= 4; break;
case GL_FLOAT_MAT3: size *= 9; break;
case GL_FLOAT_MAT4: size *= 16; break;
case GL_FLOAT_MAT2x3: size *= 6; break;
case GL_FLOAT_MAT2x4: size *= 8; break;
case GL_FLOAT_MAT3x2: size *= 6; break;
case GL_FLOAT_MAT3x4: size *= 12; break;
case GL_FLOAT_MAT4x2: size *= 8; break;
case GL_FLOAT_MAT4x3: size *= 12; break;
case GL_DOUBLE_MAT2: size *= 8; break;
case GL_DOUBLE_MAT3: size *= 18; break;
case GL_DOUBLE_MAT4: size *= 32; break;
case GL_DOUBLE_MAT2x3: size *= 12; break;
case GL_DOUBLE_MAT2x4: size *= 16; break;
case GL_DOUBLE_MAT3x2: size *= 12; break;
case GL_DOUBLE_MAT3x4: size *= 24; break;
case GL_DOUBLE_MAT4x2: size *= 16; break;
case GL_DOUBLE_MAT4x3: size *= 24; break;
}
mTotalUniformSize += size;
}
#endif
S32 location = glGetUniformLocationARB(mProgramObject, name);
if (location != -1)
{
@@ -365,7 +425,10 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
is_array[0] = 0;
}
mUniformMap[name] = location;
LLStaticHashedString hashedName(name);
mUniformNameMap[location] = name;
mUniformMap[hashedName] = location;
LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL;
//find the index of this uniform
@@ -386,7 +449,7 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
for (U32 i = 0; i < uniforms->size(); i++)
{
if ( (mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] == -1)
&& ((*uniforms)[i] == name))
&& ((*uniforms)[i].String() == name))
{
//found it
mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location;
@@ -396,7 +459,17 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
}
}
}
}
}
void LLGLSLShader::addPermutation(std::string name, std::string value)
{
mDefines[name] = value;
}
void LLGLSLShader::removePermutation(std::string name)
{
mDefines[name].erase();
}
GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type)
{
@@ -410,13 +483,15 @@ GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type)
return -1;
}
BOOL LLGLSLShader::mapUniforms(const vector<string> * uniforms)
BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
{
BOOL res = TRUE;
mTotalUniformSize = 0;
mActiveTextureChannels = 0;
mUniform.clear();
mUniformMap.clear();
mUniformNameMap.clear();
mTexture.clear();
mValue.clear();
//initialize arrays
@@ -437,6 +512,7 @@ BOOL LLGLSLShader::mapUniforms(const vector<string> * uniforms)
unbind();
LL_DEBUGS("ShaderLoading") << "Total Uniform Size: " << mTotalUniformSize << llendl;
return res;
}
@@ -495,6 +571,58 @@ void LLGLSLShader::bindNoShader(void)
}
}
S32 LLGLSLShader::bindTexture(const std::string &uniform, LLTexture *texture, LLTexUnit::eTextureType mode)
{
S32 channel = 0;
channel = getUniformLocation(uniform);
return bindTexture(channel, texture, mode);
}
S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextureType mode)
{
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
return -1;
}
uniform = mTexture[uniform];
if (uniform > -1)
{
gGL.getTexUnit(uniform)->bind(texture, mode);
}
return uniform;
}
S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureType mode)
{
S32 channel = 0;
channel = getUniformLocation(uniform);
return unbindTexture(channel);
}
S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode)
{
if (uniform < 0 || uniform >= (S32)mTexture.size())
{
UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
return -1;
}
uniform = mTexture[uniform];
if (uniform > -1)
{
gGL.getTexUnit(uniform)->unbind(mode);
}
return uniform;
}
S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode)
{
if (uniform < 0 || uniform >= (S32)mTexture.size())
@@ -817,18 +945,18 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c
}
}
GLint LLGLSLShader::getUniformLocation(const string& uniform)
GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform)
{
GLint ret = -1;
if (mProgramObject > 0)
{
std::map<string, GLint>::iterator iter = mUniformMap.find(uniform);
LLStaticStringTable<GLint>::iterator iter = mUniformMap.find(uniform);
if (iter != mUniformMap.end())
{
if (gDebugGL)
{
stop_glerror();
if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.c_str()))
if (iter->second != glGetUniformLocationARB(mProgramObject, uniform.String().c_str()))
{
llerrs << "Uniform does not match." << llendl;
}
@@ -865,7 +993,7 @@ GLint LLGLSLShader::getAttribLocation(U32 attrib)
}
}
void LLGLSLShader::uniform1i(const string& uniform, GLint v)
void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v)
{
GLint location = getUniformLocation(uniform);
@@ -881,7 +1009,24 @@ void LLGLSLShader::uniform1i(const string& uniform, GLint v)
}
}
void LLGLSLShader::uniform1f(const string& uniform, GLfloat v)
void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j)
{
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
LLVector4 vec(i,j,0.f,0.f);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
glUniform2iARB(location, i, j);
mValue[location] = vec;
}
}
}
void LLGLSLShader::uniform1f(const LLStaticHashedString& uniform, GLfloat v)
{
GLint location = getUniformLocation(uniform);
@@ -897,7 +1042,7 @@ void LLGLSLShader::uniform1f(const string& uniform, GLfloat v)
}
}
void LLGLSLShader::uniform2f(const string& uniform, GLfloat x, GLfloat y)
void LLGLSLShader::uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y)
{
GLint location = getUniformLocation(uniform);
@@ -914,7 +1059,7 @@ void LLGLSLShader::uniform2f(const string& uniform, GLfloat x, GLfloat y)
}
void LLGLSLShader::uniform3f(const string& uniform, GLfloat x, GLfloat y, GLfloat z)
void LLGLSLShader::uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z)
{
GLint location = getUniformLocation(uniform);
@@ -930,23 +1075,7 @@ void LLGLSLShader::uniform3f(const string& uniform, GLfloat x, GLfloat y, GLfloa
}
}
void LLGLSLShader::uniform4f(const string& uniform, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
LLVector4 vec(x,y,z,w);
if (iter == mValue.end() || shouldChange(iter->second,vec))
{
glUniform4fARB(location, x,y,z,w);
mValue[location] = vec;
}
}
}
void LLGLSLShader::uniform1fv(const string& uniform, U32 count, const GLfloat* v)
void LLGLSLShader::uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
@@ -962,7 +1091,7 @@ void LLGLSLShader::uniform1fv(const string& uniform, U32 count, const GLfloat* v
}
}
void LLGLSLShader::uniform2fv(const string& uniform, U32 count, const GLfloat* v)
void LLGLSLShader::uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
@@ -978,7 +1107,7 @@ void LLGLSLShader::uniform2fv(const string& uniform, U32 count, const GLfloat* v
}
}
void LLGLSLShader::uniform3fv(const string& uniform, U32 count, const GLfloat* v)
void LLGLSLShader::uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
@@ -994,7 +1123,7 @@ void LLGLSLShader::uniform3fv(const string& uniform, U32 count, const GLfloat* v
}
}
void LLGLSLShader::uniform4fv(const string& uniform, U32 count, const GLfloat* v)
void LLGLSLShader::uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
@@ -1012,27 +1141,7 @@ void LLGLSLShader::uniform4fv(const string& uniform, U32 count, const GLfloat* v
}
}
void LLGLSLShader::uniformMatrix2fv(const string& uniform, U32 count, GLboolean transpose, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
glUniformMatrix2fvARB(location, count, transpose, v);
}
}
void LLGLSLShader::uniformMatrix3fv(const string& uniform, U32 count, GLboolean transpose, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);
if (location >= 0)
{
glUniformMatrix3fvARB(location, count, transpose, v);
}
}
void LLGLSLShader::uniformMatrix4fv(const string& uniform, U32 count, GLboolean transpose, const GLfloat* v)
void LLGLSLShader::uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat* v)
{
GLint location = getUniformLocation(uniform);

View File

@@ -29,6 +29,7 @@
#include "llgl.h"
#include "llrender.h"
#include "llstaticstringtable.h"
class LLShaderFeatures
{
@@ -68,6 +69,7 @@ public:
};
LLGLSLShader(S32 shader_class);
~LLGLSLShader();
static GLhandleARB sCurBoundShader;
static LLGLSLShader* sCurBoundShaderPtr;
@@ -75,16 +77,16 @@ public:
static bool sNoFixedFunction;
void unload();
BOOL createShader(std::vector<std::string> * attributes,
std::vector<std::string> * uniforms,
BOOL createShader(std::vector<LLStaticHashedString> * attributes,
std::vector<LLStaticHashedString> * uniforms,
U32 varying_count = 0,
const char** varyings = NULL);
BOOL attachObject(std::string object);
void attachObject(GLhandleARB object);
void attachObjects(GLhandleARB* objects = NULL, S32 count = 0);
BOOL mapAttributes(const std::vector<std::string> * attributes);
BOOL mapUniforms(const std::vector<std::string> * uniforms);
void mapUniform(GLint index, const std::vector<std::string> * uniforms);
BOOL mapAttributes(const std::vector<LLStaticHashedString> * attributes);
BOOL mapUniforms(const std::vector<LLStaticHashedString> *);
void mapUniform(GLint index, const std::vector<LLStaticHashedString> *);
void uniform1i(U32 index, GLint i);
void uniform1f(U32 index, GLfloat v);
void uniform2f(U32 index, GLfloat x, GLfloat y);
@@ -95,34 +97,35 @@ public:
void uniform2fv(U32 index, U32 count, const GLfloat* v);
void uniform3fv(U32 index, U32 count, const GLfloat* v);
void uniform4fv(U32 index, U32 count, const GLfloat* v);
void uniform1i(const std::string& uniform, GLint i);
void uniform1f(const std::string& uniform, GLfloat v);
void uniform2f(const std::string& uniform, GLfloat x, GLfloat y);
void uniform3f(const std::string& uniform, GLfloat x, GLfloat y, GLfloat z);
void uniform4f(const std::string& uniform, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void uniform1iv(const std::string& uniform, U32 count, const GLint* i);
void uniform1fv(const std::string& uniform, U32 count, const GLfloat* v);
void uniform2fv(const std::string& uniform, U32 count, const GLfloat* v);
void uniform3fv(const std::string& uniform, U32 count, const GLfloat* v);
void uniform4fv(const std::string& uniform, U32 count, const GLfloat* v);
void uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j);
void uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v);
void uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v);
void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v);
void uniformMatrix2fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v);
void uniformMatrix3fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v);
void uniformMatrix4fv(const std::string& uniform, U32 count, GLboolean transpose, const GLfloat *v);
void uniform1i(const LLStaticHashedString& uniform, GLint i);
void uniform1f(const LLStaticHashedString& uniform, GLfloat v);
void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y);
void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z);
void uniform1fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform2fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform3fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniform4fv(const LLStaticHashedString& uniform, U32 count, const GLfloat* v);
void uniformMatrix4fv(const LLStaticHashedString& uniform, U32 count, GLboolean transpose, const GLfloat *v);
void setMinimumAlpha(F32 minimum);
void vertexAttrib4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
void vertexAttrib4fv(U32 index, GLfloat* v);
GLint getUniformLocation(const std::string& uniform);
//GLint getUniformLocation(const std::string& uniform);
GLint getUniformLocation(const LLStaticHashedString& uniform);
GLint getUniformLocation(U32 index);
GLint getAttribLocation(U32 attrib);
GLint mapUniformTextureChannel(GLint location, GLenum type);
void addPermutation(std::string name, std::string value);
void removePermutation(std::string name);
//enable/disable texture channel for specified uniform
//if given texture uniform is active in the shader,
//the corresponding channel will be active upon return
@@ -130,6 +133,13 @@ public:
S32 enableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
S32 disableTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
// bindTexture returns the texture unit we've bound the texture to.
// You can reuse the return value to unbind a texture when required.
S32 bindTexture(const std::string& uniform, LLTexture *texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
S32 bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
S32 unbindTexture(const std::string& uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
S32 unbindTexture(S32 uniform, LLTexUnit::eTextureType mode = LLTexUnit::TT_TEXTURE);
BOOL link(BOOL suppress_errors = FALSE);
void bind();
void unbind();
@@ -142,10 +152,13 @@ public:
GLhandleARB mProgramObject;
std::vector<GLint> mAttribute; //lookup table of attribute enum to attribute channel
U32 mAttributeMask; //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask())
std::vector<GLint> mUniform; //lookup table of uniform enum to uniform location
std::map<std::string, GLint> mUniformMap; //lookup map of uniform name to uniform location
LLStaticStringTable<GLint> mUniformMap; //lookup map of uniform name to uniform location
std::map<GLint, std::string> mUniformNameMap; //lookup map of uniform location to uniform name
std::map<GLint, LLVector4> mValue; //lookup map of uniform location to last known value
std::vector<GLint> mTexture;
S32 mTotalUniformSize;
S32 mActiveTextureChannels;
S32 mShaderClass;
S32 mShaderLevel;
@@ -154,6 +167,7 @@ public:
LLShaderFeatures mFeatures;
std::vector< std::pair< std::string, GLenum > > mShaderFiles;
std::string mName;
std::map<std::string, std::string> mDefines;
};
//UI shader (declared here so llui_libtest will link properly)

View File

@@ -1099,6 +1099,26 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt
intformat = GL_RGBA8;
}
if (pixformat == GL_LUMINANCE && pixtype == GL_UNSIGNED_BYTE)
{ //GL_LUMINANCE is deprecated, convert to GL_RGBA
use_scratch = true;
scratch = new U32[width*height];
U32 pixel_count = (U32) (width*height);
for (U32 i = 0; i < pixel_count; i++)
{
U8 lum = ((U8*) pixels)[i];
U8* pix = (U8*) &scratch[i];
pix[0] = pix[1] = pix[2] = lum;
pix[3] = 1.f;
}
pixformat = GL_RGBA;
intformat = GL_RGBA8;
}
if (pixformat == GL_LUMINANCE_ALPHA && pixtype == GL_UNSIGNED_BYTE)
{ //GL_LUMINANCE_ALPHA is deprecated, convert to RGBA
use_scratch = true;

View File

@@ -51,6 +51,28 @@ extern LLGLSLShader gPostPosterizeProgram;
extern LLGLSLShader gPostMotionBlurProgram;
extern LLGLSLShader gPostVignetteProgram;
static LLStaticHashedString sGamma("gamma");
static LLStaticHashedString sBrightness("brightness");
static LLStaticHashedString sContrast("contrast");
static LLStaticHashedString sContrastBase("contrastBase");
static LLStaticHashedString sSaturation("saturation");
static LLStaticHashedString sBrightMult("brightMult");
static LLStaticHashedString sNoiseStrength("noiseStrength");
static LLStaticHashedString sLayerCount("layerCount");
static LLStaticHashedString sVignetteStrength("vignette_strength");
static LLStaticHashedString sVignettRadius("vignette_radius");
static LLStaticHashedString sVignetteDarkness("vignette_darkness");
static LLStaticHashedString sVignetteDesaturation("vignette_desaturation");
static LLStaticHashedString sVignetteChromaticAberration("vignette_chromatic_aberration");
static LLStaticHashedString sScreenRes("screen_res");
static LLStaticHashedString sHorizontalPass("horizontalPass");
static LLStaticHashedString sPrevProj("prev_proj");
static LLStaticHashedString sInvProj("inv_proj");
static LLStaticHashedString sBlurStrength("blur_strength");
static const unsigned int NOISE_SIZE = 512;
static const char * const XML_FILENAME = "postprocesseffects.xml";
@@ -155,16 +177,16 @@ public:
/*virtual*/ QuadType preDraw()
{
getShader().uniform1f("gamma", mGamma);
getShader().uniform1f("brightness", mBrightness);
getShader().uniform1f("contrast", mContrast);
getShader().uniform1f(sGamma, mGamma);
getShader().uniform1f(sBrightness, mBrightness);
getShader().uniform1f(sContrast, mContrast);
float baseI = (mContrastBase.get()[VX] + mContrastBase.get()[VY] + mContrastBase.get()[VZ]) / 3.0f;
baseI = mContrastBase.get()[VW] / llmax(baseI,0.001f);
float baseR = mContrastBase.get()[VX] * baseI;
float baseG = mContrastBase.get()[VY] * baseI;
float baseB = mContrastBase.get()[VZ] * baseI;
getShader().uniform3fv("contrastBase", 1, LLVector3(baseR, baseG, baseB).mV);
getShader().uniform1f("saturation", mSaturation);
getShader().uniform3fv(sContrastBase, 1, LLVector3(baseR, baseG, baseB).mV);
getShader().uniform1f(sSaturation, mSaturation);
return QUAD_NORMAL;
}
@@ -187,8 +209,8 @@ public:
{
LLPostProcess::getInstance()->bindNoise(1);
getShader().uniform1f("brightMult", mBrightnessMult);
getShader().uniform1f("noiseStrength", mNoiseStrength);
getShader().uniform1f(sBrightMult, mBrightnessMult);
getShader().uniform1f(sNoiseStrength, mNoiseStrength);
return QUAD_NOISE;
}
@@ -206,7 +228,7 @@ public:
}
/*virtual*/ QuadType preDraw()
{
getShader().uniform1i("layerCount", mNumLayers);
getShader().uniform1i(sLayerCount, mNumLayers);
return QUAD_NORMAL;
}
};
@@ -232,12 +254,13 @@ public:
/*virtual*/ QuadType preDraw()
{
LLVector2 screen_rect = LLPostProcess::getInstance()->getDimensions();
getShader().uniform1f("vignette_strength", mStrength);
getShader().uniform1f("vignette_radius", mRadius);
getShader().uniform1f("vignette_darkness", mDarkness);
getShader().uniform1f("vignette_desaturation", mDesaturation);
getShader().uniform1f("vignette_chromatic_aberration", mChromaticAberration);
getShader().uniform2fv("screen_res", 1, screen_rect.mV);
getShader().uniform1f(sVignetteStrength, mStrength);
getShader().uniform1f(sVignettRadius, mRadius);
getShader().uniform1f(sVignetteDarkness, mDarkness);
getShader().uniform1f(sVignetteDesaturation, mDesaturation);
getShader().uniform1f(sVignetteChromaticAberration, mChromaticAberration);
getShader().uniform2fv(sScreenRes, 1, screen_rect.mV);
return QUAD_NORMAL;
}
};
@@ -259,7 +282,7 @@ public:
/*virtual*/ S32 getDepthChannel() const { return -1; }
/*virtual*/ QuadType preDraw()
{
mPassLoc = getShader().getUniformLocation("horizontalPass");
mPassLoc = getShader().getUniformLocation(sHorizontalPass);
return QUAD_NORMAL;
}
/*virtual*/ bool draw(U32 pass)
@@ -295,10 +318,10 @@ public:
LLVector2 screen_rect = LLPostProcess::getInstance()->getDimensions();
getShader().uniformMatrix4fv("prev_proj", 1, GL_FALSE, prev_proj.m);
getShader().uniformMatrix4fv("inv_proj", 1, GL_FALSE, inv_proj.m);
getShader().uniform2fv("screen_res", 1, screen_rect.mV);
getShader().uniform1i("blur_strength", mStrength);
getShader().uniformMatrix4fv(sPrevProj, 1, GL_FALSE, prev_proj.m);
getShader().uniformMatrix4fv(sInvProj, 1, GL_FALSE, inv_proj.m);
getShader().uniform2fv(sScreenRes, 1, screen_rect.mV);
getShader().uniform1i(sBlurStrength, mStrength);
return QUAD_NORMAL;
}
@@ -312,7 +335,7 @@ public:
LLPostProcess::LLPostProcess(void) :
mVBO(NULL),
mDepthTexture(0),
mNoiseTexture(NULL),
mNoiseTexture(0),
mScreenWidth(0),
mScreenHeight(0),
mNoiseTextureScale(0.f),
@@ -407,7 +430,10 @@ void LLPostProcess::createScreenTextures()
stop_glerror();
if(mDepthTexture)
{
LLImageGL::deleteTextures(1, &mDepthTexture);
mDepthTexture = 0;
}
for(std::list<LLPointer<LLPostProcessShader> >::iterator it=mShaders.begin();it!=mShaders.end();++it)
{
@@ -434,16 +460,25 @@ void LLPostProcess::createNoiseTexture()
}
}
mNoiseTexture = new LLImageGL(FALSE) ;
if(mNoiseTexture->createGLTexture())
if(mNoiseTexture)
{
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseTexture->getTexName());
LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_RED, NOISE_SIZE, NOISE_SIZE, GL_RED, GL_UNSIGNED_BYTE, &buffer[0]);
stop_glerror();
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP);
stop_glerror();
LLImageGL::deleteTextures(1, &mNoiseTexture);
mNoiseTexture = 0;
}
LLImageGL::generateTextures(1, &mNoiseTexture);
stop_glerror();
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseTexture);
stop_glerror();
if(gGLManager.mGLVersion >= 4.f)
LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_R8, NOISE_SIZE, NOISE_SIZE, GL_RED, GL_UNSIGNED_BYTE, &buffer[0], false);
else
LLImageGL::setManualImage(GL_TEXTURE_2D, 0, GL_LUMINANCE8, NOISE_SIZE, NOISE_SIZE, GL_LUMINANCE, GL_UNSIGNED_BYTE, &buffer[0], false);
stop_glerror();
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_WRAP);
stop_glerror();
}
void LLPostProcess::destroyGL()
@@ -453,7 +488,9 @@ void LLPostProcess::destroyGL()
if(mDepthTexture)
LLImageGL::deleteTextures(1, &mDepthTexture);
mDepthTexture=0;
mNoiseTexture = NULL ;
if(mNoiseTexture)
LLImageGL::deleteTextures(1, &mNoiseTexture);
mNoiseTexture=0 ;
mVBO = NULL ;
}
@@ -467,6 +504,7 @@ void LLPostProcess::copyFrameBuffer()
{
mRenderTarget[!!mRenderTarget[0].getFBO()].bindTexture(0,0);
glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB,0,0,0,0,0,mScreenWidth, mScreenHeight);
stop_glerror();
if(mDepthTexture)
{
@@ -476,6 +514,7 @@ void LLPostProcess::copyFrameBuffer()
{
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_RECT_TEXTURE, mDepthTexture);
glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB,0,0,0,0,0,mScreenWidth, mScreenHeight);
stop_glerror();
break;
}
}
@@ -485,7 +524,7 @@ void LLPostProcess::copyFrameBuffer()
void LLPostProcess::bindNoise(U32 channel)
{
gGL.getTexUnit(channel)->bind(mNoiseTexture);
gGL.getTexUnit(channel)->bindManual(LLTexUnit::TT_TEXTURE,mNoiseTexture);
}
void LLPostProcess::renderEffects(unsigned int width, unsigned int height)
@@ -508,8 +547,7 @@ void LLPostProcess::doEffects(void)
{
LLVertexBuffer::unbind();
mNoiseTextureScale = 0.001f + ((100.f - mSelectedEffectInfo["noise_size"].asFloat()) / 100.f);
mNoiseTextureScale *= (mScreenHeight / NOISE_SIZE);
mNoiseTextureScale = (1.f - (mSelectedEffectInfo["noise_size"].asFloat() - 1.f) *(9.f/990.f)) / (float)NOISE_SIZE;
/// Copy the screen buffer to the render texture
copyFrameBuffer();
@@ -562,13 +600,19 @@ void LLPostProcess::applyShaders(void)
QuadType quad = (*it)->preDraw();
while((*it)->draw(pass++))
{
mRenderTarget[!primary_rendertarget].bindTarget();
LLRenderTarget& write_target = mRenderTarget[!primary_rendertarget];
LLRenderTarget& read_target = mRenderTarget[mRenderTarget[0].getFBO() ? primary_rendertarget : !primary_rendertarget];
write_target.bindTarget();
if(color_channel >= 0)
mRenderTarget[mRenderTarget[0].getFBO() ? primary_rendertarget : !primary_rendertarget].bindTexture(0,color_channel);
read_target.bindTexture(0,color_channel);
drawOrthoQuad(quad);
mRenderTarget[!primary_rendertarget].flush();
if(color_channel >= 0 && !mRenderTarget[0].getFBO())
gGL.getTexUnit(color_channel)->unbind(read_target.getUsage());
write_target.flush();
if(mRenderTarget[0].getFBO())
primary_rendertarget = !primary_rendertarget;
}
@@ -593,8 +637,13 @@ void LLPostProcess::drawOrthoQuad(QuadType type)
LLStrider<LLVector2> uv2;
mVBO->getTexCoord1Strider(uv2);
float offs[2] = {(float) rand() / (float) RAND_MAX, (float) rand() / (float) RAND_MAX};
float scale[2] = {mScreenWidth * mNoiseTextureScale / mScreenHeight, mNoiseTextureScale};
float offs[2] = {
llround(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE),
llround(((float) rand() / (float) RAND_MAX) * (float)NOISE_SIZE)/float(NOISE_SIZE) };
float scale[2] = {
(float)mScreenWidth * mNoiseTextureScale,
(float)mScreenHeight * mNoiseTextureScale };
uv2[0] = LLVector2(offs[0],offs[1]);
uv2[1] = LLVector2(offs[0],offs[1]+scale[1]);
uv2[2] = LLVector2(offs[0]+scale[0],offs[1]);

View File

@@ -90,7 +90,7 @@ private:
// However this is ONLY the case if fbos are actually supported, else swapping isn't needed.
LLRenderTarget mRenderTarget[2];
U32 mDepthTexture;
LLPointer<LLImageGL> mNoiseTexture ;
U32 mNoiseTexture ;
U32 mScreenWidth;
U32 mScreenHeight;

View File

@@ -1496,7 +1496,7 @@ void LLRender::translateUI(F32 x, F32 y, F32 z)
}
LLVector4a add(x,y,z);
mUIOffset.back()->add(add);
mUIOffset.back().add(add);
}
void LLRender::scaleUI(F32 x, F32 y, F32 z)
@@ -1507,33 +1507,27 @@ void LLRender::scaleUI(F32 x, F32 y, F32 z)
}
LLVector4a scale(x,y,z);
mUIScale.back()->mul(scale);
mUIScale.back().mul(scale);
}
void LLRender::pushUIMatrix()
{
if (mUIOffset.empty())
{
mUIOffset.push_back(static_cast<LLVector4a*>(ll_aligned_malloc_16(sizeof(LLVector4a))));
mUIOffset.back()->splat(0.f);
mUIOffset.push_back(LLVector4a(0.f));
}
else
{
const LLVector4a* last_entry = mUIOffset.back();
mUIOffset.push_back(static_cast<LLVector4a*>(ll_aligned_malloc_16(sizeof(LLVector4a))));
*mUIOffset.back() = *last_entry;
mUIOffset.push_back(mUIOffset.back());
}
if (mUIScale.empty())
{
mUIScale.push_back(static_cast<LLVector4a*>(ll_aligned_malloc_16(sizeof(LLVector4a))));
mUIScale.back()->splat(1.f);
mUIScale.push_back(LLVector4a(1.f));
}
else
{
const LLVector4a* last_entry = mUIScale.back();
mUIScale.push_back(static_cast<LLVector4a*>(ll_aligned_malloc_16(sizeof(LLVector4a))));
*mUIScale.back() = *last_entry;
mUIScale.push_back(mUIScale.back());
}
}
@@ -1543,9 +1537,7 @@ void LLRender::popUIMatrix()
{
llerrs << "UI offset stack blown." << llendl;
}
ll_aligned_free_16(mUIOffset.back());
mUIOffset.pop_back();
ll_aligned_free_16(mUIScale.back());
mUIScale.pop_back();
}
@@ -1555,7 +1547,7 @@ LLVector3 LLRender::getUITranslation()
{
return LLVector3(0,0,0);
}
return LLVector3(mUIOffset.back()->getF32ptr());
return LLVector3(mUIOffset.back().getF32ptr());
}
LLVector3 LLRender::getUIScale()
@@ -1564,7 +1556,7 @@ LLVector3 LLRender::getUIScale()
{
return LLVector3(1,1,1);
}
return LLVector3(mUIScale.back()->getF32ptr());
return LLVector3(mUIScale.back().getF32ptr());
}
@@ -1574,8 +1566,8 @@ void LLRender::loadUIIdentity()
{
llerrs << "Need to push UI translation frame before clearing offset." << llendl;
}
mUIOffset.back()->splat(0.f);
mUIScale.back()->splat(1.f);
mUIOffset.back().splat(0.f);
mUIScale.back().splat(1.f);
}
void LLRender::setColorMask(bool writeColor, bool writeAlpha)
@@ -1977,8 +1969,8 @@ void LLRender::vertex4a(const LLVector4a& vertex)
else
{
//LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back());
mVerticesp[mCount].setAdd(vertex,*mUIOffset.back());
mVerticesp[mCount].mul(*mUIScale.back());
mVerticesp[mCount].setAdd(vertex,mUIOffset.back());
mVerticesp[mCount].mul(mUIScale.back());
}
if (mMode == LLRender::QUADS && LLRender::sGLCoreProfile)

View File

@@ -38,6 +38,7 @@
#include "v3math.h"
#include "v4coloru.h"
#include "v4math.h"
#include "llalignedarray.h"
#include "llstrider.h"
#include "llpointer.h"
#include "llglheaders.h"
@@ -466,9 +467,8 @@ private:
F32 mMaxAnisotropy;
std::vector<LLVector4a*> mUIOffset;
std::vector<LLVector4a*> mUIScale;
LLAlignedArray<LLVector4a, 64> mUIOffset;
LLAlignedArray<LLVector4a, 64> mUIScale;
};
extern F32 gGLModelView[16];

View File

@@ -72,7 +72,7 @@ LLRenderTarget::~LLRenderTarget()
release();
}
void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt)
void LLRenderTarget::resize(U32 resx, U32 resy)
{
//for accounting, get the number of pixels added/subtracted
S32 pix_diff = (resx*resy)-(mResX*mResY);
@@ -80,10 +80,12 @@ void LLRenderTarget::resize(U32 resx, U32 resy, U32 color_fmt)
mResX = resx;
mResY = resy;
llassert(mInternalFormat.size() == mTex.size());
for (U32 i = 0; i < mTex.size(); ++i)
{ //resize color attachments
gGL.getTexUnit(0)->bindManual(mUsage, mTex[i]);
LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false);
LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, mInternalFormat[i], mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false);
sBytesAllocated += pix_diff*4;
}

View File

@@ -79,7 +79,7 @@ public:
// CAUTION: if the GL runs out of memory attempting to resize, this render target will be undefined
// DO NOT use for screen space buffers or for scratch space for an image that might be uploaded
// DO use for render targets that resize often and aren't likely to ruin someone's day if they break
void resize(U32 resx, U32 resy, U32 color_fmt);
void resize(U32 resx, U32 resy);
//provide this render target with a multisample resource.
void setSampleBuffer(LLMultisampleBuffer* buffer);

View File

@@ -528,7 +528,7 @@ void LLShaderMgr::dumpObjectLog(GLhandleARB ret, BOOL warns)
}
}
GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, S32 texture_index_channels)
GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, std::map<std::string, std::string>* defines, S32 texture_index_channels)
{
std::pair<std::multimap<std::string, CachedObjectInfo >::iterator, std::multimap<std::string, CachedObjectInfo>::iterator> range;
range = mShaderObjects.equal_range(filename);
@@ -669,12 +669,14 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
if(SHPackDeferredNormals)
text[count++] = strdup("#define PACK_NORMALS\n");
//copy preprocessor definitions into buffer
for (std::map<std::string,std::string>::iterator iter = mDefinitions.begin(); iter != mDefinitions.end(); ++iter)
if(defines)
{
for (std::map<std::string,std::string>::iterator iter = defines->begin(); iter != defines->end(); ++iter)
{
std::string define = "#define " + iter->first + " " + iter->second + "\n";
text[count++] = (GLcharARB *) strdup(define.c_str());
}
}
if (texture_index_channels > 0 && type == GL_FRAGMENT_SHADER_ARB)
{
@@ -924,7 +926,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
if (shader_level > 1)
{
shader_level--;
return loadShaderFile(filename,shader_level,type,texture_index_channels);
return loadShaderFile(filename,shader_level,type, defines, texture_index_channels);
}
LL_WARNS("ShaderLoading") << "Failed to load " << filename << LL_ENDL;
}
@@ -1044,7 +1046,9 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("texture_matrix1");
mReservedUniforms.push_back("texture_matrix2");
mReservedUniforms.push_back("texture_matrix3");
llassert(mReservedUniforms.size() == LLShaderMgr::TEXTURE_MATRIX3+1);
mReservedUniforms.push_back("object_plane_s");
mReservedUniforms.push_back("object_plane_t");
llassert(mReservedUniforms.size() == LLShaderMgr::OBJECT_PLANE_T+1);
mReservedUniforms.push_back("viewport");
@@ -1185,7 +1189,47 @@ void LLShaderMgr::initAttribsAndUniforms()
mReservedUniforms.push_back("lightMap");
mReservedUniforms.push_back("bloomMap");
mReservedUniforms.push_back("projectionMap");
mReservedUniforms.push_back("norm_mat");
mReservedUniforms.push_back("matrixPalette");
mReservedUniforms.push_back("screenTex");
mReservedUniforms.push_back("screenDepth");
mReservedUniforms.push_back("refTex");
mReservedUniforms.push_back("eyeVec");
mReservedUniforms.push_back("time");
mReservedUniforms.push_back("d1");
mReservedUniforms.push_back("d2");
mReservedUniforms.push_back("lightDir");
mReservedUniforms.push_back("specular");
mReservedUniforms.push_back("lightExp");
mReservedUniforms.push_back("waterFogColor");
mReservedUniforms.push_back("waterFogDensity");
mReservedUniforms.push_back("waterFogKS");
mReservedUniforms.push_back("refScale");
mReservedUniforms.push_back("waterHeight");
mReservedUniforms.push_back("waterPlane");
mReservedUniforms.push_back("normScale");
mReservedUniforms.push_back("fresnelScale");
mReservedUniforms.push_back("fresnelOffset");
mReservedUniforms.push_back("blurMultiplier");
mReservedUniforms.push_back("sunAngle");
mReservedUniforms.push_back("scaledAngle");
mReservedUniforms.push_back("sunAngle2");
mReservedUniforms.push_back("camPosLocal");
mReservedUniforms.push_back("gWindDir");
mReservedUniforms.push_back("gSinWaveParams");
mReservedUniforms.push_back("gGravity");
mReservedUniforms.push_back("detail_0");
mReservedUniforms.push_back("detail_1");
mReservedUniforms.push_back("detail_2");
mReservedUniforms.push_back("detail_3");
mReservedUniforms.push_back("alpha_ramp");
mReservedUniforms.push_back("origin");
llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS);
std::set<std::string> dupe_check;

View File

@@ -47,6 +47,8 @@ public:
TEXTURE_MATRIX1,
TEXTURE_MATRIX2,
TEXTURE_MATRIX3,
OBJECT_PLANE_S,
OBJECT_PLANE_T,
VIEWPORT,
LIGHT_POSITION,
LIGHT_DIRECTION,
@@ -164,6 +166,45 @@ public:
DEFERRED_LIGHT,
DEFERRED_BLOOM,
DEFERRED_PROJECTION,
DEFERRED_NORM_MATRIX,
AVATAR_MATRIX,
WATER_SCREENTEX,
WATER_SCREENDEPTH,
WATER_REFTEX,
WATER_EYEVEC,
WATER_TIME,
WATER_WAVE_DIR1,
WATER_WAVE_DIR2,
WATER_LIGHT_DIR,
WATER_SPECULAR,
WATER_SPECULAR_EXP,
WATER_FOGCOLOR,
WATER_FOGDENSITY,
WATER_FOGKS,
WATER_REFSCALE,
WATER_WATERHEIGHT,
WATER_WATERPLANE,
WATER_NORM_SCALE,
WATER_FRESNEL_SCALE,
WATER_FRESNEL_OFFSET,
WATER_BLUR_MULTIPLIER,
WATER_SUN_ANGLE,
WATER_SCALED_ANGLE,
WATER_SUN_ANGLE2,
WL_CAMPOSLOCAL,
AVATAR_WIND,
AVATAR_SINWAVE,
AVATAR_GRAVITY,
TERRAIN_DETAIL0,
TERRAIN_DETAIL1,
TERRAIN_DETAIL2,
TERRAIN_DETAIL3,
TERRAIN_ALPHARAMP,
SHINY_ORIGIN,
END_RESERVED_UNIFORMS
} eGLSLReservedUniforms;
@@ -176,7 +217,7 @@ public:
void dumpObjectLog(GLhandleARB ret, BOOL warns = TRUE);
BOOL linkProgramObject(GLhandleARB obj, BOOL suppress_errors = FALSE);
BOOL validateProgramObject(GLhandleARB obj);
GLhandleARB loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, S32 texture_index_channels = -1);
GLhandleARB loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, std::map<std::string, std::string>* defines = NULL, S32 texture_index_channels = -1);
// Implemented in the application to actually point to the shader directory.
virtual std::string getShaderDirPrefix(void) = 0; // Pure Virtual

View File

@@ -207,9 +207,6 @@ public:
void setImageFlash(LLPointer<LLUIImage> image);
void setImagePressed(LLPointer<LLUIImage> image);
void setCommitOnReturn(BOOL commit) { mCommitOnReturn = commit; }
BOOL getCommitOnReturn() const { return mCommitOnReturn; }
static void onHeldDown(void *userdata); // to be called by gIdleCallbacks
void setHelpURLCallback(const std::string &help_url);
const std::string& getHelpURL() const { return mHelpURL; }

View File

@@ -4630,10 +4630,13 @@ BOOL LLMenuHolderGL::handleKey(KEY key, MASK mask, BOOL called_from_parent)
}
else
{
//highlight first enabled one
if(pMenu->highlightNextItem(NULL))
if (key == KEY_UP || key == KEY_DOWN) // Singu Note: Only highlight if the user actually meant to navigate through the menu
{
handled = true;
//highlight first enabled one
if (pMenu->highlightNextItem(NULL))
{
handled = true;
}
}
}
}

View File

@@ -159,8 +159,12 @@ void LLPanel::addBorder(LLViewBorder::EBevel border_bevel,
void LLPanel::removeBorder()
{
delete mBorder;
mBorder = NULL;
if (mBorder)
{
removeChild(mBorder);
delete mBorder;
mBorder = NULL;
}
}
@@ -277,7 +281,7 @@ BOOL LLPanel::handleKeyHere( KEY key, MASK mask )
// handle user hitting ESC to defocus
if (key == KEY_ESCAPE && mask == MASK_NONE)
{
gFocusMgr.setKeyboardFocus(NULL);
setFocus(FALSE);
return TRUE;
}
else if( (mask == MASK_SHIFT) && (KEY_TAB == key))
@@ -304,29 +308,25 @@ BOOL LLPanel::handleKeyHere( KEY key, MASK mask )
}
}
}
// If we have a default button, click it when
// return is pressed, unless current focus is a return-capturing button
// in which case *that* button will handle the return key
LLButton* focused_button = dynamic_cast<LLButton*>(cur_focus);
if (cur_focus && !(focused_button && focused_button->getCommitOnReturn()))
// If RETURN was pressed and something has focus, call onCommit()
if (!handled && cur_focus && key == KEY_RETURN && mask == MASK_NONE)
{
// RETURN key means hit default button in this case
if (key == KEY_RETURN && mask == MASK_NONE
&& mDefaultBtn != NULL
&& mDefaultBtn->getVisible()
&& mDefaultBtn->getEnabled())
if (cur_focus->getCommitOnReturn())
{
// current focus is a return-capturing element,
// let *that* element handle the return key
handled = FALSE;
}
else if (mDefaultBtn && mDefaultBtn->getVisible() && mDefaultBtn->getEnabled())
{
// If we have a default button, click it when return is pressed
mDefaultBtn->onCommit();
handled = TRUE;
}
}
if (key == KEY_RETURN && mask == MASK_NONE)
{
// set keyboard focus to self to trigger commitOnFocusLost behavior on current ctrl
if (cur_focus && cur_focus->acceptsTextInput())
else if (cur_focus->acceptsTextInput())
{
// call onCommit for text input handling control
cur_focus->onCommit();
handled = TRUE;
}
@@ -363,34 +363,16 @@ void LLPanel::handleVisibilityChange ( BOOL new_visibility )
void LLPanel::setFocus(BOOL b)
{
if( b )
if( b && !hasFocus())
{
if (!gFocusMgr.childHasKeyboardFocus(this))
{
//refresh();
if (!focusFirstItem())
{
LLUICtrl::setFocus(TRUE);
}
onFocusReceived();
}
// give ourselves focus preemptively, to avoid infinite loop
LLUICtrl::setFocus(TRUE);
// then try to pass to first valid child
focusFirstItem();
}
else
{
if( this == gFocusMgr.getKeyboardFocus() )
{
gFocusMgr.setKeyboardFocus( NULL );
}
else
{
//RN: why is this here?
LLView::ctrl_list_t ctrls = getCtrlList();
for (LLView::ctrl_list_t::iterator ctrl_it = ctrls.begin(); ctrl_it != ctrls.end(); ++ctrl_it)
{
LLUICtrl* ctrl = *ctrl_it;
ctrl->setFocus( FALSE );
}
}
LLUICtrl::setFocus(b);
}
}

View File

@@ -56,7 +56,8 @@ LLUICtrl::LLUICtrl() :
mDoubleClickSignal(NULL),
mTentative(FALSE),
mTabStop(TRUE),
mIsChrome(FALSE)
mIsChrome(FALSE),
mCommitOnReturn(FALSE)
{
}
@@ -78,7 +79,8 @@ LLUICtrl::LLUICtrl(const std::string& name, const LLRect rect, BOOL mouse_opaque
mDoubleClickSignal(NULL),
mTentative( FALSE ),
mTabStop( TRUE ),
mIsChrome(FALSE)
mIsChrome(FALSE),
mCommitOnReturn(FALSE)
{
if(commit_callback)
setCommitCallback(commit_callback);
@@ -178,6 +180,13 @@ BOOL LLUICtrl::handleDoubleClick(S32 x, S32 y, MASK mask)
return handled;
}
// can't tab to children of a non-tab-stop widget
BOOL LLUICtrl::canFocusChildren() const
{
return TRUE;//hasTabStop();
}
void LLUICtrl::onCommit()
{
if (mCommitSignal)
@@ -528,7 +537,8 @@ BOOL LLUICtrl::focusNextItem(BOOL text_fields_only)
{
// this assumes that this method is called on the focus root.
LLCtrlQuery query = getTabOrderQuery();
if(text_fields_only || LLUI::sConfigGroup->getBOOL("TabToTextFieldsOnly"))
static LLUICachedControl<bool> tab_to_text_fields_only ("TabToTextFieldsOnly", false);
if(text_fields_only || tab_to_text_fields_only)
{
query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
}
@@ -540,7 +550,8 @@ BOOL LLUICtrl::focusPrevItem(BOOL text_fields_only)
{
// this assumes that this method is called on the focus root.
LLCtrlQuery query = getTabOrderQuery();
if(text_fields_only || LLUI::sConfigGroup->getBOOL("TabToTextFieldsOnly"))
static LLUICachedControl<bool> tab_to_text_fields_only ("TabToTextFieldsOnly", false);
if(text_fields_only || tab_to_text_fields_only)
{
query.addPreFilter(LLUICtrl::LLTextInputFilter::getInstance());
}
@@ -552,7 +563,7 @@ LLUICtrl* LLUICtrl::findRootMostFocusRoot()
{
LLUICtrl* focus_root = NULL;
LLUICtrl* next_view = this;
while(next_view)
while(next_view/* && next_view->hasTabStop()*/)
{
if (next_view->isFocusRoot())
{

View File

@@ -70,6 +70,7 @@ public:
/*virtual*/ BOOL isCtrl() const;
/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL canFocusChildren() const;
/*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
@@ -132,6 +133,9 @@ public:
LLUICtrl* getParentUICtrl() const;
void setCommitOnReturn(BOOL commit) { mCommitOnReturn = commit; }
BOOL getCommitOnReturn() const { return mCommitOnReturn; }
//Start using these!
boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb );
boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb );
@@ -198,6 +202,8 @@ private:
BOOL mIsChrome;
BOOL mTentative;
bool mCommitOnReturn;
class DefaultTabGroupFirstSorter;
};

View File

@@ -1377,7 +1377,10 @@ void LLView::reshape(S32 width, S32 height, BOOL called_from_parent)
S32 delta_x = child_rect.mLeft - viewp->getRect().mLeft;
S32 delta_y = child_rect.mBottom - viewp->getRect().mBottom;
viewp->translate( delta_x, delta_y );
viewp->reshape(child_rect.getWidth(), child_rect.getHeight());
if (child_rect.getWidth() != viewp->getRect().getWidth() || child_rect.getHeight() != viewp->getRect().getHeight())
{
viewp->reshape(child_rect.getWidth(), child_rect.getHeight());
}
}
}

View File

@@ -48,6 +48,7 @@ void main()
color.rgb = fullbrightScaleSoftClip(color.rgb);
color.a = .0;
frag_color = color;
}

View File

@@ -0,0 +1,67 @@
/**
* @file debugF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2D depthMap;
uniform float delta;
VARYING vec2 tc0;
VARYING vec2 tc1;
VARYING vec2 tc2;
VARYING vec2 tc3;
VARYING vec2 tc4;
VARYING vec2 tc5;
VARYING vec2 tc6;
VARYING vec2 tc7;
VARYING vec2 tc8;
void main()
{
vec4 depth1 =
vec4(texture2D(depthMap, tc0).r,
texture2D(depthMap, tc1).r,
texture2D(depthMap, tc2).r,
texture2D(depthMap, tc3).r);
vec4 depth2 =
vec4(texture2D(depthMap, tc4).r,
texture2D(depthMap, tc5).r,
texture2D(depthMap, tc6).r,
texture2D(depthMap, tc7).r);
depth1 = min(depth1, depth2);
float depth = min(depth1.x, depth1.y);
depth = min(depth, depth1.z);
depth = min(depth, depth1.w);
depth = min(depth, texture2D(depthMap, tc8).r);
gl_FragDepth = depth;
}

View File

@@ -0,0 +1,69 @@
/**
* @file debugF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
uniform float delta;
VARYING vec2 tc0;
VARYING vec2 tc1;
VARYING vec2 tc2;
VARYING vec2 tc3;
VARYING vec2 tc4;
VARYING vec2 tc5;
VARYING vec2 tc6;
VARYING vec2 tc7;
VARYING vec2 tc8;
void main()
{
vec4 depth1 =
vec4(texture2DRect(depthMap, tc0).r,
texture2DRect(depthMap, tc1).r,
texture2DRect(depthMap, tc2).r,
texture2DRect(depthMap, tc3).r);
vec4 depth2 =
vec4(texture2DRect(depthMap, tc4).r,
texture2DRect(depthMap, tc5).r,
texture2DRect(depthMap, tc6).r,
texture2DRect(depthMap, tc7).r);
depth1 = min(depth1, depth2);
float depth = min(depth1.x, depth1.y);
depth = min(depth, depth1.z);
depth = min(depth, depth1.w);
depth = min(depth, texture2DRect(depthMap, tc8).r);
gl_FragDepth = depth;
}

View File

@@ -0,0 +1,59 @@
/**
* @file debugV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2011, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
uniform vec2 screen_res;
uniform vec2 delta;
VARYING vec2 tc0;
VARYING vec2 tc1;
VARYING vec2 tc2;
VARYING vec2 tc3;
VARYING vec2 tc4;
VARYING vec2 tc5;
VARYING vec2 tc6;
VARYING vec2 tc7;
VARYING vec2 tc8;
void main()
{
gl_Position = vec4(position, 1.0);
vec2 tc = (position.xy*0.5+0.5)*screen_res;
tc0 = tc+vec2(-delta.x,-delta.y);
tc1 = tc+vec2(0,-delta.y);
tc2 = tc+vec2(delta.x,-delta.y);
tc3 = tc+vec2(-delta.x,0);
tc4 = tc+vec2(0,0);
tc5 = tc+vec2(delta.x,0);
tc6 = tc+vec2(-delta.x,delta.y);
tc7 = tc+vec2(0,delta.y);
tc8 = tc+vec2(delta.x,delta.y);
}

View File

@@ -50,7 +50,7 @@ void fullbright_shiny_lighting()
color.rgb = fullbrightScaleSoftClip(color.rgb);
color.a = max(color.a, vertex_color.a);
color.a = 0.0;
frag_color = color;
}

View File

@@ -51,7 +51,7 @@ void fullbright_shiny_lighting()
color.rgb = fullbrightScaleSoftClip(color.rgb);
color.a = max(color.a, vertex_color.a);
color.a = 0.0;
frag_color = color;
}

View File

@@ -48,7 +48,7 @@ void fullbright_shiny_lighting_water()
color.rgb = fullbrightShinyAtmosTransport(color.rgb);
color.rgb = fullbrightScaleSoftClip(color.rgb);
color.a = max(color.a, vertex_color.a);
color.a = 1.0;
frag_color = applyWaterFog(color);
}

View File

@@ -49,7 +49,7 @@ void fullbright_shiny_lighting_water()
color.rgb = fullbrightShinyAtmosTransport(color.rgb);
color.rgb = fullbrightScaleSoftClip(color.rgb);
color.a = max(color.a, vertex_color.a);
color.a = 0.0;
frag_color = applyWaterFog(color);
}

View File

@@ -32,7 +32,7 @@ out vec4 frag_color;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
vec4 diffuseLookup(vec2 texcoord);
/* vec4 diffuseLookup(vec2 texcoord); */
vec3 fullbrightAtmosTransport(vec3 light);
vec4 applyWaterFog(vec4 color);

View File

@@ -50,7 +50,7 @@ void shiny_lighting()
color.rgb = atmosLighting(color.rgb);
color.rgb = scaleSoftClip(color.rgb);
color.a = max(color.a, vertex_color.a);
color.a = 1.0;
frag_color = color;
}

View File

@@ -51,7 +51,7 @@ void shiny_lighting()
color.rgb = atmosLighting(color.rgb);
color.rgb = scaleSoftClip(color.rgb);
color.a = max(color.a, vertex_color.a);
color.a = 1.0;
frag_color = color;
}

View File

@@ -47,7 +47,7 @@ void shiny_lighting_water()
color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a);
color.rgb = atmosLighting(color.rgb);
color.a = max(color.a, vertex_color.a);
color.a = 1.0;
frag_color = applyWaterFog(color);
}

View File

@@ -48,7 +48,7 @@ void shiny_lighting_water()
color.rgb = mix(color.rgb, envColor.rgb, vertex_color.a);
color.rgb = atmosLighting(color.rgb);
color.a = max(color.a, vertex_color.a);
color.a = 1.0;
frag_color = applyWaterFog(color);
}

View File

@@ -48,11 +48,9 @@ void main()
mat = modelview_matrix * mat;
vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
vertex_color = emissive;
calcAtmospherics(pos.xyz);
vertex_color = emissive;
gl_Position = projection_matrix*vec4(pos, 1.0);
}

View File

@@ -35,6 +35,14 @@ RequestExecutionLevel admin ; on Vista we must be admin because we write to Prog
%%GRID_VARS%%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Alows us to determine if we're running on 64 bit OS; ${If} macros
!include "x64.nsh"
!include "LogicLib.nsh"
;; are 64 bit binaries packaged in this installer
%%WIN64_BIN_BUILD%%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; - language files - one for each language (or flavor thereof)
;; (these files are in the same place as the nsi template but the python script generates a new nsi file in the
@@ -664,6 +672,12 @@ FunctionEnd
;; entry to the language ID selector below
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Function .onInit
!ifdef WIN64_BIN_BUILD
${IfNot} ${RunningX64}
MessageBox MB_OK|MB_ICONSTOP "This version requires 64 bit operating sytem."
Quit
${EndIf}
!endif
Push $0
${GetParameters} $COMMANDLINE ; get our command line
${GetOptions} $COMMANDLINE "/LANGID=" $0 ; /LANGID=1033 implies US English

View File

@@ -4332,9 +4332,10 @@ public:
<< llendl;
//dec_busy_count();
gInventory.removeObserver(this);
doOnIdleOneTime(mCallable);
// lets notify observers that loading is finished.
gAgentWearables.notifyLoadingFinished();
//gAgentWearables.notifyLoadingFinished();
delete this;
return;
}

View File

@@ -1509,7 +1509,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
stop_glerror();
LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv("matrixPalette",
LLDrawPoolAvatar::sVertexProgram->uniformMatrix4fv(LLViewerShaderMgr::AVATAR_MATRIX,
maxJoints,
FALSE,
(GLfloat*) mat[0].mMatrix);

View File

@@ -570,6 +570,7 @@ void LLDrawPoolBump::renderFullbrightShiny()
{
LLGLEnable blend_enable(GL_BLEND);
gGL.setSceneBlendType(LLRender::BT_REPLACE);
if (mVertexShaderLevel > 1)
{
LLRenderPass::pushBatches(LLRenderPass::PASS_FULLBRIGHT_SHINY, sVertexMask | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
@@ -578,6 +579,7 @@ void LLDrawPoolBump::renderFullbrightShiny()
{
LLRenderPass::renderTexture(LLRenderPass::PASS_FULLBRIGHT_SHINY, sVertexMask);
}
gGL.setSceneBlendType(LLRender::BT_ALPHA);
}
}
@@ -896,7 +898,9 @@ void LLDrawPoolBump::renderPostDeferred(S32 pass)
switch (pass)
{
case 0:
gGL.setColorMask(true, true);
renderFullbrightShiny();
gGL.setColorMask(true, false);
break;
case 1:
renderBump(LLRenderPass::PASS_POST_BUMP);
@@ -1370,9 +1374,14 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
LLGLDisable blend(GL_BLEND);
gGL.setColorMask(TRUE, TRUE);
gNormalMapGenProgram.bind();
gNormalMapGenProgram.uniform1f("norm_scale", gSavedSettings.getF32("RenderNormalMapScale"));
gNormalMapGenProgram.uniform1f("stepX", 1.f/bump->getWidth());
gNormalMapGenProgram.uniform1f("stepY", 1.f/bump->getHeight());
static LLStaticHashedString sNormScale("norm_scale");
static LLStaticHashedString sStepX("stepX");
static LLStaticHashedString sStepY("stepY");
gNormalMapGenProgram.uniform1f(sNormScale, gSavedSettings.getF32("RenderNormalMapScale"));
gNormalMapGenProgram.uniform1f(sStepX, 1.f/bump->getWidth());
gNormalMapGenProgram.uniform1f(sStepX, 1.f/bump->getHeight());
LLVector2 v((F32) bump->getWidth()/gPipeline.mScreen.getWidth(),
(F32) bump->getHeight()/gPipeline.mScreen.getHeight());

View File

@@ -362,8 +362,8 @@ void LLDrawPoolTerrain::renderFullShader()
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
llassert(shader);
shader->uniform4fv("object_plane_s", 1, tp0.mV);
shader->uniform4fv("object_plane_t", 1, tp1.mV);
shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0.mV);
shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1.mV);
gGL.matrixMode(LLRender::MM_TEXTURE);
gGL.loadIdentity();
@@ -873,8 +873,8 @@ void LLDrawPoolTerrain::renderSimple()
if (LLGLSLShader::sNoFixedFunction)
{
sShader->uniform4fv("object_plane_s", 1, tp0.mV);
sShader->uniform4fv("object_plane_t", 1, tp1.mV);
sShader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0.mV);
sShader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1.mV);
}
else
{

View File

@@ -449,8 +449,8 @@ void LLDrawPoolWater::renderOpaqueLegacyWater()
}
else
{
shader->uniform4fv("object_plane_s", 1, tp0);
shader->uniform4fv("object_plane_t", 1, tp1);
shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0);
shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1);
}
gGL.diffuseColor3f(1.f, 1.f, 1.f);
@@ -624,12 +624,12 @@ void LLDrawPoolWater::shade()
mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT);
}
S32 screentex = shader->enableTexture(LLViewerShaderMgr::WATER_SCREENTEX);
S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);
if (screentex > -1)
{
shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
shader->uniform1f(LLViewerShaderMgr::WATER_FOGDENSITY,
shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY,
param_mgr->getFogDensity());
gPipeline.mWaterDis.bindTexture(0, screentex);
}
@@ -641,7 +641,7 @@ void LLDrawPoolWater::shade()
if (mVertexShaderLevel == 1)
{
sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue;
shader->uniform4fv(LLViewerShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
}
F32 screenRes[] =
@@ -649,10 +649,10 @@ void LLDrawPoolWater::shade()
1.f/gGLViewport[2],
1.f/gGLViewport[3]
};
shader->uniform2fv("screenRes", 1, screenRes);
shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes);
stop_glerror();
S32 diffTex = shader->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
stop_glerror();
light_dir.normVec();
@@ -661,26 +661,26 @@ void LLDrawPoolWater::shade()
light_diffuse *= 6.f;
//shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix);
shader->uniform1f(LLViewerShaderMgr::WATER_WATERHEIGHT, eyedepth);
shader->uniform1f(LLViewerShaderMgr::WATER_TIME, sTime);
shader->uniform3fv(LLViewerShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV);
shader->uniform3fv(LLViewerShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);
shader->uniform1f(LLViewerShaderMgr::WATER_SPECULAR_EXP, light_exp);
shader->uniform2fv(LLViewerShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV);
shader->uniform2fv(LLViewerShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV);
shader->uniform3fv(LLViewerShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV);
shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth);
shader->uniform1f(LLShaderMgr::WATER_TIME, sTime);
shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV);
shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);
shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp);
shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV);
shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV);
shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV);
shader->uniform3fv("normScale", 1, param_mgr->getNormalScale().mV);
shader->uniform1f("fresnelScale", param_mgr->getFresnelScale());
shader->uniform1f("fresnelOffset", param_mgr->getFresnelOffset());
shader->uniform1f("blurMultiplier", param_mgr->getBlurMultiplier());
shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV);
shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale());
shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset());
shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier());
F32 sunAngle = llmax(0.f, light_dir.mV[2]);
F32 scaledAngle = 1.f - sunAngle;
shader->uniform1f("sunAngle", sunAngle);
shader->uniform1f("scaledAngle", scaledAngle);
shader->uniform1f("sunAngle2", 0.1f + 0.2f*sunAngle);
shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle);
shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle);
shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle);
LLColor4 water_color;
LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
@@ -688,12 +688,12 @@ void LLDrawPoolWater::shade()
if (LLViewerCamera::getInstance()->cameraUnderWater())
{
water_color.setVec(1.f, 1.f, 1.f, 0.4f);
shader->uniform1f(LLViewerShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow());
shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow());
}
else
{
water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot));
shader->uniform1f(LLViewerShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove());
shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove());
}
if (water_color.mV[3] > 0.9f)
@@ -739,12 +739,12 @@ void LLDrawPoolWater::shade()
}
}
shader->disableTexture(LLViewerShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
shader->disableTexture(LLViewerShaderMgr::WATER_SCREENTEX);
shader->disableTexture(LLViewerShaderMgr::BUMP_MAP);
shader->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
shader->disableTexture(LLViewerShaderMgr::WATER_REFTEX);
shader->disableTexture(LLViewerShaderMgr::WATER_SCREENDEPTH);
shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
shader->disableTexture(LLShaderMgr::WATER_SCREENTEX);
shader->disableTexture(LLShaderMgr::BUMP_MAP);
shader->disableTexture(LLShaderMgr::DIFFUSE_MAP);
shader->disableTexture(LLShaderMgr::WATER_REFTEX);
shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH);
if (deferred_render)
{

View File

@@ -161,7 +161,8 @@ void LLDrawPoolWLSky::renderDome(F32 camHeightLocal, LLGLSLShader * shader) cons
gGL.translatef(0.f,-camHeightLocal, 0.f);
// Draw WL Sky
shader->uniform3f("camPosLocal", 0.f, camHeightLocal, 0.f);
static LLStaticHashedString sCamPosLocal("camPosLocal");
shader->uniform3f(sCamPosLocal, 0.f, camHeightLocal, 0.f);
gSky.mVOWLSkyp->drawDome();
@@ -219,7 +220,8 @@ void LLDrawPoolWLSky::renderStars(void) const
if (gPipeline.canUseVertexShaders())
{
star_shader->uniform1f("custom_alpha", star_alpha.mV[3]);
static LLStaticHashedString sCustomAlpha("custom_alpha");
star_shader->uniform1f(sCustomAlpha, star_alpha.mV[3]);
}
else
{
@@ -294,7 +296,8 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
if (gPipeline.canUseVertexShaders())
{
// Okay, so the moon isn't a star, but it's close enough.
star_shader->uniform1f("custom_alpha", color.mV[VW]);
static LLStaticHashedString sCustomAlpha("custom_alpha");
star_shader->uniform1f(sCustomAlpha, color.mV[VW]);
}
else
{

View File

@@ -131,7 +131,7 @@ void LLViewerDynamicTexture::preRender(BOOL clear_depth)
llassert(mFullHeight <= 512);
llassert(mFullWidth <= 512);
if (gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete())
if (gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete() && !gGLManager.mIsATI)
{ //using offscreen render target, just use the bottom left corner
mOrigin.set(0, 0);
}
@@ -218,13 +218,12 @@ BOOL LLViewerDynamicTexture::updateAllInstances()
return TRUE;
}
#if 0 //THIS CAUSES MAINT-1092
bool use_fbo = gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete();
bool use_fbo = gGLManager.mHasFramebufferObject && gPipeline.mWaterDis.isComplete() && !gGLManager.mIsATI;
if (use_fbo)
{
gPipeline.mWaterDis.bindTarget();
}
#endif
LLGLSLShader::bindNoShader();
LLVertexBuffer::unbind();
@@ -259,12 +258,10 @@ BOOL LLViewerDynamicTexture::updateAllInstances()
}
}
#if 0 //THIS CAUSES MAINT-1092
if (use_fbo)
{
gPipeline.mWaterDis.flush();
}
#endif
return ret;
}

View File

@@ -60,6 +60,9 @@
#define LL_MAX_INDICES_COUNT 1000000
static LLStaticHashedString sTextureIndexIn("texture_index_in");
static LLStaticHashedString sColorIn("color_in");
BOOL LLFace::sSafeRenderSelect = TRUE; // FALSE
#define DOTVEC(a,b) (a.mV[0]*b.mV[0] + a.mV[1]*b.mV[1] + a.mV[2]*b.mV[2])
@@ -1186,6 +1189,21 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
}
// <FS:ND> The volume face vf can have more indices/vertices than this face. All striders below are aquired with a size of this face, but then written with num_verices/num_indices values,
// thus overflowing the buffer when vf holds more data.
// We can either clamp num_* down like here, or aquire all striders not using the face size, but the size if vf (that is swapping out mGeomCount with num_vertices and mIndicesCout with num_indices
// in all calls to nVertbuffer->get*Strider(...). Final solution is to just return FALSE and be done with it.
//
// The correct poison of choice is debatable, either copying not all data of vf (clamping) or writing more data than this face claims to have (aquiring bigger striders). Returning will not display this face at all.
//
// clamping it is for now.
num_vertices = llclamp( num_vertices, (S32)0, (S32)mGeomCount );
num_indices = llclamp( num_indices, (S32)0, (S32)mIndicesCount );
// </FS:ND>
//don't use map range (generates many redundant unmap calls)
bool map_range = false; //gGLManager.mHasMapBufferRange || gGLManager.mHasFlushBufferRange;
@@ -1414,7 +1432,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
vp[2] = 0;
vp[3] = 0;
gTransformPositionProgram.uniform1i("texture_index_in", val);
gTransformPositionProgram.uniform1i(sTextureIndexIn, val);
glBeginTransformFeedback(GL_POINTS);
buff->setBuffer(LLVertexBuffer::MAP_VERTEX);
@@ -1432,7 +1450,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
S32 val = *((S32*) color.mV);
gTransformColorProgram.uniform1i("color_in", val);
gTransformColorProgram.uniform1i(sColorIn, val);
glBeginTransformFeedback(GL_POINTS);
buff->setBuffer(LLVertexBuffer::MAP_VERTEX);
push_for_transform(buff, vf.mNumVertices, mGeomCount);
@@ -1453,7 +1471,7 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
(glow << 16) |
(glow << 24);
gTransformColorProgram.uniform1i("color_in", glow32);
gTransformColorProgram.uniform1i(sColorIn, glow32);
glBeginTransformFeedback(GL_POINTS);
buff->setBuffer(LLVertexBuffer::MAP_VERTEX);
push_for_transform(buff, vf.mNumVertices, mGeomCount);
@@ -1641,7 +1659,14 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
if (!do_xform)
{
LLFastTimer t(FTM_FACE_TEX_QUICK_NO_XFORM);
S32 tc_size = (num_vertices*2*sizeof(F32)+0xF) & ~0xF;
// <FS:ND> Don't round up, or there's high risk to write past buffer
// S32 tc_size = (num_vertices*2*sizeof(F32)+0xF) & ~0xF;
S32 tc_size = (num_vertices*2*sizeof(F32));
// </FS:ND>
LLVector4a::memcpyNonAliased16((F32*) tex_coords0.get(), (F32*) vf.mTexCoords, tc_size);
}
else

View File

@@ -1696,7 +1696,8 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal,
gGL.getModelviewMatrix().inverse().mult_vec_matrix(plane);
gClipProgram.uniform4fv("clip_plane", 1, plane.v);
static LLStaticHashedString sClipPlane("clip_plane");
gClipProgram.uniform4fv(sClipPlane, 1, plane.v);
BOOL particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES);
#if ENABLE_CLASSIC_CLOUDS

View File

@@ -3255,12 +3255,17 @@ void LLStartUp::loadInitialOutfit( const std::string& outfit_folder_name,
}
else
{
// FIXME SH-3860 - this creates a race condition, where COF
// changes (base outfit link added) after appearance update
// request has been submitted.
sWearablesLoadedCon = gAgentWearables.addLoadedCallback(LLStartUp::saveInitialOutfit);
bool do_copy = true;
bool do_append = false;
LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id);
LLAppearanceMgr::instance().wearInventoryCategory(cat, do_copy, do_append);
// Need to fetch cof contents before we can wear.
callAfterCategoryFetch(LLAppearanceMgr::instance().getCOF(),
boost::bind(&LLAppearanceMgr::wearInventoryCategory, LLAppearanceMgr::getInstance(), cat, do_copy, do_append));
lldebugs << "initial outfit category id: " << cat_id << llendl;
}

View File

@@ -869,6 +869,7 @@ void LLToolCompGun::draw()
}
else mTimerFOV.stop();
}
LLToolComposite::draw(); // Singu Note: We call parent here, instead of being clueless and adding to LLViewerWindow::draw for crosshairs and such
}
// </exodus>

View File

@@ -57,6 +57,13 @@
#define UNIFORM_ERRS LL_ERRS("Shader")
#endif
static LLStaticHashedString sTexture0("texture0");
static LLStaticHashedString sTexture1("texture1");
static LLStaticHashedString sTex0("tex0");
static LLStaticHashedString sTex1("tex1");
static LLStaticHashedString sGlowMap("glowMap");
static LLStaticHashedString sScreenMap("screenMap");
// Lots of STL stuff in here, using namespace std to keep things more readable
using std::vector;
using std::pair;
@@ -90,6 +97,8 @@ LLGLSLShader gTwoTextureAddProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gOneTextureNoColorProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gDebugProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gClipProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gDownsampleDepthProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gDownsampleDepthRectProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gAlphaMaskProgram(LLViewerShaderMgr::SHADER_INTERFACE);
LLGLSLShader gUIProgram(LLViewerShaderMgr::SHADER_INTERFACE);
@@ -241,47 +250,6 @@ void LLViewerShaderMgr::initAttribsAndUniforms(void)
if (mReservedAttribs.empty())
{
LLShaderMgr::initAttribsAndUniforms();
mAvatarUniforms.push_back("matrixPalette");
mAvatarUniforms.push_back("gWindDir");
mAvatarUniforms.push_back("gSinWaveParams");
mAvatarUniforms.push_back("gGravity");
mWLUniforms.push_back("camPosLocal");
mTerrainUniforms.reserve(5);
mTerrainUniforms.push_back("detail_0");
mTerrainUniforms.push_back("detail_1");
mTerrainUniforms.push_back("detail_2");
mTerrainUniforms.push_back("detail_3");
mTerrainUniforms.push_back("alpha_ramp");
mGlowUniforms.push_back("glowDelta");
mGlowUniforms.push_back("glowStrength");
mGlowExtractUniforms.push_back("minLuminance");
mGlowExtractUniforms.push_back("maxExtractAlpha");
mGlowExtractUniforms.push_back("lumWeights");
mGlowExtractUniforms.push_back("warmthWeights");
mGlowExtractUniforms.push_back("warmthAmount");
mShinyUniforms.push_back("origin");
mWaterUniforms.reserve(12);
mWaterUniforms.push_back("screenTex");
mWaterUniforms.push_back("screenDepth");
mWaterUniforms.push_back("refTex");
mWaterUniforms.push_back("eyeVec");
mWaterUniforms.push_back("time");
mWaterUniforms.push_back("d1");
mWaterUniforms.push_back("d2");
mWaterUniforms.push_back("lightDir");
mWaterUniforms.push_back("specular");
mWaterUniforms.push_back("lightExp");
mWaterUniforms.push_back("fogCol");
mWaterUniforms.push_back("kd");
mWaterUniforms.push_back("refScale");
mWaterUniforms.push_back("waterHeight");
}
}
@@ -331,11 +299,6 @@ void LLViewerShaderMgr::setShaders()
}
}
//setup preprocessor definitions
LLShaderMgr::instance()->mDefinitions.clear();
LLShaderMgr::instance()->mDefinitions["samples"] = llformat("%d", gSavedSettings.getU32("RenderFSAASamples"));
LLShaderMgr::instance()->mDefinitions["NUM_TEX_UNITS"] = llformat("%d", gGLManager.mNumTextureImageUnits);
initAttribsAndUniforms();
gPipeline.releaseGLBuffers();
@@ -724,7 +687,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders()
for (U32 i = 0; i < shaders.size(); i++)
{
// Note usage of GL_FRAGMENT_SHADER_ARB
if (loadShaderFile(shaders[i].first, shaders[i].second, GL_FRAGMENT_SHADER_ARB, index_channels[i]) == 0)
if (loadShaderFile(shaders[i].first, shaders[i].second, GL_FRAGMENT_SHADER_ARB, NULL, index_channels[i]) == 0)
{
return FALSE;
}
@@ -756,7 +719,7 @@ BOOL LLViewerShaderMgr::loadShadersEnvironment()
gTerrainProgram.mShaderFiles.push_back(make_pair("environment/terrainV.glsl", GL_VERTEX_SHADER_ARB));
gTerrainProgram.mShaderFiles.push_back(make_pair("environment/terrainF.glsl", GL_FRAGMENT_SHADER_ARB));
gTerrainProgram.mShaderLevel = mVertexShaderLevel[SHADER_ENVIRONMENT];
success = gTerrainProgram.createShader(NULL, &mTerrainUniforms);
success = gTerrainProgram.createShader(NULL, NULL);
}
if (!success)
@@ -792,7 +755,7 @@ BOOL LLViewerShaderMgr::loadShadersWater()
gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterV.glsl", GL_VERTEX_SHADER_ARB));
gWaterProgram.mShaderFiles.push_back(make_pair("environment/waterF.glsl", GL_FRAGMENT_SHADER_ARB));
gWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_WATER];
success = gWaterProgram.createShader(NULL, &mWaterUniforms);
success = gWaterProgram.createShader(NULL, NULL);
}
if (success)
@@ -806,7 +769,7 @@ BOOL LLViewerShaderMgr::loadShadersWater()
gUnderWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_WATER];
gUnderWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
success = gUnderWaterProgram.createShader(NULL, &mWaterUniforms);
success = gUnderWaterProgram.createShader(NULL, NULL);
}
if (success)
@@ -824,7 +787,7 @@ BOOL LLViewerShaderMgr::loadShadersWater()
gTerrainWaterProgram.mShaderFiles.push_back(make_pair("environment/terrainWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
gTerrainWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_ENVIRONMENT];
gTerrainWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
terrainWaterSuccess = gTerrainWaterProgram.createShader(NULL, &mTerrainUniforms);
terrainWaterSuccess = gTerrainWaterProgram.createShader(NULL, NULL);
}
/// Keep track of water shader levels
@@ -872,7 +835,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
gGlowProgram.mShaderFiles.push_back(make_pair("effects/glowV.glsl", GL_VERTEX_SHADER_ARB));
gGlowProgram.mShaderFiles.push_back(make_pair("effects/glowF.glsl", GL_FRAGMENT_SHADER_ARB));
gGlowProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT];
success = gGlowProgram.createShader(NULL, &mGlowUniforms);
success = gGlowProgram.createShader(NULL, NULL);
LLPipeline::sRenderGlow = success;
}
@@ -883,7 +846,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
gGlowExtractProgram.mShaderFiles.push_back(make_pair("effects/glowExtractV.glsl", GL_VERTEX_SHADER_ARB));
gGlowExtractProgram.mShaderFiles.push_back(make_pair("effects/glowExtractF.glsl", GL_FRAGMENT_SHADER_ARB));
gGlowExtractProgram.mShaderLevel = mVertexShaderLevel[SHADER_EFFECT];
success = gGlowExtractProgram.createShader(NULL, &mGlowExtractUniforms);
success = gGlowExtractProgram.createShader(NULL, NULL);
LLPipeline::sRenderGlow = success;
}
}
@@ -895,13 +858,16 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
//load Color Filter Shader
//if (success)
{
vector<string> shaderUniforms;
shaderUniforms.reserve(6);
shaderUniforms.push_back("gamma");
shaderUniforms.push_back("brightness");
shaderUniforms.push_back("contrast");
shaderUniforms.push_back("contrastBase");
shaderUniforms.push_back("saturation");
static std::vector<LLStaticHashedString> shaderUniforms;
if(shaderUniforms.empty())
{
shaderUniforms.reserve(6);
shaderUniforms.push_back(LLStaticHashedString("gamma"));
shaderUniforms.push_back(LLStaticHashedString("brightness"));
shaderUniforms.push_back(LLStaticHashedString("contrast"));
shaderUniforms.push_back(LLStaticHashedString("contrastBase"));
shaderUniforms.push_back(LLStaticHashedString("saturation"));
}
gPostColorFilterProgram.mName = "Color Filter Shader (Post)";
gPostColorFilterProgram.mShaderFiles.clear();
@@ -911,18 +877,20 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
if(gPostColorFilterProgram.createShader(NULL, &shaderUniforms))
{
gPostColorFilterProgram.bind();
gPostColorFilterProgram.uniform1i("tex0", 0);
gPostColorFilterProgram.uniform1i(sTex0, 0);
}
}
//load Night Vision Shader
//if (success)
{
vector<string> shaderUniforms;
shaderUniforms.reserve(3);
shaderUniforms.push_back("brightMult");
shaderUniforms.push_back("noiseStrength");
static std::vector<LLStaticHashedString> shaderUniforms;
if(shaderUniforms.empty())
{
shaderUniforms.reserve(3);
shaderUniforms.push_back(LLStaticHashedString("brightMult"));
shaderUniforms.push_back(LLStaticHashedString("noiseStrength"));
}
gPostNightVisionProgram.mName = "Night Vision Shader (Post)";
gPostNightVisionProgram.mShaderFiles.clear();
gPostNightVisionProgram.mShaderFiles.push_back(make_pair("effects/nightVisionF.glsl", GL_FRAGMENT_SHADER_ARB));
@@ -931,16 +899,19 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
if(gPostNightVisionProgram.createShader(NULL, &shaderUniforms))
{
gPostNightVisionProgram.bind();
gPostNightVisionProgram.uniform1i("tex0", 0);
gPostNightVisionProgram.uniform1i("tex1", 1);
gPostNightVisionProgram.uniform1i(sTex0, 0);
gPostNightVisionProgram.uniform1i(sTex1, 1);
}
}
//if (success)
{
vector<string> shaderUniforms;
shaderUniforms.reserve(1);
shaderUniforms.push_back("horizontalPass");
static std::vector<LLStaticHashedString> shaderUniforms;
if(shaderUniforms.empty())
{
shaderUniforms.reserve(1);
shaderUniforms.push_back(LLStaticHashedString("horizontalPass"));
}
gPostGaussianBlurProgram.mName = "Gaussian Blur Shader (Post)";
gPostGaussianBlurProgram.mShaderFiles.clear();
@@ -950,14 +921,17 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
if(gPostGaussianBlurProgram.createShader(NULL, &shaderUniforms))
{
gPostGaussianBlurProgram.bind();
gPostGaussianBlurProgram.uniform1i("tex0", 0);
gPostGaussianBlurProgram.uniform1i(sTex0, 0);
}
}
{
vector<string> shaderUniforms;
shaderUniforms.reserve(1);
shaderUniforms.push_back("layerCount");
static std::vector<LLStaticHashedString> shaderUniforms;
if(shaderUniforms.empty())
{
shaderUniforms.reserve(1);
shaderUniforms.push_back(LLStaticHashedString("layerCount"));
}
gPostPosterizeProgram.mName = "Posterize Shader (Post)";
gPostPosterizeProgram.mShaderFiles.clear();
@@ -967,16 +941,19 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
if(gPostPosterizeProgram.createShader(NULL, &shaderUniforms))
{
gPostPosterizeProgram.bind();
gPostPosterizeProgram.uniform1i("tex0", 0);
gPostPosterizeProgram.uniform1i(sTex0, 0);
}
}
{
vector<string> shaderUniforms;
shaderUniforms.reserve(3);
shaderUniforms.push_back("inv_proj");
shaderUniforms.push_back("prev_proj");
shaderUniforms.push_back("screen_res");
static std::vector<LLStaticHashedString> shaderUniforms;
if(shaderUniforms.empty())
{
shaderUniforms.reserve(3);
shaderUniforms.push_back(LLStaticHashedString("inv_proj"));
shaderUniforms.push_back(LLStaticHashedString("prev_proj"));
shaderUniforms.push_back(LLStaticHashedString("screen_res"));
}
gPostMotionBlurProgram.mName = "Motion Blur Shader (Post)";
gPostMotionBlurProgram.mShaderFiles.clear();
@@ -986,17 +963,20 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
if(gPostMotionBlurProgram.createShader(NULL, &shaderUniforms))
{
gPostMotionBlurProgram.bind();
gPostMotionBlurProgram.uniform1i("tex0", 0);
gPostMotionBlurProgram.uniform1i("tex1", 1);
gPostMotionBlurProgram.uniform1i(sTex0, 0);
gPostMotionBlurProgram.uniform1i(sTex1, 1);
}
}
{
vector<string> shaderUniforms;
shaderUniforms.reserve(3);
shaderUniforms.push_back("vignette_darkness");
shaderUniforms.push_back("vignette_radius");
shaderUniforms.push_back("screen_res");
static std::vector<LLStaticHashedString> shaderUniforms;
if(shaderUniforms.empty())
{
shaderUniforms.reserve(3);
shaderUniforms.push_back(LLStaticHashedString("vignette_darkness"));
shaderUniforms.push_back(LLStaticHashedString("vignette_radius"));
shaderUniforms.push_back(LLStaticHashedString("screen_res"));
}
gPostVignetteProgram.mName = "Vignette Shader (Post)";
gPostVignetteProgram.mShaderFiles.clear();
@@ -1006,7 +986,7 @@ BOOL LLViewerShaderMgr::loadShadersEffects()
if(gPostVignetteProgram.createShader(NULL, &shaderUniforms))
{
gPostVignetteProgram.bind();
gPostVignetteProgram.uniform1i("tex0", 0);
gPostVignetteProgram.uniform1i(sTex0, 0);
}
}
@@ -1314,7 +1294,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredWaterProgram.mShaderFiles.push_back(make_pair("deferred/waterF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredWaterProgram.createShader(NULL, &mWaterUniforms);
success = gDeferredWaterProgram.createShader(NULL, NULL);
}
if (success)
@@ -1373,7 +1353,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAvatarShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarShadowF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredAvatarShadowProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredAvatarShadowProgram.createShader(NULL, &mAvatarUniforms);
success = gDeferredAvatarShadowProgram.createShader(NULL, NULL);
}
if (success)
@@ -1394,7 +1374,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredTerrainProgram.mShaderFiles.push_back(make_pair("deferred/terrainF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredTerrainProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredTerrainProgram.createShader(NULL, &mTerrainUniforms);
success = gDeferredTerrainProgram.createShader(NULL, NULL);
}
if (success)
@@ -1405,7 +1385,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarProgram.mShaderFiles.push_back(make_pair("deferred/avatarV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredAvatarProgram.mShaderFiles.push_back(make_pair("deferred/avatarF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredAvatarProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredAvatarProgram.createShader(NULL, &mAvatarUniforms);
success = gDeferredAvatarProgram.createShader(NULL, NULL);
}
if (success)
@@ -1425,7 +1405,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedNoColorF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredAvatarAlphaProgram.createShader(NULL, &mAvatarUniforms);
success = gDeferredAvatarAlphaProgram.createShader(NULL, NULL);
gDeferredAvatarAlphaProgram.mFeatures.calculatesLighting = true;
gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true;
@@ -1490,7 +1470,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
gDeferredWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gDeferredWLSkyProgram.createShader(NULL, &mWLUniforms);
success = gDeferredWLSkyProgram.createShader(NULL, NULL);
}
if (success)
@@ -1501,14 +1481,19 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gDeferredWLCloudProgram.createShader(NULL, &mWLUniforms);
success = gDeferredWLCloudProgram.createShader(NULL, NULL);
}
if (success)
{
gDeferredStarProgram.mName = "Deferred Star Program";
vector<string> shaderUniforms(mWLUniforms);
shaderUniforms.push_back("custom_alpha");
static std::vector<LLStaticHashedString> shaderUniforms;
static bool bUniformsInitted = false;
if(!bUniformsInitted)
{
bUniformsInitted = true;
shaderUniforms.push_back(LLStaticHashedString("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));
@@ -1819,7 +1804,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB));
gObjectShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB));
gObjectShinyNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
success = gObjectShinyNonIndexedProgram.createShader(NULL, &mShinyUniforms);
success = gObjectShinyNonIndexedProgram.createShader(NULL, NULL);
}
if (success)
@@ -1836,7 +1821,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB));
gObjectShinyNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
gObjectShinyNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
success = gObjectShinyNonIndexedWaterProgram.createShader(NULL, &mShinyUniforms);
success = gObjectShinyNonIndexedWaterProgram.createShader(NULL, NULL);
}
if (success)
@@ -1852,7 +1837,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectFullbrightShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB));
gObjectFullbrightShinyNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB));
gObjectFullbrightShinyNonIndexedProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
success = gObjectFullbrightShinyNonIndexedProgram.createShader(NULL, &mShinyUniforms);
success = gObjectFullbrightShinyNonIndexedProgram.createShader(NULL, NULL);
}
if (success)
@@ -1870,7 +1855,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectFullbrightShinyNonIndexedWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
gObjectFullbrightShinyNonIndexedWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
gObjectFullbrightShinyNonIndexedWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
success = gObjectFullbrightShinyNonIndexedWaterProgram.createShader(NULL, &mShinyUniforms);
success = gObjectFullbrightShinyNonIndexedWaterProgram.createShader(NULL, NULL);
}
if (success)
@@ -1949,12 +1934,11 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectBumpProgram.mShaderFiles.push_back(make_pair("objects/bumpF.glsl", GL_FRAGMENT_SHADER_ARB));
gObjectBumpProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
success = gObjectBumpProgram.createShader(NULL, NULL);
if (success)
{ //lldrawpoolbump assumes "texture0" has channel 0 and "texture1" has channel 1
gObjectBumpProgram.bind();
gObjectBumpProgram.uniform1i("texture0", 0);
gObjectBumpProgram.uniform1i("texture1", 1);
gObjectBumpProgram.uniform1i(sTexture0, 0);
gObjectBumpProgram.uniform1i(sTexture1, 1);
gObjectBumpProgram.unbind();
}
}
@@ -2103,7 +2087,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectShinyProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB));
gObjectShinyProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB));
gObjectShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
success = gObjectShinyProgram.createShader(NULL, &mShinyUniforms);
success = gObjectShinyProgram.createShader(NULL, NULL);
}
if (success)
@@ -2120,7 +2104,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyV.glsl", GL_VERTEX_SHADER_ARB));
gObjectShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
gObjectShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
success = gObjectShinyWaterProgram.createShader(NULL, &mShinyUniforms);
success = gObjectShinyWaterProgram.createShader(NULL, NULL);
}
if (success)
@@ -2136,7 +2120,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyV.glsl", GL_VERTEX_SHADER_ARB));
gObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB));
gObjectFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
success = gObjectFullbrightShinyProgram.createShader(NULL, &mShinyUniforms);
success = gObjectFullbrightShinyProgram.createShader(NULL, NULL);
}
if (success)
@@ -2154,7 +2138,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
gObjectFullbrightShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
gObjectFullbrightShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
success = gObjectFullbrightShinyWaterProgram.createShader(NULL, &mShinyUniforms);
success = gObjectFullbrightShinyWaterProgram.createShader(NULL, NULL);
}
if (mVertexShaderLevel[SHADER_AVATAR] > 0)
@@ -2168,6 +2152,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gSkinnedObjectSimpleProgram.mFeatures.hasAtmospherics = true;
gSkinnedObjectSimpleProgram.mFeatures.hasLighting = true;
gSkinnedObjectSimpleProgram.mFeatures.hasObjectSkinning = true;
gSkinnedObjectSimpleProgram.mFeatures.hasAlphaMask = true;
gSkinnedObjectSimpleProgram.mFeatures.disableTextureIndex = true;
gSkinnedObjectSimpleProgram.mShaderFiles.clear();
gSkinnedObjectSimpleProgram.mShaderFiles.push_back(make_pair("objects/simpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
@@ -2184,6 +2169,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gSkinnedObjectFullbrightProgram.mFeatures.hasTransport = true;
gSkinnedObjectFullbrightProgram.mFeatures.isFullbright = true;
gSkinnedObjectFullbrightProgram.mFeatures.hasObjectSkinning = true;
gSkinnedObjectFullbrightProgram.mFeatures.hasAlphaMask = true;
gSkinnedObjectFullbrightProgram.mFeatures.disableTextureIndex = true;
gSkinnedObjectFullbrightProgram.mShaderFiles.clear();
gSkinnedObjectFullbrightProgram.mShaderFiles.push_back(make_pair("objects/fullbrightSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
@@ -2234,12 +2220,13 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gSkinnedObjectFullbrightShinyProgram.mFeatures.isShiny = true;
gSkinnedObjectFullbrightShinyProgram.mFeatures.isFullbright = true;
gSkinnedObjectFullbrightShinyProgram.mFeatures.hasObjectSkinning = true;
gSkinnedObjectFullbrightShinyProgram.mFeatures.hasAlphaMask = true;
gSkinnedObjectFullbrightShinyProgram.mFeatures.disableTextureIndex = true;
gSkinnedObjectFullbrightShinyProgram.mShaderFiles.clear();
gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB));
gSkinnedObjectFullbrightShinyProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyF.glsl", GL_FRAGMENT_SHADER_ARB));
gSkinnedObjectFullbrightShinyProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
success = gSkinnedObjectFullbrightShinyProgram.createShader(NULL, &mShinyUniforms);
success = gSkinnedObjectFullbrightShinyProgram.createShader(NULL, NULL);
}
if (success)
@@ -2250,13 +2237,14 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gSkinnedObjectShinySimpleProgram.mFeatures.hasGamma = true;
gSkinnedObjectShinySimpleProgram.mFeatures.hasAtmospherics = true;
gSkinnedObjectShinySimpleProgram.mFeatures.hasObjectSkinning = true;
gSkinnedObjectShinySimpleProgram.mFeatures.hasAlphaMask = true;
gSkinnedObjectShinySimpleProgram.mFeatures.isShiny = true;
gSkinnedObjectShinySimpleProgram.mFeatures.disableTextureIndex = true;
gSkinnedObjectShinySimpleProgram.mShaderFiles.clear();
gSkinnedObjectShinySimpleProgram.mShaderFiles.push_back(make_pair("objects/shinySimpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
gSkinnedObjectShinySimpleProgram.mShaderFiles.push_back(make_pair("objects/shinyF.glsl", GL_FRAGMENT_SHADER_ARB));
gSkinnedObjectShinySimpleProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
success = gSkinnedObjectShinySimpleProgram.createShader(NULL, &mShinyUniforms);
success = gSkinnedObjectShinySimpleProgram.createShader(NULL, NULL);
}
if (success)
@@ -2287,6 +2275,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gSkinnedObjectFullbrightWaterProgram.mFeatures.hasTransport = true;
gSkinnedObjectFullbrightWaterProgram.mFeatures.isFullbright = true;
gSkinnedObjectFullbrightWaterProgram.mFeatures.hasObjectSkinning = true;
gSkinnedObjectFullbrightWaterProgram.mFeatures.hasAlphaMask = true;
gSkinnedObjectFullbrightWaterProgram.mFeatures.hasWaterFog = true;
gSkinnedObjectFullbrightWaterProgram.mFeatures.disableTextureIndex = true;
gSkinnedObjectFullbrightWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
@@ -2306,6 +2295,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.isShiny = true;
gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.isFullbright = true;
gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasObjectSkinning = true;
gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasAlphaMask = true;
gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.hasWaterFog = true;
gSkinnedObjectFullbrightShinyWaterProgram.mFeatures.disableTextureIndex = true;
gSkinnedObjectFullbrightShinyWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
@@ -2313,7 +2303,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinySkinnedV.glsl", GL_VERTEX_SHADER_ARB));
gSkinnedObjectFullbrightShinyWaterProgram.mShaderFiles.push_back(make_pair("objects/fullbrightShinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
gSkinnedObjectFullbrightShinyWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
success = gSkinnedObjectFullbrightShinyWaterProgram.createShader(NULL, &mShinyUniforms);
success = gSkinnedObjectFullbrightShinyWaterProgram.createShader(NULL, NULL);
}
if (success)
@@ -2324,6 +2314,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasGamma = true;
gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasAtmospherics = true;
gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasObjectSkinning = true;
gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasAlphaMask = true;
gSkinnedObjectShinySimpleWaterProgram.mFeatures.isShiny = true;
gSkinnedObjectShinySimpleWaterProgram.mFeatures.hasWaterFog = true;
gSkinnedObjectShinySimpleWaterProgram.mFeatures.disableTextureIndex = true;
@@ -2332,7 +2323,7 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/shinySimpleSkinnedV.glsl", GL_VERTEX_SHADER_ARB));
gSkinnedObjectShinySimpleWaterProgram.mShaderFiles.push_back(make_pair("objects/shinyWaterF.glsl", GL_FRAGMENT_SHADER_ARB));
gSkinnedObjectShinySimpleWaterProgram.mShaderLevel = mVertexShaderLevel[SHADER_OBJECT];
success = gSkinnedObjectShinySimpleWaterProgram.createShader(NULL, &mShinyUniforms);
success = gSkinnedObjectShinySimpleWaterProgram.createShader(NULL, NULL);
}
}
@@ -2370,7 +2361,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar()
gAvatarProgram.mShaderFiles.push_back(make_pair("avatar/avatarV.glsl", GL_VERTEX_SHADER_ARB));
gAvatarProgram.mShaderFiles.push_back(make_pair("avatar/avatarF.glsl", GL_FRAGMENT_SHADER_ARB));
gAvatarProgram.mShaderLevel = mVertexShaderLevel[SHADER_AVATAR];
success = gAvatarProgram.createShader(NULL, &mAvatarUniforms);
success = gAvatarProgram.createShader(NULL, NULL);
if (success)
{
@@ -2389,7 +2380,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar()
// Note: no cloth under water:
gAvatarWaterProgram.mShaderLevel = llmin(mVertexShaderLevel[SHADER_AVATAR], 1);
gAvatarWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER;
success = gAvatarWaterProgram.createShader(NULL, &mAvatarUniforms);
success = gAvatarWaterProgram.createShader(NULL, NULL);
}
/// Keep track of avatar levels
@@ -2408,7 +2399,7 @@ BOOL LLViewerShaderMgr::loadShadersAvatar()
gAvatarPickProgram.mShaderFiles.push_back(make_pair("avatar/pickAvatarV.glsl", GL_VERTEX_SHADER_ARB));
gAvatarPickProgram.mShaderFiles.push_back(make_pair("avatar/pickAvatarF.glsl", GL_FRAGMENT_SHADER_ARB));
gAvatarPickProgram.mShaderLevel = mVertexShaderLevel[SHADER_AVATAR];
success = gAvatarPickProgram.createShader(NULL, &mAvatarUniforms);
success = gAvatarPickProgram.createShader(NULL, NULL);
}
if (success)
@@ -2490,7 +2481,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
if (success)
{
gSplatTextureRectProgram.bind();
gSplatTextureRectProgram.uniform1i("screenMap", 0);
gSplatTextureRectProgram.uniform1i(sScreenMap, 0);
gSplatTextureRectProgram.unbind();
}
}
@@ -2506,8 +2497,8 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
if (success)
{
gGlowCombineProgram.bind();
gGlowCombineProgram.uniform1i("glowMap", 0);
gGlowCombineProgram.uniform1i("screenMap", 1);
gGlowCombineProgram.uniform1i(sGlowMap, 0);
gGlowCombineProgram.uniform1i(sScreenMap, 1);
gGlowCombineProgram.unbind();
}
}
@@ -2523,8 +2514,8 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
if (success)
{
gGlowCombineFXAAProgram.bind();
gGlowCombineFXAAProgram.uniform1i("glowMap", 0);
gGlowCombineFXAAProgram.uniform1i("screenMap", 1);
gGlowCombineFXAAProgram.uniform1i(sGlowMap, 0);
gGlowCombineFXAAProgram.uniform1i(sScreenMap, 1);
gGlowCombineFXAAProgram.unbind();
}
}
@@ -2541,8 +2532,8 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
if (success)
{
gTwoTextureAddProgram.bind();
gTwoTextureAddProgram.uniform1i("tex0", 0);
gTwoTextureAddProgram.uniform1i("tex1", 1);
gTwoTextureAddProgram.uniform1i(sTex0, 0);
gTwoTextureAddProgram.uniform1i(sTex1, 1);
}
}
@@ -2557,7 +2548,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
if (success)
{
gOneTextureNoColorProgram.bind();
gOneTextureNoColorProgram.uniform1i("tex0", 0);
gOneTextureNoColorProgram.uniform1i(sTex0, 0);
}
}
@@ -2577,7 +2568,7 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
if (success)
{
gSolidColorProgram.bind();
gSolidColorProgram.uniform1i("tex0", 0);
gSolidColorProgram.uniform1i(sTex0, 0);
gSolidColorProgram.unbind();
}
}
@@ -2622,6 +2613,26 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
success = gClipProgram.createShader(NULL, NULL);
}
if (success)
{
gDownsampleDepthProgram.mName = "DownsampleDepth Shader";
gDownsampleDepthProgram.mShaderFiles.clear();
gDownsampleDepthProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthV.glsl", GL_VERTEX_SHADER_ARB));
gDownsampleDepthProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthF.glsl", GL_FRAGMENT_SHADER_ARB));
gDownsampleDepthProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
success = gDownsampleDepthProgram.createShader(NULL, NULL);
}
if (success)
{
gDownsampleDepthRectProgram.mName = "DownsampleDepthRect Shader";
gDownsampleDepthRectProgram.mShaderFiles.clear();
gDownsampleDepthRectProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthV.glsl", GL_VERTEX_SHADER_ARB));
gDownsampleDepthRectProgram.mShaderFiles.push_back(make_pair("interface/downsampleDepthRectF.glsl", GL_FRAGMENT_SHADER_ARB));
gDownsampleDepthRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
success = gDownsampleDepthRectProgram.createShader(NULL, NULL);
}
if (success)
{
gAlphaMaskProgram.mName = "Alpha Mask Shader";
@@ -2660,7 +2671,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()
gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyF.glsl", GL_FRAGMENT_SHADER_ARB));
gWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT];
gWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gWLSkyProgram.createShader(NULL, &mWLUniforms);
success = gWLSkyProgram.createShader(NULL, NULL);
}
if (success)
@@ -2672,7 +2683,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight()
gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB));
gWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT];
gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY;
success = gWLCloudProgram.createShader(NULL, &mWLUniforms);
success = gWLCloudProgram.createShader(NULL, NULL);
}
return success;

View File

@@ -80,57 +80,6 @@ public:
SHADER_COUNT
};
typedef enum
{
SHINY_ORIGIN = END_RESERVED_UNIFORMS
} eShinyUniforms;
typedef enum
{
WATER_SCREENTEX = END_RESERVED_UNIFORMS,
WATER_SCREENDEPTH,
WATER_REFTEX,
WATER_EYEVEC,
WATER_TIME,
WATER_WAVE_DIR1,
WATER_WAVE_DIR2,
WATER_LIGHT_DIR,
WATER_SPECULAR,
WATER_SPECULAR_EXP,
WATER_FOGCOLOR,
WATER_FOGDENSITY,
WATER_REFSCALE,
WATER_WATERHEIGHT,
} eWaterUniforms;
typedef enum
{
WL_CAMPOSLOCAL = END_RESERVED_UNIFORMS,
WL_WATERHEIGHT
} eWLUniforms;
typedef enum
{
TERRAIN_DETAIL0 = END_RESERVED_UNIFORMS,
TERRAIN_DETAIL1,
TERRAIN_DETAIL2,
TERRAIN_DETAIL3,
TERRAIN_ALPHARAMP
} eTerrainUniforms;
typedef enum
{
GLOW_DELTA = END_RESERVED_UNIFORMS
} eGlowUniforms;
typedef enum
{
AVATAR_MATRIX = END_RESERVED_UNIFORMS,
AVATAR_WIND,
AVATAR_SINWAVE,
AVATAR_GRAVITY,
} eAvatarUniforms;
// simple model of forward iterator
// http://www.sgi.com/tech/stl/ForwardIterator.html
class shader_iter
@@ -235,6 +184,7 @@ extern LLGLSLShader gTransformTexCoordProgram;
extern LLGLSLShader gTransformNormalProgram;
extern LLGLSLShader gTransformColorProgram;
extern LLGLSLShader gTransformTangentProgram;
//utility shaders
extern LLGLSLShader gOcclusionProgram;
extern LLGLSLShader gOcclusionCubeProgram;
@@ -244,6 +194,8 @@ extern LLGLSLShader gSplatTextureRectProgram;
extern LLGLSLShader gGlowCombineFXAAProgram;
extern LLGLSLShader gDebugProgram;
extern LLGLSLShader gClipProgram;
extern LLGLSLShader gDownsampleDepthProgram;
extern LLGLSLShader gDownsampleDepthRectProgram;
//output tex0[tc0] + tex1[tc1]
extern LLGLSLShader gTwoTextureAddProgram;

View File

@@ -1208,7 +1208,12 @@ void LLViewerFetchedTexture::addToCreateTexture()
destroyRawImage();
return ;
}
mRawImage->scale(w >> i, h >> i) ;
{
//make a duplicate in case somebody else is using this raw image
mRawImage = mRawImage->duplicate();
mRawImage->scale(w >> i, h >> i) ;
}
}
}
}
@@ -2540,7 +2545,11 @@ void LLViewerFetchedTexture::setCachedRawImage()
mIsRawImageValid = 0;
return;
}
mRawImage->scale(w >> i, h >> i) ;
{
//make a duplicate in case somebody else is using this raw image
mRawImage = mRawImage->duplicate();
mRawImage->scale(w >> i, h >> i) ;
}
}
if(mCachedRawImage.notNull())
mCachedRawImage->setInCache(false);

View File

@@ -6442,8 +6442,6 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
if (attachment->isObjectAttached(viewer_object))
{
cleanupAttachedMesh( viewer_object );
attachment->removeObject(viewer_object);
std::vector<std::pair<LLViewerObject*,LLViewerJointAttachment*> >::iterator it = std::find(mAttachedObjectsVector.begin(),mAttachedObjectsVector.end(),std::make_pair(viewer_object,attachment));
if(it != mAttachedObjectsVector.end())
{
@@ -6451,6 +6449,8 @@ BOOL LLVOAvatar::detachObject(LLViewerObject *viewer_object)
mAttachedObjectsVector.pop_back();
}
cleanupAttachedMesh( viewer_object );
attachment->removeObject(viewer_object);
lldebugs << "Detaching object " << viewer_object->mID << " from " << attachment->getName() << llendl;
return TRUE;
}

View File

@@ -4733,7 +4733,14 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
if (is_rigged)
{
drawablep->setState(LLDrawable::RIGGED);
if (!drawablep->isState(LLDrawable::RIGGED))
{
drawablep->setState(LLDrawable::RIGGED);
//first time this is drawable is being marked as rigged,
// do another LoD update to use avatar bounding box
vobj->updateLOD();
}
}
else
{

View File

@@ -320,12 +320,12 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader)
if (shader->mShaderGroup == LLGLSLShader::SG_WATER)
{
shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLWLParamManager::getInstance()->getRotatedLightDir().mV);
shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV);
shader->uniform4fv("waterFogColor", 1, LLDrawPoolWater::sWaterFogColor.mV);
shader->uniform4fv("waterPlane", 1, mWaterPlane.mV);
shader->uniform1f("waterFogDensity", getFogDensity());
shader->uniform1f("waterFogKS", mWaterFogKS);
shader->uniform1f("distance_multiplier", 0);
shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV);
shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, LLDrawPoolWater::sWaterFogColor.mV);
shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, mWaterPlane.mV);
shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, getFogDensity());
shader->uniform1f(LLShaderMgr::WATER_FOGKS, mWaterFogKS);
shader->uniform1f(LLViewerShaderMgr::DISTANCE_MULTIPLIER, 0);
}
}

View File

@@ -373,8 +373,8 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader)
if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT)
{
shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mRotatedLightDir.mV);
shader->uniform3fv("camPosLocal", 1, LLViewerCamera::getInstance()->getOrigin().mV);
shader->uniform4fv(LLShaderMgr::LIGHTNORM, 1, mRotatedLightDir.mV);
shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV);
}
else if (shader->mShaderGroup == LLGLSLShader::SG_SKY)
@@ -382,7 +382,7 @@ void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader)
shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDir.mV);
}
shader->uniform1f("scene_light_strength", mSceneLightStrength);
shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, mSceneLightStrength);
}

View File

@@ -44,6 +44,22 @@
#include <sstream>
static LLStaticHashedString sStarBrightness("star_brightness");
static LLStaticHashedString sPresetNum("preset_num");
static LLStaticHashedString sSunAngle("sun_angle");
static LLStaticHashedString sEastAngle("east_angle");
static LLStaticHashedString sEnableCloudScroll("enable_cloud_scroll");
static LLStaticHashedString sCloudScrollRate("cloud_scroll_rate");
static LLStaticHashedString sLightNorm("lightnorm");
static LLStaticHashedString sCloudDensity("cloud_pos_density1");
static LLStaticHashedString sCloudScale("cloud_scale");
static LLStaticHashedString sCloudShadow("cloud_shadow");
static LLStaticHashedString sDensityMultiplier("density_multiplier");
static LLStaticHashedString sDistanceMultiplier("distance_multiplier");
static LLStaticHashedString sHazeDensity("haze_density");
static LLStaticHashedString sHazeHorizon("haze_horizon");
static LLStaticHashedString sMaxY("max_y");
LLWLParamSet::LLWLParamSet(void) :
mName("Unnamed Preset"),
mCloudScrollXOffset(0.f), mCloudScrollYOffset(0.f)
@@ -54,21 +70,24 @@ static LLFastTimer::DeclareTimer FTM_WL_PARAM_UPDATE("WL Param Update");
void LLWLParamSet::update(LLGLSLShader * shader) const
{
LLFastTimer t(FTM_WL_PARAM_UPDATE);
for(LLSD::map_const_iterator i = mParamValues.beginMap();
i != mParamValues.endMap();
++i)
LLSD::map_const_iterator i = mParamValues.beginMap();
std::vector<LLStaticHashedString>::const_iterator n = mParamHashedNames.begin();
for(;(i != mParamValues.endMap()) && (n != mParamHashedNames.end());++i, n++)
{
const std::string& param = i->first;
const LLStaticHashedString& param = *n;
if( param == "star_brightness" || param == "preset_num" || param == "sun_angle" ||
param == "east_angle" || param == "enable_cloud_scroll" ||
param == "cloud_scroll_rate" || param == "lightnorm" )
// check that our pre-hashed names are still tracking the mParamValues map correctly
//
llassert(param.String() == i->first);
if (param == sStarBrightness || param == sPresetNum || param == sSunAngle ||
param == sEastAngle || param == sEnableCloudScroll ||
param == sCloudScrollRate || param == sLightNorm )
{
continue;
}
if(param == "cloud_pos_density1")
if (param == sCloudDensity)
{
LLVector4 val;
val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset;
@@ -80,10 +99,10 @@ void LLWLParamSet::update(LLGLSLShader * shader) const
shader->uniform4fv(param, 1, val.mV);
stop_glerror();
}
else if (param == "cloud_scale" || param == "cloud_shadow" ||
param == "density_multiplier" || param == "distance_multiplier" ||
param == "haze_density" || param == "haze_horizon" ||
param == "max_y" )
else if (param == sCloudScale || param == sCloudShadow ||
param == sDensityMultiplier || param == sDistanceMultiplier ||
param == sHazeDensity || param == sHazeHorizon ||
param == sMaxY )
{
F32 val = (F32) i->second[0].asReal();
@@ -384,3 +403,14 @@ void LLWLParamSet::updateCloudScrolling(void)
mCloudScrollYOffset += F32(delta_t * (getCloudScrollY() - 10.f) / 100.f);
}
}
void LLWLParamSet::updateHashedNames()
{
mParamHashedNames.clear();
// Iterate through values
for(LLSD::map_iterator iter = mParamValues.beginMap(); iter != mParamValues.endMap(); ++iter)
{
mParamHashedNames.push_back(LLStaticHashedString(iter->first));
}
}

View File

@@ -38,6 +38,7 @@
#include "v4math.h"
#include "v4color.h"
#include "llstaticstringtable.h"
class LLWLParamSet;
class LLGLSLShader;
@@ -54,9 +55,12 @@ public:
private:
LLSD mParamValues;
std::vector<LLStaticHashedString> mParamHashedNames;
float mCloudScrollXOffset, mCloudScrollYOffset;
void updateHashedNames();
public:
LLWLParamSet();
@@ -184,6 +188,8 @@ inline void LLWLParamSet::setAll(const LLSD& val)
if(val.isMap()) {
mParamValues = val;
}
updateHashedNames();
}
inline const LLSD& LLWLParamSet::getAll()

View File

@@ -204,6 +204,12 @@ LLFastTimer::DeclareTimer FTM_RENDER_DEFERRED("Deferred Shading");
static LLFastTimer::DeclareTimer FTM_STATESORT_DRAWABLE("Sort Drawables");
static LLFastTimer::DeclareTimer FTM_STATESORT_POSTSORT("Post Sort");
static LLStaticHashedString sNormMat("norm_mat");
static LLStaticHashedString sOffset("offset");
static LLStaticHashedString sDelta("delta");
static LLStaticHashedString sDistFactor("dist_factor");
static LLStaticHashedString sKern("kern");
static LLStaticHashedString sKernScale("kern_scale");
//----------------------------------------
std::string gPoolNames[] =
{
@@ -768,10 +774,12 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
BOOL RenderDepthOfField = gSavedSettings.getBOOL("RenderDepthOfField");
static const LLCachedControl<F32> RenderShadowResolutionScale("RenderShadowResolutionScale",1.0f);
const U32 occlusion_divisor = 3;
//allocate deferred rendering color buffers
if (!mDeferredScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!mOcclusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if (!addDeferredAttachments(mDeferredScreen)) return false;
if (!mScreen.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
@@ -801,6 +809,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
for (U32 i = 0; i < 4; i++)
{
if (!mShadow[i].allocate(sun_shadow_map_width,U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false;
if (!mShadowOcclusion[i].allocate(mShadow[i].getWidth()/occlusion_divisor, mShadow[i].getHeight()/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE)) return false;
}
}
else
@@ -808,6 +817,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
for (U32 i = 0; i < 4; i++)
{
mShadow[i].release();
mShadowOcclusion[i].release();
}
}
@@ -820,6 +830,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
for (U32 i = 4; i < 6; i++)
{
if (!mShadow[i].allocate(spot_shadow_map_width, height, 0, TRUE, FALSE)) return false;
if (!mShadowOcclusion[i].allocate(mShadow[i].getWidth()/occlusion_divisor, mShadow[i].getHeight()/occlusion_divisor, 0, TRUE, FALSE)) return false;
}
}
else
@@ -827,6 +838,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
for (U32 i = 4; i < 6; i++)
{
mShadow[i].release();
mShadowOcclusion[i].release();
}
}
@@ -843,13 +855,14 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
for (U32 i = 0; i < 6; i++)
{
mShadow[i].release();
mShadowOcclusion[i].release();
}
mFXAABuffer.release();
mScreen.release();
mDeferredScreen.release(); //make sure to release any render targets that share a depth buffer with mDeferredScreen first
mDeferredDepth.release();
mOcclusionDepth.release();
if (!mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false;
if(samples > 1 && mScreen.getFBO())
{
@@ -969,12 +982,14 @@ void LLPipeline::releaseScreenBuffers()
mDeferredScreen.release();
mDeferredDepth.release();
mDeferredLight.release();
mOcclusionDepth.release();
//mHighlight.release();
for (U32 i = 0; i < 6; i++)
{
mShadow[i].release();
mShadowOcclusion[i].release();
}
mSampleBuffer.release();
@@ -2161,7 +2176,14 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
if (to_texture)
{
mScreen.bindTarget();
if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender)
{
mOcclusionDepth.bindTarget();
}
else
{
mScreen.bindTarget();
}
}
if (sUseOcclusion > 1)
@@ -2299,7 +2321,14 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
if (to_texture)
{
mScreen.flush();
if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender)
{
mOcclusionDepth.flush();
}
else
{
mScreen.flush();
}
}
}
@@ -2367,6 +2396,79 @@ void LLPipeline::markOccluder(LLSpatialGroup* group)
}
}
void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space)
{
LLGLSLShader* last_shader = LLGLSLShader::sCurBoundShaderPtr;
LLGLSLShader* shader = NULL;
if (scratch_space)
{
scratch_space->copyContents(source,
0, 0, source.getWidth(), source.getHeight(),
0, 0, scratch_space->getWidth(), scratch_space->getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
}
dest.bindTarget();
dest.clear(GL_DEPTH_BUFFER_BIT);
if(mDeferredVB.isNull())
{
mDeferredVB = new LLVertexBuffer(DEFERRED_VB_MASK, 0);
mDeferredVB->allocateBuffer(8, 0, true);
}
LLStrider<LLVector3> vert;
mDeferredVB->getVertexStrider(vert);
LLStrider<LLVector2> tc0;
vert[0].set(-1,1,0);
vert[1].set(-1,-3,0);
vert[2].set(3,1,0);
if (source.getUsage() == LLTexUnit::TT_RECT_TEXTURE)
{
shader = &gDownsampleDepthRectProgram;
shader->bind();
shader->uniform2f(sDelta, 1.f, 1.f);
shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, source.getWidth(), source.getHeight());
}
else
{
shader = &gDownsampleDepthProgram;
shader->bind();
shader->uniform2f(sDelta, 1.f/source.getWidth(), 1.f/source.getHeight());
shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, 1.f, 1.f);
}
gGL.getTexUnit(0)->bind(scratch_space ? scratch_space : &source, TRUE);
{
LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS);
mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3);
}
dest.flush();
if (last_shader)
{
last_shader->bind();
}
else
{
shader->unbind();
}
}
void LLPipeline::doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space)
{
downsampleDepthBuffer(source, dest, scratch_space);
dest.bindTarget();
doOcclusion(camera);
dest.flush();
}
void LLPipeline::doOcclusion(LLCamera& camera)
{
if (LLGLSLShader::sNoFixedFunction && LLPipeline::sUseOcclusion > 1 && sCull->hasOcclusionGroups())
@@ -4182,7 +4284,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera)
gGL.setColorMask(true, false);
}
void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion)
{
LLFastTimer t(FTM_POST_DEFERRED_POOLS);
U32 cur_type = 0;
@@ -4198,7 +4300,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
gGL.setColorMask(true, false);
pool_set_t::iterator iter1 = mPools.begin();
BOOL occlude = LLPipeline::sUseOcclusion > 1;
BOOL occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion;
while ( iter1 != mPools.end() )
{
@@ -4212,7 +4314,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera)
gGLLastMatrix = NULL;
gGL.loadMatrix(gGLModelView);
LLGLSLShader::bindNoShader();
doOcclusion(camera);
doOcclusion(camera, mScreen, mOcclusionDepth, &mDeferredDepth);
gGL.setColorMask(true, false);
}
@@ -5304,7 +5406,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera)
// crazy cast so that we can overwrite the fade value
// even though gcc enforces sets as const
// (fade value doesn't affect sort so this is safe)
Light* farthest_light = ((Light*) (&(*(mNearbyLights.rbegin()))));
Light* farthest_light = (const_cast<Light*>(&(*(mNearbyLights.rbegin()))));
if (light->dist < farthest_light->dist)
{
if (farthest_light->fade >= 0.f)
@@ -7478,10 +7580,10 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n
shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff);
if (shader.getUniformLocation("norm_mat") >= 0)
if (shader.getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0)
{
glh::matrix4f norm_mat = glh_get_current_modelview().inverse().transpose();
shader.uniformMatrix4fv("norm_mat", 1, FALSE, norm_mat.m);
shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m);
}
}
@@ -7617,8 +7719,8 @@ void LLPipeline::renderDeferredLighting()
}
}
gDeferredSunProgram.uniform3fv("offset", slice, offset);
gDeferredSunProgram.uniform2f("screenRes", mDeferredLight.getWidth(), mDeferredLight.getHeight());
gDeferredSunProgram.uniform3fv(sOffset, slice, offset);
gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight());
{
LLGLDisable blend(GL_BLEND);
@@ -7662,10 +7764,10 @@ void LLPipeline::renderDeferredLighting()
x += 1.f;
}
gDeferredBlurLightProgram.uniform2f("delta", 1.f, 0.f);
gDeferredBlurLightProgram.uniform1f("dist_factor", dist_factor);
gDeferredBlurLightProgram.uniform3fv("kern", kern_length, gauss[0].mV);
gDeferredBlurLightProgram.uniform1f("kern_scale", blur_size * (kern_length/2.f - 0.5f));
gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f);
gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor);
gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV);
gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length/2.f - 0.5f));
{
LLGLDisable blend(GL_BLEND);
@@ -7682,7 +7784,7 @@ void LLPipeline::renderDeferredLighting()
mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX);
mDeferredLight.bindTarget();
gDeferredBlurLightProgram.uniform2f("delta", 0.f, 1.f);
gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f);
{
LLGLDisable blend(GL_BLEND);
@@ -7749,7 +7851,7 @@ void LLPipeline::renderDeferredLighting()
LLPipeline::END_RENDER_TYPES);
renderGeomPostDeferred(*LLViewerCamera::getInstance());
renderGeomPostDeferred(*LLViewerCamera::getInstance(), false);
gPipeline.popRenderTypeMask();
}
@@ -8598,9 +8700,15 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
gDeferredShadowCubeProgram.bind();
}
LLRenderTarget& occlusion_target = mShadowOcclusion[LLViewerCamera::sCurCameraID-1];
occlusion_target.bindTarget();
updateCull(shadow_cam, result);
occlusion_target.flush();
stateSort(shadow_cam, result);
//generate shadow map
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
@@ -8679,7 +8787,10 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera
gDeferredShadowCubeProgram.bind();
gGLLastMatrix = NULL;
gGL.loadMatrix(gGLModelView);
doOcclusion(shadow_cam);
LLRenderTarget& occlusion_source = mShadow[LLViewerCamera::sCurCameraID-1];
doOcclusion(shadow_cam, occlusion_source, occlusion_target);
if (use_shader)
{
@@ -9823,7 +9934,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
resY != avatar->mImpostor.getHeight())
{
LLFastTimer t(FTM_IMPOSTOR_RESIZE);
avatar->mImpostor.resize(resX,resY,GL_RGBA);
avatar->mImpostor.resize(resX,resY);
}
avatar->mImpostor.bindTarget();

View File

@@ -177,6 +177,12 @@ public:
// Object related methods
void markVisible(LLDrawable *drawablep, LLCamera& camera);
void markOccluder(LLSpatialGroup* group);
//downsample source to dest, taking the maximum depth value per pixel in source and writing to dest
// if source's depth buffer cannot be bound for reading, a scratch space depth buffer must be provided
void downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space = NULL);
void doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space = NULL);
void doOcclusion(LLCamera& camera);
void markNotCulled(LLSpatialGroup* group, LLCamera &camera);
void markMoved(LLDrawable *drawablep, BOOL damped_motion = FALSE);
@@ -274,7 +280,7 @@ public:
void renderGeom(LLCamera& camera, BOOL forceVBOUpdate = FALSE);
void renderGeomDeferred(LLCamera& camera);
void renderGeomPostDeferred(LLCamera& camera);
void renderGeomPostDeferred(LLCamera& camera, bool do_occlusion=true);
void renderGeomShadow(LLCamera& camera);
void bindDeferredShader(LLGLSLShader& shader, U32 light_index = 0, U32 noise_map = 0xFFFFFFFF);
void setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep);
@@ -573,6 +579,7 @@ public:
LLRenderTarget mFXAABuffer;
LLRenderTarget mEdgeMap;
LLRenderTarget mDeferredDepth;
LLRenderTarget mOcclusionDepth;
LLRenderTarget mDeferredLight;
LLMultisampleBuffer mSampleBuffer;
LLRenderTarget mPhysicsDisplay;
@@ -585,6 +592,7 @@ public:
//sun shadow map
LLRenderTarget mShadow[6];
LLRenderTarget mShadowOcclusion[6];
std::vector<LLVector3> mShadowFrustPoints[4];
LLVector4 mShadowError;
LLVector4 mShadowFOV;

View File

@@ -461,6 +461,7 @@ class WindowsManifest(ViewerManifest):
"%%INSTALL_FILES%%":self.nsi_file_commands(True),
"%%DELETE_FILES%%":self.nsi_file_commands(False),
"%%INSTALLDIR%%":"%s\\%s" % ('$PROGRAMFILES64' if self.is_win64() else '$PROGRAMFILES', self.channel_oneword()),
"%%WIN64_BIN_BUILD%%":"!define WIN64_BIN_BUILD 1" if self.is_win64() else "",
})
# We use the Unicode version of NSIS, available from

View File

@@ -67,9 +67,9 @@
<key>windows64</key>
<map>
<key>md5sum</key>
<string>df67aeb1ca4681dc4d9a556454203426</string>
<string>c6d96cc9f6d993e2147710a5fb0b089a</string>
<key>url</key>
<uri>https://bitbucket.org/SingularityViewer/libraries/downloads/glod-1.0pre4-windows64-20131020.tar.bz2</uri>
<uri>https://bitbucket.org/SingularityViewer/libraries/downloads/glod-1.0pre4-windows64-20131028.tar.bz2</uri>
</map>
</map>
</map>
@@ -540,9 +540,9 @@
<key>windows64</key>
<map>
<key>md5sum</key>
<string>bfde86bbd84536448ac2a717ed1646d8</string>
<string>17f6c6e1b2d404a1e039aa23445f446c</string>
<key>url</key>
<uri>https://bitbucket.org/SingularityViewer/libraries/downloads/freetype-2.5.0.1-windows64-20131020.tar.bz2</uri>
<uri>https://bitbucket.org/SingularityViewer/libraries/downloads/freetype-2.3.9-windows64-20131028.tar.bz2</uri>
</map>
</map>
</map>