Tutorial on how to make amazing grass! (New little nature demo included!)

(cademtz) #1

The first part of this tutorial is a simple scene set up for people who are new to BGE, so skip it if you just want to make the grass.​

A link to a blend file will be provided at the bottom.

***Scene set up:
***Lets start making some grass. First thing’s first, make sure that you’re in GLSL mode.

***Since we’re making grass, I’ve already added a ground, but we also need a sun lamp, so add that to.


***Now, make sure that you have the “Show Shadow Box” option checked, and make sure that it’s covering your ground so you won’t get buggy shadows.

As you can see, some of the ground isn’t covered, so you can turn up your frustrum size or just reposition it.
***I don’t want to make this too long, so I’m going to leave you with a snapshot of my sun lamp settings if you want it.

Notice that I made the sun’s color slightly yellow, and a slightly blue shadow for realism.
***Hang in there, we’re almost done! Now let’s just quickly add a Hemisphere lamp, and make the color slightly blue for realism. Here’s a snapshot of the settings if you want it.

http://i.imgur.com/VpEEBgj.png

Were done! Now it’s time for the grass
***Making the grass:
***For the grass, add a plane, go into edit mode, and UV unwrap it.


***Now you can turn off edit mode.

Go to the material tab with your object selected, and make make a new material for the grass. Name it whatever you like, and make sure to turn the specularity off.

Make sure that you have the alpha blend set to “Alpha Clip”.

http://i.imgur.com/sDNHVgI.png

Now enable transparency (found near the bottom), and turn the “Alpha” slider to 0. This will make it invisible, but we’ll fix it later.

http://i.imgur.com/YgTqKm6.png
***Go to the textures tab and add a new image texture. Name it whatever you like, and set it to a grass texture with transparency. Here’s a link to the one I’m using: (http://www.reinerstilesets.de/3dtextures/billboardgrass0001.png)

Now scroll down to Influence, and check the “Alpha” slider. Make sure it’s at 1.

http://i.imgur.com/BAuELlA.png
***After this, you should be able to see your grass! But we’re not done yet. It’s time to do something really strange.

Add a new texture by clicking on a blank slot, make it an image texture, and set it to this: (http://i.imgur.com/CLYkCHm.png) That’s an inverted normal map if you’re wondering.

http://i.imgur.com/rrlbv6I.png
***To make Blender understand this is a normal map, you’ll need to open the Image Sampling tab and check “Normal Map”

http://i.imgur.com/Tpz27Qw.png

Scroll down to influence. This time we’re going to disable everything and check “Normal”

http://i.imgur.com/iMxWpKG.png

Basically, this normal map will cause the grass to show the opposite side of it’s face. Now we have 3 more steps left!
***Go back to the materials tab, and press the plus button. Instead of making a new one, select your grass material and press the button with a number next to it. This will duplicate your material. Name it whatever you like.

http://i.imgur.com/EqbEeNw.png

Now go into edit mode, select all the verts, faces, whatever, and duplicate them. Make sure the duplicate doesn’t move.

Now with your duplicate face selected, press the assign button for the duplicate material

http://i.imgur.com/EoPsbU4.png

***With your duplicate face still selected, press Spacebar, search for “Flip Normals”, and select it.
If you don’t see it, you may not be in edit mode.

http://i.imgur.com/bY9rIqk.png
***Last step! Go into textures, select your weird normal map, and disable it.

http://i.imgur.com/1gkCOSC.png

If your grass looks dark on both sides, flip it by 180 degrees.

***Finally done. Now your grass should be looking MUCH more realistic!

You can download the file in this picture at the bottom of it!

I’ll appreciate feedback about my tutorial! I hope it wasn’t a pain to read through if you already know a lot about BGE. Also, huge thanks to ThatTimst3r’s post-processing addon that was used in this blend file! Have fun

The blend file hasn’t been optimized for an actual game, so you may get very low framerate.

Attachments

Grass tutorial.blend (12.3 MB)

(Thatimster) #2

Is there a way to change how much translucency there is? It seems to only allow 100%.
Using emission of 0.15 with this method works quite nicely.

(cademtz) #3

Well, this method basically just gets the grass to show 1 side of its face on both sides. This means you’d have to find a way to make it actually translucent, which isn’t supported by BGE’s default mechanics.

Possible answer:
I’m not skilled in python, but I bet someone could make a shader or something to create actual translucency, which would be great, because if the grass I made is rotated the wrong way, both faces will be dark.

Here’s the best answer I can come up with for now:
You could try putting a texture on the opposite face of the grass that makes it slightly darker. Refer to the above paragraph if you’d rather have a more legitimate way of making translucent grass.

Also, why would you use emission on the grass? The contrast in shading goes really nice with it.

(Josip Kladaric) #4

There is a way to make it translucent, if you have skype I can show it to you.

(theoldguy) #5

Don’t look right to me. Grass seems to emit it’s own shades of green light when it’s in full sunlight. I don’t see the shadows shown in your picture above in real life. I noticed that today mowing the lawn, even tall grass (weeds) don’t seem to take on the shadows seen above. Maybe it’s just the way I see it. Shadeless looks right to me. Others may see it different. :slight_smile:

(mziskandar) #6

Thanks for sharing.
Got 4fps.
Went to layer 2 and joined it all. “a” (select all), then “ctrl-j” (joined it all)
…and getting 40fps.

(cademtz) #7

Why can’t you post it here or in a separate thread?

(- Click for resources) #8

what is wrong with Shadeless and a gradient texture, and to show the back just turn off backface culling?

(cademtz) #9

[QUOTE=cotax;3112643]/QUOTE]

(cademtz) #10

There’s a reason I have back face culling on. You need 2 different faces to get the translucent effect.

(- Click for resources) #11

Ok got it, the new screenshot says it all haha, nice job.

(wolfgannn) #12

ty … a videotutorial is a very good option too … nice stuff.

(anas) #13

fantastic work man

(theoldguy) #14

That looks way better than the first picture. Good job. :slight_smile:

(BluePrintRandom) #15

open this in upbge, make sure all your grass are instances (alt+D)

then in materials check geometry instancing for the grass material.

should get a waaaaay better frame rate.

(theoldguy) #16

Right, at 22,800 tris it runs poorly on weaker computers. 5 fps on my old PC. (It’s OK on my new one) And it’s a small scene. Imagine if it was a large open world. With all the other game logic, a game would be unplayable on some PC’s. It still looks good though.

@BPR - thanks for that. Been looking for the instancing feature. So alt-D does true instancing in UPBGE? Like Unity and UE4?

(BluePrintRandom) #17

yeah, you want to make sure the object has under 128 vertex for it to be really effient though

so best for grass and leaves etc.

(theoldguy) #18

Thnx, BPR. That’s huge. What about group instancing, array modifiers, same old same old? Or true instancing?

(cademtz) #19

Just keep in mind that the grass I made was in no way optimized. I’m bad at making good grass model, but maybe decreasing some and replacing patches with big bushes could increase performance a bit.

(BluePrintRandom) #20

group instances work, but I don’t think arrays do at the moment**

maybe we should test?