Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
00810b7d
S
stb
项目概览
itdan3344
/
stb
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
00810b7d
编写于
3月 14, 2015
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
correct normals for vheight floors
上级
c10b3fef
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
475 addition
and
118 deletion
+475
-118
stb_voxel_render.h
stb_voxel_render.h
+444
-109
tests/caveview/cave_mesher.c
tests/caveview/cave_mesher.c
+23
-6
tests/caveview/cave_render.c
tests/caveview/cave_render.c
+8
-3
未找到文件。
stb_voxel_render.h
浏览文件 @
00810b7d
此差异已折叠。
点击以展开。
tests/caveview/cave_mesher.c
浏览文件 @
00810b7d
...
...
@@ -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
#if
def 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
#if
def 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
;
...
...
tests/caveview/cave_render.c
浏览文件 @
00810b7d
...
...
@@ -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
.
0
f
/
60
.
0
f
;
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
.
125
f
);
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
.
65
f
}
};
float
bright
=
15
;
float
bright
=
8
;
lighting
[
1
][
0
]
*=
bright
;
lighting
[
1
][
1
]
*=
bright
;
lighting
[
1
][
2
]
*=
bright
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录