OpenGL2 <insert ascii art here>

OpenGL2 is an alternate renderer for ioquake3. It aims to implement modern features and technologies into the id tech 3 engine, but without sacrificing compatibility with existing Quake 3 mods.


FEATURES



INSTALLATION


For *nix:

  1. This should be identical to installing ioq3. Check their README for more details.


For Win32:

  1. Have a Quake 3 install, fully patched.
  2. Copy the following files into Quake 3's install directory:

    ioquake3.x86.exe renderer_opengl1_x86.dll renderer_opengl2_x86.dll

    These can be found in build/release-mingw32-x86 after compiling, or bug someone to release binaries.


RUNNING


  1. Start ioquake3. (ioquake3.x86.exe on Win32)
  2. Open the console (the default key is tilde ~) and type

/cl_renderer opengl2 and press enter /vid_restart then press enter again.

  1. Enjoy.

CVARS


Cvars for simple rendering features:

Cvars for HDR and tonemapping:

Cvars for advanced material usage:

Cvars for image interpolation and generation:

Cvars for the sunlight and cascaded shadow maps:

Cvars that you probably don't care about or shouldn't mess with:

Cvars that have broken bits:


MATERIALS


OpenGL2 supports .mtr files, which are basically the same as .shader files, and are located in the same place, but override existing .shader files if they exist. This is to allow maps and mods to use the new material features without breaking the map when using the old renderer.

Here's an example of a material stored in one, showing off some new features:

textures/abandon/grass
{
    qer_editorimage textures/abandon/grass.jpg
    {
        map textures/abandon/grass3_256_d.jpg
        rgbgen identity
    }
    {
        stage normalparallaxmap
        map textures/abandon/grass3_1024_n.png
        normalScale 1 1
        parallaxDepth 0.05
    }
    {
        stage specularmap
        map textures/abandon/grass3_256_s.png
        specularReflectance 0.12
        specularExponent 16
    }
    {
        map $lightmap
        blendfunc GL_DST_COLOR GL_ZERO
    }
}

The first thing to notice is that this is basically the same as old Quake 3 shader files. The next thing to notice are the new keywords. Here is what they mean:

stage <type>
- State how this imagemap will be used by OpenGL2:

    diffuseMap        - Standard, same as no stage entry
    normalMap         - Image will be used as a normal map
    normalParallaxMap - Image will be used as a normal map with 
                        alpha treated as height for parallax mapping
    specularMap       - Image will be used as a specular map with
                        alpha treated as shininess.

specularReflectance <value>

An important note is that normal and specular maps influence the diffuse map declared before them, so materials like this are possible:

textures/terrain/grass
{
    qer_editorimage textures/terrain/grass.jpg
    {
        map textures/terrain/rock.jpg
    }
    {
        stage normalparallaxmap
        map textures/terrain/rock_n.png
    }
    {
        stage specularmap
        map textures/terrain/rock_s.jpg
    }
    {
        map textures/terrain/grass.jpg
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        alphaGen vertex
    }
    {
        stage normalparallaxmap
        map textures/terrain/grass_n.png
    }
    {
        stage specularmap
        map textures/terrain/grass_s.png
        specularReflectance 0.12
    }
    {
        map $lightmap
        blendfunc GL_DST_COLOR GL_ZERO
    }
}

Though note due to the complexity of lighting, dynamic light (including sunlight with cascaded shadow maps) currently only works 100% on materials like this, where the second diffuse map doesn't have its own alpha, and only uses vertex alpha. YMMV.

Another addition to materials is working normal/specular maps on vertex lit surfaces. To enable this, make your material look like this:

textures/vehicles/car
{
    qer_editorimage textures/vehicles/car.jpg
    {
        map textures/vehicles/car.jpg
        rgbGen vertexLit
    }
    {
        stage normalparallaxmap
        map textures/vehicles/car_n.jpg
    }
    {
        stage specularmap
        map textures/vehicles/car_s.jpg
    }
}

Note the new keyword, 'vertexLit' after rgbGen. This is analogous to 'rgbGen vertex', except a light direction will be determined from the lightgrid and used with the normal and specular maps. 'exactVertexLit' exists as well, and is the equivalent for 'exactVertex'.


DYNAMIC SUNLIGHT AND CASCADED SHADOW MAPS


This adds a new keyword to sky materials, q3gl2_sun. The syntax is:

q3gl2_sun <red> <green> <blue> <intensity> <degrees> <elevation> <mapLightScale> <ambientLightScale>
Note the first six parameters are the same as in q3map_sun or q3map_sunExt, and the last two indicate scaling factors for the map brightness and an ambient light of the same color as the sun.

There are currently two ways to use this in your own (and other people's) maps.

  1. Create your map as normal, set r_sunlightMode to 1, and add a 'q3gl2_sun' line after your 'q3map_sun' line in your sky material, like so:

    textures/skies/bluesky { qer_editorimage textures/skies/bluesky.jpg

    surfaceparm nomarks surfaceparm noimpact surfaceparm nolightmap surfaceparm sky q3map_sunExt 240 238 200 100 195 35 3 16 q3gl2_sun 240 238 200 50 195 35 1.0 0.2 q3map_skylight 50 16 q3map_lightimage $whiteimage

    skyparms env/bluesky - - }

    The advantages with this method are that your map will continue to work with the old renderer with the sunlight baked into the lightmap, and it can be used with existing maps without recompilation. The downside is artifacts like doubled shadows and uneven shadow edges.

  2. Set r_sunlightMode to 2 and use 'q3gl2_sun' instead of 'q3map_sun' or 'q3map_sunExt', like so:

    textures/skies/bluesky { qer_editorimage textures/skies/bluesky.jpg

    surfaceparm nomarks surfaceparm noimpact surfaceparm nolightmap surfaceparm sky q3gl2_sun 240 238 200 50 195 35 0.5 0.2 q3map_skylight 50 16 q3map_lightimage $whiteimage

    skyparms env/bluesky - - }

    The advantages with this method are that you don't get the artifacts that characterize the other method, and your map compiles a lot faster without the sunlight bouncing calculations. The downsides are that your map will not display properly with the old renderer, and you lose the bounced light that compiling the map with q3map_sun* in it would have.


TONE MAPPING AND AUTO EXPOSURE


This adds a new keyword to sky materials, q3gl2_tonemap. The syntax is:

q3gl2_tonemap <toneMapMin> <toneMapAvg> <toneMapMax <autoExposureMin> <autoExposureMax>
Each of these settings corresponds to a matching cvar, so you can view and adjust the effect before settling on fixed settings.


THANKS


I'd like to take this part of the readme to thank the numerous people who contributed thoughts, ideas, and whole swaths of code to this project.

If I missed you in this section, feel free to drop me a line and I'll add you.


CONTACT


My name is James Canete, and I wrote most of this readme. Also, a renderer.

If you wish to get in touch with me, try my GMail at use.less01 (you should be able to solve this), or look for SmileTheory in #ioquake3 on irc.freenode.net.