Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shader-picker): new handling of shaders #259

Draft
wants to merge 20 commits into
base: develop
Choose a base branch
from

Conversation

NMC-TBone
Copy link
Contributor

@NMC-TBone NMC-TBone commented Jan 18, 2025

closes: #180 #179 #170 #214

Can potentially also solve #68 but need more info on what it should look like

NMC-TBone and others added 20 commits February 16, 2024 19:12
* fix(shader): Prevent resetting parameters in shader settings

Introduce an early return check for the shader's variation. If the selected variation is the same as the previously active one, the function exits early, preventing any unnecessary resetting of shader parameters.

Fix StjerneIdioten#180

* feat(material): New way of adding shaders

- The shaders will now be automatically loaded in a EnumProperty through the data path set in addon preferences
- This includes a operator that will migrate the old "source" property over to the new "shader" enum property (and preserve all the other shader related data)
- Made it possible to add "material_name" to the load_shader and load_shader_variation operators so it can be called through API without needing to have a active object with a active material to run the operators

* Added support to export new shader setup
Convert from the old format while loading a file instead through a manual click on an operator
Delete all the functions that save out the data as it is no longer needed
Copy link
Contributor Author

@NMC-TBone NMC-TBone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not really sure what to look after anymore haha.

The only thing that I have not included is support for custom shaders, not entirly sure where or how it should be done. In addition to that, probably 99.9% of cases in game shaders is used 😅Of course thats no reason not to include it. But yea... 🙈

def shader_getter(self):
return self.get('shader', 0)

shader: EnumProperty(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to do the same as I did for variations for the shaders as well? (search_prop)
image

@LKAMinco
Copy link
Contributor

LKAMinco commented Jan 19, 2025

I am not really sure what to look after anymore haha.

The only thing that I have not included is support for custom shaders, not entirly sure where or how it should be done. In addition to that, probably 99.9% of cases in game shaders is used 😅Of course thats no reason not to include it. But yea... 🙈

Maybe add to shader enum Custom Path entry and when it is selected, the path getter will show. + if u will not rename the variable and it still will be i3d_attributes.shader_picker.source, then even old blend files will be supported, because value is stored even when is not visible,

for the shader enum, i recommend to parse all .xml files in data/shaders file, in case Giants will add / remove some shaders.

@NMC-TBone
Copy link
Contributor Author

Maybe add to shader enum Custom Path entry and when it is selected, the path getter will show. + if u will not rename the variable and it still will be i3d_attributes.shader_picker.source, then even old blend files will be supported, because value is stored even when is not visible,

Hmm yea adding "Custom Path" entry to enum is possible, but I am not 100% sure what I think about it tbh. Might become hard to find your own "custom shader" in a list with already 50 shaders in it.
I saw @StjerneIdioten added shader_extra_paths CollectionProperty to the UI properties, which I guess is a place for users to add custom shaders paths. So in my head it might make more sense to have some kind of toggle/boolean property in the material panel to choose if you want to use game shaders or your own shaders from shader_extra_paths collection prop.

for the shader enum, i recommend to parse all .xml files in data/shaders file, in case Giants will add / remove some shaders.

populate_shader_cache will run each time you open a blender file, so that should already be covered I think 🤔

@LKAMinco
Copy link
Contributor

Maybe add to shader enum Custom Path entry and when it is selected, the path getter will show. + if u will not rename the variable and it still will be i3d_attributes.shader_picker.source, then even old blend files will be supported, because value is stored even when is not visible,

Hmm yea adding "Custom Path" entry to enum is possible, but I am not 100% sure what I think about it tbh. Might become hard to find your own "custom shader" in a list with already 50 shaders in it. I saw @StjerneIdioten added shader_extra_paths CollectionProperty to the UI properties, which I guess is a place for users to add custom shaders paths. So in my head it might make more sense to have some kind of toggle/boolean property in the material panel to choose if you want to use game shaders or your own shaders from shader_extra_paths collection prop.

for the shader enum, i recommend to parse all .xml files in data/shaders file, in case Giants will add / remove some shaders.

populate_shader_cache will run each time you open a blender file, so that should already be covered I think 🤔

You can make shader selection as searchbar, or you can manually place at second index "Custom Path", if the default is None. So it will be always on top of the enum.

@NMC-TBone
Copy link
Contributor Author

For the parameters, is there any way we could add default values, min/max values & for FS25 description to each of the parameter? 🤔

Have looked a little bit at it and it seems to not be doable through PropertyGroup properties at least ad FloatVectorProperty only support single float input for min/max anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants