Figure 39 A Shade Table
Each entry in the shade table is an index into a colour palette. The shade table is usually arranged so that each row contains a number of shades of the same colour, ranging from very dark to very bright.
You can build your own shade tables using the tool MKSHADES. The shade table supplied with BRender, shade.tab
, references the palette std.pal
. To display BRender's standard shade table, enter the following command line:
texconv -I pixelmap shade.tab -P std.pal -v
BRTUTR6B.C
/* * Copyright (c) 1996 Argonaut Technologies Limited. All rights reserved. * Program to Display a Texture-Mapped Sphere (8-bit colour). */ #include <stddef.h> #include <stdio.h> #include "brender.h" #include "dosio.h" int main(int argc, char **argv) { br_pixelmap *screen_buffer, *back_buffer, *depth_buffer, *palette, *shade; br_actor *world, *observer, *planet; br_material *planet_material; int i; /*********** Initialise BRender and Graphics Hardware ***********/ BrBegin(); /* * Initialise screen buffer and set up CLUT (ignored in true colour) */ . . . . . . . . . . . . . . . . . . BrZbBegin(screen_buffer->type, BR_PMT_DEPTH_16); back_buffer = BrPixelmapMatch(screen_buffer,BR_PMMATCH_OFFSCREEN); depth_buffer = BrPixelmapMatch(screen_buffer,BR_PMMATCH_DEPTH_16); /* * Load Shade Table */ shade = BrPixelmapLoad("shade.tab"); if (shade==NULL) BR_ERROR("Couldn't load shade.tab"); BrTableAdd(shade); /*************** Build the World Database **********************/ world = BrActorAllocate(BR_ACTOR_NONE,NULL); BrLightEnable(BrActorAdd(world,BrActorAllocate(BR_ACTOR_LIGHT,NULL))); /* * Load and Position Camera */ observer = BrActorAdd(world,BrActorAllocate(BR_ACTOR_CAMERA,NULL)); observer->t.type = BR_TRANSFORM_MATRIX34; BrMatrix34Translate(&observer->t.t.mat,BR_SCALAR(0.0),BR_SCALAR(0.0), BR_SCALAR(5.0)); /* * Load and Position Planet Actor */ planet = BrActorAdd(world,BrActorAllocate(BR_ACTOR_MODEL,NULL)); planet->model = BrModelLoad("sph32.dat"); BrModelAdd(planet->model); planet->t.type = BR_TRANSFORM_MATRIX34; BrMatrix34PostRotateX(&planet->t.t.mat,BR_ANGLE_DEG(90)); /* * Load and Register "earth" Texture */ BrMapAdd(BrPixelmapLoad("earth8.pix")); /* * Load and Apply Earth Material */ planet_material = BrFmtScriptMaterialLoad("earth8.mat"); BrMaterialAdd(planet_material); planet->material = BrMaterialFind("earth8_map"); /********************** Animation Loop ***********************/ for(i=0; i < 200; i++) { BrPixelmapFill(back_buffer,0); BrPixelmapFill(depth_buffer,0xFFFFFFFF); BrZbSceneRender(world,observer,back_buffer,depth_buffer); BrPixelmapDoubleBuffer(screen_buffer,back_buffer); BrMatrix34PostRotateY(&planet->t.t.mat,BR_ANGLE_DEG(2.0)); } /* * Close down */ BrPixelmapFree(depth_buffer); BrPixelmapFree(back_buffer); BrZbEnd(); . . . . . . . . . . . . . . . . . . BrEnd(); return 0; }
BRTUTR6B.C
BRTUTR6B.C
displays a texture-mapped sphere in 8-bit colour mode. The material script file earth8.mat
is listed below.
earth8.mat
# This material script file describes the appearance # of the material "earth8_map" material = [ identifier = "earth8_map"; ambient = 0.05; diffuse = 0.55; specular = 0.4; power = 20; flags = [light,smooth]; map_transform = [[1,0], [0,1], [0,0]]; colour_map = "earth"; index_shade = "shade_table"; ];
Note that the shade table, like the texture map, is referenced by name.