2012
03.30

Finally fond some time to publish a new article.I recently have been working on a commercial project which involves some areas of computational geometry.In fact ,I can say that this is one of most complex areas of CS but is also one of most fascinating.The most important thing when you first get to it is not to panic.Many of the algorithms are extremely math intensive and make it hard to progress through the actual work.But the good news are that we live in the work of WWW and pretty every possible algorithm has already been implemented in some language.Therefore , in many scenarios  one can  port some chunks from code based found in the net. I take this approach occasionally but my favorite way is -books. I read a lot of tech books primarily on 3D graphics programming.Most of them not only supply the source code but also deep explanations of the techniques and algorithms on which the end apps are based.

So one day I  decided to implement a  surface subdivision in Flash 3D .Typing the term in Google gives a great multitude of results .Most of those present the Catmull-Clark subdivision algorithm.And there are tons of  C and C++ open source practical implementation of it in the net.But beware ,there is a catch. Catmull-Clark operates on  quadrilateral polygons,that is polygons consisting of 4 edges .3D libraries like OpenGL or Direct3D can handle this type of geometry.In OpenGL you can define GL_QUAD or GL_POLYGON drawing mode and the library would render quadrilateral meshed (though much slower than using GL_TRIANGLES . Alas , in Stage3D we can draw only triangles for the good reasons -performance.While it is technically possible  subdividing using Catmull-Clark for Stage3D that may add a lot of overhead as in such a case we would need to join each 2 triangles into quads before the operation and then  split each resulting quad  back to 2 triangles before handing the subdivided model back to the rendering .

One of my recent readings has been “Advanced 3D game programming with DirectX 10″ . I must say that is one of the best 3D graphics books I have ever read.Not only it introduces the reader in very convenient way with the Direct3D programming but the book is stuffed with cool 3d techniques of all kinds  including elaborated examples .The author has a chapter on subdivision and he presents an algorithm called “Butterfly” because of the way the subdivided polygons look like.The implementation is really straightforward and if you don’t want to strain your brains to much you can just port the ready program from .cpp source supplied with the book.One important detail here must be mentioned.If the indices of your model are defined in a simple progressive way ( like:  first triangle  - 0 ,1 ,2   second triangle- 3 , 4 , 5 third triangle - 6 , 7 , 8 ) the algorithm fails.That is because it has no way to calculate all the adjacent edges for each vertex  which are essential to split the polygons. The format of the indices must be defined so that each index ,that defines a vertex that shares its position with another vertex  like one, inherits its value from the index of that vertex. Obj data format is a good example for such indices.

Here you can see my experiment program with “Butterfly ” in action .You can see some UV bugs on the first subdivision.That is something I still have to take care about .But generally it works really nice.The current implementation is powered by Flare3D engine.

 

2012
02.29

Short update.

Just a quick update.During the last two months I had no time at all to write here.So just a short update.I started collaborating with Flare3D some time ago and now I am in the middle of work on some really cool project for these guys.Stay tuned for more updates.

2012
01.07

Hi All.A while ago I wrote a flash app that could be used to write and test shader programs in real time using Flare2D shading language(FLSL).For those who don’t know what FLSL is take a look at my previous articles.Essentially ,the main advantage of it is the ability to write shaders in OpenGL’s GLSL-like user friendly syntax without need messing up with AGAL registers and opcodes directly.
The app was very simple but then I decided to upgrade it a little and put out for the masses.So what you can do.You can write your shaders,compile them in real time,save them to file locally or save them to a database I designated especially for it which then us used as the shaders code bank.Yes the concept of the app is pretty the same as of mr Doob’s GLSL SANDBOX .

 

If you think that UI is ugly you are right.Unfortunately I am not a designer :)  Some explanation on how to use.In the middle you have got the editor window which you can hide by clicking “Close editor” button in the footer.You type your shader code in this window.Right side bar has more controls.The top most drop list enables you to select one of 3 primitives to render in the viewport.These are Sphere,Cube,Plane.Under it you have a button called “Upload Texture”.By default the program passes into shader program a simple perline noise generated bitmapdata which you access via “tex1Map” uniform.You may choose your own texture by uploading one.Then we have “Select shader” drop list.This is the list of users shaders which comes straight from the DB.The more people will submit they experiments the bigger shader collection we will have.To save your work to DB don’t forget to enter description in the “Description” field.Further ,there are two buttons:”Compile Shader” which as you probably guessed compiles the current code in the editor to  a shader program.The green “Save to File” button allows you to save the shader at your computer in .flsl file which you can then load directly or embed in the Flare3D engine.

Another important details  is how you actually write the code.So first ,you have a button at he footer called “FLSL reference”. Clicking it will open FLSL reference doc.There you can find all the built in shader functions,default uniforms and attributes accessible from inside any shader.Also when you startup the app you have a basic shader code inserted by default into the editor.It can serve a good quick start.Also take a look at my previous articles which include some explanation on how to write FLSL.Once I have more free time I will publish detailed tutorial on this subject.

At last ,I want to get bug reports,feedbacks from you .This app is really Alpha so expect some bugs.Also ,more features will be added gradually.It all depends how much free time I have Â

The FLSL Editor (Alpha)    

View Michael Iv's profile on LinkedIn