Sign in to follow this  
solenoidz

Lighting a billboard quad

Recommended Posts

Hi people.

I have a field, covered with billboarded grass blades, but I can\t find a proper way to illuminate it.
Let's say the camera is in the center of the field and is heading west. There's a rising sun from the east, and as my grass blades are oriented torwards the camera (and the sun in this case), their normals point to the east, and they appear fully lit.
As I rotate the camera look to the north, the grass blades rotate aswell and their normals start to point south, and because the sun shines from east, they receive almost no light.
I can set the normals to always point upwards, but that looks very unnatural.

How can I calculate the normals of the grass billboards, so they appear independant of the camera rotation and in the same time be lit in a natural way ?

Thanks in advance.

Share this post


Link to post
Share on other sites
Some random thoughts -
- when facing W, are your billboards facing E (as per your post) or are they facing towards the camera? There's a big difference. If facing the camera, your lighting issue will be resolved. or,

- don't use billboards, and the normals will always be correct (and grass won't appear to 'move' when the camera pans). or,
- if you're looking NE, 'some' grass should still appear lit (because random orientation of real grass blades will provide some at an appropriate angle of incidence). You could simulate this by having each grass billboard actually being two billboards - one with ambient grass and the other with lit grass. or,
- someone will post something far more intelligent below ;)



Share this post


Link to post
Share on other sites
I think that upward normal is the best way to go, unless your grass is casting shadows - but then you have another problem, as the shadows of billboard rectangles do not look right.

Normally even if sun is rising-setting, grass is not fully lit, as it shadows itself - only the tips may be lit. The actual shading of grass is mostly determined by shading and not surface normals - grass leaves are semi-translucent after all.

You may try using some weighted median between up direction and rectangle normal as well, so it will not become completely dim, if sun is at horizon.

Share this post


Link to post
Share on other sites
I wouldnt use billboards as Latent said, then I wouldnt light them directionally because it will show them up as being flat. I would use a singer colour per quad of grass or a top and bottom colour. A lot of making grass look good is down to your artwork though!

Share this post


Link to post
Share on other sites
It is just bunch of billboards, as I said before, you just need to use your terrain normals for grass lighting.
You want the grass to look like the terrain underneath.
Also, read this article [url="http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter01.html"]click[/url]

Share this post


Link to post
Share on other sites
Thank you people.
I forgot to mention, I'm using a deferred renderer and grass is also rendered to the G-buffe for proper lighting later on in the lighting pass. I'm not using an alpha-blended grass blades, rendered after the deferred lighting pass, as I'm using lots of local lights over my terrain and I need my grass to be lit with those, as proper as possible.

Using straight upward normal vector for my grass vertices won't work, as the lighting would be just wrong. I'll try to give you an example :
I have beach and nearby I have a steep hill, or rock. The grass covers the flat ground of the beach, but also spreads over the nearby steep hill. I have a local light, that is positioned low, just above the beach surface. The grass blades that cover the beach have upward vector as well, as the grass blades that cover the steep hill. The position of the blades on the hill is higher than the light position and as their normal is pointing straight up, they would appear completely unlit.
In other words, In order to vertex to recieve some light at all, it position should be bellow the light position, so it's normal that is pointing straight up to have some positive dot product with light-vertex vector.
[color="#1C2837"][size="2"]
[b][url="http://www.gamedev.net/user/142646-hiyar/"]Hiyar[/url] [/b]
[/size][/color]
Thanks, I'm trying to sample my heightmap and calculate the normal, using some kind of sobel-filter algo. I'm familliar with this article, it has some interesting info, a bit old though, when it comes to shadowing the grass.
Unfortunately, using the terrain normal will not be perfect as well, as it would give wrong lighting if the grass blade position is above light positionm and the blade is standing on a flat horizontal part of the terrain.

[url="http://imageshack.us/photo/my-images/8/grasslightterrain.jpg/"][img]http://img8.imageshack.us/img8/5920/grasslightterrain.jpg[/img][/url]

Share this post


Link to post
Share on other sites
Your billboards are that big??
It is not perfect, but usually the billboards are small anyway and if you are using heightmap based terrain, it looks natural if you make the grass lighting look the same as the terrain lighting.

Share this post


