skybox: added moon and stars
This commit is contained in:
@@ -5,13 +5,14 @@
|
||||
#include <memory>
|
||||
#include <assert.h>
|
||||
|
||||
#include "../content/Content.h"
|
||||
#include "../graphics/ChunksRenderer.h"
|
||||
#include "../window/Window.h"
|
||||
#include "../window/Camera.h"
|
||||
#include "../content/Content.h"
|
||||
#include "../graphics/ChunksRenderer.h"
|
||||
#include "../graphics/Mesh.h"
|
||||
#include "../graphics/Atlas.h"
|
||||
#include "../graphics/Shader.h"
|
||||
#include "../graphics/Batch3D.h"
|
||||
#include "../graphics/Texture.h"
|
||||
#include "../graphics/LineBatch.h"
|
||||
#include "../voxels/Chunks.h"
|
||||
@@ -46,7 +47,8 @@ WorldRenderer::WorldRenderer(Engine* engine, LevelFrontend* frontend)
|
||||
lineBatch(new LineBatch()),
|
||||
renderer(new ChunksRenderer(level,
|
||||
frontend->getContentGfxCache(),
|
||||
engine->getSettings())) {
|
||||
engine->getSettings())),
|
||||
batch3d(new Batch3D(4096)) {
|
||||
|
||||
auto& settings = engine->getSettings();
|
||||
level->events->listen(EVT_CHUNK_HIDDEN,
|
||||
@@ -129,31 +131,24 @@ void WorldRenderer::drawChunks(Chunks* chunks,
|
||||
|
||||
|
||||
void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool hudVisible){
|
||||
Window::clearDepth();
|
||||
EngineSettings& settings = engine->getSettings();
|
||||
skybox->refresh(level->world->daytime,
|
||||
1.0f+fog*2.0f, 4);
|
||||
skybox->refresh(pctx, level->world->daytime, 1.0f+fog*2.0f, 4);
|
||||
|
||||
const Content* content = level->content;
|
||||
auto indices = content->getIndices();
|
||||
Assets* assets = engine->getAssets();
|
||||
Atlas* atlas = assets->getAtlas("blocks");
|
||||
Shader* shader = assets->getShader("main");
|
||||
Shader* linesShader = assets->getShader("lines");
|
||||
|
||||
const Viewport& viewport = pctx.getViewport();
|
||||
int displayWidth = viewport.getWidth();
|
||||
int displayHeight = viewport.getHeight();
|
||||
Window::clearDepth();
|
||||
Window::viewport(0, 0, displayWidth, displayHeight);
|
||||
|
||||
// Drawing background sky plane
|
||||
Shader* backShader = assets->getShader("background");
|
||||
backShader->use();
|
||||
backShader->uniformMatrix("u_view", camera->getView(false));
|
||||
backShader->uniform1f("u_zoom", camera->zoom*camera->getFov()/(3.141592*0.5f));
|
||||
backShader->uniform1f("u_ar", float(displayWidth)/float(displayHeight));
|
||||
skybox->draw(backShader);
|
||||
skybox->draw(pctx, camera, assets, level->getWorld()->daytime, fog);
|
||||
|
||||
Shader* linesShader = assets->getShader("lines");
|
||||
{
|
||||
GfxContext ctx = pctx.sub();
|
||||
ctx.depthTest(true);
|
||||
|
||||
Reference in New Issue
Block a user