Headline News
Secure Blackphone starts shipping (June 30, 2014 10:03 am)
Linux Mint KDE reviewed (June 24, 2014 2:06 pm)
Linux Mint 17 “Qiana” KDE released! (June 23, 2014 10:24 am)
7 Improvements The Linux Desktop Needs (June 21, 2014 12:48 am)
Natural_Selection_2

After Valve, Natural Selection 2’s OpenGL translation layers released

The developers behind Natural Selection 2, Unknown Worlds Entertainment, have released their translation layers that they use to parse HLSL into OpenGL’s GLSL. They are using the MIT license so anyone is free to do what ever they want with the code, as long as it adheres to the license.

The code, which is available on github, isn’t compile-able out of the box is missing some basic dependencies like memory allocators, array classes etc, which shouldn’t be much of a trouble for people experienced in programming. Maybe some enterprising programmer or a group of them can pick it up and include these and maybe even wrap it in an easy to use package that can be easily used in other games, thus streamlining the porting process and overall decrease the time required.

The parser is designed to work with HLSL code written in the legacy Direct3D 9 style (e.g. D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY should be used with D3D11). The parser works with cbuffers for uniforms, so in addition to generating GLSL, there is a class provided for generating D3D9-compatible HLSL which doesn’t support cbuffers. The GLSL code requires version 3.1 for support of uniform blocks. The parser is designed to catch all errors and generate “clean” GLSL which can then be compiled without any errors.

The HLSL parsing is done though a basic recursive descent parser coded by hand rather than using a parser generator. We believe makes the code easier to understand and work with.

To get consistent results from Direct3D and OpenGL, our engine renders in OpenGL “upside down”. This is automatically added into the generated GLSL vertex shaders.

Although this code was written specifically for our use, we hope that it may be useful as an educational tool or a base for someone who wants to do something similar.

We are looking for aspiring bloggers and journalists for The Mukt. If you are interested, apply now!

Source: Github

Partha Das

Lover of food, books, anime, movies, music, tech, games and sleep. Hobbies include cooking, drawing, tinkering, coding, electronics/robotics and general mad-scientist stuff. Love to learn different languages and about different cultures and trying out new things. Currently learning Japanese and Korean too!