PDA

View Full Version : Shadow mapping



tgaudele
02-19-2016, 01:39 AM
Hi all,

Here's my issue: I'm looking to detect shadow in a picture. It so happens that I have a three-dimensional object of the scene (obtained through stereo method) and I'm trying to assess if shadow mapping is a sensible method to find the shadow in the picture. For this I'm trying to use openGL as I think it's probably the most optimized solution out there. My objective is to output a 2D binary image corresponding to the shadow map from the camera point of view. I have everything I need, I can render the scene in 3D without issues but I do not know where to get the shadow map from and to output it as a binary mask.

If you have any input, I would greatly appreciate it,
Cheers,

Carmine
02-19-2016, 03:40 PM
... I have a three-dimensional object of the scene .... This statement makes no sense to me. Did you mean to say you have a "3D image"? Do you have an OpenGL program that generates the images? Have you written this program yourself? Can you change the source code? If so, it should be easy to determine where the shadows lie. It would be very helpful (to me) if you could post an image. Do you know where the light source is located in the scene?

tgaudele
02-22-2016, 01:27 AM
Hi Carmine, thanks for your reply! I have a 3D image. I place the light source and then render the scene from a given point of view (different from the light source). This naturally leads to shadows appearing in the scene and I want to extract these shadows as a 2D binary mask as seen from the point of view. Nothing really fancy here, and I am pretty sure it must be straightforward for a seasoned openGL programmer but I can't find any info as to where and how I can extract this.

Carmine
02-22-2016, 08:11 PM
Don't have an easy answer for you. I've implemented OpenGL shadowing using the shadow mapping approach. My code was based on examples I found on the web. The basic idea is easy to understand, but the OpenGL implementation was hard for me to follow on a line-by-line level. So I'm not the one to give advice on this topic. You could try what I did by looking at examples of shadowing code on the web until you find one that made enough sense to use as a template.

uwi2k2
02-23-2016, 12:36 AM
hi,
sounds to me like you are missing the basic idea of how to do it ...
maybe just to get you started, a little easy help:
http://www.opengl2go.net/2016/01/30/published-011-lights-and-shadows/

tgaudele
02-24-2016, 01:29 AM
Thanks for your replies guys. uwi2k2, I understand the principle fairly well, I have implemented the algorithm in Matlab and can obtain the result I want there. I want to use openGL for efficiency (speed GPU + better precision). I am just trying to locate/extract (or how to create) the two-dimensional shadow-map of the scene as seen from the camera point of view. And I am having trouble finding where/how it is stored by openGL.

Spoops
02-24-2016, 05:44 AM
Hi,
Shadow mapping is quite an advanced technique for a beginner and will require you to learn most aspects of 'modern' OpenGL (shaders, textures, FBOs). There's lots of good tutorials on the internet, but I would recommend learnopengl.com for its clarity, and it includes a page about shadow mapping as well.