tools: ass2iqe opacity key support

main
Dominik Madarász 2024-08-23 18:24:24 +02:00
parent 89a09f127a
commit 770f8be8f1
12 changed files with 44 additions and 40 deletions

View File

@ -1327,7 +1327,7 @@ enum SHADING_MODE {
SHADING_PBR,
};
enum RENDER_PASS {
RENDER_PASS_NORMAL,
RENDER_PASS_OPAQUE,
RENDER_PASS_SHADOW,
RENDER_PASS_LIGHTMAP,
NUM_RENDER_PASSES

View File

@ -17574,7 +17574,7 @@ enum SHADING_MODE {
};
enum RENDER_PASS {
RENDER_PASS_NORMAL,
RENDER_PASS_OPAQUE,
RENDER_PASS_SHADOW,
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.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.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(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;
else
#endif
material_color.a = 1;
}
if( !material_embedded_texture ) {
@ -385501,14 +385501,14 @@ void model_set_renderstates(model_t *m) {
m->rs[i] = renderstate();
}
// Normal pass
renderstate_t *normal_rs = &m->rs[RENDER_PASS_NORMAL];
// Opaque pass
renderstate_t *opaque_rs = &m->rs[RENDER_PASS_OPAQUE];
{
normal_rs->blend_enabled = 1;
normal_rs->blend_src = GL_SRC_ALPHA;
normal_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
normal_rs->cull_face_mode = GL_BACK;
normal_rs->front_face = GL_CW;
opaque_rs->blend_enabled = 1;
opaque_rs->blend_src = GL_SRC_ALPHA;
opaque_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
opaque_rs->cull_face_mode = GL_BACK;
opaque_rs->front_face = GL_CW;
}
// Shadow pass @todo
@ -385813,7 +385813,7 @@ void model_draw_call(model_t m, int shader) {
handle old_shader = last_shader;
shader_bind(shader);
renderstate_t *rs = &m.rs[RENDER_PASS_NORMAL];
renderstate_t *rs = &m.rs[RENDER_PASS_OPAQUE];
renderstate_apply(rs);
@ -386231,7 +386231,7 @@ void model_destroy(model_t m) {
FREE(q);
}
static unsigned model_renderpass = RENDER_PASS_NORMAL;
static unsigned model_renderpass = RENDER_PASS_OPAQUE;
unsigned model_getpass() {
return model_renderpass;
@ -387921,8 +387921,8 @@ void scene_render(int flags) {
model->billboard = obj->billboard;
model->rs[RENDER_PASS_NORMAL].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].cull_face_enabled = flags&SCENE_CULLFACE ? 1 : 0;
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);
if( do_retexturing ) {

View File

@ -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.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.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(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;
else
#endif
material_color.a = 1;
}
if( !material_embedded_texture ) {
@ -3885,14 +3885,14 @@ void model_set_renderstates(model_t *m) {
m->rs[i] = renderstate();
}
// Normal pass
renderstate_t *normal_rs = &m->rs[RENDER_PASS_NORMAL];
// Opaque pass
renderstate_t *opaque_rs = &m->rs[RENDER_PASS_OPAQUE];
{
normal_rs->blend_enabled = 1;
normal_rs->blend_src = GL_SRC_ALPHA;
normal_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
normal_rs->cull_face_mode = GL_BACK;
normal_rs->front_face = GL_CW;
opaque_rs->blend_enabled = 1;
opaque_rs->blend_src = GL_SRC_ALPHA;
opaque_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
opaque_rs->cull_face_mode = GL_BACK;
opaque_rs->front_face = GL_CW;
}
// Shadow pass @todo
@ -4197,7 +4197,7 @@ void model_draw_call(model_t m, int shader) {
handle old_shader = last_shader;
shader_bind(shader);
renderstate_t *rs = &m.rs[RENDER_PASS_NORMAL];
renderstate_t *rs = &m.rs[RENDER_PASS_OPAQUE];
renderstate_apply(rs);
@ -4615,7 +4615,7 @@ void model_destroy(model_t m) {
FREE(q);
}
static unsigned model_renderpass = RENDER_PASS_NORMAL;
static unsigned model_renderpass = RENDER_PASS_OPAQUE;
unsigned model_getpass() {
return model_renderpass;

View File

@ -607,7 +607,7 @@ enum SHADING_MODE {
};
enum RENDER_PASS {
RENDER_PASS_NORMAL,
RENDER_PASS_OPAQUE,
RENDER_PASS_SHADOW,
RENDER_PASS_LIGHTMAP,

View File

@ -564,8 +564,8 @@ void scene_render(int flags) {
model->billboard = obj->billboard;
model->rs[RENDER_PASS_NORMAL].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].cull_face_enabled = flags&SCENE_CULLFACE ? 1 : 0;
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);
if( do_retexturing ) {

View File

@ -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.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.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(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;
else
#endif
material_color.a = 1;
}
if( !material_embedded_texture ) {
@ -20670,14 +20670,14 @@ void model_set_renderstates(model_t *m) {
m->rs[i] = renderstate();
}
// Normal pass
renderstate_t *normal_rs = &m->rs[RENDER_PASS_NORMAL];
// Opaque pass
renderstate_t *opaque_rs = &m->rs[RENDER_PASS_OPAQUE];
{
normal_rs->blend_enabled = 1;
normal_rs->blend_src = GL_SRC_ALPHA;
normal_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
normal_rs->cull_face_mode = GL_BACK;
normal_rs->front_face = GL_CW;
opaque_rs->blend_enabled = 1;
opaque_rs->blend_src = GL_SRC_ALPHA;
opaque_rs->blend_dst = GL_ONE_MINUS_SRC_ALPHA;
opaque_rs->cull_face_mode = GL_BACK;
opaque_rs->front_face = GL_CW;
}
// Shadow pass @todo
@ -20982,7 +20982,7 @@ void model_draw_call(model_t m, int shader) {
handle old_shader = last_shader;
shader_bind(shader);
renderstate_t *rs = &m.rs[RENDER_PASS_NORMAL];
renderstate_t *rs = &m.rs[RENDER_PASS_OPAQUE];
renderstate_apply(rs);
@ -21400,7 +21400,7 @@ void model_destroy(model_t m) {
FREE(q);
}
static unsigned model_renderpass = RENDER_PASS_NORMAL;
static unsigned model_renderpass = RENDER_PASS_OPAQUE;
unsigned model_getpass() {
return model_renderpass;
@ -23090,8 +23090,8 @@ void scene_render(int flags) {
model->billboard = obj->billboard;
model->rs[RENDER_PASS_NORMAL].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].cull_face_enabled = flags&SCENE_CULLFACE ? 1 : 0;
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);
if( do_retexturing ) {

View File

@ -3641,7 +3641,7 @@ enum SHADING_MODE {
};
enum RENDER_PASS {
RENDER_PASS_NORMAL,
RENDER_PASS_OPAQUE,
RENDER_PASS_SHADOW,
RENDER_PASS_LIGHTMAP,

Binary file not shown.

Binary file not shown.

View File

@ -1062,6 +1062,7 @@ void export_node(FILE *out, const struct aiScene *scene, const struct aiNode *no
#if 1 // material colors
char colorbuffer[32] = {0};
float opacity = 0.0f;
struct aiColor4D color;
struct aiColor4D translucentColor;
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 );
if (result2 == AI_SUCCESS)
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);
}
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.