Merge remote-tracking branch 'siana/master'

Conflicts:
	indra/llrender/llvertexbuffer.cpp

Resolved: needed two casts for 64bit warning.
This commit is contained in:
Aleric Inglewood
2012-06-27 04:10:20 +02:00
197 changed files with 1820 additions and 1185 deletions

View File

@@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -226,7 +226,7 @@ endif (LINUX)
if (DARWIN)
add_definitions(-DLL_DARWIN=1)
add_definitions(-DLL_DARWIN=1 -D_XOPEN_SOURCE)
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mlong-branch")
@@ -234,11 +234,11 @@ if (DARWIN)
# NOTE: it's critical that the optimization flag is put in front.
# NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -03 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -03 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -msse3 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_CXX_FLAGS_RELEASESSE2 "${CMAKE_CXX_FLAGS_RELEASESSE2} -O3 -msse2 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2} -03 -msse2 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
set(CMAKE_C_FLAGS_RELEASESSE2 "${CMAKE_C_FLAGS_RELEASESSE2} -O3 -msse2 -mtune=generic -mfpmath=sse ${GCC_EXTRA_OPTIMIZATIONS}")
endif (DARWIN)

View File

@@ -10,6 +10,7 @@ if (STANDALONE)
else (STANDALONE)
use_prebuilt_binary(ares)
if (WINDOWS)
add_definitions("-DCARES_STATICLIB")
set(CARES_LIBRARIES areslib)
elseif (DARWIN)
set(CARES_LIBRARIES

View File

@@ -1575,7 +1575,7 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp)
constraint_it++)
{
U8 byte = constraint_it->mChainLength;
dp.packU8(byte, "chain_lenght");
dp.packU8(byte, "chain_length");
byte = constraint_it->mConstraintType;
dp.packU8(byte, "constraint_type");

View File

@@ -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
//-------------------------------------------------------------------------

View File

@@ -363,8 +363,7 @@ S32 LLImageJ2C::calcHeaderSizeJ2C()
return FIRST_PACKET_SIZE; // Hack. just needs to be >= actual header size...
}
//static
S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 rate)
static S32 cald_data_size_help(S32 w, S32 h, S32 comp, S32 discard_level, F32 rate)
{
if (rate <= 0.f) rate = .125f;
while (discard_level > 0)
@@ -376,7 +375,22 @@ S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 r
discard_level--;
}
S32 bytes = (S32)((F32)(w*h*comp)*rate);
//bytes = llmax(bytes, calcHeaderSizeJ2C());
return bytes;
}
//static
S32 LLImageJ2C::calcDataSizeJ2C(S32 w, S32 h, S32 comp, S32 discard_level, F32 rate)
{
static const LLCachedControl<F32> exponent("SianaJ2CSizeExponent", 1.0f);
static const LLCachedControl<S32> offset("SianaJ2CSizeOffset", 0);
S32 size = cald_data_size_help(w, h, comp, discard_level, rate);
S32 size_d0 = cald_data_size_help(w, h, comp, 0, rate);
llassert_always(size_d0);
S32 bytes = size_d0*pow((double)size/size_d0, (double)exponent) + offset;
bytes = llmax (0, bytes - 600);
bytes = ((bytes + (1000 - 1))/1000)*1000 + 600;
return bytes;
}
@@ -392,15 +406,7 @@ S32 LLImageJ2C::calcDataSize(S32 discard_level)
static const LLCachedControl<bool> legacy_size("SianaLegacyJ2CSize", false);
if (legacy_size) {
static const LLCachedControl<F32> exponent("SianaJ2CSizeExponent", 1.0f);
static const LLCachedControl<S32> offset("SianaJ2CSizeOffset", 0);
S32 size = calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), discard_level, mRate);
S32 size_d0 = calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), 0, mRate);
llassert_always(size_d0);
S32 bytes = pow(size/size_d0, exponent)*size_d0 + offset;
bytes = llmax(bytes, calcHeaderSizeJ2C());
return bytes;
return calcDataSizeJ2C(getWidth(), getHeight(), getComponents(), discard_level, mRate);
}
discard_level = llclamp(discard_level, 0, MAX_DISCARD_LEVEL);

View File

@@ -149,7 +149,19 @@ BOOL LLImageJ2COJ::decodeImpl(LLImageJ2C &base, LLImageRaw &raw_image, F32 decod
opj_setup_decoder(dinfo, &parameters);
/* open a byte stream */
#if 0
std::vector<U8> data(base.getData(), base.getData()+base.getDataSize());
S32 size = data.size();
if (data[size-1] == 0xFF) {
data.push_back((U8)0xD9);
} else if (data[size-2] != 0xFF || data[size-1] != 0xD9) {
data.push_back((U8)0xFF);
data.push_back((U8)0xD9);
}
cio = opj_cio_open((opj_common_ptr)dinfo, &data[0], data.size());
#else
cio = opj_cio_open((opj_common_ptr)dinfo, base.getData(), base.getDataSize());
#endif
/* decode the stream and fill the image structure */
image = opj_decode(dinfo, cio);

View File

@@ -28,6 +28,7 @@
#include "linden_common.h"
#include "llbuffer.h"
#include <iterator>
#include "llmath.h"
#include "llmemtype.h"

View File

@@ -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)
@@ -583,22 +584,33 @@ LLCurl::Multi::Multi(F32 idle_time_out)
LLCurl::Multi::~Multi()
{
cleanup() ;
cleanup(true);
delete mDeletionMutexp ;
mDeletionMutexp = NULL ;
}
void LLCurl::Multi::cleanup()
void LLCurl::Multi::cleanup(bool deleted)
{
if(!mCurlMultiHandle)
{
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)
{
Easy* easy = *iter;
check_curl_multi_code(curl_multi_remove_handle(mCurlMultiHandle, easy->getCurlHandle()));
if(deleted)
{
easy->mResponder = NULL ; //avoid triggering mResponder.
}
delete easy;
}
mEasyActiveList.clear();
@@ -610,14 +622,12 @@ void LLCurl::Multi::cleanup()
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;
@@ -644,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)
@@ -741,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 ;
}
@@ -966,14 +990,7 @@ void LLCurlThread::killMulti(LLCurl::Multi* multi)
return ;
}
if(multi->isValid())
{
multi->markDead() ;
}
else
{
deleteMulti(multi) ;
}
multi->markDead() ;
}
//private
@@ -992,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) ;
}
}
//------------------------------------------------------------

View File

@@ -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() ;
@@ -318,7 +318,7 @@ public:
private:
void easyFree(LLCurl::Easy*);
void cleanup() ;
void cleanup(bool deleted = false);
CURLM* mCurlMultiHandle;
@@ -333,6 +333,7 @@ private:
ePerformState mState;
BOOL mDead ;
BOOL mValid ;
LLMutex* mMutexp ;
LLMutex* mDeletionMutexp ;
LLMutex* mEasyMutexp ;

View File

@@ -29,6 +29,7 @@
#include "lldispatcher.h"
#include <algorithm>
#include <iterator>
#include "llstl.h"
#include "message.h"

View File

@@ -34,7 +34,6 @@
#include <string>
#include <boost/intrusive_ptr.hpp>
#include <openssl/x509_vfy.h>
#include "llurlrequest.h"
#include "llassettype.h"
#include "llcurl.h"

View File

