mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
floating points packing for shaders
This commit is contained in:
@@ -29,7 +29,7 @@ Requires 64 bit processor and operation system.
|
||||
|OS|Windows 7/macOS Sierra/Ubuntu 16.04|Windows 10/macOS Big Sur/Linux with Kernel 5.4|
|
||||
|CPU|AMD Phenom X4 9600/Intel Core 2 Duo E8400|AMD Ryzen 5 1500X/Intel Core i7-4770K/Apple M1|
|
||||
|Memory|4 GB RAM|8 GB RAM|
|
||||
|OpenGL|3.2|4.0|
|
||||
|OpenGL|3.3|4.0|
|
||||
|Graphics|GeForce 9600 GT|Anything that supports OpenGL 4.0|
|
||||
|Storage|2 GB available|2 GB available but faster|
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
in vec4 v_color; // lightCol
|
||||
in vec4 v_generic; // [rgb gamma, a gamma, shadiness, 0]
|
||||
in vec4 v_generic; // [rgb gamma + a gamma, shadiness, 0, 0]
|
||||
in vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
out vec4 fragColor;
|
||||
@@ -16,9 +16,9 @@ vec4 shadeVec = vec4(1.0 + 3.333 * v_generic.z, 1.0 + 3.333 * v_generic.z, 1.0 +
|
||||
|
||||
void main() {
|
||||
vec4 cloudCol = v_color;
|
||||
float rgbGamma = v_generic.x;
|
||||
float aGamma = v_generic.y;
|
||||
vec4 gamma = v_generic.xxxy;
|
||||
float rgbGamma = uintBitsToFloat(floatBitsToUint(v_generic.x) & 0xffff0000u);
|
||||
float aGamma = uintBitsToFloat((floatBitsToUint(v_generic.x) & 0x0000ffffu) << 16);
|
||||
vec4 gamma = vec4(rgbGamma, rgbGamma, rgbGamma, aGamma);
|
||||
|
||||
vec4 range = vec4(vec3(min(rgbGamma, 1.0 / rgbGamma)), 1.0);
|
||||
vec4 offset = vec4(vec3(max(0.0, 1.0 - rgbGamma)), 0.0);
|
||||
|
||||
Reference in New Issue
Block a user