@@ -7,5 +7,5 @@ layout(location = 0) out vec4 fragmentColor;
|
|
7
7
|
|
8
8
|
void main()
|
9
9
|
{
|
10
|
-
fragmentColor = vec4(
|
10
|
+
fragmentColor = vec4(gl_FragCoord.z);
|
11
11
|
}
|
@@ -346,10 +346,33 @@ void display(void)
|
|
346
346
|
// Set up shadow map parameters
|
347
347
|
///////////////////////////////////////////////////////////////////////////
|
348
348
|
// Task 1
|
349
|
+
if(shadowMapFB.width != shadowMapResolution || shadowMapFB.height != shadowMapResolution)
|
350
|
+
{
|
351
|
+
shadowMapFB.resize(shadowMapResolution, shadowMapResolution);
|
352
|
+
}
|
353
|
+
|
354
|
+
glBindTexture(GL_TEXTURE_2D, shadowMapFB.depthBuffer);
|
355
|
+
|
356
|
+
|
357
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
358
|
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
359
|
+
|
349
360
|
|
350
361
|
///////////////////////////////////////////////////////////////////////////
|
351
362
|
// Draw Shadow Map
|
352
363
|
///////////////////////////////////////////////////////////////////////////
|
364
|
+
glBindFramebuffer(GL_FRAMEBUFFER, shadowMapFB.framebufferId);
|
365
|
+
glViewport(0, 0, shadowMapFB.width, shadowMapFB.height);
|
366
|
+
glClearColor(1.0, 1.0, 1.0, 1.0);
|
367
|
+
glClearDepth(1.0);
|
368
|
+
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
369
|
+
|
370
|
+
|
371
|
+
drawScene(depthProgram, lightViewMatrix, lightProjMatrix, lightViewMatrix, lightProjMatrix);
|
372
|
+
|
373
|
+
|
374
|
+
labhelper::Material& screen = landingpadModel->m_materials[8];
|
375
|
+
screen.m_emission_texture.gl_id = shadowMapFB.colorTextureTarget;
|
353
376
|
|
354
377
|
///////////////////////////////////////////////////////////////////////////
|
355
378
|
// Draw from camera
|