mirror of https://github.com/sm64pc/sm64pc.git
Rework logic of how material mods are applied.
This commit is contained in:
parent
58f28e45e5
commit
179193f0d5
|
@ -1360,31 +1360,42 @@ static void gfx_rt64_rapi_apply_mod(RT64_MATERIAL *material, RT64_TEXTURE **norm
|
|||
}
|
||||
|
||||
static void gfx_rt64_rapi_draw_triangles_common(RT64_MATRIX4 transform, float buf_vbo[], size_t buf_vbo_len, size_t buf_vbo_num_tris, bool raytrace) {
|
||||
RT64_MATERIAL material;
|
||||
RT64_INSTANCE *instance = gfx_rt64_rapi_add_instance();
|
||||
RT64_MESH *mesh = gfx_rt64_rapi_process_mesh(buf_vbo, buf_vbo_len, buf_vbo_num_tris, raytrace);
|
||||
RT64_TEXTURE *diffuseMapTexture = RT64.blankTexture;
|
||||
RT64_TEXTURE *normalMapTexture = nullptr;
|
||||
if (RT64.graphNodeMod != nullptr) {
|
||||
gfx_rt64_rapi_apply_mod(&material, &normalMapTexture, RT64.graphNodeMod, transform);
|
||||
}
|
||||
RecordedMod *textureMod = nullptr;
|
||||
bool linearFilter = false;
|
||||
uint32_t cms = 0, cmt = 0;
|
||||
|
||||
// Find all parameters associated to the texture if it's used.
|
||||
if (RT64.shaderProgram->used_textures[0]) {
|
||||
RecordedTexture &recordedTexture = RT64.textures[RT64.currentTextureIds[RT64.currentTile]];
|
||||
material = gfx_rt64_rapi_build_material(RT64.shaderProgram, RT64.background, recordedTexture.linearFilter, recordedTexture.cms, recordedTexture.cmt);
|
||||
linearFilter = recordedTexture.linearFilter;
|
||||
cms = recordedTexture.cms;
|
||||
cmt = recordedTexture.cmt;
|
||||
|
||||
if (recordedTexture.texture != nullptr) {
|
||||
diffuseMapTexture = recordedTexture.texture;
|
||||
}
|
||||
|
||||
auto texModIt = RT64.texMods.find(recordedTexture.hash);
|
||||
if (texModIt != RT64.texMods.end()) {
|
||||
gfx_rt64_rapi_apply_mod(&material, &normalMapTexture, texModIt->second, transform);
|
||||
textureMod = texModIt->second;
|
||||
}
|
||||
}
|
||||
else {
|
||||
material = gfx_rt64_rapi_build_material(RT64.shaderProgram, RT64.background, 0, 0, 0);
|
||||
|
||||
// Build material with applied mods.
|
||||
RT64_MATERIAL material = gfx_rt64_rapi_build_material(RT64.shaderProgram, RT64.background, linearFilter, cms, cmt);
|
||||
if (RT64.graphNodeMod != nullptr) {
|
||||
gfx_rt64_rapi_apply_mod(&material, &normalMapTexture, RT64.graphNodeMod, transform);
|
||||
}
|
||||
|
||||
if (textureMod != nullptr) {
|
||||
gfx_rt64_rapi_apply_mod(&material, &normalMapTexture, textureMod, transform);
|
||||
}
|
||||
|
||||
// Create the instance and process the mesh that corresponds to the VBO.
|
||||
RT64_INSTANCE *instance = gfx_rt64_rapi_add_instance();
|
||||
RT64_MESH *mesh = gfx_rt64_rapi_process_mesh(buf_vbo, buf_vbo_len, buf_vbo_num_tris, raytrace);
|
||||
RT64.lib.SetInstance(instance, mesh, transform, diffuseMapTexture, normalMapTexture, material);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue