mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-09 21:31:51 +09:00
floating points packing for shaders
This commit is contained in:
@@ -1671,8 +1671,8 @@ public class App implements ApplicationListener {
|
||||
frag = "#version 400\n"+frag0;
|
||||
}
|
||||
else {
|
||||
vert = "#version 150\n#define fma(a,b,c) (((a)*(b))+(c))\n"+vert0;
|
||||
frag = "#version 150\n#define fma(a,b,c) (((a)*(b))+(c))\n"+frag0;
|
||||
vert = "#version 330\n#define fma(a,b,c) (((a)*(b))+(c))\n"+vert0;
|
||||
frag = "#version 330\n#define fma(a,b,c) (((a)*(b))+(c))\n"+frag0;
|
||||
}
|
||||
|
||||
ShaderProgram s = new ShaderProgram(vert, frag);
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.lwjgl.opengl.GL11
|
||||
class TerrarumGLinfo {
|
||||
private var _initialised = false
|
||||
|
||||
val MINIMAL_GL_VERSION = 320
|
||||
val MINIMAL_GL_VERSION = 330
|
||||
|
||||
var GL_VERSION = -1; private set
|
||||
get() = if (_initialised) field else throw UninitializedPropertyAccessException()
|
||||
|
||||
@@ -78,6 +78,13 @@ class WeatherObjectCloud(
|
||||
|
||||
private val vecMult = Vector3(1f, 1f, 1f / (4f * H))
|
||||
|
||||
private fun packFloat(f: Float, g: Float): Float {
|
||||
val fi = java.lang.Float.floatToRawIntBits(f)
|
||||
val gi = java.lang.Float.floatToRawIntBits(g)
|
||||
val hi = (fi and 0xffff0000.toInt()) or ((gi and 0xffff0000.toInt()) ushr 16)
|
||||
return java.lang.Float.intBitsToFloat(hi)
|
||||
}
|
||||
|
||||
fun render(batch: UnpackedColourSpriteBatch, cloudDrawColour0: Color, shadiness: Float) {
|
||||
val sc = screenCoord
|
||||
|
||||
@@ -87,7 +94,7 @@ class WeatherObjectCloud(
|
||||
it.a = alpha
|
||||
}
|
||||
batch.color = cloudCol
|
||||
batch.generic.set(rgbGamma, aGamma, shadiness, 0f)
|
||||
batch.generic.set(packFloat(rgbGamma, aGamma), shadiness, 0f, 0f)
|
||||
|
||||
if (flipW)
|
||||
batch.draw(texture, sc.x + texture.regionWidth / posZ, sc.y, -texture.regionWidth * sc.z, texture.regionHeight * sc.z)
|
||||
|
||||
Reference in New Issue
Block a user