PDA

View Full Version : Plants



Rodrix
04-09-2007, 12:25 AM
Hi there! :)

I thinking on adding a feature to my engine and I wanted to know if you guys considered a better approach than mine:

I want to render my plants on shadows dimmer than the others on light. This idea surged from a conversation with Zeeoverlod ;) analyzing the FarCry Engine in this post (http://www.opengl.org/discussion_boards/ubb/ultimatebb.php?ubb=get_topic;f=2;t=021167#000004) :
FarCry's screenshot (http://img245.imageshack.us/my.php?image=fceditzc4.png) .
(The point is that both trees are the same and are lighted different according to the shadowmap projected on the groud, and that they are completely shaded or unshaded)

I just implemented a heightmap where my plants lay, and the terrain has:
1) 2048x2048 base texture that contains shadows (I am in the process of implenting shadowmaps, but I am going to be using them only for projecting the plant's shadows on the terrain, so I will not be using the shadowmap's values in the next approach)
2) Detail texture

I was considering this idea:
For each plant position, get a group of sample associated pixels (just below the plant) from the terrain base texture, and calculate an average lumen value with the R, G, and B components of the associated pixels.


If lumenValue is less than X then the plant is more in the shadow than in the light: set material properties of plant to low ambient and diffuse, else set to high ambient and diffuse (I always use no specular as the plants are very low poly). Equivalently another method could be: multiply plant's material property by average lumen value too.


1-Do you consider this a good idea? Any better approach? (assuming no GLSL support)

2- Taking this to the next level: using GLSL, I saw that most engines apply a "Bloom" shader to the plants. Also per pixel lighting?

Thanks so much in advance,
Rod

P.S: When I try per-pixel lighting in my FX5500 (even a simple phong shader with texture) or anything Shader-related my FPS instantly drops to 10-12fps (from 80-90fps). I know now that my card is not prepared for shaders, however I was wondering if I buy a GeForce 6 or 7 if my fps will boost significantly or not?

Zengar
04-09-2007, 04:02 AM
I can only answer P.S. because I want to have my breakfast and don't want to think much :) FX5500 is a VERY bad card in regards to per-fragment processing. You can get a new card like 7600GT for about 120 Euro and it will be at least 5 times faster. I recently bought a 7900GS and am very happy with it feature and performance-vise.

Rodrix
04-10-2007, 11:49 PM
Thanks for the info Zengar! I am anxious on replacing my card :)

Regarding 1, what do you guys think of the idea I mentioned?

I have been thinking and have developed this implementation:
Instead of testing a group of pixels from the 2048x2048 texture (testing pixels means that I need to store the Texture in the CPU apart from loading into GPU) I have though first pushing the texture to GPU and then scaling the texture down to 512x512 or so. Having scaled the texture, the pixels are averaged, so I don't need to sample the group of pixels. I just need to get the pixel more closer to the object's position (ObjectPositionX/WorldWidth * TextureWidth = PositionInTextureX). So this would assure I am using less memory.

Regardless guys... before implementing any of this I want to know if you guys think this is a good idea or not (and if there is a better one).

Thanks so much! :)
Cheers!
Rod