Archive for January, 2010

Techdemo: Terrain physics and grass

Monday, January 25th, 2010

The terrain has heightfield shapes attached to it so it collides with other objects, or the objects collide with it… Anyway, the terrain is around 20×20 km visible, but can be extended to even 250×250 km invisible/streamed from disk, because you simply add more terrain patches on the fly.

So we have the physics, a simple skybox which will evolve into a scattering solution, cubemap computed on CPU and used on a sphere as skysphere, Mie Rayleigh scattering.

The terrain texturing is now done with 4 diffuse textures, one detail normap map, but I will change it to use texture atlas for diffuse/normal/specular, this way I can have like 10 diffuse textures in one texture (stage), and same for normal and specular, and the splatting will be done in shader, we’ll have to test the performance of this approach, but it is quite appealing.

Next, after the terrain physics, I want to see some nice grass on the terrain, so the grass will be instanced on the terrain using a distribution map: Red will be used to paint grass, Green will be used to paint trees, Blue can be used to paint rocks, Alpha to paint detail objects like broken branches or soda cans.. Each channel can have its procedural parameters, like spacing, rotation,scaling,slope min/max. This system can be extended to use more than one map to generate stuff on the terrain, and you can just do something like: terrain->addDistributionChannel( someMap, CHANNEL_RED, someObjectInstancingInfo );

The grass in particular, will be culled around the camera, inside a radius, and it will fade away using alpha testing (not blending ), the grass will bend in the wind using shader driven motion, and I’ll think how I can add arbitrary forces like ship engines blowing down to the grass or helicopter’s blades. The grass blades will always face the camera, they will not be only vertically locked, actually that can be some flag for a specific channel, some sort of VERTICAL_BILLBOARDING flag.

Pictures/videos soon.

Started “Eternal 2″ – Nytro TechDemo Game

Saturday, January 16th, 2010

Developing an engine, and a pretty generic engine its pretty hard and can lead you to a point where you dont know why you are developing that feature, will it be really used ? maybe not.. so I have decided to write a game in parallel with the engine development, Eternal 2, “sequel” of the first mini game wrote with Nytro, for some competition, it was a 1-week project, check the video here:

The game will show off flying vehicles, terrain vehicles, drones, landscape / vegetation, sky, and other small things. The development progress will be shown on this blog, on the Eternal2 game gategory. Wish me luck :) . More info on story, gameplay, soon.

Fixed pipeline mode goodbye, console commands & variables

Thursday, January 14th, 2010

I had the rendering of text and UI elements, and also debug / schematic rendering based on the SetShader(NULL), which fell back on the fixed function pipeline of the driver/card, but this thing is gone in DX10 and beyond, so I said bye bye to FF, and added a new ‘basic’ shader that only can render unlit simple stuff, colored and textured/untextured primitives, now the engine is really full shader based.
The engine has a console with commands that can be registered in C++ and script code, and also it has a global variables system, which can be created dynamically or from the engine.setup.xml or from C++/script code, the variables are Variant objects holding any kind of data from numbers to strings (is there any more ? :) )

nytro::engine::setGlobalVariable( "yeah_someGlobalVar", 2.0f );
nytro::engine::setGlobalVariable( "someGlobalVar2", "HAHA!" );
nytro::engine::setGlobalVariable( "someGlobalVar3", 123 );
 
Variant val = nytro::engine::getGlobalVariable( "yeah_someGlobalVar", 2.0f /*default*/ );
or
float32 val = nytro::engine::getGlobalVariable( "yeah_someGlobalVar", 2.0f /*default*/ );