kvark / vange-rs

Rusty Vangers clone
https://vange.rs
Apache License 2.0
438 stars 21 forks source link

Lighting #9

Open kvark opened 8 years ago

kvark commented 8 years ago

We could greatly enhance the looks and enrich the volume by adding simple phong lighting. Models already come with normals and solid colors, so these are trivial to light. Problem comes from the terrain:

kvark commented 8 years ago

We could go 2 ways about the model lighting:

  1. just do it on our own with a Phong model
  2. follow the existing code:
    unsigned char color_offset = COLORS_VALUE_TABLE[color_id*2];
    unsigned char color_shift = COLORS_VALUE_TABLE[color_id*2 + 1];
        unsigned c = color_offset + (((unsigned)normals[0] -> I_8 + normals[1] -> I_8 + normals[2] -> I_8) >> color_shift)/3;

where I_8 is computed by fast_calc_intensity()