Using new LLLightState class instead of direct glLight calls, also other misc cleanup.
This commit is contained in:
@@ -10686,6 +10686,17 @@
|
|||||||
<key>Value</key>
|
<key>Value</key>
|
||||||
<integer>1</integer>
|
<integer>1</integer>
|
||||||
</map>
|
</map>
|
||||||
|
<key>RenderPreferStreamDraw</key>
|
||||||
|
<map>
|
||||||
|
<key>Comment</key>
|
||||||
|
<string>Use GL_STREAM_DRAW in place of GL_DYNAMIC_DRAW</string>
|
||||||
|
<key>Persist</key>
|
||||||
|
<integer>1</integer>
|
||||||
|
<key>Type</key>
|
||||||
|
<string>Boolean</string>
|
||||||
|
<key>Value</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</map>
|
||||||
<key>RenderVolumeLODFactor</key>
|
<key>RenderVolumeLODFactor</key>
|
||||||
<map>
|
<map>
|
||||||
<key>Comment</key>
|
<key>Comment</key>
|
||||||
|
|||||||
@@ -638,6 +638,7 @@ void settings_setup_listeners()
|
|||||||
gSavedSettings.getControl("MuteUI")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1));
|
gSavedSettings.getControl("MuteUI")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _1));
|
||||||
gSavedSettings.getControl("RenderVBOEnable")->getSignal()->connect(boost::bind(&handleRenderUseVBOChanged, _1));
|
gSavedSettings.getControl("RenderVBOEnable")->getSignal()->connect(boost::bind(&handleRenderUseVBOChanged, _1));
|
||||||
gSavedSettings.getControl("RenderVBOMappingDisable")->getSignal()->connect(boost::bind(&handleRenderUseVBOMappingChanged, _1));
|
gSavedSettings.getControl("RenderVBOMappingDisable")->getSignal()->connect(boost::bind(&handleRenderUseVBOMappingChanged, _1));
|
||||||
|
gSavedSettings.getControl("RenderPreferStreamDraw")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _1));
|
||||||
gSavedSettings.getControl("WLSkyDetail")->getSignal()->connect(boost::bind(&handleWLSkyDetailChanged, _1));
|
gSavedSettings.getControl("WLSkyDetail")->getSignal()->connect(boost::bind(&handleWLSkyDetailChanged, _1));
|
||||||
gSavedSettings.getControl("NumpadControl")->getSignal()->connect(boost::bind(&handleNumpadControlChanged, _1));
|
gSavedSettings.getControl("NumpadControl")->getSignal()->connect(boost::bind(&handleNumpadControlChanged, _1));
|
||||||
gSavedSettings.getControl("JoystickAxis0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _1));
|
gSavedSettings.getControl("JoystickAxis0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _1));
|
||||||
|
|||||||
@@ -610,6 +610,10 @@ void LLPipeline::updateRenderDeferred()
|
|||||||
gSavedSettings.getBOOL("RenderAvatarVP") &&
|
gSavedSettings.getBOOL("RenderAvatarVP") &&
|
||||||
gSavedSettings.getBOOL("WindLightUseAtmosShaders") &&
|
gSavedSettings.getBOOL("WindLightUseAtmosShaders") &&
|
||||||
!gUseWireframe);
|
!gUseWireframe);
|
||||||
|
if (sRenderDeferred)
|
||||||
|
{ //must render glow when rendering deferred since post effect pass is needed to present any lighting at all
|
||||||
|
sRenderGlow = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLPipeline::releaseGLBuffers()
|
void LLPipeline::releaseGLBuffers()
|
||||||
@@ -1440,7 +1444,7 @@ F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera
|
|||||||
//get area of circle around node
|
//get area of circle around node
|
||||||
F32 app_angle = atanf(size.length()/dist);
|
F32 app_angle = atanf(size.length()/dist);
|
||||||
F32 radius = app_angle*LLDrawable::sCurPixelAngle;
|
F32 radius = app_angle*LLDrawable::sCurPixelAngle;
|
||||||
return radius*radius * 3.14159f;
|
return radius*radius * F_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLPipeline::grabReferences(LLCullResult& result)
|
void LLPipeline::grabReferences(LLCullResult& result)
|
||||||
@@ -4173,16 +4177,19 @@ void LLPipeline::setupAvatarLights(BOOL for_edit)
|
|||||||
|
|
||||||
light_pos.normalize();
|
light_pos.normalize();
|
||||||
|
|
||||||
|
LLLightState* light = gGL.getLight(1);
|
||||||
|
|
||||||
mHWLightColors[1] = diffuse;
|
mHWLightColors[1] = diffuse;
|
||||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse.mV);
|
|
||||||
glLightfv(GL_LIGHT1, GL_AMBIENT, LLColor4::black.mV);
|
light->setDiffuse(diffuse);
|
||||||
glLightfv(GL_LIGHT1, GL_SPECULAR, LLColor4::black.mV);
|
light->setAmbient(LLColor4::black);
|
||||||
glLightfv(GL_LIGHT1, GL_POSITION, light_pos.mV);
|
light->setSpecular(LLColor4::black);
|
||||||
glLightf (GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.0f);
|
light->setPosition(light_pos);
|
||||||
glLightf (GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.0f);
|
light->setConstantAttenuation(1.f);
|
||||||
glLightf (GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.0f);
|
light->setLinearAttenuation(0.f);
|
||||||
glLightf (GL_LIGHT1, GL_SPOT_EXPONENT, 0.0f);
|
light->setQuadraticAttenuation(0.f);
|
||||||
glLightf (GL_LIGHT1, GL_SPOT_CUTOFF, 180.0f);
|
light->setSpotExponent(0.f);
|
||||||
|
light->setSpotCutoff(180.f);
|
||||||
}
|
}
|
||||||
else if (gAvatarBacklight) // Always true (unless overridden in a devs .ini)
|
else if (gAvatarBacklight) // Always true (unless overridden in a devs .ini)
|
||||||
{
|
{
|
||||||
@@ -4213,22 +4220,28 @@ void LLPipeline::setupAvatarLights(BOOL for_edit)
|
|||||||
backlight_diffuse *= backlight_mag / max_component;
|
backlight_diffuse *= backlight_mag / max_component;
|
||||||
|
|
||||||
mHWLightColors[1] = backlight_diffuse;
|
mHWLightColors[1] = backlight_diffuse;
|
||||||
glLightfv(GL_LIGHT1, GL_POSITION, backlight_pos.mV); // this is just sun/moon direction
|
|
||||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, backlight_diffuse.mV);
|
LLLightState* light = gGL.getLight(1);
|
||||||
glLightfv(GL_LIGHT1, GL_AMBIENT, LLColor4::black.mV);
|
|
||||||
glLightfv(GL_LIGHT1, GL_SPECULAR, LLColor4::black.mV);
|
light->setPosition(backlight_pos);
|
||||||
glLightf (GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.0f);
|
light->setDiffuse(backlight_diffuse);
|
||||||
glLightf (GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.0f);
|
light->setAmbient(LLColor4::black);
|
||||||
glLightf (GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.0f);
|
light->setSpecular(LLColor4::black);
|
||||||
glLightf (GL_LIGHT1, GL_SPOT_EXPONENT, 0.0f);
|
light->setConstantAttenuation(1.f);
|
||||||
glLightf (GL_LIGHT1, GL_SPOT_CUTOFF, 180.0f);
|
light->setLinearAttenuation(0.f);
|
||||||
|
light->setQuadraticAttenuation(0.f);
|
||||||
|
light->setSpotExponent(0.f);
|
||||||
|
light->setSpotCutoff(180.f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
LLLightState* light = gGL.getLight(1);
|
||||||
|
|
||||||
mHWLightColors[1] = LLColor4::black;
|
mHWLightColors[1] = LLColor4::black;
|
||||||
glLightfv(GL_LIGHT1, GL_DIFFUSE, LLColor4::black.mV);
|
|
||||||
glLightfv(GL_LIGHT1, GL_AMBIENT, LLColor4::black.mV);
|
light->setDiffuse(LLColor4::black);
|
||||||
glLightfv(GL_LIGHT1, GL_SPECULAR, LLColor4::black.mV);
|
light->setAmbient(LLColor4::black);
|
||||||
|
light->setSpecular(LLColor4::black);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4412,13 +4425,17 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
|
|||||||
LLVector4 light_pos(mSunDir, 0.0f);
|
LLVector4 light_pos(mSunDir, 0.0f);
|
||||||
LLColor4 light_diffuse = mSunDiffuse;
|
LLColor4 light_diffuse = mSunDiffuse;
|
||||||
mHWLightColors[0] = light_diffuse;
|
mHWLightColors[0] = light_diffuse;
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION, light_pos.mV); // this is just sun/moon direction
|
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse.mV);
|
LLLightState* light = gGL.getLight(0);
|
||||||
glLightfv(GL_LIGHT0, GL_AMBIENT, LLColor4::black.mV);
|
light->setPosition(light_pos);
|
||||||
glLightfv(GL_LIGHT0, GL_SPECULAR, LLColor4::black.mV);
|
light->setDiffuse(light_diffuse);
|
||||||
glLightf (GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.0f);
|
light->setAmbient(LLColor4::black);
|
||||||
glLightf (GL_LIGHT0, GL_SPOT_EXPONENT, 0.0f);
|
light->setSpecular(LLColor4::black);
|
||||||
glLightf (GL_LIGHT0, GL_SPOT_CUTOFF, 180.0f);
|
light->setConstantAttenuation(1.f);
|
||||||
|
light->setLinearAttenuation(0.f);
|
||||||
|
light->setQuadraticAttenuation(0.f);
|
||||||
|
light->setSpotExponent(0.f);
|
||||||
|
light->setSpotCutoff(180.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Light 1 = Backlight (for avatars)
|
// Light 1 = Backlight (for avatars)
|
||||||
@@ -4476,23 +4493,23 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
|
|||||||
float linatten = x / (light_radius); // % of brightness at radius
|
float linatten = x / (light_radius); // % of brightness at radius
|
||||||
|
|
||||||
mHWLightColors[cur_light] = light_color;
|
mHWLightColors[cur_light] = light_color;
|
||||||
S32 gllight = GL_LIGHT0+cur_light;
|
LLLightState* light_state = gGL.getLight(cur_light);
|
||||||
glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
|
|
||||||
glLightfv(gllight, GL_DIFFUSE, light_color.mV);
|
light_state->setPosition(light_pos_gl);
|
||||||
glLightfv(gllight, GL_AMBIENT, LLColor4::black.mV);
|
light_state->setDiffuse(light_color);
|
||||||
glLightf (gllight, GL_CONSTANT_ATTENUATION, 0.0f);
|
light_state->setAmbient(LLColor4::black);
|
||||||
if(sRenderDeferred)
|
light_state->setConstantAttenuation(0.f);
|
||||||
|
if (sRenderDeferred)
|
||||||
{
|
{
|
||||||
glLightf (gllight, GL_LINEAR_ATTENUATION, light_radius*1.5f);
|
light_state->setLinearAttenuation(light_radius*1.5f);
|
||||||
glLightf (gllight, GL_QUADRATIC_ATTENUATION, light->getLightFalloff()*0.5f+1.f);
|
light_state->setQuadraticAttenuation(light->getLightFalloff()*0.5f+1.f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glLightf (gllight, GL_LINEAR_ATTENUATION, linatten);
|
light_state->setLinearAttenuation(linatten);
|
||||||
glLightf (gllight, GL_QUADRATIC_ATTENUATION, 0.0f);
|
light_state->setQuadraticAttenuation(0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const LLCachedControl<bool> render_spot_lights_in_nondeferred("RenderSpotLightsInNondeferred",false);
|
static const LLCachedControl<bool> render_spot_lights_in_nondeferred("RenderSpotLightsInNondeferred",false);
|
||||||
if (light->isLightSpotlight() // directional (spot-)light
|
if (light->isLightSpotlight() // directional (spot-)light
|
||||||
&& (LLPipeline::sRenderDeferred || render_spot_lights_in_nondeferred)) // these are only rendered as GL spotlights if we're in deferred rendering mode *or* the setting forces them on
|
&& (LLPipeline::sRenderDeferred || render_spot_lights_in_nondeferred)) // these are only rendered as GL spotlights if we're in deferred rendering mode *or* the setting forces them on
|
||||||
@@ -4501,21 +4518,21 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
|
|||||||
LLQuaternion quat = light->getRenderRotation();
|
LLQuaternion quat = light->getRenderRotation();
|
||||||
LLVector3 at_axis(0,0,-1); // this matches deferred rendering's object light direction
|
LLVector3 at_axis(0,0,-1); // this matches deferred rendering's object light direction
|
||||||
at_axis *= quat;
|
at_axis *= quat;
|
||||||
//llinfos << "SPOT!!!!!!! fov: " << spotparams.mV[0] << " focus: " << spotparams.mV[1] << " dir: " << at_axis << llendl;
|
|
||||||
glLightfv(gllight, GL_SPOT_DIRECTION, at_axis.mV);
|
light_state->setSpotDirection(at_axis);
|
||||||
glLightf (gllight, GL_SPOT_EXPONENT, 2.0f); // 2.0 = good old dot product ^ 2
|
light_state->setSpotCutoff(90.f);
|
||||||
glLightf (gllight, GL_SPOT_CUTOFF, 90.0f); // hemisphere
|
light_state->setSpotExponent(2.f);
|
||||||
const float specular[] = {0.f, 0.f, 0.f, 0.f};
|
|
||||||
glLightfv(gllight, GL_SPECULAR, specular);
|
light_state->setSpecular(LLColor4::black);
|
||||||
}
|
}
|
||||||
else // omnidirectional (point) light
|
else // omnidirectional (point) light
|
||||||
{
|
{
|
||||||
glLightf (gllight, GL_SPOT_EXPONENT, 0.0f);
|
light_state->setSpotExponent(0.f);
|
||||||
glLightf (gllight, GL_SPOT_CUTOFF, 180.0f);
|
light_state->setSpotCutoff(180.f);
|
||||||
|
|
||||||
// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
|
// we use specular.w = 1.0 as a cheap hack for the shaders to know that this is omnidirectional rather than a spotlight
|
||||||
const float specular[] = {0.f, 0.f, 0.f, 1.f};
|
const LLColor4 specular(0.f, 0.f, 0.f, 1.f);
|
||||||
glLightfv(gllight, GL_SPECULAR, specular);
|
light_state->setSpecular(specular);
|
||||||
//llinfos << "boring light" << llendl;
|
//llinfos << "boring light" << llendl;
|
||||||
}
|
}
|
||||||
cur_light++;
|
cur_light++;
|
||||||
@@ -4528,12 +4545,12 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
|
|||||||
for ( ; cur_light < 8 ; cur_light++)
|
for ( ; cur_light < 8 ; cur_light++)
|
||||||
{
|
{
|
||||||
mHWLightColors[cur_light] = LLColor4::black;
|
mHWLightColors[cur_light] = LLColor4::black;
|
||||||
S32 gllight = GL_LIGHT0+cur_light;
|
LLLightState* light = gGL.getLight(cur_light);
|
||||||
glLightfv(gllight, GL_DIFFUSE, LLColor4::black.mV);
|
|
||||||
glLightfv(gllight, GL_AMBIENT, LLColor4::black.mV);
|
|
||||||
glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
light->setDiffuse(LLColor4::black);
|
||||||
|
light->setAmbient(LLColor4::black);
|
||||||
|
light->setSpecular(LLColor4::black);
|
||||||
|
}
|
||||||
if (isAgentAvatarValid() &&
|
if (isAgentAvatarValid() &&
|
||||||
gAgent.getAvatarObject()->mSpecialRenderMode == 3)
|
gAgent.getAvatarObject()->mSpecialRenderMode == 3)
|
||||||
{
|
{
|
||||||
@@ -4549,23 +4566,24 @@ void LLPipeline::setupHWLights(LLDrawPool* pool)
|
|||||||
float linatten = x / (light_radius); // % of brightness at radius
|
float linatten = x / (light_radius); // % of brightness at radius
|
||||||
|
|
||||||
mHWLightColors[2] = light_color;
|
mHWLightColors[2] = light_color;
|
||||||
S32 gllight = GL_LIGHT2;
|
LLLightState* light = gGL.getLight(2);
|
||||||
glLightfv(gllight, GL_POSITION, light_pos_gl.mV);
|
|
||||||
glLightfv(gllight, GL_DIFFUSE, light_color.mV);
|
light->setPosition(light_pos_gl);
|
||||||
glLightfv(gllight, GL_AMBIENT, LLColor4::black.mV);
|
light->setDiffuse(light_color);
|
||||||
glLightfv(gllight, GL_SPECULAR, LLColor4::black.mV);
|
light->setAmbient(LLColor4::black);
|
||||||
glLightf (gllight, GL_CONSTANT_ATTENUATION, 0.0f);
|
light->setSpecular(LLColor4::black);
|
||||||
glLightf (gllight, GL_LINEAR_ATTENUATION, linatten);
|
light->setQuadraticAttenuation(0.f);
|
||||||
glLightf (gllight, GL_QUADRATIC_ATTENUATION, 0.0f);
|
light->setConstantAttenuation(0.f);
|
||||||
glLightf (gllight, GL_SPOT_EXPONENT, 0.0f);
|
light->setLinearAttenuation(linatten);
|
||||||
glLightf (gllight, GL_SPOT_CUTOFF, 180.0f);
|
light->setSpotExponent(0.f);
|
||||||
|
light->setSpotCutoff(180.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init GL state
|
// Init GL state
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
for (S32 gllight=GL_LIGHT0; gllight<=GL_LIGHT7; gllight++)
|
for (S32 i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
glDisable(gllight);
|
gGL.getLight(i)->disable();
|
||||||
}
|
}
|
||||||
mLightMask = 0;
|
mLightMask = 0;
|
||||||
}
|
}
|
||||||
@@ -4588,15 +4606,16 @@ void LLPipeline::enableLights(U32 mask)
|
|||||||
{
|
{
|
||||||
for (S32 i=0; i<8; i++)
|
for (S32 i=0; i<8; i++)
|
||||||
{
|
{
|
||||||
|
LLLightState* light = gGL.getLight(i);
|
||||||
if (mask & (1<<i))
|
if (mask & (1<<i))
|
||||||
{
|
{
|
||||||
glEnable(GL_LIGHT0 + i);
|
light->enable();
|
||||||
glLightfv(GL_LIGHT0 + i, GL_DIFFUSE, mHWLightColors[i].mV);
|
light->setDiffuse(mHWLightColors[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glDisable(GL_LIGHT0 + i);
|
light->disable();
|
||||||
glLightfv(GL_LIGHT0 + i, GL_DIFFUSE, LLColor4::black.mV);
|
light->setDiffuse(LLColor4::black);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4683,7 +4702,6 @@ void LLPipeline::enableLightsFullbright(const LLColor4& color)
|
|||||||
void LLPipeline::disableLights()
|
void LLPipeline::disableLights()
|
||||||
{
|
{
|
||||||
enableLights(0); // no lighting (full bright)
|
enableLights(0); // no lighting (full bright)
|
||||||
glColor4f(1.f, 1.f, 1.f, 1.f); // lighting color = white by default
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
@@ -6231,7 +6249,8 @@ void LLPipeline::renderDeferredLighting()
|
|||||||
0, 0, mDeferredDepth.getWidth(), mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
0, 0, mDeferredDepth.getWidth(), mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||||
}
|
}
|
||||||
|
|
||||||
LLGLEnable multisample(GL_MULTISAMPLE_ARB);
|
static const LLCachedControl<U32> fsaa_samples("RenderFSAASamples",0);
|
||||||
|
LLGLEnable multisample(fsaa_samples > 0 ? GL_MULTISAMPLE_ARB : 0);
|
||||||
|
|
||||||
if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD))
|
if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD))
|
||||||
{
|
{
|
||||||
@@ -6792,9 +6811,7 @@ void LLPipeline::renderDeferredLighting()
|
|||||||
if (count == max_count || fullscreen_lights.empty())
|
if (count == max_count || fullscreen_lights.empty())
|
||||||
{
|
{
|
||||||
gDeferredMultiLightProgram.uniform1i("light_count", count);
|
gDeferredMultiLightProgram.uniform1i("light_count", count);
|
||||||
gDeferredMultiLightProgram.uniform4fv("light[0]", count, (GLfloat*) light);
|
|
||||||
gDeferredMultiLightProgram.uniform4fv("light", count, (GLfloat*) light);
|
gDeferredMultiLightProgram.uniform4fv("light", count, (GLfloat*) light);
|
||||||
gDeferredMultiLightProgram.uniform4fv("light_col[0]", count, (GLfloat*) col);
|
|
||||||
gDeferredMultiLightProgram.uniform4fv("light_col", count, (GLfloat*) col);
|
gDeferredMultiLightProgram.uniform4fv("light_col", count, (GLfloat*) col);
|
||||||
gDeferredMultiLightProgram.uniform1f("far_z", far_z);
|
gDeferredMultiLightProgram.uniform1f("far_z", far_z);
|
||||||
far_z = 0.f;
|
far_z = 0.f;
|
||||||
|
|||||||
Reference in New Issue
Block a user