Renderer/ShaderAst: Add Sample2D
This commit is contained in:
@@ -40,6 +40,7 @@ namespace Nz
|
||||
void Write(const ShaderAst::ExpressionStatement& node) override;
|
||||
void Write(const ShaderAst::NamedVariable& node) override;
|
||||
void Write(const ShaderAst::NodePtr& node) override;
|
||||
void Write(const ShaderAst::Sample2D& node) override;
|
||||
void Write(const ShaderAst::StatementBlock& node) override;
|
||||
void Write(const ShaderAst::SwizzleOp& node) override;
|
||||
|
||||
|
||||
@@ -42,12 +42,13 @@ namespace Nz
|
||||
|
||||
enum class ExpressionType
|
||||
{
|
||||
Boolean, // bool
|
||||
Float1, // float
|
||||
Float2, // vec2
|
||||
Float3, // vec3
|
||||
Float4, // vec4
|
||||
Mat4x4, // mat4
|
||||
Boolean, // bool
|
||||
Float1, // float
|
||||
Float2, // vec2
|
||||
Float3, // vec3
|
||||
Float4, // vec4
|
||||
Mat4x4, // mat4
|
||||
Sampler2D, // sampler2D
|
||||
|
||||
Void // void
|
||||
};
|
||||
@@ -284,6 +285,21 @@ namespace Nz
|
||||
std::size_t componentCount;
|
||||
ExpressionPtr expression;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class NAZARA_RENDERER_API Sample2D : public Expression
|
||||
{
|
||||
public:
|
||||
inline Sample2D(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr);
|
||||
|
||||
ExpressionType GetExpressionType() const override;
|
||||
void Register(ShaderWriter& visitor) override;
|
||||
void Visit(ShaderWriter& visitor) override;
|
||||
|
||||
ExpressionPtr sampler;
|
||||
ExpressionPtr coordinates;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/ShaderAst.hpp>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -225,6 +226,17 @@ namespace Nz
|
||||
|
||||
std::copy(swizzleComponents.begin(), swizzleComponents.end(), components.begin());
|
||||
}
|
||||
|
||||
inline Sample2D::Sample2D(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr) :
|
||||
sampler(std::move(samplerPtr)),
|
||||
coordinates(std::move(coordinatesPtr))
|
||||
{
|
||||
if (sampler->GetExpressionType() != ExpressionType::Sampler2D)
|
||||
throw std::runtime_error("Sampler must be a Sampler2D");
|
||||
|
||||
if (coordinates->GetExpressionType() != ExpressionType::Float2)
|
||||
throw std::runtime_error("Coordinates must be a Float2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace Nz { namespace ShaderBuilder
|
||||
constexpr BinOpBuilder<ShaderAst::BinaryType::Multiply> Multiply;
|
||||
constexpr VarBuilder<ShaderAst::VariableType::Output> Output;
|
||||
constexpr VarBuilder<ShaderAst::VariableType::Parameter> Parameter;
|
||||
constexpr GenBuilder<ShaderAst::Sample2D> Sample2D;
|
||||
constexpr GenBuilder<ShaderAst::SwizzleOp> Swizzle;
|
||||
constexpr BinOpBuilder<ShaderAst::BinaryType::Substract> Substract;
|
||||
constexpr VarBuilder<ShaderAst::VariableType::Uniform> Uniform;
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Nz
|
||||
virtual void Write(const ShaderAst::ExpressionStatement& node) = 0;
|
||||
virtual void Write(const ShaderAst::NamedVariable& node) = 0;
|
||||
virtual void Write(const ShaderAst::NodePtr& node) = 0;
|
||||
virtual void Write(const ShaderAst::Sample2D& node) = 0;
|
||||
virtual void Write(const ShaderAst::StatementBlock& node) = 0;
|
||||
virtual void Write(const ShaderAst::SwizzleOp& node) = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user