OCCT receives OpenVR support

Release of “Half Life: Alyx” for Virtual Reality shown to me, that VR is not only about funny mechanics. Exploration of deeply detailed world can be joyful even without interactions, although they make world more realistic.

This reminded me about unfinished two-years-old patch for Open CASCADE Technology adding OpenVR support. Looks like a good time to complete the patch!

Continue reading

sRGB color space in OpenGL

RGB (red+green+blue) is the most commonly used color model, and computer graphics is not an exception. Mixture of red, green and blue (also called primaries for RGB) with different proportions allows defining any other color distinguishable by the human eye, which is known to everybody from early school days.

Artists, however, usually aware of much more terms with and without RGB in name – sRGB, AdobeRGB, scRGB, DCI-P3, Rec. 2020, wide-gamut RGB. And developers of graphics applications, including 3D Viewer, should be aware of them too.

CIE1931xy_gamut_comparison.svg.png

Color spaces comparison chart
from Wikipedia.

Continue reading

Atomic float arithmetic on GPU

Mutex is an essential tool for any multi-threaded application. But when it comes to small primitive types, and not structures, there are more options to consider.

Atomic operations, or simply atomics, are handy CPU or GPU instructions allowing to concurrently modify a value of primitive type without involving expensive tools like mutexes.

This small article is not intended to clarify usage of atomic operations, but to share a tricky experience of such operations in GPU program.

iss_tiles_vis_error.png

Continue reading

AIS_ViewController in OCCT 7.4.0

Open CASCADE 7.4.0 brings new handy class AIS_ViewController.

3D Viewer needs handling mouse input to bring interactivity to it. AIS_ViewController class takes responsibility for mapping user input events (mouse, keyboard, etc.) onto 3D viewer camera manipulations (rotation, panning, zooming) as well as highlighting objects in scene. Basically, it provides a more solid, cross-platform interface to V3d_View and AIS_InteractiveContext methods. AIS_ViewCube is another new class in OCCT 7.4.0 displaying an interactive cube for selecting 3D viewer camera direction.

occt_draw_view_cubes

As existing OCCT users might be curious what AIS_ViewController is, I have decided writing a small memo in Questions & Answers form.

Continue reading

GL_R16 and OpenGL ES on Android

sView user on Android device just sent me a link to online stereoscopic 3D video with yuv420p10 pixel format… and it is not an anime. The user complained about green screen in the player instead of a video. So far I haven’t seen much videos with more than 8-bit per channel in a wild, and appearance of such files in online services surprised me.

FFmpeg decodes such videos into pixel formats like AV_PIX_FMT_YUV420P10LE. This pixel format has 10-bit per-channel payload, but actually aligned into 16-bit per-channel planes. sView uploads such pixel formats into GL_ALPHA16 textures, which has been implemented a long time ago. After some investigation, I figured out that there is no OpenGL ES implementation supporting such texture format, and the only direct counterpart is GL_R16_EXT (normalized 16-bit red channel only format, same as GL_R16 on desktop), which is not yet in any core OpenGL ES specs, and requires extension GL_EXT_texture_norm16.

By the way, all this “deprecation thing” applied to useful texture formats like GL_APHA8, replaced by GL_R8 for no profit within OpenGL 3+ on desktop, always confused be. Applications supporting wide range of OpenGL drivers (including OpenGL 2.1) has to be messed up with different code per OpenGL version for exactly the same thing! As texture swizzling came later (and also messed-up API), fallback requires dummy GLSL code modifications fetching .r or .a of texture sample color.

Apparently, so far just two vendors support GL_EXT_texture_norm16 extension – Qualcomm Adreno and NVIDIA Tegra, which is quite predictable considering links to desktop graphics in their past. Testing on Adreno device has shown good playback performance of given video sample.

Unfortunately, devices with Mali graphics do not support this extension, leading to bad performance due to software conversion via SWScaler. Possible solution would be uploading planes into GL_R16UI textures (which is included into OpenGL ES 3.0 specs, but integer formats do not support texture filtering) and either implement texture filtering via GLSL program or convert it further into GL_R32F format (the latter one seems to be implemented by some internet browsers).

Displaying Mesh Edges in OCCT

Mesh displayed in OCCT 3D Viewer might come from different sources – imported from external file (glTF, JT, STL, PLY, OBJ), computed for analytical BRep geometry by BRepMesh and ExpressMesh algorithms or generated directly by application code.

interior1_persp_glsl_msaa.png

Draw Harness test case for Mesh Edges.

The mesh is usually displayed shaded, but this presentation is not suitable for analysis of mesh structure. In many cases, application developer needs other mesh presentations to locate issues (too many details, not enough details, local deviations, etc.) and make corrections based on analysis results (adjust mesh generation or export parameters).

In this case, mesh edges presentation becomes very helpful. Continue reading

Tracking FFmpeg API changes

Using external libraries in a project as well as writing your own library reveal API/ABI compatibility issues. It is difficult preserving a public API of an intensively developed library, and almost impossible managing ABI compatibility.

In this article I’m just sharing my thoughts about maintenance burden to keep sView source code compatible with various Linux (Ubuntu) releases depending on FFmpeg version.

Continue reading

CheckDLL – checking missing DLLs

One more handful tool without user interface – CheckDLL. This one I’ve developed a long time ago (since ‘2010), but just recently have decided making it available to everybody:
https://github.com/gkv311/checkdll/releases

It is a common problem for developer (and less common for user) that application doesn’t show up due to some libraries missing. There might be a plenty of reasons for that – mess up in environment variables (and/or batch scripts), mess up in system (some dump application decided installing a version-less DLL in System32), some libraries haven’t been copied by delivery script, mess up with 32-bit and 64-bit DLLs, forgetting dependency from C/C++ runtime libraries, etc.

The most common way for developer to check which dependencies library/application has on Windows platform is using Dependency Walker tool. This is a powerful tool, but in most cases it is over-complicated for simple use cases. In practice, I’m prefer using a Fileinfo plugin for Total Commander instead.

Still, when I need to know if there are some broken DLLs in a folder, I’m using CheckDLL. Just put this tool into your folder and launch from explorer to see that every library can be loaded. Alternatively, the tool can be also started from command-line with a path to the folder.

checkdll_screenshot