Monthly Archives: June 2012

Parallax and defomable terrain

I am working on some serious stuff, including a lot of parallax layers, and a deformable terrain. Screenies below.

Right now, I apply brute force fragment shaders, rendering a total of 8 textures in one pass. This sound efficient, but it really isn’t. While it runs 60fps on ipad2 and 3 ( retina ), and somewhat slower on ipad1, the problem is, that I render way to many transparent pixels. Even if parallax 2 only is 5% visible at the bottom, I render a nearly entire blank screen of parallax 2, because I am forced to render only one piece of geometry. While mix( ) is insanely fast, with 8 full screens of textures, things will eventually start to slow down.

And then it struck me.

The parallax should be split into 5 quads, each being a band of overlapping parallax layers. First quad will be pure skybox. Second quad will be skybox and far most parallax. Third quad will be etc etc etc etc. If you adjust you parallax textures to include fewest possible transparent pixels, this will render it all, with an absolute minimum of pixel operation.

You of course have to write 5 shaders, in stead of one shader, but that is a small price to pay.

All the images below, is rendered in a single quad.

Enjoy the landscapes.

The earth crust is made with inspiration from a demo I watched, and is fully deformable, meaning that if I dig a hole into the ground, the grass will disappear. Not by magic, but by the insane power of the shader.
I did some math, and calculated that I could save 35-80% of all texture look-ups ( currently the shader does 25.2M look-ups pr frame )
The final picture shows how I plan to implement it. The picture is a bit fuzzy, but so is my ideas on how to implement this also.