About Store Forum Documentation Contact



Post Reply 
Some questions about Gras objects
Author Message
Gian-Reto Offline
Member

Post: #1
Some questions about Gras objects
I have some question concerning Gras objects...

1) I noticed that the lighting on gras objects seems to be odd. Sometimes faces that are pointing away from a light source seem to be illuminated, and sometimes faces that should be illuminated are in shadow.... what can I do about this? Seems to be wrong (see attachement 1)

2) It seems that gras objects are not affected by ambient occlusion, even while the terrain and characters are.... is this expected from gras objects? Or am I doing something wrong? (see attachement 2)

3) Is there a possibility to set a gras object to billboard mode, so that its always facing the camera?


Thanks

Gian-Reto


Attached File(s) Image(s)
       
04-06-2011 08:16 AM
Find all posts by this user Quote this message in a reply
llynx Offline
Member

Post: #2
RE: Some questions about Gras objects
(04-06-2011 08:16 AM)Gian-Reto Wrote:  I have some question concerning Gras objects...

1) I noticed that the lighting on gras objects seems to be odd. Sometimes faces that are pointing away from a light source seem to be illuminated, and sometimes faces that should be illuminated are in shadow.... what can I do about this? Seems to be wrong (see attachement 1)

2) It seems that gras objects are not affected by ambient occlusion, even while the terrain and characters are.... is this expected from gras objects? Or am I doing something wrong? (see attachement 2)

3) Is there a possibility to set a gras object to billboard mode, so that its always facing the camera?


Thanks

Gian-Reto

As I've already gone down this path before I'll give you some insight,

1) When you use grass made up of planes you get this problem quite often. If you grass is made up of individual blades then you never run into this problem, but on the downside it is much much much slower.

2) Yes this is one of the optimizations done in order to increase the amount of grass you can render. (If you set the material type to Alpha Test you will get occlusion)

3) You can do this manually but you will always run into the lighting problem in 1). It looks especially bad when rotating the camera.



The best solution is the following: http://www.cg.tuwien.ac.at/research/publ..._2007_IAG/

An example of the implentation using the standard textures can be found here: http://forum.unity3d.com/threads/76748-V...ass-system
http://www.stobierski.pl/unity/meadow.html
http://www.stobierski.pl/unity/soccer.html

It should look much better when higher resolution grass billboards are used. When I get time I'll be implementing this but this seems like the best option from everything I've looked at.

Additionally with this implementation you never run into the "thousands of grass objects" speed issue as well AND it bends to terrain!
(This post was last modified: 04-07-2011 10:13 AM by llynx.)
04-06-2011 08:36 AM
Find all posts by this user Quote this message in a reply
Gian-Reto Offline
Member

Post: #3
RE: Some questions about Gras objects
1) Why do you run into that Problem? I still fail to understand the reason.... shouldn't the renderer be able tell the direction the quad is facing and assign the proper lighting? Is it because of intersections? Is it the Type of shader I'm using? Its Test Blend Light Grass / MUS_DEFAULT / MUT_PLANT....

2) Okay, I'll try it to see what gives me the best performance / visual tradeoff. I kinda dislike the look of the gras objects without AO or shadows, but I do see that the AO on the gras objects (or using a different shader) did have some noticable impact on the framerate, while not delivering 100% convincing results....

3) there really isn't any out-of-the-box shader in Esenthel for billboards?


This solution is promising, yet I'm unsure how that would work for an isometric view.... maybe by using more, more tightly packed "Grass Cells"? As from a 45 degree viewpoint, the effect of the proposed shader is less good....
04-06-2011 06:41 PM
Find all posts by this user Quote this message in a reply
llynx Offline
Member

Post: #4
RE: Some questions about Gras objects
(04-06-2011 06:41 PM)Gian-Reto Wrote:  This solution is promising, yet I'm unsure how that would work for an isometric view.... maybe by using more, more tightly packed "Grass Cells"? As from a 45 degree viewpoint, the effect of the proposed shader is less good....

If you take a look at the meadow.html example and soccer.html example he implemented grass bending to remove the gridded appearance when looking top down, so you can have a up to a 75degree+ down from horizontal view of the grass and not see the grid. I have to say it looks really really nice and the performance is ridiculously good.
(04-06-2011 06:41 PM)Gian-Reto Wrote:  1) Why do you run into that Problem? I still fail to understand the reason.... shouldn't the renderer be able tell the direction the quad is facing and assign the proper lighting? Is it because of intersections? Is it the Type of shader I'm using? Its Test Blend Light Grass / MUS_DEFAULT / MUT_PLANT....

Assigning proper lighting for relatively large planes that are view sensitive is very temperamental in all engines. The more you segment a plane into different angles, the less apparent any shading problems appear.

E.g. Take 1 billboard plane of grass and apply light directly from the side and you'll see no shading (a consequence of using planes). Now take that that billboard, split it into 100 little billboards representing blades/blade groups and randomize their rotation about their Y-axis. This removes most visible shading anomalies and additionally you can properly apply AO that is relatively more accurate (But doing this is clearly more costly performance-wise)

