Skip to content

Commit 8fb258d

Browse files
committed
update xc3_model, texture layering improvements
1 parent ba8f2af commit 8fb258d

File tree

6 files changed

+35
-9
lines changed

6 files changed

+35
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
* Added field `layers` to `OutputAssignment`.
1111
* Added type `OutputLayerAssignment`.
1212
* Added field `color_layers` to `shader_database.ShaderProgram`.
13+
* Added fields `blend_mode` and `is_fresnel` to `OutputLayerAssignment`.
14+
* Added fields `blend_mode` and `is_fresnel` to `shader_database.TextureLayer`.
15+
* Added type `shader_database.LayerBlendMode`.
1316

1417
### Changed
1518
* Changed method `ChannelAssignment.textures` to `ChannelAssignment.texture` with a single texture assignment.
19+
* Combined fields `name` and `channel` for `shader_database.TextureLayer` to a single field `value` of type `shader_database.Dependency`.
1620

1721
## 0.8.0 - 2024-08-16
1822
### Added

xc3_model_py/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ edition = "2021"
66
readme = "../README.md"
77

88
[dependencies]
9-
xc3_model = { git = "https://github.com/ScanMountGoat/xc3_lib", rev = "7a5df85" }
10-
xc3_lib = { git = "https://github.com/ScanMountGoat/xc3_lib", rev = "7a5df85" }
9+
xc3_model = { git = "https://github.com/ScanMountGoat/xc3_lib", rev = "4a021c6" }
10+
xc3_lib = { git = "https://github.com/ScanMountGoat/xc3_lib", rev = "4a021c6" }
1111
xc3_model_py_derive = { path = "../xc3_model_py_derive" }
1212
image_dds = "0.6.0"
1313
pyo3 = { version = "0.21.2", features = ["extension-module", "indexmap"] }

xc3_model_py/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use glam::Mat4;
55
use numpy::{IntoPyArray, PyArray, PyArrayMethods, PyReadonlyArrayDyn};
66
use pyo3::{create_exception, exceptions::PyException, prelude::*, types::PyList};
77
use rayon::prelude::*;
8-
use shader_database::{ShaderDatabase, ShaderProgram};
8+
use shader_database::{ShaderDatabase, ShaderProgram, LayerBlendMode};
99
use vertex::ModelBuffers;
1010
use xc3_lib::dds::DdsExt;
1111

@@ -968,6 +968,8 @@ pub struct OutputLayerAssignment {
968968
pub z: Option<ChannelAssignment>,
969969
pub w: Option<ChannelAssignment>,
970970
pub weight: Option<ChannelAssignment>,
971+
pub blend_mode: LayerBlendMode,
972+
pub is_fresnel: bool
971973
}
972974

973975
#[pyclass]

xc3_model_py/src/shader_database.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use pyo3::{
55
};
66
use smol_str::SmolStr;
77

8-
use crate::{map_py::MapPy, map_py_wrapper_impl, py_exception};
8+
use crate::{map_py::MapPy, map_py_wrapper_impl, py_exception, python_enum};
99

1010
#[pyclass]
1111
#[derive(Debug, Clone)]
@@ -120,11 +120,21 @@ pub struct AttributeDependency {
120120
#[derive(Debug, Clone, MapPy)]
121121
#[map(xc3_model::shader_database::TextureLayer)]
122122
pub struct TextureLayer {
123-
pub name: String,
124-
pub channel: Option<char>,
123+
pub value: Dependency,
125124
pub ratio: Option<Py<Dependency>>,
125+
pub blend_mode: LayerBlendMode,
126+
pub is_fresnel: bool,
126127
}
127128

129+
python_enum!(
130+
LayerBlendMode,
131+
xc3_model::shader_database::LayerBlendMode,
132+
Mix,
133+
MixRatio,
134+
Add,
135+
AddNormal
136+
);
137+
128138
// Workaround for representing Rust enums in Python.
129139
#[pymethods]
130140
impl Dependency {
@@ -197,6 +207,7 @@ pub fn shader_database(py: Python, module: &Bound<'_, PyModule>) -> PyResult<()>
197207
m.add_class::<TexCoordParams>()?;
198208
m.add_class::<AttributeDependency>()?;
199209
m.add_class::<TextureLayer>()?;
210+
m.add_class::<LayerBlendMode>()?;
200211

201212
module.add_submodule(&m)?;
202213
Ok(())

xc3_model_py/xc3_model_py/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ class OutputLayerAssignment:
497497
z: Optional[ChannelAssignment]
498498
w: Optional[ChannelAssignment]
499499
weight: Optional[ChannelAssignment]
500+
blend_mode: shader_database.LayerBlendMode
501+
is_fresnel: bool
500502

501503
class ChannelAssignment:
502504
def texture(self) -> Optional[TextureAssignment]: ...

xc3_model_py/xc3_model_py/shader_database.pyi

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, Tuple
1+
from typing import ClassVar, Optional, Tuple
22

33
class ShaderDatabase:
44
@staticmethod
@@ -54,6 +54,13 @@ class AttributeDependency:
5454
channels: str
5555

5656
class TextureLayer:
57-
name: str
58-
channel: Optional[str]
57+
value: Dependency
5958
ratio: Optional[Dependency]
59+
blend_mode: LayerBlendMode
60+
is_fresnel: bool
61+
62+
class LayerBlendMode:
63+
Mix: ClassVar[LayerBlendMode]
64+
MixRatio: ClassVar[LayerBlendMode]
65+
Add: ClassVar[LayerBlendMode]
66+
AddNormal: ClassVar[LayerBlendMode]

0 commit comments

Comments
 (0)