Author Topic: ObjectReader  (Read 8213 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1542
    • zapsolution
« on: January 15, 2016, 11:44:28 am »

This is the 64-bit version of ObjectReader, compiled with the latest Visual Studio Community 2015 edition, and Windows 10.

In its current state, this is the result of a close cooperation between:
Patrice Terrier and Michael Lobko-Lobanovsky,
In order to join the fun, send us a PM, and we will gladly share our code with you, if you want to contribute.

The application is provided with one single 3D model, you can download more from the links posted in "The 3D model collection". All material files have been tailored to use the unique features built-in ObjReader64, to achieve visual quality that comes close to real objects.

Make sure to use the latest OpenGL drivers, and to switch to the high performance nVIDIA graphic card mode, because the quality is so much better than with the default Intel graphic card.

You can select a 3D model from the menu "File", "Open..." option, or by using drag and drop of an *.obj file from the Explorer onto the ObjReader64 OpenGL section.

To install ObjReader64:

    1. Download the attached compressed 7Z file
    2. Unlock the compressed file to avoid any Windows UAC problem.
    3. Create a new folder, and decompress all files into it, preserving the directory tree structure.
    4. Once done, select ObjReader64.exe to run the program.
    5. The "Models" folder is the place to put all the models you download, keeping each of them into a distinct subfolder.

Note: The default model provided with the is located into the "Models\IronMan" subfolder.

For those still running a 32-bit version of Windows, there is a 32-bit version available on request.

01-14-2016 Version 1.00: forum opening.
03-20-2016 Version 1.01: bounding sphere detection (Efficient Frustum Culling)
05-03-2016 Version 1.02: to illuminate both sides of polygons in case of dark faces.
07-14-2017 Version 1.03: added simplified command line support (ProccessCommandline).
01-24-2018 Version 2.00: new features list
02-24-2018 Version 2.50: new features list
06-19-2018 Version 2.52: new features list
08-23-2018 Version 2.53: new features list
10-11-2018 Version 2.54: new features list
02-10-2019 Version 2.75: new features list

« Last Edit: February 11, 2019, 10:45:51 am by Patrice Terrier »
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1542
    • zapsolution
« Reply #1 on: January 27, 2016, 03:01:32 pm »
ObjReader, displays 3D models using the wavefront OBJ format exclusively.

Because ObjReader is a GDImage/WinLIFT application it uses a specific skinned interface.

They are available from the menu "File" or from the menu "View".
Note: "View" is also the contextual menu that pops up when you press the right mouse button on the OpenGL viewport.

Display the Windows file selector to choose a model from a specific folder.
ObjReader uses a default "Models\" subfolder, that is the prefered place to put all your models, like the "Models\IronMan\" that stores the Mark17.obj file and all its related materials. Each model with all related materials must be stored into an individual subfolder.

Rather than using the "Open" command, you can also use directly the Windows explorer to select a specific .obj file, and use drag and drop onto the ObjReader's OpenGL section to display the model.

Note: Because some 3D models could be very large, ObjReader displays a spinner animation, and you have to wait for full completion before you can do anything with it.

A dialog box shows you the version number, the copyright, and informations about the active 3D model.

Shut down the program, same as the close button on the top right corner.

Switch to fullscreen mode, with just the OpenGL viewport visible. To return to the window mode, either press the space bar or the escape key.
Note: The contextual popup menu is also avaible in fullscreen mode, and you can select the "Fullscreen" command again to return to the window mode.

Restore the initial state of the camera, same than when you first display the model.

Use fixed pipeline
This command allows you to switch between the two 3D mode supported by ObjReader.
The GLSL Programmable Pipeline (PPL), and the Fixed Function Pipeline (FFP).
Most of the time you will not see much difference between PPL and FFP, however in case of bump materials we always switch to the Programmable Pipeline, while we keep using the Fixed Function Pipeline for simple material files.

This one is set automatically at the time you load a new model, and it is checked when the model uses textures.
However this command allows you to switch between textured or untextured mode to inspect the basic model.

This is very handy to better figure the polygon details used by a specific model, and it uses wire raher than solid to render the surfaces.

Point cloud
Same than wireframe, except that point are used rather than wire. The point size vary slightly with the zooming factor, because we have to accomodate to always show you something.

Ambient reflection
In order to see this effect, you must switch first to untextured mode, then this command uses the wallpaper to create GLSL spherical/specular reflection. To better see the effect, try with different wallpapers, you can select them from the listbox shown on the right.

Mipmap textures
When turned on (default), this command enables GPU computation of intermediate textures to better render the model when zooming in or out.

Multiple light sources
Three different light sources are used simultaneously to enhance the global illumination of the model.
(see also, the #ambient meta command)

Alpha to coverage
When using low polygon models with alpha transparency, this command help to produce better rendering of the transparent part of a texture. This is also very useful when dense foliage, grass, or hair must be rendered. It uses the alpha channel of the texture as a coverage mask for anti-aliasing.

Cull back faces
When this command is enabled, it doesn't render the hidden polygons.

Swap Y,Z axes
To change the orientation of a misaligned model.

Swap polygon winding order
The default OpenGL orientation is to use GL_CCW, but some models are using GL_CW causing elimination of back facing polygons, in that case GL_CW must be specified to change the default OpenGL setting, especially when using the menu "Cull back faces" command.
(see also, the #GL_CW meta command)

Smooth zooming
This is mostly to be used with high polygon models, to produce smooth zooming transition while performing video screen capture.

Illuminate both sides
To illuminate both sides of polygons with models using inverted normals (black faces).

Save to image
Save the current OpenGL viewport into a .png file (works also in full screen mode).

Print image
Send the current OpenGL viewport to the default printer.

Material files
Each of the .mtl, material file, must be tailored to use the exclusive features provided by the software.

This is done by using meta commands prefixed by the hashtag symbol: #.

In version 1.00 (command menu "About" to check the version) they are:

To use a specific image stored into the resource\ subfolder, as wallpaper background (same than in the listbox).
Syntax: #wallpaper abstract02.png

The default OpenGL orientation is to use GL_CCW, but some models are using GL_CW causing elimination of back facing polygons, in that case GL_CW must be specified to change the default OpenGL setting, especially when using the menu "Cull back faces" command.
Syntax: #GL_CW

This is the same than using the menu command "Multiple light sources", in that case a total of 3 light sources are used from multiple angles to enhance the global illumination.
Syntax: #ambient

This is the same than using the rotary button to adjust the alpha threshold with transparent materials. It is a decimal value ranging from 0.0 to 0.99. The default value is 0.10, the higher the value the larger the threshold to full transparency.
Syntax: #threshold 0.10

Enable the GL_LIGHT_MODEL_TWO_SIDE parameter, to illuminate both sides of polygons. By default, only the front of polygons is illuminated.
Syntax: #bothsides

Note: the meta commands are not case sensitive.

Specific material features
In order to produce nice rendering, ObjReader is able to use reflection files, they are spherical .png textures stored in each model's subfolder.

These spherical textures are meant to be used in conjunction with the refl and illum reserved mtl keywords, like this:

illum 3
refl texture.png

This one could be used altogether with, or without, alpha transparency, and the d 0.75 (percentage parameter), to produce raytracing reflection using the texture file specified as the refl parameter.

illum 4
refl fake_texture_name.png

In that case, while the refl instruction is still needed, the texture parameter name is not meaningful, because illum 4 instructs ObjReader to use the active wallpaper background to produce spherical reflection.
Most of the time, the best looking result is achieved by using it altogether with the specular value Ns 512, and a Ks 0.75 0.75 0.75 parameter.

« Last Edit: May 03, 2016, 11:15:59 am by Patrice Terrier »
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1542
    • zapsolution
New features of version 2.00
« Reply #2 on: January 12, 2018, 01:28:22 pm »
New meta commands:

This is a global or per material  meta.

#straylight percentage.
This is a global meta.
To reduce the light intensity, the percentage value is any number in the range 0 to 100, 100 being the current value and the default.

Same than #ambient, but more explicit.

To specify the material emissive color.

New menu "Lighting"




Each light meta, can use one of those color constants :

Y rotation mode (demo mode)
This starts the 360 self rotation of the model along the Y axe.
Press either the "+" or "-" key to speedup or slowdown the rotation.
By default the rotation starts in CCW mode, press the "-" to run it in CW mode.

Using a specific wallpaper
Rather than using a generic wallpaper into the mtl file,
it is possible to use a texture laying into the model folder,  using the "@" prefix in front of the texture name, like this:
#wallpaper @texture.png

Adding global lighting colors into mtl file

You can use either three R G B color values in the range 0-255, or a predefined GDIPLUS constant (see the above color table).

#Light frontAll 1 2 3
#Light frontAmbient aliceblue
#Light frontDiffuse antiquewhite
#Light frontSpecular 255 255 240

#Light frontAll 255 255 0
#Light frontAmbient aliceblue
#Light frontDiffuse antiquewhite
#Light frontSpecular 0 0 0

#Light leftAll aquamarine
#Light leftAmbient aquamarine
#Light leftDiffuse azure
#Light leftSpecular aquamarine

#Light rightAll bisque
#Light rightAmbient aqua
#Light rightDiffuse darkcyan
#Light rightSpecular darkgreen

Arguments to the #billboard metastatement may come in any order. Meaning of each:
  • cylinder/sphere -- cylindrical or spherical billboard, respectively. sphere is the default and may be omitted.
  • nodepth -- billboard is drawn in glDisable(GL_DEPTH_TEST) mode so that it is seen through the model as it rotates at any angle.
  • flip -- pertains to cylinder billboard mode only; when specified, it forces an asymmetrical cylindrical billboard to keep its "head" "up" when flipped upside down by model rotation. sphere billboards are always "flippable" and ignore this parameter.
« Last Edit: February 22, 2018, 10:12:39 am by Patrice Terrier »
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1542
    • zapsolution
Version 2.00 video presentation
« Reply #3 on: January 13, 2018, 06:46:10 pm »
Here is a link to a video presentation of some of the things that could be done with version 2.00.

« Last Edit: January 14, 2018, 09:32:17 pm by Patrice Terrier »
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1542
    • zapsolution
Re: ObjectReader
« Reply #4 on: January 24, 2018, 01:34:49 pm »
Version 2.00 has been attached to the first post of this thread.

Note: This is a complete VS 2017 C++ 64-bit project targeted to the latest Windows 10 version 1709.
The pre-compiled binary code is within the x64\release subfolder.
« Last Edit: January 24, 2018, 01:39:56 pm by Patrice Terrier »
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1542
    • zapsolution
New features of version 2.50
« Reply #5 on: February 22, 2018, 02:50:32 pm »
Version 2.50

This version has switched from VBA to VBO mode, meaning almost everything is now handled by the GPU at the maximum speed of the graphic card to allow for smooth manipulation of high polygon models with millions of vertices.

However the CPU/GPU loads and system responsiveness are still dependent on: (in the order of importance)
-- polygon count
-- default/maximized/full screen window size
-- visible distance to model
-- "Illuminate both sides" setting
-- FFP or PPL (menu "Use fixed pipeline" checked or unchecked, respectively)
-- number of material textures (and consequently, number of texture lookups in the shaders)
-- backface culling
-- etc.

Graphics card auto detection:
The matching icon is shown on the right side of caption bar (currently only nVidia or ATi).

New composited control panel:
Its primary purpose is to greatly simplify and enhance the light settings through the "Lighting" menu.

To show the control panel, either select the "Light settings panel" from the menu or press the F1 key that works as an On/Off toggle switch.

Use the mouse wheel to scroll the panel content up or down when mouse focus is on the panel, and press the right mouse button if you want to jump up to the panel top.

Light settings
Use the [<<] or [>>] buttons to select colors from a specific color palette (currently 8 palettes all in all). The default is the same color set as in version 2.00 (see post #3).

Use this switch to display the FPS rate (a.k.a. frames per second) normally shown as two digits in the top left corner of OpenGL view port.

TURBO ("running man" button)
Use this switch to double the FPS rate (increases the GPU percentage but makes animation smoother).

Monitor the percentage use for the respective processor.

Drag and drop a desired color onto a specific light option. The matching On/Off switch must be enabled to see the effect.
The "Lighting" menu option "Save lighting to mtl file" stores the settings directly into the material file (.mtl extension).
You can always switch back to default using the "Lighting" menu option "Reset scene lighting".
« Last Edit: February 23, 2018, 08:58:40 pm by Michael Lobko-Lobanovsky »
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1542
    • zapsolution
ObjectReader versio 2.52
« Reply #6 on: June 19, 2018, 02:52:19 pm »
Version 2.52

The full new version has been attached to the first post of this thread.

New features:

- SyncTimer thread function, to replace the classic TIMER API (limited to 60 FPS).
Now the default is to work in turbo mode, using the same resfresh rate than the main display being used (most of the time 75 hz on modern display).

- Animation a new material meta command #rotate rStep, rX, rY, rZ inspired by glRotatef allow to perform individual mesh rotation on any of the 3D axis, the first parameter (angle) is used to setup the rotation speed (it can be either positive or negative to match CW or CCW rotation).

« Last Edit: June 19, 2018, 05:12:58 pm by Patrice Terrier »
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1542
    • zapsolution
Re: ObjectReader
« Reply #7 on: August 23, 2018, 11:37:40 am »
Version 2.53

The full new version has been attached to the first post of this thread.

New features:

Material enhancements

-- map_Ks (partly modulated by static ambient occlusion map)
-- map_Ka (static ambient occlusion map channel)
-- map_bump (new local meta command BUMP_NORMAL, BUMP_PARALLAX, BUMP_STEEP, BUMP_SELFSHADOW to control the amount of surface virtual bumpiness)

Normal Mapping

1. Conventional

Conventional normal mapping bakes the finer details of object bumpiness into the predominantly purple colored tangent-space normal maps that allow per-pixel simulation of fine bumps in the model areas where, due to model decimation, there are no corresponding geometric vertices any more. Combined with the OpenGL automatic smoothing capability, normal maps are a very cheap means to enhance the looks of the model's low-poly LODs.

The best quality normal maps should be baked from the original high-poly model before decimation and then applied to the decimated LODs at render time. This can be done in almost any professional 3D editor like Cinema 4D, 3ds Max and Maya, Blender, etc. If for some reason this isn't possible (e.g. the high-poly model isn't available), then usable but considerably lower quality normal maps can be derived from diffuse maps with the aid of e.g. the Photoshop nVidia plugin or CrazyBump app.

Conventional normal maps are however of limited capability because their range of veritable bumpiness is rather narrow.

2. Parallax

Parallax bump mapping derives additional height information from the normal map itself (and sometimes from an additional height map) and allows the amount of visible bumpiness to be controlled in real time. It allows us to either make the cavities visually deeper, or the bumps higher, or both, as compared to conventional normal mapping, through just two additional parameters that can be controlled by the observer at render time.

Parallax bump mapping looks much, much better than conventional normal mapping but still it isn't physiologically correct. Distant bumps protrude just as prominently as the closest ones, and this isn't how the human eye and brain percept bumpy objects in real world.

3. Steep Parallax

Steep parallax bump mapping eliminates the above deficiency by using a separate grayscale height map (or depth map that's effectively the inverse of height) that reduces the object's visible bumpiness as the apparent distance to the bumps increases. Steep parallax can also be controlled in real time through a number of parameters.

Note: ObjReader is not a 3D editor or ray tracer but just an OpenGL renderer. Its shader has a minimal set of uniforms to reduce render time load on the computer CPU and data bus in favor of the highest FPS rate achievable for the given model geometry. Therefore both parallax and steep parallax parameters have been set to some predefined general case numeric values hardcoded in the shader.

Just like a conventional normal map, the height map is best baked from the original high-poly model but can also be derived satisfactorily in most cases from the object's diffuse map e.g. in the CrazyBump app. The Sponza lion head model uses maps that have all been derived in CrazyBump from the one and only diffuse map the model was originally supplied with.

If the height map isn't available, ObjReader will use a blank white dummy map and its steep parallax will behave much like an ordinary parallax renderer though still doing quite a lot of thus unnecessary calc. We need a new steep parameter to the map_bump meta to control if a particular material should use steep parallax rather than ordinary parallax when rendered. Ordinary parallax uses much fewer computations in the shader and is thus less stressful for the GPU.

4. Bent Normals

Normal maps allow us to reproduce fine and medium sized bumps but they don't affect the shadowing of emulated relief. Unlike true geo, emulated bumps don't produce shadows on the other adjacent emulated bumps and cavities regardless of the position of the lights in the scene. The existing shadow casting techniques are based on model geometry shadowing other geometry but they ignore the ghost relief emulated with normal maps.

There is a tiny tool written in C that, given a conventional normal map and a corresponding height map, allows the normals in the normal map to be modulated ("bent") with additional height data at model design time in such a way that they would emulate casting gray-scale shadows dynamically on the adjacent relief at render time in accordance with the current position of scene lighting.

The said Sponza lion head model features both conventional and bent normal maps generated by the tool (bent ones are visibly more greenish). Experimenting with both material normal maps in the .MAT file allows the visual effect to be seen more clearly. As the lion's head nods slowly towards the viewer under forward directional lighting, it can be seen how the bent normal map's greenish areas start to cast gray "shadows" over the nearby emulated bumpy areas of the head.

The bent normal map acts like some kind of continuous dynamically generated ambient occlusion but unlike the latter, it comes absolutely for free, computation-wise.


1. Light/Shadow Mapping

If the model storage format provides for at least two concurrent sets of texture coords, then it becomes possible to use tiny colorful light maps to emulate shadowed and lit areas of the scene's static geometry. OpenGL is able to interpolate colors over surfaces nicely, and when the tiny light map is magnified to the model's actual size, color interpolation produces beautiful emulated penumbra shadows pre-baked into the light map in 3ds Max, Maya, Blender, Gyles and some other 3D editors at model design time.

Light maps are however per-triangle or per-plane based and use a different topological layout in their own texture atlas as compared to the conventional diffuse/normal/specular maps, hence the need for a concurrent alternative set of texture coords in the model format. If it isn't available as e.g. in our .OBJ format, then a conventional but minified and colored ambient occlusion map could be used. But there's hardly any 3D editor that's able to bake colored rather than grayscale AO maps to emulate veritably colorful shadows and light spots.

Light maps can also be emulated roughly by vertex colors. But this technique works poorly for low-res LODs because their sparse vertices tend to distort the contours of the scene's lit and shadowed areas.

Both light maps and vertex colors are used to colorfully GL_MODULATE the diffuse channel of the rendering pipeline.

2. Ambient Occlusion

Ambient occlusion is similar to light mapping but is usually high resolution and grayscale. Unlike light mapping, it is used to modulate predominantly the ambient component of scene lighting. AO can be static (pre-baked into an AO map in a 3D editor through an ordinary set of tex coords) or computed dynamically for animated models at render time. Dynamic AO is however computationally very intensive and therefore an FPS killer for high-quality real time rendering. ObjReader is currently able to support static AO in its map_Ka channel.

« Last Edit: August 26, 2018, 01:03:04 am by Michael Lobko-Lobanovsky »
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1542
    • zapsolution
Version 2.54
« Reply #8 on: October 11, 2018, 06:35:01 am »
Version 2.54

The full new version has been attached to the first post of this thread.

New feature:

Top-down lighting
This works just the same as the other three scene lights we already have.
It is available from the overlay control panel (F1).

Bug fix:

The overlay had a bug: when it was scrolled up a little and a palette color box was dragged-and-dropped onto some light control above the overlay palette, it landed in a wrong light channel box. That was because the light control rectangles were stored in absolute coordinates regardless of current scroll amount.
Now the vertical scroll offset is used to compute the correct location.
« Last Edit: October 11, 2018, 09:01:13 am by Michael Lobko-Lobanovsky »
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1542
    • zapsolution
Re: ObjectReader
« Reply #9 on: February 10, 2019, 05:49:19 pm »
Version 2.75

The full new version has been attached to the first post of this thread.

New features:
  • Transparent help.
  • Toast window help.
  • Full OpenGL driver/GLSL version info.
  • Model reload and unload.
  • Spinner load progress timer.
  • Selectable fields of view.
  • Emissive color mapping.
  • Specular exponent mapping.
  • Design mode - texture inspection (Main->Inspect: 8 per-texture viewers + UV checker).
  • Design mode - geometry inspection (Main->Inspect: material surface, color coded wireframe overlay, color coded meshes, vertex normals/tangents/bitangents).
  • Design mode - mesh info tips.
  • Design mode - Z-axis rotation.
  • Design mode - bounding volumes.
  • Design mode - scene grid.
  • Design mode - model slicer.
  • 6 fancy lighting/shading modes (Main->Renderer).
  • Animated - lights.
  • Animated - model reset.

Learn more about all these, using the new exclusive transparent help system (press F1 key) that allows you to keep working while reading.

« Last Edit: February 10, 2019, 05:55:38 pm by Patrice Terrier »
(Always working with the latest Windows version available...)