tools: ass2iqe opacity key support
parent
89a09f127a
commit
770f8be8f1
|
@ -1327,7 +1327,7 @@ enum SHADING_MODE {
|
||||||
SHADING_PBR,
|
SHADING_PBR,
|
||||||
};
|
};
|
||||||
enum RENDER_PASS {
|
enum RENDER_PASS {
|
||||||
RENDER_PASS_NORMAL,
|
RENDER_PASS_OPAQUE,
|
||||||
RENDER_PASS_SHADOW,
|
RENDER_PASS_SHADOW,
|
||||||
RENDER_PASS_LIGHTMAP,
|
RENDER_PASS_LIGHTMAP,
|
||||||
NUM_RENDER_PASSES
|
NUM_RENDER_PASSES
|
||||||
|
|
|
@ -17574,7 +17574,7 @@ enum SHADING_MODE {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RENDER_PASS {
|
enum RENDER_PASS {
|
||||||
RENDER_PASS_NORMAL,
|
RENDER_PASS_OPAQUE,
|
||||||
RENDER_PASS_SHADOW,
|
RENDER_PASS_SHADOW,
|
||||||
RENDER_PASS_LIGHTMAP,
|
RENDER_PASS_LIGHTMAP,
|
||||||
|
|
||||||
|
@ -385391,12 +385391,12 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model,
|
||||||
material_color.r = ((material_color_hex[0] >= 'a') ? material_color_hex[0] - 'a' + 10 : material_color_hex[0] - '0') / 15.f;
|
material_color.r = ((material_color_hex[0] >= 'a') ? material_color_hex[0] - 'a' + 10 : material_color_hex[0] - '0') / 15.f;
|
||||||
material_color.g = ((material_color_hex[1] >= 'a') ? material_color_hex[1] - 'a' + 10 : material_color_hex[1] - '0') / 15.f;
|
material_color.g = ((material_color_hex[1] >= 'a') ? material_color_hex[1] - 'a' + 10 : material_color_hex[1] - '0') / 15.f;
|
||||||
material_color.b = ((material_color_hex[2] >= 'a') ? material_color_hex[2] - 'a' + 10 : material_color_hex[2] - '0') / 15.f;
|
material_color.b = ((material_color_hex[2] >= 'a') ? material_color_hex[2] - 'a' + 10 : material_color_hex[2] - '0') / 15.f;
|
||||||
|
material_color.a = ((material_color_hex[3] >= 'a') ? material_color_hex[3] - 'a' + 10 : material_color_hex[3] - '0') / 15.f;
|
||||||
#if 0 // not enabled because of some .obj files like suzanne, with color_hex=9990 found
|
#if 0 // not enabled because of some .obj files like suzanne, with color_hex=9990 found
|
||||||
if(material_color_hex[3])
|
if(material_color_hex[3])
|
||||||
material_color.a = ((material_color_hex[3] >= 'a') ? material_color_hex[3] - 'a' + 10 : material_color_hex[3] - '0') / 15.f;
|
material_color.a = ((material_color_hex[3] >= 'a') ? material_color_hex[3] - 'a' + 10 : material_color_hex[3] - '0') / 15.f;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
material_color.a = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !material_embedded_texture ) {
|
if( !material_embedded_texture ) {
|
||||||
|
@ -385501,14 +385501,14 @@ void model_set_renderstates(model_t *m) {
|
||||||
m->rs[i] = renderstate();
|
m->rs[i] = renderstate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal pass
|
// Opaque pass
|
||||||
renderstate_t *normal_rs = &m->rs[RENDER_PASS_NORMAL];
|
renderstate_t *opaque_rs = &m->rs[RENDER_PASS_OPAQUE];
|
||||||
{
|
{
|
||||||
normal_rs->blend_enabled = 1;
|
opaque_rs->blend_enabled = 1;
|
||||||
normal_rs->blend_src = GL_SRC_ALPHA;
|
opaque_rs->blend_src = GL_SRC_ALPHA;
|
||||||
normal_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
|
opaque_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||||
normal_rs->cull_face_mode = GL_BACK;
|
opaque_rs->cull_face_mode = GL_BACK;
|
||||||
normal_rs->front_face = GL_CW;
|
opaque_rs->front_face = GL_CW;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shadow pass @todo
|
// Shadow pass @todo
|
||||||
|
@ -385813,7 +385813,7 @@ void model_draw_call(model_t m, int shader) {
|
||||||
handle old_shader = last_shader;
|
handle old_shader = last_shader;
|
||||||
shader_bind(shader);
|
shader_bind(shader);
|
||||||
|
|
||||||
renderstate_t *rs = &m.rs[RENDER_PASS_NORMAL];
|
renderstate_t *rs = &m.rs[RENDER_PASS_OPAQUE];
|
||||||
|
|
||||||
renderstate_apply(rs);
|
renderstate_apply(rs);
|
||||||
|
|
||||||
|
@ -386231,7 +386231,7 @@ void model_destroy(model_t m) {
|
||||||
FREE(q);
|
FREE(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned model_renderpass = RENDER_PASS_NORMAL;
|
static unsigned model_renderpass = RENDER_PASS_OPAQUE;
|
||||||
|
|
||||||
unsigned model_getpass() {
|
unsigned model_getpass() {
|
||||||
return model_renderpass;
|
return model_renderpass;
|
||||||
|
@ -387921,8 +387921,8 @@ void scene_render(int flags) {
|
||||||
|
|
||||||
|
|
||||||
model->billboard = obj->billboard;
|
model->billboard = obj->billboard;
|
||||||
model->rs[RENDER_PASS_NORMAL].cull_face_enabled = flags&SCENE_CULLFACE ? 1 : 0;
|
model->rs[RENDER_PASS_OPAQUE].cull_face_enabled = flags&SCENE_CULLFACE ? 1 : 0;
|
||||||
model->rs[RENDER_PASS_NORMAL].polygon_mode_draw = flags&SCENE_WIREFRAME ? GL_LINE : GL_FILL;
|
model->rs[RENDER_PASS_OPAQUE].polygon_mode_draw = flags&SCENE_WIREFRAME ? GL_LINE : GL_FILL;
|
||||||
model_render(*model, cam->proj, cam->view, obj->transform, model->program);
|
model_render(*model, cam->proj, cam->view, obj->transform, model->program);
|
||||||
|
|
||||||
if( do_retexturing ) {
|
if( do_retexturing ) {
|
||||||
|
|
|
@ -3775,12 +3775,12 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model,
|
||||||
material_color.r = ((material_color_hex[0] >= 'a') ? material_color_hex[0] - 'a' + 10 : material_color_hex[0] - '0') / 15.f;
|
material_color.r = ((material_color_hex[0] >= 'a') ? material_color_hex[0] - 'a' + 10 : material_color_hex[0] - '0') / 15.f;
|
||||||
material_color.g = ((material_color_hex[1] >= 'a') ? material_color_hex[1] - 'a' + 10 : material_color_hex[1] - '0') / 15.f;
|
material_color.g = ((material_color_hex[1] >= 'a') ? material_color_hex[1] - 'a' + 10 : material_color_hex[1] - '0') / 15.f;
|
||||||
material_color.b = ((material_color_hex[2] >= 'a') ? material_color_hex[2] - 'a' + 10 : material_color_hex[2] - '0') / 15.f;
|
material_color.b = ((material_color_hex[2] >= 'a') ? material_color_hex[2] - 'a' + 10 : material_color_hex[2] - '0') / 15.f;
|
||||||
|
material_color.a = ((material_color_hex[3] >= 'a') ? material_color_hex[3] - 'a' + 10 : material_color_hex[3] - '0') / 15.f;
|
||||||
#if 0 // not enabled because of some .obj files like suzanne, with color_hex=9990 found
|
#if 0 // not enabled because of some .obj files like suzanne, with color_hex=9990 found
|
||||||
if(material_color_hex[3])
|
if(material_color_hex[3])
|
||||||
material_color.a = ((material_color_hex[3] >= 'a') ? material_color_hex[3] - 'a' + 10 : material_color_hex[3] - '0') / 15.f;
|
material_color.a = ((material_color_hex[3] >= 'a') ? material_color_hex[3] - 'a' + 10 : material_color_hex[3] - '0') / 15.f;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
material_color.a = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !material_embedded_texture ) {
|
if( !material_embedded_texture ) {
|
||||||
|
@ -3885,14 +3885,14 @@ void model_set_renderstates(model_t *m) {
|
||||||
m->rs[i] = renderstate();
|
m->rs[i] = renderstate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal pass
|
// Opaque pass
|
||||||
renderstate_t *normal_rs = &m->rs[RENDER_PASS_NORMAL];
|
renderstate_t *opaque_rs = &m->rs[RENDER_PASS_OPAQUE];
|
||||||
{
|
{
|
||||||
normal_rs->blend_enabled = 1;
|
opaque_rs->blend_enabled = 1;
|
||||||
normal_rs->blend_src = GL_SRC_ALPHA;
|
opaque_rs->blend_src = GL_SRC_ALPHA;
|
||||||
normal_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
|
opaque_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||||
normal_rs->cull_face_mode = GL_BACK;
|
opaque_rs->cull_face_mode = GL_BACK;
|
||||||
normal_rs->front_face = GL_CW;
|
opaque_rs->front_face = GL_CW;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shadow pass @todo
|
// Shadow pass @todo
|
||||||
|
@ -4197,7 +4197,7 @@ void model_draw_call(model_t m, int shader) {
|
||||||
handle old_shader = last_shader;
|
handle old_shader = last_shader;
|
||||||
shader_bind(shader);
|
shader_bind(shader);
|
||||||
|
|
||||||
renderstate_t *rs = &m.rs[RENDER_PASS_NORMAL];
|
renderstate_t *rs = &m.rs[RENDER_PASS_OPAQUE];
|
||||||
|
|
||||||
renderstate_apply(rs);
|
renderstate_apply(rs);
|
||||||
|
|
||||||
|
@ -4615,7 +4615,7 @@ void model_destroy(model_t m) {
|
||||||
FREE(q);
|
FREE(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned model_renderpass = RENDER_PASS_NORMAL;
|
static unsigned model_renderpass = RENDER_PASS_OPAQUE;
|
||||||
|
|
||||||
unsigned model_getpass() {
|
unsigned model_getpass() {
|
||||||
return model_renderpass;
|
return model_renderpass;
|
||||||
|
|
|
@ -607,7 +607,7 @@ enum SHADING_MODE {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RENDER_PASS {
|
enum RENDER_PASS {
|
||||||
RENDER_PASS_NORMAL,
|
RENDER_PASS_OPAQUE,
|
||||||
RENDER_PASS_SHADOW,
|
RENDER_PASS_SHADOW,
|
||||||
RENDER_PASS_LIGHTMAP,
|
RENDER_PASS_LIGHTMAP,
|
||||||
|
|
||||||
|
|
|
@ -564,8 +564,8 @@ void scene_render(int flags) {
|
||||||
|
|
||||||
|
|
||||||
model->billboard = obj->billboard;
|
model->billboard = obj->billboard;
|
||||||
model->rs[RENDER_PASS_NORMAL].cull_face_enabled = flags&SCENE_CULLFACE ? 1 : 0;
|
model->rs[RENDER_PASS_OPAQUE].cull_face_enabled = flags&SCENE_CULLFACE ? 1 : 0;
|
||||||
model->rs[RENDER_PASS_NORMAL].polygon_mode_draw = flags&SCENE_WIREFRAME ? GL_LINE : GL_FILL;
|
model->rs[RENDER_PASS_OPAQUE].polygon_mode_draw = flags&SCENE_WIREFRAME ? GL_LINE : GL_FILL;
|
||||||
model_render(*model, cam->proj, cam->view, obj->transform, model->program);
|
model_render(*model, cam->proj, cam->view, obj->transform, model->program);
|
||||||
|
|
||||||
if( do_retexturing ) {
|
if( do_retexturing ) {
|
||||||
|
|
24
engine/v4k.c
24
engine/v4k.c
|
@ -20560,12 +20560,12 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model,
|
||||||
material_color.r = ((material_color_hex[0] >= 'a') ? material_color_hex[0] - 'a' + 10 : material_color_hex[0] - '0') / 15.f;
|
material_color.r = ((material_color_hex[0] >= 'a') ? material_color_hex[0] - 'a' + 10 : material_color_hex[0] - '0') / 15.f;
|
||||||
material_color.g = ((material_color_hex[1] >= 'a') ? material_color_hex[1] - 'a' + 10 : material_color_hex[1] - '0') / 15.f;
|
material_color.g = ((material_color_hex[1] >= 'a') ? material_color_hex[1] - 'a' + 10 : material_color_hex[1] - '0') / 15.f;
|
||||||
material_color.b = ((material_color_hex[2] >= 'a') ? material_color_hex[2] - 'a' + 10 : material_color_hex[2] - '0') / 15.f;
|
material_color.b = ((material_color_hex[2] >= 'a') ? material_color_hex[2] - 'a' + 10 : material_color_hex[2] - '0') / 15.f;
|
||||||
|
material_color.a = ((material_color_hex[3] >= 'a') ? material_color_hex[3] - 'a' + 10 : material_color_hex[3] - '0') / 15.f;
|
||||||
#if 0 // not enabled because of some .obj files like suzanne, with color_hex=9990 found
|
#if 0 // not enabled because of some .obj files like suzanne, with color_hex=9990 found
|
||||||
if(material_color_hex[3])
|
if(material_color_hex[3])
|
||||||
material_color.a = ((material_color_hex[3] >= 'a') ? material_color_hex[3] - 'a' + 10 : material_color_hex[3] - '0') / 15.f;
|
material_color.a = ((material_color_hex[3] >= 'a') ? material_color_hex[3] - 'a' + 10 : material_color_hex[3] - '0') / 15.f;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
material_color.a = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !material_embedded_texture ) {
|
if( !material_embedded_texture ) {
|
||||||
|
@ -20670,14 +20670,14 @@ void model_set_renderstates(model_t *m) {
|
||||||
m->rs[i] = renderstate();
|
m->rs[i] = renderstate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal pass
|
// Opaque pass
|
||||||
renderstate_t *normal_rs = &m->rs[RENDER_PASS_NORMAL];
|
renderstate_t *opaque_rs = &m->rs[RENDER_PASS_OPAQUE];
|
||||||
{
|
{
|
||||||
normal_rs->blend_enabled = 1;
|
opaque_rs->blend_enabled = 1;
|
||||||
normal_rs->blend_src = GL_SRC_ALPHA;
|
opaque_rs->blend_src = GL_SRC_ALPHA;
|
||||||
normal_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
|
opaque_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||||
normal_rs->cull_face_mode = GL_BACK;
|
opaque_rs->cull_face_mode = GL_BACK;
|
||||||
normal_rs->front_face = GL_CW;
|
opaque_rs->front_face = GL_CW;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shadow pass @todo
|
// Shadow pass @todo
|
||||||
|
@ -20982,7 +20982,7 @@ void model_draw_call(model_t m, int shader) {
|
||||||
handle old_shader = last_shader;
|
handle old_shader = last_shader;
|
||||||
shader_bind(shader);
|
shader_bind(shader);
|
||||||
|
|
||||||
renderstate_t *rs = &m.rs[RENDER_PASS_NORMAL];
|
renderstate_t *rs = &m.rs[RENDER_PASS_OPAQUE];
|
||||||
|
|
||||||
renderstate_apply(rs);
|
renderstate_apply(rs);
|
||||||
|
|
||||||
|
@ -21400,7 +21400,7 @@ void model_destroy(model_t m) {
|
||||||
FREE(q);
|
FREE(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned model_renderpass = RENDER_PASS_NORMAL;
|
static unsigned model_renderpass = RENDER_PASS_OPAQUE;
|
||||||
|
|
||||||
unsigned model_getpass() {
|
unsigned model_getpass() {
|
||||||
return model_renderpass;
|
return model_renderpass;
|
||||||
|
@ -23090,8 +23090,8 @@ void scene_render(int flags) {
|
||||||
|
|
||||||
|
|
||||||
model->billboard = obj->billboard;
|
model->billboard = obj->billboard;
|
||||||
model->rs[RENDER_PASS_NORMAL].cull_face_enabled = flags&SCENE_CULLFACE ? 1 : 0;
|
model->rs[RENDER_PASS_OPAQUE].cull_face_enabled = flags&SCENE_CULLFACE ? 1 : 0;
|
||||||
model->rs[RENDER_PASS_NORMAL].polygon_mode_draw = flags&SCENE_WIREFRAME ? GL_LINE : GL_FILL;
|
model->rs[RENDER_PASS_OPAQUE].polygon_mode_draw = flags&SCENE_WIREFRAME ? GL_LINE : GL_FILL;
|
||||||
model_render(*model, cam->proj, cam->view, obj->transform, model->program);
|
model_render(*model, cam->proj, cam->view, obj->transform, model->program);
|
||||||
|
|
||||||
if( do_retexturing ) {
|
if( do_retexturing ) {
|
||||||
|
|
|
@ -3641,7 +3641,7 @@ enum SHADING_MODE {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RENDER_PASS {
|
enum RENDER_PASS {
|
||||||
RENDER_PASS_NORMAL,
|
RENDER_PASS_OPAQUE,
|
||||||
RENDER_PASS_SHADOW,
|
RENDER_PASS_SHADOW,
|
||||||
RENDER_PASS_LIGHTMAP,
|
RENDER_PASS_LIGHTMAP,
|
||||||
|
|
||||||
|
|
BIN
tools/ark.exe
BIN
tools/ark.exe
Binary file not shown.
Binary file not shown.
|
@ -1062,6 +1062,7 @@ void export_node(FILE *out, const struct aiScene *scene, const struct aiNode *no
|
||||||
|
|
||||||
#if 1 // material colors
|
#if 1 // material colors
|
||||||
char colorbuffer[32] = {0};
|
char colorbuffer[32] = {0};
|
||||||
|
float opacity = 0.0f;
|
||||||
struct aiColor4D color;
|
struct aiColor4D color;
|
||||||
struct aiColor4D translucentColor;
|
struct aiColor4D translucentColor;
|
||||||
enum aiReturn result = AI_FAILURE, result2 = AI_FAILURE;
|
enum aiReturn result = AI_FAILURE, result2 = AI_FAILURE;
|
||||||
|
@ -1070,6 +1071,9 @@ void export_node(FILE *out, const struct aiScene *scene, const struct aiNode *no
|
||||||
result2 = aiGetMaterialColor( material, AI_MATKEY_COLOR_TRANSPARENT, &translucentColor );
|
result2 = aiGetMaterialColor( material, AI_MATKEY_COLOR_TRANSPARENT, &translucentColor );
|
||||||
if (result2 == AI_SUCCESS)
|
if (result2 == AI_SUCCESS)
|
||||||
color.a = (1.0 - translucentColor.r);
|
color.a = (1.0 - translucentColor.r);
|
||||||
|
result2 = aiGetMaterialFloat( material, AI_MATKEY_OPACITY, &opacity );
|
||||||
|
if (result2 == AI_SUCCESS)
|
||||||
|
color.a = opacity;
|
||||||
//printf("diffuse:%d, transp:%d, ", result == AI_SUCCESS, result2 == AI_SUCCESS);
|
//printf("diffuse:%d, transp:%d, ", result == AI_SUCCESS, result2 == AI_SUCCESS);
|
||||||
}
|
}
|
||||||
if( result == AI_FAILURE ) { result = aiGetMaterialColor( material, AI_MATKEY_COLOR_REFLECTIVE, &color ); /*printf("reflective:%d, ", result == AI_SUCCESS);*/ }
|
if( result == AI_FAILURE ) { result = aiGetMaterialColor( material, AI_MATKEY_COLOR_REFLECTIVE, &color ); /*printf("reflective:%d, ", result == AI_SUCCESS);*/ }
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue