(totally outdated !) Blender to Indigo photorealistic grass

Tutorials/guides/tips on how to use Indigo and the Indigo exporters
User avatar
drBouvierLeduc
Posts: 412
Joined: Wed Oct 11, 2006 2:32 am
Location: france

(totally outdated !) Blender to Indigo photorealistic grass

Post by drBouvierLeduc » Tue Feb 06, 2007 1:59 pm

Image

edit : I'm afraid that tutorial is totally oudated now (as of june 2008), you'd rather use an instanced grass patch to get more accurate results.

(note : you can download this whole tutorial in pdf)

In this tutorial you will see how to produce a nice-looking grass using blender and indigo (though the technique is the same with any other modelling software).
See a good example of what you can produce here.
Nothing really fancy here, but as a blender user it's been a long time I was waiting for a blender-compatible renderer to work with alpha maps, as it's the best way to produce good-looking vegetation.
Also for the moment you'll have to hand-edit the XML file produced by the exporter at some point, as I didn't get it to export blended materials correctly (it's still in beta stage).

One last word : this tutorial is written to be understood by beginners, so I tend to explain every single step. It may seems long, but it's only four simple steps, really.

1. UV-map a plane with an image of grass
2. Duplicate it several times, add some randomness
3. Edit the XML to create the blend material
4. render !


So you need :
* indigo 0.7 t3
* blender exporter 0.7 t3 beta 1
* blender 2.40+

* if you're using a blender version prior to 2.43 RC, you need that script : randomize (unzip it and copy the python file in ../blender/.blender/scripts)



0. How it works


(note : I got the two images below from this tutorial)

An alpha-maped material is a mix of two images :
Image
You apply the alpha map to the original image : only the black part of the alpha-map appears in the final blended material.
You can find some royalty-free images at http://www.sxc.h, but I suggest you take your camera and make pictures of your own to get real fine looking images.
Here are the two images I used for this tutorial (right-click --> save link as)

Image
Image


1. Create the basic uv-mapped plane in blender


FOR ADVANCED USERS :
Create 2 planes with diffuse material like the picture above, put a UV texture on the grass-mesh, and go directly to the step 2 !
Image


A) First, create the ground under the grass leafes.
We want a 1m x 1m plane, with a green diffuse material.

* In top view, add a plane. Keep the original 1x1 size (as I understood, 1 unit in blender is equal to 1 meter in indigo, so this is fine for this tutorial).
* Create a new material, call it like you want (here : ground) Put spec=0, and hard=300.
* Choose a color close to the grass image you're going to use.

Image

B) Then create the basic grass mesh.
It will be a white diffuse material with a UV-mapped texture.

* In front view, add a plane.
* In edit mode, change its size so it fits the image you're going to use (this is very important, always change the size in EDIT mode, otherwise you will get an « orthogonal matrix » error message when you will render. In fact, the size in object mode must always be the same for X, Z and Y. I hope next exporters will get ride of this annoyance).
* Put the center to the bottom of the mesh, like in the screenshot below (in edit mode : select the two bottom vertices, press SHIFT + S choose cursor --> selection, back to object mode, editing tab(F9), choose center at cursor).
* Create a new material called « grass », with a white color, spec=0 and hard=50.
Image

* Go to texture tab (F6), add a new texture (its name doesn't matter), chose type=image and pick up the image you want.
Image

* Back to materials, change the texture position from local to UV
Image

C) Now we just have to UV-map the plane, and our basic material will be ready.

* You must have at least two windows : one in 3d-view (front view), the other in UV/image editor mode. In that last one, choose image --> open and pick up the grass image.
* Switch to UV select mode, in front view, press U, select Project from view (Bounds).

Once the plane is UV-mapped. You can see the result by pressing ALT + Z
Image


2. Duplicate the base mesh and add some randomness


A) Duplicate the mesh all over the ground.

You could be tented to use the array modifier, but I advice you not to do so.
Instead duplicate it using ALT + D, this will activate instancing in indigo, and speed up render times. Put the ground-mesh in another layer, and in top view duplicate the grass-mesh the way below.
Image

B) Add some randomness.

For that we'll use a very usefull script wich can randomize the size, location and rotation of the objects you selected.
(Make sure it is properly installed, see at the beginning of this tutorial)

* Select all the grass-meshes, press object --> scripts --> randomize Size Loc Rot
Image

* First, we'll change each mesh location a little : select X and Y axis, use loc: 0.300 (after pressing ok, you'll notice that the Z position has changed, even if you didn't select « Z axis » in the script... well it doesn't matter, we'll fix that afterward)
Image

* Then run the script again, and use rot: 0.400 on the Z axis
Image

* And to finish, we'll change each mesh size : (don't forget to press « link axis », each axis must have the same dimension).
Image

Play with this script a while, this can really change the aspect of your grass. And of course you can change the three values at the same time.

