MaterialShading
The MaterialShading class implements a user-defined material with detailed control over rendering passes.
It is fully defined by a *.shading
file that contains per-pass shading and geometry transformation source code.
Callbacks can be assigned to provide custom parameters to the pipeline and kernel during rendering.
#include <scene/TellusimMaterialShading.h>
Inheritance
- Inherits from MaterialRoot
Constructors
explicit MaterialShading(const char *name = nullptr)
explicit MaterialShading(Scene &scene, const char *name = nullptr)
Methods
Shading file name.
void setShadingName(const char *name)
void setShadingName(const String &name)
String getShadingName() const
Shading source.
void setShadingSource(const String &src)
String getShadingSource() const
Load material shading.
bool load(const char *name, bool reload = false)
bool load(const String &name, bool reload = false)
Create material shading.
bool create(const String &src, bool reload = false)
Vertex texture access.
void setVertexTexture(bool enable)
bool getVertexTexture() const
Material fill mode.
void setFillMode(FillMode mode)
FillMode getFillMode() const
void setFillMode(Pass pass, FillMode mode)
FillMode getFillMode(Pass pass) const
Material cull mode.
void setCullMode(CullMode mode)
CullMode getCullMode() const
void setCullMode(Pass pass, CullMode mode)
CullMode getCullMode(Pass pass) const
Material blend function.
void setBlend(BlendOp op, BlendFunc src, BlendFunc dest)
BlendOp getBlendOp() const
BlendFunc getBlendSrcFunc() const
BlendFunc getBlendDestFunc() const
void setBlend(Pass pass, BlendOp op, BlendFunc src, BlendFunc dest)
BlendOp getBlendOp(Pass pass) const
BlendFunc getBlendSrcFunc(Pass pass) const
BlendFunc getBlendDestFunc(Pass pass) const
Material color mask.
void setColorMask(ColorMask mask)
ColorMask getColorMask() const
void setColorMask(Pass pass, ColorMask mask)
ColorMask getColorMask(Pass pass) const
Material normal mask.
void setNormalMask(ColorMask mask)
ColorMask getNormalMask() const
Material diffuse mask.
void setDiffuseMask(ColorMask mask)
ColorMask getDiffuseMask() const
Material metallic mask.
void setMetallicMask(ColorMask mask)
ColorMask getMetallicMask() const
Material auxiliary mask.
void setAuxiliaryMask(ColorMask mask)
ColorMask getAuxiliaryMask() const
Material motion mask.
void setMotionMask(ColorMask mask)
ColorMask getMotionMask() const
Material depth mask.
void setDepthMask(DepthMask mask)
DepthMask getDepthMask() const
void setDepthMask(Pass pass, DepthMask mask)
DepthMask getDepthMask(Pass pass) const
Material depth function.
void setDepthFunc(DepthFunc func)
DepthFunc getDepthFunc() const
void setDepthFunc(Pass pass, DepthFunc func)
DepthFunc getDepthFunc(Pass pass) const
Material depth bias.
void setDepthBias(float32_t bias, float32_t slope, float32_t clamp = 0.0f)
float32_t getDepthBias() const
float32_t getDepthSlope() const
float32_t getDepthClamp() const
void setDepthBias(Pass pass, float32_t bias, float32_t slope, float32_t clamp = 0.0f)
float32_t getDepthBias(Pass pass) const
float32_t getDepthSlope(Pass pass) const
float32_t getDepthClamp(Pass pass) const
Material depth function.
void setDepthReplace(bool enable)
bool getDepthReplace() const
void setDepthReplace(Pass pass, bool enable)
bool getDepthReplace(Pass pass) const
Material stencil parameters.
void setStencilRef(Pass pass, uint32_t ref)
void setStencilMask(Pass pass, uint32_t mask)
void setStencilFunc(Pass pass, StencilFunc func, StencilOp dpass_op)
void setStencilFunc(Pass pass, StencilFunc func, StencilOp fail_op, StencilOp dfail_op, StencilOp dpass_op)
uint32_t getStencilRef(Pass pass) const
uint32_t getStencilMask(Pass pass) const
StencilFunc getStencilFunc(Pass pass) const
StencilOp getStencilFailOp(Pass pass) const
StencilOp getStencilDepthFailOp(Pass pass) const
StencilOp getStencilDepthPassOp(Pass pass) const
Material samplers.
void reserveSamplers(uint32_t num_samplers)
uint32_t addSampler(const char *name, Mask mask = Shader::MaskFragment, const char *layout = nullptr, bool check = true)
uint32_t findSampler(const String &name) const
uint32_t findSampler(const char *name) const
uint32_t getNumSamplers() const
String getSamplerName(uint32_t index) const
Mask getSamplerMask(uint32_t index) const
String getSamplerLayout(uint32_t index) const
String getSamplerLayout(uint32_t index, const char *name) const
bool hasSamplerLayout(uint32_t index, const char *name) const
void setSampler(uint32_t index, Filter filter, WrapMode wrap_mode = Sampler::WrapModeRepeat)
void setSampler(uint32_t index, Sampler &sampler, bool owner = false)
Filter getSamplerFilter(uint32_t index) const
WrapMode getSamplerWrapMode(uint32_t index) const
Sampler getSampler(uint32_t index) const
void setSampler(const char *name, Filter filter, WrapMode wrap_mode = Sampler::WrapModeRepeat)
void setSampler(const char *name, Sampler &sampler, bool owner = false)
Filter getSamplerFilter(const char *name) const
WrapMode getSamplerWrapMode(const char *name) const
Sampler getSampler(const char *name) const
Material shading textures.
void reserveShadingTextures(uint32_t num_textures)
uint32_t addShadingTexture(const char *name, Mask mask = Shader::MaskFragment, const char *layout = nullptr, bool check = true)
uint32_t findShadingTexture(const String &name) const
uint32_t findShadingTexture(const char *name) const
uint32_t getNumShadingTextures() const
String getShadingTextureName(uint32_t index) const
Mask getShadingTextureMask(uint32_t index) const
String getShadingTextureLayout(uint32_t index) const
String getShadingTextureLayout(uint32_t index, const char *name) const
bool hasShadingTextureLayout(uint32_t index, const char *name) const
void setShadingTexture(uint32_t index, const char *file, bool force = false)
void setShadingTexture(uint32_t index, Texture &texture, bool owner = false)
String getShadingTextureFile(uint32_t index) const
Texture getShadingTexture(uint32_t index) const
void setShadingTexture(const char *name, const char *file, bool force = false)
void setShadingTexture(const char *name, Texture &texture, bool owner = false)
String getShadingTextureFile(const char *name) const
Texture getShadingTexture(const char *name) const
Global shader source.
void setGlobalSource(Pass pass, const String &src)
String getGlobalSource(Pass pass) const
Interface shader source.
void setInterfaceSource(Pass pass, const String &src)
String getInterfaceSource(Pass pass) const
Vertex shader source.
void setVertexSource(Pass pass, const String &src)
String getVertexSource(Pass pass) const
Varying shader source.
void setVaryingSource(Pass pass, const String &src)
String getVaryingSource(Pass pass) const
Fragment shader source.
void setFragmentSource(Pass pass, const String &src)
String getFragmentSource(Pass pass) const
Tracing shader source.
void setTracingSource(Pass pass, const String &src)
String getTracingSource(Pass pass) const
Begin program callback.
void setBeginProgramCallback(const BeginProgramCallback &func)
BeginProgramCallback getBeginProgramCallback() const
Create kernel callback.
void setCreateKernelCallback(const CreateKernelCallback &func)
CreateKernelCallback getCreateKernelCallback() const
Bind kernel callback.
void setBindKernelCallback(const BindKernelCallback &func)
BindKernelCallback getBindKernelCallback() const
Create pipeline callback.
void setCreatePipelineCallback(const CreatePipelineCallback &func)
CreatePipelineCallback getCreatePipelineCallback() const
Bind pipeline callback.
void setBindPipelineCallback(const BindPipelineCallback &func)
BindPipelineCallback getBindPipelineCallback() const
Types
using BeginProgramCallback = Function<bool(const Device device, RenderFrame frame, Object::Type type, Pass pass, Mode mode, uint32_t index)>
using CreateKernelCallback = Function<bool(const Device device, Kernel kernel, Object::Type type, Pass pass, uint32_t hash)>
using BindKernelCallback = Function<bool(Compute compute, RenderFrame frame, Kernel kernel, Object::Type type, Pass pass, uint32_t hash)>
using CreatePipelineCallback = Function<bool(const Device device, Pipeline pipeline, Object::Type type, Pass pass, uint32_t hash)>
using BindPipelineCallback = Function<bool(Command command, RenderFrame frame, Pipeline pipeline, Object::Type type, Pass pass, uint32_t hash)>