master
Dave Parks 2011-08-08 15:39:02 -05:00
commit f076bdf609
126 changed files with 1580 additions and 882 deletions

View File

@ -1329,8 +1329,6 @@ void LLGLState::initClass()
sStateMap[GL_MULTISAMPLE_ARB] = GL_FALSE;
glDisable(GL_MULTISAMPLE_ARB);
glEnableClientState(GL_VERTEX_ARRAY);
}
//static
@ -1604,7 +1602,7 @@ void LLGLState::checkTextureChannels(const std::string& msg)
void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask)
{
if (!gDebugGL)
if (!gDebugGL || LLGLSLShader::sNoFixedFunction)
{
return;
}
@ -1661,7 +1659,7 @@ void LLGLState::checkClientArrays(const std::string& msg, U32 data_mask)
};
for (S32 j = 0; j < 4; j++)
for (S32 j = 1; j < 4; j++)
{
if (glIsEnabled(value[j]))
{
@ -1875,79 +1873,6 @@ void LLGLManager::initGLStates()
////////////////////////////////////////////////////////////////////////////////
void enable_vertex_weighting(const S32 index)
{
#if GL_ARB_vertex_program
if (index > 0) glEnableVertexAttribArrayARB(index); // vertex weights
#endif
}
void disable_vertex_weighting(const S32 index)
{
#if GL_ARB_vertex_program
if (index > 0) glDisableVertexAttribArrayARB(index); // vertex weights
#endif
}
void enable_binormals(const S32 index)
{
#if GL_ARB_vertex_program
if (index > 0)
{
glEnableVertexAttribArrayARB(index); // binormals
}
#endif
}
void disable_binormals(const S32 index)
{
#if GL_ARB_vertex_program
if (index > 0)
{
glDisableVertexAttribArrayARB(index); // binormals
}
#endif
}
void enable_cloth_weights(const S32 index)
{
#if GL_ARB_vertex_program
if (index > 0) glEnableVertexAttribArrayARB(index);
#endif
}
void disable_cloth_weights(const S32 index)
{
#if GL_ARB_vertex_program
if (index > 0) glDisableVertexAttribArrayARB(index);
#endif
}
void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights)
{
#if GL_ARB_vertex_program
if (index > 0) glVertexAttribPointerARB(index, 1, GL_FLOAT, FALSE, stride, weights);
stop_glerror();
#endif
}
void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights)
{
#if GL_ARB_vertex_program
if (index > 0) glVertexAttribPointerARB(index, 4, GL_FLOAT, TRUE, stride, weights);
stop_glerror();
#endif
}
void set_binormals(const S32 index, const U32 stride,const LLVector3 *binormals)
{
#if GL_ARB_vertex_program
if (index > 0) glVertexAttribPointerARB(index, 3, GL_FLOAT, FALSE, stride, binormals);
stop_glerror();
#endif
}
void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific )
{
// GL_VERSION returns a null-terminated string with the format:

View File

@ -252,7 +252,7 @@ public:
static void dumpStates();
static void checkStates(const std::string& msg = "");
static void checkTextureChannels(const std::string& msg = "");
static void checkClientArrays(const std::string& msg = "", U32 data_mask = 0x0001);
static void checkClientArrays(const std::string& msg = "", U32 data_mask = 0);
protected:
static boost::unordered_map<LLGLenum, LLGLboolean> sStateMap;
@ -419,15 +419,7 @@ extern LLMatrix4 gGLObliqueProjectionInverse;
#include "llglstates.h"
void init_glstates();
void enable_vertex_weighting(const S32 index);
void disable_vertex_weighting(const S32 index);
void enable_binormals(const S32 index);
void disable_binormals(const S32 index);
void enable_cloth_weights(const S32 index);
void disable_cloth_weights(const S32 index);
void set_vertex_weights(const S32 index, const U32 stride, const F32 *weights);
void set_vertex_clothing_weights(const S32 index, const U32 stride, const LLVector4 *weights);
void set_binormals(const S32 index, const U32 stride, const LLVector3 *binormals);
void parse_gl_version( S32* major, S32* minor, S32* release, std::string* vendor_specific );
extern BOOL gClothRipple;

View File

@ -31,6 +31,7 @@
#include "llshadermgr.h"
#include "llfile.h"
#include "llrender.h"
#include "llvertexbuffer.h"
#if LL_DARWIN
#include "OpenGL/OpenGL.h"
@ -386,6 +387,7 @@ void LLGLSLShader::bind()
gGL.flush();
if (gGLManager.mHasShaderObjects)
{
LLVertexBuffer::unbind();
glUseProgramObjectARB(mProgramObject);
sCurBoundShader = mProgramObject;
sCurBoundShaderPtr = this;
@ -411,6 +413,7 @@ void LLGLSLShader::unbind()
stop_glerror();
}
}
LLVertexBuffer::unbind();
glUseProgramObjectARB(0);
sCurBoundShader = 0;
sCurBoundShaderPtr = NULL;
@ -420,6 +423,7 @@ void LLGLSLShader::unbind()
void LLGLSLShader::bindNoShader(void)
{
LLVertexBuffer::unbind();
glUseProgramObjectARB(0);
sCurBoundShader = 0;
sCurBoundShaderPtr = NULL;

View File

@ -1580,6 +1580,105 @@ void LLRender::color3fv(const GLfloat* c)
color4f(c[0],c[1],c[2],1);
}
void LLRender::diffuseColor3f(F32 r, F32 g, F32 b)
{
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(LLVertexBuffer::TYPE_COLOR);
}
if (loc >= 0)
{
glVertexAttrib3fARB(loc, r,g,b);
}
else
{
glColor3f(r,g,b);
}
}
void LLRender::diffuseColor3fv(const F32* c)
{
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(LLVertexBuffer::TYPE_COLOR);
}
if (loc >= 0)
{
glVertexAttrib3fvARB(loc, c);
}
else
{
glColor3fv(c);
}
}
void LLRender::diffuseColor4f(F32 r, F32 g, F32 b, F32 a)
{
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(LLVertexBuffer::TYPE_COLOR);
}
if (loc >= 0)
{
glVertexAttrib4fARB(loc, r,g,b,a);
}
else
{
glColor4f(r,g,b,a);
}
}
void LLRender::diffuseColor4fv(const F32* c)
{
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(LLVertexBuffer::TYPE_COLOR);
}
if (loc >= 0)
{
glVertexAttrib4fvARB(loc, c);
}
else
{
glColor4fv(c);
}
}
void LLRender::diffuseColor4ubv(const U8* c)
{
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(LLVertexBuffer::TYPE_COLOR);
}
if (loc >= 0)
{
glVertexAttrib4ubvARB(loc, c);
}
else
{
glColor4ubv(c);
}
}
void LLRender::debugTexUnits(void)
{
LL_INFOS("TextureUnit") << "Active TexUnit: " << mCurrTextureUnitIndex << LL_ENDL;

View File

@ -350,6 +350,12 @@ public:
void color3fv(const GLfloat* c);
void color4ubv(const GLubyte* c);
void diffuseColor3f(F32 r, F32 g, F32 b);
void diffuseColor3fv(const F32* c);
void diffuseColor4f(F32 r, F32 g, F32 b, F32 a);
void diffuseColor4fv(const F32* c);
void diffuseColor4ubv(const U8* c);
void vertexBatchPreTransformed(LLVector3* verts, S32 vert_count);
void vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 vert_count);
void vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLColor4U*, S32 vert_count);

View File

@ -130,6 +130,7 @@ S32 LLVertexBuffer::sTypeSize[LLVertexBuffer::TYPE_MAX] =
sizeof(LLVector2), // TYPE_TEXCOORD2,
sizeof(LLVector2), // TYPE_TEXCOORD3,
sizeof(LLColor4U), // TYPE_COLOR,
sizeof(U8), // TYPE_EMISSIVE
sizeof(LLVector4), // TYPE_BINORMAL,
sizeof(F32), // TYPE_WEIGHT,
sizeof(LLVector4), // TYPE_WEIGHT4,
@ -156,36 +157,79 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
llerrs << "Cannot use LLGLImmediate and LLVertexBuffer simultaneously!" << llendl;
}*/
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
if (sLastMask != data_mask)
{
llassert(!LLGLSLShader::sNoFixedFunction || shader != NULL);
static LLGLSLShader* last_shader = LLGLSLShader::sCurBoundShaderPtr;
llassert(sLastMask == 0 || last_shader == shader);
last_shader = shader;
U32 mask[] =
{
MAP_VERTEX,
MAP_NORMAL,
MAP_TEXCOORD0,
MAP_COLOR,
MAP_EMISSIVE,
MAP_WEIGHT,
MAP_WEIGHT4,
MAP_BINORMAL,
MAP_CLOTHWEIGHT,
};
U32 type[] =
{
TYPE_VERTEX,
TYPE_NORMAL,
TYPE_TEXCOORD0,
TYPE_COLOR,
TYPE_EMISSIVE,
TYPE_WEIGHT,
TYPE_WEIGHT4,
TYPE_BINORMAL,
TYPE_CLOTHWEIGHT,
};
GLenum array[] =
{
GL_VERTEX_ARRAY,
GL_NORMAL_ARRAY,
GL_TEXTURE_COORD_ARRAY,
GL_COLOR_ARRAY,
0,
0,
0,
0,
0,
};
BOOL error = FALSE;
for (U32 i = 0; i < 4; ++i)
for (U32 i = 0; i < 9; ++i)
{
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(type[i]);
}
if (sLastMask & mask[i])
{ //was enabled
if (!(data_mask & mask[i]) && i > 0)
if (!(data_mask & mask[i]))
{ //needs to be disabled
glDisableClientState(array[i]);
if (loc >= 0)
{
glDisableVertexAttribArrayARB(loc);
}
else if (!shader)
{
glDisableClientState(array[i]);
}
}
else if (gDebugGL)
{ //needs to be enabled, make sure it was (DEBUG TEMPORARY)
if (i > 0 && !glIsEnabled(array[i]))
else if (gDebugGL && !shader && array[i])
{ //needs to be enabled, make sure it was (DEBUG)
if (loc < 0 && !glIsEnabled(array[i]))
{
if (gDebugSession)
{
@ -201,11 +245,18 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
}
else
{ //was disabled
if (data_mask & mask[i] && i > 0)
if (data_mask & mask[i])
{ //needs to be enabled
glEnableClientState(array[i]);
if (loc >= 0)
{
glEnableVertexAttribArrayARB(loc);
}
else if (!shader)
{
glEnableClientState(array[i]);
}
}
else if (gDebugGL && i > 0 && glIsEnabled(array[i]))
else if (!shader && array[i] && gDebugGL && glIsEnabled(array[i]))
{ //needs to be disabled, make sure it was (DEBUG TEMPORARY)
if (gDebugSession)
{
@ -232,62 +283,71 @@ void LLVertexBuffer::setupClientArrays(U32 data_mask)
MAP_TEXCOORD3
};
U32 type_tc[] =
{
TYPE_TEXCOORD1,
TYPE_TEXCOORD2,
TYPE_TEXCOORD3
};
for (U32 i = 0; i < 3; i++)
{
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(type_tc[i]);
}
if (sLastMask & map_tc[i])
{
if (!(data_mask & map_tc[i]))
{
glClientActiveTextureARB(GL_TEXTURE1_ARB+i);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
{ //disable
if (loc >= 0)
{
glDisableVertexAttribArrayARB(loc);
}
else if (!shader)
{
glClientActiveTextureARB(GL_TEXTURE1_ARB+i);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
}
}
else if (data_mask & map_tc[i])
{
glClientActiveTextureARB(GL_TEXTURE1_ARB+i);
if (loc >= 0)
{
glEnableVertexAttribArrayARB(loc);
}
else if (!shader)
{
glClientActiveTextureARB(GL_TEXTURE1_ARB+i);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
}
}
if (!shader)
{
if (sLastMask & MAP_BINORMAL)
{
if (!(data_mask & MAP_BINORMAL))
{
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
}
else if (data_mask & MAP_BINORMAL)
{
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
}
if (sLastMask & MAP_BINORMAL)
{
if (!(data_mask & MAP_BINORMAL))
{
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
}
else if (data_mask & MAP_BINORMAL)
{
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
if (sLastMask & MAP_WEIGHT4)
{
if (sWeight4Loc < 0)
{
llerrs << "Weighting disabled but vertex buffer still bound!" << llendl;
}
if (!(data_mask & MAP_WEIGHT4))
{ //disable 4-component skin weight
glDisableVertexAttribArrayARB(sWeight4Loc);
}
}
else if (data_mask & MAP_WEIGHT4)
{
if (sWeight4Loc >= 0)
{ //enable 4-component skin weight
glEnableVertexAttribArrayARB(sWeight4Loc);
}
}
sLastMask = data_mask;
}
}
@ -1593,6 +1653,10 @@ bool LLVertexBuffer::getColorStrider(LLStrider<LLColor4U>& strider, S32 index, S
{
return VertexBufferStrider<LLColor4U,TYPE_COLOR>::get(*this, strider, index, count, map_range);
}
bool LLVertexBuffer::getEmissiveStrider(LLStrider<U8>& strider, S32 index, S32 count, bool map_range)
{
return VertexBufferStrider<U8,TYPE_EMISSIVE>::get(*this, strider, index, count, map_range);
}
bool LLVertexBuffer::getWeightStrider(LLStrider<F32>& strider, S32 index, S32 count, bool map_range)
{
return VertexBufferStrider<F32,TYPE_WEIGHT>::get(*this, strider, index, count, map_range);
@ -1811,46 +1875,166 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
llerrs << "LLVertexBuffer::setupVertexBuffer missing required components for supplied data mask." << llendl;
}
LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
//assert that fixed function is allowed OR a shader is currently bound
llassert(!LLGLSLShader::sNoFixedFunction || shader != NULL);
if (data_mask & MAP_NORMAL)
{
glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(TYPE_NORMAL);
}
if (loc >= 0)
{
glVertexAttribPointerARB(loc, 3, GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
}
else if (!shader)
{
glNormalPointer(GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_NORMAL], (void*)(base + mOffsets[TYPE_NORMAL]));
}
}
if (data_mask & MAP_TEXCOORD3)
{
glClientActiveTextureARB(GL_TEXTURE3_ARB);
glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD3], (void*)(base + mOffsets[TYPE_TEXCOORD3]));
glClientActiveTextureARB(GL_TEXTURE0_ARB);
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(TYPE_TEXCOORD3);
}
if (loc >= 0)
{
glVertexAttribPointerARB(loc,2,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD3], (void*)(base + mOffsets[TYPE_TEXCOORD3]));
}
else if (!shader)
{
glClientActiveTextureARB(GL_TEXTURE3_ARB);
glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD3], (void*)(base + mOffsets[TYPE_TEXCOORD3]));
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
}
if (data_mask & MAP_TEXCOORD2)
{
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD2], (void*)(base + mOffsets[TYPE_TEXCOORD2]));
glClientActiveTextureARB(GL_TEXTURE0_ARB);
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(TYPE_TEXCOORD2);
}
if (loc >= 0)
{
glVertexAttribPointerARB(loc,2,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD2], (void*)(base + mOffsets[TYPE_TEXCOORD2]));
}
else if (!shader)
{
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD2], (void*)(base + mOffsets[TYPE_TEXCOORD2]));
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
}
if (data_mask & MAP_TEXCOORD1)
{
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD1], (void*)(base + mOffsets[TYPE_TEXCOORD1]));
glClientActiveTextureARB(GL_TEXTURE0_ARB);
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(TYPE_TEXCOORD1);
}
if (loc >= 0)
{
glVertexAttribPointerARB(loc,2,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD1], (void*)(base + mOffsets[TYPE_TEXCOORD1]));
}
else if (!shader)
{
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD1], (void*)(base + mOffsets[TYPE_TEXCOORD1]));
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
}
if (data_mask & MAP_BINORMAL)
{
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glTexCoordPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_BINORMAL], (void*)(base + mOffsets[TYPE_BINORMAL]));
glClientActiveTextureARB(GL_TEXTURE0_ARB);
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(TYPE_BINORMAL);
}
if (loc >= 0)
{
glVertexAttribPointerARB(loc, 3,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_BINORMAL], (void*)(base + mOffsets[TYPE_BINORMAL]));
}
else if (!shader)
{
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glTexCoordPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_BINORMAL], (void*)(base + mOffsets[TYPE_BINORMAL]));
glClientActiveTextureARB(GL_TEXTURE0_ARB);
}
}
if (data_mask & MAP_TEXCOORD0)
{
glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(TYPE_TEXCOORD0);
}
if (loc >= 0)
{
glVertexAttribPointerARB(loc,2,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
}
else if (!shader)
{
glTexCoordPointer(2,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_TEXCOORD0], (void*)(base + mOffsets[TYPE_TEXCOORD0]));
}
}
if (data_mask & MAP_COLOR)
{
glColorPointer(4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeSize[TYPE_COLOR], (void*)(base + mOffsets[TYPE_COLOR]));
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(TYPE_COLOR);
}
if (loc >= 0)
{
glVertexAttribPointerARB(loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_COLOR], (void*)(base + mOffsets[TYPE_COLOR]));
}
else if (!shader)
{
glColorPointer(4, GL_UNSIGNED_BYTE, LLVertexBuffer::sTypeSize[TYPE_COLOR], (void*)(base + mOffsets[TYPE_COLOR]));
}
}
if (data_mask & MAP_EMISSIVE)
{
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(TYPE_EMISSIVE);
}
if (loc >= 0)
{
glVertexAttribPointerARB(loc, 1, GL_UNSIGNED_BYTE, GL_TRUE, LLVertexBuffer::sTypeSize[TYPE_EMISSIVE], (void*)(base + mOffsets[TYPE_EMISSIVE]));
}
}
if (data_mask & MAP_WEIGHT)
{
glVertexAttribPointerARB(1, 1, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT], (void*)(base + mOffsets[TYPE_WEIGHT]));
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(TYPE_WEIGHT);
}
if (loc < 0)
{ //legacy behavior, some shaders have weight hardcoded to location 1
loc = 1;
}
glVertexAttribPointerARB(loc, 1, GL_FLOAT, FALSE, LLVertexBuffer::sTypeSize[TYPE_WEIGHT], (void*)(base + mOffsets[TYPE_WEIGHT]));
}
if (data_mask & MAP_WEIGHT4 && sWeight4Loc != -1)
@ -1860,17 +2044,47 @@ void LLVertexBuffer::setupVertexBuffer(U32 data_mask) const
if (data_mask & MAP_CLOTHWEIGHT)
{
glVertexAttribPointerARB(4, 4, GL_FLOAT, TRUE, LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
S32 loc = -1;
if (shader)
{
loc = shader->getAttribLocation(TYPE_CLOTHWEIGHT);
}
if (loc < 0)
{ //legacy behavior, some shaders have weight hardcoded to location 4
loc = 4;
}
glVertexAttribPointerARB(loc, 4, GL_FLOAT, TRUE, LLVertexBuffer::sTypeSize[TYPE_CLOTHWEIGHT], (void*)(base + mOffsets[TYPE_CLOTHWEIGHT]));
}
if (data_mask & MAP_VERTEX)
{
if (data_mask & MAP_TEXTURE_INDEX)
S32 loc = -1;
if (shader)
{
glVertexPointer(4,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_VERTEX], (void*)(base + 0));
loc = shader->getAttribLocation(TYPE_VERTEX);
}
else
if (loc >= 0)
{
glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_VERTEX], (void*)(base + 0));
if (data_mask & MAP_TEXTURE_INDEX)
{
glVertexAttribPointerARB(loc, 4,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], (void*)(base + 0));
}
else
{
glVertexAttribPointerARB(loc, 3,GL_FLOAT, GL_FALSE, LLVertexBuffer::sTypeSize[TYPE_VERTEX], (void*)(base + 0));
}
}
else if (!shader)
{
if (data_mask & MAP_TEXTURE_INDEX)
{
glVertexPointer(4,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_VERTEX], (void*)(base + 0));
}
else
{
glVertexPointer(3,GL_FLOAT, LLVertexBuffer::sTypeSize[TYPE_VERTEX], (void*)(base + 0));
}
}
}

View File

@ -133,6 +133,12 @@ public:
static S32 calcOffsets(const U32& typemask, S32* offsets, S32 num_vertices);
//WARNING -- when updating these enums you MUST
// 1 - update LLVertexBuffer::sTypeSize
// 2 - add a strider accessor
// 3 - modify LLVertexBuffer::setupVertexBuffer
// 4 - modify LLVertexBuffer::setupClientArray
// 5 - modify LLViewerShaderMgr::mReservedAttribs
enum {
TYPE_VERTEX,
TYPE_NORMAL,
@ -141,6 +147,7 @@ public:
TYPE_TEXCOORD2,
TYPE_TEXCOORD3,
TYPE_COLOR,
TYPE_EMISSIVE,
// These use VertexAttribPointer and should possibly be made generic
TYPE_BINORMAL,
TYPE_WEIGHT,
@ -160,6 +167,7 @@ public:
MAP_TEXCOORD2 = (1<<TYPE_TEXCOORD2),
MAP_TEXCOORD3 = (1<<TYPE_TEXCOORD3),
MAP_COLOR = (1<<TYPE_COLOR),
MAP_EMISSIVE = (1<<TYPE_EMISSIVE),
// These use VertexAttribPointer and should possibly be made generic
MAP_BINORMAL = (1<<TYPE_BINORMAL),
MAP_WEIGHT = (1<<TYPE_WEIGHT),
@ -218,10 +226,12 @@ public:
bool getNormalStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getBinormalStrider(LLStrider<LLVector3>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getColorStrider(LLStrider<LLColor4U>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getEmissiveStrider(LLStrider<U8>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getWeightStrider(LLStrider<F32>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getWeight4Strider(LLStrider<LLVector4>& strider, S32 index=0, S32 count = -1, bool map_range = false);
bool getClothWeightStrider(LLStrider<LLVector4>& strider, S32 index=0, S32 count = -1, bool map_range = false);
BOOL isEmpty() const { return mEmpty; }
BOOL isLocked() const { return mVertexLocked || mIndexLocked; }
S32 getNumVerts() const { return mNumVerts; }

View File

@ -43,7 +43,7 @@
<key>tags</key>
<array>
<!-- sample entry for debugging a specific item -->
<!-- <string>Voice</string> -->
<!-- <string>Voice</string> -->
</array>
</map>
</array>

View File

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

View File

@ -6,8 +6,7 @@
*/
attribute vec4 weight; //1
attribute vec4 weight;
uniform vec4 matrixPalette[45];

View File

@ -5,7 +5,9 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
mat4 getSkinnedTransform();
@ -13,31 +15,33 @@ void calcAtmospherics(vec3 inPositionEye);
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
vec4 pos;
vec3 norm;
vec4 pos_in = vec4(position.xyz, 1.0);
mat4 trans = getSkinnedTransform();
pos.x = dot(trans[0], gl_Vertex);
pos.y = dot(trans[1], gl_Vertex);
pos.z = dot(trans[2], gl_Vertex);
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, gl_Normal);
norm.y = dot(trans[1].xyz, gl_Normal);
norm.z = dot(trans[2].xyz, gl_Normal);
norm.x = dot(trans[0].xyz, normal);
norm.y = dot(trans[1].xyz, normal);
norm.z = dot(trans[2].xyz, normal);
norm = normalize(norm);
gl_Position = gl_ProjectionMatrix * pos;
//gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
//gl_Position = gl_ModelViewProjectionMatrix * position;
gl_FogFragCoord = length(pos.xyz);
calcAtmospherics(pos.xyz);
vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0,0,0,0));
vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), vec4(0,0,0,0));
gl_FrontColor = color;
}

