mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-07 03:51:50 +00:00
move sky sprites to environment
This commit is contained in:
parent
28b7713648
commit
4aaa5b2d7e
4 changed files with 70 additions and 44 deletions
|
|
@ -23,7 +23,6 @@
|
|||
using namespace advanced_pipeline;
|
||||
|
||||
const int STARS_COUNT = 3000;
|
||||
|
||||
const int STARS_SEED = 632;
|
||||
|
||||
Skybox::Skybox(uint size, const Assets& assets)
|
||||
|
|
@ -41,31 +40,6 @@ Skybox::Skybox(uint size, const Assets& assets)
|
|||
{{1.0f, -1.0f}}};
|
||||
|
||||
mesh = std::make_unique<Mesh<SkyboxVertex>>(vertices, 6);
|
||||
|
||||
sprites.push_back(SkySprite {
|
||||
"misc/moon",
|
||||
glm::pi<float>() * 0.5f,
|
||||
4.0f,
|
||||
false,
|
||||
glm::pi<float>() * 0.25f,
|
||||
});
|
||||
|
||||
sprites.push_back(SkySprite {
|
||||
"misc/moon_flare",
|
||||
glm::pi<float>() * 0.5f,
|
||||
0.5f,
|
||||
false,
|
||||
glm::pi<float>() * 0.25f,
|
||||
});
|
||||
|
||||
sprites.push_back(SkySprite {
|
||||
"misc/sun",
|
||||
glm::pi<float>() * 1.5f,
|
||||
4.0f,
|
||||
true,
|
||||
glm::pi<float>() * 0.25f,
|
||||
});
|
||||
|
||||
setMode(mode);
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +91,8 @@ void Skybox::drawStars(float angle, float opacity) {
|
|||
void Skybox::drawSkySprites(
|
||||
float daytime,
|
||||
float angle,
|
||||
float opacity
|
||||
float opacity,
|
||||
const std::vector<SkySprite>& sprites
|
||||
) {
|
||||
float depthScale = 2e3;
|
||||
for (auto& sprite : sprites) {
|
||||
|
|
@ -160,7 +135,7 @@ void Skybox::draw(
|
|||
DrawContext ctx = pctx.sub();
|
||||
ctx.setBlendMode(BlendMode::addition);
|
||||
|
||||
if (!environment.sky.sprites && !environment.sky.stars) {
|
||||
if (environment.sky.sprites.empty() && !environment.sky.stars) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -170,8 +145,8 @@ void Skybox::draw(
|
|||
shader->uniformMatrix("u_apply", glm::mat4(1.0f));
|
||||
batch3d->begin();
|
||||
|
||||
if (environment.sky.sprites) {
|
||||
drawSkySprites(daytime, angle, opacity);
|
||||
if (!environment.sky.sprites.empty()) {
|
||||
drawSkySprites(daytime, angle, opacity, environment.sky.sprites);
|
||||
}
|
||||
if (environment.sky.stars) {
|
||||
drawStars(angle, opacity);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include "typedefs.hpp"
|
||||
#include "world/Environment.hpp"
|
||||
|
||||
|
||||
template <typename VertexStructure>
|
||||
class Mesh;
|
||||
class Shader;
|
||||
|
|
@ -28,14 +27,6 @@ struct SkyboxVertex {
|
|||
{VertexAttribute::Type::FLOAT, false, 2}, {{}, 0}};
|
||||
};
|
||||
|
||||
struct SkySprite {
|
||||
std::string texture;
|
||||
float phase;
|
||||
float distance;
|
||||
bool emissive;
|
||||
float altitude;
|
||||
};
|
||||
|
||||
class Skybox {
|
||||
SkyMode mode = SkyMode::SOLID;
|
||||
uint size;
|
||||
|
|
@ -47,7 +38,6 @@ class Skybox {
|
|||
|
||||
std::unique_ptr<Mesh<SkyboxVertex>> mesh;
|
||||
std::unique_ptr<Batch3D> batch3d;
|
||||
std::vector<SkySprite> sprites;
|
||||
int frameid = 0;
|
||||
|
||||
float prevMie = -1.0f;
|
||||
|
|
@ -58,7 +48,12 @@ class Skybox {
|
|||
|
||||
void drawStars(float angle, float opacity);
|
||||
void drawBackground(const Camera& camera, int width, int height);
|
||||
void drawSkySprites(float daytime, float angle, float opacity);
|
||||
void drawSkySprites(
|
||||
float daytime,
|
||||
float angle,
|
||||
float opacity,
|
||||
const std::vector<SkySprite>& sprites
|
||||
);
|
||||
void refreshFace(uint face, Cubemap& cubemap);
|
||||
public:
|
||||
Skybox(uint size, const Assets& assets);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue