Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 10 (modified by wiesep, 6 years ago) (diff)

Bump Mapping

To get detailed information about how to create a model with a bump map in blender and import it to Orxonox, take a look at Youtube Blender Tutorial - Normal Mapping.

To use a bump map in a material, you can create a new material script inheriting from the base bump map script. Replace both texture image files with your own files.

import * from "BumpMap.material"
// Any number of lights, diffuse
material Cube_Lava_Normal : BumpMap_Base
{
    technique
    {
        pass ambient
        {
        }
        // Now do the lighting pass
        // NB we don't do decal texture here because this is repeated per light
        pass perlight
        {
            // Base bump map
            texture_unit normalmap
            {
                texture Cube_Lava_NORM.jpg
                colour_op replace
            }
        }

        // Decal pass
        pass decal
        {
            texture_unit decalmap
            {
                texture Cube_Lava_COLOR.jpg
            }
        }
    }
}

The base bump map material script is located at [media_directory]/materials/BumpMapping/BumpMap.material

To get an idea what bump maps are capable of, start the test level BumpMap

Important Notes

Lightning

Bump Maps only work with lights and not with ambient lights. Take a look at Light on hot to use lights (directional, point or spotlight).

Flickering

During the implementation of the bump map functionality the problem of flickering flickering occurred. This could be fixed by inserting the following lines into ever pass.

 depth_write on
 depth_bias 1
  • Ambient Pass: depth_bias 0
  • Lightning Pass: depth_bias 1
  • Decal Pass: depth_bias 2

Flickering Problem

Screenshot

New File

Source

Base Material

// Any number of lights, diffuse
material BumpMap_Base
{
    technique
    {
        // Base ambient pass
        pass ambient
        {
          // base colours, not needed for rendering, but as information
          // to lighting pass categorisation routine
          diffuse 0 0 0

          // need to prevent flickering
          depth_write on
          depth_bias 0

        }
        // Now do the lighting pass
        // NB we don't do decal texture here because this is repeated per light
        pass perlight
        {

            // do this for each light
            iteration once_per_light
            scene_blend add

            // need to prevent flickering
            depth_write on
            depth_bias 1

            // base colours, not needed for rendering, but as information
            // to lighting pass categorisation routine
            ambient 0 0 0

            // Vertex program reference
            vertex_program_ref BumpMapping/BumpMapVP
            {
                param_named_auto lightPosition light_position_object_space 0
                param_named_auto worldViewProj worldviewproj_matrix
            }

            // Fragment program
            fragment_program_ref BumpMapping/BumpMapFP
            {
                param_named_auto lightDiffuse light_diffuse_colour 0
            }

            // texture shadow receiver program
            shadow_receiver_vertex_program_ref BumpMapping/BumpMapVPShadowRcv
            {
                param_named_auto lightPosition light_position_object_space 0
                param_named_auto worldViewProj worldviewproj_matrix
                param_named_auto worldMatrix world_matrix
                param_named_auto texViewProj texture_viewproj_matrix
            }
            // Additive texture shadow receiver program
            shadow_receiver_fragment_program_ref BumpMapping/BumpMapFPShadowRcv
            {
                param_named_auto lightDiffuse light_diffuse_colour 0
            }

            // Vertex program reference
            vertex_program_ref BumpMapping/BumpMapVPSpecular
            {
                param_named_auto lightPosition light_position_object_space 0
                param_named_auto eyePosition camera_position_object_space
                param_named_auto worldViewProj worldviewproj_matrix
            }

            // Fragment program
            fragment_program_ref BumpMapping/BumpMapFPSpecular
            {
                param_named_auto lightDiffuse light_diffuse_colour 0
                param_named_auto lightSpecular light_specular_colour 0
            }


            // Base bump map
            texture_unit normalmap
            {
                texture Cube_Lava_NORM.jpg
                colour_op replace
            }
        }

        // Decal pass
        pass decal
        {
            // base colours, not needed for rendering, but as information
            // to lighting pass categorisation routine
            lighting off

            // need to prevent flickering
            depth_write on
            depth_bias 2

            scene_blend dest_colour zero
            texture_unit decalmap
            {
                texture Cube_Lava_COLOR.jpg
            }
        }
    }
}

Attachments (3)

Download all attachments as: .zip