Labels

April 6, 2012

BGE Candy status update 01

It has been a busy week with real life stuff, so I am not progressing very fast.

Last 2 days I have been working on environment reflection mapping coordinates. Blender currently have only view-space reflection coords reflect(viewvec,viewnormal);  and of course that is not nearly enough for a proper IBL (Image Based Lighting) setup.

So first I implemented world space reflection coordinates so the environment texture is world oriented.
Then I have implemented 2 most widely used mapping algorithms - "Angular" or "Sphere" mapping and "Equirectangular" or "Spherical Panorama" mapping but sometimes also called "Blinn/Newell Latitude-Longitude" mapping.
The third and most widely used one - "Cube mapping" should be already possible as a built-in function in OpenGL, but I have to figure out how to make it work in BGE.

Same mapping techniques can be applied not only on "Reflection" coordinates, but also on "Object" and "Normal" coordinates, which means that besides doing reflection and specular reflection, the environment mapping can also be used for texturing the object or doing image-based diffuse lighting.

these are the 3 environment map textures:

"sphere" or "angular" map


"equirectangular" or "spherical panorama" or "Blinn/Newell latitude-longitude" map


"cube" map


All 3 of them does the same job, but with different results. I found a nice article about all three of env-map approaches explained in detail HERE

I'm going to vacation for 2 weeks, so no BGE Candies till then..

March 22, 2012

BGE Candy branch

From now on I am a part of Blender developers team. Together with Matthew Dietel aka mokazon we started a new Blender development branch called "BGE Candy" with main goal to fix broken and add missing and new (mostly visual) features to Blender Game Engine.

I am quite excited about this, I even made our own logo and splash screen (with "sweet", "eye", "candy" and "Blender" in mind)



so here is the list of stuff currently done and yet to be done.

done:
• SSS (subsurface scattering) material
• rectangular area lights
• logic connector highlighting in UI

in progress:
• parallax mapping
• volumetric point & spot lights
• real-time composite nodes

planned:
• volumetric shadowing for volumetric lights
• environment cube-mapping
• scrolling texture coordinates in Blender material editor
• timer node in material node editor
• world normals in material node editor
• extra uniform inputs for 2D GLSL filters
• extra 2D GLSL filters
• Sky and Atmosphere
• fog volumes

BGE Candy branch thread in BlenderArtists HERE

March 20, 2012

stereo 3D for games and Inficolor triOviz

Dalai Felinto proposed a little challenge to Mike Pan and me - to add support for "Inficolor triOviz 3D" glasses for Blender Game Engine. I am quite crazy for challenges I am not sure I can handle so I started investigating the techniques behind stereo 3D.

Oh, and in return Dalai sent me a pair of glasses. Another pair I had an honor to send to Blender Foundation. It seems it has found a use there already, haha.



http://mango.blender.org/production/kickoff-workshop-day-2/

While Blender has various stereo options already, they are all based on rendering two separate images - one for each eye, from from 2 cameras - one moved a little to the right, other to the left. Then special glasses (either anaglyph, passive or active) separates the image for the correct eye. Sounds simple and reasonable, but it does not work quite well. The explanation is found HERE

implementation
Simply translating camera position will make both eye view direction parallel to each other and for closer objects will result large portion of them to be visible only for single eye and this will cause considerable eye strain.
So we need to add thing called eye convergence - both eyes are aiming at the object you are looking at, this means - for a distant object the eyes are almost parallel, but for a close object eyes must toe inward. So for our stereo 3D implementation we need to add a focal point to focus on. Now we have set both cameras to be translated by half eye-seperation-distance and oriented to look at focal object.
But we are not done yet - now both camera orientations are different and convergence is not parallel to screen plane causing vertical parallax and this adds confusion and discomfort for whole 3D experience. So we need to leave only horizontal parallax. Changes in camera projection matrix are needed to achieve non symmetric (offaxis) camera frustum.
HERE is a great article by Paul Bourke with more detailed explanation and implementation details.

too slow?
Now how about performance. While this might not be an issue for higher-end PCs, using this method for demanding console games are unimaginable. This means rendering same scene twice and cutting already shivery framerate to half is a really expensive sacrifice over an extra feature.