@@ -38,7 +38,6 @@
#include "lliopipe.h"
#include "llchainio.h"
#include "llerror.h"
#include <openssl/x509_vfy.h>
#include "llcurl.h"
@@ -51,6 +50,9 @@ class LLURLRequestDetail;
class LLURLRequestComplete;
struct x509_store_ctx_st;
typedef struct x509_store_ctx_st X509_STORE_CTX;
/**
* @class LLURLRequest
* @brief Class to handle url based requests.

View File

@@ -108,9 +108,15 @@ 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
void parse_glsl_version(S32& major, S32& minor);
void ll_init_fail_log(std::string filename)
{
gFailLog.open(filename.c_str());
@@ -309,6 +315,7 @@ PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniformARB = NULL;
PFNGLGETUNIFORMFVARBPROC glGetUniformfvARB = NULL;
PFNGLGETUNIFORMIVARBPROC glGetUniformivARB = NULL;
PFNGLGETSHADERSOURCEARBPROC glGetShaderSourceARB = NULL;
PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = NULL;
#if LL_WINDOWS
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL;
@@ -458,7 +465,8 @@ LLGLManager::LLGLManager() :
mDriverVersionMinor(0),
mDriverVersionRelease(0),
mGLVersion(1.0f),
mGLSLVersionMajor(0),
mGLSLVersionMinor(0),
mVRAM(0),
mGLMaxVertexRange(0),
mGLMaxIndexRange(0)
@@ -569,6 +577,29 @@ bool LLGLManager::initGL()
mGLVersion = mDriverVersionMajor + mDriverVersionMinor * .1f;
if (mGLVersion >= 2.f)
{
parse_glsl_version(mGLSLVersionMajor, mGLSLVersionMinor);
#if LL_DARWIN
//never use GLSL greater than 1.20 on OSX
if (mGLSLVersionMajor > 1 || mGLSLVersionMinor >= 30)
{
mGLSLVersionMajor = 1;
mGLSLVersionMinor = 20;
}
#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 ")
@@ -589,11 +620,8 @@ bool LLGLManager::initGL()
#endif // LL_WINDOWS
#if (LL_WINDOWS || LL_LINUX) && !LL_MESA_HEADLESS
// release 7277 is a point at which we verify that ATI OpenGL
// drivers get pretty stable with SL, ~Catalyst 8.2,
// for both Win32 and Linux.
if (mDriverVersionRelease < 7277 &&
mDriverVersionRelease != 0) // 0 == Undetectable driver version - these get to pretend to be new ATI drivers, though that decision may be revisited.
// count any pre OpenGL 3.0 implementation as an old driver
if (mGLVersion < 3.f)
{
mATIOldDriver = TRUE;
}
@@ -1292,6 +1320,7 @@ void LLGLManager::initExtensions()
glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4uivARB");
glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttrib4usvARB");
glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttribPointerARB");
glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) GLH_EXT_GET_PROC_ADDRESS("glVertexAttribIPointer");
glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) GLH_EXT_GET_PROC_ADDRESS("glEnableVertexAttribArrayARB");
glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) GLH_EXT_GET_PROC_ADDRESS("glDisableVertexAttribArrayARB");
glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) GLH_EXT_GET_PROC_ADDRESS("glProgramStringARB");
@@ -2082,6 +2111,55 @@ void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor
}
}
void parse_glsl_version(S32& major, S32& minor)
{
// GL_SHADING_LANGUAGE_VERSION returns a null-terminated string with the format:
// <major>.<minor>[.<release>] [<vendor specific>]
const char* version = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION);
major = 0;
minor = 0;
if( !version )
{
return;
}
std::string ver_copy( version );
S32 len = (S32)strlen( version ); /* Flawfinder: ignore */
S32 i = 0;
S32 start;
// Find the major version
start = i;
for( ; i < len; i++ )
{
if( '.' == version[i] )
{
break;
}
}
std::string major_str = ver_copy.substr(start,i-start);
LLStringUtil::convertToS32(major_str, major);
if( '.' == version[i] )
{
i++;
}
// Find the minor version
start = i;
for( ; i < len; i++ )
{
if( ('.' == version[i]) || isspace(version[i]) )
{
break;
}
}
std::string minor_str = ver_copy.substr(start,i-start);
LLStringUtil::convertToS32(minor_str, minor);
}
LLGLUserClipPlane::LLGLUserClipPlane(const LLPlane& p, const glh::matrix4f& modelview, const glh::matrix4f& projection, bool apply)
{
mApply = apply;

View File

@@ -145,6 +145,8 @@ public:
S32 mDriverVersionMinor;
S32 mDriverVersionRelease;
F32 mGLVersion; // e.g = 1.4
S32 mGLSLVersionMajor;
S32 mGLSLVersionMinor;
std::string mDriverVersionVendorString;
S32 mVRAM; // VRAM in MB

View File

@@ -207,6 +207,7 @@ extern PFNGLVERTEXATTRIB4UBVARBPROC glVertexAttrib4ubvARB;
extern PFNGLVERTEXATTRIB4UIVARBPROC glVertexAttrib4uivARB;
extern PFNGLVERTEXATTRIB4USVARBPROC glVertexAttrib4usvARB;
extern PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB;
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
extern PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
extern PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB;
extern PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;
@@ -466,6 +467,7 @@ extern PFNGLVERTEXATTRIB4UBVARBPROC glVertexAttrib4ubvARB;
extern PFNGLVERTEXATTRIB4UIVARBPROC glVertexAttrib4uivARB;
extern PFNGLVERTEXATTRIB4USVARBPROC glVertexAttrib4usvARB;
extern PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB;
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
extern PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
extern PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB;
extern PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;
@@ -699,6 +701,7 @@ extern PFNGLVERTEXATTRIB4UBVARBPROC glVertexAttrib4ubvARB;
extern PFNGLVERTEXATTRIB4UIVARBPROC glVertexAttrib4uivARB;
extern PFNGLVERTEXATTRIB4USVARBPROC glVertexAttrib4usvARB;
extern PFNGLVERTEXATTRIBPOINTERARBPROC glVertexAttribPointerARB;
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
extern PFNGLENABLEVERTEXATTRIBARRAYARBPROC glEnableVertexAttribArrayARB;
extern PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glDisableVertexAttribArrayARB;
extern PFNGLPROGRAMSTRINGARBPROC glProgramStringARB;

View File

@@ -149,12 +149,6 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes,
glDeleteObjectARB(mProgramObject);
// Create program
mProgramObject = glCreateProgramObjectARB();
static const LLCachedControl<bool> no_texture_indexing("ShyotlUseLegacyTextureBatching",false);
if (gGLManager.mGLVersion < 3.1f || no_texture_indexing)
{ //force indexed texture channels to 1 if GL version is old (performance improvement for drivers with poor branching shader model support)
mFeatures.mIndexedTextureChannels = llmin(mFeatures.mIndexedTextureChannels, 1);
}
//compile new source
vector< pair<string,GLenum> >::iterator fileIter = mShaderFiles.begin();
@@ -181,8 +175,9 @@ BOOL LLGLSLShader::createShader(vector<string> * attributes,
return FALSE;
}
if (gGLManager.mGLVersion < 3.1f || no_texture_indexing)
{ //attachShaderFeatures may have set the number of indexed texture channels, so set to 1 again
static const LLCachedControl<bool> no_texture_indexing("ShyotlUseLegacyTextureBatching",false);
if (gGLManager.mGLVersion < 3.1f || no_texture_indexing)
{ //attachShaderFeatures may have set the number of indexed texture channels, so set to 1 again
mFeatures.mIndexedTextureChannels = llmin(mFeatures.mIndexedTextureChannels, 1);
}

View File

@@ -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();

View File

@@ -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?

View File

@@ -1440,8 +1440,6 @@ void LLRender::loadIdentity()
flush();
{
llassert_always(mMatrixMode < NUM_MATRIX_MODES) ;
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].make_identity();
mMatHash[mMatrixMode]++;
}

View File

@@ -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);
}

View File

@@ -543,7 +543,6 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
return 0;
}
//read in from file
LLFILE* file = NULL;
@@ -572,40 +571,52 @@ 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];
GLuint count = 0;
F32 version = gGLManager.mGLVersion;
//hack to never use GLSL > 1.20 on OSX
#if LL_DARWIN
version = llmin(version, 2.9f);
#endif
if (version < 2.1f)
S32 major_version = gGLManager.mGLSLVersionMajor;
S32 minor_version = gGLManager.mGLSLVersionMinor;
if (major_version == 1 && minor_version < 30)
{
text[count++] = strdup("#version 110\n");
text[count++] = strdup("#define ATTRIBUTE attribute\n");
text[count++] = strdup("#define VARYING varying\n");
}
else if (version < 3.3f)
{
//set version to 1.20
text[count++] = strdup("#version 120\n");
text[count++] = strdup("#define FXAA_GLSL_120 1\n");
text[count++] = strdup("#define FXAA_FAST_PIXEL_OFFSET 0\n");
text[count++] = strdup("#define ATTRIBUTE attribute\n");
text[count++] = strdup("#define VARYING varying\n");
if (minor_version < 10)
{
//should NEVER get here -- if major version is 1 and minor version is less than 10,
// viewer should never attempt to use shaders, continuing will result in undefined behavior
llerrs << "Unsupported GLSL Version." << llendl;
}
if (minor_version <= 19)
{
text[count++] = strdup("#version 110\n");
text[count++] = strdup("#define ATTRIBUTE attribute\n");
text[count++] = strdup("#define VARYING varying\n");
text[count++] = strdup("#define VARYING_FLAT varying\n");
}
else if (minor_version <= 29)
{
//set version to 1.20
text[count++] = strdup("#version 120\n");
text[count++] = strdup("#define FXAA_GLSL_120 1\n");
text[count++] = strdup("#define FXAA_FAST_PIXEL_OFFSET 0\n");
text[count++] = strdup("#define ATTRIBUTE attribute\n");
text[count++] = strdup("#define VARYING varying\n");
text[count++] = strdup("#define VARYING_FLAT varying\n");
}
}
else
{
if (version < 4.f)
if (major_version < 4)
{
//set version to 1.30
text[count++] = strdup("#version 130\n");
//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
@@ -621,21 +632,25 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
{ //"varying" state is "out" in a vertex program, "in" in a fragment program
// ("varying" is deprecated after version 1.20)
text[count++] = strdup("#define VARYING out\n");
text[count++] = strdup("#define VARYING_FLAT flat out\n");
}
else
{
text[count++] = strdup("#define VARYING in\n");
text[count++] = strdup("#define VARYING_FLAT flat in\n");
}
//backwards compatibility with legacy texture lookup syntax
text[count++] = strdup("#define texture2D 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
@@ -659,22 +674,24 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
.
uniform sampler2D texN;
varying float vary_texture_index;
VARYING_FLAT ivec4 vary_texture_index;
vec4 ret = vec4(1,0,1,1);
vec4 diffuseLookup(vec2 texcoord)
{
switch (int(vary_texture_index+0.25))
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;
}
*/
@@ -687,7 +704,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
if (texture_index_channels > 1)
{
text[count++] = strdup("VARYING float vary_texture_index;\n");
text[count++] = strdup("VARYING_FLAT ivec4 vary_texture_index;\n");
}
text[count++] = strdup("vec4 diffuseLookup(vec2 texcoord)\n");
@@ -699,45 +716,28 @@ 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
{
//switches aren't supported, make block that looks like:
/*
int ti = int(vary_texture_index+0.25);
if (ti == 0) return texture2D(tex0, texcoord);
if (ti == 1) return texture2D(tex1, texcoord);
.
.
.
if (ti == N) return texture2D(texN, texcoord);
*/
text[count++] = strdup("int ti = int(vary_texture_index+0.25);\n");
for (S32 i = 0; i < texture_index_channels; ++i)
{
std::string if_str = llformat("if (ti == %d) return texture2D(tex%d, texcoord);\n", i, i);
text[count++] = strdup(if_str.c_str());
}
text[count++] = strdup("\treturn vec4(1,0,1,1);\n");
text[count++] = strdup("}\n");
}
{ //should never get here. Indexed texture rendering requires GLSL 1.30 or later
// (for passing integers between vertex and fragment shaders)
llerrs << "Indexed texture rendering requires GLSL 1.30 or later." << llendl;
}
}
//copy file into memory

View File

@@ -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;
@@ -285,6 +381,12 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
{
bool error = false;
if (gGLManager.mGLSLVersionMajor < 2 && gGLManager.mGLSLVersionMinor < 30)
{
//make sure texture index is disabled
data_mask = data_mask & ~MAP_TEXTURE_INDEX;
}
if (LLGLSLShader::sNoFixedFunction)
{
for (U32 i = 0; i < TYPE_MAX; ++i)
@@ -430,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();
@@ -689,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)
{
@@ -741,8 +843,8 @@ void LLVertexBuffer::cleanupClass()
if(sPrivatePoolp)
{
LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp) ;
sPrivatePoolp = NULL ;
LLPrivateMemoryPoolManager::getInstance()->deletePool(sPrivatePoolp);
sPrivatePoolp = NULL;
}
}
@@ -750,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) :
@@ -877,7 +995,10 @@ LLVertexBuffer::~LLVertexBuffer()
mFence = NULL;
llassert_always(!mMappedData && !mMappedIndexData) ;
sVertexCount -= mNumVerts;
sIndexCount -= mNumIndices;
llassert_always(!mMappedData && !mMappedIndexData);
};
void LLVertexBuffer::placeFence() const
@@ -908,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)
{
@@ -924,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)
{
@@ -1089,18 +1210,25 @@ void LLVertexBuffer::updateNumVerts(S32 nverts)
if (nverts >= 65535)
{
llwarns << "Vertex buffer overflow!" << llendl;
nverts = 65535;
// <FS:ND> FIRE-5077; Just print an info if there are more than 0xFFFF, for now just so there is a message in the logs where in older version #vertices would have been capped.
// llwarns << "Vertex buffer overflow!" << llendl;
// nverts = 65535;
llinfos << "More vertices than 65535 (#" << nverts << ")" <<llendl;
// </FS:ND>
}
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)
@@ -1109,14 +1237,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)
@@ -1125,11 +1255,21 @@ void LLVertexBuffer::allocateBuffer(S32 nverts, S32 nindices, bool create)
stop_glerror();
if (nverts < 0 || nindices < 0 ||
nverts > 65536)
{
// <FS:ND> FIRE-5077; Just print an info if there are more than 0xFFFF, for now just so there is a message in the logs where in older version #vertices would have been capped.
// if (nverts < 0 || nindices < 0 ||
// nverts > 65536)
// {
// llerrs << "Bad vertex buffer allocation: " << nverts << " : " << nindices << llendl;
// }
if( nverts < 0 || nindices < 0 )
llerrs << "Bad vertex buffer allocation: " << nverts << " : " << nindices << llendl;
}
if( nverts > 0xFFFF )
llinfos << "More vertices than 65535 (#" << nverts << ")" <<llendl;
// </FS:ND>
updateNumVerts(nverts);
updateNumIndices(nindices);
@@ -1178,7 +1318,7 @@ void LLVertexBuffer::setupVertexArray()
1, //TYPE_WEIGHT,
4, //TYPE_WEIGHT4,
4, //TYPE_CLOTHWEIGHT,
1, //TYPE_TEXTURE_INDEX
4, //TYPE_TEXTURE_INDEX
};
U32 attrib_type[] =
@@ -1195,7 +1335,24 @@ void LLVertexBuffer::setupVertexArray()
GL_FLOAT, //TYPE_WEIGHT,
GL_FLOAT, //TYPE_WEIGHT4,
GL_FLOAT, //TYPE_CLOTHWEIGHT,
GL_FLOAT, //TYPE_TEXTURE_INDEX
GL_UNSIGNED_BYTE, //TYPE_TEXTURE_INDEX
};
bool attrib_integer[] =
{
false, //TYPE_VERTEX,
false, //TYPE_NORMAL,
false, //TYPE_TEXCOORD0,
false, //TYPE_TEXCOORD1,
false, //TYPE_TEXCOORD2,
false, //TYPE_TEXCOORD3,
false, //TYPE_COLOR,
false, //TYPE_EMISSIVE,
false, //TYPE_BINORMAL,
false, //TYPE_WEIGHT,
false, //TYPE_WEIGHT4,
false, //TYPE_CLOTHWEIGHT,
true, //TYPE_TEXTURE_INDEX
};
U32 attrib_normalized[] =
@@ -1223,7 +1380,21 @@ void LLVertexBuffer::setupVertexArray()
if (mTypeMask & (1 << i))
{
glEnableVertexAttribArrayARB(i);
glVertexAttribPointerARB(i, attrib_size[i], attrib_type[i], attrib_normalized[i], sTypeSize[i], reinterpret_cast<void*>(mOffsets[i]));
if (attrib_integer[i])
{
#if !LL_DARWIN
//glVertexattribIPointer requires GLSL 1.30 or later
if (gGLManager.mGLSLVersionMajor > 1 || gGLManager.mGLSLVersionMinor >= 30)
{
glVertexAttribIPointer(i, attrib_size[i], attrib_type[i], sTypeSize[i], reinterpret_cast<void*>(mOffsets[i]));
}
#endif
}
else
{
glVertexAttribPointerARB(i, attrib_size[i], attrib_type[i], attrib_normalized[i], sTypeSize[i], reinterpret_cast<void*>(mOffsets[i]));
}
}
else
{
@@ -1286,6 +1457,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)
{
@@ -1420,16 +1592,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;
@@ -1444,7 +1616,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;
}
}
}
@@ -1598,7 +1770,7 @@ volatile U8* LLVertexBuffer::mapIndexBuffer(S32 index, S32 count, bool map_range
if (!mMappedIndexData)
{
log_glerror();
LLMemory::logMemoryInfo(true) ;
LLMemory::logMemoryInfo(true);
if(mMappable)
{
@@ -1613,7 +1785,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;
}
}
}
@@ -1644,10 +1816,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)
{
@@ -1778,10 +1950,10 @@ void LLVertexBuffer::unmapBuffer()
glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB);
stop_glerror();
mMappedIndexData = NULL ;
mMappedIndexData = NULL;
}
mIndexLocked = false ;
mIndexLocked = false;
sMappedCount--;
}
@@ -1832,7 +2004,7 @@ template <class T,S32 type> struct VertexBufferStrider
}
else
{
llerrs << "VertexBufferStrider could not find valid vertex data." << llendl;
llwarns << "VertexBufferStrider could not find valid vertex data." << llendl;
}
return false;
}
@@ -2204,11 +2376,14 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask)
void* ptr = (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]);
glVertexAttribPointerARB(loc, 4, GL_FLOAT, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], ptr);
}
if (data_mask & MAP_TEXTURE_INDEX)
if (data_mask & MAP_TEXTURE_INDEX &&
(gGLManager.mGLSLVersionMajor >= 2 || gGLManager.mGLSLVersionMinor >= 30)) //indexed texture rendering requires GLSL 1.30 or later
{
#if !LL_DARWIN
S32 loc = TYPE_TEXTURE_INDEX;
void *ptr = (void*) (base + mOffsets[TYPE_VERTEX] + 12);
glVertexAttribPointerARB(loc, 1, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr);
glVertexAttribIPointer(loc, 4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], ptr);
#endif
}
if (data_mask & MAP_VERTEX)
{

View File

@@ -55,14 +55,15 @@ class LLVBOPool
{
public:
static U32 sBytesPooled;
static U32 sIndexBytesPooled;
LLVBOPool(U32 vboUsage, U32 vboType)
: mUsage(vboUsage)
, mType(vboType)
{}
const U32 mUsage;
U32 mType;
const U32 mType;
//size MUST be a power of 2
volatile U8* allocate(U32& name, U32 size);
@@ -93,7 +94,7 @@ public:
//============================================================================
// base class
class LLPrivateMemoryPool ;
class LLPrivateMemoryPool;
class LLVertexBuffer : public LLRefCount
{
public:
@@ -280,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
@@ -296,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;
@@ -309,7 +313,7 @@ protected:
static S32 determineUsage(S32 usage);
private:
static LLPrivateMemoryPool* sPrivatePoolp ;
static LLPrivateMemoryPool* sPrivatePoolp;
public:
static S32 sCount;
@@ -329,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;
};

View File

@@ -1202,6 +1202,7 @@ BOOL LLFloater::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
return LLPanel::handleMiddleMouseDown( x, y, mask );
}
// virtual
BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask)
{
@@ -1210,22 +1211,6 @@ BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask)
return was_minimized || LLPanel::handleDoubleClick(x, y, mask);
}
// virtual
BOOL LLFloater::handleKeyHere(KEY key, MASK mask)
{
if (key == 'W' && mask == MASK_CONTROL)
{
if (canClose() && isCloseable())
{
close();
}
return TRUE;
}
return LLPanel::handleKeyHere(key, mask);
}
void LLFloater::bringToFront( S32 x, S32 y )
{
if (getVisible() && pointInView(x, y))
@@ -1352,21 +1337,10 @@ void LLFloater::onClickEdit(void *userdata)
// static
LLFloater* LLFloater::getClosableFloaterFromFocus()
{
LLFloater* focused_floater = NULL;
LLFloater* focused_floater = gFloaterView->getFocusedFloater();
handle_map_iter_t iter;
for(iter = sFloaterMap.begin(); iter != sFloaterMap.end(); ++iter)
if (!focused_floater)
{
focused_floater = iter->second;
if (focused_floater->hasFocus())
{
break;
}
}
if (iter == sFloaterMap.end())
{
// nothing found, return
return NULL;
}
@@ -1374,7 +1348,7 @@ LLFloater* LLFloater::getClosableFloaterFromFocus()
// Find and close a parental floater that is closeable, if any.
LLFloater* previous_floater = NULL; // Guard against endless loop, because getParentFloater(x) can return x!
for(LLFloater* floater_to_close = focused_floater;
NULL != floater_to_close && floater_to_close != gFloaterView->getParentFloater(floater_to_close);
NULL != floater_to_close;
floater_to_close = gFloaterView->getParentFloater(floater_to_close))
{
if(floater_to_close == previous_floater)

View File

@@ -197,7 +197,6 @@ public:
virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
virtual BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
virtual void draw();
virtual void onOpen() {}

View File

@@ -406,6 +406,22 @@ void LLMultiFloater::setVisible(BOOL visible)
}
}
BOOL LLMultiFloater::handleKeyHere(KEY key, MASK mask)
{
if (key == 'W' && mask == MASK_CONTROL)
{
LLFloater* floater = getActiveFloater();
// is user closeable and is system closeable
if (floater && floater->canClose() && floater->isCloseable())
{
floater->close();
}
return TRUE;
}
return LLFloater::handleKeyHere(key, mask);
}
LLFloater* LLMultiFloater::getActiveFloater()
{
return (LLFloater*)mTabContainer->getCurrentPanel();

View File

@@ -51,6 +51,7 @@ public:
/*virtual*/ void onClose(bool app_quitting);
/*virtual*/ void draw();
/*virtual*/ void setVisible(BOOL visible);
/*virtual*/ BOOL handleKeyHere(KEY key, MASK mask);
virtual void setCanResize(BOOL can_resize);
virtual void growToFit(S32 content_width, S32 content_height);

View File

@@ -47,6 +47,9 @@ class LLPreeditor;
class LLWindowCallbacks;
static const S32 MIN_WINDOW_WIDTH = 864;
static const S32 MIN_WINDOW_HEIGHT = 472;
// Refer to llwindow_test in test/common/llwindow for usage example
class LLWindow

View File

@@ -2548,9 +2548,6 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
{
// This is where we would constrain move/resize to a particular screen
const S32 MIN_WIDTH = 1024;
const S32 MIN_HEIGHT = 768;
Rect currentBounds;
Rect previousBounds;
@@ -2575,14 +2572,14 @@ OSStatus LLWindowMacOSX::eventHandler (EventHandlerCallRef myHandler, EventRef e
mPreviousWindowRect = previousBounds;
}
if ((currentBounds.right - currentBounds.left) < MIN_WIDTH)
if ((currentBounds.right - currentBounds.left) < MIN_WINDOW_WIDTH)
{
currentBounds.right = currentBounds.left + MIN_WIDTH;
currentBounds.right = currentBounds.left + MIN_WINDOW_WIDTH;
}
if ((currentBounds.bottom - currentBounds.top) < MIN_HEIGHT)
if ((currentBounds.bottom - currentBounds.top) < MIN_WINDOW_HEIGHT)
{
currentBounds.bottom = currentBounds.top + MIN_HEIGHT;
currentBounds.bottom = currentBounds.top + MIN_WINDOW_HEIGHT;
}
SetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, sizeof(Rect), &currentBounds);

View File

@@ -71,8 +71,6 @@ extern BOOL gDebugWindowProc;
const S32 MAX_NUM_RESOLUTIONS = 200;
const S32 MIN_WINDOW_WIDTH = 1024;
const S32 MIN_WINDOW_HEIGHT = 768;
// static variable for ATI mouse cursor crash work-around:
static bool ATIbug = false;

View File

@@ -2414,8 +2414,8 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
case WM_GETMINMAXINFO:
{
LPMINMAXINFO min_max = (LPMINMAXINFO)l_param;
min_max->ptMinTrackSize.x = 1024;
min_max->ptMinTrackSize.y = 768;
min_max->ptMinTrackSize.x = MIN_WINDOW_WIDTH;
min_max->ptMinTrackSize.y = MIN_WINDOW_HEIGHT;
return 0;
}

View File

@@ -1207,7 +1207,9 @@ if (WINDOWS)
DXGUID_LIBRARY
)
# see EXP-1765 - theory is opengl32.lib needs to be included before gdi32.lib (windows libs)
set(viewer_LIBRARIES
opengl32
advapi32
comdlg32
${DINPUT_LIBRARY}
@@ -1218,7 +1220,6 @@ if (WINDOWS)
odbccp32
ole32
oleaut32
opengl32
shell32
user32
Vfw32

View File

@@ -287,7 +287,7 @@
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.5</real>
<real>1.0</real>
</map>
<key>SianaJ2CSizeOffset</key>
<map>
@@ -298,7 +298,7 @@
<key>Type</key>
<string>S32</string>
<key>Value</key>
<integer>100</integer>
<integer>0</integer>
</map>
<key>SianaLegacyJ2CSize</key>
@@ -3941,7 +3941,29 @@
<key>Value</key>
<integer>0</integer>
</map>
<key>CurlUseMultipleThreads</key>
<key>CurlMaximumNumberOfHandles</key>
<map>
<key>Comment</key>
<string>Maximum number of handles curl can use (requires restart)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>S32</string>
<key>Value</key>
<integer>256</integer>
</map>
<key>CurlRequestTimeOut</key>
<map>
<key>Comment</key>
<string>Max idle time of a curl request before killed (requires restart)</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>120.0</real>
</map>
<key>CurlUseMultipleThreads</key>
<map>
<key>Comment</key>
<string>Use background threads for executing curl_multi_perform (requires restart)</string>
@@ -9807,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>

View File

@@ -145,7 +145,7 @@
<key>Type</key>
<string>Boolean</string>
<key>Value</key>
<integer>1</integer>
<integer>0</integer>
</map>
<key>AscentShowSelfTagColor</key>
<map>

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
VARYING vec4 vertex_color;
@@ -34,5 +36,5 @@ uniform sampler2D diffuseMap;
void main()
{
gl_FragColor = vec4(vertex_color.rgb, texture2D(diffuseMap, vary_texcoord0.xy).a);
frag_color = vec4(vertex_color.rgb, texture2D(diffuseMap, vary_texcoord0.xy).a);
}

View File

@@ -26,15 +26,15 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
vec4 diffuseLookup(vec2 texcoord);
uniform mat4 shadow_matrix[6];
uniform vec4 shadow_clip;
uniform vec2 screen_res;
vec3 atmosLighting(vec3 light);
@@ -69,6 +69,6 @@ void main()
color.rgb += diff.rgb * vary_pointlight_col.rgb;
gl_FragColor = color;
frag_color = color;
}

View File

@@ -26,15 +26,15 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
uniform sampler2D diffuseMap;
uniform mat4 shadow_matrix[6];
uniform vec4 shadow_clip;
uniform vec2 screen_res;
vec3 atmosLighting(vec3 light);
@@ -81,9 +81,9 @@ void main()
color.rgb += diff.rgb * vary_pointlight_col.rgb;
gl_FragColor = color;
//gl_FragColor = vec4(1,0,1,1);
//gl_FragColor = vec4(1,0,1,1)*shadow;
frag_color = color;
//frag_color = vec4(1,0,1,1);
//frag_color = vec4(1,0,1,1)*shadow;
}

