mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Initial refactoring on shader usage and generation
`IShaderSource` was designed with the idea that if you want a shader, you must want it for a node. So it depends heavily on being given a tile material and the node drawtype. But this doesn't make sense neither in theory nor in practice. This commit takes a small step towards removing the incorrect abstraction.
This commit is contained in:
parent
eb8beb335e
commit
a6293b9861
14 changed files with 81 additions and 53 deletions
|
@ -196,18 +196,33 @@ using CachedStructPixelShaderSetting = CachedStructShaderSetting<T, count, cache
|
|||
|
||||
/*
|
||||
ShaderSource creates and caches shaders.
|
||||
*/
|
||||
|
||||
A "shader" could more precisely be called a "shader material" and comprises
|
||||
a vertex, fragment and optional geometry shader.
|
||||
*/
|
||||
class IShaderSource {
|
||||
public:
|
||||
IShaderSource() = default;
|
||||
virtual ~IShaderSource() = default;
|
||||
|
||||
virtual u32 getShaderIdDirect(const std::string &name,
|
||||
MaterialType material_type, NodeDrawType drawtype = NDT_NORMAL){return 0;}
|
||||
virtual ShaderInfo getShaderInfo(u32 id){return ShaderInfo();}
|
||||
/**
|
||||
* @brief returns information about an existing shader
|
||||
*
|
||||
* Use this to get the material ID to plug into `video::SMaterial`.
|
||||
*/
|
||||
virtual ShaderInfo getShaderInfo(u32 id) = 0;
|
||||
|
||||
/// @brief Generates or gets a shader suitable for nodes and entities
|
||||
virtual u32 getShader(const std::string &name,
|
||||
MaterialType material_type, NodeDrawType drawtype = NDT_NORMAL){return 0;}
|
||||
MaterialType material_type, NodeDrawType drawtype = NDT_NORMAL) = 0;
|
||||
|
||||
/**
|
||||
* Generates or gets a shader for general use.
|
||||
* @param name name of the shader (directory on disk)
|
||||
* @param blendAlpha enable alpha blending for this material?
|
||||
* @return shader ID
|
||||
*/
|
||||
virtual u32 getShaderRaw(const std::string &name, bool blendAlpha = false) = 0;
|
||||
};
|
||||
|
||||
class IWritableShaderSource : public IShaderSource {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue