fix for the sigmoid functions

This commit is contained in:
minjaesong
2021-06-09 11:09:24 +09:00
parent 655b8acf68
commit 4a4425afd1
3 changed files with 31 additions and 24 deletions

View File

@@ -37,7 +37,7 @@ public class AppLoader {
EmulInstance reference = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.ReferenceGraphicsAdapter", "assets/disk0");
EmulInstance reference2 = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.ReferenceLikeLCD", "assets/disk0");
EmulInstance term = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.TexticsAdapter", "assets/disk0");
EmulInstance term = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.Term", "assets/disk0");
EmulInstance portable = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.CharacterLCDdisplay", "assets/disk0");
EmulInstance wp = new EmulInstance(appConfig, vm, "net.torvald.tsvm.peripheral.WpTerm", "assets/wpdisk");

View File

@@ -916,20 +916,23 @@ int getTileFromColor(vec4 color) {
return _colToInt(color) & 0xFFFFF;
}
uniform float sgmp = 4.3;
float sgmcomp = 2.0 / (1.0 + exp(-sgmp)) - 1.001; // making sure everything sits within [0..1)
float sigmoid(float x) {
return 2.0 / (1.0 + exp(-6.333 * x)) - 1.0;
return (2.0 / (1.0 + exp(-sgmp * x)) - 1.0) / sgmcomp;
}
vec4 sigmoid(vec4 x) {
return 2.0 / (1.0 + exp(-6.333 * x)) - 1.0;
return (2.0 / (1.0 + exp(-sgmp * x)) - 1.0) / sgmcomp;
}
float invsigmoid(float x) {
return (1.0 / 6.333) * log((1.0 + x) / (1.0 - x));
return (1.0 / sgmp) * log((1.0 + sgmcomp * x) / (1.0 - sgmcomp * x));
}
vec4 invsigmoid(vec4 x) {
return (1.0 / 6.333) * log((1.0 + x) / (1.0 - x));
return (1.0 / sgmp) * log((1.0 + sgmcomp * x) / (1.0 - sgmcomp * x));
}
vec4 sigmoidmix(vec4 a, vec4 b, float x) {
@@ -1023,20 +1026,23 @@ vec4 grey(vec4 color) {
return vec4(lum, lum, lum, color.a);
}
uniform float sgmp = 4.3;
float sgmcomp = 2.0 / (1.0 + exp(-sgmp)) - 1.001; // making sure everything sits within [0..1)
float sigmoid(float x) {
return 2.0 / (1.0 + exp(-6.333 * x)) - 1.0;
return (2.0 / (1.0 + exp(-sgmp * x)) - 1.0) / sgmcomp;
}
vec4 sigmoid(vec4 x) {
return 2.0 / (1.0 + exp(-6.333 * x)) - 1.0;
return (2.0 / (1.0 + exp(-sgmp * x)) - 1.0) / sgmcomp;
}
float invsigmoid(float x) {
return (1.0 / 6.333) * log((1.0 + x) / (1.0 - x));
return (1.0 / sgmp) * log((1.0 + sgmcomp * x) / (1.0 - sgmcomp * x));
}
vec4 invsigmoid(vec4 x) {
return (1.0 / 6.333) * log((1.0 + x) / (1.0 - x));
return (1.0 / sgmp) * log((1.0 + sgmcomp * x) / (1.0 - sgmcomp * x));
}
vec4 sigmoidmix(vec4 a, vec4 b, float x) {

View File

@@ -1,6 +1,5 @@
package net.torvald.tsvm.peripheral
import com.badlogic.gdx.graphics.Camera
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.GL20
import com.badlogic.gdx.graphics.Texture
@@ -9,19 +8,7 @@ import net.torvald.tsvm.VM
import net.torvald.tsvm.kB
import kotlin.math.absoluteValue
open class TexticsAdapter(vm: VM, config: AdapterConfig = AdapterConfig(
"crt_white",
720,
480,
80,
32,
254,
0,
256.kB(),
"./hp2640.png",
0.32f,
GraphicsAdapter.TEXT_TILING_SHADER_MONOCHROME
)) : GraphicsAdapter(vm, config) {
open class TexticsAdapterBase(vm: VM, config: AdapterConfig) : GraphicsAdapter(vm, config) {
private val crtGradTex = Texture("./assets/crt_grad.png")
@@ -77,7 +64,21 @@ open class TexticsAdapter(vm: VM, config: AdapterConfig = AdapterConfig(
}
}
class WpTerm(vm: VM) : TexticsAdapter(vm = vm, AdapterConfig(
class Term(vm: VM) : TexticsAdapterBase(vm, AdapterConfig(
"crt_white",
720,
480,
80,
32,
254,
0,
256.kB(),
"./hp2640.png",
0.32f,
GraphicsAdapter.TEXT_TILING_SHADER_MONOCHROME
))
class WpTerm(vm: VM) : TexticsAdapterBase(vm, AdapterConfig(
"crt_amber",
810,
300,