branchless = better performance.
This commit is contained in:
@@ -6,6 +6,8 @@ PROGRAMMING
|
|||||||
+ try to have dialogue for every wrong interaction
|
+ try to have dialogue for every wrong interaction
|
||||||
+ preload all sounds
|
+ preload all sounds
|
||||||
+ behind house left direction not great
|
+ behind house left direction not great
|
||||||
|
+ spying broken
|
||||||
|
+ z-index of bloodclots gem can be in front
|
||||||
|
|
||||||
IOS
|
IOS
|
||||||
+ all mp3s
|
+ all mp3s
|
||||||
|
|||||||
@@ -29,3 +29,10 @@
|
|||||||
|
|
||||||
(defn reload []
|
(defn reload []
|
||||||
(on-gl (set-screen! advent title/title-screen)))
|
(on-gl (set-screen! advent title/title-screen)))
|
||||||
|
|
||||||
|
(set-screen-wrapper! (fn [screen screen-fn]
|
||||||
|
(try (screen-fn)
|
||||||
|
(catch Exception e
|
||||||
|
(.log Gdx/app (with-out-str (.printStackTrace e)))
|
||||||
|
(.printStackTrace e)
|
||||||
|
(set-screen! advent title/title-screen)))))
|
||||||
|
|||||||
@@ -485,7 +485,7 @@
|
|||||||
:door (assoc (animation->texture screen door)
|
:door (assoc (animation->texture screen door)
|
||||||
:x 160 :y 97 :baseline 99
|
:x 160 :y 97 :baseline 99
|
||||||
:open door
|
:open door
|
||||||
:door-sound (sound "door.ogg")
|
:door-sound (utils/load-sound "door.ogg")
|
||||||
:anim-sound-frames {door {1 [:door-sound 1.0]}}
|
:anim-sound-frames {door {1 [:door-sound 1.0]}}
|
||||||
)
|
)
|
||||||
:sword (assoc (utils/get-texture "inside-castle/sword.png")
|
:sword (assoc (utils/get-texture "inside-castle/sword.png")
|
||||||
|
|||||||
@@ -84,109 +84,53 @@ uniform float hue_amount;
|
|||||||
|
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
vec3 RGBToHSL(vec3 color)
|
float Epsilon = 1e-10;
|
||||||
|
|
||||||
|
vec3 RGBtoHCV (vec3 RGB)
|
||||||
{
|
{
|
||||||
vec3 hsl; // init to 0 to avoid warnings ? (and reverse if + remove first part)
|
// Based on work by Sam Hocevar and Emil Persson
|
||||||
|
vec4 P = (RGB.g < RGB.b) ? vec4 (RGB.bg, -1.0, 2.0/3.0) : vec4 (RGB.gb, 0.0, -1.0/3.0);
|
||||||
float fmin = min(min(color.r, color.g), color.b); //Min. value of RGB
|
vec4 Q = (RGB.r < P.x) ? vec4 (P.xyw, RGB.r) : vec4 (RGB.r, P.yzx);
|
||||||
float fmax = max(max(color.r, color.g), color.b); //Max. value of RGB
|
float C = Q.x - min (Q.w, Q.y);
|
||||||
float delta = fmax - fmin; //Delta RGB value
|
float H = abs ((Q.w - Q.y) / (6.0 * C + Epsilon) + Q.z);
|
||||||
|
return vec3 (H, C, Q.x);
|
||||||
hsl.z = (fmax + fmin) / 2.0; // Luminance
|
|
||||||
|
|
||||||
if (delta == 0.0)//This is a gray, no chroma...
|
|
||||||
{
|
|
||||||
hsl.x = 0.0;// Hue
|
|
||||||
hsl.y = 0.0;// Saturation
|
|
||||||
}
|
|
||||||
else //Chromatic data...
|
|
||||||
{
|
|
||||||
if (hsl.z < 0.5)
|
|
||||||
hsl.y = delta / (fmax + fmin); // Saturation
|
|
||||||
else
|
|
||||||
hsl.y = delta / (2.0 - fmax - fmin); // Saturation
|
|
||||||
|
|
||||||
float deltaR = (((fmax - color.r) / 6.0) + (delta / 2.0)) / delta;
|
|
||||||
float deltaG = (((fmax - color.g) / 6.0) + (delta / 2.0)) / delta;
|
|
||||||
float deltaB = (((fmax - color.b) / 6.0) + (delta / 2.0)) / delta;
|
|
||||||
|
|
||||||
if (color.r == fmax )
|
|
||||||
hsl.x = deltaB - deltaG; // Hue
|
|
||||||
else if (color.g == fmax)
|
|
||||||
hsl.x = (1.0 / 3.0) + deltaR - deltaB; // Hue
|
|
||||||
else if (color.b == fmax)
|
|
||||||
hsl.x = (2.0 / 3.0) + deltaG - deltaR; // Hue
|
|
||||||
|
|
||||||
if (hsl.x < 0.0)
|
|
||||||
hsl.x += 1.0; // Hue
|
|
||||||
else if (hsl.x > 1.0)
|
|
||||||
hsl.x -= 1.0; // Hue
|
|
||||||
}
|
|
||||||
|
|
||||||
return hsl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float HueToRGB(float f1, float f2, float hue)
|
vec3 HUEtoRGB(float H)
|
||||||
{
|
{
|
||||||
if (hue < 0.0)
|
float R = abs(H * 6.0 - 3.0) - 1.0;
|
||||||
hue += 1.0;
|
float G = 2.0 - abs(H * 6.0 - 2.0);
|
||||||
else if (hue > 1.0)
|
float B = 2.0 - abs(H * 6.0 - 4.0);
|
||||||
hue -= 1.0;
|
return clamp(vec3(R,G,B), 0.0, 1.0);
|
||||||
float res;
|
|
||||||
if ((6.0 * hue) < 1.0)
|
|
||||||
res = f1 + (f2 - f1) * 6.0 * hue;
|
|
||||||
else if ((2.0 * hue) < 1.0)
|
|
||||||
res = f2;
|
|
||||||
else if ((3.0 * hue) < 2.0)
|
|
||||||
res = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0;
|
|
||||||
else
|
|
||||||
res = f1;
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 HSLToRGB(vec3 hsl)
|
vec3 HSLtoRGB(vec3 HSL)
|
||||||
{
|
{
|
||||||
vec3 rgb;
|
vec3 RGB = HUEtoRGB(HSL.x);
|
||||||
|
float C = (1.0 - abs(2.0 * HSL.z - 1.0)) * HSL.y;
|
||||||
if (hsl.y == 0.0)
|
return (RGB - 0.5) * C + HSL.z;
|
||||||
rgb = vec3(hsl.z); // Luminance
|
|
||||||
else
|
|
||||||
{
|
|
||||||
float f2;
|
|
||||||
|
|
||||||
if (hsl.z < 0.5)
|
|
||||||
f2 = hsl.z * (1.0 + hsl.y);
|
|
||||||
else
|
|
||||||
f2 = (hsl.z + hsl.y) - (hsl.y * hsl.z);
|
|
||||||
|
|
||||||
float f1 = 2.0 * hsl.z - f2;
|
|
||||||
|
|
||||||
rgb.r = HueToRGB(f1, f2, hsl.x + (1.0/3.0));
|
|
||||||
rgb.g = HueToRGB(f1, f2, hsl.x);
|
|
||||||
rgb.b= HueToRGB(f1, f2, hsl.x - (1.0/3.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
return rgb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 RGBtoHSL(vec3 RGB)
|
||||||
|
{
|
||||||
|
vec3 HCV = RGBtoHCV(RGB);
|
||||||
|
float L = HCV.z - HCV.y * 0.5;
|
||||||
|
float S = HCV.y / (1.0 - abs(L * 2.0 - 1.0) + Epsilon);
|
||||||
|
return vec3(HCV.x, S, L);
|
||||||
|
}
|
||||||
|
|
||||||
vec3 BlendHue(vec3 base, vec3 blend)
|
vec3 BlendHue(vec3 base, vec3 blend)
|
||||||
{
|
{
|
||||||
if (blend.r == blend.g && blend.g == blend.b) {
|
if (blend.r == blend.g && blend.g == blend.b) {
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
vec3 baseHSL = RGBToHSL(base);
|
vec3 baseHSL = RGBtoHSL(base);
|
||||||
return HSLToRGB(vec3(RGBToHSL(blend).r, baseHSL.g, baseHSL.b));
|
return HSLtoRGB(vec3(RGBtoHSL(blend).r, baseHSL.g, baseHSL.b));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color Mode keeps the brightness of the base color and applies both the hue and saturation of the blend color.
|
|
||||||
vec3 BlendColor(vec3 base, vec3 blend)
|
|
||||||
{
|
|
||||||
vec3 blendHSL = RGBToHSL(blend);
|
|
||||||
return HSLToRGB(vec3(blendHSL.r, blendHSL.g, RGBToHSL(base).b));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BlendOpacity(base, blend, F, O) (F(base, blend) * O + blend * (1.0 - O))
|
#define BlendOpacity(base, blend, F, O) (F(base, blend) * O + blend * (1.0 - O))
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
@@ -955,6 +899,8 @@ void main()
|
|||||||
(let [[^OrthographicCamera cam] (utils/setup-viewport screen 320 240)]
|
(let [[^OrthographicCamera cam] (utils/setup-viewport screen 320 240)]
|
||||||
(set! (. cam zoom) 0.95)
|
(set! (. cam zoom) 0.95)
|
||||||
(let [shader (ShaderProgram. ^String v-shader ^String pix-shader)
|
(let [shader (ShaderProgram. ^String v-shader ^String pix-shader)
|
||||||
|
|
||||||
|
|
||||||
_ (update! screen :shader shader)
|
_ (update! screen :shader shader)
|
||||||
rooms {:inside-house (rooms.inside-house/make screen)
|
rooms {:inside-house (rooms.inside-house/make screen)
|
||||||
:inside-stash (rooms.inside-stash/make screen)
|
:inside-stash (rooms.inside-stash/make screen)
|
||||||
|
|||||||
@@ -251,3 +251,5 @@
|
|||||||
:on-resize (fn [{:keys [viewport width height]} [entities]]
|
:on-resize (fn [{:keys [viewport width height]} [entities]]
|
||||||
(.update viewport width height false)
|
(.update viewport width height false)
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
|||||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||||
config.colorFormat = GLKViewDrawableColorFormat.SRGBA8888;
|
config.colorFormat = GLKViewDrawableColorFormat.SRGBA8888;
|
||||||
config.depthFormat = GLKViewDrawableDepthFormat._24;
|
config.depthFormat = GLKViewDrawableDepthFormat._24;
|
||||||
|
config.orientationPortrait = false;
|
||||||
|
config.orientationLandscape = true;
|
||||||
config.preferredFramesPerSecond = 30;
|
config.preferredFramesPerSecond = 30;
|
||||||
|
|
||||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.core"));
|
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.core"));
|
||||||
|
|||||||
Reference in New Issue
Block a user