View File

@ -6,6 +6,10 @@
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec3 normal;
attribute vec2 texcoord0;
vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@ -13,16 +17,17 @@ void calcAtmospherics(vec3 inPositionEye);
void main()
{
//transform vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec3 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0)).xyz;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
vec3 norm = normalize(gl_NormalMatrix * normal);
calcAtmospherics(pos.xyz);
vec4 specular = vec4(1.0);
vec4 color = calcLightingSpecular(pos, norm, gl_Color, specular, vec4(0.0));
vec4 color = calcLightingSpecular(pos, norm, diffuse_color, specular, vec4(0.0));
gl_FrontColor = color;
}

View File

@ -5,21 +5,23 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
mat4 getSkinnedTransform();
void main()
{
vec4 pos;
vec4 pos_in = vec4(position, 1.0);
mat4 trans = getSkinnedTransform();
pos.x = dot(trans[0], gl_Vertex);
pos.y = dot(trans[1], gl_Vertex);
pos.z = dot(trans[2], gl_Vertex);
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;
gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_FrontColor = diffuse_color;
gl_TexCoord[0] = vec4(texcoord0,0,1);
gl_Position = gl_ProjectionMatrix * pos;
}

View File

@ -6,6 +6,10 @@
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
mat4 getObjectSkinnedTransform();
@ -59,7 +63,7 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
vec4 pos;
vec3 norm;
@ -67,9 +71,9 @@ void main()
mat4 trans = getObjectSkinnedTransform();
trans = gl_ModelViewMatrix * trans;
pos = trans * gl_Vertex;
pos = trans * vec4(position.xyz, 1.0);
norm = gl_Vertex.xyz + gl_Normal.xyz;
norm = position.xyz + normal.xyz;
norm = normalize(( trans*vec4(norm, 1.0) ).xyz-pos.xyz);
vec4 frag_pos = gl_ProjectionMatrix * pos;
@ -80,7 +84,7 @@ void main()
calcAtmospherics(pos.xyz);
vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
// Collect normal lights
col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation, gl_LightSource[2].specular.a);
@ -90,17 +94,17 @@ void main()
col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation, gl_LightSource[6].specular.a);
col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation, gl_LightSource[7].specular.a);
vary_pointlight_col = col.rgb*gl_Color.rgb;
vary_pointlight_col = col.rgb*diffuse_color.rgb;
col.rgb = vec3(0,0,0);
// Add windlight lights
col.rgb = atmosAmbient(vec3(0.));
vary_ambient = col.rgb*gl_Color.rgb;
vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
vary_ambient = col.rgb*diffuse_color.rgb;
vary_directional = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
col.rgb = min(col.rgb*gl_Color.rgb, 1.0);
col.rgb = min(col.rgb*diffuse_color.rgb, 1.0);
gl_FrontColor = col;

View File

@ -5,7 +5,10 @@
* $/LicenseInfo$
*/
attribute vec4 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@ -62,22 +65,22 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
void main()
{
//transform vertex
vec4 vert = vec4(gl_Vertex.xyz, 1.0);
vary_texture_index = gl_Vertex.w;
gl_Position = gl_ModelViewProjectionMatrix * vert;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec4 vert = vec4(position.xyz, 1.0);
vary_texture_index = position.w;
vec4 pos = (gl_ModelViewMatrix * vert);
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
vec3 norm = normalize(gl_NormalMatrix * normal);
float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz));
vary_position = pos.xyz + gl_LightSource[0].position.xyz * (1.0-dp_directional_light)*shadow_offset;
calcAtmospherics(pos.xyz);
//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
// Collect normal lights
col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation, gl_LightSource[2].specular.a);
@ -87,7 +90,7 @@ void main()
col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation, gl_LightSource[6].specular.a);
col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation, gl_LightSource[7].specular.a);
vary_pointlight_col = col.rgb*gl_Color.rgb;
vary_pointlight_col = col.rgb*diffuse_color.rgb;
col.rgb = vec3(0,0,0);
@ -96,10 +99,10 @@ void main()
vary_light = gl_LightSource[0].position.xyz;
vary_ambient = col.rgb*gl_Color.rgb;
vary_directional.rgb = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
vary_ambient = col.rgb*diffuse_color.rgb;
vary_directional.rgb = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
col.rgb = col.rgb*gl_Color.rgb;
col.rgb = col.rgb*diffuse_color.rgb;
gl_FrontColor = col;

View File

@ -5,21 +5,23 @@
* $License$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
mat4 getObjectSkinnedTransform();
void main()
{
//transform vertex
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
mat4 mat = getObjectSkinnedTransform();
mat = gl_ModelViewMatrix * mat;
vec3 pos = (mat*gl_Vertex).xyz;
vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
vec4 p = gl_ProjectionMatrix * vec4(pos, 1.0);
p.z = max(p.z, -p.w+0.01);

View File

@ -5,7 +5,10 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
mat4 getSkinnedTransform();
@ -59,20 +62,21 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
vec4 pos;
vec3 norm;
mat4 trans = getSkinnedTransform();
pos.x = dot(trans[0], gl_Vertex);
pos.y = dot(trans[1], gl_Vertex);
pos.z = dot(trans[2], gl_Vertex);
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, gl_Normal);
norm.y = dot(trans[1].xyz, gl_Normal);
norm.z = dot(trans[2].xyz, gl_Normal);
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 = gl_ProjectionMatrix * pos;
@ -82,9 +86,9 @@ void main()
calcAtmospherics(pos.xyz);
//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
// Collect normal lights
col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation, gl_LightSource[2].specular.a);
@ -94,17 +98,17 @@ void main()
col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation, gl_LightSource[6].specular.a);
col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation, gl_LightSource[7].specular.a);
vary_pointlight_col = col.rgb*gl_Color.rgb;
vary_pointlight_col = col.rgb*diffuse_color.rgb;
col.rgb = vec3(0,0,0);
// Add windlight lights
col.rgb = atmosAmbient(vec3(0.));
vary_ambient = col.rgb*gl_Color.rgb;
vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
vary_ambient = col.rgb*diffuse_color.rgb;
vary_directional = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
col.rgb = min(col.rgb*gl_Color.rgb, 1.0);
col.rgb = min(col.rgb*diffuse_color.rgb, 1.0);
gl_FrontColor = col;

View File

