# Lighting a billboard quad

This topic is 2616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 ?

##### 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 on other sites
Hi,
you can use the normal vector of your terrain.

##### 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 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 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.

##### 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"]

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.

##### 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 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

##### 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.

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.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633734
• Total Posts
3013587
×