Zanir » OpenGL

Archive for the ‘OpenGL’ Category

Program 31 – Motion blur with p-buffer


031_motion_blur_with_pbufferProgram uses pixel buffer, for rendering scene to texture. Motion blur is make with equation:
frame(t+1) = alpha*texture + (1-alpha)*frame(t)
Frame buffer doesn’t need clear. Frame buffer doesn’t contain z-buffer. Alpha is preset on 0.18. Texture has 1024 * 1024. Texture contain z-buffer.

Request: WGL_ARB_pbuffer, WGL_ARB_pixel_format and WGL_ARB_render_texture.

source code and executable – 640kB

Program 30 – Particle system



source code and executable – 100kB

Program 29 – Many point lights


029_Many_Point_LightsI use vertex program for drawing object lighting with 17 point lights.

Reques: GL_ARB_vertex_program

source code and executable – 240kB

Program 28 – Water


028_waterIt uses:
- law of reflection
- Snell’s Law
- Fresnel equation

Recommend: GL_ARB_multitexture, GL_ARB_texture_env_combine and GL_ARB_texture_cube_map.

source code and executable – 180kB without jpeglibm.lib

Program 27 – ASE Loader


027_ASE_loader_0There are:
- lighting with light-map which was created with radiosity in 3ds max
- better collision
- gravitation and jumps

source code and executable – 660kB without jpeglibm.lib
model to 3ds max – 95kB027_ASE_loader_1

Program 26 – Stencil Shadow


026_Stencil_ShadowI use algorithm, which is explained in
Practical and Robust Shadow Volumes (.pdf) (2153 KB).

Program request hardware accelerated 8 bits stencil buffer.

source code and program – 25kB

Program 25 – Environment mapped bump mapping (EMBM)


GL_ARB_multitexture, GL_ARB_texture_env_combine a GL_ATI_envmap_bumpmap.

source code and executable – 320kB without jpeglibm.lib

Program 24 – DOT3 bump mapping


024_DOT3_bump_mapping024_DOT3_bump_mapping_3dsDot Product 3 Bump Mapping is per-pixel lighitng. Use dot product per-pixel. Standard lighting in OpenGL is computed per-vertex. I use equation:

color = ambient + (N.L)xDifuzeColor + (N.H)^SpecExp x SpecularColor
N is normal vector, this is texture map, created from bump map with Sobel-Prewitt filter.
L is light vector. L = light_pos – vertex_pos
H = HalfVector = normalize[ ( eye_pos-vertex_pos ) + ( light_pos-vertex_pos) ]

Request: GL_ARB_multitexture, GL_ARB_texture_env_combine, GL_ARB_texture_env_dot3.

source code and executable – 430kB without jpeglibm.lib

Program 23 – Dynamical cube mapping


023_Cube_MappingRequest: GL_ARB_texture_cube_map

source code for library jpeglibm.lib – 207kB
source code and executable – 530kB

Program 22 – Terrain


022_terrain022_terrain_volum_fogTerrain is important part of more type games.
I use octree and volumetric fog.

source code (without jpeg.lib) and executable – 290kB