[2954] | 1 | #include "SkyPreetham.h"
|
---|
[2955] | 2 | #include "common.h"
|
---|
| 3 | #include "Vector3.h"
|
---|
[2957] | 4 | #include "SceneEntity.h"
|
---|
| 5 | #include "Transform3.h"
|
---|
| 6 | #include "Camera.h"
|
---|
| 7 | #include "RenderState.h"
|
---|
[3036] | 8 | #include "ShaderProgram.h"
|
---|
| 9 | #include "Shape.h"
|
---|
| 10 | #include "Material.h"
|
---|
[3057] | 11 | #include "ShaderManager.h"
|
---|
[2955] | 12 |
|
---|
[3021] | 13 |
|
---|
[3038] | 14 |
|
---|
[3021] | 15 | #ifdef _CRT_SET
|
---|
| 16 | #define _CRTDBG_MAP_ALLOC
|
---|
| 17 | #include <stdlib.h>
|
---|
| 18 | #include <crtdbg.h>
|
---|
| 19 |
|
---|
| 20 | // redefine new operator
|
---|
| 21 | #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
|
---|
| 22 | #define new DEBUG_NEW
|
---|
| 23 | #endif
|
---|
| 24 |
|
---|
| 25 |
|
---|
[3038] | 26 |
|
---|
| 27 |
|
---|
[2957] | 28 | using namespace CHCDemoEngine;
|
---|
| 29 | using namespace std;
|
---|
[2955] | 30 |
|
---|
[2954] | 31 |
|
---|
[2959] | 32 |
|
---|
[2955] | 33 | inline float CBQ(float x)
|
---|
| 34 | {
|
---|
| 35 | return x * x * x;
|
---|
| 36 | }
|
---|
[2954] | 37 |
|
---|
| 38 |
|
---|
[2955] | 39 | inline float SQR(float x)
|
---|
| 40 | {
|
---|
| 41 | return x * x ;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 |
|
---|
[3038] | 45 | void SkyPreetham::InitCG()
|
---|
[2957] | 46 | {
|
---|
[3038] | 47 | mSkyVtxProgram =
|
---|
[3057] | 48 | ShaderManager::GetSingleton()->CreateVertexProgram("sky_preetham", "default_vs", "skyVtx");
|
---|
[3038] | 49 |
|
---|
| 50 | if (mSkyVtxProgram->IsValid())
|
---|
[2957] | 51 | {
|
---|
[3038] | 52 | mSkyVtxProgram->AddParameter("lightDir", 0);
|
---|
| 53 | mSkyVtxProgram->AddParameter("thetaSun", 1);
|
---|
| 54 | mSkyVtxProgram->AddParameter("zenithColor", 2);
|
---|
| 55 | mSkyVtxProgram->AddParameter("aColor", 3);
|
---|
| 56 | mSkyVtxProgram->AddParameter("bColor", 4);
|
---|
| 57 | mSkyVtxProgram->AddParameter("cColor", 5);
|
---|
| 58 | mSkyVtxProgram->AddParameter("dColor", 6);
|
---|
| 59 | mSkyVtxProgram->AddParameter("eColor", 7);
|
---|
| 60 | mSkyVtxProgram->AddParameter("multiplier", 8);
|
---|
[2957] | 61 | }
|
---|
| 62 | else
|
---|
[3291] | 63 | {
|
---|
[2957] | 64 | cerr << "sky program failed to load" << endl;
|
---|
[3291] | 65 | }
|
---|
[2959] | 66 |
|
---|
[3038] | 67 | mSkyFragProgram =
|
---|
[3057] | 68 | ShaderManager::GetSingleton()->CreateFragmentProgram("sky_preetham", "frag_skydome", "skyFragMrt");
|
---|
[2957] | 69 | }
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | SkyPreetham::SkyPreetham(float turbitity, SceneEntity *skyDome):
|
---|
| 73 | mSkyDome(skyDome),
|
---|
| 74 | mTurbidity(turbitity)
|
---|
[2981] | 75 | //, mSunQuad(NULL)
|
---|
[2954] | 76 | {
|
---|
[2955] | 77 | CreateSunQuad();
|
---|
[3036] | 78 | Shape *shape = mSkyDome->GetShape(0);
|
---|
| 79 |
|
---|
[3038] | 80 | InitCG();
|
---|
| 81 |
|
---|
[3036] | 82 | Material *mat = shape->GetMaterial();
|
---|
| 83 |
|
---|
[3045] | 84 | mat->GetTechnique(0)->SetFragmentProgram(mSkyFragProgram);
|
---|
| 85 | mat->GetTechnique(0)->SetVertexProgram(mSkyVtxProgram);
|
---|
| 86 |
|
---|
| 87 | mat->GetTechnique(1)->SetFragmentProgram(mSkyFragProgram);
|
---|
| 88 | mat->GetTechnique(1)->SetVertexProgram(mSkyVtxProgram);
|
---|
[2954] | 89 | }
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | SkyPreetham::~SkyPreetham()
|
---|
| 93 | {
|
---|
[2955] | 94 | //DEL_PTR(mSunQuad);
|
---|
[2954] | 95 | }
|
---|
| 96 |
|
---|
| 97 |
|
---|
[2983] | 98 | void SkyPreetham::RenderSkyDome(const Vector3 &sunDir,
|
---|
| 99 | Camera *camera,
|
---|
| 100 | RenderState *state,
|
---|
[3279] | 101 | bool scaleToRange,
|
---|
| 102 | float skyDomeScaleFactor)
|
---|
[2954] | 103 | {
|
---|
[2960] | 104 | pair<float, float> sun_theta;
|
---|
[2955] | 105 | Vector3 zenithColor;
|
---|
[2960] | 106 | vector<Vector3> ABCDE;
|
---|
[3036] | 107 |
|
---|
[2960] | 108 | ComputeFactors(sunDir, zenithColor, ABCDE, sun_theta);
|
---|
[2954] | 109 |
|
---|
| 110 | // Move skybox with camera.
|
---|
[2957] | 111 | Vector3 position = camera->GetPosition();
|
---|
[2954] | 112 |
|
---|
[3246] | 113 | // scale the sky dome so no intersection with the scene is visible
|
---|
[3279] | 114 | position.z -= 3.0f * skyDomeScaleFactor;
|
---|
[2957] | 115 | Matrix4x4 m = TranslationMatrix(position);
|
---|
| 116 |
|
---|
[3279] | 117 | Matrix4x4 s = ScaleMatrix(skyDomeScaleFactor);
|
---|
[2957] | 118 | mSkyDome->GetTransform()->SetMatrix(s * m);
|
---|
| 119 |
|
---|
[3042] | 120 | Material *mat = mSkyDome->GetShape(0)->GetMaterial();
|
---|
[2957] | 121 |
|
---|
[3045] | 122 | Technique *tech;
|
---|
| 123 |
|
---|
[3048] | 124 | tech = mat->GetTechnique(state->GetRenderTechnique());
|
---|
[3045] | 125 |
|
---|
[3042] | 126 | GPUProgramParameters *vtxParams = tech->GetVertexProgramParameters();
|
---|
| 127 |
|
---|
[3036] | 128 | vtxParams->SetValue3f(0, sunDir.x, sunDir.y, sunDir.z);
|
---|
| 129 | vtxParams->SetValue2f(1, sun_theta.first, sun_theta.second);
|
---|
| 130 | vtxParams->SetValue3f(2, zenithColor.x, zenithColor.y, zenithColor.z);
|
---|
[2957] | 131 |
|
---|
[3036] | 132 | vtxParams->SetValue3f(3, ABCDE[0].x, ABCDE[0].y, ABCDE[0].z);
|
---|
| 133 | vtxParams->SetValue3f(4, ABCDE[1].x, ABCDE[1].y, ABCDE[1].z);
|
---|
| 134 | vtxParams->SetValue3f(5, ABCDE[2].x, ABCDE[2].y, ABCDE[2].z);
|
---|
| 135 | vtxParams->SetValue3f(6, ABCDE[3].x, ABCDE[3].y, ABCDE[3].z);
|
---|
| 136 | vtxParams->SetValue3f(7, ABCDE[4].x, ABCDE[4].y, ABCDE[4].z);
|
---|
[2983] | 137 |
|
---|
| 138 |
|
---|
| 139 | if (!scaleToRange)
|
---|
[3123] | 140 | {
|
---|
[2983] | 141 | // use tone mapping
|
---|
[3038] | 142 | vtxParams->SetValue1f(8, 1.0f);
|
---|
[2983] | 143 | }
|
---|
| 144 | else
|
---|
[2982] | 145 | {
|
---|
[3193] | 146 | // no tone mapping => linearily scale to displayable dynamic range
|
---|
[3038] | 147 | vtxParams->SetValue1f(8, 8e-5f);
|
---|
[2982] | 148 | }
|
---|
[3039] | 149 |
|
---|
[3043] | 150 | // render sky dome
|
---|
[2957] | 151 | mSkyDome->Render(state);
|
---|
[2954] | 152 |
|
---|
[3043] | 153 | // render additively blended sun disc.
|
---|
[2958] | 154 | //RenderSunDisk(sunDir, camera);
|
---|
[2954] | 155 | }
|
---|
| 156 |
|
---|
| 157 |
|
---|
[2958] | 158 | void SkyPreetham::RenderSunDisk(const Vector3 &sunDir, Camera *camera)
|
---|
[2954] | 159 | {
|
---|
[3070] | 160 | #if TODO
|
---|
[2958] | 161 | // Move skybox with camera.
|
---|
| 162 | Vector3 position = camera->GetPosition();
|
---|
[2954] | 163 |
|
---|
[2958] | 164 | const float scaleFactor = 100.0f;
|
---|
| 165 | position.z -= 10 * scaleFactor;
|
---|
| 166 |
|
---|
[2954] | 167 | // Set world matrix to sun disc position.
|
---|
[2958] | 168 | Matrix4x4 sunPos = TranslationMatrix(position);
|
---|
[2954] | 169 |
|
---|
[2958] | 170 | Vector3 ndir = -Normalize(sunDir);
|
---|
[2954] | 171 |
|
---|
[2958] | 172 | const float pitch = -atan2(ndir.x, ndir.y);
|
---|
| 173 | const float yaw = atan2(ndir.z, sqrt((ndir.x * ndir.x) + (ndir.y * ndir.y)));
|
---|
[2954] | 174 |
|
---|
[2958] | 175 | Matrix4x4 roty = RotationYMatrix(pitch);
|
---|
| 176 | Matrix4x4 rotx = RotationXMatrix(yaw);
|
---|
| 177 |
|
---|
| 178 | sunPos *= roty;
|
---|
| 179 | sunPos *= rotx;;
|
---|
| 180 |
|
---|
[3036] | 181 | sunposition.rotateAroundY(-D().getScene().getLight().getHorizontalOrientation() + 90.0f);
|
---|
| 182 | sunposition.rotateAroundX(-D().getScene().getLight().getVerticalOrientation());
|
---|
[2954] | 183 |
|
---|
[2958] | 184 | glMatrixMode(GL_MODELVIEW);
|
---|
| 185 | glMultMatrixf((float *)sunPos.x);
|
---|
| 186 |
|
---|
| 187 | float ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
|
---|
| 188 |
|
---|
| 189 | glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
|
---|
| 190 |
|
---|
[3036] | 191 | Float size = 0.5f + (1.0f - lightdirection.y) * 0.5f;
|
---|
[2958] | 192 |
|
---|
[3036] | 193 | mSunEffect->setVariableVector3("LightDiffuseColor", D().getScene().getLight().getDiffuseColor());
|
---|
| 194 | mSunEffect->setVariableFloat("SunSize", size);
|
---|
| 195 | mSunEffect->setVariableTexture2D("SunTexture", mSunTexture);
|
---|
[2958] | 196 |
|
---|
[3036] | 197 | mSunEffect->activate();
|
---|
[2958] | 198 |
|
---|
[2954] | 199 | mSunQuad->render();
|
---|
| 200 |
|
---|
| 201 | mSunEffect->deactivate();
|
---|
[3036] | 202 | F().getRenderDevice().setDefaultBlendingMode(FRenderDevice::BLENDING_NONE);
|
---|
[2954] | 203 |
|
---|
[2958] | 204 | glPopMatrix();
|
---|
[3036] | 205 | #endif
|
---|
[2954] | 206 | }
|
---|
| 207 |
|
---|
| 208 |
|
---|
[2955] | 209 | void SkyPreetham::CreateSunQuad()
|
---|
[2954] | 210 | {
|
---|
[3036] | 211 | #if TODO
|
---|
[2954] | 212 | mSunQuad = new FVertexBuffer();
|
---|
| 213 | mSunQuad->setupPrimitiveType(FVertexBuffer::PRIMITIVES_TRIANGLES);
|
---|
| 214 | mSunQuad->setupVertexFormat(3, 0, 0, true);
|
---|
| 215 | mSunQuad->setupTexCoordSet(0, 2);
|
---|
| 216 | mSunQuad->setVertexBufferSize(4, 6);
|
---|
| 217 |
|
---|
| 218 | mSunQuad->setVertexPosition(0, FVector3(-0.1f, 0.1f, 1.0f));
|
---|
| 219 | mSunQuad->setVertexPosition(1, FVector3( 0.1f, 0.1f, 1.0f));
|
---|
| 220 | mSunQuad->setVertexPosition(2, FVector3(-0.1f, -0.1f, 1.0f));
|
---|
| 221 | mSunQuad->setVertexPosition(3, FVector3( 0.1f, -0.1f, 1.0f));
|
---|
| 222 | mSunQuad->setVertexTexCoord(0, 0, FVector2(0.0f, 0.0f));
|
---|
| 223 | mSunQuad->setVertexTexCoord(1, 0, FVector2(1.0f, 0.0f));
|
---|
| 224 | mSunQuad->setVertexTexCoord(2, 0, FVector2(0.0f, 1.0f));
|
---|
| 225 | mSunQuad->setVertexTexCoord(3, 0, FVector2(1.0f, 1.0f));
|
---|
| 226 |
|
---|
| 227 | mSunQuad->setIndex(0, 0);
|
---|
| 228 | mSunQuad->setIndex(1, 1);
|
---|
| 229 | mSunQuad->setIndex(2, 2);
|
---|
| 230 | mSunQuad->setIndex(3, 2);
|
---|
| 231 | mSunQuad->setIndex(4, 1);
|
---|
| 232 | mSunQuad->setIndex(5, 3);
|
---|
[3036] | 233 | #endif
|
---|
[2960] | 234 | }
|
---|
| 235 |
|
---|
| 236 |
|
---|
| 237 | void SkyPreetham::ComputeFactors(const Vector3 &sunDir,
|
---|
| 238 | Vector3 &zenithColor,
|
---|
| 239 | vector<Vector3> &ABCDE,
|
---|
| 240 | std::pair<float, float> &sunThetha) const
|
---|
| 241 | {
|
---|
| 242 | sunThetha.first = acos(sunDir.z);
|
---|
| 243 |
|
---|
| 244 | const float cos_theta = cos(sunThetha.first);
|
---|
| 245 | sunThetha.second = cos_theta * cos_theta;
|
---|
| 246 |
|
---|
| 247 | zenithColor.x = ( 0.00165f * CBQ(sunThetha.first) - 0.00374f * SQR(sunThetha.first) + 0.00208f * sunThetha.first + 0.0f) * SQR(mTurbidity) +
|
---|
| 248 | (-0.02902f * CBQ(sunThetha.first) + 0.06377f * SQR(sunThetha.first) - 0.03202f * sunThetha.first + 0.00394f) * mTurbidity +
|
---|
| 249 | ( 0.11693f * CBQ(sunThetha.first) - 0.21196f * SQR(sunThetha.first) + 0.06052f * sunThetha.first + 0.25885f);
|
---|
| 250 |
|
---|
| 251 | zenithColor.y = ( 0.00275f * CBQ(sunThetha.first) - 0.00610f * SQR(sunThetha.first) + 0.00316f * sunThetha.first + 0.0f) * SQR(mTurbidity) +
|
---|
| 252 | (-0.04214f * CBQ(sunThetha.first) + 0.08970f * SQR(sunThetha.first) - 0.04153f * sunThetha.first + 0.00515f) * mTurbidity +
|
---|
| 253 | ( 0.15346f * CBQ(sunThetha.first) - 0.26756f * SQR(sunThetha.first) + 0.06669f * sunThetha.first + 0.26688f);
|
---|
| 254 |
|
---|
| 255 | zenithColor.z = (float)((4.0453f * mTurbidity - 4.9710f) * tan((4.0f / 9.0f - mTurbidity / 120.0f) *
|
---|
| 256 | (M_PI - 2.0f * sunThetha.first)) - 0.2155f * mTurbidity + 2.4192f);
|
---|
| 257 |
|
---|
| 258 | // convert kcd/m² to cd/m²
|
---|
| 259 | zenithColor.z *= 1000.0f;
|
---|
| 260 |
|
---|
| 261 | ABCDE.push_back(Vector3(-0.01925 * mTurbidity - 0.25922, -0.01669 * mTurbidity - 0.26078, 0.17872 * mTurbidity - 1.46303));
|
---|
| 262 | ABCDE.push_back(Vector3(-0.06651 * mTurbidity + 0.00081, -0.09495 * mTurbidity + 0.00921, -0.35540 * mTurbidity + 0.42749));
|
---|
| 263 | ABCDE.push_back(Vector3(-0.00041 * mTurbidity + 0.21247, -0.00792 * mTurbidity + 0.21023, -0.02266 * mTurbidity + 5.32505));
|
---|
| 264 | ABCDE.push_back(Vector3(-0.06409 * mTurbidity - 0.89887, -0.04405 * mTurbidity - 1.65369, 0.12064 * mTurbidity - 2.57705));
|
---|
| 265 | ABCDE.push_back(Vector3(-0.00325 * mTurbidity + 0.04517, -0.01092 * mTurbidity + 0.05291, -0.06696 * mTurbidity + 0.37027));
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 |
|
---|
[2983] | 269 | void SkyPreetham::ComputeSunColor(const Vector3 &sunDir,
|
---|
| 270 | Vector3 &ambient,
|
---|
| 271 | Vector3 &diffuse,
|
---|
| 272 | bool scaleToRange) const
|
---|
[2960] | 273 | {
|
---|
| 274 | // sunDir is sun direction
|
---|
| 275 | // ambient color: shadow color
|
---|
| 276 | // diffuse color: sun color
|
---|
| 277 | pair<float, float> sun_theta;
|
---|
[3123] | 278 |
|
---|
[2960] | 279 | Vector3 zenithColor;
|
---|
| 280 | vector<Vector3> ABCDE;
|
---|
| 281 |
|
---|
| 282 | ComputeFactors(sunDir, zenithColor, ABCDE, sun_theta);
|
---|
| 283 |
|
---|
| 284 | Vector3 zenith_XYZ;
|
---|
| 285 |
|
---|
[2967] | 286 | zenith_XYZ.x = (zenithColor.x / zenithColor.y) * zenithColor.z;
|
---|
| 287 | zenith_XYZ.y = zenithColor.z;
|
---|
| 288 | zenith_XYZ.z = ((1.0f - zenithColor.x - zenithColor.y) / zenithColor.y) * zenithColor.z;
|
---|
[2960] | 289 |
|
---|
| 290 | ambient.x = 3.240479f * zenith_XYZ.x - 1.537150f * zenith_XYZ.y - 0.498535f * zenith_XYZ.z;
|
---|
| 291 | ambient.y = -0.969256f * zenith_XYZ.x + 1.875992f * zenith_XYZ.y + 0.041556f * zenith_XYZ.z;
|
---|
| 292 | ambient.z = 0.055648f * zenith_XYZ.x - 0.204043f * zenith_XYZ.y + 1.057311f * zenith_XYZ.z;
|
---|
| 293 |
|
---|
| 294 | // downscale ambient color
|
---|
[2982] | 295 | if (scaleToRange)
|
---|
[3295] | 296 | {
|
---|
[3189] | 297 | ambient *= 8e-6f;
|
---|
[3295] | 298 | }
|
---|
[2981] | 299 | else
|
---|
[3291] | 300 | {
|
---|
[2981] | 301 | ambient *= 1e-1f;
|
---|
[2960] | 302 |
|
---|
[3291] | 303 | // slightly too blueish with tone mapping => scale
|
---|
| 304 | ambient.x *= 1.3f;
|
---|
| 305 | ambient.y *= 1.1f;
|
---|
| 306 | ambient.z = max(max(ambient.z, ambient.x), ambient.y);
|
---|
| 307 | }
|
---|
| 308 |
|
---|
[3287] | 309 |
|
---|
[2960] | 310 | // simulate the sun intensity by modulating the ambient term.
|
---|
[2970] | 311 | ambient *= (10.0f - 9.0f * DotProd(sunDir, Vector3::UNIT_Z()));
|
---|
[2960] | 312 |
|
---|
[3077] | 313 |
|
---|
[2960] | 314 | Vector3 num;
|
---|
| 315 |
|
---|
| 316 | num.x = (1.0f + ABCDE[0].x * exp(ABCDE[1].x / sunDir.z)) * (1.0f + ABCDE[2].x)+ ABCDE[4].x;
|
---|
| 317 | num.y = (1.0f + ABCDE[0].y * exp(ABCDE[1].y / sunDir.z)) * (1.0f + ABCDE[2].y)+ ABCDE[4].y;
|
---|
| 318 | num.z = (1.0f + ABCDE[0].z * exp(ABCDE[1].z / sunDir.z)) * (1.0f + ABCDE[2].z)+ ABCDE[4].z;
|
---|
| 319 |
|
---|
| 320 | Vector3 den;
|
---|
| 321 |
|
---|
| 322 | den.x = (1.0f + ABCDE[0].x * exp(ABCDE[1].x)) * (1.0f + ABCDE[2].x * exp(ABCDE[3].x * sun_theta.first) + ABCDE[4].x * sun_theta.second);
|
---|
| 323 | den.y = (1.0f + ABCDE[0].y * exp(ABCDE[1].y)) * (1.0f + ABCDE[2].y * exp(ABCDE[3].y * sun_theta.first) + ABCDE[4].y * sun_theta.second);
|
---|
| 324 | den.z = (1.0f + ABCDE[0].z * exp(ABCDE[1].z)) * (1.0f + ABCDE[2].z * exp(ABCDE[3].z * sun_theta.first) + ABCDE[4].z * sun_theta.second);
|
---|
| 325 |
|
---|
| 326 |
|
---|
[2967] | 327 | Vector3 xyY = zenithColor * num / den;
|
---|
[2960] | 328 |
|
---|
| 329 | Vector3 XYZ;
|
---|
| 330 |
|
---|
| 331 | XYZ.x = (xyY.x / xyY.y) * xyY.z;
|
---|
| 332 | XYZ.y = xyY.z;
|
---|
| 333 | XYZ.z = ((1.0f - xyY.x - xyY.y) / xyY.y) * xyY.z;
|
---|
| 334 |
|
---|
| 335 |
|
---|
[2967] | 336 | /////////////
|
---|
| 337 | //-- transform to rgb
|
---|
| 338 |
|
---|
[2960] | 339 | Vector3 color;
|
---|
| 340 | color.x = 3.240479f * XYZ.x - 1.537150f * XYZ.y - 0.498535f * XYZ.z;
|
---|
| 341 | color.y = -0.969256f * XYZ.x + 1.875992f * XYZ.y + 0.041556f *XYZ.z;
|
---|
| 342 | color.z = 0.055648f * XYZ.x - 0.204043f * XYZ.y + 1.057311f * XYZ.z;
|
---|
| 343 |
|
---|
[3077] | 344 | // calculate final sun diffuse color.
|
---|
[2982] | 345 | if (scaleToRange)
|
---|
[3295] | 346 | {
|
---|
[3189] | 347 | diffuse = color * 3e-5f;
|
---|
[3295] | 348 | }
|
---|
[2981] | 349 | else
|
---|
[3295] | 350 | {
|
---|
[2981] | 351 | diffuse = color * 3e-1f;
|
---|
[3295] | 352 | }
|
---|
[2981] | 353 |
|
---|
[3017] | 354 | // diffuse component should be more saturated (and less blueish) for high sun positions
|
---|
[3020] | 355 | diffuse.x *= 1.3f;
|
---|
| 356 | diffuse.z *= 0.7f;
|
---|
[3017] | 357 |
|
---|
| 358 | // scale diffuse component in order to make sky look less bright in relation to
|
---|
| 359 | // the geometry in the evening
|
---|
[2971] | 360 | diffuse *= (2.0f - 1.0f * DotProd(sunDir, Vector3::UNIT_Z()));
|
---|
[2967] | 361 |
|
---|
[2968] | 362 | //cout << "diffuse: " << Magnitude(diffuse) << " ambient: " << Magnitude(ambient) << endl;
|
---|
[2954] | 363 | } |
---|