00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "lldrawpoolsky.h"
00035
00036 #include "imageids.h"
00037
00038 #include "llagent.h"
00039 #include "lldrawable.h"
00040 #include "llface.h"
00041 #include "llsky.h"
00042 #include "llviewercamera.h"
00043 #include "llviewerimagelist.h"
00044 #include "llviewerregion.h"
00045 #include "llviewerwindow.h"
00046 #include "llvosky.h"
00047 #include "llworld.h"
00048 #include "pipeline.h"
00049 #include "llglslshader.h"
00050
00051 LLDrawPoolSky::LLDrawPoolSky() :
00052 LLFacePool(POOL_SKY), mShader(NULL)
00053 {
00054 }
00055
00056 LLDrawPool *LLDrawPoolSky::instancePool()
00057 {
00058 return new LLDrawPoolSky();
00059 }
00060
00061 void LLDrawPoolSky::prerender()
00062 {
00063 mVertexShaderLevel = LLShaderMgr::getVertexShaderLevel(LLShaderMgr::SHADER_ENVIRONMENT);
00064 gSky.mVOSkyp->updateGeometry(gSky.mVOSkyp->mDrawable);
00065 }
00066
00067 void LLDrawPoolSky::render(S32 pass)
00068 {
00069 if (mDrawFace.empty())
00070 {
00071 return;
00072 }
00073
00074
00075 if (gPipeline.canUseWindLightShaders())
00076 {
00077 return;
00078 }
00079
00080
00081 if(mVertexShaderLevel > 0 && LLPipeline::sUnderWaterRender)
00082 {
00083 mShader = &gObjectFullbrightWaterProgram;
00084 mShader->bind();
00085 }
00086 else
00087 {
00088
00089 if (gGLManager.mHasShaderObjects)
00090 {
00091
00092
00093 glUseProgramObjectARB(0);
00094 }
00095 mShader = NULL;
00096 }
00097
00098
00099 LLVOSky *voskyp = gSky.mVOSkyp;
00100 LLGLSPipelineSkyBox gls_skybox;
00101
00102 LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
00103
00104 LLGLClampToFarClip far_clip(glh_get_current_projection());
00105
00106 LLGLEnable fog_enable( (mVertexShaderLevel < 1 && LLViewerCamera::getInstance()->cameraUnderWater()) ? GL_FOG : 0);
00107
00108 gPipeline.disableLights();
00109
00110 LLGLDisable clip(GL_CLIP_PLANE0);
00111
00112 glPushMatrix();
00113 LLVector3 origin = LLViewerCamera::getInstance()->getOrigin();
00114 glTranslatef(origin.mV[0], origin.mV[1], origin.mV[2]);
00115
00116 S32 face_count = (S32)mDrawFace.size();
00117
00118 for (S32 i = 0; i < llmin(6, face_count); ++i)
00119 {
00120 renderSkyCubeFace(i);
00121 }
00122
00123 LLFace *hbfaces[3];
00124 hbfaces[0] = NULL;
00125 hbfaces[1] = NULL;
00126 hbfaces[2] = NULL;
00127 for (S32 curr_face = 0; curr_face < face_count; curr_face++)
00128 {
00129 LLFace* facep = mDrawFace[curr_face];
00130 if (voskyp->isSameFace(LLVOSky::FACE_SUN, facep))
00131 {
00132 hbfaces[0] = facep;
00133 }
00134 if (voskyp->isSameFace(LLVOSky::FACE_MOON, facep))
00135 {
00136 hbfaces[1] = facep;
00137 }
00138 if (voskyp->isSameFace(LLVOSky::FACE_BLOOM, facep))
00139 {
00140 hbfaces[2] = facep;
00141 }
00142 }
00143
00144 LLGLEnable blend(GL_BLEND);
00145
00146 if (hbfaces[2])
00147 {
00148
00149 }
00150 if (hbfaces[0])
00151 {
00152
00153 }
00154 if (hbfaces[1])
00155 {
00156
00157 }
00158
00159 glPopMatrix();
00160 }
00161
00162 void LLDrawPoolSky::renderSkyCubeFace(U8 side)
00163 {
00164 LLFace &face = *mDrawFace[LLVOSky::FACE_SIDE0 + side];
00165 if (!face.getGeomCount())
00166 {
00167 return;
00168 }
00169
00170 mSkyTex[side].bindTexture(TRUE);
00171
00172 face.renderIndexed();
00173
00174 if (LLSkyTex::doInterpolate())
00175 {
00176 LLGLEnable blend(GL_BLEND);
00177 mSkyTex[side].bindTexture(FALSE);
00178 glColor4f(1, 1, 1, LLSkyTex::getInterpVal());
00179 face.renderIndexed();
00180 }
00181 }
00182
00183 void LLDrawPoolSky::renderHeavenlyBody(U8 hb, LLFace* face)
00184 {
00185 if ( !mHB[hb]->getDraw() ) return;
00186 if (! face->getGeomCount()) return;
00187
00188 LLImageGL* tex = face->getTexture();
00189 tex->bind();
00190 LLColor4 color(mHB[hb]->getInterpColor());
00191 LLOverrideFaceColor override(this, color);
00192 face->renderIndexed();
00193 }
00194
00195
00196
00197 void LLDrawPoolSky::renderSunHalo(LLFace* face)
00198 {
00199 if (! mHB[0]->getDraw()) return;
00200 if (! face->getGeomCount()) return;
00201
00202 LLImageGL* tex = face->getTexture();
00203 tex->bind();
00204 LLColor4 color(mHB[0]->getInterpColor());
00205 color.mV[3] = llclamp(mHB[0]->getHaloBrighness(), 0.f, 1.f);
00206
00207 LLOverrideFaceColor override(this, color);
00208 face->renderIndexed();
00209 }
00210
00211
00212 void LLDrawPoolSky::renderForSelect()
00213 {
00214 }
00215
00216 void LLDrawPoolSky::endRenderPass( S32 pass )
00217 {
00218 }