Oh and this might help you, If I remember correctly, the shading problem was slightly helped by adding normal/bump maps to billboard grass. But still this doesn't seem like the most efficient way to implement large amounts of grass in games and the shader way above seems like the best way to do it.

[Anyone who knows more, feel free to correct me where I'm wrong/inaccurate]
(This post was last modified: 04-06-2011 08:35 PM by llynx.)
04-06-2011 08:18 PM
Find all posts by this user Quote this message in a reply
Gian-Reto Offline
Member

Post: #5
RE: Some questions about Gras objects
Okay, I need to have a deeper look at this examples....

Is there a possibility to hack the shader so the lighting is "corrected" for large billboard planes? So that when they "should" be illuminated (for example, when the sun is directly above the plane, which of course is not illuminating any of the sides of the plane), the planes are illuminated no matter where the sun stands? Might help with the lighting problem.
04-07-2011 07:18 AM
Find all posts by this user Quote this message in a reply
llynx Offline
Member

Post: #6
RE: Some questions about Gras objects
(04-07-2011 07:18 AM)Gian-Reto Wrote:  the planes are illuminated no matter where the sun stands?

That can be done through RM_BLEND but doesn't look good.
04-07-2011 08:11 AM
Find all posts by this user Quote this message in a reply
Gian-Reto Offline
Member

Post: #7
RE: Some questions about Gras objects
RM_BLEND? Where do I need to set this? At the moment I want to try everything....

Tried the AO on the Gras, mixed results.... while, with extreme AO Settings, the Gras looked much better (because the AO pronounced the Grasblades), or it looked like it was shadowing the ground (higher range), I needed to turn off the softening, cause else the whole Gras objects looked somehow blurred. Which in turn made a lot of artefacts appear, that created a grainy look.
On the bright side, not that much performance lost.... maybe a 6th of the total framerate. Well, not that this is nothing to sneeze at wink

I tried the gras shadowing. I had to turn up the Shadowmap size to the max to make the flickering of the gras shadows less obvious. With some tweaking, I only lost around a 5th of the framerate by turning on the gras shadows.

Hm, I'm a little lost now.... I think I'll try creating bigger "Gras Objects" So I need less objects to create a good looking lawn (which should reduce draw calls, right?), and I'll leave out the AO, as it doesn't look that good on the gras.....
But without at least gras shadows, the gras looks odd from a isometric view.....

Could I make a grass object drop a blob shadow? So, is it possible to mix dynamic with static shadows? Would it cost me less Framerate to do that?
04-08-2011 12:53 PM
Find all posts by this user Quote this message in a reply
llynx Offline
Member

Post: #8
RE: Some questions about Gras objects
(04-08-2011 12:53 PM)Gian-Reto Wrote:  RM_BLEND? Where do I need to set this? At the moment I want to try everything....

Tried the AO on the Gras, mixed results.... while, with extreme AO Settings, the Gras looked much better (because the AO pronounced the Grasblades), or it looked like it was shadowing the ground (higher range), I needed to turn off the softening, cause else the whole Gras objects looked somehow blurred. Which in turn made a lot of artefacts appear, that created a grainy look.
On the bright side, not that much performance lost.... maybe a 6th of the total framerate. Well, not that this is nothing to sneeze at wink

I tried the gras shadowing. I had to turn up the Shadowmap size to the max to make the flickering of the gras shadows less obvious. With some tweaking, I only lost around a 5th of the framerate by turning on the gras shadows.

Hm, I'm a little lost now.... I think I'll try creating bigger "Gras Objects" So I need less objects to create a good looking lawn (which should reduce draw calls, right?), and I'll leave out the AO, as it doesn't look that good on the gras.....
But without at least gras shadows, the gras looks odd from a isometric view.....

Could I make a grass object drop a blob shadow? So, is it possible to mix dynamic with static shadows? Would it cost me less Framerate to do that?

RM_BLEND is just blend mode under materials.

I still would like to find out the technical reasoning behind why if you were to have say 100 grass objects vs 10000 grass objects that both represent the same polygons, why it is dramatically slower to draw the 10000 grass objects versus the 100. It make sense intuitively but a technical explanation would be nice from someone who knows more about this.

Yes you can make blob shadows, check out the fast shadow tutorial.
04-08-2011 01:11 PM
Find all posts by this user Quote this message in a reply
Gian-Reto Offline
Member

Post: #9
RE: Some questions about Gras objects
I'll have a look at this tutorial.

Other question: when I try to add a normal, bump and specularity map to my gras, they don't seem to be used.... is it cause I set access method to grass? Doesn't seem to be used else also though.....

Is there anything I need to change else?
(This post was last modified: 04-08-2011 01:44 PM by Gian-Reto.)
04-08-2011 01:14 PM
Find all posts by this user Quote this message in a reply
Post Reply