floating points packing for shaders

This commit is contained in:
minjaesong
2023-09-25 19:09:26 +09:00
parent 7623b120ac
commit 2c9f3ce1e5
5 changed files with 16 additions and 9 deletions

View File

@@ -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);

View File

@@ -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()

View File

@@ -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)