Catching up with Lindies part 3
This commit is contained in:
@@ -132,7 +132,7 @@ public:
|
||||
|
||||
virtual void addDebugText( const std::string& text ) = 0;
|
||||
|
||||
virtual const LLUUID& getID() = 0;
|
||||
virtual const LLUUID& getID() const = 0;
|
||||
//-------------------------------------------------------------------------
|
||||
// End Interface
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
@@ -548,6 +548,7 @@ LLCurl::Multi::Multi(F32 idle_time_out)
|
||||
mErrorCount(0),
|
||||
mState(STATE_READY),
|
||||
mDead(FALSE),
|
||||
mValid(TRUE),
|
||||
mMutexp(NULL),
|
||||
mDeletionMutexp(NULL),
|
||||
mEasyMutexp(NULL)
|
||||
@@ -584,6 +585,9 @@ LLCurl::Multi::Multi(F32 idle_time_out)
|
||||
LLCurl::Multi::~Multi()
|
||||
{
|
||||
cleanup(true);
|
||||
|
||||
delete mDeletionMutexp ;
|
||||
mDeletionMutexp = NULL ;
|
||||
}
|
||||
|
||||
void LLCurl::Multi::cleanup(bool deleted)
|
||||
@@ -592,7 +596,10 @@ void LLCurl::Multi::cleanup(bool deleted)
|
||||
{
|
||||
return ; //nothing to clean.
|
||||
}
|
||||
llassert_always(deleted || !mValid) ;
|
||||
|
||||
LLMutexLock lock(mDeletionMutexp);
|
||||
|
||||
// Clean up active
|
||||
for(easy_active_list_t::iterator iter = mEasyActiveList.begin();
|
||||
iter != mEasyActiveList.end(); ++iter)
|
||||
@@ -600,9 +607,9 @@ void LLCurl::Multi::cleanup(bool deleted)
|
||||
Easy* easy = *iter;
|
||||
check_curl_multi_code(curl_multi_remove_handle(mCurlMultiHandle, easy->getCurlHandle()));
|
||||
|
||||
if(deleted)
|
||||
{
|
||||
easy->mResponder = NULL ; //avoid triggering mResponder.
|
||||
if(deleted)
|
||||
{
|
||||
easy->mResponder = NULL ; //avoid triggering mResponder.
|
||||
}
|
||||
delete easy;
|
||||
}
|
||||
@@ -615,14 +622,12 @@ void LLCurl::Multi::cleanup(bool deleted)
|
||||
|
||||
check_curl_multi_code(LLCurl::deleteMultiHandle(mCurlMultiHandle));
|
||||
mCurlMultiHandle = NULL ;
|
||||
|
||||
|
||||
delete mMutexp ;
|
||||
mMutexp = NULL ;
|
||||
delete mDeletionMutexp ;
|
||||
mDeletionMutexp = NULL ;
|
||||
delete mEasyMutexp ;
|
||||
mEasyMutexp = NULL ;
|
||||
|
||||
|
||||
mQueued = 0 ;
|
||||
mState = STATE_COMPLETED;
|
||||
|
||||
@@ -649,10 +654,20 @@ void LLCurl::Multi::unlock()
|
||||
|
||||
void LLCurl::Multi::markDead()
|
||||
{
|
||||
LLMutexLock lock(mDeletionMutexp) ;
|
||||
{
|
||||
LLMutexLock lock(mDeletionMutexp) ;
|
||||
|
||||
mDead = TRUE ;
|
||||
LLCurl::getCurlThread()->setPriority(mHandle, LLQueuedThread::PRIORITY_URGENT) ;
|
||||
if(mCurlMultiHandle != NULL)
|
||||
{
|
||||
mDead = TRUE ;
|
||||
LLCurl::getCurlThread()->setPriority(mHandle, LLQueuedThread::PRIORITY_URGENT) ;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//not valid, delete it.
|
||||
delete this;
|
||||
}
|
||||
|
||||
void LLCurl::Multi::setState(LLCurl::Multi::ePerformState state)
|
||||
@@ -746,10 +761,14 @@ bool LLCurl::Multi::doPerform()
|
||||
setState(STATE_COMPLETED) ;
|
||||
mIdleTimer.reset() ;
|
||||
}
|
||||
else if(mIdleTimer.getElapsedTimeF32() > mIdleTimeOut) //idle for too long, remove it.
|
||||
else if(!mValid && mIdleTimer.getElapsedTimeF32() > mIdleTimeOut) //idle for too long, remove it.
|
||||
{
|
||||
dead = true ;
|
||||
}
|
||||
else if(mValid && mIdleTimer.getElapsedTimeF32() > mIdleTimeOut - 1.f) //idle for too long, mark it invalid.
|
||||
{
|
||||
mValid = FALSE ;
|
||||
}
|
||||
|
||||
return dead ;
|
||||
}
|
||||
@@ -971,14 +990,7 @@ void LLCurlThread::killMulti(LLCurl::Multi* multi)
|
||||
return ;
|
||||
}
|
||||
|
||||
if(multi->isValid())
|
||||
{
|
||||
multi->markDead() ;
|
||||
}
|
||||
else
|
||||
{
|
||||
deleteMulti(multi) ;
|
||||
}
|
||||
multi->markDead() ;
|
||||
}
|
||||
|
||||
//private
|
||||
@@ -997,6 +1009,10 @@ void LLCurlThread::deleteMulti(LLCurl::Multi* multi)
|
||||
void LLCurlThread::cleanupMulti(LLCurl::Multi* multi)
|
||||
{
|
||||
multi->cleanup() ;
|
||||
if(multi->isDead()) //check if marked dead during cleaning up.
|
||||
{
|
||||
deleteMulti(multi) ;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
@@ -304,7 +304,7 @@ public:
|
||||
ePerformState getState() ;
|
||||
|
||||
bool isCompleted() ;
|
||||
bool isValid() {return mCurlMultiHandle != NULL ;}
|
||||
bool isValid() {return mCurlMultiHandle != NULL && mValid;}
|
||||
bool isDead() {return mDead;}
|
||||
|
||||
bool waitToComplete() ;
|
||||
@@ -333,6 +333,7 @@ private:
|
||||
ePerformState mState;
|
||||
|
||||
BOOL mDead ;
|
||||
BOOL mValid ;
|
||||
LLMutex* mMutexp ;
|
||||
LLMutex* mDeletionMutexp ;
|
||||
LLMutex* mEasyMutexp ;
|
||||
|
||||
@@ -108,6 +108,10 @@ void APIENTRY gl_debug_callback(GLenum source,
|
||||
llwarns << "Severity: " << std::hex << severity << llendl;
|
||||
llwarns << "Message: " << message << llendl;
|
||||
llwarns << "-----------------------" << llendl;
|
||||
if (severity == GL_DEBUG_SEVERITY_HIGH_ARB)
|
||||
{
|
||||
llerrs << "Halting on GL Error" << llendl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -587,6 +591,15 @@ bool LLGLManager::initGL()
|
||||
#endif
|
||||
}
|
||||
|
||||
if (mGLVersion >= 3.f && LLImageGL::sCompressTextures)
|
||||
{ //use texture compression
|
||||
glHint(GL_TEXTURE_COMPRESSION_HINT, GL_NICEST);
|
||||
}
|
||||
else
|
||||
{ //GL version is < 3.0, always disable texture compression
|
||||
LLImageGL::sCompressTextures = false;
|
||||
}
|
||||
|
||||
// Trailing space necessary to keep "nVidia Corpor_ati_on" cards
|
||||
// from being recognized as ATI.
|
||||
if (mGLVendor.substr(0,4) == "ATI ")
|
||||
|
||||
@@ -62,6 +62,7 @@ BOOL LLImageGL::sGlobalUseAnisotropic = FALSE;
|
||||
F32 LLImageGL::sLastFrameTime = 0.f;
|
||||
BOOL LLImageGL::sAllowReadBackRaw = FALSE ;
|
||||
LLImageGL* LLImageGL::sDefaultGLTexture = NULL ;
|
||||
bool LLImageGL::sCompressTextures = false;
|
||||
|
||||
std::set<LLImageGL*> LLImageGL::sImageList;
|
||||
|
||||
@@ -489,6 +490,8 @@ void LLImageGL::init(BOOL usemipmaps)
|
||||
mHeight = 0;
|
||||
mCurrentDiscardLevel = -1;
|
||||
|
||||
mAllowCompression = true;
|
||||
|
||||
mTarget = GL_TEXTURE_2D;
|
||||
mBindTarget = LLTexUnit::TT_TEXTURE;
|
||||
mHasMipMaps = false;
|
||||
@@ -720,7 +723,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
|
||||
stop_glerror();
|
||||
}
|
||||
|
||||
LLImageGL::setManualImage(mTarget, gl_level, mFormatInternal, w, h, mFormatPrimary, GL_UNSIGNED_BYTE, (GLvoid*)data_in);
|
||||
LLImageGL::setManualImage(mTarget, gl_level, mFormatInternal, w, h, mFormatPrimary, GL_UNSIGNED_BYTE, (GLvoid*)data_in, mAllowCompression);
|
||||
if (gl_level == 0)
|
||||
{
|
||||
analyzeAlpha(data_in, w, h);
|
||||
@@ -762,7 +765,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
|
||||
LLImageGL::setManualImage(mTarget, 0, mFormatInternal,
|
||||
w, h,
|
||||
mFormatPrimary, mFormatType,
|
||||
data_in);
|
||||
data_in, mAllowCompression);
|
||||
analyzeAlpha(data_in, w, h);
|
||||
stop_glerror();
|
||||
|
||||
@@ -821,7 +824,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
|
||||
stop_glerror();
|
||||
}
|
||||
|
||||
LLImageGL::setManualImage(mTarget, m, mFormatInternal, w, h, mFormatPrimary, mFormatType, cur_mip_data);
|
||||
LLImageGL::setManualImage(mTarget, m, mFormatInternal, w, h, mFormatPrimary, mFormatType, cur_mip_data, mAllowCompression);
|
||||
if (m == 0)
|
||||
{
|
||||
analyzeAlpha(data_in, w, h);
|
||||
@@ -880,7 +883,7 @@ void LLImageGL::setImage(const U8* data_in, BOOL data_hasmips)
|
||||
}
|
||||
|
||||
LLImageGL::setManualImage(mTarget, 0, mFormatInternal, w, h,
|
||||
mFormatPrimary, mFormatType, (GLvoid *)data_in);
|
||||
mFormatPrimary, mFormatType, (GLvoid *)data_in, mAllowCompression);
|
||||
analyzeAlpha(data_in, w, h);
|
||||
|
||||
updatePickMask(w, h, data_in);
|
||||
@@ -1039,7 +1042,7 @@ void LLImageGL::deleteTextures(S32 numTextures, U32 *textures, bool immediate)
|
||||
}
|
||||
|
||||
// static
|
||||
void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels)
|
||||
void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels, bool allow_compression)
|
||||
{
|
||||
bool use_scratch = false;
|
||||
U32* scratch = NULL;
|
||||
@@ -1102,6 +1105,36 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt
|
||||
}
|
||||
}
|
||||
|
||||
if (LLImageGL::sCompressTextures && allow_compression)
|
||||
{
|
||||
switch (intformat)
|
||||
{
|
||||
case GL_RGB:
|
||||
case GL_RGB8:
|
||||
intformat = GL_COMPRESSED_RGB;
|
||||
break;
|
||||
case GL_RGBA:
|
||||
case GL_RGBA8:
|
||||
intformat = GL_COMPRESSED_RGBA;
|
||||
break;
|
||||
case GL_LUMINANCE:
|
||||
case GL_LUMINANCE8:
|
||||
intformat = GL_COMPRESSED_LUMINANCE;
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
case GL_LUMINANCE8_ALPHA8:
|
||||
intformat = GL_COMPRESSED_LUMINANCE_ALPHA;
|
||||
break;
|
||||
case GL_ALPHA:
|
||||
case GL_ALPHA8:
|
||||
intformat = GL_COMPRESSED_ALPHA;
|
||||
break;
|
||||
default:
|
||||
llwarns << "Could not compress format: " << std::hex << intformat << llendl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
stop_glerror();
|
||||
glTexImage2D(target, miplevel, intformat, width, height, 0, pixformat, pixtype, use_scratch ? scratch : pixels);
|
||||
stop_glerror();
|
||||
|
||||
@@ -100,12 +100,13 @@ public:
|
||||
|
||||
void setSize(S32 width, S32 height, S32 ncomponents);
|
||||
void setComponents(S32 ncomponents) { mComponents = (S8)ncomponents ;}
|
||||
void setAllowCompression(bool allow) { mAllowCompression = allow; }
|
||||
|
||||
// These 3 functions currently wrap glGenTextures(), glDeleteTextures(), and glTexImage2D()
|
||||
// for tracking purposes and will be deprecated in the future
|
||||
static void generateTextures(S32 numTextures, U32 *textures);
|
||||
static void deleteTextures(S32 numTextures, U32 *textures, bool immediate = false);
|
||||
static void setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels);
|
||||
static void setManualImage(U32 target, S32 miplevel, S32 intformat, S32 width, S32 height, U32 pixformat, U32 pixtype, const void *pixels, bool allow_compression = true);
|
||||
|
||||
BOOL createGLTexture() ;
|
||||
BOOL createGLTexture(S32 discard_level, const LLImageRaw* imageraw, S32 usename = 0, BOOL to_create = TRUE,
|
||||
@@ -202,6 +203,8 @@ private:
|
||||
U16 mHeight;
|
||||
S8 mCurrentDiscardLevel;
|
||||
|
||||
bool mAllowCompression;
|
||||
|
||||
protected:
|
||||
LLGLenum mTarget; // Normally GL_TEXTURE2D, sometimes something else (ex. cube maps)
|
||||
LLTexUnit::eTextureType mBindTarget; // Normally TT_TEXTURE, sometimes something else (ex. cube maps)
|
||||
@@ -239,6 +242,7 @@ public:
|
||||
static U32 sUniqueCount; // Tracks number of unique texture binds for current frame
|
||||
static BOOL sGlobalUseAnisotropic;
|
||||
static LLImageGL* sDefaultGLTexture ;
|
||||
static bool sCompressTextures; //use GL texture compression
|
||||
|
||||
#if DEBUG_MISS
|
||||
BOOL mMissed; // Missed on last bind?
|
||||
|
||||
@@ -157,7 +157,7 @@ bool LLRenderTarget::addColorAttachment(U32 color_fmt)
|
||||
|
||||
{
|
||||
clear_glerror();
|
||||
LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
LLImageGL::setManualImage(LLTexUnit::getInternalType(mUsage), 0, color_fmt, mResX, mResY, GL_RGBA, GL_UNSIGNED_BYTE, NULL, false);
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
llwarns << "Could not allocate color buffer for render target." << llendl;
|
||||
@@ -237,7 +237,7 @@ bool LLRenderTarget::allocateDepth()
|
||||
U32 internal_type = LLTexUnit::getInternalType(mUsage);
|
||||
stop_glerror();
|
||||
clear_glerror();
|
||||
LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT24, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
|
||||
LLImageGL::setManualImage(internal_type, 0, GL_DEPTH_COMPONENT24, mResX, mResY, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL, false);
|
||||
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
|
||||
}
|
||||
|
||||
|
||||
@@ -543,7 +543,6 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//read in from file
|
||||
LLFILE* file = NULL;
|
||||
|
||||
@@ -572,7 +571,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
return 0;
|
||||
}
|
||||
|
||||
//we can't have any lines longer than 1024 characters
|
||||
//we can't have any lines longer than 1024 characters
|
||||
//or any shaders longer than 4096 lines... deal - DaveP
|
||||
GLcharARB buff[1024];
|
||||
GLcharARB* text[4096];
|
||||
@@ -617,6 +616,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
|
||||
//some implementations of GLSL 1.30 require integer precision be explicitly declared
|
||||
text[count++] = strdup("precision mediump int;\n");
|
||||
text[count++] = strdup("precision highp float;\n");
|
||||
}
|
||||
else
|
||||
{ //set version to 400
|
||||
@@ -642,15 +642,15 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
|
||||
//backwards compatibility with legacy texture lookup syntax
|
||||
text[count++] = strdup("#define texture2D texture\n");
|
||||
text[count++] = strdup("#define texture2DRect texture\n");
|
||||
text[count++] = strdup("#define textureCube texture\n");
|
||||
text[count++] = strdup("#define texture2DLod textureLod\n");
|
||||
text[count++] = strdup("#define shadow2D(a,b) vec2(texture(a,b))\n"); //Shadow lookups only return a single float.
|
||||
|
||||
//Also deprecated:
|
||||
text[count++] = strdup("#define texture2D texture\n");
|
||||
text[count++] = strdup("#define texture2DRect texture\n");
|
||||
text[count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n");
|
||||
text[count++] = strdup("#define shadow2D(a,b) vec2(texture(a,b))\n");
|
||||
|
||||
if (major_version > 1 || minor_version >= 40)
|
||||
{ //GLSL 1.40 replaces texture2DRect et al with texture
|
||||
text[count++] = strdup("#define texture2DRect texture\n");
|
||||
text[count++] = strdup("#define shadow2DRect(a,b) vec2(texture(a,b))\n");
|
||||
}
|
||||
}
|
||||
|
||||
//copy preprocessor definitions into buffer
|
||||
@@ -676,20 +676,22 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
|
||||
VARYING_FLAT ivec4 vary_texture_index;
|
||||
|
||||
vec4 ret = vec4(1,0,1,1);
|
||||
|
||||
vec4 diffuseLookup(vec2 texcoord)
|
||||
{
|
||||
switch (vary_texture_index.r))
|
||||
switch (vary_texture_index.r))
|
||||
{
|
||||
case 0: return texture2D(tex0, texcoord);
|
||||
case 1: return texture2D(tex1, texcoord);
|
||||
case 2: return texture2D(tex2, texcoord);
|
||||
case 0: ret = texture2D(tex0, texcoord); break;
|
||||
case 1: ret = texture2D(tex1, texcoord); break;
|
||||
case 2: ret = texture2D(tex2, texcoord); break;
|
||||
.
|
||||
.
|
||||
.
|
||||
case N: return texture2D(texN, texcoord);
|
||||
case N: return texture2D(texN, texcoord); break;
|
||||
}
|
||||
|
||||
return vec4(0,0,0,0);
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -714,20 +716,21 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
text[count++] = strdup("return texture2D(tex0, texcoord);\n");
|
||||
text[count++] = strdup("}\n");
|
||||
}
|
||||
else if (gGLManager.mGLVersion >= 3.f && !(gGLManager.mIsATI && gGLManager.mGLVersion < 3.3f) )
|
||||
{
|
||||
text[count++] = strdup("\tswitch (int(vary_texture_index+0.25))\n");
|
||||
else if (major_version > 1 || minor_version >= 30)
|
||||
{ //switches are supported in GLSL 1.30 and later
|
||||
text[count++] = strdup("\tvec4 ret = vec4(1,0,1,1);\n");
|
||||
text[count++] = strdup("\tswitch (vary_texture_index.r)\n");
|
||||
text[count++] = strdup("\t{\n");
|
||||
|
||||
//switch body
|
||||
for (S32 i = 0; i < texture_index_channels; ++i)
|
||||
{
|
||||
std::string case_str = llformat("\t\tcase %d: return texture2D(tex%d, texcoord);\n", i, i);
|
||||
std::string case_str = llformat("\t\tcase %d: ret = texture2D(tex%d, texcoord); break;\n", i, i);
|
||||
text[count++] = strdup(case_str.c_str());
|
||||
}
|
||||
|
||||
text[count++] = strdup("\t}\n");
|
||||
text[count++] = strdup("\treturn vec4(1,0,1,1);\n");
|
||||
text[count++] = strdup("\treturn ret;\n");
|
||||
text[count++] = strdup("}\n");
|
||||
}
|
||||
else
|
||||
|
||||
@@ -34,12 +34,13 @@
|
||||
#include "llmemtype.h"
|
||||
#include "llrender.h"
|
||||
#include "llvector4a.h"
|
||||
#include "llcontrol.h"
|
||||
#include "llshadermgr.h"
|
||||
#include "llglslshader.h"
|
||||
#include "llmemory.h"
|
||||
#include "llfasttimer.h"
|
||||
|
||||
#define LL_VBO_POOLING 0
|
||||
|
||||
//Next Highest Power Of Two
|
||||
//helper function, returns first number > v that is a power of 2, or v if v is already a power of 2
|
||||
U32 nhpo2(U32 v)
|
||||
@@ -51,6 +52,35 @@ U32 nhpo2(U32 v)
|
||||
return r;
|
||||
}
|
||||
|
||||
//which power of 2 is i?
|
||||
//assumes i is a power of 2 > 0
|
||||
U32 wpo2(U32 i)
|
||||
{
|
||||
llassert(i > 0);
|
||||
llassert(nhpo2(i) == i);
|
||||
|
||||
U32 r = 0;
|
||||
|
||||
while (i >>= 1) ++r;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
const U32 LL_VBO_BLOCK_SIZE = 2048;
|
||||
|
||||
U32 vbo_block_size(U32 size)
|
||||
{ //what block size will fit size?
|
||||
U32 mod = size % LL_VBO_BLOCK_SIZE;
|
||||
return mod == 0 ? size : size + (LL_VBO_BLOCK_SIZE-mod);
|
||||
}
|
||||
|
||||
U32 vbo_block_index(U32 size)
|
||||
{
|
||||
return vbo_block_size(size)/LL_VBO_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//============================================================================
|
||||
|
||||
@@ -59,9 +89,13 @@ LLVBOPool LLVertexBuffer::sStreamVBOPool(GL_STREAM_DRAW_ARB, GL_ARRAY_BUFFER_ARB
|
||||
LLVBOPool LLVertexBuffer::sDynamicVBOPool(GL_DYNAMIC_DRAW_ARB, GL_ARRAY_BUFFER_ARB);
|
||||
LLVBOPool LLVertexBuffer::sStreamIBOPool(GL_STREAM_DRAW_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB);
|
||||
LLVBOPool LLVertexBuffer::sDynamicIBOPool(GL_DYNAMIC_DRAW_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB);
|
||||
U32 LLVBOPool::sBytesPooled = 0;
|
||||
|
||||
LLPrivateMemoryPool* LLVertexBuffer::sPrivatePoolp = NULL ;
|
||||
U32 LLVBOPool::sBytesPooled = 0;
|
||||
U32 LLVBOPool::sIndexBytesPooled = 0;
|
||||
U32 LLVertexBuffer::sAllocatedIndexBytes = 0;
|
||||
U32 LLVertexBuffer::sIndexCount = 0;
|
||||
|
||||
LLPrivateMemoryPool* LLVertexBuffer::sPrivatePoolp = NULL;
|
||||
U32 LLVertexBuffer::sBindCount = 0;
|
||||
U32 LLVertexBuffer::sSetCount = 0;
|
||||
S32 LLVertexBuffer::sCount = 0;
|
||||
@@ -76,6 +110,7 @@ U32 LLVertexBuffer::sLastMask = 0;
|
||||
bool LLVertexBuffer::sVBOActive = false;
|
||||
bool LLVertexBuffer::sIBOActive = false;
|
||||
U32 LLVertexBuffer::sAllocatedBytes = 0;
|
||||
U32 LLVertexBuffer::sVertexCount = 0;
|
||||
bool LLVertexBuffer::sMapped = false;
|
||||
bool LLVertexBuffer::sUseStreamDraw = true;
|
||||
bool LLVertexBuffer::sUseVAO = false;
|
||||
@@ -136,39 +171,35 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//which power of 2 is i?
|
||||
//assumes i is a power of 2 > 0
|
||||
U32 wpo2(U32 i)
|
||||
{
|
||||
llassert(i > 0);
|
||||
llassert(nhpo2(i) == i);
|
||||
|
||||
U32 r = 0;
|
||||
|
||||
while (i >>= 1) ++r;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
volatile U8* LLVBOPool::allocate(U32& name, U32 size)
|
||||
{
|
||||
llassert(nhpo2(size) == size);
|
||||
llassert(vbo_block_size(size) == size);
|
||||
|
||||
volatile U8* ret = NULL;
|
||||
|
||||
U32 i = wpo2(size);
|
||||
#if LL_VBO_POOLING
|
||||
|
||||
U32 i = vbo_block_index(size);
|
||||
|
||||
if (mFreeList.size() <= i)
|
||||
{
|
||||
mFreeList.resize(i+1);
|
||||
}
|
||||
|
||||
volatile U8* ret = NULL;
|
||||
|
||||
if (mFreeList[i].empty())
|
||||
{
|
||||
//make a new buffer
|
||||
glGenBuffersARB(1, &name);
|
||||
glBindBufferARB(mType, name);
|
||||
LLVertexBuffer::sAllocatedBytes += size;
|
||||
|
||||
if (mType == GL_ARRAY_BUFFER_ARB)
|
||||
{
|
||||
LLVertexBuffer::sAllocatedBytes += size;
|
||||
}
|
||||
else
|
||||
{
|
||||
LLVertexBuffer::sAllocatedIndexBytes += size;
|
||||
}
|
||||
|
||||
if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW_ARB)
|
||||
{
|
||||
@@ -179,6 +210,7 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size)
|
||||
{ //always use a true hint of static draw when allocating non-client-backed buffers
|
||||
glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB);
|
||||
}
|
||||
|
||||
glBindBufferARB(mType, 0);
|
||||
}
|
||||
else
|
||||
@@ -186,19 +218,55 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size)
|
||||
name = mFreeList[i].front().mGLName;
|
||||
ret = mFreeList[i].front().mClientData;
|
||||
|
||||
sBytesPooled -= size;
|
||||
if (mType == GL_ARRAY_BUFFER_ARB)
|
||||
{
|
||||
sBytesPooled -= size;
|
||||
}
|
||||
else
|
||||
{
|
||||
sIndexBytesPooled -= size;
|
||||
}
|
||||
|
||||
mFreeList[i].pop_front();
|
||||
}
|
||||
#else //no pooling
|
||||
|
||||
glGenBuffersARB(1, &name);
|
||||
glBindBufferARB(mType, name);
|
||||
|
||||
if (mType == GL_ARRAY_BUFFER_ARB)
|
||||
{
|
||||
LLVertexBuffer::sAllocatedBytes += size;
|
||||
}
|
||||
else
|
||||
{
|
||||
LLVertexBuffer::sAllocatedIndexBytes += size;
|
||||
}
|
||||
|
||||
if (LLVertexBuffer::sDisableVBOMapping || mUsage != GL_DYNAMIC_DRAW_ARB)
|
||||
{
|
||||
glBufferDataARB(mType, size, 0, mUsage);
|
||||
ret = (U8*) ll_aligned_malloc_16(size);
|
||||
}
|
||||
else
|
||||
{ //always use a true hint of static draw when allocating non-client-backed buffers
|
||||
glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB);
|
||||
}
|
||||
|
||||
glBindBufferARB(mType, 0);
|
||||
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size)
|
||||
{
|
||||
llassert(nhpo2(size) == size);
|
||||
llassert(vbo_block_size(size) == size);
|
||||
|
||||
U32 i = wpo2(size);
|
||||
#if LL_VBO_POOLING
|
||||
|
||||
U32 i = vbo_block_index(size);
|
||||
|
||||
llassert(mFreeList.size() > i);
|
||||
|
||||
@@ -212,9 +280,29 @@ void LLVBOPool::release(U32 name, volatile U8* buffer, U32 size)
|
||||
}
|
||||
else
|
||||
{
|
||||
sBytesPooled += size;
|
||||
if (mType == GL_ARRAY_BUFFER_ARB)
|
||||
{
|
||||
sBytesPooled += size;
|
||||
}
|
||||
else
|
||||
{
|
||||
sIndexBytesPooled += size;
|
||||
}
|
||||
mFreeList[i].push_back(rec);
|
||||
}
|
||||
#else //no pooling
|
||||
glDeleteBuffersARB(1, &name);
|
||||
ll_aligned_free_16((U8*) buffer);
|
||||
|
||||
if (mType == GL_ARRAY_BUFFER_ARB)
|
||||
{
|
||||
LLVertexBuffer::sAllocatedBytes -= size;
|
||||
}
|
||||
else
|
||||
{
|
||||
LLVertexBuffer::sAllocatedIndexBytes -= size;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void LLVBOPool::cleanup()
|
||||
@@ -238,8 +326,16 @@ void LLVBOPool::cleanup()
|
||||
|
||||
l.pop_front();
|
||||
|
||||
LLVertexBuffer::sAllocatedBytes -= size;
|
||||
sBytesPooled -= size;
|
||||
if (mType == GL_ARRAY_BUFFER_ARB)
|
||||
{
|
||||
sBytesPooled -= size;
|
||||
LLVertexBuffer::sAllocatedBytes -= size;
|
||||
}
|
||||
else
|
||||
{
|
||||
sIndexBytesPooled -= size;
|
||||
LLVertexBuffer::sAllocatedIndexBytes -= size;
|
||||
}
|
||||
}
|
||||
|
||||
size *= 2;
|
||||
@@ -436,7 +532,7 @@ void LLVertexBuffer::drawArrays(U32 mode, const std::vector<LLVector3>& pos, con
|
||||
|
||||
U32 count = pos.size();
|
||||
llassert_always(norm.size() >= pos.size());
|
||||
llassert_always(count > 0) ;
|
||||
llassert_always(count > 0);
|
||||
|
||||
unbind();
|
||||
|
||||
@@ -695,8 +791,8 @@ void LLVertexBuffer::drawArrays(U32 mode, U32 first, U32 count) const
|
||||
//static
|
||||
void LLVertexBuffer::initClass(bool use_vbo, bool no_vbo_mapping)
|
||||
{
|
||||
sEnableVBOs = use_vbo && gGLManager.mHasVertexBufferObject ;
|
||||
sDisableVBOMapping = sEnableVBOs && no_vbo_mapping ;
|
||||
sEnableVBOs = use_vbo && gGLManager.mHasVertexBufferObject;
|
||||
sDisableVBOMapping = sEnableVBOs && no_vbo_mapping;
|
||||
|
||||
if (!sPrivatePoolp)
|
||||
{
|
||||
@@ -747,8 +843,8 @@ void LLVertexBuffer::cleanupClass()
|
||||
|
||||
if(sPrivatePoolp)
|
||||
{
|
||||
LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp) ;
|
||||
sPrivatePoolp = NULL ;
|
||||
LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp);
|
||||
sPrivatePoolp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -756,25 +852,41 @@ void LLVertexBuffer::cleanupClass()
|
||||
|
||||
S32 LLVertexBuffer::determineUsage(S32 usage)
|
||||
{
|
||||
if (LLRender::sGLCoreProfile)
|
||||
S32 ret_usage = usage;
|
||||
|
||||
if (!sEnableVBOs)
|
||||
{
|
||||
ret_usage = 0;
|
||||
}
|
||||
|
||||
if (ret_usage == GL_STREAM_DRAW_ARB && !sUseStreamDraw)
|
||||
{
|
||||
ret_usage = 0;
|
||||
}
|
||||
|
||||
if (ret_usage == GL_DYNAMIC_DRAW_ARB && sPreferStreamDraw)
|
||||
{
|
||||
ret_usage = GL_STREAM_DRAW_ARB;
|
||||
}
|
||||
|
||||
if (ret_usage == 0 && LLRender::sGLCoreProfile)
|
||||
{ //MUST use VBOs for all rendering
|
||||
if(!usage)
|
||||
return GL_STREAM_DRAW_ARB;
|
||||
ret_usage = GL_STREAM_DRAW_ARB;
|
||||
}
|
||||
else if (!sEnableVBOs || !usage || (!sUseStreamDraw && usage == GL_STREAM_DRAW_ARB))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//Only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default.
|
||||
//Always use stream_draw VBO if mapping is disabled, or stream is preferred or expected
|
||||
if( sDisableVBOMapping || sPreferStreamDraw || (usage == GL_STREAM_DRAW_ARB))
|
||||
{
|
||||
return GL_STREAM_DRAW_ARB;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GL_DYNAMIC_DRAW_ARB;
|
||||
|
||||
if (ret_usage && ret_usage != GL_STREAM_DRAW_ARB)
|
||||
{ //only stream_draw and dynamic_draw are supported when using VBOs, dynamic draw is the default
|
||||
if (sDisableVBOMapping)
|
||||
{ //always use stream draw if VBO mapping is disabled
|
||||
ret_usage = GL_STREAM_DRAW_ARB;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret_usage = GL_DYNAMIC_DRAW_ARB;
|
||||
}
|
||||
}
|
||||
|
||||
return ret_usage;
|
||||
}
|
||||
|
||||
LLVertexBuffer::LLVertexBuffer(U32 typemask, S32 usage) :
|
||||
@@ -883,7 +995,10 @@ LLVertexBuffer::~LLVertexBuffer()
|
||||
|
||||
mFence = NULL;
|
||||
|
||||
llassert_always(!mMappedData && !mMappedIndexData) ;
|
||||
sVertexCount -= mNumVerts;
|
||||
sIndexCount -= mNumIndices;
|
||||
|
||||
llassert_always(!mMappedData && !mMappedIndexData);
|
||||
};
|
||||
|
||||
void LLVertexBuffer::placeFence() const
|
||||
@@ -914,7 +1029,7 @@ void LLVertexBuffer::waitFence() const
|
||||
|
||||
void LLVertexBuffer::genBuffer(U32 size)
|
||||
{
|
||||
mSize = nhpo2(size);
|
||||
mSize = vbo_block_size(size);
|
||||
|
||||
if (mUsage == GL_STREAM_DRAW_ARB)
|
||||
{
|
||||
@@ -930,7 +1045,7 @@ void LLVertexBuffer::genBuffer(U32 size)
|
||||
|
||||
void LLVertexBuffer::genIndices(U32 size)
|
||||
{
|
||||
mIndicesSize = nhpo2(size);
|
||||
mIndicesSize = vbo_block_size(size);
|
||||
|
||||
if (mUsage == GL_STREAM_DRAW_ARB)
|
||||
{
|
||||
@@ -1099,14 +1214,16 @@ void LLVertexBuffer::updateNumVerts(S32 nverts)
|
||||
nverts = 65535;
|
||||
}
|
||||
|
||||
U32 needed_size = calcOffsets(mTypeMask, mOffsets, nverts);
|
||||
S32 needed_size = calcOffsets(mTypeMask, mOffsets, nverts);
|
||||
|
||||
if (needed_size > (U32)mSize || needed_size <= (U32)mSize/2)
|
||||
if (needed_size > mSize || needed_size <= mSize/2)
|
||||
{
|
||||
createGLBuffer(needed_size);
|
||||
}
|
||||
|
||||
sVertexCount -= mNumVerts;
|
||||
mNumVerts = nverts;
|
||||
sVertexCount += mNumVerts;
|
||||
}
|
||||
|
||||
void LLVertexBuffer::updateNumIndices(S32 nindices)
|
||||
@@ -1115,14 +1232,16 @@ void LLVertexBuffer::updateNumIndices(S32 nindices)
|
||||
|
||||
llassert(nindices >= 0);
|
||||
|
||||
U32 needed_size = sizeof(U16) * nindices;
|
||||
S32 needed_size = sizeof(U16) * nindices;
|
||||
|
||||
if (needed_size > (U32)mIndicesSize || needed_size <= (U32)mIndicesSize/2)
|
||||
if (needed_size > mIndicesSize || needed_size <= mIndicesSize/2)
|
||||
{
|
||||
createGLIndices(needed_size);
|
||||
}
|
||||
|
||||
sIndexCount -= mNumIndices;
|
||||
mNumIndices = nindices;
|
||||
sIndexCount += mNumIndices;
|
||||
}
|
||||
|
||||
void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
|
||||
@@ -1247,7 +1366,7 @@ void LLVertexBuffer::setupVertexArray()
|
||||
{
|
||||
glEnableVertexAttribArrayARB(i);
|
||||
|
||||
if (attrib_integer)
|
||||
if (attrib_integer[i])
|
||||
{
|
||||
#if !LL_DARWIN
|
||||
//glVertexattribIPointer requires GLSL 1.30 or later
|
||||
@@ -1323,6 +1442,7 @@ bool expand_region(LLVertexBuffer::MappedRegion& region, S32 index, S32 count)
|
||||
|
||||
static LLFastTimer::DeclareTimer FTM_VBO_MAP_BUFFER_RANGE("VBO Map Range");
|
||||
static LLFastTimer::DeclareTimer FTM_VBO_MAP_BUFFER("VBO Map");
|
||||
|
||||
// Map for data access
|
||||
volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, bool map_range)
|
||||
{
|
||||
@@ -1457,16 +1577,16 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo
|
||||
log_glerror();
|
||||
|
||||
//check the availability of memory
|
||||
LLMemory::logMemoryInfo(true) ;
|
||||
LLMemory::logMemoryInfo(true);
|
||||
|
||||
if(mMappable)
|
||||
{
|
||||
//--------------------
|
||||
//print out more debug info before crash
|
||||
llinfos << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << llendl ;
|
||||
GLint size ;
|
||||
glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size) ;
|
||||
llinfos << "GL_ARRAY_BUFFER_ARB size is " << size << llendl ;
|
||||
llinfos << "vertex buffer size: (num verts : num indices) = " << getNumVerts() << " : " << getNumIndices() << llendl;
|
||||
GLint size;
|
||||
glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size);
|
||||
llinfos << "GL_ARRAY_BUFFER_ARB size is " << size << llendl;
|
||||
//--------------------
|
||||
|
||||
GLint buff;
|
||||
@@ -1481,7 +1601,7 @@ volatile U8* LLVertexBuffer::mapVertexBuffer(S32 type, S32 index, S32 count, boo
|
||||
}
|
||||
else
|
||||
{
|
||||
llerrs << "memory allocation for vertex data failed." << llendl ;
|
||||
llerrs << "memory allocation for vertex data failed." << llendl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1635,7 +1755,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range
|
||||
if (!mMappedIndexData)
|
||||
{
|
||||
log_glerror();
|
||||
LLMemory::logMemoryInfo(true) ;
|
||||
LLMemory::logMemoryInfo(true);
|
||||
|
||||
if(mMappable)
|
||||
{
|
||||
@@ -1650,7 +1770,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range
|
||||
}
|
||||
else
|
||||
{
|
||||
llerrs << "memory allocation for Index data failed. " << llendl ;
|
||||
llerrs << "memory allocation for Index data failed. " << llendl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1681,10 +1801,10 @@ void LLVertexBuffer::unmapBuffer()
|
||||
LLMemType mt2(LLMemType::MTYPE_VERTEX_UNMAP_BUFFER);
|
||||
if (!useVBOs())
|
||||
{
|
||||
return ; //nothing to unmap
|
||||
return; //nothing to unmap
|
||||
}
|
||||
|
||||
bool updated_all = false ;
|
||||
bool updated_all = false;
|
||||
|
||||
if (mMappedData && mVertexLocked)
|
||||
{
|
||||
@@ -1815,10 +1935,10 @@ void LLVertexBuffer::unmapBuffer()
|
||||
glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
|
||||
stop_glerror();
|
||||
|
||||
mMappedIndexData = NULL ;
|
||||
mMappedIndexData = NULL;
|
||||
}
|
||||
|
||||
mIndexLocked = false ;
|
||||
mIndexLocked = false;
|
||||
sMappedCount--;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,8 @@ class LLVBOPool
|
||||
{
|
||||
public:
|
||||
static U32 sBytesPooled;
|
||||
|
||||
static U32 sIndexBytesPooled;
|
||||
|
||||
LLVBOPool(U32 vboUsage, U32 vboType)
|
||||
: mUsage(vboUsage)
|
||||
, mType(vboType)
|
||||
@@ -93,7 +94,7 @@ public:
|
||||
|
||||
//============================================================================
|
||||
// base class
|
||||
class LLPrivateMemoryPool ;
|
||||
class LLPrivateMemoryPool;
|
||||
class LLVertexBuffer : public LLRefCount
|
||||
{
|
||||
public:
|
||||
@@ -269,6 +270,8 @@ public:
|
||||
//for debugging, validate data in given range is valid
|
||||
void validateRange(U32 start, U32 end, U32 count, U32 offset) const;
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
S32 mNumVerts; // Number of vertices allocated
|
||||
S32 mNumIndices; // Number of indices allocated
|
||||
@@ -278,7 +281,9 @@ protected:
|
||||
S32 mSize;
|
||||
S32 mIndicesSize;
|
||||
U32 mTypeMask;
|
||||
S32 mUsage; // GL usage
|
||||
|
||||
const S32 mUsage; // GL usage
|
||||
|
||||
U32 mGLBuffer; // GL VBO handle
|
||||
U32 mGLIndices; // GL IBO handle
|
||||
U32 mGLArray; // GL VAO handle
|
||||
@@ -294,6 +299,7 @@ protected:
|
||||
U32 mEmpty : 1; // if true, client buffer is empty (or NULL). Old values have been discarded.
|
||||
|
||||
mutable bool mMappable; // if true, use memory mapping to upload data (otherwise doublebuffer and use glBufferSubData)
|
||||
|
||||
S32 mOffsets[TYPE_MAX];
|
||||
|
||||
std::vector<MappedRegion> mMappedVertexRegions;
|
||||
@@ -307,7 +313,7 @@ protected:
|
||||
static S32 determineUsage(S32 usage);
|
||||
|
||||
private:
|
||||
static LLPrivateMemoryPool* sPrivatePoolp ;
|
||||
static LLPrivateMemoryPool* sPrivatePoolp;
|
||||
|
||||
public:
|
||||
static S32 sCount;
|
||||
@@ -327,6 +333,9 @@ public:
|
||||
static bool sIBOActive;
|
||||
static U32 sLastMask;
|
||||
static U32 sAllocatedBytes;
|
||||
static U32 sAllocatedIndexBytes;
|
||||
static U32 sVertexCount;
|
||||
static U32 sIndexCount;
|
||||
static U32 sBindCount;
|
||||
static U32 sSetCount;
|
||||
};
|
||||
|
||||
@@ -9829,6 +9829,17 @@
|
||||
<key>Value</key>
|
||||
<integer>1</integer>
|
||||
</map>
|
||||
<key>RenderCompressTextures</key>
|
||||
<map>
|
||||
<key>Comment</key>
|
||||
<string>Enable texture compression on OpenGL 3.0 and later implementations (EXPERIMENTAL, requires restart)</string>
|
||||
<key>Persist</key>
|
||||
<integer>1</integer>
|
||||
<key>Type</key>
|
||||
<string>Boolean</string>
|
||||
<key>Value</key>
|
||||
<integer>0</integer>
|
||||
</map>
|
||||
|
||||
<key>RenderLocalLights</key>
|
||||
<map>
|
||||
|
||||
@@ -35,8 +35,6 @@ uniform sampler2DRect depthMap;
|
||||
|
||||
vec4 diffuseLookup(vec2 texcoord);
|
||||
|
||||
uniform mat4 shadow_matrix[6];
|
||||
uniform vec4 shadow_clip;
|
||||
uniform vec2 screen_res;
|
||||
|
||||
vec3 atmosLighting(vec3 light);
|
||||
|
||||
@@ -35,8 +35,6 @@ uniform sampler2DRect depthMap;
|
||||
uniform sampler2D diffuseMap;
|
||||
|
||||
|
||||
uniform mat4 shadow_matrix[6];
|
||||
uniform vec4 shadow_clip;
|
||||
uniform vec2 screen_res;
|
||||
|
||||
vec3 atmosLighting(vec3 light);
|
||||
|
||||
@@ -34,8 +34,6 @@ out vec4 frag_color;
|
||||
uniform sampler2DRect depthMap;
|
||||
uniform sampler2D diffuseMap;
|
||||
|
||||
uniform mat4 shadow_matrix[6];
|
||||
uniform vec4 shadow_clip;
|
||||
uniform vec2 screen_res;
|
||||
|
||||
vec3 atmosLighting(vec3 light);
|
||||
|
||||
@@ -41,7 +41,6 @@ vec3 atmosAffectDirectionalLight(float lightIntensity);
|
||||
VARYING vec3 vary_position;
|
||||
VARYING vec3 vary_ambient;
|
||||
VARYING vec3 vary_directional;
|
||||
VARYING vec3 vary_normal;
|
||||
VARYING vec3 vary_fragcoord;
|
||||
VARYING vec3 vary_pointlight_col;
|
||||
VARYING vec4 vertex_color;
|
||||
@@ -110,8 +109,7 @@ void main()
|
||||
gl_Position = frag_pos;
|
||||
|
||||
vary_position = pos.xyz;
|
||||
vary_normal = norm;
|
||||
|
||||
|
||||
calcAtmospherics(pos.xyz);
|
||||
|
||||
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
|
||||
|
||||
@@ -48,7 +48,6 @@ VARYING vec3 vary_ambient;
|
||||
VARYING vec3 vary_directional;
|
||||
VARYING vec3 vary_fragcoord;
|
||||
VARYING vec3 vary_position;
|
||||
VARYING vec3 vary_light;
|
||||
VARYING vec3 vary_pointlight_col;
|
||||
|
||||
VARYING vec4 vertex_color;
|
||||
@@ -129,14 +128,11 @@ void main()
|
||||
col.rgb += light_diffuse[7].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[7], light_direction[7], light_attenuation[7].x, light_attenuation[7].y, light_attenuation[7].z);
|
||||
|
||||
vary_pointlight_col = col.rgb*diffuse_color.rgb;
|
||||
|
||||
col.rgb = vec3(0,0,0);
|
||||
|
||||
// Add windlight lights
|
||||
col.rgb = atmosAmbient(vec3(0.));
|
||||
|
||||
vary_light = light_position[0].xyz;
|
||||
|
||||
vary_ambient = col.rgb*diffuse_color.rgb;
|
||||
vary_directional.rgb = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
|
||||
|
||||
|
||||
@@ -30,12 +30,10 @@ out vec4 frag_color;
|
||||
|
||||
uniform sampler2D diffuseMap;
|
||||
|
||||
VARYING vec4 vertex_color;
|
||||
VARYING vec2 vary_texcoord0;
|
||||
|
||||
void main()
|
||||
{
|
||||
//frag_color = vec4(1,1,1,vertex_color.a * texture2D(diffuseMap, vary_texcoord0.xy).a);
|
||||
frag_color = vec4(1,1,1,1);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,8 @@ uniform mat4 modelview_matrix;
|
||||
uniform mat4 texture_matrix0;
|
||||
|
||||
ATTRIBUTE vec3 position;
|
||||
ATTRIBUTE vec4 diffuse_color;
|
||||
ATTRIBUTE vec2 texcoord0;
|
||||
|
||||
VARYING vec4 vertex_color;
|
||||
|
||||
mat4 getObjectSkinnedTransform();
|
||||
|
||||
void main()
|
||||
@@ -42,8 +39,6 @@ void main()
|
||||
mat = modelview_matrix * mat;
|
||||
vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
|
||||
|
||||
vertex_color = diffuse_color;
|
||||
|
||||
vec4 p = projection_matrix * vec4(pos, 1.0);
|
||||
p.z = max(p.z, -p.w+0.01);
|
||||
gl_Position = p;
|
||||
|
||||
@@ -120,7 +120,7 @@ void main()
|
||||
sc -= 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
diff /= w;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
uniform mat4 modelview_projection_matrix;
|
||||
|
||||
ATTRIBUTE vec3 position;
|
||||
ATTRIBUTE vec2 texcoord0;
|
||||
|
||||
// SKY ////////////////////////////////////////////////////////////////////////
|
||||
// The vertex shader for creating the atmospheric sky
|
||||
@@ -34,7 +33,6 @@ ATTRIBUTE vec2 texcoord0;
|
||||
|
||||
// Output parameters
|
||||
VARYING vec4 vary_HazeColor;
|
||||
VARYING vec2 vary_texcoord0;
|
||||
|
||||
// Inputs
|
||||
uniform vec3 camPosLocal;
|
||||
@@ -60,8 +58,7 @@ void main()
|
||||
|
||||
// World / view / projection
|
||||
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
|
||||
vary_texcoord0 = texcoord0;
|
||||
|
||||
|
||||
// Get relative position
|
||||
vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
|
||||
//vec3 P = position.xyz + vec3(0,50,0);
|
||||
|
||||
@@ -146,9 +146,7 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
|
||||
|
||||
vec3 P = inPositionEye;
|
||||
setPositionEye(P);
|
||||
//(TERRAIN) limit altitude
|
||||
// if (P.y > max_y.x) P *= (max_y.x / P.y);
|
||||
// if (P.y < -max_y.x) P *= (-max_y.x / P.y);
|
||||
|
||||
vec3 tmpLightnorm = lightnorm.xyz;
|
||||
|
||||
vec3 Pn = normalize(P);
|
||||
@@ -313,7 +311,7 @@ void main()
|
||||
//add environmentmap
|
||||
vec3 env_vec = env_mat * refnormpersp;
|
||||
col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb,
|
||||
max(spec.a-diffuse.a*2.0, 0.0));
|
||||
max(spec.a-diffuse.a*2.0, 0.0));
|
||||
}
|
||||
|
||||
col = atmosLighting(col);
|
||||
|
||||
@@ -1,336 +0,0 @@
|
||||
/**
|
||||
* @file softenLightF.glsl
|
||||
*
|
||||
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
*/
|
||||
|
||||
|
||||
#extension GL_ARB_texture_rectangle : enable
|
||||
|
||||
uniform sampler2DRect diffuseRect;
|
||||
uniform sampler2DRect specularRect;
|
||||
uniform sampler2DRect normalMap;
|
||||
uniform sampler2DRect depthMap;
|
||||
uniform sampler2D lightFunc;
|
||||
|
||||
uniform float blur_size;
|
||||
uniform float blur_fidelity;
|
||||
|
||||
// Inputs
|
||||
uniform vec4 morphFactor;
|
||||
uniform vec3 camPosLocal;
|
||||
//uniform vec4 camPosWorld;
|
||||
uniform vec4 gamma;
|
||||
uniform vec4 lightnorm;
|
||||
uniform vec4 sunlight_color;
|
||||
uniform vec4 ambient;
|
||||
uniform vec4 blue_horizon;
|
||||
uniform vec4 blue_density;
|
||||
uniform vec4 haze_horizon;
|
||||
uniform vec4 haze_density;
|
||||
uniform vec4 cloud_shadow;
|
||||
uniform vec4 density_multiplier;
|
||||
uniform vec4 distance_multiplier;
|
||||
uniform vec4 max_y;
|
||||
uniform vec4 glow;
|
||||
uniform float scene_light_strength;
|
||||
uniform vec3 env_mat[3];
|
||||
//uniform mat4 shadow_matrix[3];
|
||||
//uniform vec4 shadow_clip;
|
||||
uniform mat3 ssao_effect_mat;
|
||||
|
||||
VARYING vec4 vary_light;
|
||||
VARYING vec2 vary_fragcoord;
|
||||
|
||||
vec3 vary_PositionEye;
|
||||
|
||||
vec3 vary_SunlitColor;
|
||||
vec3 vary_AmblitColor;
|
||||
vec3 vary_AdditiveColor;
|
||||
vec3 vary_AtmosAttenuation;
|
||||
|
||||
uniform mat4 inv_proj;
|
||||
uniform vec2 screen_res;
|
||||
|
||||
vec4 getPosition_d(vec2 pos_screen, float depth)
|
||||
{
|
||||
vec2 sc = pos_screen.xy*2.0;
|
||||
sc /= screen_res;
|
||||
sc -= vec2(1.0,1.0);
|
||||
vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
|
||||
vec4 pos = inv_proj * ndc;
|
||||
pos /= pos.w;
|
||||
pos.w = 1.0;
|
||||
return pos;
|
||||
}
|
||||
|
||||
vec4 getPosition(vec2 pos_screen)
|
||||
{ //get position in screen space (world units) given window coordinate and depth map
|
||||
float depth = texture2DRect(depthMap, pos_screen.xy).a;
|
||||
return getPosition_d(pos_screen, depth);
|
||||
}
|
||||
|
||||
vec3 getPositionEye()
|
||||
{
|
||||
return vary_PositionEye;
|
||||
}
|
||||
vec3 getSunlitColor()
|
||||
{
|
||||
return vary_SunlitColor;
|
||||
}
|
||||
vec3 getAmblitColor()
|
||||
{
|
||||
return vary_AmblitColor;
|
||||
}
|
||||
vec3 getAdditiveColor()
|
||||
{
|
||||
return vary_AdditiveColor;
|
||||
}
|
||||
vec3 getAtmosAttenuation()
|
||||
{
|
||||
return vary_AtmosAttenuation;
|
||||
}
|
||||
|
||||
|
||||
void setPositionEye(vec3 v)
|
||||
{
|
||||
vary_PositionEye = v;
|
||||
}
|
||||
|
||||
void setSunlitColor(vec3 v)
|
||||
{
|
||||
vary_SunlitColor = v;
|
||||
}
|
||||
|
||||
void setAmblitColor(vec3 v)
|
||||
{
|
||||
vary_AmblitColor = v;
|
||||
}
|
||||
|
||||
void setAdditiveColor(vec3 v)
|
||||
{
|
||||
vary_AdditiveColor = v;
|
||||
}
|
||||
|
||||
void setAtmosAttenuation(vec3 v)
|
||||
{
|
||||
vary_AtmosAttenuation = v;
|
||||
}
|
||||
|
||||
void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
|
||||
|
||||
vec3 P = inPositionEye;
|
||||
setPositionEye(P);
|
||||
|
||||
//(TERRAIN) limit altitude
|
||||
if (P.y > max_y.x) P *= (max_y.x / P.y);
|
||||
if (P.y < -max_y.x) P *= (-max_y.x / P.y);
|
||||
|
||||
vec3 tmpLightnorm = lightnorm.xyz;
|
||||
|
||||
vec3 Pn = normalize(P);
|
||||
float Plen = length(P);
|
||||
|
||||
vec4 temp1 = vec4(0);
|
||||
vec3 temp2 = vec3(0);
|
||||
vec4 blue_weight;
|
||||
vec4 haze_weight;
|
||||
vec4 sunlight = sunlight_color;
|
||||
vec4 light_atten;
|
||||
|
||||
//sunlight attenuation effect (hue and brightness) due to atmosphere
|
||||
//this is used later for sunlight modulation at various altitudes
|
||||
light_atten = (blue_density * 1.0 + vec4(haze_density.r) * 0.25) * (density_multiplier.x * max_y.x);
|
||||
//I had thought blue_density and haze_density should have equal weighting,
|
||||
//but attenuation due to haze_density tends to seem too strong
|
||||
|
||||
temp1 = blue_density + vec4(haze_density.r);
|
||||
blue_weight = blue_density / temp1;
|
||||
haze_weight = vec4(haze_density.r) / temp1;
|
||||
|
||||
//(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain)
|
||||
temp2.y = max(0.0, tmpLightnorm.y);
|
||||
temp2.y = 1. / temp2.y;
|
||||
sunlight *= exp( - light_atten * temp2.y);
|
||||
|
||||
// main atmospheric scattering line integral
|
||||
temp2.z = Plen * density_multiplier.x;
|
||||
|
||||
// Transparency (-> temp1)
|
||||
// ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier.x in a variable because the ati
|
||||
// compiler gets confused.
|
||||
temp1 = exp(-temp1 * temp2.z * distance_multiplier.x);
|
||||
|
||||
//final atmosphere attenuation factor
|
||||
setAtmosAttenuation(temp1.rgb);
|
||||
|
||||
//compute haze glow
|
||||
//(can use temp2.x as temp because we haven't used it yet)
|
||||
temp2.x = dot(Pn, tmpLightnorm.xyz);
|
||||
temp2.x = 1. - temp2.x;
|
||||
//temp2.x is 0 at the sun and increases away from sun
|
||||
temp2.x = max(temp2.x, .03); //was glow.y
|
||||
//set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
|
||||
temp2.x *= glow.x;
|
||||
//higher glow.x gives dimmer glow (because next step is 1 / "angle")
|
||||
temp2.x = pow(temp2.x, glow.z);
|
||||
//glow.z should be negative, so we're doing a sort of (1 / "angle") function
|
||||
|
||||
//add "minimum anti-solar illumination"
|
||||
temp2.x += .25;
|
||||
|
||||
//increase ambient when there are more clouds
|
||||
vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5;
|
||||
|
||||
/* decrease value and saturation (that in HSV, not HSL) for occluded areas
|
||||
* // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html
|
||||
* // The following line of code performs the equivalent of:
|
||||
* float ambAlpha = tmpAmbient.a;
|
||||
* float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis
|
||||
* vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue);
|
||||
* tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha);
|
||||
*/
|
||||
tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
|
||||
|
||||
//haze color
|
||||
setAdditiveColor(
|
||||
vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow.x) + tmpAmbient)
|
||||
+ (haze_horizon.r * haze_weight) * (sunlight*(1.-cloud_shadow.x) * temp2.x
|
||||
+ tmpAmbient)));
|
||||
|
||||
//brightness of surface both sunlight and ambient
|
||||
setSunlitColor(vec3(sunlight * .5));
|
||||
setAmblitColor(vec3(tmpAmbient * .25));
|
||||
setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1));
|
||||
}
|
||||
|
||||
vec3 atmosLighting(vec3 light)
|
||||
{
|
||||
light *= getAtmosAttenuation().r;
|
||||
light += getAdditiveColor();
|
||||
return (2.0 * light);
|
||||
}
|
||||
|
||||
vec3 atmosTransport(vec3 light) {
|
||||
light *= getAtmosAttenuation().r;
|
||||
light += getAdditiveColor() * 2.0;
|
||||
return light;
|
||||
}
|
||||
vec3 atmosGetDiffuseSunlightColor()
|
||||
{
|
||||
return getSunlitColor();
|
||||
}
|
||||
|
||||
vec3 scaleDownLight(vec3 light)
|
||||
{
|
||||
return (light / scene_light_strength );
|
||||
}
|
||||
|
||||
vec3 scaleUpLight(vec3 light)
|
||||
{
|
||||
return (light * scene_light_strength);
|
||||
}
|
||||
|
||||
vec3 atmosAmbient(vec3 light)
|
||||
{
|
||||
return getAmblitColor() + light / 2.0;
|
||||
}
|
||||
|
||||
vec3 atmosAffectDirectionalLight(float lightIntensity)
|
||||
{
|
||||
return getSunlitColor() * lightIntensity;
|
||||
}
|
||||
|
||||
vec3 scaleSoftClip(vec3 light)
|
||||
{
|
||||
//soft clip effect:
|
||||
light = 1. - clamp(light, vec3(0.), vec3(1.));
|
||||
light = 1. - pow(light, gamma.xxx);
|
||||
|
||||
return light;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 tc = vary_fragcoord.xy;
|
||||
float depth = texture2DRect(depthMap, tc.xy).a;
|
||||
vec3 pos = getPosition_d(tc, depth).xyz;
|
||||
vec3 norm = texture2DRect(normalMap, tc).xyz;
|
||||
norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
|
||||
//vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
|
||||
|
||||
float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
|
||||
|
||||
vec4 diffuse = texture2DRect(diffuseRect, tc);
|
||||
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
|
||||
|
||||
calcAtmospherics(pos.xyz, 1.0);
|
||||
|
||||
vec3 col = atmosAmbient(vec3(0));
|
||||
col += atmosAffectDirectionalLight(max(min(da, 1.0), diffuse.a));
|
||||
|
||||
col *= diffuse.rgb;
|
||||
|
||||
if (spec.a > 0.0) // specular reflection
|
||||
{
|
||||
// the old infinite-sky shiny reflection
|
||||
//
|
||||
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
|
||||
float sa = dot(refnormpersp, vary_light.xyz);
|
||||
vec3 dumbshiny = vary_SunlitColor*texture2D(lightFunc, vec2(sa, spec.a)).a;
|
||||
|
||||
/*
|
||||
// screen-space cheap fakey reflection map
|
||||
//
|
||||
vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
|
||||
depth -= 0.5; // unbias depth
|
||||
// first figure out where we'll make our 2D guess from
|
||||
vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
|
||||
// Offset the guess source a little according to a trivial
|
||||
// checkerboard dither function and spec.a.
|
||||
// This is meant to be similar to sampling a blurred version
|
||||
// of the diffuse map. LOD would be better in that regard.
|
||||
// The goal of the blur is to soften reflections in surfaces
|
||||
// with low shinyness, and also to disguise our lameness.
|
||||
float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
|
||||
float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5);
|
||||
ref2d += vec2(checkoffset, checkoffset);
|
||||
ref2d += tc.xy; // use as offset from destination
|
||||
// Get attributes from the 2D guess point.
|
||||
// We average two samples of diffuse (not of anything else) per
|
||||
// pixel to try to reduce aliasing some more.
|
||||
vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb +
|
||||
texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);
|
||||
float refdepth = texture2DRect(depthMap, ref2d).a;
|
||||
vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
|
||||
vec3 refn = texture2DRect(normalMap, ref2d).rgb;
|
||||
refn = normalize(vec3((refn.xy-0.5)*2.0,refn.z)); // unpack norm
|
||||
// figure out how appropriate our guess actually was
|
||||
float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
|
||||
// darken reflections from points which face away from the reflected ray - our guess was a back-face
|
||||
//refapprop *= step(dot(refnorm, refn), 0.0);
|
||||
refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
|
||||
// get appropriate light strength for guess-point.
|
||||
// reflect light direction to increase the illusion that
|
||||
// these are reflections.
|
||||
vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
|
||||
float reflit = max(dot(refn, reflight.xyz), 0.0);
|
||||
// apply sun color to guess-point, dampen according to inappropriateness of guess
|
||||
float refmod = min(refapprop, reflit);
|
||||
vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
|
||||
vec3 ssshiny = (refprod * spec.a);
|
||||
ssshiny *= 0.3; // dampen it even more
|
||||
*/
|
||||
vec3 ssshiny = vec3(0,0,0);
|
||||
|
||||
// add the two types of shiny together
|
||||
col += (ssshiny + dumbshiny) * spec.rgb;
|
||||
}
|
||||
|
||||
col = atmosLighting(col);
|
||||
col = scaleSoftClip(col);
|
||||
|
||||
gl_FragColor.rgb = col;
|
||||
gl_FragColor.a = 0.0;
|
||||
}
|
||||
@@ -39,8 +39,6 @@ uniform sampler2D noiseMap;
|
||||
|
||||
|
||||
// Inputs
|
||||
uniform mat4 shadow_matrix[6];
|
||||
uniform vec4 shadow_clip;
|
||||
uniform float ssao_radius;
|
||||
uniform float ssao_max_radius;
|
||||
uniform float ssao_factor;
|
||||
@@ -51,9 +49,6 @@ VARYING vec2 vary_fragcoord;
|
||||
uniform mat4 inv_proj;
|
||||
uniform vec2 screen_res;
|
||||
|
||||
uniform float shadow_bias;
|
||||
uniform float shadow_offset;
|
||||
|
||||
vec4 getPosition(vec2 pos_screen)
|
||||
{
|
||||
float depth = texture2DRect(depthMap, pos_screen.xy).r;
|
||||
|
||||
@@ -37,21 +37,24 @@ VARYING vec4 vary_texcoord1;
|
||||
VARYING vec4 vary_texcoord2;
|
||||
VARYING vec4 vary_texcoord3;
|
||||
|
||||
vec4 kern = vec4(.25,.5,.8,1.0);
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
vec4 col = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
col += kern.x * texture2D(diffuseMap, vary_texcoord0.xy);
|
||||
col += kern.y * texture2D(diffuseMap, vary_texcoord1.xy);
|
||||
col += kern.z * texture2D(diffuseMap, vary_texcoord2.xy);
|
||||
col += kern.w * texture2D(diffuseMap, vary_texcoord3.xy);
|
||||
col += kern.w * texture2D(diffuseMap, vary_texcoord0.zw);
|
||||
col += kern.z * texture2D(diffuseMap, vary_texcoord1.zw);
|
||||
col += kern.y * texture2D(diffuseMap, vary_texcoord2.zw);
|
||||
col += kern.x * texture2D(diffuseMap, vary_texcoord3.zw);
|
||||
// ATI compiler falls down on array initialization.
|
||||
float kern[8];
|
||||
kern[0] = 0.25; kern[1] = 0.5; kern[2] = 0.8; kern[3] = 1.0;
|
||||
kern[4] = 1.0; kern[5] = 0.8; kern[6] = 0.5; kern[7] = 0.25;
|
||||
|
||||
col += kern[0] * texture2D(diffuseMap, vary_texcoord0.xy);
|
||||
col += kern[1] * texture2D(diffuseMap, vary_texcoord1.xy);
|
||||
col += kern[2] * texture2D(diffuseMap, vary_texcoord2.xy);
|
||||
col += kern[3] * texture2D(diffuseMap, vary_texcoord3.xy);
|
||||
col += kern[4] * texture2D(diffuseMap, vary_texcoord0.zw);
|
||||
col += kern[5] * texture2D(diffuseMap, vary_texcoord1.zw);
|
||||
col += kern[6] * texture2D(diffuseMap, vary_texcoord2.zw);
|
||||
col += kern[7] * texture2D(diffuseMap, vary_texcoord3.zw);
|
||||
|
||||
frag_color = vec4(col.rgb * glowStrength, col.a);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,26 @@
|
||||
/**
|
||||
* @file waterFogF.glsl
|
||||
*
|
||||
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
|
||||
* $License$
|
||||
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
|
||||
* Second Life Viewer Source Code
|
||||
* Copyright (C) 2007, 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$
|
||||
*/
|
||||
|
||||
|
||||
@@ -32,7 +50,7 @@ vec4 applyWaterFog(vec4 color)
|
||||
float depth = length(getPositionEye() - int_v);
|
||||
|
||||
//get "thickness" of water
|
||||
float l = min(max(depth, 0.1),50.0);
|
||||
float l = max(depth, 0.1);
|
||||
|
||||
float kd = waterFogDensity;
|
||||
float ks = waterFogKS;
|
||||
|
||||
@@ -80,7 +80,7 @@ void main()
|
||||
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
|
||||
frag *= screen_res;
|
||||
|
||||
float shadow = 1.0;
|
||||
float shadow = 0.0;
|
||||
vec4 pos = vec4(vary_position, 1.0);
|
||||
|
||||
vec4 spos = pos;
|
||||
@@ -89,31 +89,65 @@ void main()
|
||||
{
|
||||
vec4 lpos;
|
||||
|
||||
if (spos.z < -shadow_clip.z)
|
||||
vec4 near_split = shadow_clip*-0.75;
|
||||
vec4 far_split = shadow_clip*-1.25;
|
||||
vec4 transition_domain = near_split-far_split;
|
||||
float weight = 0.0;
|
||||
|
||||
if (spos.z < near_split.z)
|
||||
{
|
||||
lpos = shadow_matrix[3]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap3, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
|
||||
shadow += pcfShadow(shadowMap3, lpos, 0.25)*w;
|
||||
weight += w;
|
||||
shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
|
||||
}
|
||||
else if (spos.z < -shadow_clip.y)
|
||||
|
||||
if (spos.z < near_split.y && spos.z > far_split.z)
|
||||
{
|
||||
lpos = shadow_matrix[2]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap2, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
|
||||
w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
|
||||
shadow += pcfShadow(shadowMap2, lpos, 0.75)*w;
|
||||
weight += w;
|
||||
}
|
||||
else if (spos.z < -shadow_clip.x)
|
||||
|
||||
if (spos.z < near_split.x && spos.z > far_split.y)
|
||||
{
|
||||
lpos = shadow_matrix[1]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap1, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
|
||||
w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
|
||||
shadow += pcfShadow(shadowMap1, lpos, 0.75)*w;
|
||||
weight += w;
|
||||
}
|
||||
else
|
||||
|
||||
if (spos.z > far_split.x)
|
||||
{
|
||||
lpos = shadow_matrix[0]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap0, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
|
||||
|
||||
shadow += pcfShadow(shadowMap0, lpos, 1.0)*w;
|
||||
weight += w;
|
||||
}
|
||||
|
||||
|
||||
shadow /= weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
shadow = 1.0;
|
||||
}
|
||||
|
||||
vec4 diff = diffuseLookup(vary_texcoord0.xy);
|
||||
|
||||
@@ -93,7 +93,7 @@ void main()
|
||||
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
|
||||
frag *= screen_res;
|
||||
|
||||
float shadow = 1.0;
|
||||
float shadow = 0.0;
|
||||
vec4 pos = vec4(vary_position, 1.0);
|
||||
|
||||
vec4 spos = pos;
|
||||
@@ -102,33 +102,68 @@ void main()
|
||||
{
|
||||
vec4 lpos;
|
||||
|
||||
if (spos.z < -shadow_clip.z)
|
||||
vec4 near_split = shadow_clip*-0.75;
|
||||
vec4 far_split = shadow_clip*-1.25;
|
||||
vec4 transition_domain = near_split-far_split;
|
||||
float weight = 0.0;
|
||||
|
||||
if (spos.z < near_split.z)
|
||||
{
|
||||
lpos = shadow_matrix[3]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap3, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
|
||||
shadow += pcfShadow(shadowMap3, lpos, 0.25)*w;
|
||||
weight += w;
|
||||
shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
|
||||
}
|
||||
else if (spos.z < -shadow_clip.y)
|
||||
|
||||
if (spos.z < near_split.y && spos.z > far_split.z)
|
||||
{
|
||||
lpos = shadow_matrix[2]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap2, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
|
||||
w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
|
||||
shadow += pcfShadow(shadowMap2, lpos, 0.75)*w;
|
||||
weight += w;
|
||||
}
|
||||
else if (spos.z < -shadow_clip.x)
|
||||
|
||||
if (spos.z < near_split.x && spos.z > far_split.y)
|
||||
{
|
||||
lpos = shadow_matrix[1]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap1, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
|
||||
w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
|
||||
shadow += pcfShadow(shadowMap1, lpos, 0.75)*w;
|
||||
weight += w;
|
||||
}
|
||||
else
|
||||
|
||||
if (spos.z > far_split.x)
|
||||
{
|
||||
lpos = shadow_matrix[0]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap0, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
|
||||
|
||||
shadow += pcfShadow(shadowMap0, lpos, 1.0)*w;
|
||||
weight += w;
|
||||
}
|
||||
|
||||
|
||||
shadow /= weight;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
shadow = 1.0;
|
||||
}
|
||||
|
||||
vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
|
||||
|
||||
vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, vertex_color.a);
|
||||
|
||||
@@ -92,7 +92,7 @@ void main()
|
||||
vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
|
||||
frag *= screen_res;
|
||||
|
||||
float shadow = 1.0;
|
||||
float shadow = 0.0;
|
||||
vec4 pos = vec4(vary_position, 1.0);
|
||||
|
||||
vec4 spos = pos;
|
||||
@@ -101,31 +101,65 @@ void main()
|
||||
{
|
||||
vec4 lpos;
|
||||
|
||||
if (spos.z < -shadow_clip.z)
|
||||
vec4 near_split = shadow_clip*-0.75;
|
||||
vec4 far_split = shadow_clip*-1.25;
|
||||
vec4 transition_domain = near_split-far_split;
|
||||
float weight = 0.0;
|
||||
|
||||
if (spos.z < near_split.z)
|
||||
{
|
||||
lpos = shadow_matrix[3]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap3, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
|
||||
shadow += pcfShadow(shadowMap3, lpos, 0.25)*w;
|
||||
weight += w;
|
||||
shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
|
||||
}
|
||||
else if (spos.z < -shadow_clip.y)
|
||||
|
||||
if (spos.z < near_split.y && spos.z > far_split.z)
|
||||
{
|
||||
lpos = shadow_matrix[2]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap2, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
|
||||
w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
|
||||
shadow += pcfShadow(shadowMap2, lpos, 0.75)*w;
|
||||
weight += w;
|
||||
}
|
||||
else if (spos.z < -shadow_clip.x)
|
||||
|
||||
if (spos.z < near_split.x && spos.z > far_split.y)
|
||||
{
|
||||
lpos = shadow_matrix[1]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap1, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
|
||||
w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
|
||||
shadow += pcfShadow(shadowMap1, lpos, 0.75)*w;
|
||||
weight += w;
|
||||
}
|
||||
else
|
||||
|
||||
if (spos.z > far_split.x)
|
||||
{
|
||||
lpos = shadow_matrix[0]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap0, lpos, 1.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
|
||||
|
||||
shadow += pcfShadow(shadowMap0, lpos, 1.0)*w;
|
||||
weight += w;
|
||||
}
|
||||
|
||||
|
||||
shadow /= weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
shadow = 1.0;
|
||||
}
|
||||
|
||||
vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy);
|
||||
|
||||
@@ -319,7 +319,7 @@ void main()
|
||||
//add environmentmap
|
||||
vec3 env_vec = env_mat * refnormpersp;
|
||||
col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb,
|
||||
max(spec.a-diffuse.a*2.0, 0.0));
|
||||
max(spec.a-diffuse.a*2.0, 0.0));
|
||||
}
|
||||
|
||||
col = atmosLighting(col);
|
||||
|
||||
@@ -135,7 +135,7 @@ void main()
|
||||
return;
|
||||
}*/
|
||||
|
||||
float shadow = 1.0;
|
||||
float shadow = 0.0;
|
||||
float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz));
|
||||
|
||||
vec3 shadow_pos = pos.xyz + displace*norm;
|
||||
@@ -154,32 +154,62 @@ void main()
|
||||
{
|
||||
vec4 lpos;
|
||||
|
||||
if (spos.z < -shadow_clip.z)
|
||||
vec4 near_split = shadow_clip*-0.75;
|
||||
vec4 far_split = shadow_clip*-1.25;
|
||||
vec4 transition_domain = near_split-far_split;
|
||||
float weight = 0.0;
|
||||
|
||||
if (spos.z < near_split.z)
|
||||
{
|
||||
lpos = shadow_matrix[3]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap3, lpos, 0.25);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
|
||||
shadow += pcfShadow(shadowMap3, lpos, 0.25)*w;
|
||||
weight += w;
|
||||
shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
|
||||
}
|
||||
else if (spos.z < -shadow_clip.y)
|
||||
|
||||
if (spos.z < near_split.y && spos.z > far_split.z)
|
||||
{
|
||||
lpos = shadow_matrix[2]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap2, lpos, 0.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
|
||||
w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
|
||||
shadow += pcfShadow(shadowMap2, lpos, 0.75)*w;
|
||||
weight += w;
|
||||
}
|
||||
else if (spos.z < -shadow_clip.x)
|
||||
|
||||
if (spos.z < near_split.x && spos.z > far_split.y)
|
||||
{
|
||||
lpos = shadow_matrix[1]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap1, lpos, 0.75);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
|
||||
w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
|
||||
shadow += pcfShadow(shadowMap1, lpos, 0.75)*w;
|
||||
weight += w;
|
||||
}
|
||||
else
|
||||
|
||||
if (spos.z > far_split.x)
|
||||
{
|
||||
lpos = shadow_matrix[0]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap0, lpos, 1.0);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
|
||||
|
||||
shadow += pcfShadow(shadowMap0, lpos, 1.0)*w;
|
||||
weight += w;
|
||||
}
|
||||
|
||||
|
||||
shadow /= weight;
|
||||
|
||||
// take the most-shadowed value out of these two:
|
||||
// * the blurred sun shadow in the light (shadow) map
|
||||
// * an unblurred dot product between the sun and this norm
|
||||
|
||||
@@ -196,7 +196,7 @@ void main()
|
||||
return;
|
||||
}*/
|
||||
|
||||
float shadow = 1.0;
|
||||
float shadow = 0.0;
|
||||
float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz));
|
||||
|
||||
vec3 shadow_pos = pos.xyz + displace*norm;
|
||||
@@ -214,33 +214,63 @@ void main()
|
||||
else
|
||||
{
|
||||
vec4 lpos;
|
||||
|
||||
if (spos.z < -shadow_clip.z)
|
||||
|
||||
vec4 near_split = shadow_clip*-0.75;
|
||||
vec4 far_split = shadow_clip*-1.25;
|
||||
vec4 transition_domain = near_split-far_split;
|
||||
float weight = 0.0;
|
||||
|
||||
if (spos.z < near_split.z)
|
||||
{
|
||||
lpos = shadow_matrix[3]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap3, lpos, 0.25);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.z, 0.0)/transition_domain.z;
|
||||
shadow += pcfShadow(shadowMap3, lpos, 0.25)*w;
|
||||
weight += w;
|
||||
shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
|
||||
}
|
||||
else if (spos.z < -shadow_clip.y)
|
||||
|
||||
if (spos.z < near_split.y && spos.z > far_split.z)
|
||||
{
|
||||
lpos = shadow_matrix[2]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap2, lpos, 0.5);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.y, 0.0)/transition_domain.y;
|
||||
w -= max(near_split.z-spos.z, 0.0)/transition_domain.z;
|
||||
shadow += pcfShadow(shadowMap2, lpos, 0.75)*w;
|
||||
weight += w;
|
||||
}
|
||||
else if (spos.z < -shadow_clip.x)
|
||||
|
||||
if (spos.z < near_split.x && spos.z > far_split.y)
|
||||
{
|
||||
lpos = shadow_matrix[1]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap1, lpos, 0.75);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(spos.z-far_split.x, 0.0)/transition_domain.x;
|
||||
w -= max(near_split.y-spos.z, 0.0)/transition_domain.y;
|
||||
shadow += pcfShadow(shadowMap1, lpos, 0.75)*w;
|
||||
weight += w;
|
||||
}
|
||||
else
|
||||
|
||||
if (spos.z > far_split.x)
|
||||
{
|
||||
lpos = shadow_matrix[0]*spos;
|
||||
lpos.xy *= shadow_res;
|
||||
shadow = pcfShadow(shadowMap0, lpos, 1.0);
|
||||
|
||||
float w = 1.0;
|
||||
w -= max(near_split.x-spos.z, 0.0)/transition_domain.x;
|
||||
|
||||
shadow += pcfShadow(shadowMap0, lpos, 1.0)*w;
|
||||
weight += w;
|
||||
}
|
||||
|
||||
|
||||
shadow /= weight;
|
||||
|
||||
// take the most-shadowed value out of these two:
|
||||
// * the blurred sun shadow in the light (shadow) map
|
||||
// * an unblurred dot product between the sun and this norm
|
||||
|
||||
@@ -85,7 +85,6 @@ void main()
|
||||
vec4 sunlight = sunlight_color;
|
||||
vec4 light_atten;
|
||||
|
||||
|
||||
// Sunlight attenuation effect (hue and brightness) due to atmosphere
|
||||
// this is used later for sunlight modulation at various altitudes
|
||||
light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y);
|
||||
|
||||
@@ -481,6 +481,7 @@ static void settings_to_globals()
|
||||
|
||||
LLRender::sGLCoreProfile = gSavedSettings.getBOOL("RenderGLCoreProfile");
|
||||
LLImageGL::sGlobalUseAnisotropic = gSavedSettings.getBOOL("RenderAnisotropic");
|
||||
LLImageGL::sCompressTextures = gSavedSettings.getBOOL("RenderCompressTextures");
|
||||
LLVOVolume::sLODFactor = gSavedSettings.getF32("RenderVolumeLODFactor");
|
||||
LLVOVolume::sDistanceFactor = 1.f-LLVOVolume::sLODFactor * 0.1f;
|
||||
LLVolumeImplFlexible::sUpdateFactor = gSavedSettings.getF32("RenderFlexTimeFactor");
|
||||
@@ -500,7 +501,7 @@ static void settings_to_globals()
|
||||
gAgentPilot.mNumRuns = gSavedSettings.getS32("StatsNumRuns");
|
||||
gAgentPilot.mQuitAfterRuns = gSavedSettings.getBOOL("StatsQuitAfterRuns");
|
||||
gAgent.setHideGroupTitle(gSavedSettings.getBOOL("RenderHideGroupTitle"));
|
||||
|
||||
|
||||
gDebugWindowProc = gSavedSettings.getBOOL("DebugWindowProc");
|
||||
gAllowIdleAFK = gSavedSettings.getBOOL("AllowIdleAFK");
|
||||
gAllowTapTapHoldRun = gSavedSettings.getBOOL("AllowTapTapHoldRun");
|
||||
|
||||
@@ -1155,6 +1155,8 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
|
||||
return;
|
||||
}
|
||||
|
||||
llassert(LLPipeline::sImpostorRender || !avatarp->isVisuallyMuted());
|
||||
|
||||
/*if (single_avatar && avatarp->mSpecialRenderMode >= 1) // 1=anim preview, 2=image preview, 3=morph view
|
||||
{
|
||||
gPipeline.enableLightsAvatarEdit(LLColor4(.5f, .5f, .5f, 1.f));
|
||||
|
||||
@@ -1342,7 +1342,6 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
|
||||
// immediately assign bump to a global smart pointer in case some local smart pointer
|
||||
// accidentally releases it.
|
||||
LLPointer<LLViewerTexture> bump = LLViewerTextureManager::getLocalTexture( TRUE );
|
||||
|
||||
|
||||
if (!LLPipeline::sRenderDeferred)
|
||||
{
|
||||
@@ -1352,6 +1351,10 @@ void LLBumpImageList::onSourceLoaded( BOOL success, LLViewerTexture *src_vi, LLI
|
||||
}
|
||||
else
|
||||
{ //convert to normal map
|
||||
|
||||
//disable compression on normal maps to prevent errors below
|
||||
bump->getGLTexture()->setAllowCompression(false);
|
||||
|
||||
{
|
||||
LLFastTimer t(FTM_BUMP_SOURCE_CREATE);
|
||||
bump->setExplicitFormat(GL_RGBA8, GL_ALPHA);
|
||||
|
||||
@@ -1100,6 +1100,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
||||
if (success)
|
||||
{
|
||||
std::string fragment;
|
||||
std::string vertex = "deferred/sunLightV.glsl";
|
||||
|
||||
if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
|
||||
{
|
||||
@@ -1108,11 +1109,15 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
||||
else
|
||||
{
|
||||
fragment = "deferred/sunLightF.glsl";
|
||||
if (mVertexShaderLevel[SHADER_DEFERRED] == 1)
|
||||
{ //no shadows, no SSAO, no frag coord
|
||||
vertex = "deferred/sunLightNoFragCoordV.glsl";
|
||||
}
|
||||
}
|
||||
|
||||
gDeferredSunProgram.mName = "Deferred Sun Shader";
|
||||
gDeferredSunProgram.mShaderFiles.clear();
|
||||
gDeferredSunProgram.mShaderFiles.push_back(make_pair("deferred/sunLightV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredSunProgram.mShaderFiles.push_back(make_pair(vertex, GL_VERTEX_SHADER_ARB));
|
||||
gDeferredSunProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB));
|
||||
gDeferredSunProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
|
||||
success = gDeferredSunProgram.createShader(NULL, NULL);
|
||||
@@ -1296,7 +1301,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
||||
gDeferredAvatarAlphaProgram.mFeatures.isAlphaLighting = true;
|
||||
gDeferredAvatarAlphaProgram.mFeatures.disableTextureIndex = true;
|
||||
gDeferredAvatarAlphaProgram.mShaderFiles.clear();
|
||||
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaNoColorV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredAvatarAlphaProgram.mShaderFiles.push_back(make_pair("deferred/alphaNonIndexedNoColorF.glsl", GL_FRAGMENT_SHADER_ARB));
|
||||
gDeferredAvatarAlphaProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
|
||||
|
||||
@@ -1320,7 +1325,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
||||
{
|
||||
gDeferredPostProgram.mName = "Deferred Post Shader";
|
||||
gDeferredPostProgram.mShaderFiles.clear();
|
||||
gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredF.glsl", GL_FRAGMENT_SHADER_ARB));
|
||||
gDeferredPostProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
|
||||
success = gDeferredPostProgram.createShader(NULL, NULL);
|
||||
@@ -1330,7 +1335,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
||||
{
|
||||
gDeferredCoFProgram.mName = "Deferred CoF Shader";
|
||||
gDeferredCoFProgram.mShaderFiles.clear();
|
||||
gDeferredCoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredCoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredCoFProgram.mShaderFiles.push_back(make_pair("deferred/cofF.glsl", GL_FRAGMENT_SHADER_ARB));
|
||||
gDeferredCoFProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
|
||||
success = gDeferredCoFProgram.createShader(NULL, NULL);
|
||||
@@ -1340,7 +1345,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
||||
{
|
||||
gDeferredDoFCombineProgram.mName = "Deferred DoFCombine Shader";
|
||||
gDeferredDoFCombineProgram.mShaderFiles.clear();
|
||||
gDeferredDoFCombineProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredDoFCombineProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredDoFCombineProgram.mShaderFiles.push_back(make_pair("deferred/dofCombineF.glsl", GL_FRAGMENT_SHADER_ARB));
|
||||
gDeferredDoFCombineProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
|
||||
success = gDeferredDoFCombineProgram.createShader(NULL, NULL);
|
||||
@@ -1350,7 +1355,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
|
||||
{
|
||||
gDeferredPostNoDoFProgram.mName = "Deferred Post Shader";
|
||||
gDeferredPostNoDoFProgram.mShaderFiles.clear();
|
||||
gDeferredPostNoDoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredPostNoDoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER_ARB));
|
||||
gDeferredPostNoDoFProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoDoFF.glsl", GL_FRAGMENT_SHADER_ARB));
|
||||
gDeferredPostNoDoFProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
|
||||
success = gDeferredPostNoDoFProgram.createShader(NULL, NULL);
|
||||
|
||||
@@ -3357,10 +3357,14 @@ LLViewerMediaTexture::LLViewerMediaTexture(const LLUUID& id, BOOL usemipmaps, LL
|
||||
sMediaMap.insert(std::make_pair(id, this));
|
||||
|
||||
mGLTexturep = gl_image ;
|
||||
|
||||
if(mGLTexturep.isNull())
|
||||
{
|
||||
generateGLTexture() ;
|
||||
}
|
||||
|
||||
mGLTexturep->setAllowCompression(false);
|
||||
|
||||
mGLTexturep->setNeedsAlphaAndPickMask(FALSE) ;
|
||||
|
||||
mIsPlaying = FALSE ;
|
||||
|
||||
@@ -273,6 +273,9 @@ protected:
|
||||
void reorganizeVolumeList() ;
|
||||
void setTexelsPerImage();
|
||||
private:
|
||||
friend class LLBumpImageList;
|
||||
friend class LLUIImageList;
|
||||
|
||||
//note: do not make this function public.
|
||||
/*virtual*/ LLImageGL* getGLTexture() const ;
|
||||
virtual void switchToCachedImage();
|
||||
|
||||
@@ -1455,6 +1455,9 @@ LLUIImagePtr LLUIImageList::loadUIImage(LLViewerFetchedTexture* imagep, const st
|
||||
|
||||
imagep->setAddressMode(LLTexUnit::TAM_CLAMP);
|
||||
|
||||
//don't compress UI images
|
||||
imagep->getGLTexture()->setAllowCompression(false);
|
||||
|
||||
//all UI images are non-deletable
|
||||
imagep->setNoDelete();
|
||||
|
||||
|
||||
@@ -512,7 +512,10 @@ public:
|
||||
|
||||
}
|
||||
|
||||
addText(xpos, ypos, llformat("%d MB Vertex Data (%d MB Pooled)", LLVertexBuffer::sAllocatedBytes/(1024*1024), LLVBOPool::sBytesPooled/(1024*1024)));
|
||||
addText(xpos, ypos, llformat("%d MB Index Data (%d MB Pooled, %d KIndices)", LLVertexBuffer::sAllocatedIndexBytes/(1024*1024), LLVBOPool::sIndexBytesPooled/(1024*1024), LLVertexBuffer::sIndexCount/1024));
|
||||
ypos += y_inc;
|
||||
|
||||
addText(xpos, ypos, llformat("%d MB Vertex Data (%d MB Pooled, %d KVerts)", LLVertexBuffer::sAllocatedBytes/(1024*1024), LLVBOPool::sBytesPooled/(1024*1024), LLVertexBuffer::sVertexCount/1024));
|
||||
ypos += y_inc;
|
||||
|
||||
addText(xpos, ypos, llformat("%d Vertex Buffers", LLVertexBuffer::sGLCount));
|
||||
|
||||
@@ -4058,7 +4058,7 @@ void LLVOAvatar::slamPosition()
|
||||
mRoot.updateWorldMatrixChildren();
|
||||
}
|
||||
|
||||
bool LLVOAvatar::isVisuallyMuted()
|
||||
bool LLVOAvatar::isVisuallyMuted() const
|
||||
{
|
||||
if(isSelf())return false;
|
||||
static LLCachedControl<U32> max_attachment_bytes(gSavedSettings, "RenderAutoMuteByteLimit");
|
||||
@@ -4137,7 +4137,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
|
||||
// the rest should only be done occasionally for far away avatars
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
if (visible && !isSelf() && !mIsDummy && sUseImpostors && !mNeedsAnimUpdate && !sFreezeCounter)
|
||||
if (visible && (!isSelf() || isVisuallyMuted()) && !mIsDummy && sUseImpostors && !mNeedsAnimUpdate && !sFreezeCounter)
|
||||
{
|
||||
const LLVector4a* ext = mDrawable->getSpatialExtents();
|
||||
LLVector4a size;
|
||||
@@ -4177,6 +4177,11 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
|
||||
|
||||
visible = (LLDrawable::getCurrentFrame()+mID.mData[0])%mUpdatePeriod == 0 ? TRUE : FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mUpdatePeriod = 1;
|
||||
}
|
||||
|
||||
|
||||
// don't early out for your own avatar, as we rely on your animations playing reliably
|
||||
// for example, the "turn around" animation when entering customize avatar needs to trigger
|
||||
@@ -5777,7 +5782,7 @@ S32 LLVOAvatar::getCollisionVolumeID(std::string &name)
|
||||
//-----------------------------------------------------------------------------
|
||||
// getID()
|
||||
//-----------------------------------------------------------------------------
|
||||
const LLUUID& LLVOAvatar::getID()
|
||||
const LLUUID& LLVOAvatar::getID() const
|
||||
{
|
||||
return mID;
|
||||
}
|
||||
@@ -10407,7 +10412,7 @@ void LLVOAvatar::updateImpostors()
|
||||
|
||||
BOOL LLVOAvatar::isImpostor() const
|
||||
{
|
||||
return (sUseImpostors && mUpdatePeriod >= IMPOSTOR_PERIOD) ? TRUE : FALSE;
|
||||
return (isVisuallyMuted() || (sUseImpostors && mUpdatePeriod >= IMPOSTOR_PERIOD)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ public:
|
||||
void resetJointPositionsToDefault( void );
|
||||
void resetSpecificJointPosition( const std::string& name );
|
||||
virtual const char* getAnimationPrefix() { return "avatar"; }
|
||||
virtual const LLUUID& getID();
|
||||
virtual const LLUUID& getID() const;
|
||||
virtual LLVector3 getVolumePos(S32 joint_index, LLVector3& volume_offset);
|
||||
virtual LLJoint* findCollisionVolume(U32 volume_id);
|
||||
virtual S32 getCollisionVolumeID(std::string &name);
|
||||
@@ -382,7 +382,7 @@ public:
|
||||
// Graphical stuff for objects - maybe broken out into render class later?
|
||||
U32 renderFootShadows();
|
||||
U32 renderImpostor(LLColor4U color = LLColor4U(255,255,255,255), S32 diffuse_channel = 0);
|
||||
bool isVisuallyMuted();
|
||||
bool isVisuallyMuted() const;
|
||||
|
||||
U32 renderRigid();
|
||||
U32 renderSkinned(EAvatarRenderPass pass);
|
||||
|
||||
@@ -677,6 +677,10 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
|
||||
|
||||
if (LLPipeline::sRenderDeferred)
|
||||
{
|
||||
// Set this flag in case we crash while resizing window or allocating space for deferred rendering targets
|
||||
gSavedSettings.setBOOL("RenderInitError", TRUE);
|
||||
gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
|
||||
|
||||
S32 shadow_detail = gSavedSettings.getS32("RenderShadowDetail");
|
||||
BOOL ssao = gSavedSettings.getBOOL("RenderDeferredSSAO");
|
||||
BOOL RenderDepthOfField = gSavedSettings.getBOOL("RenderDepthOfField");
|
||||
@@ -743,6 +747,10 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
|
||||
mShadow[i].release();
|
||||
}
|
||||
}
|
||||
|
||||
// don't disable shaders on next session
|
||||
gSavedSettings.setBOOL("RenderInitError", FALSE);
|
||||
gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -929,7 +937,7 @@ void LLPipeline::createGLBuffers()
|
||||
LLImageGL::generateTextures(1, &mNoiseMap);
|
||||
|
||||
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mNoiseMap);
|
||||
LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise);
|
||||
LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB, GL_FLOAT, noise, false);
|
||||
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
|
||||
}
|
||||
|
||||
@@ -944,7 +952,7 @@ void LLPipeline::createGLBuffers()
|
||||
|
||||
LLImageGL::generateTextures(1, &mTrueNoiseMap);
|
||||
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mTrueNoiseMap);
|
||||
LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise);
|
||||
LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_RGB16F_ARB, noiseRes, noiseRes, GL_RGB,GL_FLOAT, noise, false);
|
||||
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
|
||||
}
|
||||
|
||||
@@ -981,7 +989,7 @@ void LLPipeline::createGLBuffers()
|
||||
|
||||
LLImageGL::generateTextures(1, &mLightFunc);
|
||||
gGL.getTexUnit(0)->bindManual(LLTexUnit::TT_TEXTURE, mLightFunc);
|
||||
LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_R8, lightResX, lightResY, GL_RED, GL_UNSIGNED_BYTE, lg);
|
||||
LLImageGL::setManualImage(LLTexUnit::getInternalType(LLTexUnit::TT_TEXTURE), 0, GL_R8, lightResX, lightResY, GL_RED, GL_UNSIGNED_BYTE, lg, false);
|
||||
gGL.getTexUnit(0)->setTextureAddressMode(LLTexUnit::TAM_CLAMP);
|
||||
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_TRILINEAR);
|
||||
|
||||
@@ -8654,16 +8662,16 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
|
||||
|
||||
da = powf(da, split_exp.mV[2]);
|
||||
|
||||
|
||||
F32 sxp = split_exp.mV[1] + (split_exp.mV[0]-split_exp.mV[1])*da;
|
||||
|
||||
|
||||
|
||||
for (U32 i = 0; i < 4; ++i)
|
||||
{
|
||||
F32 x = (F32)(i+1)/4.f;
|
||||
x = powf(x, sxp);
|
||||
mSunClipPlanes.mV[i] = near_clip+range*x;
|
||||
}
|
||||
|
||||
mSunClipPlanes.mV[0] *= 1.25f; //bump back first split for transition padding
|
||||
}
|
||||
|
||||
// convenience array of 4 near clip plane distances
|
||||
@@ -8719,8 +8727,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
|
||||
delta += (frust[i+4]-frust[(i+2)%4+4])*0.05f;
|
||||
delta.normVec();
|
||||
F32 dp = delta*pn;
|
||||
frust[i] = eye + (delta*dist[j]*0.95f)/dp;
|
||||
frust[i+4] = eye + (delta*dist[j+1]*1.05f)/dp;
|
||||
frust[i] = eye + (delta*dist[j]*0.75f)/dp;
|
||||
frust[i+4] = eye + (delta*dist[j+1]*1.25f)/dp;
|
||||
}
|
||||
|
||||
shadow_cam.calcAgentFrustumPlanes(frust);
|
||||
|
||||
Reference in New Issue
Block a user