Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 3 of 3 FirstFirst 123
Results 21 to 23 of 23

Thread: Calculating where the shadow falls on a plane

  1. #21
    Intern Newbie
    Join Date
    Dec 2011
    Posts
    46

    Re: Calculating where the shadow falls on a plane

    Quote Originally Posted by Dark Photon
    Sounds like you're trying to compute soft shadows by accumulating the results of rendering hard shadows from a bunch of different points on the surface of an area light source.

    I probably don't understand some of what you're requirements are, but...
    This program allows to see if 3d vehicles respect a certain standard or not. This is why I need to image my floor like a matrix based on tiles and know with precision which of them are hard and soft shadowed.

    Quote Originally Posted by Dark Photon
    I have to confess. I don't understand:
    1. why you think you need CUDA for this,
    2. why you're convinced you need a renderbuffer over a texture.
    - Because I thought it could be much faster keeping all data on graphic card and merge all the shadow-set from there, without reading everytime the RBO/Texture to a buffer and sending it everytime back the to the cpu.
    - Because reading around, they say RBO are faster (like here )

    However, I would like to underline that this is just my impressions and since I am a newbie in OpenGL I am totally open to suggests/ideas

    Quote Originally Posted by Dark Photon
    From what I gather, seems to me you could do this all in GL/GLSL, keep around just two images (or some small number), and use textures instead (so you could use GLSL to do the reduction).
    Ok, but would this require to use OpenGL 3+? Because I was told to start with OpenGL 2 since it is easier for beginners. Do you think GL/GLSL and OpenGL 3 is too much? I am also asking, because it looked to me like the most of tutorials on the web are for the 80% based on the OpenGL 2 and 1.

    Quote Originally Posted by Dark Photon
    Rendering 5 million tris is child's play for GL on a GPU (if you batch your data properly), so even with 100 such frames rendered from different eyepoints (positions on the light source), this isn't super heavy lifting. Not necessarily real-time (I'm assuming that's not your goal), but still pretty darn fast.
    Actually I was trying to render a 5 milions of triangles, but I had some problem with the VBO allocation (I could not create a single VBO with more than 2M), so at the end I just allocate 3 VBOs and render them sequentially. It was quite slow, but could be depend on the crap 9400 GT that I am using?

    Btw this could depend on java and 32-bit system. I am going to check on a 64b windows in the next future.

    Quote Originally Posted by Dark Photon
    You may want to check out Casting Shadows in Real-time for this and other soft shadow algorithms to determine if there's another more efficient solution that you'd be happier with (unless you're just trying to generate an approximate ground truth image). This content may have juiced up and released as a book under the name Real-time Shadows (I say may because I haven't actually had the latter in my hands yet, but the Table of Contents looks suspiciously similar).
    Thanks for the link, I am going to see it later

  2. #22
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882

    Re: Calculating where the shadow falls on a plane

    Quote Originally Posted by elect
    This program allows to see if 3d vehicles respect a certain standard or not.
    Ok.

    Quote Originally Posted by Dark Photon
    I have to confess. I don't understand:
    1. why you think you need CUDA for this,
    2. why you're convinced you need a renderbuffer over a texture.
    - Because I thought it could be much faster keeping all data on graphic card and merge all the shadow-set from there, without reading everytime the RBO/Texture to a buffer and sending it everytime back the to the cpu.
    Almost certainly! However, AFAICT you can do this all in OpenGL on the GPU, without any readback to the CPU, without any CUDA or OpenCL.

    - Because reading around, they say RBO are faster (like here )
    Perhaps a little in some circumstances, depending on vendor/format/driver version idiosyncrasies, but that's not a given.

    However, it's trivial to switch rendering from renderbuffer to texture or vice versa. You just use the texture if you need to read the data back into GL later. Use renderbuffer if you don't. And even then, if you're hard set on rendering to renderbuffer, you can use glCopyTexImage2D to copy from RB into texture after rendering. You have options.

    Quote Originally Posted by Dark Photon
    From what I gather, seems to me you could do this all in GL/GLSL, keep around just two images (or some small number), and use textures instead (so you could use GLSL to do the reduction).
    Ok, but would this require to use OpenGL 3+? Because I was told to start with OpenGL 2 since it is easier for beginners. Do you think GL/GLSL and OpenGL 3 is too much? I am also asking, because it looked to me like the most of tutorials on the web are for the 80% based on the OpenGL 2 and 1.
    Given what I think you're trying to do, it seems that using CUDA or OpenCL is probably overkill (definitely so if you've never coded in CUDA or OpenCL).

    You could use OpenGL with GLSL shaders for this (which is OpenGL 2.x not 3.x), and that would give you the most flexibility and probably ultimately be simplest (it's not that hard). Though I think you might even be able to do what you want without shaders if you're determined, since you can build shadow maps and render with them without shaders, and possibly use additive blending to merge your shadow counts together.

  3. #23
    Intern Newbie
    Join Date
    Dec 2011
    Posts
    46

    Re: Calculating where the shadow falls on a plane

    Quote Originally Posted by Dark Photon
    However, it's trivial to switch rendering from renderbuffer to texture or vice versa. You just use the texture if you need to read the data back into GL later. Use renderbuffer if you don't. And even then, if you're hard set on rendering to renderbuffer, you can use glCopyTexImage2D to copy from RB into texture after rendering. You have options.
    Yep, but the tricky part is to find the best implementation

    Quote Originally Posted by Dark Photon
    Given what I think you're trying to do, it seems that using CUDA or OpenCL is probably overkill (definitely so if you've never coded in CUDA or OpenCL).

    You could use OpenGL with GLSL shaders for this (which is OpenGL 2.x not 3.x), and that would give you the most flexibility and probably ultimately be simplest (it's not that hard). Though I think you might even be able to do what you want without shaders if you're determined, since you can build shadow maps and render with them without shaders, and possibly use additive blending to merge your shadow counts together.
    Here the comfortable part comes , I spent over one year on Cuda, developing a custom program that speed up Zero-Knowledge proof that require thousand of multiplications between large numbers. And based on what I looked around, OpenCL is pretty similar.. So this should not be a problem.
    Indeed, actually I do already use Cuda to calculate the coordinates of the projected triangles on the floor (that is the shadow) of my 3d model.
    What scares me, is OpenGL 3/4, shader and GLSL.. material on these topics lack over the net

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •