Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 268 vs 272 for /trunk/Source Code/Hardware/Video/Shaders/ShaderProgram.cpp

Diff revisions: vs.
  @@ -38,6 +38,7 @@
38 38 _extendedMatrixEntry[WV_INV_MATRIX] = -1;
39 39 _extendedMatrixEntry[WVP_MATRIX] = -1;
40 40 _extendedMatrixEntry[NORMAL_MATRIX] = -1;
41 + _invProjMatrixEntry = -1;
41 42 _timeLoc = -1;
42 43 _cameraLocationLoc = -1;
43 44 _clipPlanesLoc = -1;
  @@ -47,9 +48,11 @@
47 48 _zPlanesLoc = -1;
48 49 _sceneZPlanesLoc = -1;
49 50 _screenDimensionLoc = -1;
51 + _invScreenDimension = -1;
50 52 _fogColorLoc = -1;
51 53 _fogDensityLoc = -1;
52 54 _prevLOD = 250;
55 + _prevTextureCount = 250;
53 56 _lodVertLight.resize(2);
54 57 _lodFragLight.resize(2);
55 58 I32 i = 0, j = 0;
  @@ -92,11 +95,12 @@
92 95 this->Uniform(_enableFogLoc, enableFog);
93 96 this->Uniform(_lightAmbientLoc, lightMgr.getAmbientLight());
94 97 if(_dirty){
95 - this->Uniform(_screenDimensionLoc, Application::getInstance().getResolution());
96 -
98 + const vec2<U16>& screenRes = GFX_DEVICE.getRenderTarget(GFXDevice::RENDER_TARGET_SCREEN)->getResolution();
99 + this->Uniform(_screenDimensionLoc, screenRes);
100 + this->Uniform(_invScreenDimension, vec2<F32>(1.0f / screenRes.width, 1.0f / screenRes.height));
97 101 //Apply global shader values valid throughout application runtime:
98 102 char depthMapSampler1[32], depthMapSampler2[32], depthMapSampler3[32];
99 - for(I32 i = 0; i < Config::MAX_SHADOW_CASTING_LIGHTS_PER_NODE; i++){
103 + for (I32 i = 0; i < Config::Lighting::MAX_SHADOW_CASTING_LIGHTS_PER_NODE; i++){
100 104 sprintf_s(depthMapSampler1, "texDepthMapFromLight[%d]", i);
101 105 sprintf_s(depthMapSampler2, "texDepthMapFromLightArray[%d]", i);
102 106 sprintf_s(depthMapSampler3, "texDepthMapFromLightCube[%d]", i);
  @@ -144,6 +148,7 @@
144 148 _extendedMatrixEntry[WV_INV_MATRIX] = this->cachedLoc("dvd_WorldViewMatrixInverse");
145 149 _extendedMatrixEntry[WVP_MATRIX] = this->cachedLoc("dvd_WorldViewProjectionMatrix");
146 150 _extendedMatrixEntry[NORMAL_MATRIX] = this->cachedLoc("dvd_NormalMatrix");
151 + _invProjMatrixEntry = this->cachedLoc("dvd_ProjectionMatrixInverse");
147 152 _timeLoc = this->cachedLoc("dvd_time");
148 153 _cameraLocationLoc = this->cachedLoc("dvd_cameraPosition");
149 154 _clipPlanesLoc = this->cachedLoc("dvd_clip_plane");
  @@ -208,6 +213,10 @@
208 213 this->Uniform(currentLocation, GFX.getMatrix4(WVP_MATRIX));
209 214 }
210 215
216 + currentLocation = _invProjMatrixEntry;
217 + if (currentLocation != -1){
218 + this->Uniform(currentLocation, GFX.getMatrix(PROJECTION_INV_MATRIX));
219 + }
211 220 _extendedMatricesDirty = false;
212 221 }
213 222 /*Get and upload clip plane data*/
  @@ -242,7 +251,11 @@
242 251 }
243 252
244 253 Uniform("material", material->getMaterialMatrix());
245 - Uniform("textureCount", material->getTextureCount());
254 + U8 currentTextureCount = material->getTextureCount();
255 + if(_prevTextureCount != currentTextureCount){
256 + Uniform("textureCount", material->getTextureCount());
257 + _prevTextureCount = currentTextureCount;
258 + }
246 259 }
247 260
248 261 void ShaderProgram::SetLOD(U8 currentLOD){