Saturday, November 20, 2010

Animation and new model format.

I'm currently implementing a new format for 3D models.

This format will contains :

  • basics info : vertices, normals, texture coordinates and triangle indexes.
  • Animation using keyframes or bones.
  • Materials description
  • Several models.

At the moment, I have written a MaxScript to generate models from 3dsMax. Only basics informations and keyframe animation are supported.

Here's a preview :







Wednesday, September 1, 2010

3D Live Wallpaper

I have implemented Materials and lights. Here a SC2 Space Marines as Live Wallpaper :)

Monday, June 7, 2010

Scene editor is functional !

The editor is functional. There are still some small improvements to do but here a sample :


And the result in application :

Wednesday, March 31, 2010

Model Editor finished.

Now, models can be aggregated using the GroupModelEditor. This will allow to add and manipulate complex models into the scene.

Here the editor :


This editor allow to aggregate severals md2 models into one entitie.

Each "sub-model" have a field called type. This type can be associated to a custom object class derived from GLModelObject.

After that, each sub-model can be handled one by one.

Here an example :




NOTE : It's more efficient to move a static object with code than using Model animation. Static objects are loaded into VBO. If you rotate a VBO object, there is few datas sent into the bus. Whereas if animations are used, each vertices are sent at each render(only if modified), into the bus. On PC it's less important as buses (AGP or PCI-E) are very fast. But on mobile device, buses are slower.

In the near futur, I will make scriptable the above code, maybe with Lua. It will allows non-programmers to create a scene, and make it "alive!"

Thursday, March 4, 2010

All effects

After added ground reflection :



All contacts are loaded from Android phonebook. The thumbnails comes from phonebook too.

Thursday, February 18, 2010

How to make bloom effect without shaders

The "bloom light" effect will give this kind of result :


What we would like, it's to make it run on a device that does not support any shaders. The following method has been done using OpenGL ES 1.1 and a framebuffer object.

First you need to create a framebuffer object using glBindFramebufferOES() and co. (glBindFramebufferEXT for OpenGL). In my case, the framebuffer have the same size of the screen. (I have tried with smaller Framebuffer with no really gain of performances)
When you create this framebuffer, you must use the following parameter :

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);


Then, bind your framebuffer and set the viewport to 0,0,ScreenWidth>>1,ScreenHeight>>1 (Green square on picture).
Render all your objects that will be affected by bloom light and other objects in black color with no texture.
After that, reset the viewport to  0,0,ScreenWidth,ScreenHeight. Render a rectangle that will use this Framebuffer as texture. (Yes It works). This rectangle should have this size : ScreenWidth>>2,ScreenHeight>>2 and can be rendered at the top left of the framebuffer. Repeat the operation with rectangle size of ScreenWidth>>3,ScreenHeight>>3 and ScreenWidth>>4,ScreenHeight>>4.
Your framebuffer content should be as following :


Ok, now unbind your framebuffer to render on the screen. Render your scene as usual on the screen buffer.
Once, it's done, bind your framebuffer as a texture and render 4 rectangles of the screen size. Make texture coordinates match with each 4 thumbnails from framebuffer.
Use additive color blend while you render your square: glBlendFunc(GL_SRC_ALPHA, GL_ONE_BLEND);

Here the rendering process :


Note : 
Texture of ScreenWidth>>1,ScreenHeight>>1 = 1:2
Texture of ScreenWidth>>2,ScreenHeight>>2 = 1:4
Texture of ScreenWidth>>3,ScreenHeight>>3 = 1:8
Texture of ScreenWidth>>4,ScreenHeight>>4 = 1:16

First, render rectangle of 1:2 using alpha value of  10% over your final scene.
Repeat the operation for rectangles :

  • 1:4 with alpha 15%
  • 1:8 with alpha 34%
  • 1:16 with alpha 60%

That's done your bloom light effect is completed.
NOTE : This implementation depend on OpenGL ES driver implementation. On Acer liquid, if bloom is enable I get about 15 fps and if it's disabled I get 55-60 fps. On PC, I do not detect such performances fall.
If I found a way to improve performances, I will update this post.

Sources : http://developer.amd.com/media/gpu_assets/GDC06-GLES_Tutorial_Day-Ginsburg-Advanced_Rendering.pdf

Tuesday, February 16, 2010

Poseidon ported on Android.

Here a short video of an application that use Poseidon on Android.
The phone used is an Acer liquid.

Tuesday, January 26, 2010

OpenGL / GLES Picking Method in Poseidon

I will explain, how in Poseidon Picking method works.

First of all, the method of picking in OpenGL using glRenderMode(GL_SELECT) and co. are not available under OpenGL ES.

After googling, I found this solution :
  • When the mouse is pressed I make a quick render of the scene. The texture are disabled, color shading is disabled and other effects are also disabled.(fog, lights, dither ...)
    When a GLObject is rendered a color is associated to this object. Ex: (0A,05,00). As there is the GLWrapper, the color used for rendering is bypass here.
  • Once the scene is rendered, I read the pixel at the clicked position. Then, we can compare the read color and GLObject color. We look if color are similar, not exactly match. When you are in 16 bits color rendering, colors may be scaled. That's why when we assign a color to GLObject, we step the next color value of 32(edit : explaination after).
  • After that, we render the scene normaly and swap buffers.
Here a rendering using this 
picking method.(Not visible on screen)


And now the visible rendering.

Here the computation to select GLObject color :
  • Select a Red, Green and Blue unique value. Each channel value should be in  [0..32[
  • Left Shift Bit each channel by 3
NOTE : With this methods, 32x32x32 = 32768 objects are selectable !

When a color is read, compare each channel of read color(Cr) and object color(Co).
For each channel C :
if (abs(Cr-Co) < D)
{
    // Channel match !
}

Where is equal to 5 8. For each color you can have an error of 10 (Co +5 or -5).
EDIT : 
To sum up :
- each R/G/B values are in [0..32[
- After the bit shift of 3, the result R/G/B are in [0..256[


When you are in 24-bits colors :
- When you read back the pixel, you will get the exact same value.


But in 16-bits colors mode (for instance 565) :
- When you read back the pixel, R is coded on 5 bits, G on 6 and B on 5 bits.
Let's look on Red channel. The possibles values are limited to 2⁵ = 32.
So the red value is fitted from 256 to 32 ranged.
The way that the value is scaled is obscur for me but if you draw with
red value of 200 and you read back the value, it will be 206.
But anyway, this difference cannot exceed 8 = 256 / 32.




Impressive !!!

http://mi.eng.cam.ac.uk/~qp202/

And the video :




"The system works by calculating the Delaunay tetrahedralisation of a point cloud obtained from on-line structure from motion estimation which is then carved using a recursive and probabilistic algorithm to rapidly obtain the surface mesh."

When I was at University, I have worked on a project using Delaunay triangulation, A-Shape and Voronoï diagram. Our project was to rebuild A-Shape from a point cloud. We used the library CGAL (http://www.cgal.org/) to compute each shape.

Friday, January 22, 2010

A test application

Here my first test applications using Poseidon and running on Linux and on Android emulator :


for his tutorial on MD2 :) and his quake II model.

Poseidon on Android is not a full JAVA application. It was built using android NDK.
There is JAVA code, but only to start a GL rendering view. All the rest is the same code (except Poseidon porting layer) as linux application.
As you can notice, bitmap loading is not yet implemented ^^. As far as I know, there is 3 ways to load a bitmap on Android platform :


Any advice on this point is welcomed :)

For the moment, I will cheat :
  • serialize the Image object to a file from PC version
  • copy the file onto Android 
  • deserialize the image from this file on Android platform.

Here the result on another model :

As you can see there is no difference 
between applications


What is Poseidon ? What is it for ?

The goal of this project is to ease development of 3D applications and UI on multiple devices.

NOTE : All codes of this library was written from scratch.

Here a summary of this library (it could change in future) :



This library is written in C++ but it does not used STL. On severals embeded platforms, STL is not availabled (ex : Android).

  • It's designed to use easily system resources such as Thread, Mutexes, Semaphore, Inter-process communications, files and resources access. It also provides tools to make Inter-process API.
  • You can serialize objects and store them in a file and restore them later or send them serialized to another process. You can access an object using its URL and open it like a file.
  • It also try to simplify 3D programming by wrapping OpenGL to OpenGL ES. The library provides a "GLServer" that allows to make simple 3D scene. There is also an implementation of OGL picking methods that works with OGLES.
  • It will also provides basic tools to make 2D UI elements.
The main goal is to make something simple for developpers.
For the moment, current Poseidon implementation depends on :


Background

I was an employee of a French company (Digital Airways). We developped tools to make UI for mobile and embedded devices such as mobile phone, set-top box... Most of applications were 2D UI. But I have worked on 3D UI. Here a sample of project I've worked on :



And here a video of this application on a HTC Touch Diamond:
But these projects were left out :(
Moreover, the UI tool we used, was not designed to make 3D applications.
I left the company due to crisis.
Now, I decided to start my own project.