mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 03:44:54 -04:00
render sun with texture
This commit is contained in:
parent
cd1a8a126a
commit
70fb02f290
@ -23,6 +23,7 @@ import de.bixilon.minosoft.data.world.time.WorldTime
|
||||
import de.bixilon.minosoft.gui.rendering.events.CameraMatrixChangeEvent
|
||||
import de.bixilon.minosoft.gui.rendering.sky.SkyChildRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.sky.SkyRenderer
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.BlendingFunctions
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.RenderingCapabilities
|
||||
import de.bixilon.minosoft.gui.rendering.textures.TextureUtil.texture
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener.Companion.listen
|
||||
@ -67,7 +68,7 @@ class SunRenderer(
|
||||
|
||||
override fun postInit() {
|
||||
prepareMesh()
|
||||
// sky.renderWindow.textureManager.staticTextures.use(shader)
|
||||
sky.renderWindow.textureManager.staticTextures.use(shader)
|
||||
sky.renderWindow.connection.events.listen<CameraMatrixChangeEvent> { calculateMatrix(it.projectionMatrix, it.viewMatrix) }
|
||||
}
|
||||
|
||||
@ -121,13 +122,15 @@ class SunRenderer(
|
||||
shader.setVec4("uTintColor", Vec4(1.0f, 1.0f, 1.0f, calculateSunIntensity()))
|
||||
this.matrixUpdate = false
|
||||
}
|
||||
|
||||
sky.renderSystem.enable(RenderingCapabilities.BLENDING)
|
||||
sky.renderSystem.setBlendFunction(BlendingFunctions.SOURCE_ALPHA, BlendingFunctions.ONE, BlendingFunctions.ONE, BlendingFunctions.ZERO)
|
||||
|
||||
mesh.unload()
|
||||
mesh = SunMesh(sky.renderWindow)
|
||||
prepareMesh()
|
||||
mesh.draw()
|
||||
sky.renderSystem.disable(RenderingCapabilities.BLENDING)
|
||||
sky.renderSystem.resetBlending()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -125,6 +125,12 @@ interface RenderSystem {
|
||||
fun polygonOffset(factor: Float, unit: Float)
|
||||
|
||||
|
||||
fun resetBlending() {
|
||||
disable(RenderingCapabilities.BLENDING)
|
||||
setBlendFunction(BlendingFunctions.ONE, BlendingFunctions.ONE_MINUS_SOURCE_ALPHA, BlendingFunctions.ONE, BlendingFunctions.ZERO)
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
fun createRenderSystem(renderWindow: RenderWindow): RenderSystem {
|
||||
|
@ -20,13 +20,11 @@ in vec3 finTextureCoordinates;
|
||||
|
||||
uniform vec4 uTintColor;
|
||||
|
||||
// #include "minosoft:texture"
|
||||
|
||||
#include "minosoft:texture"
|
||||
|
||||
|
||||
void main() {
|
||||
// vec4 texelColor = getTexture(finTextureIndex, finTextureCoordinates);
|
||||
foutColor = vec4(1.0f, 0.5f, 0.5f, 1.0f) * uTintColor;
|
||||
foutColor = getTexture(finTextureIndex, finTextureCoordinates) * uTintColor;
|
||||
if (foutColor.a == 0.0f) {
|
||||
discard;
|
||||
}
|
||||
|
@ -17,16 +17,14 @@ layout (location = 0) in vec3 vinPosition;
|
||||
layout (location = 1) in vec2 vinUV;
|
||||
layout (location = 2) in uint vinIndexLayerAnimation;
|
||||
|
||||
//flat out uint finTextureIndex;
|
||||
//out vec3 finTextureCoordinates;
|
||||
flat out uint finTextureIndex;
|
||||
out vec3 finTextureCoordinates;
|
||||
|
||||
uniform mat4 uSunMatrix;
|
||||
|
||||
#include "minosoft:color"
|
||||
|
||||
void main() {
|
||||
gl_Position = uSunMatrix * vec4(vinPosition, 1.0f);
|
||||
|
||||
// finTextureIndex = vinIndexLayerAnimation >> 28u;
|
||||
// finTextureCoordinates = vec3(vinUV, ((vinIndexLayerAnimation >> 12) & 0xFFFFu));
|
||||
finTextureIndex = vinIndexLayerAnimation >> 28u;
|
||||
finTextureCoordinates = vec3(vinUV, ((vinIndexLayerAnimation >> 12) & 0xFFFFu));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user