Skip to content

Commit a2ba4df

Browse files
committed
[Renderer] sky disc
1 parent fe60ca8 commit a2ba4df

6 files changed

Lines changed: 50 additions & 22 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#version 330 core
22
#extension GL_ARB_separate_shader_objects : enable
33

4+
layout(location = 0) in vec3 discColor;
45
layout(location = 0) out vec4 outColor;
56

67
void main()
78
{
8-
outColor = vec4(1.0);
9+
outColor = vec4(discColor, 1.0);
910
}
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
11
#version 330 core
22
#extension GL_ARB_separate_shader_objects : enable
33

4+
#include "basics/vertexgen.glsl"
5+
6+
#include "basics/structs/camera.glsl"
7+
layout(location = 0) out vec3 discColor;
8+
9+
#define PI 3.1415926535897
10+
411
void main()
512
{
6-
gl_Position = vec4(1.0);
13+
vec4 actualPos;
14+
int id = vertexgen_id();
15+
if (id % 3 == 0)
16+
{
17+
actualPos = vec4(0.0, 0.0, 0.0, 1.0);
18+
discColor = vec3(0.470, 0.654, 1.0);
19+
}
20+
else if (id % 3 == 1)
21+
{
22+
actualPos = vec4(sin(PI / 4 * (id / 3)), 0.0, cos(PI / 4 * (id / 3)), 1.0);
23+
discColor = vec3(0.198, 0.371, 1.0);
24+
}
25+
else
26+
{
27+
actualPos = vec4(sin(PI / 4 * (id / 3 + 1)), 0.0, cos(PI / 4 * (id / 3 + 1)), 1.0);
28+
discColor = vec3(0.198, 0.371, 1.0);
29+
}
30+
31+
actualPos *= 256;
32+
actualPos.y = -16;
33+
gl_Position = camera.viewProj * actualPos;
734
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ class OMVoxelManager
339339
OMRendererPipeline *pipeline, *debugPipeline, *complexPipeline;
340340
OMRendererPipeline *translucentPipeline, *translucentComplexPipeline;
341341
OMRendererPipeline *composePipeline;
342+
OMRendererPipeline *skyDiscPipeline;
342343
OMRendererBuffer *chunkoffs, *debugoffs;
343344
OMRendererTexture *textureAtlas;
344345
OMRendererTexture *textureAtlasSecondary;

scripts/draw3.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,22 @@ OMVoxelManager::OMVoxelManager(OMRenderer *renderer, OMRendererRenderTarget *res
186186
->depthReverseZ(true)
187187
->buildN();
188188

189+
skyDiscPipeline = renderer->createPipeline()
190+
->input(UniformBuffer)
191+
->inputName("Camera")
192+
->output(cutoutTargetMS->target)
193+
->samples(samples)
194+
->shader(renderer->shaderManager.preprocess("core/voxel/skydisc.frag.glsl", Fragment,
195+
GLSLSource, simpleFormat))
196+
->shader(renderer->shaderManager.preprocess("core/voxel/skydisc.vert.glsl", Vertex,
197+
GLSLSource, simpleFormat))
198+
->format(simpleFormat)
199+
->blendFunc({Alpha, OneMinusAlpha, Alpha, OneMinusAlpha})
200+
->blend(true)
201+
->depth(false, false)
202+
->depthReverseZ(true)
203+
->buildN();
204+
189205
composePipeline = renderer->createPipeline()
190206
->input(ImageSampler)
191207
->inputName("inTextureCutout")
@@ -394,6 +410,8 @@ auto OMVoxelManager::submit(OMRendererTask *task, OMRendererTempTarget *resolveT
394410
auto tsk = task->clearColor({0.198f, 0.371f, 1.0f, 1.0f})
395411
->clearDepth(0.0f)
396412
->target(cutoutTargetMS->target)
413+
->pipeline(skyDiscPipeline)
414+
->drawN(24)
397415
->pipeline(pipeline)
398416
->vertexBuffer({voxelLayer->buf()->buffer})
399417
->drawInstanceN(6, voxelLayer->buf()->totalSize / sizeof(OMVoxel))

src/openminecraft/renderer/worldrenderer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ OMWorldRenderer::OMWorldRenderer(OMRenderer *renderer, std::shared_ptr<basics::O
9494
voxelManager->complexPipeline->bindInput(0, cameraBuffer);
9595
voxelManager->translucentPipeline->bindInput(0, cameraBuffer);
9696
voxelManager->translucentComplexPipeline->bindInput(0, cameraBuffer);
97+
voxelManager->skyDiscPipeline->bindInput(0, cameraBuffer);
9798
}
9899

99100
static float ang = 0.0f;

0 commit comments

Comments
 (0)