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

Anisotropic specular #653

Merged
merged 7 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/Castor3D/Castor3D Scene.xml

Large diffs are not rendered by default.

26 changes: 9 additions & 17 deletions include/Core/Castor3D/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,19 +429,9 @@ namespace castor3d
*\param[in] lightingModelId L'ID du modèle d'éclairage.
*\param[in] backgroundModelId L'ID du modèle de fond.
*/
C3D_API void unregisterLightingModel( LightingModelID lightingModelId
, BackgroundModelID backgroundModelId )const;
/**
*\~english
*\brief Unregisters a Lighting Model.
*\param[in] name The model name.
*\param[in] backgroundModelId The background model ID.
*\~french
*\brief Désenregistre un Lighting Model.
*\param[in] name Le nom du modèle.
*\param[in] backgroundModelId L'ID du modèle de fond.
*/
C3D_API void unregisterLightingModel( castor::String const & name
C3D_API castor::Vector< LightingModelID > unregisterLightingModel( castor::String const & baseName
, castor::StringArray const & diffuseBrdfs
, castor::StringArray const & specularBrdfs
, BackgroundModelID backgroundModelId )const;
/**
*\~english
Expand Down Expand Up @@ -509,14 +499,14 @@ namespace castor3d
*\~english
*\brief Unregisters a combination of lighting model and background model.
*\param[in] backgroundModelId The background model.
*\param[in] lightingModelId The lighting model.
*\param[in] baseName The lighting model base name.
*\~french
*\brief Désenregistre une combinaison de modèle d'éclairage et de modèle de fond.
*\param[in] backgroundModelId Le modèle de fond.
*\param[in] lightingModelId Le modèle d'éclairage.
*\param[in] baseName Le nom de base modèle d'éclairage.
*/
C3D_API void unregisterPassModel( BackgroundModelID backgroundModelId
, LightingModelID lightingModelId )const;
, castor::String const & baseName )const;
/**
*\~english
*\brief Unregisters all combinations of given lighting model and background models.
Expand All @@ -525,7 +515,9 @@ namespace castor3d
*\brief Désenregistre toutes les combinaisons du modèle d'éclairage et des modèles de fond.
*\param[in] type Le nom du modèle d'éclairage.
*/
C3D_API void unregisterPassModels( castor::String const & type )const;
C3D_API void unregisterPassModels( castor::String const & baseName
, castor::StringArray const & diffuseBrdfs
, castor::StringArray const & specularBrdfs )const;
/**
*\~english
*\brief Registers a specific data shader buffer.
Expand Down
21 changes: 8 additions & 13 deletions include/Core/Castor3D/Shader/LightingModelFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace castor3d
shader::SpecularBrdfDesc defaultSpecularBrdf{};
shader::DiffuseBrdfArray diffuseBrdfs{};
shader::SpecularBrdfArray specularBrdfs{};
castor::UnorderedSet< BackgroundModelID > backgroundModels{};
};
using LightingModelCont = castor::Vector< LightingModel >;

Expand Down Expand Up @@ -77,19 +78,9 @@ namespace castor3d
*\param[in] key Le modèle d'éclairage.
*\param[in] backgroundModelId L'ID du modèle de fond.
*/
C3D_API void unregisterType( Key const & key
, BackgroundModelID backgroundModelId );
/**
*\~english
*\brief Unregisters a lighting model.
*\param[in] lightingModelId The lighting model ID.
*\param[in] backgroundModelId The background model ID.
*\~french
*\brief Désenregistre un modèle d'éclairage.
*\param[in] lightingModelId L'ID du modèle d'éclairage.
*\param[in] backgroundModelId L'ID du modèle de fond.
*/
C3D_API void unregisterType( LightingModelID lightingModelId
C3D_API castor::Vector< LightingModelID > unregisterType( castor::String const & baseName
, castor::StringArray diffuseBrdfs
, castor::StringArray specularBrdfs
, BackgroundModelID backgroundModelId );
/**
*\~english
Expand Down Expand Up @@ -223,6 +214,10 @@ namespace castor3d
, BrdfID specularBrdfId
, BackgroundModelID backgroundModelId
, Creator create );
LightingModelID unregisterType( castor::String const & baseName
, castor::String const & diffuseBrdf
, castor::String const & specularBrdf
, BackgroundModelID backgroundModelId );

private:
LightingModelID m_currentId{};
Expand Down
17 changes: 2 additions & 15 deletions include/Core/Castor3D/Shader/Shaders/GlslCookTorranceBRDF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,14 @@ namespace castor3d::shader
public:
C3D_API CookTorranceBRDF( sdw::ShaderWriter & writer
, BRDFHelpers & brdfHelpers );
C3D_API sdw::RetVec3 compute( sdw::Vec3 const & radiance
, sdw::Float const & intensity
, sdw::Float const & NdotL
, sdw::Float const & NdotH
, sdw::Float const & NdotV
, sdw::Vec3 const & F
, sdw::Float const & roughness )override;

C3D_API static SpecularBRDFUPtr create( sdw::ShaderWriter & writer
, BRDFHelpers & brdfHelpers );
C3D_API static castor::StringView constexpr Name{ cuT( "cook_torrance" ) };

private:
sdw::Function< sdw::Vec3
, sdw::InVec3
, sdw::InFloat
, sdw::InFloat
, sdw::InFloat
, sdw::InFloat
, sdw::InVec3
, sdw::InFloat > m_compute;
void doGenerate( BlendComponents const & components
, LightSurface const & lightSurface )override;
};
}

Expand Down
20 changes: 10 additions & 10 deletions include/Core/Castor3D/Shader/Shaders/GlslDiffuseBRDF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ namespace castor3d::shader
, BRDFHelpers & brdfHelpers );
C3D_API virtual ~DiffuseBRDF() = default;

C3D_API virtual sdw::RetVec3 compute( sdw::Vec3 const & radiance
C3D_API sdw::RetVec3 compute( BlendComponents const & components
, LightSurface const & lightSurface
, sdw::Vec3 const & radiance
, sdw::Float const & intensity
, sdw::Float const & NdotL
, sdw::Float const & NdotV
, sdw::Float const & LdotV
, sdw::Vec3 const & F
, sdw::Float const & roughness ) = 0;
, sdw::Float const & NdotL );

private:
virtual void doGenerate( BlendComponents const & components
, LightSurface const & lightSurface ) = 0;

protected:
sdw::ShaderWriter & m_writer;
BRDFHelpers & m_brdfHelpers;
sdw::Function< sdw::Vec3
, InBlendComponents
, InLightSurface
, sdw::InVec3
, sdw::InFloat
, sdw::InFloat
, sdw::InFloat
, sdw::InFloat
, sdw::InVec3
, sdw::InFloat > m_compute;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ namespace castor3d::shader
{
public:
C3D_API explicit GlobalIllumination( sdw::ShaderWriter & writer
, DiffuseBRDF * diffuseBrdf
, Utils & utils );
C3D_API explicit GlobalIllumination( sdw::ShaderWriter & writer
, DiffuseBRDF * diffuseBrdf
, Utils & utils
, uint32_t & bindingIndex
, uint32_t setIndex
Expand Down Expand Up @@ -104,7 +102,6 @@ namespace castor3d::shader

private:
sdw::ShaderWriter & m_writer;
DiffuseBRDF * m_diffuseBrdf;
Utils & m_utils;
sdw::Function< sdw::Vec4
, sdw::InVec3 > m_evalSH;
Expand Down
12 changes: 4 additions & 8 deletions include/Core/Castor3D/Shader/Shaders/GlslLambertianBRDF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ namespace castor3d::shader
C3D_API explicit LambertianBRDF( sdw::ShaderWriter & writer
, BRDFHelpers & brdfHelpers );

C3D_API sdw::RetVec3 compute( sdw::Vec3 const & radiance
, sdw::Float const & intensity
, sdw::Float const & NdotL
, sdw::Float const & NdotV
, sdw::Float const & LdotV
, sdw::Vec3 const & F
, sdw::Float const & roughness )override;

C3D_API static DiffuseBRDFUPtr create( sdw::ShaderWriter & writer
, BRDFHelpers & brdfHelpers );
C3D_API static castor::StringView constexpr Name{ cuT( "lambertian" ) };

private:
void doGenerate( BlendComponents const & components
, LightSurface const & lightSurface )override;
};
}

Expand Down
4 changes: 4 additions & 0 deletions include/Core/Castor3D/Shader/Shaders/GlslLightSurface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ namespace castor3d::shader
, bool enableDotProducts
, bool enableFresnel
, bool enableIridescence );
C3D_API static ast::type::BaseStructPtr makeType( ast::type::TypesCache & cache
, LightSurface const & rhs );

C3D_API static LightSurface create( sdw::ShaderWriter & writer
, castor::MbString const & name
Expand Down Expand Up @@ -94,6 +96,7 @@ namespace castor3d::shader
DerivFloat NdotL()const { return m_NdotL; }
DerivFloat NdotH()const { return m_NdotH; }
DerivFloat LdotV()const { return m_LdotV; }
DerivFloat HdotL()const { return m_HdotL; }
DerivVec3 F()const { return m_F; }
DerivVec3 spcF()const { return m_spcF; }
DerivVec3 difF()const { return m_difF; }
Expand All @@ -116,6 +119,7 @@ namespace castor3d::shader
mutable sdw::DefaultedT< DerivFloat > m_NdotH;
mutable sdw::DefaultedT< DerivFloat > m_HdotV;
mutable sdw::DefaultedT< DerivFloat > m_LdotV;
mutable sdw::DefaultedT< DerivFloat > m_HdotL;

mutable sdw::DefaultedT< DerivVec3 > m_F;
mutable sdw::DefaultedT< DerivVec3 > m_spcF;
Expand Down
36 changes: 12 additions & 24 deletions include/Core/Castor3D/Shader/Shaders/GlslOrenNayarBRDF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ namespace castor3d::shader
C3D_API QualitativeOrenNayarBRDF( sdw::ShaderWriter & writer
, BRDFHelpers & brdfHelpers );

C3D_API sdw::RetVec3 compute( sdw::Vec3 const & radiance
, sdw::Float const & intensity
, sdw::Float const & NdotL
, sdw::Float const & NdotV
, sdw::Float const & LdotV
, sdw::Vec3 const & F
, sdw::Float const & roughness )override;

C3D_API static DiffuseBRDFUPtr create( sdw::ShaderWriter & writer
, BRDFHelpers & brdfHelpers );
C3D_API static castor::StringView constexpr Name{ cuT( "qualitative_oren_nayar" ) };

private:
void doGenerate( BlendComponents const & components
, LightSurface const & lightSurface )override;
};

class FujiiOrenNayarBRDF
Expand All @@ -35,17 +31,13 @@ namespace castor3d::shader
C3D_API FujiiOrenNayarBRDF( sdw::ShaderWriter & writer
, BRDFHelpers & brdfHelpers );

C3D_API sdw::RetVec3 compute( sdw::Vec3 const & radiance
, sdw::Float const & intensity
, sdw::Float const & NdotL
, sdw::Float const & NdotV
, sdw::Float const & LdotV
, sdw::Vec3 const & F
, sdw::Float const & roughness )override;

C3D_API static DiffuseBRDFUPtr create( sdw::ShaderWriter & writer
, BRDFHelpers & brdfHelpers );
C3D_API static castor::StringView constexpr Name{ cuT( "fujii_oren_nayar" ) };

private:
void doGenerate( BlendComponents const & components
, LightSurface const & lightSurface )override;
};

class EnergyConservativeOrenNayarBRDF
Expand All @@ -55,18 +47,14 @@ namespace castor3d::shader
C3D_API EnergyConservativeOrenNayarBRDF( sdw::ShaderWriter & writer
, BRDFHelpers & brdfHelpers );

C3D_API sdw::RetVec3 compute( sdw::Vec3 const & radiance
, sdw::Float const & intensity
, sdw::Float const & NdotL
, sdw::Float const & NdotV
, sdw::Float const & LdotV
, sdw::Vec3 const & F
, sdw::Float const & roughness )override;

C3D_API static DiffuseBRDFUPtr create( sdw::ShaderWriter & writer
, BRDFHelpers & brdfHelpers );
C3D_API static castor::StringView constexpr Name{ cuT( "energy_conservative_oren_nayar" ) };

private:
void doGenerate( BlendComponents const & components
, LightSurface const & lightSurface )override;

private:
sdw::Function< sdw::Float
, sdw::InFloat
Expand Down
20 changes: 16 additions & 4 deletions include/Core/Castor3D/Shader/Shaders/GlslSpecularBRDF.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,29 @@ namespace castor3d::shader
, BRDFHelpers & brdfHelpers );
C3D_API virtual ~SpecularBRDF() = default;

C3D_API virtual sdw::RetVec3 compute( sdw::Vec3 const & radiance
C3D_API sdw::RetVec3 compute( BlendComponents const & components
, LightSurface const & lightSurface
, sdw::Vec3 const & radiance
, sdw::Float const & intensity
, sdw::Float const & NdotL
, sdw::Float const & NdotH
, sdw::Float const & NdotV
, sdw::Vec3 const & F
, sdw::Float const & roughness ) = 0;
, sdw::Float const & roughness );

private:
virtual void doGenerate( BlendComponents const & components
, LightSurface const & lightSurface ) = 0;

protected:
sdw::ShaderWriter & m_writer;
BRDFHelpers & m_brdfHelpers;
sdw::Function< sdw::Vec3
, InBlendComponents
, InLightSurface
, sdw::InVec3
, sdw::InFloat
, sdw::InFloat
, sdw::InFloat
, sdw::InFloat > m_compute;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ namespace castor3d::shader

C3D_API static sdw::Float getFloat( sdw::Vec4 const & sampled
, sdw::UInt const & mask );
C3D_API static sdw::Vec2 getVec2( sdw::Vec4 const & sampled
, sdw::UInt const & mask );
C3D_API static sdw::Vec3 getVec3( sdw::Vec4 const & sampled
, sdw::UInt const & mask );

Expand Down
Loading
Loading