mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-08 06:48:16 +03:00
3d: Apply per-instance diffuse to mesh color
SetInstanceDiffuse has two roles depending on the instance type: for directional lights it is the light color, and for meshes it is a multiplier on the mesh color. xsystem4 honored only the former. Treat inst->diffuse as color multiplier, via the diffuse_mod uniform.
This commit is contained in:
+1
-1
@@ -184,6 +184,7 @@ struct RE_instance {
|
||||
bool use_mag_speed;
|
||||
bool motion_blend;
|
||||
float motion_blend_rate;
|
||||
vec3 diffuse; // color multiplier for meshes, light color for lights
|
||||
vec3 ambient;
|
||||
vec3 column_pos;
|
||||
float column_height;
|
||||
@@ -195,7 +196,6 @@ struct RE_instance {
|
||||
|
||||
// Lights
|
||||
vec3 vec;
|
||||
vec3 diffuse;
|
||||
vec3 globe_diffuse;
|
||||
|
||||
// Private
|
||||
|
||||
@@ -818,7 +818,7 @@ struct mpr_modulation {
|
||||
struct mpr *mpr_load(uint8_t *data, size_t size, struct model *model);
|
||||
void mpr_free(struct mpr *mpr);
|
||||
void mpr_evaluate_object(const struct mpr *mpr, float frame,
|
||||
const struct RE_instance *inst, struct mpr_modulation *out);
|
||||
struct RE_instance *inst, struct mpr_modulation *out);
|
||||
void mpr_evaluate_mesh(const struct mpr_track_set *mt, float frame,
|
||||
const struct mpr_modulation *obj, struct mpr_modulation *out);
|
||||
void mpr_build_mat_tex_index(const struct model *model, const struct RE_instance *inst,
|
||||
|
||||
+3
-3
@@ -244,11 +244,11 @@ static int eval_int(const struct mpr_int_key *keys, int nr, float frame, int fal
|
||||
|
||||
// Combine inst defaults with .mpr Object-scope keyframes.
|
||||
void mpr_evaluate_object(const struct mpr *mpr, float frame,
|
||||
const struct RE_instance *inst, struct mpr_modulation *out)
|
||||
struct RE_instance *inst, struct mpr_modulation *out)
|
||||
{
|
||||
out->alpha = inst->alpha;
|
||||
glm_vec3_copy((float *)inst->ambient, out->ambient);
|
||||
glm_vec3_one(out->diffuse);
|
||||
glm_vec3_copy(inst->ambient, out->ambient);
|
||||
glm_vec3_copy(inst->diffuse, out->diffuse);
|
||||
if (!mpr)
|
||||
return;
|
||||
out->alpha *= eval_float(mpr->object.mul_alpha, mpr->object.nr_mul_alpha, frame, 1.f);
|
||||
|
||||
+2
-3
@@ -42,10 +42,9 @@ static struct RE_instance *create_instance(struct RE_plugin *plugin)
|
||||
instance->plugin = plugin;
|
||||
for (int i = 0; i < RE_NR_INSTANCE_TARGETS; i++)
|
||||
instance->target[i] = -1;
|
||||
instance->scale[0] = 1.0f;
|
||||
instance->scale[1] = 1.0f;
|
||||
instance->scale[2] = 1.0f;
|
||||
glm_vec3_one(instance->scale);
|
||||
instance->alpha = 1.0f;
|
||||
glm_vec3_one(instance->diffuse);
|
||||
instance->shadow_volume_bone_radius = 0.1f;
|
||||
instance->draw_bump = true;
|
||||
instance->fps = 30.0f;
|
||||
|
||||
Reference in New Issue
Block a user