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
glLoadIdentity
Var k=900
do2=45 'angle of light
ksin=kSin(do2degtorad):kcos=kCos(do2degtorad)
glortho(-k,k,-ksin,ksin,10,100000)
glmatrixmode gl_modelview
Var dbx=bmpx
glviewport(0,0,dbx,dbx)
tshadow=1
glLoadIdentity ()
If kcos<0 Then glrotatef(180,0,0,1)
glulookat(x,y-kcos10,z+ksin10, x,y,z, 0,0,1)
glcolor3f(1,1,1)
…here drawterrain with texture offset & zheight=z(player perso)
glcolor3f(0,0.3,0)
…here 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_FILTER,GL_linear)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,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
glLoadIdentity
’ anglevue xmax/ymax mxmin,mxmax
gluPerspective 48, xmax/ymax, 3.3, 100000
glmatrixmode gl_modelview
glviewport(0,0,xmax,ymax)
glcolor3f(1,1,1)
tshadow=0
… 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