Script-based material effects and shaders

An effect is nothing more than a collection of different rendering techniques that are supported by a variety of 3D video cards. The effects can be written by advanced users but they can be used by anyone; the picture below shows a box with a DOT3 bump-mapping effect applied to its texture.


 
 

file_length(filehandle)

This instruction returns the length of the file with the given handle, in bytes. Here's a code sample that uses it:

var my_level;

string ok_str = "the level is ok";
string changed_str = "the level was changed!";

text some_txt
{
     pos_x = 0;
     pos_y = 0;
     font = _a4font;
     flags = visible;
}
 
function check_file()
{
     my_level = file_open_read("office.wmp"); // open the file
     if (file_length (my_level) == 51064) // put the size of your level here
     {
          some_txt.string = ok_str;
     }
     else
     {
          some_txt.string = changed_str;
     }
}

on_c = check_file; // press "C" to check the integrity of your office.wmp file

 
 
ent_animate(entity, scenename, percent, mode)

This instruction replaces ent_frame and ent_cycle and works ok for both vertex and bones animation methods. The same instruction works ok for sprites too!

These are the old and the new scripts that animate an entity using its "walk" animation:

action animate_old
{
     while (1)
     {
          ent_cycle("walk", my.skill46); // play "walk" frames animation
          my.skill46 += 10 * time; // "walk" animation speed
          my.skill46 %= 100; // loop animation
          wait (1);
     }
}

action animate_new
{
     while (1)
     {
          ent_animate(me, "walk", my.skill46, ANM_CYCLE); // "walk" cycle
          my.skill46 += 10 * time; // "walk" animation speed
          wait (1);
     }
}