Jump to content

Better Foliage


JeffR

Recommended Posts

One area that Torque is somewhat lacking in is in good foliage.


Part of it is not having dedicated shader/shader features to handle lighting on it properly, but another aspect is that not many people have pushed it on the art side - a few people have done good work with it, but not too many.


Given that foliage is a pretty major part of many environments, having good examples, tutorials, and source art can be a major tool in making better foliage for the enviornments in games that need it.


We've seen Torque can do a pretty good job with foliage when it needs to, as seen in the old South Pacific demo:


http://ghc-games.com/public/Pacific.png


However, currently those assets are closed off to us, and even then they're falling behind on the modern standards in effect now.


I've spent a fair bit of time drudging through tutorials and examples, and while I can't say anything is definitively "The Best" way, there are definitely some examples that could be pointed to as good baselines.


So I figured I'd start a thread here for people to discuss methods, tutorials they found and provide examples if they choose.


To start, I had stumbled upon a tutorial done by a guy on the Cry Engine forums that was both rather thourough, and produced excellent results for grass.


The tutorial is here: http://www.cryengine.com/community/viewtopic.php?f315&t=100319


And the results are thus:

http://ghc-games.com/public/grass_med_finished.jpg


So I started testing his approach out, and while it's not 100% it's most of the way there. The results are pretty solid:

In the viewport, on the grass mesh:

http://ghc-games.com/public/viewport_wip_grass.png


And the texture I rendered for it, per the tutorial:

http://ghc-games.com/public/Grass_Texture.png


So that's my current foray into the grass side of foliage stuffs.

For it to be perfect, we'd still need shaders that handle the lighting on foliage better(managing backface lighting so they look like they're more volumous, etc), but the first step is to have good textures and models.


Feel free to give that tutorial method a try, and see if there are improvements that can be made! I'll be putting up the blender source file for my efforts on it in the near future.

Link to comment
Share on other sites

Oh whoops, I thought that first screen was Torque. Should have known it was suspiciously good :P.

 

The first screen is Torque, from the Pacific Demo. Unless you mean the screen that's nothing but grass. Then yes, that's CryEngine.

 

Now, post screenshots of your new grass in Torque :P


I'll do a little research and see what I can find for a grass shader.

 

I'll see about getting it in there tomorrow.


As for grass shader stuffs, 2 major elements I've seen from CryEngine's handling of it is 2 modifiers. One handles how much backfacing shadows lit polies, and the other handles how much backfacing shadows polies that are in the shade.


I spotted them because the dude that did the grass tut was complaining that they're broken in one of the latest versions of the engine, and provided image references.


http://www.cryengine.com/community/viewtopic.php?f=369&t=76715&p=1233484#p1233484


As you can see in his images, it manipulates how the grass is lit and goes a long way to making it feel like it has volume and avoids the weird flat-poly backshading effect.


I'd imagine the basis of the fields is pretty simple, just impact how much pixels on a backfacing poly accept shading when lit and in shadows.

Link to comment
Share on other sites

I had not, but in the long run, it seems somewhat poor form to require artists to do special proprietary workarounds to get their art to work in the engine.


It'd probably work as a stopgap solution, but updating the lighting stuffs to properly accommodate foliage is a better long-term plan.

Link to comment
Share on other sites

@Nils


Interesting. How did you set up the materials/models so they don't deal with backshading?

 

Very planar; a few planes stuck together with animated double-sided texture and one extra LOD with an auto-billboard. A bit of AO to simulate a bit of shadow, in T3D it doesn't come out very strong but without shadows (bugged) it runs smoother anyway. No costly shaders, no normal maps. If you need to render so many shapes it's best to strip it all clean. All the ground cover objects in the the pic share the same atlas map.

Edited by Nils
Link to comment
Share on other sites

So stripped from everything that decreases performance you can

really populate the shape in great numbers and still run perfectly in-game.


The 1920 x 1080 shot below is taken with all settings to max (AA 4x, FA 16x etc.) with a 3 year old graphics card and still it's >40fps

 

3d_Grass_Ingame_T3D2.thumb.jpg.ad7e71a2220a80cd3ccc5f36869bde8f.jpg

Link to comment
Share on other sites

I'm still not sure how you're not seeing shading on polies that face away from light sources like the sun though. That's the single biggest cause of ugly foliage in T3D.


Also, what's the tri count on your high-res grass mesh?


Pretty awesome shot there at though :)

Link to comment
Share on other sites

I'm still not sure how you're not seeing shading on polies that face away from light sources like the sun though. That's the single biggest cause of ugly foliage in T3D.

 

That's because the downwards facing mesh normals will appear too strong on ground cover objects in T3D. You can edit the normals in your 3d application to make them look brighter by pushing them upwards.

 

Also, what's the tri count on your high-res grass mesh?

 

The green grass mesh in the 1st shot has 27 vertices at LOD 0 and 4 at LOD 1 (auto billboard)

Link to comment
Share on other sites

Would a potential engine side solution be a material property that overwrites the normals that are writtten into the gbuffer for that material with upward facing ones? You could enable it on the grass material and the grass would be lit as though it had all upward facing normals.

 

For the lazy artist it would be handy solution :P :P :P


Editing normals in a 3d application is work that can be done in a matter of seconds. An artist could choose to fine tune the normals to fake a bit of shadow; of course depending on the amount of faces used in the mesh.

Link to comment
Share on other sites

Well, for example, blender doesn't have very good tools for manually editing normals.


As well as if you're trying to use art packs in the engine - needing to crack those open and manually fix them is kind of an annoying step that slows down prototyping and the like.


It's not a hard fix, but streamlining the art pipeline is generally a good thing where possible ;)

Link to comment
Share on other sites

Maybe if the normals were just weighed heavily in the Z+ direction using a configurable value in the material from 0 - 1. That way it wouldn't be so cut and dry as all upward facing normals, but instead let you scale the normals towards Z+ using a value from 0 - 1.


I'm trying to avoid having to place a new material info flag into the gbuffer to flag foliage and light it differently. If I could provide a workable solution from altering the normals before the lighting stage that would be ideal. Worse case scenario I'll just bite the bullet and make a custom lighting flag for foliage.

Link to comment
Share on other sites

Ha yes, @JeffR, probably you're right about that.


I found that changing the normals is really about giving those the right angle, not just abruptly all straight up. That would just kill the normals on the mesh and make it look completely flat. In T3D there's a threshold; beyond 90° (see pick) normals do look much better.

 

edit_normal.jpg.da4aa718329e5cb20fa4afda1252be21.jpg

You'd want to change them all at once to avoid having normals that don't look normal ;)

Perhaps giving the artist the possibility to put in an angle?

 

@Nils Looks nice! Any video?

8-)

@Steve_Yorkshire We're working utterly hard to create a teaser video.

More soon! :D :D :D

Link to comment
Share on other sites

@Chieling Rendering 3d shapes is obviously much more costly then billboards. It takes at least twice as much performance decrease; whole depending on the amount of vertices, LOD's and render distance. For that you gain groundcover that will not turn with the camera and can be seen from any angle; also from top.


Art-wise, you can't go on using billboards in 2015 without a clear purpose or some kind of style or statement (a 90's retro look for example). Billboards would do fine on low-end hardware like tablets and such though :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...