correct normals for vheight floors
This commit is contained in:
@ -13,8 +13,11 @@
|
||||
#include "sdl_thread.h"
|
||||
#include <math.h>
|
||||
|
||||
#define STB_VOXEL_RENDER_IMPLEMENTATION
|
||||
//#define VHEIGHT_TEST
|
||||
//#define STBVOX_OPTIMIZED_VHEIGHT
|
||||
|
||||
#define STBVOX_ROTATION_IN_LIGHTING
|
||||
#define STB_VOXEL_RENDER_IMPLEMENTATION
|
||||
#include "stb_voxel_render.h"
|
||||
|
||||
extern void ods(char *fmt, ...);
|
||||
@ -585,7 +588,9 @@ void build_chunk(int chunk_x, int chunk_y, fast_chunk *fc_table[4][4], raw_mesh
|
||||
int a,b,z;
|
||||
stbvox_input_description *map;
|
||||
|
||||
//unsigned char vheight[34][34][18];
|
||||
#ifdef VHEIGHT_TEST
|
||||
unsigned char vheight[34][34][18];
|
||||
#endif
|
||||
|
||||
assert((chunk_x & 1) == 0);
|
||||
assert((chunk_y & 1) == 0);
|
||||
@ -632,7 +637,7 @@ void build_chunk(int chunk_x, int chunk_y, fast_chunk *fc_table[4][4], raw_mesh
|
||||
map->blocktype = &rm->sv_blocktype[1][1][1-z]; // specify location of 0,0,0 so that accessing z0..z1 gets right data
|
||||
map->lighting = &rm->sv_lighting[1][1][1-z];
|
||||
|
||||
#if 0
|
||||
#ifdef VHEIGHT_TEST
|
||||
// hacky test of vheight
|
||||
for (a=0; a < 34; ++a) {
|
||||
for (b=0; b < 34; ++b) {
|
||||
@ -640,8 +645,12 @@ void build_chunk(int chunk_x, int chunk_y, fast_chunk *fc_table[4][4], raw_mesh
|
||||
for (c=0; c < 17; ++c) {
|
||||
if (rm->sv_blocktype[a][b][c] != 0 && rm->sv_blocktype[a][b][c+1] == 0) {
|
||||
// topmost block
|
||||
rm->sv_blocktype[a][b][c] = 168;
|
||||
vheight[a][b][c] = rand() & 255;
|
||||
rm->sv_blocktype[a][b][c] = 168;
|
||||
} else if (c > 0 && rm->sv_blocktype[a][b][c] != 0 && rm->sv_blocktype[a][b][c-1] == 0) {
|
||||
// bottommost block
|
||||
vheight[a][b][c] = ((rand() % 3) << 6) + ((rand() % 3) << 4) + ((rand() % 3) << 2) + (rand() % 3);
|
||||
rm->sv_blocktype[a][b][c] = 169;
|
||||
}
|
||||
}
|
||||
vheight[a][b][c] = STBVOX_MAKE_VHEIGHT(2,2,2,2); // flat top
|
||||
@ -792,7 +801,7 @@ void mesh_init(void)
|
||||
minecraft_color_for_blocktype[11][i] = 63; // emissive
|
||||
}
|
||||
|
||||
#if 0 // vheight test
|
||||
#ifdef VHEIGHT_TEST
|
||||
effective_blocktype[168] = 168;
|
||||
minecraft_tex1_for_blocktype[168][0] = 1;
|
||||
minecraft_tex1_for_blocktype[168][1] = 1;
|
||||
@ -800,7 +809,15 @@ void mesh_init(void)
|
||||
minecraft_tex1_for_blocktype[168][3] = 1;
|
||||
minecraft_tex1_for_blocktype[168][4] = 1;
|
||||
minecraft_tex1_for_blocktype[168][5] = 1;
|
||||
minecraft_geom_for_blocktype[168] = STBVOX_GEOM_floor_vheight_02;
|
||||
minecraft_geom_for_blocktype[168] = STBVOX_GEOM_floor_vheight_12;
|
||||
effective_blocktype[169] = 169;
|
||||
minecraft_tex1_for_blocktype[169][0] = 1;
|
||||
minecraft_tex1_for_blocktype[169][1] = 1;
|
||||
minecraft_tex1_for_blocktype[169][2] = 1;
|
||||
minecraft_tex1_for_blocktype[169][3] = 1;
|
||||
minecraft_tex1_for_blocktype[169][4] = 1;
|
||||
minecraft_tex1_for_blocktype[169][5] = 1;
|
||||
minecraft_geom_for_blocktype[169] = STBVOX_GEOM_ceil_vheight_03;
|
||||
#endif
|
||||
|
||||
remap[53] = 1;
|
||||
|
@ -184,9 +184,12 @@ GLint uniform_loc[16];
|
||||
float table3[128][3];
|
||||
GLint tablei[2];
|
||||
|
||||
float step=0;
|
||||
|
||||
void setup_uniforms(float pos[3])
|
||||
{
|
||||
int i,j;
|
||||
step += 1.0f/60.0f;
|
||||
for (i=0; i < STBVOX_UNIFORM_count; ++i) {
|
||||
stbvox_uniform_info *ui = stbvox_get_uniform_info(&g_mesh_maker, i);
|
||||
uniform_loc[i] = -1;
|
||||
@ -224,9 +227,11 @@ void setup_uniforms(float pos[3])
|
||||
table3[0][0] = pos[0];
|
||||
table3[0][1] = pos[1];
|
||||
table3[0][2] = pos[2];
|
||||
table3[0][3] = stb_max(0,(float)sin(step*2)*0.125f);
|
||||
break;
|
||||
|
||||
case STBVOX_UNIFORM_ambient: {
|
||||
float bright = 0.75;
|
||||
float amb[3][3];
|
||||
|
||||
// ambient direction is sky-colored upwards
|
||||
@ -245,8 +250,8 @@ void setup_uniforms(float pos[3])
|
||||
// amb[1] + (amb[2] - amb[1]) * dot/2 + (amb[2]-amb[1])/2
|
||||
|
||||
for (j=0; j < 3; ++j) {
|
||||
table3[1][j] = (amb[2][j] - amb[1][j])/2;
|
||||
table3[2][j] = (amb[1][j] + amb[2][j])/2;
|
||||
table3[1][j] = (amb[2][j] - amb[1][j])/2 * bright;
|
||||
table3[2][j] = (amb[1][j] + amb[2][j])/2 * bright;
|
||||
}
|
||||
|
||||
// fog color
|
||||
@ -783,7 +788,7 @@ void render_caves(float campos[3])
|
||||
|
||||
{
|
||||
float lighting[2][3] = { { campos[0],campos[1],campos[2] }, { 0.75,0.75,0.65f } };
|
||||
float bright = 15;
|
||||
float bright = 8;
|
||||
lighting[1][0] *= bright;
|
||||
lighting[1][1] *= bright;
|
||||
lighting[1][2] *= bright;
|
||||
|
Reference in New Issue
Block a user