Link to post
Share on other sites
Reminded me I had these floating around on my HDD Lighting used the normal of the terrain, 7 years ago! I didnt code it though, just working on the Art
[URL=http://img43.imageshack.us/i/landscapethumb.jpg/][IMG]http://img43.imageshack.us/img43/5166/landscapethumb.th.jpg[/IMG][/URL]
[URL=http://img838.imageshack.us/i/landscape1.jpg/][IMG]http://img838.imageshack.us/img838/383/landscape1.th.jpg[/IMG][/URL]
[URL=http://img594.imageshack.us/i/landscape2.jpg/][IMG]http://img594.imageshack.us/img594/4531/landscape2.th.jpg[/IMG][/URL]
[URL=http://img695.imageshack.us/i/landscape3.jpg/][IMG]http://img695.imageshack.us/img695/581/landscape3.th.jpg[/IMG][/URL]
[URL=http://img249.imageshack.us/i/landscape5.jpg/][IMG]http://img249.imageshack.us/img249/3794/landscape5.th.jpg[/IMG][/URL]
[URL=http://img266.imageshack.us/i/landscape6.jpg/][IMG]http://img266.imageshack.us/img266/8759/landscape6.th.jpg[/IMG][/URL]
[URL=http://img41.imageshack.us/i/landscape7.jpg/][IMG]http://img41.imageshack.us/img41/4719/landscape7.th.jpg[/IMG][/URL]
[URL=http://img818.imageshack.us/i/landscape8.jpg/][IMG]http://img818.imageshack.us/img818/5585/landscape8.th.jpg[/IMG][/URL]
[URL=http://img3.imageshack.us/i/landscape9.jpg/][IMG]http://img3.imageshack.us/img3/4185/landscape9.th.jpg[/IMG][/URL]
[URL=http://img163.imageshack.us/i/landscape9x1.jpg/][IMG]http://img163.imageshack.us/img163/6365/landscape9x1.th.jpg[/IMG][/URL]
[URL=http://img52.imageshack.us/i/landscape9x2.jpg/][IMG]http://img52.imageshack.us/img52/1628/landscape9x2.th.jpg[/IMG][/URL]
[URL=http://img856.imageshack.us/i/landscape9x3.jpg/][IMG]http://img856.imageshack.us/img856/9726/landscape9x3.th.jpg[/IMG][/URL]
[URL=http://img7.imageshack.us/i/landscape9x4.jpg/][IMG]http://img7.imageshack.us/img7/7489/landscape9x4.th.jpg[/IMG][/URL]

Share this post


Link to post
Share on other sites
[quote name='solenoidz' timestamp='1318681314' post='4872807']
Thank you people.
I forgot to mention, I'm using a deferred renderer and grass is also rendered to the G-buffe for proper lighting later on in the lighting pass. I'm not using an alpha-blended grass blades, rendered after the deferred lighting pass, as I'm using lots of [b]local lights[/b] over my terrain and I need my grass to be lit with those, as proper as possible.
[/quote]
Local lights and quad-based grass do not mix well at all. Especially, if your lights can move.
Whatever will be your normal direction - vertical, terrain-following or something else - you can place a local light close to grass so that it is perpendicular to normal and grass will thus be unlit.
If you have some free (half-) channel in GBuffer you can use ambience coefficient, treating part of diffuse lighting as ambient for grass.

Share this post


Link to post
Share on other sites
@mikiex:
Nice screens. Can you post some screens with local light, close to the ground, for ex. fire.


@Hiyar - "[color=#1C2837][size=2]Your billboards are that big??"[/size][/color]
[size="2"][color="#1c2837"]Well, pretty big i guess, as I'm trying to make lush environments with thick grass cover. Also, some of the big bushes and trees use impostor billboards at distance.[/color][/size]
[size="2"][color="#1c2837"]Should I use normal mapped billboards, to illuminate distant impostors, can I solve my issues with a normal mapped grass blades, as well ?[/color][/size]
[size="2"][color="#1c2837"]
[/color][/size]

Share this post


Link to post
Share on other sites
[quote name='solenoidz' timestamp='1318758986' post='4873085']
@mikiex:
Nice screens. Can you post some screens with local light, close to the ground, for ex. fire.

[/quote]

I dont have any shots with a realtime light affecting it, infact I cannot remember even if it did light the grass as well.
I only posted these because I was quite happy with the results and 80% of making it look good was the correcrt textures.

Last time I worked on some grass (this year) it was a forward renderer and the most imporant thing was keeping the cost of the shader down, it was as simple as prebaking a single lighting value for each quad (randomly rotated in the Y), not very high tech but all that the hardware(ps3/360)/engine/time really could offer. No dynamic lighting at all, if we had it would of been very cheap.

I guess with deferred you dont need to worry about the cost so much, as no overdraw on your lighting.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this