Wikia

OpenArena

Mapping manual/Creating basic shaders

< Mapping manual

370pages on
this wiki
Talk0

After taking a look to what shaders are, the required syntaxes and the keywords, it's time to put our newly-acquired knowledge to practice.

Basic sprites Edit

textures/xxxxxx
{
   deformVertexes autoSprite
   surfaceparm trans
   surfaceparm nomarks
   surfaceparm nolightmap
   cull none
        {		 
        clampmap textures/xxxxxx.tga
        blendFunc blend
        rgbGen identity
        }
}

This works by using a cube brush with just one face textured with this shader, all other faces should be nodraw and non-solid ("common/nodraw" should fit).

This is a lens flare shader, but can be used on skyboxes to decorate it with sprites. Clampmap makes the texture scale like lens flare do, larger at distance, smaller when closer, but since skybox distance is fixed, the sprites scale stays fixed as well. blendfunc blend makes the black pixels of the texture's alpha channel invisible. The size of the sprite can be changed by changing the brush's size.

Rgbgen identity can be removed.

An interesting variant to deformVertexes autoSprite is deformVertexes autoSprite2: while an "autosprite" looks the same from all angles, an "autosprite2" turns around its longer axis only. Autosprite2 does not require the brush face to be perfectly squared: it may be used for example for enegery columns or similar effects.

A bright and non-lightmapped texture Edit

textures/xxxxxxxxx
{
   qer_editorimage textures/xxxxxxxxxx.tga
   q3map_nolightmap
{
  map textures/xxxxxx.tga
  blendFunc GL_ONE GL_zero
}
}

This creates a texture that ignores lightmaps, but doesn't render as a black surface in game. Blendfunc gl_one gl_zero makes the texture brightness equal to 1 in game, while the lightmap of that face equal to zero, thus, ignored or invisible in game.

If the brush is a lamp or some 3D lightsource, add surfaceparm trans to make light not be blocked by the brush.

Translucent and lightmapped texture Edit

textures/xxxxx
{
       surfaceparm nomarks
       surfaceparm trans
       surfaceparm water
       cull none
	{
            map textures/liquids/xxxx.tga
            rgbGen identity
            blendfunc blend
            alphaGen const 0.5
	}
  { 
  tcgen lightmap
  map $lightmap
  blendfunc gl_dst_color gl_src_color
  rgbGen identity
  }
}

It's possible to make glass or water surfaces that are both translucent and lightmapped, instead of just translucent and full bright.

surfaceparm trans make the texture invisible to lightrays, as a result it doesn't cast shadows.

tcgen lightmap this was copied from external lightmaps trick.

blendfunc gl_dst_color gl_src_color this is the how the lightmap is blended with the texture.

alphaGen const 0.5 this is a constant translucency factor.

Note: (taken from hydronex water shader). The lightmap stage should be last, after the transparency stage.

Some more specific details still missing.

Simple environment reflection Edit

textures/xxxxxxxxx
{
   q3map_nolightmap
	{
		map textures/xxxxxxxx.tga
		tcgen environment
		rgbGen identitylighting
		tcmod scale -1 1
	}
}

This pick ups a screenshot, photo or texture and renders in game as a environment map, more or less like the reflection created by highly specular surfaces, or wet surfaces.

The distortion that occurs in game is vertex basead, a highly tesselated surface could render with less distortion.

rgbgen identitylighting changing this changes the overall brightness of the environment map.

tcmod scale x y this scales / flips the env map. The env map tga stretches a lot in game, missing information about how to control both the scale and the texture alignment...

This effect is cheap because it's not a realtime reflection, it's a reflection basead on a pre-taken screenshot or a simple texture.


Animated texture Edit

textures/testes/1
{
   qer_editorimage textures/test/1.tga
   {
      animmap 1 textures/test/1.tga textures/test/2.tga textures/test/3.tga textures/test/4.tga textures/test/5.tga textures/test/6.tga textures/test/7.tga textures/test/8.tga
   }
}

Q3 animmap is limited to 8 frames, any other frame beyond that is ignored by the engine. The textures doesn't need to be numbered like the above example.

animmap x this controls the animation's frame rate. How many sequences are played per second.

Liquids Edit

Skies Edit

Environment boxes Edit

Mirrors and portals Edit

Notes Edit

External Links Edit

Around Wikia's network

Random Wiki