New tree code & leaves

July 21st, 2010

During my week in Geneve, i rewrote most of the treecode to use ultrafast billboards w/ a new light source-dependent leaf shader. Hard work, but worth it. Result: trees look more realistic:

Posted in Uncategorized | No Comments »

Normal Mapping & Holiday

July 13th, 2010

I just returned home from a 5-day holiday to Bergen, so I really needed a thorough coding session. The previous weeks have mostly been filled with administrative stuff such as beer, phd defenses, socializing and various other anomalies. I therefore decided that today was the day to finally implement a really needed feature: Normal Mapping.

I have added another intrinsic shading class to the CiRIOBase framework, class CBumpMapping inherits CShaderParent and contains everything needed for setting up tangential spaces and other stuff.

Below is a tree with a procedurally generated texture + normal map
Normal Shader & Normal Map generation

The main information used in the normal mapping shader is based on, well, a normal map of the procedurally generated heightmap. A new CTextureMachine command named “CreateNormalMap” does the trick, and such a map is depicted below:
The generated normal map

The normal map supports ambient, diffuse and specular lightning. These textures are just to “show off” the CTextureMachine and CBumpShader capabilities, realistic trees do not look shine like plastic =)
A procedurally generated normal tree trunk
Cacti with procedurallt generated trunks

However, I will post more screenshots when I have developed newer and better trunk textures.
A procedurally generated normal tree trunk

Posted in Uncategorized | No Comments »

First official CiRIO shader & extra stuff

July 1st, 2010

After the success of implementing impostors, I decided to do something else for a while. The recent couple of days I have therefore:
CiRIO Logo

  • Implemented a CiRIO Shader framework based on a CiRIO CShaderParent parent class
  • Implemented a blur and toon kernel-based edge-detection shader, enabling various combinations of adding blur effects / edge effects in the CiRIO framework
  • Implemented a particle class for morphing/viewing/manipulating large arrays of vertices
  • Performed several major / minor fixes, updates and improvements.

A quick example on how to use the shader for rendering “toon” scenes:

More toon shading
CToonAndTreeShader ScreenShader;
ScreenShader.Initialize("screen", TOON2, 0.2, CVector(1,1,1), 1024.0);

Here, “screen” is the shader ID, TOON2 is one of the available toon modes, 0.2 is the particular parameter for this toon mode, the vector is RGB color scaling and 1024 is the width of the blur/toon effect. In order to use the shader, include the following after your scene has been rendered:

ScreenShader.ScreenToTexture();
ScreenShader.Render();

And that’s it!
Toon tree2

An example of pure edge detection:
Edge detection

Various “artistic” combinations of blur and edge detection:
Tree1
Tree2
Blurred landscape
Toon tree
Tree3
Tree4

Particle class & toon shader:
Toon shader

Posted in Uncategorized | No Comments »

Damn those Impostors

June 28th, 2010

After 8 hours of agonizing pain, I finished implementing a code for including tree impostors. Instead of rendering high-poly trees at far-away distances, it is now possible to pre-render the tree to a texture and then rendering the whole tree using a single polygon. The net effect? CiRIOTree can now add about 5 times as many trees at the same framerate – with only a fraction of lower detaile levels.

The image below shows how small the visual difference is between a true tree and an impostor

cirio_03_05

In the following picture, 4 000 textureless unique cacti are generated. Most of the tree seen here are now impostors, drastically improving performance (runs at about 30fps on my apple macbook)

cirio_03_03

Below are some new screenshots with impostors active. All textures are generated with the CiRIO framework.

cirio_03_01 cirio_03_02 cirio_03_04 cirio_03_06

Posted in Uncategorized | 1 Comment »

Random leaf textures

June 26th, 2010

During the course of today’s work, I have done three important tasks:

  1. I have restructured the whole CiRIO framework, making way for the (upcoming) CiRIOGUI library
  2. I have implemented loads of smaller features, fixing bugs and improving overall structure
  3. I have completed the tools needed for generating leaf textures, as depicted below

The picture below shows a random generated leaf texture.

Procedurally generated leaf texture

The TextureMachine code for generating this texture is :

Initialize 3 128
GenerateDiamondMap 1
Bump 1 -1 0.3 -1 0.005 -1 -0.9
Circle 0 1 3000 4.0
Normalize 0 1
Normalize 1 1
Merge 0 1 1.0 1
RGBNormalize 0 2.0
 
ToBitMap 0 0.6 1.0 0.5 1.0
CreateTransparentTexture leaf 220
RenderLeaves 500 leaf tree1_leaf 20 10

An image of various procedural trees generated with procedural trunk and leaf textures is depicted below. Please note that these trees are different realizations of the same tree template type.
Various trees with procedurally generated textures

with a closeup shot of the leaf texture here

Procedurally generated leaves

Posted in Uncategorized | Comments Off

Polly is Dead, Long Live CiRIO

June 20th, 2010

Two and a half years ago, I started developing a hobby-based 3D engine called Polly. Polly was my sandbox, my little playground where I would gradually learn how to implement various 3D-engine features such as real-time physics, quad & octatrees, object oriented world repositories, structured OOP design, resource management, OpenGL shaders, simple AI and various algorithms and data structures.

Blue skies

Unfortunately, I might have aimed for Polly to be more than it was. A huge sandbox. It was therefore very hard to finish anything, as the whole project grew out of technical interests without any focus on implementing user interfaces, documentation nor having an overall goal. Every time I had motivation & some spare time, I would start implementing something new in this eventually large project, without knowing where i would end up. And so time flew.

Development came to a halt when I entered my final year of my thesis. Things froze, and I shifted my focus elsewhere.

In June 2010, I finished my PhD thesis. I finished half a year in advance, and will get paid by my university until december 2010. During these six months, I will have ample time to try to actually complete a project, this time more reasonable than Polly.

Cacti

Projects:

  • Extracting the basic parts of Polly, rewriting code and and providing a simple and elegant easy-to-use OpenGL library in C++. This library will contain all the “basic” functions for future libraries. This is the CiRIO base library.
  • Providing a simple and powerful library for procedurally generating fauna: trees, ferns, grass, fungi, in addition to procedurally generating the textures. This is the CiRIOTree framework.
A random forest

The earlier “Polly” framework is therefore now like a old shipwreck, where I am constantly removing parts and recycling them into new, stand-alone libraries. Instead of having one huge project to complete, I therefore believe it will be possible to actually getting things done, focusing on one library at the time.

Since I finished my PhD about a week ago, I have already implemented a preliminary CiRIO base framework together with a procedural tree generator. Some screenshots are presented here, where the only three properties that distinguish the trees from each others are a) position  b) tree type and c) the random seed.

Procedurally generated trees

In the next couple of months, I will try to build up a development blog for people who are interested in either using the CiRIO framework or interested in the algorithms that I have used. I will be focusing on both the production of procedurally generated objects, code design and CiRIO code tutorials.

Polly is dead, long live CiRIO

Posted in Uncategorized | No Comments »