View File

@@ -26,14 +26,14 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
uniform sampler2D diffuseMap;
uniform mat4 shadow_matrix[6];
uniform vec4 shadow_clip;
uniform vec2 screen_res;
vec3 atmosLighting(vec3 light);
@@ -79,6 +79,6 @@ void main()
color.rgb += diff.rgb * vary_pointlight_col.rgb;
gl_FragColor = color;
frag_color = color;
}

View File

@@ -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);

View File

@@ -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)));

View File

@@ -23,17 +23,17 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2D diffuseMap;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
void main()
{
//gl_FragColor = vec4(1,1,1,vertex_color.a * texture2D(diffuseMap, vary_texcoord0.xy).a);
gl_FragColor = vec4(1,1,1,1);
frag_color = vec4(1,1,1,1);
}

View File

@@ -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;

View File

@@ -0,0 +1,148 @@
/**
* @file avatarAlphaNoColorV.glsl
*
* $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$
*/
uniform mat4 projection_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec3 normal;
ATTRIBUTE vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
mat4 getSkinnedTransform();
void calcAtmospherics(vec3 inPositionEye);
float calcDirectionalLight(vec3 n, vec3 l);
float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);
vec3 atmosAmbient(vec3 light);
vec3 atmosAffectDirectionalLight(float lightIntensity);
vec3 scaleDownLight(vec3 light);
vec3 scaleUpLight(vec3 light);
VARYING vec3 vary_position;
VARYING vec3 vary_ambient;
VARYING vec3 vary_directional;
VARYING vec3 vary_fragcoord;
VARYING vec3 vary_pointlight_col;
VARYING vec2 vary_texcoord0;
uniform float near_clip;
uniform vec4 color;
uniform vec4 light_position[8];
uniform vec3 light_direction[8];
uniform vec3 light_attenuation[8];
uniform vec3 light_diffuse[8];
float calcDirectionalLight(vec3 n, vec3 l)
{
float a = max(dot(n,l),0.0);
return a;
}
float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight)
{
//get light vector
vec3 lv = lp.xyz-v;
//get distance
float d = dot(lv,lv);
float da = 0.0;
if (d > 0.0 && la > 0.0 && fa > 0.0)
{
//normalize light vector
lv = normalize(lv);
//distance attenuation
float dist2 = d/la;
da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
// spotlight coefficient.
float spot = max(dot(-ln, lv), is_pointlight);
da *= spot*spot; // GL_SPOT_EXPONENT=2
//angular attenuation
da *= max(dot(n, lv), 0.0);
}
return da;
}
void main()
{
vary_texcoord0 = texcoord0;
vec4 pos;
vec3 norm;
mat4 trans = getSkinnedTransform();
vec4 pos_in = vec4(position.xyz, 1.0);
pos.x = dot(trans[0], pos_in);
pos.y = dot(trans[1], pos_in);
pos.z = dot(trans[2], pos_in);
pos.w = 1.0;
norm.x = dot(trans[0].xyz, normal);
norm.y = dot(trans[1].xyz, normal);
norm.z = dot(trans[2].xyz, normal);
norm = normalize(norm);
vec4 frag_pos = projection_matrix * pos;
gl_Position = frag_pos;
vary_position = pos.xyz;
calcAtmospherics(pos.xyz);
vec4 col = vec4(0.0, 0.0, 0.0, 1.0);
// Collect normal lights
col.rgb += light_diffuse[2].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[2], light_direction[2], light_attenuation[2].x, light_attenuation[2].y, light_attenuation[2].z);
col.rgb += light_diffuse[3].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[3], light_direction[3], light_attenuation[3].x, light_attenuation[3].y, light_attenuation[3].z);
col.rgb += light_diffuse[4].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[4], light_direction[4], light_attenuation[4].x, light_attenuation[4].y, light_attenuation[4].z);
col.rgb += light_diffuse[5].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[5], light_direction[5], light_attenuation[5].x, light_attenuation[5].y, light_attenuation[5].z);
col.rgb += light_diffuse[6].rgb*calcPointLightOrSpotLight(pos.xyz, norm, light_position[6], light_direction[6], light_attenuation[6].x, light_attenuation[6].y, light_attenuation[6].z);
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*color.rgb;
col.rgb = vec3(0,0,0);
// Add windlight lights
col.rgb = atmosAmbient(vec3(0.));
vary_ambient = col.rgb*color.rgb;
vary_directional = color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, light_position[0].xyz), 0.0));
col.rgb = col.rgb * color.rgb;
vary_fragcoord.xyz = frag_pos.xyz + vec3(0,0,near_clip);
}