Now if you take a look in front view, you'll notice the meshes are not on the ground anymore.
Let's fix this.
Go in front view.
Put your cursor at the ground level (select the ground-plane, SHIFT + S and cursor -- > selection, choose cursor as the pivot point, and press move object center only next to it
Image

Now press S for scale, and 0 (zero on the keyboard). That's it, the grass is back in place.

Add a sunlamp to your scene, a camera, and make a render to see what it looks like so far. Don't forget to press separate materials
Image

And you should get something like this :
Image


3. Hand-edit the XML file to get a blended material

As for the moment there isn't any official indigo 0.7 version nor 0.7 official exporter, you cannot get a blended material directly from blender. This will change in the near future, but for the moment, you'll haveto hand edit the materials XML file
It should be located in the same folder as your .blend file. Its name is something like xxx-materials.xml
You can edit it with the notepad, or any text editor, provided it's a very small file. (I recommand XML-marker to edit bigger files, it's free and fast).

You'll have to make changes like in the pictures below, wich I hope speaks by itself :
Image

If you're familiar with HTML and XML files, you should not have any problem.
If you've never edited any XML file before, this is a good occasion to see how indigo « reads » material. It's quite simple.

1. Find your grass material.
Change its name to whatever suits you, keep it simple (here, « grass » has became « grassnoalpha »)

Code: Select all

<material>
   <name>grassnoalpha</name>
   <diffuse>
      <colour>1.000 1.000 1.000</colour>
      <albedo_texture>
         <uv_set>uv</uv_set>
         <path>herbe0.jpg</path>
         <exponent>2.300000</exponent>
      </albedo_texture>
   </diffuse>
</material>
2. Add a new « null » material
It's a totally transparent material, wich will be used by every blended material (you can use one null material for several different blended materials)

Code: Select all

<material>
   <name>null</name>
   <null_material>
</material>
3. Add a blended grass material
This is the final material, that will blend our older grass material « grassnoalpha » with the transparent material « null », according to the alpha-map (defined between the <blend-map> tag).
So you must give it the old name of the material you renamed in step 1 (grass).

Code: Select all

<material>
   <name>grass</name>
   <blend>
      <a_name>grassnoalpha</a_name>
      <b_name>null</b_name>
      <blend_factor>uv</blend_factor>
      <blend_map>
      <uv_set>uv</uv_set>
      <path>herbe0a.jpg</path>
      <exponent>1.000000</exponent>
      </blend_map>
   </blend>
</material>

4. Render !


That's it ! Save your file and render.
Image

edit : another example after some tweaking.
Image

5. Further words


You can download a zip file containing the .blend file + xml + textures.

Hopefully with the release of the final indigo 0.7, we will have an official exporter for blender, that will manage blended material correctly, and the whole process will be faster and easier.
I'll update that tutorial at the moment.

Now make some grass, and post your tests here !
These are just the basis, there are several way to enhance your grass. Try playing with the randomize script, use different textures, etc...
The example provided in this tutorial is just ok for a quick test.

I hope that helped, and if you have any suggestions to improve it, just tell it on the forum and I'll update it.
Last edited by drBouvierLeduc on Sat Jun 21, 2008 6:16 am, edited 12 times in total.

WLAD
Posts: 101
Joined: Mon Jun 26, 2006 5:59 am
Contact:

Post by WLAD » Tue Feb 06, 2007 11:55 pm

:D ye like maxwell tutorial :D ,

but you have done a god adoptation to blender and indigo, god work.

User avatar
manitwo
Posts: 1029
Joined: Wed Jul 05, 2006 4:50 am
Location: Tirol - Austria

Post by manitwo » Wed Feb 07, 2007 12:05 am

Cool, i was inspired by the "realistic-design"-tutorial too. If someone is interested i could write it for c4d.
See a good example of what you can produce here.
radiance used a real instanced gras mesh. :wink:

User avatar
drBouvierLeduc
Posts: 412
Joined: Wed Oct 11, 2006 2:32 am
Location: france

Post by drBouvierLeduc » Wed Feb 07, 2007 12:56 am

radiance used a real instanced gras mesh. :wink:
Tell me more !
You mean it's a grass leaf modelled and duplicated ?
I was wondering how to obtain the same grass as Radiance did in that picture.
ye like maxwell tutorial
Exactly, I found that tutorial so usefull I wanted to adapt it to blender and indigo.
I will try to make a wink version of this tutorial when I have time.

User avatar
manitwo
Posts: 1029
Joined: Wed Jul 05, 2006 4:50 am
Location: Tirol - Austria

Post by manitwo » Wed Feb 07, 2007 1:07 am

afaik radiance got a 50x50cm grass-patch from ctzn and instanced it.
Ctzn created the grass with maya-paintfx i think (look here for an example)
Look here for the WIP-Thread.

(I don't know but maybe ctzn would be so kind as to make this patch available to everyone if we ask :wink: )

User avatar
cooler_inc
2nd Place Winner
Posts: 158
Joined: Mon Aug 14, 2006 10:21 pm
Location: Ukraine, Donetsk
Contact:

Post by cooler_inc » Wed Feb 07, 2007 2:33 am

Nice tutorial, respect.

IanC
Posts: 147
Joined: Thu Aug 24, 2006 4:46 am

Post by IanC » Wed Feb 07, 2007 2:36 am

Nice tut, though there is no need for the copy+pasting! Use the array modifier instead, you just use 2 and you can have as many as you want in a couple of minutes.

User avatar
drBouvierLeduc
Posts: 412
Joined: Wed Oct 11, 2006 2:32 am
Location: france

Post by drBouvierLeduc » Wed Feb 07, 2007 3:17 am

IanC wrote:Nice tut, though there is no need for the copy+pasting! Use the array modifier instead, you just use 2 and you can have as many as you want in a couple of minutes.
Correct me if I'm wrong, but I think that the array modifier doesn't use instancing when exported with that version of the exporter (0.7 t3 beta1)

User avatar
kepler
Posts: 122
Joined: Wed Jan 17, 2007 3:18 am
Location: Italy

Post by kepler » Wed Feb 07, 2007 4:40 am

Great tutorial! I have not read it well (I have no time now) but it seems very useful, thanks! :D

User avatar
afecelis
Posts: 748
Joined: Tue Aug 01, 2006 4:14 am
Location: Colombia
Contact:

Post by afecelis » Wed Feb 07, 2007 4:58 am

amazing work drBouvierLeduc! Thanks for taking the time to create and share it. :D

However, th erandomize loc/size/rot script is not a blender default. Googling around I ran into this one:
http://www.koders.com/python/fidE66DF9E ... F7DE6.aspx

Is it the same as yours?

regards,
Alvaro
AMD Ryzen 7 1800 @3.6ghz, 32GB ddr4 3200 mhz Ram, 2X Nvidia Gtx 1070 8GB, Win10/Elementary OS 5.0 Juno (ubuntu 18.04), Blender/Sketchup/Modo/Cinema4d

User avatar
drBouvierLeduc
Posts: 412
Joined: Wed Oct 11, 2006 2:32 am
Location: france

Post by drBouvierLeduc » Wed Feb 07, 2007 5:17 am

afecelis wrote:amazing work drBouvierLeduc! Thanks for taking the time to create and share it. :D
However, th erandomize loc/size/rot script is not a blender default. Googling around I ran into this one:
http://www.koders.com/python/fidE66DF9E ... F7DE6.aspx
Is it the same as yours?
regards,
Alvaro
Yes you're right, my mistake !
Thanks for pointing this, I've edited the post.

User avatar
afecelis
Posts: 748
Joined: Tue Aug 01, 2006 4:14 am
Location: Colombia
Contact:

Post by afecelis » Wed Feb 07, 2007 5:35 am

hehe, nice! Just checked and it comes included in 2.43 RC1/2 or CVS builds from http://www.graphicall.org :wink:
The script you posted will give errors with official 2.42 so better use this one instead:
http://www.danielpatton.com/afecelis/bl ... domize.zip

cheers!
AMD Ryzen 7 1800 @3.6ghz, 32GB ddr4 3200 mhz Ram, 2X Nvidia Gtx 1070 8GB, Win10/Elementary OS 5.0 Juno (ubuntu 18.04), Blender/Sketchup/Modo/Cinema4d

User avatar
bq1
Posts: 20
Joined: Wed Sep 13, 2006 8:59 am
Location: Leeds, UK
Contact:

Post by bq1 » Wed Feb 07, 2007 5:44 am

Fantastic! Thanks for that. :)
afecelis wrote:However, th erandomize loc/size/rot script is not a blender default
I was thinking that too as I read through the PDF ;). I had to hack a dirty little randomize script myself for my avatar/logo/thingy...

<----

Will certainly check the script you used.

Thanks again for the tut.

User avatar
drBouvierLeduc
Posts: 412
Joined: Wed Oct 11, 2006 2:32 am
Location: france

Post by drBouvierLeduc » Wed Feb 07, 2007 5:59 am

afecelis wrote: The script you posted will give errors with official 2.42 so better use this one instead:
http://www.danielpatton.com/afecelis/bl ... domize.zip
cheers!
Thanks ! edited

IanC
Posts: 147
Joined: Thu Aug 24, 2006 4:46 am

Post by IanC » Wed Feb 07, 2007 12:59 pm

drBouvierLeduc wrote: Correct me if I'm wrong, but I think that the array modifier doesn't use instancing when exported with that version of the exporter (0.7 t3 beta1)
Ahhhh, didn't think of that. That final pic looks excellent btw!

Post Reply
76 posts

Who is online

Users browsing this forum: No registered users and 1 guest