PDA

View Full Version : Fake Plant



Rodrix
08-20-2006, 12:10 AM
Hi everyone!
I am trying to render a fake plant that consists of bunches of square leafs mapped with an alpha texture of a real fern. Therefore, even though the plants leafs are squared polygons, the leafs have real leaf shape as alpha channel is used. The final render consists of about just 18 polys so it's very cheap.

I am trying to recreate this:
Beautiful shadowed fern plant (http://www.the3dstudio.com/product_details.aspx?id_product=10214)

The model is free, so you can download it too. ;)
Yes! It's awesome... However the problem is that once loaded into OpenGL, it looks terribly fake without shadows.

3D studio Max creates a shadow based on the texture, not just based on polygons.

I there a way I can recreate that in OpenGL using real time graphics?

I am developing a game engine, so I don't mind how difficult the solutions are (Although I prefer them easy! :) ).

I have still to decide what shading method to implement in my game engine, so I would like to know what the options are. My first concerns is performance.

Right now I am using alpha textures contained in rectangles below objects to represent their shadow. I use a different texture for each object. This works great except for the fact that I must always drawn the sun ontop of my skybox (so that shadows keep correct direction), and that things get sometimes screwed up because of the blending ( I may have to use multitexturing I guess).

Thanks everyone in advance! :)
Cheers,
Rod

08-20-2006, 03:22 AM
you can project the geometry onto the ground plane and construct a mesh for shadow modulation or you could use realtime shadowing techniques to generate the shadows in realtime. there are many popular techniques available online if you search. there are also many books that cover the more popular ones like the shaderx books and gpu gems to name a few.

hth

08-20-2006, 03:42 AM
sorry, i meant texture not mesh. you can project the geometry into a texture for projective modulation which is usually just a darkening of the ground plane.

hth

Rodrix
08-20-2006, 11:50 AM
Originally posted by <zenith>:
you can project the geometry into a texture for projective modulation which is usually just a darkening of the ground plane.

hth ...But the geometry projection doesn't take into account the alpha values of the textures of the objects, right? Therefore I will get a the shadow of a plant with square leafs instead of the actual leafs described by the texture, right?
(So it won't produce the results shown in the link with such a low polygon count?) :confused:

Thanks!

ZbuffeR
08-20-2006, 03:32 PM
For billboarded textures it is simpler to go the shadowmap route. Using alphatest during shadow depthamp will retain your fine leaves.
Volume shadowing (ie. with stencil) won't work unless a lot of work (creating a high poly version).

I don't know if it is still the case, but with old 3dsmax versions, you could see that with raytraced shadows, it ignored texture alpha. It only worked with shadow mapping.

Rodrix
08-20-2006, 05:58 PM
Thanks! I read about Shadow Mapping on wikipedia. It sounds like a good idea :) .

Do you any good Shadow Mapping tutorial to recommend me? I read that it can be implemented either through GL_ARB_shadow extension (but that it required multiple passes) or through shaders. Which one do you recommend?

Thanks!

plasmonster
08-20-2006, 06:09 PM
Check out Nvidia's SDK samples, for example (very tasty) :)

http://download.developer.nvidia.com/developer/SDK/Individual_Samples/samples.html

plasmonster
08-20-2006, 06:21 PM
Oh, and I rather think the projection of alpha tested/blended textures to create a shadow mask of sorts would work quite nicely (FWIW).

Rodrix
08-21-2006, 01:05 AM
... eye dropping examples!... :eek:
Thanks for the link!

I found two really good tutorials by now. Do you recommend NVidea's "Hardware approach" (no shaders as I understood), or using shaders?

Do shaders solutions always have best performance?

Oh.. and ever anyone heard about a technique called "Forward shadow mapping- new approach to real-time shadow generation"? Is this a better aproach?

Thanks so much everyone!!! :)

plasmonster
08-21-2006, 02:17 AM
I recommend using the hardware wisely ;)

Shaders are a good bet these days, and they're here to stay. If you've got the hardware to use them, then I suggest you do so.

If you are targeting earlier hardware that has no support for them, then of course you have little choice but to use the fixed function stuff. But even so, there are still quite a few possibilities without shaders, as demonstrated by the myriad demos at Nvidia and elsewhere.

Hope this helps.

Rodrix
08-21-2006, 10:38 AM
Originally posted by spectranaut:
I recommend using the hardware wisely ;)
...Just to make sure. You mean you recommend I use shaders right?

(NVidea refers to 'Hardware' in their page as using extensions)

Thanks so much everyone! :)

plasmonster
08-21-2006, 04:15 PM
Rodrix, that is correct. I recommend using shaders, hardware permitting.

Sorry if that wasn't clear before.

Rodrix
08-21-2006, 10:49 PM
Thanks everyone!
Really thanks! :)