@ -6,16 +6,20 @@
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
varying vec3 vary_normal;
void main()
{
//transform vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
vary_normal = normalize(gl_NormalMatrix * gl_Normal);
vary_normal = normalize(gl_NormalMatrix * normal);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -9,26 +9,31 @@
mat4 getSkinnedTransform();
attribute vec4 weight;
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
varying vec4 post_pos;
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
vec4 pos;
vec3 norm;
vec4 pos_in = vec4(position.xyz, 1.0);
mat4 trans = getSkinnedTransform();
pos.x = dot(trans[0], gl_Vertex);
pos.y = dot(trans[1], gl_Vertex);
pos.z = dot(trans[2], gl_Vertex);
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, gl_Normal);
norm.y = dot(trans[1].xyz, gl_Normal);
norm.z = dot(trans[2].xyz, gl_Normal);
norm.x = dot(trans[0].xyz, normal);
norm.y = dot(trans[1].xyz, normal);
norm.z = dot(trans[2].xyz, normal);
norm = normalize(norm);
pos = gl_ProjectionMatrix * pos;
@ -36,7 +41,7 @@ void main()
gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,7 +5,10 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec3 normal;
attribute vec2 texcoord0;
mat4 getSkinnedTransform();
@ -15,28 +18,28 @@ varying vec3 vary_normal;
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
vec4 pos;
vec3 norm;
vec4 pos_in = vec4(position.xyz, 1.0);
mat4 trans = getSkinnedTransform();
pos.x = dot(trans[0], gl_Vertex);
pos.y = dot(trans[1], gl_Vertex);
pos.z = dot(trans[2], gl_Vertex);
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, gl_Normal);
norm.y = dot(trans[1].xyz, gl_Normal);
norm.z = dot(trans[2].xyz, gl_Normal);
norm.x = dot(trans[0].xyz, normal);
norm.y = dot(trans[1].xyz, normal);
norm.z = dot(trans[2].xyz, normal);
norm = normalize(norm);
vary_normal = norm;
gl_Position = gl_ProjectionMatrix * pos;
//gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
attribute vec3 position;
varying vec2 vary_fragcoord;
uniform vec2 screen_res;
@ -13,7 +13,7 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@ -5,7 +5,11 @@
* $License$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec3 normal;
attribute vec2 texcoord0;
attribute vec2 texcoord2;
varying vec3 vary_mat0;
varying vec3 vary_mat1;
@ -15,17 +19,17 @@ mat4 getObjectSkinnedTransform();
void main()
{
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
mat4 mat = getObjectSkinnedTransform();
mat = gl_ModelViewMatrix * mat;
vec3 pos = (mat*gl_Vertex).xyz;
vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
vec3 n = normalize((mat * vec4(gl_Normal.xyz+gl_Vertex.xyz, 1.0)).xyz-pos.xyz);
vec3 b = normalize((mat * vec4(gl_MultiTexCoord2.xyz+gl_Vertex.xyz, 1.0)).xyz-pos.xyz);
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 t = cross(b, n);
vary_mat0 = vec3(t.x, b.x, n.x);
@ -33,5 +37,5 @@ void main()
vary_mat2 = vec3(t.z, b.z, n.z);
gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,7 +5,11 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec3 normal;
attribute vec2 texcoord0;
attribute vec2 texcoord2;
varying vec3 vary_mat0;
varying vec3 vary_mat1;
@ -14,16 +18,16 @@ varying vec3 vary_mat2;
void main()
{
//transform vertex
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
vec3 n = normalize(gl_NormalMatrix * gl_Normal);
vec3 b = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz);
vec3 n = normalize(gl_NormalMatrix * normal);
vec3 b = normalize(gl_NormalMatrix * vec4(texcoord2,0,1).xyz);
vec3 t = cross(b, n);
vary_mat0 = vec3(t.x, b.x, n.x);
vary_mat1 = vec3(t.y, b.y, n.y);
vary_mat2 = vec3(t.z, b.z, n.z);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,7 +5,8 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec2 texcoord0;
//////////////////////////////////////////////////////////////////////////
// The vertex shader for creating the atmospheric sky
@ -41,12 +42,12 @@ void main()
{
// World / view / projection
gl_Position = ftransform();
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
// Get relative position
vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0);
vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
// Set altitude
if (P.y > 0.)
@ -142,7 +143,7 @@ void main()
// Texture coords
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
gl_TexCoord[0].xy -= 0.5;
gl_TexCoord[0].xy /= cloud_scale.x;
gl_TexCoord[0].xy += 0.5;

View File

@ -7,27 +7,32 @@
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec3 normal;
attribute vec2 texcoord0;
varying vec3 vary_normal;
mat4 getObjectSkinnedTransform();
void main()
{
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
mat4 mat = getObjectSkinnedTransform();
mat = gl_ModelViewMatrix * mat;
vec3 pos = (mat*gl_Vertex).xyz;
vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
vec4 norm = gl_Vertex;
norm.xyz += gl_Normal.xyz;
vec4 norm = vec4(position.xyz, 1.0);
norm.xyz += normal.xyz;
norm.xyz = (mat*norm).xyz;
norm.xyz = normalize(norm.xyz-pos.xyz);
vary_normal = norm.xyz;
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
}

View File

@ -6,6 +6,10 @@
*/
attribute vec4 position;
attribute vec4 diffuse_color;
attribute vec3 normal;
attribute vec2 texcoord0;
varying vec3 vary_normal;
varying float vary_texture_index;
@ -13,11 +17,11 @@ varying float vary_texture_index;
void main()
{
//transform vertex
gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
vary_texture_index = gl_Vertex.w;
vary_normal = normalize(gl_NormalMatrix * gl_Normal);
vary_texture_index = position.w;
vary_normal = normalize(gl_NormalMatrix * normal);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -6,6 +6,9 @@
*/
attribute vec4 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void calcAtmospherics(vec3 inPositionEye);
@ -19,18 +22,17 @@ varying float vary_texture_index;
void main()
{
//transform vertex
vec4 vert = vec4(gl_Vertex.xyz, 1.0);
vary_texture_index = gl_Vertex.w;
gl_Position = gl_ModelViewProjectionMatrix*vert;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec4 vert = vec4(position.xyz, 1.0);
vec4 pos = (gl_ModelViewMatrix * vert);
vary_texture_index = position.w;
gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
calcAtmospherics(pos.xyz);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
gl_FogFragCoord = pos.z;
}

View File

@ -5,6 +5,9 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
varying vec2 vary_fragcoord;
@ -14,11 +17,12 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
vec4 tex = gl_MultiTexCoord0;
vec4 tex = vec4(texcoord0,0,1);
tex.w = 1.0;
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,13 +5,15 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void main()
{
//transform vertex
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,8 +5,9 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
varying vec2 vary_fragcoord;
@ -15,9 +16,10 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -6,15 +6,17 @@
*/
attribute vec3 position;
attribute vec4 diffuse_color;
varying vec4 vary_fragcoord;
void main()
{
//transform vertex
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
vary_fragcoord = pos;
gl_Position = pos;
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,7 +5,9 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
varying vec4 vary_light;
varying vec4 vary_fragcoord;
@ -13,15 +15,15 @@ varying vec4 vary_fragcoord;
void main()
{
//transform vertex
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
vary_fragcoord = pos;
vec4 tex = gl_MultiTexCoord0;
vec4 tex = vec4(texcoord0,0,1);
tex.w = 1.0;
vary_light = gl_MultiTexCoord0;
vary_light = vec4(texcoord0,0,1);
gl_Position = pos;
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
attribute vec3 position;
varying vec2 vary_fragcoord;
uniform vec2 screen_res;
@ -13,7 +13,7 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@ -5,6 +5,7 @@
* $/LicenseInfo$
*/
attribute vec3 position;
varying vec2 vary_fragcoord;
@ -13,7 +14,7 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@ -5,19 +5,21 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
varying vec4 post_pos;
void main()
{
//transform vertex
vec4 pos = gl_ModelViewProjectionMatrix*gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
post_pos = pos;
gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
gl_FrontColor = diffuse_color;
}

View File

@ -5,14 +5,14 @@
* $/LicenseInfo$
*/
attribute vec3 position;
varying vec4 post_pos;
void main()
{
//transform vertex
vec4 pos = gl_ModelViewProjectionMatrix*gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
post_pos = pos;

View File

@ -5,7 +5,8 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec2 texcoord0;
// SKY ////////////////////////////////////////////////////////////////////////
// The vertex shader for creating the atmospheric sky
@ -39,12 +40,12 @@ void main()
{
// World / view / projection
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = vec4(texcoord0,0,1);
// Get relative position
vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0);
//vec3 P = gl_Vertex.xyz + vec3(0,50,0);
vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
//vec3 P = position.xyz + vec3(0,50,0);
// Set altitude
if (P.y > 0.)

View File

@ -45,7 +45,7 @@ uniform vec3 env_mat[3];
//uniform vec4 shadow_clip;
uniform mat3 ssao_effect_mat;
varying vec4 vary_light;
uniform vec3 sun_dir;
varying vec2 vary_fragcoord;
vec3 vary_PositionEye;
@ -265,7 +265,7 @@ void main()
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);
float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
vec4 diffuse = texture2DRect(diffuseRect, tc);
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
@ -286,7 +286,7 @@ void main()
// the old infinite-sky shiny reflection
//
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
float sa = dot(refnormpersp, vary_light.xyz);
float sa = dot(refnormpersp, sun_dir.xyz);
vec3 dumbshiny = vary_SunlitColor*texture2D(lightFunc, vec2(sa, spec.a)).a;
// add the two types of shiny together

View File

@ -6,21 +6,16 @@
*/
attribute vec3 position;
uniform vec2 screen_res;
varying vec4 vary_light;
varying vec2 vary_fragcoord;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vec4 tex = gl_MultiTexCoord0;
tex.w = 1.0;
vary_light = gl_MultiTexCoord0;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@ -6,12 +6,14 @@
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void main()
{
//transform vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
gl_FrontColor = diffuse_color;
}

View File

@ -5,7 +5,10 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
varying vec4 vary_light;
varying vec2 vary_fragcoord;
@ -15,13 +18,14 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
vec4 tex = gl_MultiTexCoord0;
vec4 tex = vec4(texcoord0,0,1);
tex.w = 1.0;
vary_light = gl_MultiTexCoord0;
vary_light = vec4(texcoord0,0,1);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,7 +5,11 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
attribute vec2 texcoord1;
varying vec3 vary_normal;
@ -26,14 +30,14 @@ vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
void main()
{
//transform vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
vary_normal = normalize(gl_NormalMatrix * gl_Normal);
vary_normal = normalize(gl_NormalMatrix * normal);
// Transform and pass tex coords
gl_TexCoord[0].xy = texgen_object(gl_Vertex, gl_MultiTexCoord0, gl_TextureMatrix[0], gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
gl_TexCoord[0].xy = texgen_object(vec4(position, 1.0), vec4(texcoord0,0,1), gl_TextureMatrix[0], gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
vec4 t = gl_MultiTexCoord1;
vec4 t = vec4(texcoord1,0,1);
gl_TexCoord[0].zw = t.xy;
gl_TexCoord[1].xy = t.xy-vec2(2.0, 0.0);

View File

@ -6,16 +6,20 @@
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec2 texcoord0;
varying vec3 vary_normal;
void main()
{
//transform vertex
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
vary_normal = normalize(gl_NormalMatrix * gl_Normal);
vary_normal = normalize(gl_NormalMatrix * normal);
gl_FrontColor = gl_Color;
gl_FrontColor = vec4(1,1,1,1);
}

View File

@ -6,6 +6,8 @@
*/
attribute vec3 position;
void calcAtmospherics(vec3 inPositionEye);
@ -29,25 +31,25 @@ float wave(vec2 v, float t, float f, vec2 d, float s)
void main()
{
//transform vertex
vec4 position = gl_Vertex;
vec4 pos = vec4(position.xyz, 1.0);
mat4 modelViewProj = gl_ModelViewProjectionMatrix;
vec4 oPosition;
//get view vector
vec3 oEyeVec;
oEyeVec.xyz = position.xyz-eyeVec;
oEyeVec.xyz = pos.xyz-eyeVec;
float d = length(oEyeVec.xy);
float ld = min(d, 2560.0);
position.xy = eyeVec.xy + oEyeVec.xy/d*ld;
pos.xy = eyeVec.xy + oEyeVec.xy/d*ld;
view.xyz = oEyeVec;
d = clamp(ld/1536.0-0.5, 0.0, 1.0);
d *= d;
oPosition = position;
oPosition = vec4(position, 1.0);
oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
vary_position = gl_ModelViewMatrix * oPosition;
oPosition = modelViewProj * oPosition;
@ -55,17 +57,16 @@ void main()
refCoord.xyz = oPosition.xyz + vec3(0,0,0.2);
//get wave position parameter (create sweeping horizontal waves)
vec3 v = position.xyz;
vec3 v = pos.xyz;
v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0;
//push position for further horizon effect.
position.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
position.w = 1.0;
position = position*gl_ModelViewMatrix;
calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz);
pos.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
pos.w = 1.0;
pos = gl_ModelViewMatrix*pos;
calcAtmospherics(pos.xyz);
//pass wave parameters to pixel shader
vec2 bigWave = (v.xy) * vec2(0.04,0.04) + d1 * time * 0.055;
//get two normal map (detail map) texture coordinates

View File

@ -19,7 +19,6 @@ uniform float warmthAmount;
void main()
{
vec4 col = texture2DRect(diffuseMap, gl_TexCoord[0].xy);
/// CALCULATING LUMINANCE (Using NTSC lum weights)
/// http://en.wikipedia.org/wiki/Luma_%28video%29
float lum = smoothstep(minLuminance, minLuminance+1.0, dot(col.rgb, lumWeights ) );
@ -27,4 +26,5 @@ void main()
gl_FragColor.rgb = col.rgb;
gl_FragColor.a = max(col.a, mix(lum, warmth, warmthAmount) * maxExtractAlpha);
}

View File

@ -5,11 +5,13 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec2 texcoord0;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;
gl_TexCoord[0].xy = texcoord0;
}

View File

@ -5,20 +5,21 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec2 texcoord0;
uniform vec2 glowDelta;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1.0);
gl_TexCoord[0].xy = gl_MultiTexCoord0.xy + glowDelta*(-3.5);
gl_TexCoord[1].xy = gl_MultiTexCoord0.xy + glowDelta*(-2.5);
gl_TexCoord[2].xy = gl_MultiTexCoord0.xy + glowDelta*(-1.5);
gl_TexCoord[3].xy = gl_MultiTexCoord0.xy + glowDelta*(-0.5);
gl_TexCoord[0].zw = gl_MultiTexCoord0.xy + glowDelta*(0.5);
gl_TexCoord[1].zw = gl_MultiTexCoord0.xy + glowDelta*(1.5);
gl_TexCoord[2].zw = gl_MultiTexCoord0.xy + glowDelta*(2.5);
gl_TexCoord[3].zw = gl_MultiTexCoord0.xy + glowDelta*(3.5);
gl_TexCoord[0].xy = texcoord0 + glowDelta*(-3.5);
gl_TexCoord[1].xy = texcoord0 + glowDelta*(-2.5);
gl_TexCoord[2].xy = texcoord0 + glowDelta*(-1.5);
gl_TexCoord[3].xy = texcoord0 + glowDelta*(-0.5);
gl_TexCoord[0].zw = texcoord0 + glowDelta*(0.5);
gl_TexCoord[1].zw = texcoord0 + glowDelta*(1.5);
gl_TexCoord[2].zw = texcoord0 + glowDelta*(2.5);
gl_TexCoord[3].zw = texcoord0 + glowDelta*(3.5);
}

View File

@ -5,6 +5,13 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
attribute vec2 texcoord1;
attribute vec2 texcoord2;
attribute vec2 texcoord3;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
@ -26,17 +33,17 @@ vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
void main()
{
//transform vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
vec4 pos = gl_ModelViewMatrix * gl_Vertex;
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
vec4 pos = gl_ModelViewMatrix * position;
vec3 norm = normalize(gl_NormalMatrix * normal);
vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), gl_Color);
vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), diffuse_color);
gl_FrontColor = color;
gl_TexCoord[0] = texgen_object(gl_Vertex,gl_MultiTexCoord0,gl_TextureMatrix[0],gl_ObjectPlaneS[0],gl_ObjectPlaneT[0]);
gl_TexCoord[1] = gl_TextureMatrix[1]*gl_MultiTexCoord1;
gl_TexCoord[2] = texgen_object(gl_Vertex,gl_MultiTexCoord2,gl_TextureMatrix[2],gl_ObjectPlaneS[2],gl_ObjectPlaneT[2]);
gl_TexCoord[3] = gl_TextureMatrix[3]*gl_MultiTexCoord3;
gl_TexCoord[0] = texgen_object(vec4(position.xyz, 1.0),vec4(texcoord0,0,1),gl_TextureMatrix[0],gl_ObjectPlaneS[0],gl_ObjectPlaneT[0]);
gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(texcoord1,0,1);
gl_TexCoord[2] = texgen_object(vec4(position.xyz, 1.0),vec4(texcoord2,0,1),gl_TextureMatrix[2],gl_ObjectPlaneS[2],gl_ObjectPlaneT[2]);
gl_TexCoord[3] = gl_TextureMatrix[3]*vec4(texcoord3,0,1);
}

View File

@ -6,6 +6,7 @@
*/
attribute vec3 position;
void calcAtmospherics(vec3 inPositionEye);
@ -27,7 +28,6 @@ float wave(vec2 v, float t, float f, vec2 d, float s)
void main()
{
//transform vertex
vec4 position = gl_Vertex;
mat4 modelViewProj = gl_ModelViewProjectionMatrix;
vec4 oPosition;
@ -45,7 +45,7 @@ void main()
d = clamp(ld/1536.0-0.5, 0.0, 1.0);
d *= d;
oPosition = position;
oPosition = vec4(position, 1.0);
oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
oPosition = modelViewProj * oPosition;
refCoord.xyz = oPosition.xyz + vec3(0,0,0.2);
@ -55,11 +55,12 @@ void main()
v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0;
//push position for further horizon effect.
position.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
position.w = 1.0;
position = position*gl_ModelViewMatrix;
vec4 pos;
pos.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
pos.w = 1.0;
pos = gl_ModelViewMatrix*pos;
calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz);
calcAtmospherics(pos.xyz);
//pass wave parameters to pixel shader

View File

@ -5,12 +5,15 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = vec4(texcoord0,0,1);
gl_FrontColor = diffuse_color;
}

