Open cochrane opened 3 years ago
Very rough concept for the runtime classes (names TBD):
Possible expansion if necessary:
Loading from existing scene files:
Saving scene files:
Actually not that difficult.
UI needs to be adapted for this, but having nicer UI is part of the point of all of this.
Should probably also add a way for models to specify which texture coordinate goes with which texture while we're at it.
A while back, all the shaders (for XNALara models anyway) were unified already behind the scenes. They used the same GLSL files, just with different defines activating different code paths. All the code that decides which shader to use, though, remained the same.
This should be changed to a more modular approach, where the shader features can be combined dynamically by the user, or by the app during loading. For example, right now a user can't combine metallic with emission; this should be possible.
For app-selected shaders, the key example is for OBJ files, where an object might have a diffuse, a specular and a normal texture, but all of them are optional and textureless object files are supported. Right now every combination is its own slightly different shader as far as the loading code is concerned. Instead, the code should simply be able to say that these are the parameters that are set on the file, and the app should generate the appropriate shader explicitly.
The exact design needs to be worked out, but the general idea is that in the model parameters, there are base shaders (possibly just one), which specifies the files to use; and then shader modules, which can be turned on and off, and have their own parameters and textures (perhaps also required vertex attributes - in this case the UI should disallow shaders that require nonexistent vertex attributes). The mesh then uses a combination of one base shader and an arbitrary number of associated shader modules. Shader modules may also be hierarchical (need normal map shader if you want detail bump maps).
Backwards compatibility is going to be an issue - all XNALara models must still load correctly, and old scene files must as well. Also, how will this be saved in scene files anyway?
Pre-requisite for #122 - not strictly necessarily, but it's probably a good idea.