Sie sind auf Seite 1von 13

Shadow Mapping &

GLM Library
CENG 477 – COMPUTER GRAPHICS

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 1


OpenGL Spaces

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 2


Modeling Transform

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 3


Viewing Transform

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 4


Projection and Perspective Divide

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 5


Shadowing Techniques
• Light maps don’t deal with movable lights.
• You bake it just once, then use it as a texture.
• Extensively use for the sunlight or indoor scenes.

• There are various methods used for dynamic shadows.


• Shadow Volume
• Project a ray from the light source through each shadow casting object.
• SHADOW MAPPING

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 6


Shadow Mapping
• Algorithm consists of two passes.
•In the first pass, scene is rendered from viewpoint of the light.
• In the HW, light is directional. Therefore ortographic projection should be used.

•In the second pass scene is rendered from viewpoint of the camera.
• But you should do an extra test to understand whether a pixel in shadow.

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 7


Shadow Mapping

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 8


Shadowed Scene

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 9


Shadow Texture

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 10


OpenGL Mathematics (GLM)
• Is a header only C++ mathematics library based on GLSL specifications.
• Most importantly matrices are in column-major order.

• Naming conventions and functionalities are same with GLSL.


•It is a header only library.
• You don’t need to build to use it.
• You only have to include <glm/[headerName].hpp>

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 11


GLM Datatypes
• Matrix-Stack is deprecated with OpenGL 3.0
• In order understand space transformations, it is suggested to use GLM in your HW.
• glm::vec4 pos = glm::vec4(1.0f, 1.0f, 0.0f, 1.0f)
• glm::mat4 viewMatrix = glm::lookAt(camPos, centerPos, upVec)
• glm::mat4 modelMatrix = glm::mat4(1.0f) // Load Identity
model = glm::rotate(model, ...)
• glm::mat4 mvMatrix = view x model
• glm::mat4 projMatrix = glm::perspective(fovy, aspect, near, far)
• glm::mat4 lightProjMatrix = glm::ortho(left, right, bottom, top)
• Glm::mat4 mvpMatrix = projMatrix(or lightProjMatrix) x mvMatrix

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 12


QUESTIONS ?

12/22/2014 IMAGE IS TAKEN FROM HTTP://GOO.GL/AHNRYT 13

Das könnte Ihnen auch gefallen