First shader

You can select images in the texture browser in your map editor (radiant) to give brushes and patches a visible surface in-game. This will show you how to make your own surface properties and effects.

There is textures, shaders and images. For the idtech3 game engine textures are only images with a default shader. The engine itself turns everything into a shader.

Here is the representation of the default shader for each texture that is hardcoded into the engine:

  •  1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    
    textures/exampleshaderfolder/floor
    {
    	{
    		map $lightmap
    		rgbGen identity
    	}
    	{
    		map textures/exampletexturefolder/floor.tga
    		blendFunc GL_DST_COLOR GL_ZERO
    	}
    }
    

    The first line is the shader name for the engine and is usually and similar to a texture name (relative path with filename but without extension).
    Line 3 and 7 initiate a shader stage with the enclosing clamps { and }.
    "textures/q3map2_sm/floor.tga" in line 8 is using an image that can always be tga or jpg.

    Let's write our own first shader:

    textures/firstshader/floor
    {
    	{
    		map $lightmap
    		rgbGen identity
    	}
    	{
    		map textures/firstshader/floor.tga
    		blendFunc GL_DST_COLOR GL_ZERO
    	}
    }
    

    We name the shader (folder) after the base map filename firstshader.map and firstshader.bsp.
    Create a folder firstshader where the image floor.tga gets dropped. The engine will search the image for the shader in the relative location "textures/firstshader/floor.tga" that should be in a pack (pk3) file.

    The first actual change will be no falling damage if a player lands on the ground (surface with the new shader).

    textures/firstshader/floor
    {
    	surfaceparm nodamage
    	{
    		map $lightmap
    		rgbGen identity
    	}
    	{
    		map textures/firstshader/floor.tga
    		blendFunc GL_DST_COLOR GL_ZERO
    	}
    }
    

    Now we store the shader content in a shader file so the game engine can find it. For example into the relative file path scripts/firstshader.shader. The game engine is loading any file with the extension shader in the scripts folder (scripts/*.shader).

    If you want to go more into detail follow this link to a q3map2 shader manual. Miscellaneous

    You can download the example map for this tutorial here:

    Written by Pan-(G)