View File

@ -5,11 +5,14 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec2 texcoord0;
attribute vec2 texcoord1;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = vec4(texcoord0,0,1);
gl_TexCoord[1] = vec4(texcoord1,0,1);
}

View File

@ -6,10 +6,10 @@
*/
uniform vec4 highlight_color;
uniform sampler2D diffuseMap;
void main()
{
gl_FragColor = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy);
gl_FragColor = highlight_color*texture2D(diffuseMap, gl_TexCoord[0].xy);
}

View File

@ -5,23 +5,13 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec2 texcoord0;
void main()
{
//transform vertex
gl_Position = ftransform();
vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
pos = normalize(pos);
float d = dot(pos, normalize(gl_NormalMatrix * gl_Normal));
d *= d;
d = 1.0 - d;
d *= d;
d = min(d, gl_Color.a*2.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_FrontColor.rgb = gl_Color.rgb;
gl_FrontColor.a = max(d, gl_Color.a);
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
}

View File

@ -5,8 +5,10 @@
* $/LicenseInfo$
*/
attribute vec3 position;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
}

View File

@ -5,12 +5,14 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_FrontColor = diffuse_color;
gl_TexCoord[0] = vec4(texcoord0,0,1);
}

View File

@ -6,11 +6,14 @@
*/
attribute vec3 position;
attribute vec2 texcoord0;
attribute vec2 texcoord1;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = vec4(texcoord0,0,1);
gl_TexCoord[1] = vec4(texcoord1,0,1);
}

View File

@ -6,11 +6,15 @@
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1);
gl_TexCoord[0] = vec4(texcoord0,0,1);
gl_FrontColor = diffuse_color;
}

View File

@ -6,11 +6,16 @@
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
attribute vec2 texcoord1;
void main()
{
//transform vertex
gl_Position = gl_ModelViewProjectionMatrix*gl_Vertex;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[1] = gl_TextureMatrix[1] * gl_MultiTexCoord1;
gl_FrontColor = gl_Color;
gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
gl_TexCoord[1] = gl_TextureMatrix[1] * vec4(texcoord1,0,1);
gl_FrontColor = diffuse_color;
}

View File

@ -6,6 +6,10 @@
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void calcAtmospherics(vec3 inPositionEye);
mat4 getObjectSkinnedTransform();
@ -15,21 +19,21 @@ void main()
mat4 mat = getObjectSkinnedTransform();
mat = gl_ModelViewMatrix * mat;
vec3 pos = (mat*gl_Vertex).xyz;
vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
vec4 norm = gl_Vertex;
norm.xyz += gl_Normal.xyz;
vec4 norm = vec4(position.xyz, 1.0);
norm.xyz += normal.xyz;
norm.xyz = (mat*norm).xyz;
norm.xyz = normalize(norm.xyz-pos.xyz);
vec3 ref = reflect(pos.xyz, -norm.xyz);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
calcAtmospherics(pos.xyz);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);

View File

@ -6,6 +6,10 @@
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec3 normal;
attribute vec2 texcoord0;
void calcAtmospherics(vec3 inPositionEye);
@ -14,18 +18,18 @@ uniform vec4 origin;
void main()
{
//transform vertex
gl_Position = ftransform();
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
vec3 norm = normalize(gl_NormalMatrix * normal);
vec3 ref = reflect(pos.xyz, -norm);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
calcAtmospherics(pos.xyz);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
gl_FogFragCoord = pos.z;
}

View File

@ -6,6 +6,9 @@
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void calcAtmospherics(vec3 inPositionEye);
mat4 getObjectSkinnedTransform();
@ -13,21 +16,16 @@ mat4 getObjectSkinnedTransform();
void main()
{
//transform vertex
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
mat4 mat = getObjectSkinnedTransform();
mat = gl_ModelViewMatrix * mat;
vec3 pos = (mat*gl_Vertex).xyz;
vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
vec4 norm = gl_Vertex;
norm.xyz += gl_Normal.xyz;
norm.xyz = (mat*norm).xyz;
norm.xyz = normalize(norm.xyz-pos.xyz);
calcAtmospherics(pos.xyz);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);

View File

@ -5,21 +5,24 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void calcAtmospherics(vec3 inPositionEye);
void main()
{
//transform vertex
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
calcAtmospherics(pos.xyz);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
gl_FogFragCoord = pos.z;
}

View File

@ -5,7 +5,10 @@
* $License$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@ -16,21 +19,21 @@ void main()
mat4 mat = getObjectSkinnedTransform();
mat = gl_ModelViewMatrix * mat;
vec3 pos = (mat*gl_Vertex).xyz;
vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
vec4 norm = gl_Vertex;
norm.xyz += gl_Normal.xyz;
vec4 norm = vec4(position.xyz, 1.0);
norm.xyz += normal.xyz;
norm.xyz = (mat*norm).xyz;
norm.xyz = normalize(norm.xyz-pos.xyz);
vec3 ref = reflect(pos.xyz, -norm.xyz);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
calcAtmospherics(pos.xyz);
vec4 color = calcLighting(pos.xyz, norm.xyz, gl_Color, vec4(0.));
vec4 color = calcLighting(pos.xyz, norm.xyz, diffuse_color, vec4(0.));
gl_FrontColor = color;
gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);

View File

@ -5,7 +5,10 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void calcAtmospherics(vec3 inPositionEye);
@ -14,14 +17,14 @@ uniform vec4 origin;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
vec3 norm = normalize(gl_NormalMatrix * normal);
calcAtmospherics(pos.xyz);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
vec3 ref = reflect(pos.xyz, -norm);

View File

@ -5,7 +5,10 @@
* $License$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@ -14,21 +17,21 @@ mat4 getObjectSkinnedTransform();
void main()
{
//transform vertex
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
mat4 mat = getObjectSkinnedTransform();
mat = gl_ModelViewMatrix * mat;
vec3 pos = (mat*gl_Vertex).xyz;
vec3 pos = (mat*vec4(position.xyz, 1.0)).xyz;
vec4 norm = gl_Vertex;
norm.xyz += gl_Normal.xyz;
vec4 norm = vec4(position.xyz, 1.0);
norm.xyz += normal.xyz;
norm.xyz = (mat*norm).xyz;
norm.xyz = normalize(norm.xyz-pos.xyz);
calcAtmospherics(pos.xyz);
vec4 color = calcLighting(pos.xyz, norm.xyz, gl_Color, vec4(0.));
vec4 color = calcLighting(pos.xyz, norm.xyz, diffuse_color, vec4(0.));
gl_FrontColor = color;
gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);

View File

@ -5,7 +5,10 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@ -13,16 +16,15 @@ void calcAtmospherics(vec3 inPositionEye);
void main()
{
//transform vertex
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
vec4 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0));
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
vec3 norm = normalize(gl_NormalMatrix * normal);
calcAtmospherics(pos.xyz);
vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
gl_FrontColor = color;
gl_FogFragCoord = pos.z;

View File

@ -6,6 +6,10 @@
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec3 normal;
attribute vec2 texcoord0;
vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@ -13,17 +17,17 @@ void calcAtmospherics(vec3 inPositionEye);
void main()
{
//transform vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
vec3 pos = (gl_ModelViewMatrix * vec4(position.xyz, 1.0)).xyz;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
vec3 norm = normalize(gl_NormalMatrix * normal);
calcAtmospherics(pos.xyz);
// vec4 specular = specularColor;
vec4 specular = vec4(1.0);
vec4 color = calcLightingSpecular(pos, norm, gl_Color, specular, vec4(0.0));
vec4 color = calcLightingSpecular(pos, norm, diffuse_color, specular, vec4(0.0));
gl_FrontColor = color;
gl_FogFragCoord = pos.z;

View File

@ -5,7 +5,10 @@
* $License$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@ -59,18 +62,18 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
void main()
{
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
mat4 mat = getObjectSkinnedTransform();
mat = gl_ModelViewMatrix * mat;
vec3 pos = (mat*gl_Vertex).xyz;
vec3 pos = (mat*position).xyz;
gl_Position = gl_ProjectionMatrix * vec4(pos, 1.0);
vec4 n = gl_Vertex;
n.xyz += gl_Normal.xyz;
vec4 n = position;
n.xyz += normal.xyz;
n.xyz = (mat*n).xyz;
n.xyz = normalize(n.xyz-pos.xyz);
@ -81,8 +84,8 @@ void main()
calcAtmospherics(pos.xyz);
//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
// Collect normal lights
col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation, gl_LightSource[2].specular.a);
@ -92,23 +95,23 @@ void main()
col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation, gl_LightSource[6].specular.a);
col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation, gl_LightSource[7].specular.a);
vary_pointlight_col = col.rgb*gl_Color.rgb;
vary_pointlight_col = col.rgb*diffuse_color.rgb;
col.rgb = vec3(0,0,0);
// Add windlight lights
col.rgb = atmosAmbient(vec3(0.));
vary_ambient = col.rgb*gl_Color.rgb;
vary_directional.rgb = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
vary_ambient = col.rgb*diffuse_color.rgb;
vary_directional.rgb = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
col.rgb = min(col.rgb*gl_Color.rgb, 1.0);
col.rgb = min(col.rgb*diffuse_color.rgb, 1.0);
gl_FrontColor = col;
gl_FogFragCoord = pos.z;
pos.xyz = (gl_ModelViewProjectionMatrix * gl_Vertex).xyz;
pos.xyz = (gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0)).xyz;
vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
}

View File

@ -5,7 +5,10 @@
* $/LicenseInfo$
*/
attribute vec4 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@ -61,22 +64,22 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
void main()
{
//transform vertex
vec4 vert = vec4(gl_Vertex.xyz, 1.0);
vary_texture_index = gl_Vertex.w;
gl_Position = gl_ModelViewProjectionMatrix * vert;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec4 vert = vec4(position.xyz, 1.0);
vary_texture_index = position.w;
vec4 pos = (gl_ModelViewMatrix * vert);
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
vec3 norm = normalize(gl_NormalMatrix * normal);
float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz));
vary_position = pos.xyz + gl_LightSource[0].position.xyz * (1.0-dp_directional_light)*shadow_offset;
calcAtmospherics(pos.xyz);
//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
// Collect normal lights
col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation, gl_LightSource[2].specular.a);
@ -86,17 +89,17 @@ void main()
col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation, gl_LightSource[6].specular.a);
col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation, gl_LightSource[7].specular.a);
vary_pointlight_col = col.rgb*gl_Color.rgb;
vary_pointlight_col = col.rgb*diffuse_color.rgb;
col.rgb = vec3(0,0,0);
// Add windlight lights
col.rgb = atmosAmbient(vec3(0.));
vary_ambient = col.rgb*gl_Color.rgb;
vary_directional.rgb = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
vary_ambient = col.rgb*diffuse_color.rgb;
vary_directional.rgb = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
col.rgb = col.rgb*gl_Color.rgb;
col.rgb = col.rgb*diffuse_color.rgb;
gl_FrontColor = col;

View File

@ -6,6 +6,10 @@
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
mat4 getSkinnedTransform();
@ -61,20 +65,21 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
vec4 pos;
vec3 norm;
mat4 trans = getSkinnedTransform();
pos.x = dot(trans[0], gl_Vertex);
pos.y = dot(trans[1], gl_Vertex);
pos.z = dot(trans[2], gl_Vertex);
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, gl_Normal);
norm.y = dot(trans[1].xyz, gl_Normal);
norm.z = dot(trans[2].xyz, gl_Normal);
norm.x = dot(trans[0].xyz, normal);
norm.y = dot(trans[1].xyz, normal);
norm.z = dot(trans[2].xyz, normal);
norm = normalize(norm);
gl_Position = gl_ProjectionMatrix * pos;
@ -84,9 +89,9 @@ void main()
calcAtmospherics(pos.xyz);
//vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
//vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
vec4 col = vec4(0.0, 0.0, 0.0, gl_Color.a);
vec4 col = vec4(0.0, 0.0, 0.0, diffuse_color.a);
// Collect normal lights
col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].spotDirection.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation, gl_LightSource[2].specular.a);
@ -96,17 +101,17 @@ void main()
col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].spotDirection.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation, gl_LightSource[6].specular.a);
col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLightOrSpotLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].spotDirection.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation, gl_LightSource[7].specular.a);
vary_pointlight_col = col.rgb*gl_Color.rgb;
vary_pointlight_col = col.rgb*diffuse_color.rgb;
col.rgb = vec3(0,0,0);
// Add windlight lights
col.rgb = atmosAmbient(vec3(0.));
vary_ambient = col.rgb*gl_Color.rgb;
vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
vary_ambient = col.rgb*diffuse_color.rgb;
vary_directional = diffuse_color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-diffuse_color.a)*(1.0-diffuse_color.a)));
col.rgb = min(col.rgb*gl_Color.rgb, 1.0);
col.rgb = min(col.rgb*diffuse_color.rgb, 1.0);
gl_FrontColor = col;

View File

@ -6,6 +6,7 @@
*/
attribute vec3 position;
varying vec2 vary_fragcoord;
uniform vec2 screen_res;
@ -13,7 +14,7 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@ -6,6 +6,8 @@
*/
attribute vec3 position;
attribute vec2 texcoord0;
uniform vec2 screen_res;
@ -14,13 +16,11 @@ varying vec2 vary_fragcoord;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
vec4 tex = gl_MultiTexCoord0;
tex.w = 1.0;
vary_light = gl_MultiTexCoord0;
vary_light = vec4(texcoord0,0,1);
}

View File

@ -5,6 +5,10 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
varying vec4 vary_light;
@ -15,13 +19,14 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
vec4 tex = gl_MultiTexCoord0;
vec4 tex = vec4(texcoord0,0,1);
tex.w = 1.0;
vary_light = gl_MultiTexCoord0;
vary_light = vec4(texcoord0,0,1);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -6,6 +6,8 @@
*/
attribute vec3 position;
attribute vec2 texcoord0;
uniform vec2 texelSize;
uniform vec2 blurDirection;
@ -14,10 +16,10 @@ uniform float blurWidth;
void main(void)
{
// Transform vertex
gl_Position = ftransform();
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
vec2 blurDelta = texelSize * blurDirection * vec2(blurWidth, blurWidth);
vec2 s = gl_MultiTexCoord0.st - (blurDelta * 3.0);
vec2 s = vec4(texcoord0,0,1).st - (blurDelta * 3.0);
// for (int i = 0; i < 7; i++) {
// gl_TexCoord[i].st = s + (i * blurDelta);

View File

@ -6,11 +6,15 @@
*/
attribute vec3 position;
attribute vec2 texcoord0;
attribute vec2 texcoord1;
void main(void)
{
//transform vertex
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = vec4(texcoord0,0,1);
gl_TexCoord[1] = vec4(texcoord1,0,1);
}

View File

@ -6,6 +6,12 @@
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
attribute vec2 texcoord1;
void calcAtmospherics(vec3 inPositionEye);
@ -28,24 +34,24 @@ vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
void main()
{
//transform vertex
gl_Position = ftransform();
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
vec4 pos = gl_ModelViewMatrix * gl_Vertex;
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
vec4 pos = gl_ModelViewMatrix * vec4(position.xyz, 1.0);
vec3 norm = normalize(gl_NormalMatrix * normal);
calcAtmospherics(pos.xyz);
/// Potentially better without it for water.
pos /= pos.w;
calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz);
vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0));
vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0));
gl_FrontColor = color;
// Transform and pass tex coords
gl_TexCoord[0].xy = texgen_object(gl_Vertex, gl_MultiTexCoord0, gl_TextureMatrix[0], gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
gl_TexCoord[0].xy = texgen_object(vec4(position.xyz, 1.0), vec4(texcoord0,0,1), gl_TextureMatrix[0], gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
vec4 t = gl_MultiTexCoord1;
vec4 t = vec4(texcoord1,0,1);
gl_TexCoord[0].zw = t.xy;
gl_TexCoord[1].xy = t.xy-vec2(2.0, 0.0);

View File

@ -5,8 +5,6 @@
* $/LicenseInfo$
*/
float calcDirectionalLight(vec3 n, vec3 l);
float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);

View File

@ -13,23 +13,28 @@ uniform vec4 origin;
varying float vary_texture_index;
attribute vec4 position;
attribute vec3 normal;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
void main()
{
//transform vertex
vec4 vert = vec4(gl_Vertex.xyz,1.0);
vary_texture_index = gl_Vertex.w;
gl_Position = gl_ModelViewProjectionMatrix*vert;
vec4 vert = vec4(position.xyz,1.0);
vary_texture_index = position.w;
vec4 pos = (gl_ModelViewMatrix * vert);
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
vec3 norm = normalize(gl_NormalMatrix * normal);
vec3 ref = reflect(pos.xyz, -norm);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
calcAtmospherics(pos.xyz);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
gl_FogFragCoord = pos.z;
}

View File

@ -5,6 +5,11 @@
* $/LicenseInfo$
*/
attribute vec4 position;
attribute vec2 texcoord0;
attribute vec3 normal;
attribute vec4 diffuse_color;
void calcAtmospherics(vec3 inPositionEye);
@ -14,16 +19,15 @@ varying float vary_texture_index;
void main()
{
//transform vertex
vec4 vert = vec4(gl_Vertex.xyz,1.0);
vary_texture_index = gl_Vertex.w;
gl_Position = gl_ModelViewProjectionMatrix*vert;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec4 vert = vec4(position.xyz,1.0);
vary_texture_index = position.w;
vec4 pos = (gl_ModelViewMatrix * vert);
gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
calcAtmospherics(pos.xyz);
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
gl_FogFragCoord = pos.z;
}

View File

@ -6,6 +6,10 @@
*/
attribute vec4 position;
attribute vec2 texcoord0;
attribute vec3 normal;
attribute vec4 diffuse_color;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
@ -18,20 +22,20 @@ uniform vec4 origin;
void main()
{
//transform vertex
vec4 vert = vec4(gl_Vertex.xyz,1.0);
vary_texture_index = gl_Vertex.w;
gl_Position = gl_ModelViewProjectionMatrix*vert;
vec4 vert = vec4(position.xyz,1.0);
vary_texture_index = position.w;
vec4 pos = (gl_ModelViewMatrix * vert);
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
vec3 norm = normalize(gl_NormalMatrix * normal);
vec3 ref = reflect(pos.xyz, -norm);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0,0,1);
gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
calcAtmospherics(pos.xyz);
gl_FrontColor = calcLighting(pos.xyz, norm, gl_Color, vec4(0.0));
gl_FrontColor = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.0));
gl_FogFragCoord = pos.z;
}

View File

@ -7,6 +7,11 @@
attribute vec4 position;
attribute vec2 texcoord0;
attribute vec3 normal;
attribute vec4 diffuse_color;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@ -15,18 +20,19 @@ varying float vary_texture_index;
void main()
{
//transform vertex
vec4 vert = vec4(gl_Vertex.xyz,1.0);
vary_texture_index = gl_Vertex.w;
gl_Position = gl_ModelViewProjectionMatrix*vert;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
vec4 vert = vec4(position.xyz,1.0);
vary_texture_index = position.w;
vec4 pos = (gl_ModelViewMatrix * vert);
gl_Position = gl_ModelViewProjectionMatrix*vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * vec4(texcoord0, 0, 1);
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
vec3 norm = normalize(gl_NormalMatrix * normal);
calcAtmospherics(pos.xyz);
vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
vec4 color = calcLighting(pos.xyz, norm, diffuse_color, vec4(0.));
gl_FrontColor = color;
gl_FogFragCoord = pos.z;

View File

@ -5,7 +5,8 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec2 texcoord0;
//////////////////////////////////////////////////////////////////////////
// The vertex shader for creating the atmospheric sky
@ -41,12 +42,12 @@ void main()
{
// World / view / projection
gl_Position = ftransform();
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
// Get relative position
vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0);
vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
// Set altitude
if (P.y > 0.)
@ -142,7 +143,7 @@ void main()
// Texture coords
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
gl_TexCoord[0].xy -= 0.5;
gl_TexCoord[0].xy /= cloud_scale.x;
gl_TexCoord[0].xy += 0.5;

View File

@ -6,6 +6,8 @@
*/
attribute vec3 position;
attribute vec2 texcoord0;
// SKY ////////////////////////////////////////////////////////////////////////
// The vertex shader for creating the atmospheric sky
@ -39,12 +41,12 @@ void main()
{
// World / view / projection
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_TexCoord[0] = vec4(texcoord0,0,1);
// Get relative position
vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0);
//vec3 P = gl_Vertex.xyz + vec3(0,50,0);
vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0);
//vec3 P = position.xyz + vec3(0,50,0);
// Set altitude
if (P.y > 0.)

View File

@ -5,38 +5,39 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec3 normal;
attribute vec2 texcoord0;
attribute vec4 clothing;
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
mat4 getSkinnedTransform();
void calcAtmospherics(vec3 inPositionEye);
attribute vec4 clothing; //4
attribute vec4 gWindDir; //7
attribute vec4 gSinWaveParams; //3
attribute vec4 gGravity; //5
uniform vec4 gWindDir;
uniform vec4 gSinWaveParams;
uniform vec4 gGravity;
const vec4 gMinMaxConstants = vec4(1.0, 0.166666, 0.0083143, .00018542); // #minimax-generated coefficients
const vec4 gPiConstants = vec4(0.159154943, 6.28318530, 3.141592653, 1.5707963); // # {1/2PI, 2PI, PI, PI/2}
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0] = vec4(texcoord0,0,1);
vec4 pos;
mat4 trans = getSkinnedTransform();
vec3 norm;
norm.x = dot(trans[0].xyz, gl_Normal);
norm.y = dot(trans[1].xyz, gl_Normal);
norm.z = dot(trans[2].xyz, gl_Normal);
norm.x = dot(trans[0].xyz, normal);
norm.y = dot(trans[1].xyz, normal);
norm.z = dot(trans[2].xyz, normal);
norm = normalize(norm);
//wind
vec4 windEffect;
windEffect = vec4(dot(norm, gWindDir.xyz));
pos.x = dot(trans[2].xyz, gl_Vertex.xyz);
pos.x = dot(trans[2].xyz, position.xyz);
windEffect.xyz = pos.x * vec3(0.015, 0.015, 0.015)
+ windEffect.xyz;
windEffect.w = windEffect.w * 2.0 + 1.0; // move wind offset value to [-1, 3]
@ -83,7 +84,7 @@ void main()
sinWave.xyz = max(sinWave.xyz, vec3(-1.0, -1.0, -1.0)); // clamp to underlying body shape
offsetPos = clothing * sinWave.x; // multiply wind effect times clothing displacement
temp2 = gWindDir*sinWave.z + vec4(norm,0); // calculate normal offset due to wind oscillation
offsetPos = vec4(1.0,1.0,1.0,0.0)*offsetPos+gl_Vertex; // add to offset vertex position, and zero out effect from w
offsetPos = vec4(1.0,1.0,1.0,0.0)*offsetPos+vec4(position.xyz, 1.0); // add to offset vertex position, and zero out effect from w
norm += temp2.xyz*2.0; // add sin wave effect on normals (exaggerated)
//add "backlighting" effect
@ -101,7 +102,7 @@ void main()
calcAtmospherics(pos.xyz);
vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.0));
vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), vec4(0.0));
gl_FrontColor = color;
gl_Position = gl_ProjectionMatrix * pos;

View File

@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
attribute vec3 position;
varying vec2 vary_fragcoord;
uniform vec2 screen_res;
@ -13,7 +13,7 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@ -5,6 +5,7 @@
* $/LicenseInfo$
*/
attribute vec3 position;
varying vec2 vary_fragcoord;
@ -13,7 +14,7 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@ -5,6 +5,9 @@
* $/LicenseInfo$
*/
attribute vec3 position;
attribute vec4 diffuse_color;
attribute vec2 texcoord0;
varying vec2 vary_fragcoord;
@ -14,11 +17,12 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
vec4 tex = gl_MultiTexCoord0;
vec4 tex = vec4(texcoord0,0,1);
tex.w = 1.0;
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,18 +5,20 @@
* $/LicenseInfo$
*/
varying vec2 vary_fragcoord;
uniform vec2 screen_res;
attribute vec3 position;
attribute vec4 diffuse_color;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
gl_FrontColor = gl_Color;
gl_FrontColor = diffuse_color;
}

View File

@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
attribute vec3 position;
varying vec2 vary_fragcoord;
uniform vec2 screen_res;
@ -13,7 +13,7 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
attribute vec3 position;
varying vec2 vary_fragcoord;
uniform vec2 screen_res;
@ -13,7 +13,7 @@ uniform vec2 screen_res;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
}

View File

@ -6,6 +6,8 @@
*/
attribute vec3 position;
attribute vec2 texcoord0;
uniform vec2 screen_res;
@ -14,13 +16,10 @@ varying vec2 vary_fragcoord;
void main()
{
//transform vertex
gl_Position = ftransform();
vec4 pos = gl_ModelViewProjectionMatrix * vec4(position.xyz, 1.0);
gl_Position = pos;
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
vec4 tex = gl_MultiTexCoord0;
tex.w = 1.0;
vary_light = gl_MultiTexCoord0;
vary_light = vec4(texcoord0,0,1);
}

View File

@ -6,7 +6,6 @@
*/
float calcDirectionalLight(vec3 n, vec3 l);
float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float is_pointlight);

View File

@ -3925,7 +3925,7 @@ void LLAgent::renderAutoPilotTarget()
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
// lovely green
glColor4f(0.f, 1.f, 1.f, 1.f);
gGL.diffuseColor4f(0.f, 1.f, 1.f, 1.f);
target_global = mAutoPilotTargetGlobal;

View File

@ -384,7 +384,7 @@ BOOL LLFacePool::LLOverrideFaceColor::sOverrideFaceColor = FALSE;
void LLFacePool::LLOverrideFaceColor::setColor(const LLColor4& color)
{
glColor4fv(color.mV);
gGL.diffuseColor4fv(color.mV);
}
void LLFacePool::LLOverrideFaceColor::setColor(const LLColor4U& color)
@ -394,7 +394,7 @@ void LLFacePool::LLOverrideFaceColor::setColor(const LLColor4U& color)
void LLFacePool::LLOverrideFaceColor::setColor(F32 r, F32 g, F32 b, F32 a)
{
glColor4f(r,g,b,a);
gGL.diffuseColor4f(r,g,b,a);
}

View File

@ -54,7 +54,7 @@ static BOOL deferred_render = FALSE;
LLDrawPoolAlpha::LLDrawPoolAlpha(U32 type) :
LLRenderPass(type), current_shader(NULL), target_shader(NULL),
simple_shader(NULL), fullbright_shader(NULL),
simple_shader(NULL), fullbright_shader(NULL), emissive_shader(NULL),
mColorSFactor(LLRender::BF_UNDEF), mColorDFactor(LLRender::BF_UNDEF),
mAlphaSFactor(LLRender::BF_UNDEF), mAlphaDFactor(LLRender::BF_UNDEF)
{
@ -175,11 +175,13 @@ void LLDrawPoolAlpha::beginRenderPass(S32 pass)
{
simple_shader = &gObjectSimpleWaterAlphaMaskProgram;
fullbright_shader = &gObjectFullbrightWaterAlphaMaskProgram;
emissive_shader = &gObjectEmissiveWaterProgram;
}
else
{
simple_shader = &gObjectSimpleAlphaMaskProgram;
fullbright_shader = &gObjectFullbrightAlphaMaskProgram;
emissive_shader = &gObjectEmissiveProgram;
}
if (mVertexShaderLevel > 0)
@ -319,20 +321,22 @@ void LLDrawPoolAlpha::render(S32 pass)
BOOL shaders = gPipeline.canUseVertexShaders();
if(shaders)
{
gObjectFullbrightNonIndexedProgram.bind();
gHighlightProgram.bind();
gHighlightProgram.uniform4f("highlight_color", 1,0,0,1);
}
else
{
gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
gGL.diffuseColor4f(1,0,0,1);
}
glColor4f(1,0,0,1);
LLViewerFetchedTexture::sSmokeImagep->addTextureStats(1024.f*1024.f);
gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sSmokeImagep, TRUE) ;
renderAlphaHighlight(LLVertexBuffer::MAP_VERTEX |
LLVertexBuffer::MAP_TEXCOORD0);
if(shaders)
{
gObjectFullbrightNonIndexedProgram.unbind();
gHighlightProgram.unbind();
}
}
}
@ -489,22 +493,25 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
// If this alpha mesh has glow, then draw it a second time to add the destination-alpha (=glow). Interleaving these state-changing calls could be expensive, but glow must be drawn Z-sorted with alpha.
if (draw_glow_for_this_partition &&
params.mGlowColor.mV[3] > 0)
params.mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_EMISSIVE))
{
// install glow-accumulating blend mode
gGL.blendFunc(LLRender::BF_ZERO, LLRender::BF_ONE, // don't touch color
LLRender::BF_ONE, LLRender::BF_ONE); // add to alpha (glow)
emissive_shader->bind();
// glow doesn't use vertex colors from the mesh data
params.mVertexBuffer->setBuffer(mask & ~LLVertexBuffer::MAP_COLOR);
glColor4ubv(params.mGlowColor.mV);
params.mVertexBuffer->setBuffer((mask & ~LLVertexBuffer::MAP_COLOR) | LLVertexBuffer::MAP_EMISSIVE);
// do the actual drawing, again
params.mVertexBuffer->drawRange(params.mDrawMode, params.mStart, params.mEnd, params.mCount, params.mOffset);
gPipeline.addTrianglesDrawn(params.mCount, params.mDrawMode);
// restore our alpha blend mode
gGL.blendFunc(mColorSFactor, mColorDFactor, mAlphaSFactor, mAlphaDFactor);
current_shader->bind();
}
if (tex_setup)

View File

@ -78,6 +78,7 @@ private:
LLGLSLShader* target_shader;
LLGLSLShader* simple_shader;
LLGLSLShader* fullbright_shader;
LLGLSLShader* emissive_shader;
// our 'normal' alpha blend function for this pass
LLRender::eBlendFactor mColorSFactor;

View File

@ -263,7 +263,6 @@ void LLDrawPoolAvatar::beginPostDeferredAlpha()
gPipeline.bindDeferredShader(*sVertexProgram);
sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
}
void LLDrawPoolAvatar::beginDeferredRiggedAlpha()
@ -314,8 +313,7 @@ void LLDrawPoolAvatar::endPostDeferredAlpha()
// if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done
sRenderingSkinned = FALSE;
sSkipOpaque = FALSE;
disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
gPipeline.unbindDeferredShader(*sVertexProgram);
sDiffuseChannel = 0;
sShaderLevel = mVertexShaderLevel;
@ -362,13 +360,12 @@ void LLDrawPoolAvatar::beginShadowPass(S32 pass)
}
//gGL.setAlphaRejectSettings(LLRender::CF_GREATER_EQUAL, 0.2f);
glColor4f(1,1,1,1);
gGL.diffuseColor4f(1,1,1,1);
if ((sShaderLevel > 0)) // for hardware blending
{
sRenderingSkinned = TRUE;
sVertexProgram->bind();
enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
}
}
else
@ -389,7 +386,6 @@ void LLDrawPoolAvatar::endShadowPass(S32 pass)
{
sRenderingSkinned = FALSE;
sVertexProgram->unbind();
disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
}
}
else
@ -492,11 +488,6 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
//reset vertex buffer mappings
LLVertexBuffer::unbind();
if (pass == 0)
{ //make sure no stale colors are left over from a previous render
glColor4f(1,1,1,1);
}
if (LLPipeline::sImpostorRender)
{ //impostor render does not have impostors or rigid rendering
pass += 2;
@ -535,6 +526,11 @@ void LLDrawPoolAvatar::beginRenderPass(S32 pass)
beginRiggedGlow();
break;
}
if (pass == 0)
{ //make sure no stale colors are left over from a previous render
gGL.diffuseColor4f(1,1,1,1);
}
}
void LLDrawPoolAvatar::endRenderPass(S32 pass)
@ -604,11 +600,11 @@ void LLDrawPoolAvatar::beginRigid()
{
if (LLPipeline::sUnderWaterRender)
{
sVertexProgram = &gObjectAlphaMaskNonIndexedWaterProgram;
sVertexProgram = &gObjectAlphaMaskNoColorWaterProgram;
}
else
{
sVertexProgram = &gObjectAlphaMaskNonIndexedProgram;
sVertexProgram = &gObjectAlphaMaskNoColorProgram;
}
if (sVertexProgram != NULL)
@ -692,11 +688,11 @@ void LLDrawPoolAvatar::beginSkinned()
{
if (LLPipeline::sUnderWaterRender)
{
sVertexProgram = &gObjectAlphaMaskNonIndexedWaterProgram;
sVertexProgram = &gObjectAlphaMaskNoColorWaterProgram;
}
else
{
sVertexProgram = &gObjectAlphaMaskNonIndexedProgram;
sVertexProgram = &gObjectAlphaMaskNoColorProgram;
}
}
@ -705,17 +701,6 @@ void LLDrawPoolAvatar::beginSkinned()
sRenderingSkinned = TRUE;
sVertexProgram->bind();
if (sShaderLevel >= SHADER_LEVEL_CLOTH)
{
enable_cloth_weights(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING]);
}
enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
if (sShaderLevel >= SHADER_LEVEL_BUMP)
{
enable_binormals(sVertexProgram->mAttribute[LLViewerShaderMgr::BINORMAL]);
}
sVertexProgram->enableTexture(LLViewerShaderMgr::BUMP_MAP);
gGL.getTexUnit(0)->activate();
}
@ -743,16 +728,6 @@ void LLDrawPoolAvatar::endSkinned()
sRenderingSkinned = FALSE;
sVertexProgram->disableTexture(LLViewerShaderMgr::BUMP_MAP);
gGL.getTexUnit(0)->activate();
disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
if (sShaderLevel >= SHADER_LEVEL_BUMP)
{
disable_binormals(sVertexProgram->mAttribute[LLViewerShaderMgr::BINORMAL]);
}
if ((sShaderLevel >= SHADER_LEVEL_CLOTH))
{
disable_cloth_weights(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_CLOTHING]);
}
sVertexProgram->unbind();
sShaderLevel = mVertexShaderLevel;
}
@ -1027,8 +1002,6 @@ void LLDrawPoolAvatar::beginDeferredSkinned()
sVertexProgram->bind();
sDiffuseChannel = sVertexProgram->enableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
enable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
gGL.getTexUnit(0)->activate();
}
@ -1036,7 +1009,6 @@ void LLDrawPoolAvatar::endDeferredSkinned()
{
// if we're in software-blending, remember to set the fence _after_ we draw so we wait till this rendering is done
sRenderingSkinned = FALSE;
disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
sVertexProgram->unbind();
sVertexProgram->disableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
@ -1150,10 +1122,10 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
return;
}
if (single_avatar && avatarp->mSpecialRenderMode >= 1) // 1=anim preview, 2=image preview, 3=morph view
/*if (single_avatar && avatarp->mSpecialRenderMode >= 1) // 1=anim preview, 2=image preview, 3=morph view
{
gPipeline.enableLightsAvatarEdit(LLColor4(.5f, .5f, .5f, 1.f));
}
}*/
if (pass == 1)
{
@ -1262,16 +1234,16 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
wind = wind * rot_mat;
wind.mV[VW] = avatarp->mWindVec.mV[VW];
sVertexProgram->vertexAttrib4fv(LLViewerShaderMgr::AVATAR_WIND, wind.mV);
sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_WIND, 1, wind.mV);
F32 phase = -1.f * (avatarp->mRipplePhase);
F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f);
LLVector4 sin_params(freq, freq, freq, phase);
sVertexProgram->vertexAttrib4fv(LLViewerShaderMgr::AVATAR_SINWAVE, sin_params.mV);
sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_SINWAVE, 1, sin_params.mV);
LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f);
gravity = gravity * rot_mat;
sVertexProgram->vertexAttrib4fv(LLViewerShaderMgr::AVATAR_GRAVITY, gravity.mV);
sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_GRAVITY, 1, gravity.mV);
}
if( !single_avatar || (avatarp == single_avatar) )
@ -1509,7 +1481,7 @@ void LLDrawPoolAvatar::renderRigged(LLVOAvatar* avatar, U32 type, bool glow)
if (glow)
{
glColor4f(0,0,0,face->getTextureEntry()->getGlow());
gGL.diffuseColor4f(0,0,0,face->getTextureEntry()->getGlow());
}
gGL.getTexUnit(sDiffuseChannel)->bind(face->getTexture());
@ -1662,7 +1634,7 @@ LLVertexBufferAvatar::LLVertexBufferAvatar()
void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const
{
if (sRenderingSkinned)
/*if (sRenderingSkinned)
{
U8* base = useVBOs() ? (U8*) mAlignedOffset : mMappedData;
@ -1686,8 +1658,8 @@ void LLVertexBufferAvatar::setupVertexBuffer(U32 data_mask) const
}
}
else
{
{*/
LLVertexBuffer::setupVertexBuffer(data_mask);
}
//}
}

View File

@ -762,7 +762,7 @@ void LLDrawPoolBump::renderBump(U32 pass)
LLGLDisable fog(GL_FOG);
LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_LEQUAL);
LLGLEnable blend(GL_BLEND);
glColor4f(1,1,1,1);
gGL.diffuseColor4f(1,1,1,1);
/// Get rid of z-fighting with non-bump pass.
LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.0f, -1.0f);

View File

@ -80,6 +80,18 @@ void LLDrawPoolGlow::endPostDeferredPass(S32 pass)
LLRenderPass::endRenderPass(pass);
}
S32 LLDrawPoolGlow::getNumPasses()
{
if (LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT) > 0)
{
return 1;
}
else
{
return 0;
}
}
void LLDrawPoolGlow::render(S32 pass)
{
LLFastTimer t(FTM_RENDER_GLOW);
@ -93,39 +105,29 @@ void LLDrawPoolGlow::render(S32 pass)
U32 shader_level = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_OBJECT);
if (shader_level > 0 && fullbright_shader)
{
fullbright_shader->bind();
}
else
{
gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
}
//should never get here without basic shaders enabled
llassert(shader_level > 0);
LLGLSLShader* shader = LLPipeline::sUnderWaterRender ? &gObjectEmissiveWaterProgram : &gObjectEmissiveProgram;
shader->bind();
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
gGL.setColorMask(false, true);
if (shader_level > 1)
{
pushBatches(LLRenderPass::PASS_GLOW, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
}
else
{
renderTexture(LLRenderPass::PASS_GLOW, getVertexDataMask());
}
pushBatches(LLRenderPass::PASS_GLOW, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE);
gGL.setColorMask(true, false);
gGL.setSceneBlendType(LLRender::BT_ALPHA);
if (shader_level > 0 && fullbright_shader)
{
fullbright_shader->unbind();
shader->unbind();
}
}
void LLDrawPoolGlow::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL batch_textures)
{
glColor4ubv(params.mGlowColor.mV);
//gGL.diffuseColor4ubv(params.mGlowColor.mV);
LLRenderPass::pushBatch(params, mask, texture, batch_textures);
}

View File

@ -118,7 +118,8 @@ public:
enum
{
VERTEX_DATA_MASK = LLVertexBuffer::MAP_VERTEX |
LLVertexBuffer::MAP_TEXCOORD0
LLVertexBuffer::MAP_TEXCOORD0 |
LLVertexBuffer::MAP_EMISSIVE
};
virtual U32 getVertexDataMask() { return VERTEX_DATA_MASK; }
@ -130,6 +131,8 @@ public:
/*virtual*/ void endPostDeferredPass(S32 pass);
/*virtual*/ void renderPostDeferred(S32 pass);
/*virtual*/ S32 getNumPasses();
void render(S32 pass = 0);
void pushBatch(LLDrawInfo& params, U32 mask, BOOL texture = TRUE, BOOL batch_textures = FALSE);

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