Merge remote-tracking branch 'refs/remotes/origin/master' into culling

This commit is contained in:
Lynix
2016-10-12 16:51:18 +02:00
95 changed files with 2139 additions and 348 deletions

View File

@@ -38,19 +38,25 @@ namespace Nz
shader->SendVector(uniforms.locations.factors + uniformOffset, Vector2f(light.ambientFactor, light.diffuseFactor));
shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.direction));
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
if (uniforms.locations.shadowMapping != -1)
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
if (light.shadowMap)
{
Renderer::SetTexture(availableTextureUnit, light.shadowMap);
Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler);
shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix);
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit);
if (uniforms.locations.lightViewProjMatrix != -1)
shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix);
if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit);
}
else
else if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
break;
}
@@ -63,18 +69,22 @@ namespace Nz
shader->SendVector(uniforms.locations.parameters1 + uniformOffset, Vector4f(light.position, light.attenuation));
shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(0.f, 0.f, 0.f, light.invRadius));
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
if (uniforms.locations.shadowMapping != -1)
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
if (light.shadowMap)
{
Renderer::SetTexture(availableTextureUnit, light.shadowMap);
Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler);
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, availableTextureUnit);
if (uniforms.locations.pointLightShadowMap != -1)
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, availableTextureUnit);
}
else
else if (uniforms.locations.pointLightShadowMap != -1)
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
break;
}
@@ -88,19 +98,25 @@ namespace Nz
shader->SendVector(uniforms.locations.parameters2 + uniformOffset, Vector4f(light.direction, light.invRadius));
shader->SendVector(uniforms.locations.parameters3 + uniformOffset, Vector2f(light.innerAngleCosine, light.outerAngleCosine));
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
if (uniforms.locations.shadowMapping != -1)
shader->SendBoolean(uniforms.locations.shadowMapping + uniformOffset, light.shadowMap != nullptr);
if (light.shadowMap)
{
Renderer::SetTexture(availableTextureUnit, light.shadowMap);
Renderer::SetTextureSampler(availableTextureUnit, s_shadowSampler);
shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix);
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit);
if (uniforms.locations.lightViewProjMatrix != -1)
shader->SendMatrix(uniforms.locations.lightViewProjMatrix + index, light.transformMatrix);
if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, availableTextureUnit);
}
else
else if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
if (uniforms.locations.pointLightShadowMap != -1)
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
break;
}
@@ -108,9 +124,14 @@ namespace Nz
}
else
{
shader->SendInteger(uniforms.locations.type + uniformOffset, -1); //< Disable the light in the shader
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
if (uniforms.locations.type != -1)
shader->SendInteger(uniforms.locations.type + uniformOffset, -1); //< Disable the light in the shader
if (uniforms.locations.directionalSpotLightShadowMap != -1)
shader->SendInteger(uniforms.locations.directionalSpotLightShadowMap + index, dummyTexture);
if (uniforms.locations.pointLightShadowMap != -1)
shader->SendInteger(uniforms.locations.pointLightShadowMap + index, dummyCubemap);
}
}

View File

@@ -17,6 +17,7 @@ namespace Nz
struct ParticleStruct_Billboard
{
Color color;
Vector2f size;
Vector3f normal;
Vector3f position;
Vector3f velocity;

View File

@@ -41,6 +41,8 @@ namespace Nz
inline void DisableTiles();
inline void DisableTiles(const Vector2ui* tilesPos, std::size_t tileCount);
inline void EnableIsometricMode(bool isometric);
inline void EnableTile(const Vector2ui& tilePos, const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U);
inline void EnableTile(const Vector2ui& tilePos, const Rectui& rect, const Color& color = Color::White, std::size_t materialIndex = 0U);
inline void EnableTiles(const Rectf& coords, const Color& color = Color::White, std::size_t materialIndex = 0U);
@@ -55,6 +57,8 @@ namespace Nz
inline const Tile& GetTile(const Vector2ui& tilePos) const;
inline const Vector2f& GetTileSize() const;
inline bool IsIsometricModeEnabled() const;
inline void SetMaterial(std::size_t index, MaterialRef material);
inline TileMap& operator=(const TileMap& TileMap);
@@ -87,6 +91,7 @@ namespace Nz
std::vector<Layer> m_layers;
Vector2ui m_mapSize;
Vector2f m_tileSize;
bool m_isometricModeEnabled;
static TileMapLibrary::LibraryMap s_library;
};

View File

@@ -25,7 +25,8 @@ namespace Nz
m_tiles(mapSize.x * mapSize.y),
m_layers(materialCount),
m_mapSize(mapSize),
m_tileSize(tileSize)
m_tileSize(tileSize),
m_isometricModeEnabled(false)
{
NazaraAssert(m_tiles.size() != 0U, "Invalid map size");
NazaraAssert(m_tileSize.x != 0U && m_tileSize.y != 0U, "Invalid tile size");
@@ -108,6 +109,22 @@ namespace Nz
InvalidateInstanceData(invalidatedLayers);
}
/*!
* \brief Enable/Disable isometric mode
*
* If enabled, every odd line will overlap by half the tile size with the upper line
*
* \param isometric Should the isometric mode be enabled for this TileMap
*
* \see IsIsometricModeEnabled
*/
inline void TileMap::EnableIsometricMode(bool isometric)
{
m_isometricModeEnabled = isometric;
InvalidateInstanceData(0xFFFFFFFF);
}
/*!
* \brief Enable and sets the tile at position tilePos
*
@@ -387,6 +404,17 @@ namespace Nz
return m_tileSize;
}
/*!
* \brief Gets the actual state of the isometric mode
* \return True if the isometric mode is enabled
*
* \see EnableIsometricMode
*/
inline bool TileMap::IsIsometricModeEnabled() const
{
return m_isometricModeEnabled;
}
/*!
* \brief Sets a material of the TileMap
*