-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
EPICGameGuy
committed
Dec 13, 2023
1 parent
d571f28
commit 5b1a6a2
Showing
15 changed files
with
105 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"mesh_file": "kettle.fbx", | ||
"primitive_type": 2147483649 | ||
"primitive_type": 2147483649, | ||
"modifiers": [ | ||
"gamma_correct_alpha" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"mesh_file": "plane.fbx", | ||
"primitive_type": 2147483649 | ||
"primitive_type": 2147483649, | ||
"modifiers": [ | ||
"gamma_correct_alpha" | ||
] | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"mesh_file": "plant.fbx", | ||
"primitive_type": 2147483650 | ||
"primitive_type": 2147483650, | ||
"modifiers": [ | ||
"vegetation", | ||
"gamma_correct_alpha" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"mesh_file": "testmap.fbx", | ||
"primitive_type": 2147483649 | ||
"primitive_type": 2147483649, | ||
"modifiers": [ | ||
"gamma_correct_alpha" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,44 @@ | ||
#include "model_modifiers.hpp" | ||
#include "utils.hpp" | ||
|
||
void apply_gamma_correction(std::vector<Mesh>& meshes) | ||
#include <cmath> | ||
|
||
static void apply_gamma_correction(Mesh& mesh) | ||
{ | ||
for (Vertex& vertex : mesh.vertices) | ||
{ | ||
//vertex.r = pow(vertex.r, 1.0 / 2.2); | ||
//vertex.g = pow(vertex.g, 1.0 / 2.2); | ||
//vertex.b = pow(vertex.b, 1.0 / 2.2); | ||
vertex.a = pow(vertex.a, 1.0 / 2.2); | ||
} | ||
} | ||
|
||
// Converts the red channel to an integer | ||
static void apply_vegetation_mod(Mesh& mesh) | ||
{ | ||
for (Vertex& vertex : mesh.vertices) | ||
{ | ||
int32_t red_value = (int)std::round(vertex.r * 255.f); | ||
vertex.r = *(reinterpret_cast<float*>(&red_value)); | ||
} | ||
} | ||
|
||
bool apply_modification(const std::string& mod, Mesh& mesh) | ||
{ | ||
for (Mesh& mesh : meshes) | ||
if (mod == "vegetation") | ||
{ | ||
for (Vertex& vertex : mesh.vertices) | ||
{ | ||
//vertex.r = pow(vertex.r, 1.0 / 2.2); | ||
//vertex.g = pow(vertex.g, 1.0 / 2.2); | ||
//vertex.b = pow(vertex.b, 1.0 / 2.2); | ||
vertex.a = pow(vertex.a, 1.0 / 2.2); | ||
} | ||
printf(ANSI_COLOR_MAGENTA "[PS2-Mesh-Converter]: Applying mesh modification: %s\n" ANSI_COLOR_RESET, "vegetation"); | ||
apply_vegetation_mod(mesh); | ||
return true; | ||
} | ||
else if (mod == "gamma_correct_alpha") | ||
{ | ||
printf(ANSI_COLOR_MAGENTA "[PS2-Mesh-Converter]: Applying mesh modification: %s\n" ANSI_COLOR_RESET, "gamma correction"); | ||
apply_gamma_correction(mesh); | ||
return true; | ||
} | ||
|
||
printf(ANSI_COLOR_RED "[PS2-Mesh-Converter]: Unable to find mesh mod: %s\n" ANSI_COLOR_RESET, mod.c_str()); | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters