mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-14 09:59:09 +03:00
Shader: total overhaul of permutations and shader flags
This commit is contained in:
+14
-20
@@ -50,7 +50,10 @@ namespace mdl {
|
||||
GL_UNSIGNED_INT,
|
||||
};
|
||||
|
||||
rctx->obj_shader.set_shader_flags(uniform_value);
|
||||
rctx->obj_shader_ubo.WriteMemory(rctx->obj_shader);
|
||||
rctx->obj_batch_ubo.WriteMemory(rctx->obj_batch);
|
||||
|
||||
if (primitive_type == OBJ_PRIMITIVE_TRIANGLE_STRIP && index_format == OBJ_INDEX_U16)
|
||||
shaders_ft.draw_range_elements(GL_TRIANGLE_STRIP,
|
||||
start, end, count, GL_UNSIGNED_SHORT, (void*)indices);
|
||||
@@ -325,7 +328,6 @@ namespace mdl {
|
||||
if (!rctx->render_manager->npr_param)
|
||||
chara = true;
|
||||
break;
|
||||
//case SHADER_FT_EYEBALL:
|
||||
case SHADER_FT_GLASEYE:
|
||||
uniform_value[U_NPR_NORMAL] = 0;
|
||||
chara = true;
|
||||
@@ -417,7 +419,6 @@ namespace mdl {
|
||||
draw_object_material_set_uniform(material, false);
|
||||
if (material->material.attrib.m.alpha_texture)
|
||||
uniform_value[U_TEXTURE_COUNT] = 0;
|
||||
rctx->obj_batch.g_texture_blend = { (float_t)uniform_value[U_TEXTURE_BLEND], 0.0f, 0.0f, 0.0f };
|
||||
shaders_ft.set(rctx->draw_state->shader_index);
|
||||
}
|
||||
|
||||
@@ -589,7 +590,7 @@ static bool draw_object_blend_set(render_context* rctx,
|
||||
}
|
||||
}
|
||||
|
||||
if (draw_object_blend_set_check_use_default_blend(shader_index)){
|
||||
if (draw_object_blend_set_check_use_default_blend(shader_index)) {
|
||||
src_blend_factor = GL_SRC_ALPHA;
|
||||
dst_blend_factor = GL_ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
@@ -602,11 +603,10 @@ static bool draw_object_blend_set(render_context* rctx,
|
||||
static bool draw_object_blend_set_check_use_default_blend(int32_t index) {
|
||||
bool use_default_blend[] = {
|
||||
false, false, true, false, true, false, false, true, true, true, false, false,
|
||||
false, true, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false, false, false, false, false, false, false, false, false, false,
|
||||
false, false, false
|
||||
false, false, false,
|
||||
};
|
||||
|
||||
if (index >= 0 && index < SHADER_FT_MAX)
|
||||
@@ -627,11 +627,8 @@ static void draw_object_chara_color_fog_set(render_context* rctx, const mdl::Obj
|
||||
|
||||
obj_material_attrib_member attrib = args->material->material.attrib.m;
|
||||
if (!attrib.no_fog && !disable_fog) {
|
||||
if (attrib.has_fog_height)
|
||||
uniform_value[U_FOG_HEIGHT] = 2 + attrib.fog_height;
|
||||
else
|
||||
uniform_value[U_FOG_HEIGHT] = 1;
|
||||
uniform_value[U_FOG] = rctx->draw_state->fog_height ? 2 : 1;
|
||||
uniform_value[U_FOG_STAGE] = attrib.has_fog_height ? (attrib.fog_height ? 3 : 2) : 1;
|
||||
uniform_value[U_FOG_CHARA] = rctx->draw_state->fog_height ? 2 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,17 +655,16 @@ static void draw_object_material_set_default(render_context* rctx, const mdl::Ob
|
||||
material->material.shader_info.get_lighting_type();
|
||||
bool disable_fog = draw_object_blend_set(rctx, args, lighting_type);
|
||||
draw_object_material_set_uniform(material, false);
|
||||
if (!rctx->draw_state->light)
|
||||
uniform_value[U_LIGHT_0] = 0;
|
||||
if (!rctx->draw_state->shadow)
|
||||
uniform_value[U_STAGE_SHADOW] = 0;
|
||||
else if (args->self_shadow)
|
||||
uniform_value[U_LIGHT_0] = 1;
|
||||
uniform_value[U_STAGE_SHADOW] = 1;
|
||||
else
|
||||
uniform_value[U_LIGHT_0] = args->sub_mesh->attrib.m.recieve_shadow ? 1 : 0;
|
||||
uniform_value[U_SHADOW] = 0;
|
||||
uniform_value[U_SELF_SHADOW] = rctx->draw_state->self_shadow ? 1 : 0;
|
||||
uniform_value[U_STAGE_SHADOW] = args->sub_mesh->attrib.m.recieve_shadow ? 1 : 0;
|
||||
uniform_value[U_CHARA_SHADOW2] = args->shadow > SHADOW_CHARA ? 1 : 0;
|
||||
uniform_value[U_CHARA_SHADOW] = rctx->draw_state->self_shadow ? 1 : 0;
|
||||
|
||||
const obj_material_texture_data* texdata = material->material.texdata;
|
||||
uniform_value[U_SHADOW] = args->shadow > SHADOW_CHARA;
|
||||
for (int32_t i = 0, j = 0; i < 8; i++, texdata++) {
|
||||
if (texdata->tex_index == -1)
|
||||
continue;
|
||||
@@ -813,10 +809,9 @@ static void draw_object_material_set_default(render_context* rctx, const mdl::Ob
|
||||
else
|
||||
shaders_ft.set(SHADER_FT_CONSTANT);
|
||||
|
||||
rctx->obj_batch.g_texture_blend = { (float_t)uniform_value[U_TEXTURE_BLEND], 0.0f, 0.0f, 0.0f };
|
||||
if (lighting_type != OBJ_MATERIAL_SHADER_LIGHTING_CONSTANT) {
|
||||
float_t material_shininess;
|
||||
if (material->material.shader.index == SHADER_FT_GLASEYE/*SHADER_FT_EYEBALL*/)
|
||||
if (material->material.shader.index == SHADER_FT_GLASEYE)
|
||||
material_shininess = 10.0f;
|
||||
else {
|
||||
material_shininess = (material->material.color.shininess - 16.0f) * (float_t)(1.0 / 112.0);
|
||||
@@ -963,7 +958,6 @@ static void draw_object_material_set_reflect(render_context* rctx, const mdl::Ob
|
||||
}
|
||||
|
||||
draw_object_material_set_uniform(material, true);
|
||||
rctx->obj_batch.g_texture_blend = { (float_t)uniform_value[U_TEXTURE_BLEND], 0.0f, 0.0f, 0.0f };
|
||||
shaders_ft.set(rctx->draw_state->shader_index);
|
||||
rctx->obj_batch.g_material_state_ambient = ambient;
|
||||
rctx->obj_batch.g_material_state_diffuse = diffuse;
|
||||
|
||||
Reference in New Issue
Block a user