solution
Do it as a post-process shader. We can re-project already rendered scene for both eyes using a simple parallax shifting using magical z-buffer.
There are some shortcomings of the technique though - missing information behind foreground objects or view edges, shaders that depend on view position like reflections and specularity will look wrong and no alpha blending due lack of z-information.
These issues can be somewhat fixed - the changes between original and projected image are quite subtle, so missing information (obscured by other objects or shifted view frustum) can be filled or stretched. And view dependent shaders and alpha blended objects can be rendered separately in a FBO with 2 camera approach and composited in the final image.

GLSL implementation
Well, basically it is my depth of field shader with 2 texture samples - 1 for each eye multiplied with magenta and green, thats all.
I could not get my hands on Crytek's SSRS technique, but mine works quite well.
Shader has wide variety of tweakable user controls including autofocus and automatic parallax calculation proportional to the distance of focal plane, for the most comfortable viewing. Btw. it goes hand in hand with depth of field shader.

GLSL shader is HERE

and blend file HERE
controls:
mouse+WASD - movement
1 - enables stereo
2 - enables depth of field shader

So anyway, what is so special about this Inficolor 3D?
You don't need 3D display to view 3D content, so it is relatively cheap and it works! Sure, it can't quite compete in image quality active shutter glasses offer, but still the depth is great and loss of color is minimal. A little washed out bright parts, but otherwise I am impressed of the image anaglyph 3D can offer. Also the eye strain is minimal after longer use.

If you have magenta/green glasses, here are my results (click on them for larger size and better 3D depth):









or cross-eyed version:

January 4, 2012

free low-poly airplane model

I have yet another unfinished game in my portfolio (sigh)
The BGE Air Race project is dead, but from the positive side I have some nice stuff to share with you.
So I give you this nice low-poly aerobatics aircraft to play with. The model is based on Extra 300L and I used Zivko Edge 540 cockpit as the reference for the interior.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
so basically you can do anything with it.











7267 triangles
1024x1024 diffuse map

blend + textures HERE
texture pack and template for you own skins HERE

January 2, 2012

//status update 02

past few months have been quite stressful, due new responsibilities. Hopefully I will resume working on my personal projects soon. Unfortunately the BGE AirRace project is dead, but I don't feel too bad about it. It has gave me new 3D models, ideas and shaders to share with. 2012 comes also with few new ideas which I have been working on past few days. Particularly interesting is a precedural volumetric planetary rendering engine. Right now it can render a planet in any size with only 12 triangles. I will write a separate topic about it.

December 20, 2011

free classic Tron lightcycle model

I have a Tron lightcycle fan game in progress.. well actually the project has stalled for exactly a year. I started wiping the dust off the project and try to finally finish a game. It means rewriting most of the code since it was made in Blender 2.49 and cleaning up it a bit. The only finished thing in the game is the lightcycle itself which I modeled from various references and blueprints from original Tron movie (1982).

some pictures of the project work in progress:





movie


cycle:




blend HERE
obj coming soon...

free low-poly shotgun model

This is an old low-poly shotgun model (from 2006) I made for testing purposes. It has been serving me well and I though I should share it with anyone.
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
so basically you can do anything with it.

1314 triangles
1024x1024 diffuse texture







blend HERE
obj mesh file + texture HERE

December 19, 2011

GLSL depth of field with bokeh v2.4

here is a new update on the depth of field shader.
changes:
• again totally redone the depth of field calculation with 2 possible options:

- Physically accurate DoF simulation calculated from "focalDepth" ,"focalLength", "f-stop" and "CoC" parameters.
- Manual - artist controlled DoF simulation calculated only from "focalDepth" and individual controls for near and far blur planes.

• added "circe of confusion" (CoC) parameter in mm to accurately simulate DoF with different camera sensor or film sizes.
• optical lens vignetting factor based on f-stop value and user defined properties.
• cleaned up the code
• some optimization

Shader is HERE
Blend is HERE

controls:
Mouse+WASD - look/movement
LMB - drag the focal point object
1 - enables DoF rendering
spacebar - toggles debug view
Up/Down arrowkeys - zoom in/out (changes focal length)
Left/Right arrowkeys - changes f-stop value

December 13, 2011

SSAO shader update v1.2

changes since 1.0:
• v1.2 - added fog calculation to mask AO. Some minor fixes.
• v1.1 - replaced rings sampling with new spiral sampling method. Taken from HERE

fragment shader HERE
blend HERE

December 9, 2011

GLSL depth of field with bokeh v2.3

This is a major update for my depth of field w. bokeh shader.
I have added a python lens control file which gets focus distance from an object, adds control of "f-stop" variable, which controls "aperture" value for the shader.

list all of the new features:

• new and physically more accurate DoF, using real lens equations
• two extra input variables - focal length (in mm), aperture iris diameter (in mm)
• added a debug visualization of focus point and focal range (red line = focal point, green area = focal range)

separate python file:
• sets focus distance from an object
• added slow adaptive focusing for natural feel
• option to control aperture diameter with f-stop values (range: f/1, f/1.4, f/2, f/2.8, f/4, f/5.6, f/8, ..... f/256)
• focal length control (default range from 6mm to 600mm)

Shader is HERE
lens control file HERE (made for Blender)
Blend is HERE



debug focal plane and depth range visualization:



v2.2 was done yesterday and I just did not had the time to post it here.

December 8, 2011

BGE impossibe box

This is a remake of Portal 2: Impossible Box seen here - http://www.youtube.com/watch?v=JAvbdU5NIyw

I made it to test out my remote portal system using multiple viewports and a GLSL stenciling.



blend file HERE

November 28, 2011

basic deferred shading system in GLSL

Today I made a basic deferred renderer as an exercise in a single shader using only depth buffer and inverse modelview matrix as input.
Normals and position are calculated from depth buffer. Unfortunately normals are flat shaded using this method and the shader itself is quite slow, but maybe someone finds the parts of this shader useful.



blend:
HERE
fragment shader (code is quite messy) :
HERE

November 22, 2011

GLSL depth of field with bokeh v2.1

This is an update from the previous post on DoF bokeh shader.
The main addition is an option of pentagonal shape bokeh. The technique is hackish, but it works. Still I am looking for a more simpler way to make procedural n-gonal shapes of sampling.

The shader is made on 2006 iMac with Mobility Radeon card so it should work on any hardware supporting OpenGL

Screenshots are captured with high sample count, but the point is to show the features and capabilities of the shader.

some of the main features explained with images:

threshold & gain:
brings out highlights by "threshold" value and enhances them with "gain"
as you can see this is the main part that makes the distinct look of the bokeh blur. Without bringing out highlights, the blur looks like just a regular circular blur.








fringe:
adds chromatic aberration for the blur (small overlay image shows r,g,b color offset of the sample)



bias:
shifts the weights of the samples on the bokeh edges





pentagon:
pentagon shape of the bokeh (still needs some work)
edit: i have removed the "scale" factor, it is now automatic.




GLSL frag shader: HERE

October 26, 2011

GLSL depth of field with bokeh v2

This is my second attempt to create a depth of field shader with bokeh. the first one is here:
http://artmartinsh.blogspot.com/2010/02/glsl-lens-blur-filter-with-bokeh.html
And I am really glad that it got popular quite fast.

This one is much more flexible and I have added few new features.

• variable sample count to increase quality/performance
• option to blur depth buffer to reduce hard edges
• option to dither the samples with noise or pattern
• bokeh chromatic aberration/fringing
• bokeh bias to bring out bokeh edges
• image thresholding to bring out highlights when image is out of focus

yet to do

• add multi-shape bokeh (does anyone knows how to make procedural pentagon or hexagon?)
• bokeh vignetting at screen edges
• some minor fixes

screenshots:






fragment shader HERE

October 25, 2011

nicer SSAO

yet another screen-space ambient occlusion shader.
original technique is HERE by Arkano22.
I tuned it up a bit adding my circular texture sampling and pattern sample filtering.
Right now it is the best depth-only based SSAO I have come across.



another screenshot with noise dithering and "garea = 0.4;" instead of "garea = 0.6;" to lighten scene a bit.


scene with and without ssao:


glsl frag shader HERE

and blend file HERE