Skip to content

Commit fd4e1f8

Browse files
committed
[Renderer] background dynamic
1 parent 1a148ee commit fd4e1f8

5 files changed

Lines changed: 51 additions & 2 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#version 330 core
2+
#extension GL_ARB_separate_shader_objects : enable
3+
4+
layout(location = 0) in vec3 discColor;
5+
layout(location = 0) out vec4 outColor;
6+
7+
uniform SkyDiscData
8+
{
9+
vec3 diskCenterColor;
10+
float discRange;
11+
vec3 diskSideColor;
12+
float discHeight;
13+
}
14+
disc;
15+
16+
void main()
17+
{
18+
outColor = vec4(disc.diskSideColor, 1.0);
19+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#version 330 core
2+
#extension GL_ARB_separate_shader_objects : enable
3+
4+
#include "basics/vertexgen.glsl"
5+
6+
layout(location = 0) out vec2 texCoord;
7+
8+
void main()
9+
{
10+
gl_Position = vec4(vertexgen_quad_ndc(), 0.0, 1.0);
11+
texCoord = vertexgen_quad_normal();
12+
}

include/openminecraft/renderer/common/wrap/om_renderer_voxel.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ class OMVoxelManager
396396
OMRendererPipeline *composePipeline;
397397
OMRendererPipeline *skyDiscPipeline;
398398
OMRendererPipeline *lightmapPipeline;
399+
OMRendererPipeline *skyPipeline;
399400
OMRendererBuffer *chunkoffs, *debugoffs;
400401
OMRendererBuffer *skydisc;
401402
OMRendererBuffer *fogdata;

src/openminecraft-core/renderer/common/wrap/om_renderer_voxel_manager.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,19 @@ OMVoxelManager::OMVoxelManager(OMRenderer *renderer, OMRendererRenderTarget *res
236236
->depth(false, false)
237237
->buildN();
238238

239+
skyPipeline =
240+
renderer->createPipeline()
241+
->input(UniformBuffer)
242+
->inputName("SkyDiscData")
243+
->output(cutoutTargetMS->target)
244+
->samples(samples)
245+
->shader(renderer->shaderManager.preprocess("core/voxel/sky.frag.glsl", Fragment, GLSLSource, simpleFormat))
246+
->shader(renderer->shaderManager.preprocess("core/voxel/sky.vert.glsl", Vertex, GLSLSource, simpleFormat))
247+
->format(simpleFormat)
248+
->blend(false)
249+
->depth(false, false)
250+
->buildN();
251+
239252
composePipeline = renderer->createPipeline()
240253
->input(ImageSampler)
241254
->inputName("inTextureCutout")
@@ -309,9 +322,11 @@ OMVoxelManager::OMVoxelManager(OMRenderer *renderer, OMRendererRenderTarget *res
309322
translucentComplexPipeline->bindInput(5, lightmap->colorTexture);
310323
skyDiscPipeline->bindInput(1, skydisc);
311324
lightmapPipeline->bindInput(0, lightmapData);
325+
skyPipeline->bindInput(0, skydisc);
312326
}
313327
OMVoxelManager::~OMVoxelManager()
314328
{
329+
delete skyPipeline;
315330
delete lightmap;
316331
delete lightmapPipeline;
317332
delete lightmapData;
@@ -450,9 +465,11 @@ auto OMVoxelManager::submit(OMRendererTask *task, OMRendererTempTarget *resolveT
450465
auto tsk = task->target(lightmap->target)
451466
->pipeline(lightmapPipeline)
452467
->drawN(6)
453-
->clearColor({0.198f, 0.371f, 1.0f, 1.0f})
468+
->clearColor({0.0f, 0.0f, 0.0f, 0.0f})
454469
->clearDepth(0.0f)
455470
->target(cutoutTargetMS->target)
471+
->pipeline(skyPipeline)
472+
->drawN(6)
456473
->pipeline(skyDiscPipeline)
457474
->drawN(24)
458475
->pipeline(pipeline)

src/openminecraft/application.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void OMApplication::mainLoop(OMBackend backend)
107107
auto camera = std::make_shared<basics::OMCamera>(win(), glm::vec3{-1.0f, 5.0f, -1.0f}, 45.0f, -45.0f);
108108

109109
auto chunkManager = std::make_shared<world::OMChunkManager<16>>();
110-
int radius = 8;
110+
int radius = 4;
111111
for (int cx = -radius; cx < radius; ++cx)
112112
{
113113
for (int cy = -radius; cy < radius; ++cy)

0 commit comments

Comments
 (0)