Graphics: Add basic reflection mapping
This commit is contained in:
@@ -76,6 +76,7 @@ namespace Nz
|
||||
|
||||
// Other uniforms
|
||||
int eyePosition;
|
||||
int reflectionMap;
|
||||
int sceneAmbient;
|
||||
int textureOverlay;
|
||||
};
|
||||
@@ -90,6 +91,8 @@ namespace Nz
|
||||
unsigned int m_maxLightPassPerObject;
|
||||
|
||||
static IndexBuffer s_quadIndexBuffer;
|
||||
static Texture s_dummyReflection;
|
||||
static TextureSampler s_reflectionSampler;
|
||||
static TextureSampler s_shadowSampler;
|
||||
static VertexBuffer s_quadVertexBuffer;
|
||||
static VertexDeclaration s_billboardInstanceDeclaration;
|
||||
|
||||
@@ -79,6 +79,7 @@ namespace Nz
|
||||
inline void EnableDepthSorting(bool depthSorting);
|
||||
inline void EnableDepthWrite(bool depthWrite);
|
||||
inline void EnableFaceCulling(bool faceCulling);
|
||||
inline void EnableReflectionMapping(bool reflection);
|
||||
inline void EnableScissorTest(bool scissorTest);
|
||||
inline void EnableShadowCasting(bool castShadows);
|
||||
inline void EnableShadowReceive(bool receiveShadows);
|
||||
@@ -128,6 +129,7 @@ namespace Nz
|
||||
inline bool IsDepthSortingEnabled() const;
|
||||
inline bool IsDepthWriteEnabled() const;
|
||||
inline bool IsFaceCullingEnabled() const;
|
||||
inline bool IsReflectionMappingEnabled() const;
|
||||
inline bool IsScissorTestEnabled() const;
|
||||
inline bool IsStencilTestEnabled() const;
|
||||
inline bool IsShadowCastingEnabled() const;
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Nz
|
||||
/*!
|
||||
* \brief Enable/Disable alpha test for this material
|
||||
*
|
||||
* When enabled, all objects using this material will be rendered using alpha testing,
|
||||
* When enabled, all objects using this material will be rendered using alpha testing,
|
||||
* rejecting pixels if their alpha component is under a defined threshold.
|
||||
* This allows some kind of transparency with a much cheaper cost as it doesn't prevent any optimization (as deferred rendering or batching).
|
||||
*
|
||||
@@ -252,7 +252,7 @@ namespace Nz
|
||||
* When enabled, and if depth buffer is enabled and present, all fragments generated with this material will write
|
||||
* to the depth buffer if they pass depth test.
|
||||
*
|
||||
* This is usually disabled with translucent objects, as depth test is wanted to prevent them from rendering on top of opaque objects but
|
||||
* This is usually disabled with translucent objects, as depth test is wanted to prevent them from rendering on top of opaque objects but
|
||||
* not depth writing (which could make other translucent fragments to fail depth test)
|
||||
*
|
||||
* \param depthBuffer Defines if this material will use depth write
|
||||
@@ -291,6 +291,31 @@ namespace Nz
|
||||
InvalidatePipeline();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Enable/Disable reflection mapping for this material
|
||||
*
|
||||
* When enabled, the material will render reflections from the object environment according to the reflection mode.
|
||||
* Whether or not this is expensive depends of the reflection mode and size.
|
||||
*
|
||||
* Please note this is only a hint for the render technique, and reflections can be forcefully enabled or disabled depending on the material shader.
|
||||
*
|
||||
* Use SetReflectionMode and SetReflectionSize to control reflection quality.
|
||||
*
|
||||
* \param reflection Defines if this material should use reflection mapping
|
||||
*
|
||||
* \remark May invalidates the pipeline
|
||||
*
|
||||
* \see IsReflectionMappingEnabled
|
||||
* \see SetReflectionMode
|
||||
* \see SetReflectionSize
|
||||
*/
|
||||
inline void Material::EnableReflectionMapping(bool reflection)
|
||||
{
|
||||
m_pipelineInfo.reflectionMapping = reflection;
|
||||
|
||||
InvalidatePipeline();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Enable/Disable scissor test for this material
|
||||
*
|
||||
@@ -782,6 +807,17 @@ namespace Nz
|
||||
return m_pipelineInfo.faceCulling;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether this material has reflection mapping enabled
|
||||
* \return true If it is the case
|
||||
*
|
||||
* \see EnableReflectionMapping
|
||||
*/
|
||||
inline bool Material::IsReflectionMappingEnabled() const
|
||||
{
|
||||
return m_pipelineInfo.reflectionMapping;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Checks whether this material has scissor test enabled
|
||||
* \return true If it is the case
|
||||
|
||||
@@ -20,15 +20,16 @@ namespace Nz
|
||||
{
|
||||
struct MaterialPipelineInfo : RenderStates
|
||||
{
|
||||
bool alphaTest = false;
|
||||
bool depthSorting = false;
|
||||
bool hasAlphaMap = false;
|
||||
bool hasDiffuseMap = false;
|
||||
bool hasEmissiveMap = false;
|
||||
bool hasHeightMap = false;
|
||||
bool hasNormalMap = false;
|
||||
bool hasSpecularMap = false;
|
||||
bool shadowReceive = true;
|
||||
bool alphaTest = false;
|
||||
bool depthSorting = false;
|
||||
bool hasAlphaMap = false;
|
||||
bool hasDiffuseMap = false;
|
||||
bool hasEmissiveMap = false;
|
||||
bool hasHeightMap = false;
|
||||
bool hasNormalMap = false;
|
||||
bool hasSpecularMap = false;
|
||||
bool reflectionMapping = false;
|
||||
bool shadowReceive = true;
|
||||
|
||||
UberShaderConstRef uberShader;
|
||||
};
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace Nz
|
||||
NazaraPipelineBoolMember(hasHeightMap);
|
||||
NazaraPipelineBoolMember(hasNormalMap);
|
||||
NazaraPipelineBoolMember(hasSpecularMap);
|
||||
NazaraPipelineBoolMember(reflectionMapping);
|
||||
NazaraPipelineBoolMember(shadowReceive);
|
||||
|
||||
NazaraPipelineMember(uberShader);
|
||||
@@ -127,6 +128,7 @@ namespace std
|
||||
NazaraPipelineBoolMember(hasHeightMap);
|
||||
NazaraPipelineBoolMember(hasNormalMap);
|
||||
NazaraPipelineBoolMember(hasSpecularMap);
|
||||
NazaraPipelineBoolMember(reflectionMapping);
|
||||
NazaraPipelineBoolMember(shadowReceive);
|
||||
|
||||
NazaraPipelineMember(uberShader);
|
||||
|
||||
@@ -13,12 +13,14 @@ namespace Nz
|
||||
{
|
||||
class AbstractBackground;
|
||||
class AbstractViewer;
|
||||
class Texture;
|
||||
|
||||
struct SceneData
|
||||
{
|
||||
Color ambientColor;
|
||||
const AbstractBackground* background;
|
||||
const AbstractViewer* viewer;
|
||||
Texture* globalReflectionTexture;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user