View File

@@ -0,0 +1,48 @@
/**
* @file avatarEyesV.glsl
*
* $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$
*/
uniform mat3 normal_matrix;
uniform mat4 texture_matrix0;
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec3 normal;
ATTRIBUTE vec4 diffuse_color;
ATTRIBUTE vec2 texcoord0;
VARYING vec3 vary_normal;
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
void main()
{
//transform vertex
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
vary_normal = normalize(normal_matrix * normal);
vertex_color = diffuse_color;
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
uniform sampler2D diffuseMap;
@@ -41,9 +43,9 @@ void main()
discard;
}
gl_FragData[0] = vec4(diff.rgb, 0.0);
gl_FragData[1] = vec4(0,0,0,0);
frag_data[0] = vec4(diff.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2D diffuseMap;
@@ -33,7 +35,7 @@ VARYING vec4 post_pos;
void main()
{
gl_FragColor = vec4(1,1,1,1);
frag_color = vec4(1,1,1,1);
gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
@@ -111,6 +113,6 @@ void main()
col /= defined_weight.xyxx;
col.y *= col.y;
gl_FragColor = col;
frag_color = col;
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
uniform sampler2D diffuseMap;
@@ -46,9 +48,9 @@ void main()
dot(norm,vary_mat1),
dot(norm,vary_mat2));
gl_FragData[0] = vec4(col, 0.0);
gl_FragData[1] = vertex_color.aaaa; // spec
//gl_FragData[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
frag_data[0] = vec4(col, 0.0);
frag_data[1] = vertex_color.aaaa; // spec
//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
vec3 nvn = normalize(tnorm);
gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
}

View File

@@ -30,7 +30,7 @@ ATTRIBUTE vec3 position;
ATTRIBUTE vec4 diffuse_color;
ATTRIBUTE vec3 normal;
ATTRIBUTE vec2 texcoord0;
ATTRIBUTE vec2 texcoord2;
ATTRIBUTE vec3 binormal;
VARYING vec3 vary_mat0;
VARYING vec3 vary_mat1;
@@ -52,7 +52,7 @@ void main()
vec3 n = normalize((mat * vec4(normal.xyz+position.xyz, 1.0)).xyz-pos.xyz);
vec3 b = normalize((mat * vec4(vec4(texcoord2,0,1).xyz+position.xyz, 1.0)).xyz-pos.xyz);
vec3 b = normalize((mat * vec4(binormal.xyz+position.xyz, 1.0)).xyz-pos.xyz);
vec3 t = cross(b, n);
vary_mat0 = vec3(t.x, b.x, n.x);

View File

@@ -25,7 +25,9 @@
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
/////////////////////////////////////////////////////////////////////////
@@ -98,8 +100,8 @@ void main()
color *= 2.;
/// Gamma correct for WL (soft clip effect).
gl_FragData[0] = vec4(scaleSoftClip(color.rgb), alpha1);
gl_FragData[1] = vec4(0.0,0.0,0.0,0.0);
gl_FragData[2] = vec4(0,0,1,0);
frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1);
frag_data[1] = vec4(0.0,0.0,0.0,0.0);
frag_data[2] = vec4(0,0,1,0);
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
@@ -83,6 +85,6 @@ void main()
sc = max(sc, -max_cof);
vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
gl_FragColor.rgb = diff.rgb + bloom.rgb;
gl_FragColor.a = sc/max_cof*0.5+0.5;
frag_color.rgb = diff.rgb + bloom.rgb;
frag_color.a = sc/max_cof*0.5+0.5;
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
uniform float minimum_alpha;
@@ -44,9 +46,9 @@ void main()
discard;
}
gl_FragData[0] = vec4(col.rgb, 0.0);
gl_FragData[1] = vec4(0,0,0,0); // spec
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0); // spec
vec3 nvn = normalize(vary_normal);
gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
VARYING vec3 vary_normal;
@@ -43,8 +45,8 @@ void main()
discard;
}
gl_FragData[0] = vec4(col.rgb, 0.0);
gl_FragData[1] = vec4(0,0,0,0);
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
}

View File

@@ -25,7 +25,9 @@
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
uniform float minimum_alpha;
@@ -44,9 +46,9 @@ void main()
discard;
}
gl_FragData[0] = vec4(col.rgb, 0.0);
gl_FragData[1] = vec4(0,0,0,0); // spec
frag_data[0] = vec4(col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0); // spec
vec3 nvn = normalize(vary_normal);
gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
uniform sampler2D diffuseMap;
@@ -36,10 +38,10 @@ VARYING vec2 vary_texcoord0;
void main()
{
vec3 col = vertex_color.rgb * texture2D(diffuseMap, vary_texcoord0.xy).rgb;
gl_FragData[0] = vec4(col, 0.0);
gl_FragData[1] = vertex_color.aaaa; // spec
//gl_FragData[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
frag_data[0] = vec4(col, 0.0);
frag_data[1] = vertex_color.aaaa; // spec
//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
vec3 nvn = normalize(vary_normal);
gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
VARYING vec3 vary_normal;
@@ -35,9 +37,9 @@ void main()
{
vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb;
gl_FragData[0] = vec4(col, 0.0);
gl_FragData[1] = vertex_color.aaaa; // spec
//gl_FragData[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
frag_data[0] = vec4(col, 0.0);
frag_data[1] = vertex_color.aaaa; // spec
//frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested
vec3 nvn = normalize(vary_normal);
gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
@@ -73,5 +75,5 @@ void main()
diff = mix(diff, col*0.25, a);
}
gl_FragColor = mix(diff, dof, a);
frag_color = mix(diff, dof, a);
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
vec3 fullbrightAtmosTransport(vec3 light);
@@ -45,6 +47,6 @@ void main()
color.rgb = fullbrightScaleSoftClip(color.rgb);
gl_FragColor = color;
frag_color = color;
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
VARYING vec4 vertex_color;
@@ -46,6 +48,6 @@ void main()
color.rgb = fullbrightScaleSoftClip(color.rgb);
gl_FragColor = color;
frag_color = color;
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
#define FXAA_PC 1
@@ -341,18 +343,23 @@ A. Or use FXAA_GREEN_AS_LUMA.
// 1 = API supports gather4 on alpha channel.
// 0 = API does not support gather4 on alpha channel.
//
#if (FXAA_GLSL_130 == 0)
#define FXAA_GATHER4_ALPHA 0
#endif
#if (FXAA_HLSL_5 == 1)
#define FXAA_GATHER4_ALPHA 1
#endif
#ifdef GL_ARB_gpu_shader5
#define FXAA_GATHER4_ALPHA 1
#endif
#ifdef GL_NV_gpu_shader5
#define FXAA_GATHER4_ALPHA 1
#endif
#ifndef FXAA_GATHER4_ALPHA
#define FXAA_GATHER4_ALPHA 0
#endif
#ifdef GL_ARB_gpu_shader5
#define FXAA_GATHER4_ALPHA 1
#endif
#ifdef GL_NV_gpu_shader5
#define FXAA_GATHER4_ALPHA 1
#endif
#ifndef FXAA_GATHER4_ALPHA
#define FXAA_GATHER4_ALPHA 0
#endif
#endif
#endif
/*============================================================================
@@ -2113,6 +2120,6 @@ void main()
//diff = texture2D(diffuseMap, vary_tc);
gl_FragColor = diff;
frag_color = diff;
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
@@ -184,5 +186,5 @@ void main()
vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
gl_FragColor.xyz = giAmbient(pos, norm);
frag_color.xyz = giAmbient(pos, norm);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
uniform float minimum_alpha;
@@ -45,7 +47,7 @@ void main()
discard;
}
gl_FragData[0] = vec4(col.rgb, col.a * 0.005);
gl_FragData[1] = texture2D(specularMap, vary_texcoord0.xy);
gl_FragData[2] = vec4(texture2D(normalMap, vary_texcoord0.xy).xyz, 0.0);
frag_data[0] = vec4(col.rgb, col.a * 0.005);
frag_data[1] = texture2D(specularMap, vary_texcoord0.xy);
frag_data[2] = vec4(texture2D(normalMap, vary_texcoord0.xy).xyz, 0.0);
}

View File

@@ -26,12 +26,14 @@
uniform sampler2DRect diffuseMap;
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
VARYING vec2 vary_fragcoord;
void main()
{
gl_FragColor = texture2DRect(diffuseMap, vary_fragcoord.xy);
frag_color = texture2DRect(diffuseMap, vary_fragcoord.xy);
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
@@ -141,6 +143,6 @@ void main()
discard;
}
gl_FragColor.rgb = out_col;
gl_FragColor.a = 0.0;
frag_color.rgb = out_col;
frag_color.a = 0.0;
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
//class 1 -- no shadows
@@ -242,6 +244,6 @@ void main()
}
}
gl_FragColor.rgb = col;
gl_FragColor.a = 0.0;
frag_color.rgb = col;
frag_color.a = 0.0;
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2D alphaMap;
@@ -52,5 +54,5 @@ void main()
norm *= 0.5;
norm += 0.5;
gl_FragColor = vec4(norm, alpha);
frag_color = vec4(norm, alpha);
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
@@ -118,6 +120,6 @@ void main()
discard;
}
gl_FragColor.rgb = col;
gl_FragColor.a = 0.0;
frag_color.rgb = col;
frag_color.a = 0.0;
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
@@ -118,9 +120,9 @@ void main()
sc -= 1.0;
}
}
diff /= w;
}
gl_FragColor = diff;
frag_color = diff;
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
@@ -40,6 +42,6 @@ void main()
vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
gl_FragColor = diff + bloom;
frag_color = diff + bloom;
}

View File

@@ -1,5 +1,5 @@
/**
* @file postgiV.glsl
* @file postDeferredV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -24,17 +24,17 @@
*/
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
VARYING vec2 vary_fragcoord;
uniform vec2 screen_res;
void main()
{
//transform vertex
vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
gl_Position = pos;
gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@@ -24,8 +24,10 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
#endif
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
@@ -96,5 +98,5 @@ void main()
col = col*col*blur_quad.x + col*blur_quad.y + blur_quad.z;
gl_FragColor.rgb = col;
frag_color.rgb = col;
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform float minimum_alpha;
@@ -44,7 +46,7 @@ void main()
discard;
}
gl_FragColor = vec4(1,1,1,1);
frag_color = vec4(1,1,1,1);
gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
}

View File

@@ -24,14 +24,16 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
VARYING vec4 post_pos;
void main()
{
gl_FragColor = vec4(1,1,1,1);
frag_color = vec4(1,1,1,1);
gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
/////////////////////////////////////////////////////////////////////////
@@ -57,8 +59,8 @@ void main()
color *= 2.;
/// Gamma correct for WL (soft clip effect).
gl_FragData[0] = vec4(scaleSoftClip(color.rgb), 1.0);
gl_FragData[1] = vec4(0.0,0.0,0.0,0.0);
gl_FragData[2] = vec4(0,0,1,0);
frag_data[0] = vec4(scaleSoftClip(color.rgb), 1.0);
frag_data[1] = vec4(0.0,0.0,0.0,0.0);
frag_data[2] = vec4(0,0,1,0);
}

View File

@@ -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);

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
@@ -144,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);
@@ -311,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);
@@ -324,7 +324,7 @@ void main()
col = diffuse.rgb;
}
gl_FragColor.rgb = col;
frag_color.rgb = col;
gl_FragColor.a = bloom;
frag_color.a = bloom;
}

View File

@@ -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;
}

View File

@@ -27,7 +27,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
@@ -184,6 +186,6 @@ void main()
}
}
gl_FragColor.rgb = col;
gl_FragColor.a = 0.0;
frag_color.rgb = col;
frag_color.a = 0.0;
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
VARYING vec4 vertex_color;
@@ -36,7 +38,7 @@ void main()
{
vec4 col = vertex_color * texture2D(diffuseMap, vary_texcoord0.xy);
gl_FragData[0] = col;
gl_FragData[1] = vec4(0,0,0,0);
gl_FragData[2] = vec4(0,0,1,0);
frag_data[0] = col;
frag_data[1] = vec4(0,0,0,0);
frag_data[2] = vec4(0,0,1,0);
}

View File

@@ -28,10 +28,12 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
void main()
{
gl_FragColor = vec4(0,0,0,0);
frag_color = vec4(0,0,0,0);
}

View File

@@ -1,5 +1,5 @@
/**
* @file giV.glsl
* @file sunLightF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
@@ -24,13 +24,8 @@
*/
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec4 diffuse_color;
ATTRIBUTE vec2 texcoord0;
VARYING vec4 vertex_color;
VARYING vec2 vary_fragcoord;
uniform vec2 screen_res;
@@ -39,10 +34,4 @@ void main()
//transform vertex
vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
vec4 tex = vec4(texcoord0,0,1);
tex.w = 1.0;
vertex_color = diffuse_color;
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
//class 1 -- no shadow, SSAO only
@@ -37,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;
@@ -49,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;
@@ -128,8 +125,8 @@ void main()
vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
gl_FragColor[0] = 1.0;
gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
gl_FragColor[2] = 1.0;
gl_FragColor[3] = 1.0;
frag_color[0] = 1.0;
frag_color[1] = calcAmbientOcclusion(pos, norm);
frag_color[2] = 1.0;
frag_color[3] = 1.0;
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
uniform sampler2D detail_0;
@@ -51,9 +53,9 @@ void main()
float alphaFinal = texture2D(alpha_ramp, vary_texcoord1.zw).a;
vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal );
gl_FragData[0] = vec4(outColor.rgb, 0.0);
gl_FragData[1] = vec4(0,0,0,0);
frag_data[0] = vec4(outColor.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
uniform sampler2D diffuseMap;
@@ -43,8 +45,8 @@ void main()
discard;
}
gl_FragData[0] = vec4(vertex_color.rgb*col.rgb, 0.0);
gl_FragData[1] = vec4(0,0,0,0);
frag_data[0] = vec4(vertex_color.rgb*col.rgb, 0.0);
frag_data[1] = vec4(0,0,0,0);
vec3 nvn = normalize(vary_normal);
gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
frag_data[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform float minimum_alpha;
@@ -43,7 +45,7 @@ void main()
discard;
}
gl_FragColor = vec4(1,1,1,1);
frag_color = vec4(1,1,1,1);
gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragData[3];
out vec4 frag_data[3];
#else
#define frag_data gl_FragData
#endif
vec3 scaleSoftClip(vec3 inColor);
@@ -157,7 +159,7 @@ void main()
//wavef = normalize(wavef);
vec3 screenspacewavef = (norm_mat*vec4(wavef, 1.0)).xyz;
gl_FragData[0] = vec4(color.rgb, 0.5); // diffuse
gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec
gl_FragData[2] = vec4(screenspacewavef.xy*0.5+0.5, screenspacewavef.z, screenspacewavef.z*0.5); // normalxyz, displace
frag_data[0] = vec4(color.rgb, 0.5); // diffuse
frag_data[1] = vec4(0.5,0.5,0.5, 0.95); // speccolor*spec, spec
frag_data[2] = vec4(screenspacewavef.xy*0.5+0.5, screenspacewavef.z, screenspacewavef.z*0.5); // normalxyz, displace
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseMap;
@@ -46,7 +48,7 @@ void main()
float lum = smoothstep(minLuminance, minLuminance+1.0, dot(col.rgb, lumWeights ) );
float warmth = smoothstep(minLuminance, minLuminance+1.0, max(col.r * warmthWeights.r, max(col.g * warmthWeights.g, col.b * warmthWeights.b)) );
gl_FragColor.rgb = col.rgb;
gl_FragColor.a = max(col.a, mix(lum, warmth, warmthAmount) * maxExtractAlpha);
frag_color.rgb = col.rgb;
frag_color.a = max(col.a, mix(lum, warmth, warmthAmount) * maxExtractAlpha);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2D diffuseMap;
@@ -35,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;
gl_FragColor = vec4(col.rgb * glowStrength, col.a);
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);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
VARYING vec4 vertex_color;
@@ -59,6 +61,6 @@ void main()
/// Add WL Components
outColor.rgb = atmosLighting(outColor.rgb * vertex_color.rgb);
gl_FragColor = vec4(scaleSoftClip(outColor.rgb), 1.0);
frag_color = vec4(scaleSoftClip(outColor.rgb), 1.0);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
VARYING vec4 vertex_color;
@@ -60,6 +62,6 @@ void main()
outColor.rgb = atmosLighting(outColor.rgb * vertex_color.rgb);
outColor = applyWaterFog(outColor);
gl_FragColor = outColor;
frag_color = outColor;
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2D diffuseMap;
@@ -106,5 +108,5 @@ void main()
vec4 fb = texture2D(screenTex, distort);
gl_FragColor = applyWaterFog(fb,view.xyz);
frag_color = applyWaterFog(fb,view.xyz);
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
vec3 scaleSoftClip(vec3 inColor);
@@ -135,5 +137,5 @@ void main()
color.rgb = scaleSoftClip(color.rgb);
color.a = spec * sunAngle2;
gl_FragColor = color;
frag_color = color;
}

View File

@@ -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;

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2D diffuseMap;
@@ -42,5 +44,5 @@ void main()
discard;
}
gl_FragColor = col;
frag_color = col;
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2D diffuseMap;
@@ -38,5 +40,5 @@ void main()
{
vec4 color = vertex_color*texture2D(diffuseMap, vary_texcoord0.xy);
color.a *= custom_alpha;
gl_FragColor = color;
frag_color = color;
}

View File

@@ -24,12 +24,14 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform vec4 color;
void main()
{
gl_FragColor = color;
frag_color = color;
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
#extension GL_ARB_texture_rectangle : enable
@@ -37,6 +39,6 @@ VARYING vec2 vary_texcoord1;
void main()
{
gl_FragColor = texture2D(glowMap, vary_texcoord0.xy) +
frag_color = texture2D(glowMap, vary_texcoord0.xy) +
texture2DRect(screenMap, vary_texcoord1.xy);
}

View File

@@ -26,7 +26,9 @@
#extension GL_ARB_texture_rectangle : enable
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform sampler2DRect diffuseRect;
@@ -38,5 +40,5 @@ void main()
{
vec3 col = texture2DRect(diffuseRect, vary_tc*screen_res).rgb;
gl_FragColor = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144)));
frag_color = vec4(col.rgb, dot(col.rgb, vec3(0.299, 0.587, 0.144)));
}

View File

@@ -24,7 +24,9 @@
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 gl_FragColor;
out vec4 frag_color;
#else
#define frag_color gl_FragColor
#endif
uniform vec4 color;
@@ -34,5 +36,5 @@ VARYING vec2 vary_texcoord0;
void main()
{
gl_FragColor = color*texture2D(diffuseMap, vary_texcoord0.xy);
frag_color = color*texture2D(diffuseMap, vary_texcoord0.xy);
}

Some files were not shown because too many files have changed in this diff Show More