Refactored background, cloud and planet rendering, fixed shadow settings
parent
e76c00c7f4
commit
9a07c1d858
|
@ -165,6 +165,10 @@ public:
|
||||||
//! Sets alpha scissor
|
//! Sets alpha scissor
|
||||||
virtual void SetAlphaScissor(float alpha) = 0;
|
virtual void SetAlphaScissor(float alpha) = 0;
|
||||||
|
|
||||||
|
//! Sets depth test
|
||||||
|
virtual void SetDepthTest(bool enabled) = 0;
|
||||||
|
//! Sets depth mask
|
||||||
|
virtual void SetDepthMask(bool enabled) = 0;
|
||||||
//! Sets cull mode
|
//! Sets cull mode
|
||||||
virtual void SetCullMode(bool enabled) = 0;
|
virtual void SetCullMode(bool enabled) = 0;
|
||||||
//! Sets transparency mode
|
//! Sets transparency mode
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "graphics/engine/cloud.h"
|
#include "graphics/engine/cloud.h"
|
||||||
|
|
||||||
#include "graphics/core/device.h"
|
#include "graphics/core/device.h"
|
||||||
|
#include "graphics/core/renderers.h"
|
||||||
|
|
||||||
#include "graphics/engine/engine.h"
|
#include "graphics/engine/engine.h"
|
||||||
#include "graphics/engine/terrain.h"
|
#include "graphics/engine/terrain.h"
|
||||||
|
@ -110,25 +111,26 @@ void CCloud::Draw()
|
||||||
float fogEnd = deep*0.24f;
|
float fogEnd = deep*0.24f;
|
||||||
|
|
||||||
CDevice* device = m_engine->GetDevice();
|
CDevice* device = m_engine->GetDevice();
|
||||||
|
auto renderer = device->GetObjectRenderer();
|
||||||
|
renderer->Begin();
|
||||||
|
|
||||||
// TODO: do this better?
|
auto fogColor = m_engine->GetFogColor(m_engine->GetRankView());
|
||||||
device->SetFogParams(FOG_LINEAR, m_engine->GetFogColor( m_engine->GetRankView() ),
|
|
||||||
fogStart, fogEnd, 1.0f);
|
|
||||||
|
|
||||||
device->SetTransform(TRANSFORM_VIEW, m_engine->GetMatView());
|
renderer->SetFog(fogStart, fogEnd, { fogColor.r, fogColor.g, fogColor.b });
|
||||||
|
|
||||||
Material material;
|
renderer->SetProjectionMatrix(m_engine->GetMatProj());
|
||||||
material.diffuse = m_diffuse;
|
renderer->SetViewMatrix(m_engine->GetMatView());
|
||||||
material.ambient = m_ambient;
|
|
||||||
m_engine->SetMaterial(material);
|
|
||||||
|
|
||||||
m_engine->SetTexture(m_fileName, 0);
|
auto texture = m_engine->LoadTexture(m_fileName);
|
||||||
m_engine->SetTexture(m_fileName, 1);
|
renderer->SetPrimaryTexture(texture);
|
||||||
|
renderer->SetSecondaryTexture(Texture{});
|
||||||
|
|
||||||
m_engine->SetState(ENG_RSTATE_TTEXTURE_BLACK | ENG_RSTATE_FOG | ENG_RSTATE_WRAP);
|
renderer->SetLighting(false);
|
||||||
|
renderer->SetTransparency(TransparencyMode::BLACK);
|
||||||
|
renderer->SetDepthMask(false);
|
||||||
|
|
||||||
glm::mat4 matrix = glm::mat4(1.0f);
|
glm::mat4 matrix = glm::mat4(1.0f);
|
||||||
device->SetTransform(TRANSFORM_WORLD, matrix);
|
renderer->SetModelMatrix(matrix);
|
||||||
|
|
||||||
float size = m_brickSize/2.0f;
|
float size = m_brickSize/2.0f;
|
||||||
glm::vec3 eye = m_engine->GetEyePt();
|
glm::vec3 eye = m_engine->GetEyePt();
|
||||||
|
@ -178,10 +180,12 @@ void CCloud::Draw()
|
||||||
pos.x += size*2.0f;
|
pos.x += size*2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, vertices.data(), vertexIndex);
|
renderer->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, vertexIndex, vertices.data());
|
||||||
m_engine->AddStatisticTriangle(vertexIndex - 2);
|
m_engine->AddStatisticTriangle(vertexIndex - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderer->End();
|
||||||
|
|
||||||
m_engine->SetDeepView(iDeep);
|
m_engine->SetDeepView(iDeep);
|
||||||
m_engine->SetFocus(m_engine->GetFocus());
|
m_engine->SetFocus(m_engine->GetFocus());
|
||||||
m_engine->UpdateMatProj(); // gives depth to initial
|
m_engine->UpdateMatProj(); // gives depth to initial
|
||||||
|
|
|
@ -3394,8 +3394,6 @@ void CEngine::Draw3DScene()
|
||||||
|
|
||||||
//m_lightMan->UpdateDeviceLights(ENG_OBJTYPE_TERRAIN);
|
//m_lightMan->UpdateDeviceLights(ENG_OBJTYPE_TERRAIN);
|
||||||
|
|
||||||
UseShadowMapping(true);
|
|
||||||
|
|
||||||
SetState(0);
|
SetState(0);
|
||||||
|
|
||||||
Gfx::ShadowParam shadowParams[4];
|
Gfx::ShadowParam shadowParams[4];
|
||||||
|
@ -3413,7 +3411,11 @@ void CEngine::Draw3DScene()
|
||||||
terrainRenderer->SetViewMatrix(m_matView);
|
terrainRenderer->SetViewMatrix(m_matView);
|
||||||
terrainRenderer->SetShadowMap(m_shadowMap);
|
terrainRenderer->SetShadowMap(m_shadowMap);
|
||||||
terrainRenderer->SetLight(glm::vec4(1.0, 1.0, -1.0, 0.0), 1.0f, glm::vec3(1.0));
|
terrainRenderer->SetLight(glm::vec4(1.0, 1.0, -1.0, 0.0), 1.0f, glm::vec3(1.0));
|
||||||
terrainRenderer->SetShadowParams(m_shadowRegions, shadowParams);
|
|
||||||
|
if (m_shadowMapping)
|
||||||
|
terrainRenderer->SetShadowParams(m_shadowRegions, shadowParams);
|
||||||
|
else
|
||||||
|
terrainRenderer->SetShadowParams(0, nullptr);
|
||||||
|
|
||||||
Color fogColor = m_fogColor[m_rankView];
|
Color fogColor = m_fogColor[m_rankView];
|
||||||
|
|
||||||
|
@ -3468,9 +3470,6 @@ void CEngine::Draw3DScene()
|
||||||
|
|
||||||
terrainRenderer->End();
|
terrainRenderer->End();
|
||||||
|
|
||||||
if (!m_qualityShadows)
|
|
||||||
UseShadowMapping(false);
|
|
||||||
|
|
||||||
// Draws the old-style shadow spots, if shadow mapping disabled
|
// Draws the old-style shadow spots, if shadow mapping disabled
|
||||||
if (!m_shadowMapping)
|
if (!m_shadowMapping)
|
||||||
DrawShadowSpots();
|
DrawShadowSpots();
|
||||||
|
@ -3493,7 +3492,11 @@ void CEngine::Draw3DScene()
|
||||||
|
|
||||||
objectRenderer->SetFog(fogStart, fogEnd, { fogColor.r, fogColor.g, fogColor.b });
|
objectRenderer->SetFog(fogStart, fogEnd, { fogColor.r, fogColor.g, fogColor.b });
|
||||||
objectRenderer->SetAlphaScissor(0.0f);
|
objectRenderer->SetAlphaScissor(0.0f);
|
||||||
objectRenderer->SetShadowParams(m_shadowRegions, shadowParams);
|
|
||||||
|
if (m_shadowMapping && m_qualityShadows)
|
||||||
|
objectRenderer->SetShadowParams(m_shadowRegions, shadowParams);
|
||||||
|
else
|
||||||
|
objectRenderer->SetShadowParams(0, nullptr);
|
||||||
|
|
||||||
objectRenderer->SetTriplanarMode(m_triplanarMode);
|
objectRenderer->SetTriplanarMode(m_triplanarMode);
|
||||||
objectRenderer->SetTriplanarScale(m_triplanarScale);
|
objectRenderer->SetTriplanarScale(m_triplanarScale);
|
||||||
|
@ -3548,9 +3551,13 @@ void CEngine::Draw3DScene()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p3.state & ENG_RSTATE_ALPHA)
|
if (p3.state & ENG_RSTATE_ALPHA)
|
||||||
|
{
|
||||||
objectRenderer->SetAlphaScissor(0.2f);
|
objectRenderer->SetAlphaScissor(0.2f);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
objectRenderer->SetAlphaScissor(0.0f);
|
objectRenderer->SetAlphaScissor(0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
if ((p3.state & ENG_RSTATE_TCOLOR_BLACK)
|
if ((p3.state & ENG_RSTATE_TCOLOR_BLACK)
|
||||||
|| (p3.state & ENG_RSTATE_TCOLOR_WHITE)
|
|| (p3.state & ENG_RSTATE_TCOLOR_WHITE)
|
||||||
|
@ -3570,12 +3577,11 @@ void CEngine::Draw3DScene()
|
||||||
|
|
||||||
objectRenderer->End();
|
objectRenderer->End();
|
||||||
|
|
||||||
UseShadowMapping(false);
|
|
||||||
|
|
||||||
objectRenderer->Begin();
|
objectRenderer->Begin();
|
||||||
objectRenderer->SetLighting(false);
|
objectRenderer->SetLighting(false);
|
||||||
|
objectRenderer->SetDepthMask(false);
|
||||||
objectRenderer->SetTransparency(TransparencyMode::BLACK);
|
objectRenderer->SetTransparency(TransparencyMode::BLACK);
|
||||||
objectRenderer->SetAlphaScissor(0.5f);
|
objectRenderer->SetAlphaScissor(0.0f);
|
||||||
objectRenderer->SetCullMode(false);
|
objectRenderer->SetCullMode(false);
|
||||||
|
|
||||||
// Draw transparent objects
|
// Draw transparent objects
|
||||||
|
@ -4185,26 +4191,6 @@ void CEngine::RenderShadowMap()
|
||||||
m_device->SetRenderState(RENDER_STATE_DEPTH_TEST, false);
|
m_device->SetRenderState(RENDER_STATE_DEPTH_TEST, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::UseShadowMapping(bool enable)
|
|
||||||
{
|
|
||||||
if (!m_shadowMapping) return;
|
|
||||||
if (m_shadowMap.id == 0) return;
|
|
||||||
|
|
||||||
if (enable)
|
|
||||||
{
|
|
||||||
m_device->SetShadowColor(m_shadowColor);
|
|
||||||
m_device->SetTransform(TRANSFORM_SHADOW, m_shadowTextureMat);
|
|
||||||
m_device->SetTexture(TEXTURE_SHADOW, m_shadowMap);
|
|
||||||
m_device->SetTextureStageWrap(TEXTURE_SHADOW, TEX_WRAP_CLAMP_TO_BORDER, TEX_WRAP_CLAMP_TO_BORDER);
|
|
||||||
m_device->SetRenderState(RENDER_STATE_SHADOW_MAPPING, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_device->SetRenderState(RENDER_STATE_SHADOW_MAPPING, false);
|
|
||||||
m_device->SetTexture(TEXTURE_SHADOW, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CEngine::UseMSAA(bool enable)
|
void CEngine::UseMSAA(bool enable)
|
||||||
{
|
{
|
||||||
m_multisample = Math::Min(m_device->GetMaxSamples(), m_multisample);
|
m_multisample = Math::Min(m_device->GetMaxSamples(), m_multisample);
|
||||||
|
@ -4263,32 +4249,6 @@ void CEngine::UseMSAA(bool enable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::DrawObject(const EngineBaseObjDataTier& p4)
|
|
||||||
{
|
|
||||||
if (p4.buffer != nullptr)
|
|
||||||
{
|
|
||||||
m_device->DrawVertexBuffer(p4.buffer);
|
|
||||||
|
|
||||||
if (p4.type == EngineTriangleType::TRIANGLES)
|
|
||||||
m_statisticTriangle += p4.vertices.size() / 3;
|
|
||||||
else
|
|
||||||
m_statisticTriangle += p4.vertices.size() - 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (p4.type == EngineTriangleType::TRIANGLES)
|
|
||||||
{
|
|
||||||
m_device->DrawPrimitive(PrimitiveType::TRIANGLES, p4.vertices.data(), p4.vertices.size());
|
|
||||||
m_statisticTriangle += p4.vertices.size() / 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, p4.vertices.data(), p4.vertices.size() );
|
|
||||||
m_statisticTriangle += p4.vertices.size() - 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CEngine::DrawInterface()
|
void CEngine::DrawInterface()
|
||||||
{
|
{
|
||||||
m_device->Restore();
|
m_device->Restore();
|
||||||
|
@ -4978,20 +4938,27 @@ void CEngine::DrawBackgroundGradient(const Color& up, const Color& down)
|
||||||
glm::vec2 p1(0.0f, 0.5f);
|
glm::vec2 p1(0.0f, 0.5f);
|
||||||
glm::vec2 p2(1.0f, 1.0f);
|
glm::vec2 p2(1.0f, 1.0f);
|
||||||
|
|
||||||
Color color[3] =
|
glm::u8vec4 color[3] =
|
||||||
{
|
{
|
||||||
up,
|
{ up.r, up.g, up.b, up.a },
|
||||||
down,
|
{ down.r, down.g, down.b, down.a },
|
||||||
Color(0.0f, 0.0f, 0.0f, 0.0f)
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
SetState(ENG_RSTATE_OPAQUE_COLOR);
|
SetState(ENG_RSTATE_OPAQUE_COLOR);
|
||||||
|
|
||||||
m_device->SetTransform(TRANSFORM_VIEW, m_matViewInterface);
|
auto renderer = m_device->GetObjectRenderer();
|
||||||
m_device->SetTransform(TRANSFORM_PROJECTION, m_matProjInterface);
|
renderer->Begin();
|
||||||
m_device->SetTransform(TRANSFORM_WORLD, m_matWorldInterface);
|
renderer->SetProjectionMatrix(m_matProjInterface);
|
||||||
|
renderer->SetViewMatrix(m_matViewInterface);
|
||||||
|
renderer->SetModelMatrix(m_matWorldInterface);
|
||||||
|
renderer->SetLighting(false);
|
||||||
|
|
||||||
VertexCol vertex[4] =
|
renderer->SetPrimaryTexture(Texture{});
|
||||||
|
renderer->SetSecondaryTexture(Texture{});
|
||||||
|
renderer->SetDepthTest(false);
|
||||||
|
|
||||||
|
Vertex3D vertex[4] =
|
||||||
{
|
{
|
||||||
{ glm::vec3(p1.x, p1.y, 0.0f), color[1] },
|
{ glm::vec3(p1.x, p1.y, 0.0f), color[1] },
|
||||||
{ glm::vec3(p1.x, p2.y, 0.0f), color[0] },
|
{ glm::vec3(p1.x, p2.y, 0.0f), color[0] },
|
||||||
|
@ -4999,8 +4966,10 @@ void CEngine::DrawBackgroundGradient(const Color& up, const Color& down)
|
||||||
{ glm::vec3(p2.x, p2.y, 0.0f), color[0] }
|
{ glm::vec3(p2.x, p2.y, 0.0f), color[0] }
|
||||||
};
|
};
|
||||||
|
|
||||||
m_device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, vertex, 4);
|
renderer->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, 4, vertex);
|
||||||
AddStatisticTriangle(2);
|
AddStatisticTriangle(2);
|
||||||
|
|
||||||
|
renderer->End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::DrawBackgroundImage()
|
void CEngine::DrawBackgroundImage()
|
||||||
|
@ -5089,15 +5058,19 @@ void CEngine::DrawPlanet()
|
||||||
if (! m_planet->PlanetExist())
|
if (! m_planet->PlanetExist())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_device->SetRenderState(RENDER_STATE_DEPTH_WRITE, false);
|
auto renderer = m_device->GetObjectRenderer();
|
||||||
m_device->SetRenderState(RENDER_STATE_LIGHTING, false);
|
renderer->Begin();
|
||||||
m_device->SetRenderState(RENDER_STATE_FOG, false);
|
renderer->SetProjectionMatrix(m_matProjInterface);
|
||||||
|
renderer->SetViewMatrix(m_matViewInterface);
|
||||||
m_device->SetTransform(TRANSFORM_VIEW, m_matViewInterface);
|
renderer->SetModelMatrix(m_matWorldInterface);
|
||||||
m_device->SetTransform(TRANSFORM_PROJECTION, m_matProjInterface);
|
renderer->SetFog(1e+6, 1e+6, {});
|
||||||
m_device->SetTransform(TRANSFORM_WORLD, m_matWorldInterface);
|
renderer->SetLighting(false);
|
||||||
|
renderer->SetDepthTest(false);
|
||||||
|
renderer->SetDepthMask(false);
|
||||||
|
|
||||||
m_planet->Draw(); // draws the planets
|
m_planet->Draw(); // draws the planets
|
||||||
|
|
||||||
|
renderer->End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEngine::DrawForegroundImage()
|
void CEngine::DrawForegroundImage()
|
||||||
|
@ -5147,31 +5120,43 @@ void CEngine::DrawOverColor()
|
||||||
glm::vec2 p1(0.0f, 0.0f);
|
glm::vec2 p1(0.0f, 0.0f);
|
||||||
glm::vec2 p2(1.0f, 1.0f);
|
glm::vec2 p2(1.0f, 1.0f);
|
||||||
|
|
||||||
Color color[3] =
|
auto color = Gfx::ColorToIntColor(m_overColor);
|
||||||
|
|
||||||
|
glm::u8vec4 colors[3] =
|
||||||
{
|
{
|
||||||
m_overColor,
|
{ color.r, color.g, color.b, color.a },
|
||||||
m_overColor,
|
{ color.r, color.g, color.b, color.a },
|
||||||
Color(0.0f, 0.0f, 0.0f, 0.0f)
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
m_device->Restore();
|
m_device->Restore();
|
||||||
|
|
||||||
SetState(m_overMode);
|
SetState(m_overMode);
|
||||||
|
|
||||||
m_device->SetTransform(TRANSFORM_VIEW, m_matViewInterface);
|
auto renderer = m_device->GetObjectRenderer();
|
||||||
m_device->SetTransform(TRANSFORM_PROJECTION, m_matProjInterface);
|
renderer->Begin();
|
||||||
m_device->SetTransform(TRANSFORM_WORLD, m_matWorldInterface);
|
|
||||||
m_device->SetRenderState(RENDER_STATE_LIGHTING, false);
|
|
||||||
|
|
||||||
VertexCol vertex[4] =
|
renderer->SetProjectionMatrix(m_matProjInterface);
|
||||||
|
renderer->SetViewMatrix(m_matViewInterface);
|
||||||
|
renderer->SetModelMatrix(m_matWorldInterface);
|
||||||
|
renderer->SetLighting(false);
|
||||||
|
|
||||||
|
if (m_overMode == ENG_RSTATE_TCOLOR_BLACK)
|
||||||
|
renderer->SetTransparency(TransparencyMode::BLACK);
|
||||||
|
else if (m_overMode == ENG_RSTATE_TCOLOR_WHITE)
|
||||||
|
renderer->SetTransparency(TransparencyMode::WHITE);
|
||||||
|
|
||||||
|
Vertex3D vertex[4] =
|
||||||
{
|
{
|
||||||
{ glm::vec3(p1.x, p1.y, 0.0f), color[1] },
|
{ glm::vec3(p1.x, p1.y, 0.0f), colors[1] },
|
||||||
{ glm::vec3(p1.x, p2.y, 0.0f), color[0] },
|
{ glm::vec3(p1.x, p2.y, 0.0f), colors[0] },
|
||||||
{ glm::vec3(p2.x, p1.y, 0.0f), color[1] },
|
{ glm::vec3(p2.x, p1.y, 0.0f), colors[1] },
|
||||||
{ glm::vec3(p2.x, p2.y, 0.0f), color[0] }
|
{ glm::vec3(p2.x, p2.y, 0.0f), colors[0] }
|
||||||
};
|
};
|
||||||
|
|
||||||
m_device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, vertex, 4);
|
renderer->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, 4, vertex);
|
||||||
|
renderer->End();
|
||||||
|
|
||||||
AddStatisticTriangle(2);
|
AddStatisticTriangle(2);
|
||||||
|
|
||||||
m_device->Restore();
|
m_device->Restore();
|
||||||
|
|
|
@ -1210,12 +1210,8 @@ protected:
|
||||||
void DrawCaptured3DScene();
|
void DrawCaptured3DScene();
|
||||||
//! Renders shadow map
|
//! Renders shadow map
|
||||||
void RenderShadowMap();
|
void RenderShadowMap();
|
||||||
//! Enables or disables shadow mapping
|
|
||||||
void UseShadowMapping(bool enable);
|
|
||||||
//! Enables or disables MSAA
|
//! Enables or disables MSAA
|
||||||
void UseMSAA(bool enable);
|
void UseMSAA(bool enable);
|
||||||
//! Draw 3D object
|
|
||||||
void DrawObject(const EngineBaseObjDataTier& p4);
|
|
||||||
//! Draws the user interface over the scene
|
//! Draws the user interface over the scene
|
||||||
void DrawInterface();
|
void DrawInterface();
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "common/event.h"
|
#include "common/event.h"
|
||||||
|
|
||||||
#include "graphics/core/device.h"
|
#include "graphics/core/device.h"
|
||||||
|
#include "graphics/core/renderers.h"
|
||||||
|
|
||||||
#include "graphics/engine/engine.h"
|
#include "graphics/engine/engine.h"
|
||||||
|
|
||||||
|
@ -100,7 +101,8 @@ void CPlanet::Draw()
|
||||||
float eyeDirH = m_engine->GetEyeDirH();
|
float eyeDirH = m_engine->GetEyeDirH();
|
||||||
float eyeDirV = m_engine->GetEyeDirV();
|
float eyeDirV = m_engine->GetEyeDirV();
|
||||||
|
|
||||||
glm::vec3 n = glm::vec3(0.0f, 0.0f, -1.0f); // normal
|
auto renderer = m_engine->GetDevice()->GetObjectRenderer();
|
||||||
|
|
||||||
float dp = 0.5f/256.0f;
|
float dp = 0.5f/256.0f;
|
||||||
|
|
||||||
for (const auto& planet : m_planets)
|
for (const auto& planet : m_planets)
|
||||||
|
@ -108,14 +110,16 @@ void CPlanet::Draw()
|
||||||
if (planet.type != m_visibleType)
|
if (planet.type != m_visibleType)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_engine->SetTexture(planet.name);
|
auto texture = m_engine->LoadTexture(planet.name);
|
||||||
|
|
||||||
|
renderer->SetPrimaryTexture(texture);
|
||||||
|
|
||||||
if (planet.transparent)
|
if (planet.transparent)
|
||||||
m_engine->SetState(ENG_RSTATE_WRAP | ENG_RSTATE_ALPHA);
|
renderer->SetTransparency(TransparencyMode::ALPHA);
|
||||||
else
|
else
|
||||||
m_engine->SetState(ENG_RSTATE_WRAP | ENG_RSTATE_TTEXTURE_BLACK);
|
renderer->SetTransparency(TransparencyMode::BLACK);
|
||||||
|
|
||||||
glm::vec2 p1, p2;
|
glm::vec2 p1{}, p2{};
|
||||||
|
|
||||||
// Determine the 2D coordinates of the centre of the planet.
|
// Determine the 2D coordinates of the centre of the planet.
|
||||||
|
|
||||||
|
@ -141,15 +145,19 @@ void CPlanet::Draw()
|
||||||
float u2 = planet.uv2.x - dp;
|
float u2 = planet.uv2.x - dp;
|
||||||
float v2 = planet.uv2.y - dp;
|
float v2 = planet.uv2.y - dp;
|
||||||
|
|
||||||
Vertex quad[4] =
|
glm::u8vec4 white(255);
|
||||||
|
|
||||||
|
Vertex3D quad[4] =
|
||||||
{
|
{
|
||||||
{ glm::vec3(p1.x, p1.y, 0.0f), n, { u1, v2 } },
|
{ glm::vec3(p1.x, p1.y, 0.0f), white, { u1, v2 } },
|
||||||
{ glm::vec3(p1.x, p2.y, 0.0f), n, { u1, v1 } },
|
{ glm::vec3(p1.x, p2.y, 0.0f), white, { u1, v1 } },
|
||||||
{ glm::vec3(p2.x, p1.y, 0.0f), n, { u2, v2 } },
|
{ glm::vec3(p2.x, p1.y, 0.0f), white, { u2, v2 } },
|
||||||
{ glm::vec3(p2.x, p2.y, 0.0f), n, { u2, v1 } }
|
{ glm::vec3(p2.x, p2.y, 0.0f), white, { u2, v1 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
device->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, quad, 4);
|
renderer->SetColor({ 1.0f, 1.0f, 1.0f, 1.0f });
|
||||||
|
|
||||||
|
renderer->DrawPrimitive(PrimitiveType::TRIANGLE_STRIP, 4, quad);
|
||||||
m_engine->AddStatisticTriangle(2);
|
m_engine->AddStatisticTriangle(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -298,6 +298,19 @@ void CGL33ObjectRenderer::SetFog(float min, float max, const glm::vec3& color)
|
||||||
glUniform3f(m_fogColor, color.r, color.g, color.b);
|
glUniform3f(m_fogColor, color.r, color.g, color.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGL33ObjectRenderer::SetDepthTest(bool enabled)
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
else
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGL33ObjectRenderer::SetDepthMask(bool enabled)
|
||||||
|
{
|
||||||
|
glDepthMask(enabled ? GL_TRUE : GL_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
void CGL33ObjectRenderer::SetCullMode(bool enabled)
|
void CGL33ObjectRenderer::SetCullMode(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled)
|
if (enabled)
|
||||||
|
@ -317,25 +330,21 @@ void CGL33ObjectRenderer::SetTransparency(TransparencyMode mode)
|
||||||
{
|
{
|
||||||
case TransparencyMode::NONE:
|
case TransparencyMode::NONE:
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
break;
|
break;
|
||||||
case TransparencyMode::ALPHA:
|
case TransparencyMode::ALPHA:
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
break;
|
break;
|
||||||
case TransparencyMode::BLACK:
|
case TransparencyMode::BLACK:
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glDepthMask(GL_FALSE);
|
|
||||||
break;
|
break;
|
||||||
case TransparencyMode::WHITE:
|
case TransparencyMode::WHITE:
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_DST_COLOR, GL_ZERO);
|
glBlendFunc(GL_DST_COLOR, GL_ZERO);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glDepthMask(GL_FALSE);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,9 @@ public:
|
||||||
//! Sets alpha scissor
|
//! Sets alpha scissor
|
||||||
virtual void SetAlphaScissor(float alpha) override;
|
virtual void SetAlphaScissor(float alpha) override;
|
||||||
|
|
||||||
|
virtual void SetDepthTest(bool enabled) override;
|
||||||
|
virtual void SetDepthMask(bool enabled) override;
|
||||||
|
|
||||||
//! Sets cull mode parameters
|
//! Sets cull mode parameters
|
||||||
virtual void SetCullMode(bool enabled) override;
|
virtual void SetCullMode(bool enabled) override;
|
||||||
//! Sets transparency mode
|
//! Sets transparency mode
|
||||||
|
|
Loading…
Reference in New Issue