Fixed numerous bugs.
This commit is contained in:
@@ -487,10 +487,20 @@ void LLFontFreetype::renderGlyph(const U32 glyph_index) const
|
||||
if (mFTFace == NULL)
|
||||
return;
|
||||
|
||||
llassert_always(! FT_Load_Glyph(mFTFace, glyph_index, FT_LOAD_DEFAULT));
|
||||
|
||||
llassert_always(! FT_Render_Glyph(mFTFace->glyph, gFontRenderMode) );
|
||||
|
||||
FT_Error error = FT_Load_Glyph(mFTFace, glyph_index, FT_LOAD_DEFAULT);
|
||||
#ifdef SHOW_ASSERT
|
||||
if (error)
|
||||
{
|
||||
LL_ERRS() << "FT_Load_Glyph returned " << error << LL_ENDL;
|
||||
}
|
||||
#endif
|
||||
error = FT_Render_Glyph(mFTFace->glyph, gFontRenderMode);
|
||||
#ifdef SHOW_ASSERT
|
||||
if (error)
|
||||
{
|
||||
LL_ERRS() << "FT_Render_Glyph returned " << error << LL_ENDL;
|
||||
}
|
||||
#endif
|
||||
mRenderGlyphCount++;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,9 +59,7 @@ static const U32 LL_NUM_LIGHT_UNITS = 8;
|
||||
static const GLenum sGLTextureType[] =
|
||||
{
|
||||
GL_TEXTURE_2D,
|
||||
GL_TEXTURE_RECTANGLE_ARB,
|
||||
GL_TEXTURE_CUBE_MAP_ARB
|
||||
//,GL_TEXTURE_2D_MULTISAMPLE Don't use.
|
||||
};
|
||||
|
||||
static const GLint sGLAddressMode[] =
|
||||
@@ -171,7 +169,7 @@ void LLTexUnit::activate(void)
|
||||
|
||||
if ((S32)gGL.mCurrTextureUnitIndex != mIndex || gGL.mDirty)
|
||||
{
|
||||
gGL.flush();
|
||||
//gGL.flush();
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + mIndex);
|
||||
gGL.mCurrTextureUnitIndex = mIndex;
|
||||
}
|
||||
@@ -230,7 +228,7 @@ bool LLTexUnit::bind(LLTexture* texture, bool for_rendering, bool forceBind)
|
||||
stop_glerror();
|
||||
if (mIndex >= 0)
|
||||
{
|
||||
gGL.flush();
|
||||
//gGL.flush();
|
||||
|
||||
LLImageGL* gl_tex = NULL ;
|
||||
|
||||
@@ -344,8 +342,6 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap)
|
||||
{
|
||||
if (mIndex < 0) return false;
|
||||
|
||||
gGL.flush();
|
||||
|
||||
if (cubeMap == NULL)
|
||||
{
|
||||
LL_WARNS() << "NULL LLTexUnit::bind cubemap" << LL_ENDL;
|
||||
@@ -361,6 +357,7 @@ bool LLTexUnit::bind(LLCubeMap* cubeMap)
|
||||
{
|
||||
if (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps)
|
||||
{
|
||||
gGL.flush();
|
||||
activate();
|
||||
enable(LLTexUnit::TT_CUBE_MAP);
|
||||
mCurrTexture = cubeMap->mImages[0]->getTexName();
|
||||
@@ -390,7 +387,7 @@ bool LLTexUnit::bind(LLRenderTarget* renderTarget, bool bindDepth)
|
||||
{
|
||||
if (mIndex < 0) return false;
|
||||
|
||||
gGL.flush();
|
||||
//gGL.flush();
|
||||
|
||||
if (bindDepth)
|
||||
{
|
||||
@@ -438,12 +435,16 @@ void LLTexUnit::unbind(eTextureType type)
|
||||
|
||||
//always flush and activate for consistency
|
||||
// some code paths assume unbind always flushes and sets the active texture
|
||||
gGL.flush();
|
||||
activate();
|
||||
if (gGL.mCurrTextureUnitIndex != mIndex || gGL.mDirty)
|
||||
{
|
||||
gGL.flush();
|
||||
activate();
|
||||
}
|
||||
|
||||
// Disabled caching of binding state.
|
||||
if (mCurrTexType == type)
|
||||
if (mCurrTexType == type && mCurrTexture != 0)
|
||||
{
|
||||
gGL.flush();
|
||||
mCurrTexture = 0;
|
||||
if (LLGLSLShader::sNoFixedFunction && type == LLTexUnit::TT_TEXTURE)
|
||||
{
|
||||
@@ -1044,6 +1045,7 @@ LLRender::LLRender()
|
||||
mMode(LLRender::TRIANGLES),
|
||||
mCurrTextureUnitIndex(0),
|
||||
mMaxAnisotropy(0.f),
|
||||
mLineWidth(1.f),
|
||||
mPrimitiveReset(false)
|
||||
{
|
||||
mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS);
|
||||
@@ -1663,8 +1665,6 @@ bool LLRender::unprojectf(const LLVector3& windowCoordinate, const LLMatrix4a& m
|
||||
|
||||
void LLRender::pushMatrix()
|
||||
{
|
||||
flush();
|
||||
|
||||
{
|
||||
if (mMatIdx[mMatrixMode] < LL_MATRIX_STACK_DEPTH-1)
|
||||
{
|
||||
@@ -1680,15 +1680,19 @@ void LLRender::pushMatrix()
|
||||
|
||||
void LLRender::popMatrix()
|
||||
{
|
||||
flush();
|
||||
{
|
||||
if (mMatIdx[mMatrixMode] > 0)
|
||||
{
|
||||
if ( memcmp(mMatrix[mMatrixMode][mMatIdx[mMatrixMode]].getF32ptr(), mMatrix[mMatrixMode][mMatIdx[mMatrixMode] - 1].getF32ptr(), sizeof(LLMatrix4a)) )
|
||||
{
|
||||
flush();
|
||||
}
|
||||
--mMatIdx[mMatrixMode];
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
else
|
||||
{
|
||||
flush();
|
||||
LL_WARNS() << "Matrix stack underflow." << LL_ENDL;
|
||||
}
|
||||
}
|
||||
@@ -1697,6 +1701,7 @@ void LLRender::popMatrix()
|
||||
void LLRender::loadMatrix(const LLMatrix4a& mat)
|
||||
{
|
||||
flush();
|
||||
|
||||
mMatrix[mMatrixMode][mMatIdx[mMatrixMode]] = mat;
|
||||
mMatHash[mMatrixMode]++;
|
||||
}
|
||||
@@ -1772,6 +1777,18 @@ void LLRender::scaleUI(F32 x, F32 y, F32 z)
|
||||
mUIScale.back().mul(scale);
|
||||
}
|
||||
|
||||
void LLRender::rotateUI(LLQuaternion& rot)
|
||||
{
|
||||
if (mUIRotation.empty())
|
||||
{
|
||||
mUIRotation.push_back(rot);
|
||||
}
|
||||
else
|
||||
{
|
||||
mUIRotation.push_back(mUIRotation.back()*rot);
|
||||
}
|
||||
}
|
||||
|
||||
void LLRender::pushUIMatrix()
|
||||
{
|
||||
if (mUIOffset.empty())
|
||||
@@ -1791,6 +1808,10 @@ void LLRender::pushUIMatrix()
|
||||
{
|
||||
mUIScale.push_back(mUIScale.back());
|
||||
}
|
||||
if (!mUIRotation.empty())
|
||||
{
|
||||
mUIRotation.push_back(mUIRotation.back());
|
||||
}
|
||||
}
|
||||
|
||||
void LLRender::popUIMatrix()
|
||||
@@ -1801,6 +1822,10 @@ void LLRender::popUIMatrix()
|
||||
}
|
||||
mUIOffset.pop_back();
|
||||
mUIScale.pop_back();
|
||||
if (!mUIRotation.empty())
|
||||
{
|
||||
mUIRotation.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
LLVector3 LLRender::getUITranslation()
|
||||
@@ -1830,6 +1855,8 @@ void LLRender::loadUIIdentity()
|
||||
}
|
||||
mUIOffset.back().splat(0.f);
|
||||
mUIScale.back().splat(1.f);
|
||||
if (!mUIRotation.empty())
|
||||
mUIRotation.push_back(LLQuaternion());
|
||||
}
|
||||
|
||||
void LLRender::setColorMask(bool writeColor, bool writeAlpha)
|
||||
@@ -1839,8 +1866,6 @@ void LLRender::setColorMask(bool writeColor, bool writeAlpha)
|
||||
|
||||
void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB, bool writeAlpha)
|
||||
{
|
||||
flush();
|
||||
|
||||
if (mCurrColorMask[0] != writeColorR ||
|
||||
mCurrColorMask[1] != writeColorG ||
|
||||
mCurrColorMask[2] != writeColorB ||
|
||||
@@ -1851,6 +1876,7 @@ void LLRender::setColorMask(bool writeColorR, bool writeColorG, bool writeColorB
|
||||
mCurrColorMask[2] = writeColorB;
|
||||
mCurrColorMask[3] = writeAlpha;
|
||||
|
||||
flush();
|
||||
glColorMask(writeColorR ? GL_TRUE : GL_FALSE,
|
||||
writeColorG ? GL_TRUE : GL_FALSE,
|
||||
writeColorB ? GL_TRUE : GL_FALSE,
|
||||
@@ -1891,8 +1917,6 @@ void LLRender::setSceneBlendType(eBlendType type)
|
||||
|
||||
void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
|
||||
{
|
||||
flush();
|
||||
|
||||
if (LLGLSLShader::sNoFixedFunction)
|
||||
{ //glAlphaFunc is deprecated in OpenGL 3.3
|
||||
return;
|
||||
@@ -1901,6 +1925,7 @@ void LLRender::setAlphaRejectSettings(eCompareFunc func, F32 value)
|
||||
if (mCurrAlphaFunc != func ||
|
||||
mCurrAlphaFuncVal != value || mDirty)
|
||||
{
|
||||
flush();
|
||||
mCurrAlphaFunc = func;
|
||||
mCurrAlphaFuncVal = value;
|
||||
if (func == CF_DEFAULT)
|
||||
@@ -2030,6 +2055,23 @@ void LLRender::setAmbientLightColor(const LLColor4& color)
|
||||
}
|
||||
}
|
||||
|
||||
void LLRender::setLineWidth(F32 line_width)
|
||||
{
|
||||
if (LLRender::sGLCoreProfile)
|
||||
{
|
||||
line_width = 1.f;
|
||||
}
|
||||
if (mLineWidth != line_width)
|
||||
{
|
||||
if (mMode == LLRender::LINES || LLRender::LINE_STRIP)
|
||||
{
|
||||
flush();
|
||||
}
|
||||
mLineWidth = line_width;
|
||||
glLineWidth(line_width);
|
||||
}
|
||||
}
|
||||
|
||||
bool LLRender::verifyTexUnitActive(U32 unitToVerify)
|
||||
{
|
||||
if (mCurrTextureUnitIndex == unitToVerify)
|
||||
@@ -2092,8 +2134,13 @@ void LLRender::end()
|
||||
mPrimitiveReset = true;
|
||||
}
|
||||
}
|
||||
|
||||
extern bool countFlushes;
|
||||
extern unsigned int flushCount;
|
||||
|
||||
void LLRender::flush()
|
||||
{
|
||||
if (countFlushes) ++flushCount;
|
||||
if (mCount > 0)
|
||||
{
|
||||
#if 0
|
||||
@@ -2236,13 +2283,33 @@ void LLRender::vertex4a(const LLVector4a& vertex)
|
||||
|
||||
if (mUIOffset.empty())
|
||||
{
|
||||
mVerticesp[mCount]=vertex;
|
||||
if (!mUIRotation.empty() && mUIRotation.back().isNotIdentity())
|
||||
{
|
||||
LLVector4 vert(vertex.getF32ptr());
|
||||
mVerticesp[mCount].loadua((vert*mUIRotation.back()).mV);
|
||||
}
|
||||
else
|
||||
{
|
||||
mVerticesp[mCount] = vertex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back());
|
||||
mVerticesp[mCount].setAdd(vertex,mUIOffset.back());
|
||||
mVerticesp[mCount].mul(mUIScale.back());
|
||||
if (!mUIRotation.empty() && mUIRotation.back().isNotIdentity())
|
||||
{
|
||||
LLVector4 vert(vertex.getF32ptr());
|
||||
vert = vert * mUIRotation.back();
|
||||
LLVector4a postrot_vert;
|
||||
postrot_vert.loadua(vert.mV);
|
||||
mVerticesp[mCount].setAdd(postrot_vert, mUIOffset.back());
|
||||
mVerticesp[mCount].mul(mUIScale.back());
|
||||
}
|
||||
else
|
||||
{
|
||||
//LLVector3 vert = (LLVector3(x,y,z)+mUIOffset.back()).scaledVec(mUIScale.back());
|
||||
mVerticesp[mCount].setAdd(vertex, mUIOffset.back());
|
||||
mVerticesp[mCount].mul(mUIScale.back());
|
||||
}
|
||||
}
|
||||
|
||||
mCount++;
|
||||
|
||||
@@ -65,7 +65,6 @@ public:
|
||||
{
|
||||
TT_TEXTURE = 0, // Standard 2D Texture
|
||||
TT_CUBE_MAP, // 6-sided cube map texture
|
||||
//TT_MULTISAMPLE_TEXTURE, // see GL_ARB_texture_multisample Do not use
|
||||
TT_NONE // No texture type is currently enabled
|
||||
} eTextureType;
|
||||
|
||||
@@ -380,6 +379,8 @@ public:
|
||||
|
||||
void translateUI(F32 x, F32 y, F32 z);
|
||||
void scaleUI(F32 x, F32 y, F32 z);
|
||||
// Rotates vertices, pre-translation/scale
|
||||
void rotateUI(LLQuaternion& rot);
|
||||
void pushUIMatrix();
|
||||
void popUIMatrix();
|
||||
void loadUIIdentity();
|
||||
@@ -435,6 +436,8 @@ public:
|
||||
LLLightState* getLight(U32 index);
|
||||
void setAmbientLightColor(const LLColor4& color);
|
||||
|
||||
void setLineWidth(F32 line_width);
|
||||
|
||||
LLTexUnit* getTexUnit(U32 index);
|
||||
|
||||
U32 getCurrentTexUnitIndex(void) const { return mCurrTextureUnitIndex; }
|
||||
@@ -475,6 +478,7 @@ private:
|
||||
bool mCurrColorMask[4];
|
||||
eCompareFunc mCurrAlphaFunc;
|
||||
F32 mCurrAlphaFuncVal;
|
||||
F32 mLineWidth;
|
||||
|
||||
LLPointer<LLVertexBuffer> mBuffer;
|
||||
LLStrider<LLVector4a> mVerticesp;
|
||||
@@ -493,6 +497,7 @@ private:
|
||||
|
||||
std::vector<LLVector4a, boost::alignment::aligned_allocator<LLVector4a, 64> > mUIOffset;
|
||||
std::vector<LLVector4a, boost::alignment::aligned_allocator<LLVector4a, 64> > mUIScale;
|
||||
std::vector<LLQuaternion> mUIRotation;
|
||||
|
||||
bool mPrimitiveReset;
|
||||
} LL_ALIGN_POSTFIX(16);
|
||||
|
||||
@@ -490,7 +490,6 @@ void gl_draw_scaled_image_with_border(S32 x, S32 y, S32 width, S32 height, LLTex
|
||||
gGL.getTexUnit(0)->bind(image, true);
|
||||
|
||||
gGL.color4fv(color.mV);
|
||||
gGL.diffuseColor4fv(color.mV); //workaround: Intel HD 4000
|
||||
|
||||
const S32 NUM_VERTICES = (2 + 2 * 3) * 3 + 4;
|
||||
LLVector2 uv[NUM_VERTICES];
|
||||
@@ -894,12 +893,11 @@ void gl_ring( F32 radius, F32 width, const LLColor4& center_color, const LLColor
|
||||
if( render_center )
|
||||
{
|
||||
gGL.color4fv(center_color.mV);
|
||||
gGL.diffuseColor4fv(center_color.mV);
|
||||
gl_deep_circle( radius, width, steps );
|
||||
}
|
||||
else
|
||||
{
|
||||
gGL.diffuseColor4fv(side_color.mV);
|
||||
gGL.color4fv(side_color.mV);
|
||||
gl_washer_2d(radius - width, radius, steps, side_color, side_color);
|
||||
gGL.translateUI(0.f, 0.f, width);
|
||||
gl_washer_2d(radius, radius - width, steps, side_color, side_color);
|
||||
@@ -1520,8 +1518,7 @@ void LLRender2D::setScaleFactor(const LLVector2 &scale_factor)
|
||||
//static
|
||||
void LLRender2D::setLineWidth(F32 width)
|
||||
{
|
||||
gGL.flush();
|
||||
glLineWidth(width * lerp(sGLScaleFactor.mV[VX], sGLScaleFactor.mV[VY], 0.5f));
|
||||
gGL.setLineWidth(width * lerp(sGLScaleFactor.mV[VX], sGLScaleFactor.mV[VY], 0.5f));
|
||||
}
|
||||
|
||||
//static
|
||||
|
||||
@@ -538,7 +538,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
range = mShaderObjects.equal_range(filename);
|
||||
for (std::multimap<std::string, CachedObjectInfo>::iterator it = range.first; it != range.second;++it)
|
||||
{
|
||||
if((*it).second.mLevel == shader_level && (*it).second.mType == type && (*it).second.mDefinitions == (defines ? *defines : std::map<std::string, std::string>()))
|
||||
if((*it).second.mLevel == shader_level && (*it).second.mType == type && (*it).second.mIndexChannels == texture_index_channels && (*it).second.mDefinitions == (defines ? *defines : std::map<std::string, std::string>()))
|
||||
{
|
||||
//LL_INFOS("ShaderLoading") << "Loading cached shader for " << filename << LL_ENDL;
|
||||
return (*it).second.mHandle;
|
||||
@@ -935,7 +935,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
|
||||
if (ret)
|
||||
{
|
||||
// Add shader file to map
|
||||
mShaderObjects.insert(make_pair(filename,CachedObjectInfo(ret,try_gpu_class,type,defines)));
|
||||
mShaderObjects.insert(make_pair(filename,CachedObjectInfo(ret,try_gpu_class,type, texture_index_channels,defines)));
|
||||
shader_level = try_gpu_class;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -242,11 +242,12 @@ DISPLAY_GAMMA,
|
||||
public:
|
||||
struct CachedObjectInfo
|
||||
{
|
||||
CachedObjectInfo(GLhandleARB handle, U32 level, GLenum type, std::map<std::string,std::string> *definitions) :
|
||||
mHandle(handle), mLevel(level), mType(type), mDefinitions(definitions ? *definitions : std::map<std::string,std::string>()){}
|
||||
CachedObjectInfo(GLhandleARB handle, U32 level, GLenum type, U32 texture_index_channels, std::map<std::string,std::string> *definitions) :
|
||||
mHandle(handle), mLevel(level), mType(type), mIndexChannels(texture_index_channels), mDefinitions(definitions ? *definitions : std::map<std::string,std::string>()){}
|
||||
GLhandleARB mHandle; //Actual handle of the opengl shader object.
|
||||
U32 mLevel; //Level /might/ not be needed, but it's stored to ensure there's no change in behavior.
|
||||
GLenum mType; //GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB. Tracked because some utility shaders can be loaded as both types (carefully).
|
||||
U32 mIndexChannels; //LLShaderFeatures::mIndexedTextureChannels
|
||||
std::map<std::string,std::string> mDefinitions;
|
||||
};
|
||||
// Map of shader names to compiled
|
||||
|
||||
@@ -40,6 +40,7 @@ uniform float max_cof;
|
||||
uniform float res_scale;
|
||||
uniform float dof_width;
|
||||
uniform float dof_height;
|
||||
uniform float kern_scale;
|
||||
|
||||
VARYING vec2 vary_fragcoord;
|
||||
|
||||
@@ -53,9 +54,9 @@ vec4 dofSample(sampler2D tex, vec2 tc)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 tc = vary_fragcoord.xy;
|
||||
vec2 tc = vary_fragcoord.xy * res_scale;
|
||||
|
||||
vec4 dof = dofSample(diffuseRect, vary_fragcoord.xy*res_scale);
|
||||
vec4 dof = dofSample(diffuseRect, tc);
|
||||
|
||||
vec4 diff = texture2D(lightMap, vary_fragcoord.xy);
|
||||
|
||||
@@ -66,10 +67,10 @@ void main()
|
||||
float sc = a/res_scale;
|
||||
|
||||
vec4 col;
|
||||
col = texture2D(lightMap, vary_fragcoord.xy+vec2(sc,sc));
|
||||
col += texture2D(lightMap, vary_fragcoord.xy+vec2(-sc,sc));
|
||||
col += texture2D(lightMap, vary_fragcoord.xy+vec2(sc,-sc));
|
||||
col += texture2D(lightMap, vary_fragcoord.xy+vec2(-sc,-sc));
|
||||
col = texture2D(lightMap, vary_fragcoord.xy+vec2(sc,sc)*kern_scale);
|
||||
col += texture2D(lightMap, vary_fragcoord.xy+vec2(-sc,sc)*kern_scale);
|
||||
col += texture2D(lightMap, vary_fragcoord.xy+vec2(sc,-sc)*kern_scale);
|
||||
col += texture2D(lightMap, vary_fragcoord.xy+vec2(-sc,-sc)*kern_scale);
|
||||
|
||||
diff = mix(diff, col*0.25, a);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ uniform sampler2D diffuseRect;
|
||||
uniform mat4 inv_proj;
|
||||
uniform float max_cof;
|
||||
uniform float res_scale;
|
||||
uniform vec2 kern_scale;
|
||||
|
||||
VARYING vec2 vary_fragcoord;
|
||||
|
||||
@@ -76,7 +77,7 @@ void main()
|
||||
{
|
||||
vec2 tc = vary_fragcoord.xy;
|
||||
|
||||
vec4 diff = texture2D(diffuseRect, vary_fragcoord.xy);
|
||||
vec4 diff = texture2D(diffuseRect, tc);
|
||||
|
||||
{
|
||||
float w = 1.0;
|
||||
@@ -97,7 +98,7 @@ void main()
|
||||
float samp_x = sc*sin(ang);
|
||||
float samp_y = sc*cos(ang);
|
||||
// you could test sample coords against an interesting non-circular aperture shape here, if desired.
|
||||
dofSampleNear(diff, w, sc, vary_fragcoord.xy + vec2(samp_x,samp_y));
|
||||
dofSampleNear(diff, w, sc, tc + vec2(samp_x,samp_y) * kern_scale);
|
||||
}
|
||||
sc -= 1.0;
|
||||
}
|
||||
@@ -114,7 +115,7 @@ void main()
|
||||
float samp_x = sc*sin(ang);
|
||||
float samp_y = sc*cos(ang);
|
||||
// you could test sample coords against an interesting non-circular aperture shape here, if desired.
|
||||
dofSample(diff, w, sc, vary_fragcoord.xy + vec2(samp_x,samp_y));
|
||||
dofSample(diff, w, sc, tc + vec2(samp_x,samp_y) * kern_scale);
|
||||
}
|
||||
sc -= 1.0;
|
||||
}
|
||||
|
||||
@@ -33,15 +33,16 @@ out vec4 frag_color;
|
||||
|
||||
VARYING vec2 vary_fragcoord;
|
||||
|
||||
uniform sampler2D depthMapDownsampled;
|
||||
uniform sampler2D depthMap;
|
||||
|
||||
uniform sampler2D diffuseRect;
|
||||
|
||||
uniform vec2 kern_scale;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color[0] = 1.0;
|
||||
frag_color[1] = texture2D(diffuseRect,vary_fragcoord.xy).r;
|
||||
frag_color[1] = texture2D(diffuseRect,vary_fragcoord.xy * kern_scale).r;
|
||||
frag_color[2] = 1.0;
|
||||
frag_color[3] = 1.0;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ uniform vec4 shadow_clip;
|
||||
|
||||
VARYING vec2 vary_fragcoord;
|
||||
|
||||
uniform vec2 kern_scale;
|
||||
|
||||
uniform mat4 inv_proj;
|
||||
uniform vec2 proj_shadow_res;
|
||||
uniform vec3 sun_dir;
|
||||
@@ -62,6 +64,7 @@ uniform float shadow_offset;
|
||||
uniform float spot_shadow_bias;
|
||||
uniform float spot_shadow_offset;
|
||||
|
||||
|
||||
vec2 encode_normal(vec3 n)
|
||||
{
|
||||
float f = sqrt(8 * n.z + 8);
|
||||
@@ -241,7 +244,7 @@ void main()
|
||||
}
|
||||
|
||||
frag_color[0] = shadow;
|
||||
frag_color[1] = texture2D(diffuseRect,vary_fragcoord).r;
|
||||
frag_color[1] = texture2D(diffuseRect,vary_fragcoord.xy * kern_scale).r;
|
||||
|
||||
spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0);
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass)
|
||||
|
||||
//prime simple shader (loads shadow relevant uniforms)
|
||||
gPipeline.bindDeferredShader(*simple_shader);
|
||||
gPipeline.unbindDeferredShader(*simple_shader);
|
||||
|
||||
//simple_shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f));
|
||||
}
|
||||
@@ -154,7 +155,11 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass)
|
||||
}
|
||||
|
||||
void LLDrawPoolAlpha::endPostDeferredPass(S32 pass)
|
||||
{
|
||||
{
|
||||
if (current_shader)
|
||||
{
|
||||
gPipeline.unbindDeferredShader(*current_shader);
|
||||
}
|
||||
if (pass == 1 && !LLPipeline::sImpostorRender)
|
||||
{
|
||||
gPipeline.mDeferredDepth.flush();
|
||||
@@ -437,6 +442,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass)
|
||||
// (this way we won't rebind shaders unnecessarily).
|
||||
if (current_shader != target_shader)
|
||||
{
|
||||
if(current_shader)
|
||||
gPipeline.unbindDeferredShader(*current_shader);
|
||||
gPipeline.bindDeferredShader(*target_shader);
|
||||
}
|
||||
}
|
||||
@@ -448,6 +455,8 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask, S32 pass)
|
||||
// (this way we won't rebind shaders unnecessarily).
|
||||
if(current_shader != target_shader)
|
||||
{
|
||||
if(current_shader)
|
||||
gPipeline.unbindDeferredShader(*current_shader);
|
||||
target_shader->bind();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,21 +268,12 @@ void LLNetMap::draw()
|
||||
// Prepare a scissor region
|
||||
F32 rotation = 0;
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.pushUIMatrix();
|
||||
|
||||
LLVector3 offset = gGL.getUITranslation();
|
||||
LLVector3 scale = gGL.getUIScale();
|
||||
|
||||
gGL.loadIdentity();
|
||||
gGL.loadUIIdentity();
|
||||
gGL.scalef(scale.mV[0], scale.mV[1], scale.mV[2]);
|
||||
gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]);
|
||||
{
|
||||
LLLocalClipRect clip(getLocalRect());
|
||||
{
|
||||
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
|
||||
gGL.matrixMode(LLRender::MM_MODELVIEW);
|
||||
|
||||
// Draw background rectangle.
|
||||
if(isBackgroundVisible())
|
||||
@@ -297,15 +288,16 @@ void LLNetMap::draw()
|
||||
S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPan.mV[VX]);
|
||||
S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPan.mV[VY]);
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f);
|
||||
gGL.pushUIMatrix();
|
||||
gGL.translateUI( (F32) center_sw_left, (F32) center_sw_bottom, 0.f);
|
||||
|
||||
static LLCachedControl<bool> rotate_map("MiniMapRotate", true);
|
||||
if (rotate_map)
|
||||
{
|
||||
// Rotate subsequent draws to agent rotation.
|
||||
rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
|
||||
gGL.rotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f);
|
||||
LLQuaternion rot(rotation, LLVector3(0.f, 0.f, 1.f));
|
||||
gGL.rotateUI(rot);
|
||||
}
|
||||
|
||||
// Figure out where agent is.
|
||||
@@ -537,7 +529,7 @@ void LLNetMap::draw()
|
||||
}
|
||||
// [/SL:KB]
|
||||
|
||||
gGL.popMatrix();
|
||||
gGL.popUIMatrix();
|
||||
|
||||
// Mouse pointer in local coordinates
|
||||
S32 local_mouse_x;
|
||||
@@ -709,14 +701,15 @@ void LLNetMap::draw()
|
||||
|
||||
LLColor4 c = rotate_map ? map_frustum_color() : map_frustum_rotating_color();
|
||||
|
||||
gGL.pushMatrix();
|
||||
gGL.pushUIMatrix();
|
||||
|
||||
gGL.translatef(ctr_x, ctr_y, 0);
|
||||
gGL.translateUI(ctr_x, ctr_y, 0);
|
||||
|
||||
// If we don't rotate the map, we have to rotate the frustum.
|
||||
if (!rotate_map)
|
||||
{
|
||||
gGL.rotatef(atan2(LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY]) * RAD_TO_DEG, 0.f, 0.f, -1.f);
|
||||
LLQuaternion rot(atan2(LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY]), LLVector3(0.f, 0.f, -1.f));
|
||||
gGL.rotateUI(rot);
|
||||
}
|
||||
|
||||
gGL.begin( LLRender::TRIANGLES );
|
||||
@@ -728,7 +721,7 @@ void LLNetMap::draw()
|
||||
gGL.vertex2f( -half_width_pixels, far_clip_pixels );
|
||||
gGL.end();
|
||||
|
||||
gGL.popMatrix();
|
||||
gGL.popUIMatrix();
|
||||
|
||||
// <exodus> Draw mouse radius
|
||||
static const LLCachedControl<LLColor4> map_avatar_rollover_color("ExodusMapRolloverCircleColor");
|
||||
@@ -737,8 +730,7 @@ void LLNetMap::draw()
|
||||
gl_circle_2d(local_mouse_x, local_mouse_y, min_pick_dist, 32, true);
|
||||
// </exodus>
|
||||
}
|
||||
|
||||
gGL.popMatrix();
|
||||
;
|
||||
gGL.popUIMatrix();
|
||||
|
||||
// Rotation of 0 means that North is up
|
||||
|
||||
@@ -7194,7 +7194,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
|
||||
|
||||
drawFullScreenRect();
|
||||
|
||||
unbindDeferredShader(*shader);
|
||||
unbindDeferredShader(*shader, &mFinalScreen);
|
||||
mDeferredLight.flush();
|
||||
}
|
||||
|
||||
@@ -7214,7 +7214,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
|
||||
|
||||
drawFullScreenRect();
|
||||
|
||||
unbindDeferredShader(*shader);
|
||||
unbindDeferredShader(*shader, &mDeferredLight);
|
||||
mFinalScreen.flush();
|
||||
gGL.setColorMask(true, true);
|
||||
}
|
||||
@@ -7252,8 +7252,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
|
||||
|
||||
shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF);
|
||||
shader->uniform1f(LLShaderMgr::DOF_RES_SCALE, CameraDoFResScale);
|
||||
shader->uniform1f(LLShaderMgr::DOF_WIDTH, dof_width-1);
|
||||
shader->uniform1f(LLShaderMgr::DOF_HEIGHT, dof_height-1);
|
||||
shader->uniform1f(LLShaderMgr::DOF_WIDTH, CameraDoFResScale - CameraDoFResScale / dof_width);
|
||||
shader->uniform1f(LLShaderMgr::DOF_HEIGHT, CameraDoFResScale - CameraDoFResScale / dof_height);
|
||||
|
||||
drawFullScreenRect();
|
||||
|
||||
@@ -7262,7 +7262,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
|
||||
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
|
||||
}
|
||||
|
||||
unbindDeferredShader(*shader);
|
||||
unbindDeferredShader(*shader, &mFinalScreen);
|
||||
|
||||
if (multisample)
|
||||
{
|
||||
@@ -7300,7 +7300,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
|
||||
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
|
||||
}
|
||||
|
||||
unbindDeferredShader(*shader);
|
||||
unbindDeferredShader(*shader, &mFinalScreen);
|
||||
|
||||
if (multisample)
|
||||
{
|
||||
@@ -7335,7 +7335,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
|
||||
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
|
||||
}
|
||||
|
||||
unbindDeferredShader(*shader);
|
||||
unbindDeferredShader(*shader, &render_target);
|
||||
|
||||
mFXAABuffer.flush();
|
||||
|
||||
@@ -7570,7 +7570,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffus
|
||||
|
||||
for (U32 i = 0; i < 4; i++)
|
||||
{
|
||||
channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_TEXTURE);
|
||||
channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i);
|
||||
stop_glerror();
|
||||
if (channel > -1)
|
||||
{
|
||||
@@ -7671,8 +7671,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffus
|
||||
norm_mat.transpose();
|
||||
shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.getF32ptr());
|
||||
}
|
||||
|
||||
//shader.uniform1f(LLShaderMgr::DEFERRED_DOWNSAMPLED_DEPTH_SCALE, llclamp(RenderSSAOResolutionScale.get(),.01f,1.f));
|
||||
}
|
||||
|
||||
static LLFastTimer::DeclareTimer FTM_GI_TRACE("Trace");
|
||||
@@ -7796,6 +7794,9 @@ void LLPipeline::renderDeferredLighting()
|
||||
mDeferredLight.clear(GL_COLOR_BUFFER_BIT);
|
||||
glClearColor(0,0,0,0);
|
||||
|
||||
F32 ssao_scale = llclamp(RenderSSAOResolutionScale.get(), .01f, 1.f);
|
||||
gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_KERN_SCALE, ssao_scale, ssao_scale);
|
||||
|
||||
//Enable bilinear filtering, as the screen tex resolution may not match current framebuffer resolution. Eg, half-res SSAO
|
||||
// diffuse map should only be found if the sun shader is the SSAO variant.
|
||||
S32 channel = gDeferredSunProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage());
|
||||
@@ -7838,7 +7839,7 @@ void LLPipeline::renderDeferredLighting()
|
||||
F32 dist_factor = RenderShadowBlurDistFactor;
|
||||
|
||||
// sample symmetrically with the middle sample falling exactly on 0.0
|
||||
F32 x = 0.f;
|
||||
//F32 x = 0.f;
|
||||
|
||||
gDeferredBlurLightProgram.uniform2f(sDelta, (blur_size * (kern_length / 2.f - 0.5f)) / mScreen.getWidth(), 0.f);
|
||||
gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor);
|
||||
@@ -7863,7 +7864,7 @@ void LLPipeline::renderDeferredLighting()
|
||||
drawFullScreenRect();
|
||||
}
|
||||
mDeferredLight.flush();
|
||||
unbindDeferredShader(gDeferredBlurLightProgram);
|
||||
unbindDeferredShader(gDeferredBlurLightProgram, &mScreen, &mScreen);
|
||||
}
|
||||
|
||||
stop_glerror();
|
||||
@@ -8374,6 +8375,10 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target)
|
||||
{ //paint shadow/SSAO light map (direct lighting lightmap)
|
||||
LLFastTimer ftm(FTM_SUN_SHADOW);
|
||||
bindDeferredShader(gDeferredSunProgram);
|
||||
|
||||
F32 ssao_scale = llclamp(RenderSSAOResolutionScale.get(), .01f, 1.f);
|
||||
gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_KERN_SCALE, ssao_scale, ssao_scale);
|
||||
|
||||
glClearColor(1,1,1,1);
|
||||
mDeferredLight.clear(GL_COLOR_BUFFER_BIT);
|
||||
glClearColor(0,0,0,0);
|
||||
@@ -8935,14 +8940,17 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
|
||||
|
||||
}
|
||||
|
||||
void LLPipeline::unbindDeferredShader(LLGLSLShader &shader)
|
||||
void LLPipeline::unbindDeferredShader(LLGLSLShader &shader, LLRenderTarget* diffuse_source, LLRenderTarget* light_source)
|
||||
{
|
||||
diffuse_source = diffuse_source ? diffuse_source : &mDeferredScreen;
|
||||
light_source = light_source ? light_source : &mDeferredLight;
|
||||
|
||||
stop_glerror();
|
||||
shader.disableTexture(LLShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage());
|
||||
shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage());
|
||||
shader.disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, diffuse_source->getUsage());
|
||||
shader.disableTexture(LLShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage());
|
||||
shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, mDeferredScreen.getUsage());
|
||||
shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, mDeferredLight.getUsage());
|
||||
shader.disableTexture(LLShaderMgr::DEFERRED_DEPTH, mDeferredDepth.getUsage());
|
||||
shader.disableTexture(LLShaderMgr::DEFERRED_LIGHT, light_source->getUsage());
|
||||
shader.disableTexture(LLShaderMgr::DIFFUSE_MAP);
|
||||
shader.disableTexture(LLShaderMgr::DEFERRED_BLOOM);
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ public:
|
||||
void bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffuse_source = NULL, LLRenderTarget* light_source = NULL);
|
||||
void setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep);
|
||||
|
||||
void unbindDeferredShader(LLGLSLShader& shader);
|
||||
void unbindDeferredShader(LLGLSLShader& shader, LLRenderTarget* diffuse_source = NULL, LLRenderTarget* light_source = NULL);
|
||||
void renderDeferredLighting();
|
||||
void renderDeferredLightingToRT(LLRenderTarget* target);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user