Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: fast shadows on smooth terrain

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    May 2013

    fast shadows on smooth terrain

    i have tryed a fast shadow on smooth terrain program in freebasic that works with transparent objects like trees too, and also opengl1.x and above.
    heres how it works :
    i take a glortho view of the scene from the direction of the light, centered on x,y,z player perso position
    glMatrixMode GL_PROJECTION
    Var k=900
    do2=45 'angle of light
    glmatrixmode gl_modelview
    Var dbx=bmpx
    glLoadIdentity ()
    If kcos<0 Then glrotatef(180,0,0,1)
    glulookat(x,y-kcos*10,z+ksin*10, x,y,z, 0,0,1)
    glcolor3f(1,1,1) drawterrain with texture offset & zheight=z(player perso)
    glcolor3f(0,0.3,0) draw persos,trees, with zheight=z(player perso)
    glReadPixels(0,0, dbx,dbx, GL_rgba, GL_UNSIGNED_BYTE, bmpbits) 'store view to bmpimage buffer
    glbindtexture(gl_texture_2d,grasstexture) ' grasstexture=texture used to draw near terrain
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_linear)
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_linear)'nomipmap (faster)
    glTexSubImage2D(GL_TEXTURE_2D, 0, 0,0,bmpx,bmpy, GL_rgba, GL_UNSIGNED_BYTE, bmpbits)
    ' store bmpimage buffer in terrain texture

    'then i draw normal scene
    glMatrixMode GL_PROJECTION
    ' anglevue xmax/ymax mxmin,mxmax
    gluPerspective 48, xmax/ymax, 3.3, 100000
    glmatrixmode gl_modelview
    ... here draw normal scene with terrain texture,persos,trees, near terrain texture=texture with shadows

    works with smooth terrain

    you can find an example with source on freebasic forum

    Last edited by nguyenc; 05-23-2013 at 06:31 AM.

Posting Permissions

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