Leave a comment

More trees and texture tricks

I spent a while making some improvements to my tree editor. Mostly just workflow cleanup, but I also added a few new features. One involved more control over which leaf textures are used for particular leaves, and the other involves removing triangles where the texture is completely transparent. You can see that in the following palm tree: the rectangular leaf grids have their corners chopped off where there are no opaque pixels.

 

TreeExample

 

I used these improvements as I was creating a new definition for a palm tree. Here’s a scene with 4 of the generated models:

 

Scene1

 

Scene2

 

I’m still not super- satisfied with the lighting on these, but I’m not sure what is missing.

One thing I had been neglecting for a while were specular maps for vegetation. I didn’t think the improvement in visual quality was sufficient enough to incur the cost of an extra texture sample.

Could I squeeze it into one of the color channels? I recall someone told me they had done something similar with their terrain. They discarded the blue channel for actual color, and used it and and the alpha channel to store a normal map. Blue was calculated based on the red and green channels. Since most ground textures are green or brown, very little information is lost.

I figured the same was true for vegetation, so I added support for that to the shader and model processing pipeline. I can now replace the blue channel of the diffuse texture with a monochrome specular map. Can you tell the difference?

 

PalmWithAndWithOutSpecInDiffuse

 

The tree on the (highlight to read ->) right has no information in its blue channel. We calculate the blue channel based on the red and green channels and a shader constant that is determined at compile time when we analyze the texture.

 

Colors

 

The original texture is on the left. The specular map is in the middle. The texture on the right is actually what gets used. The blue channel has been replaced with the specular component.

To calculate the actual diffuse color in the shader, we just do:

float4 diffuse = tex2D(DiffuseSampler, texCoords);
...
diffuse.b = dot(diffuse.rgb, BlueFromColor);

BlueFromColor is a float3, because the same shader is used for when there is no specular map stashed in the diffuse – in that case, BlueFromColor is (0, 0, 1). When we do have a specular map, the third component will be zero, and the first two will be non-zero.

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Space Quest Historian

Adventure game blogs, Let's Plays, live streams, and more

Harebrained Schemes

Developer's blog for IceFall Games

kosmonaut's blog

3d GFX and more

Halogenica

Turn up the rez!

bitsquid: development blog

Developer's blog for IceFall Games

Game Development by Sean

Developer's blog for IceFall Games

Lost Garden

Developer's blog for IceFall Games

Memories

Developer's blog for IceFall Games

Casey's Blog

Developer's blog for IceFall Games

Blog

Developer's blog for IceFall Games

Rendering Evolution

Developer's blog for IceFall Games

Simon schreibt.

Developer's blog for IceFall Games

Dev & Techno-phage

Do Computers Dream of Electric Developper?

- Woolfe -

Developer's blog for IceFall Games

Ferrara Fabio

Game & Application Developer, 3D Animator, Composer.

Clone of Duty: Stonehenge

First Person Shooter coming soon to the XBOX 360

Low Tide Productions

Games and other artsy stuff...

BadCorporateLogo

Just another WordPress.com site

Sipty's Writing

Take a look inside the mind of a game developer.

Jonas Kyratzes

Writer, game designer, filmmaker.

%d bloggers like this: