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