[update] Implemented a contrast posteffect.
This commit is contained in:
parent
05377b7472
commit
87b4d5af07
@ -12,14 +12,17 @@ class PostEffect {
|
|||||||
struct Instance {
|
struct Instance {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
align(1) float raster_fineness = 600;
|
align(4) float raster_fineness = 600;
|
||||||
///
|
///
|
||||||
align(1) float raster_width = 0;
|
align(4) float raster_width = 0;
|
||||||
|
|
||||||
///
|
///
|
||||||
align(1) vec2 clip_lefttop = vec2(0, 0);
|
align(8) vec2 clip_lefttop = vec2(0, 0);
|
||||||
///
|
///
|
||||||
align(1) vec2 clip_rightbottom = vec2(0, 0);
|
align(8) vec2 clip_rightbottom = vec2(0, 0);
|
||||||
|
|
||||||
|
///
|
||||||
|
align(16) vec4 contrast = vec4(1, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -125,6 +128,8 @@ class PostEffectProgram {
|
|||||||
|
|
||||||
vec2 clip_lefttop;
|
vec2 clip_lefttop;
|
||||||
vec2 clip_rightbottom;
|
vec2 clip_rightbottom;
|
||||||
|
|
||||||
|
vec4 contrast;
|
||||||
} instance;
|
} instance;
|
||||||
|
|
||||||
in vec2 uv_;
|
in vec2 uv_;
|
||||||
@ -141,6 +146,12 @@ class PostEffectProgram {
|
|||||||
vec2 tex_uv = (uv + vec2(1, 1)) / 2;
|
vec2 tex_uv = (uv + vec2(1, 1)) / 2;
|
||||||
pixel_ = texture(fb, fb_size * tex_uv);
|
pixel_ = texture(fb, fb_size * tex_uv);
|
||||||
|
|
||||||
|
// contrast
|
||||||
|
pixel_.r = pow(pixel_.r, instance.contrast.r);
|
||||||
|
pixel_.g = pow(pixel_.g, instance.contrast.g);
|
||||||
|
pixel_.b = pow(pixel_.b, instance.contrast.b);
|
||||||
|
pixel_.a = pow(pixel_.a, instance.contrast.a);
|
||||||
|
|
||||||
// clipping
|
// clipping
|
||||||
pixel_.a *=
|
pixel_.a *=
|
||||||
step(-1+instance.clip_lefttop.x, uv_.x) *
|
step(-1+instance.clip_lefttop.x, uv_.x) *
|
||||||
|
@ -45,7 +45,7 @@ class Game : AbstractGame {
|
|||||||
|
|
||||||
lobby_ = new LobbyWorld(programs_);
|
lobby_ = new LobbyWorld(programs_);
|
||||||
|
|
||||||
title_ = new TitleScene(lobby_, programs_);
|
title_ = new TitleScene(posteffect_, lobby_, programs_);
|
||||||
select_ = new SelectScene(lobby_, programs_, fonts_, music_list_);
|
select_ = new SelectScene(lobby_, programs_, fonts_, music_list_);
|
||||||
load_ = new LoadingScene(lobby_, posteffect_, programs_, fonts_);
|
load_ = new LoadingScene(lobby_, posteffect_, programs_, fonts_);
|
||||||
play_ = new PlayScene(posteffect_);
|
play_ = new PlayScene(posteffect_);
|
||||||
|
@ -6,6 +6,8 @@ import std.conv,
|
|||||||
|
|
||||||
import gl4d;
|
import gl4d;
|
||||||
|
|
||||||
|
static import sjplayer;
|
||||||
|
|
||||||
import sj.KeyInput,
|
import sj.KeyInput,
|
||||||
sj.LobbyWorld,
|
sj.LobbyWorld,
|
||||||
sj.ProgramSet,
|
sj.ProgramSet,
|
||||||
@ -34,9 +36,12 @@ class TitleScene : SceneInterface {
|
|||||||
enum BgOuterColor = vec4(-0.1, -0.1, -0.1, 1);
|
enum BgOuterColor = vec4(-0.1, -0.1, -0.1, 1);
|
||||||
///
|
///
|
||||||
enum CubeInterval = 0.005;
|
enum CubeInterval = 0.005;
|
||||||
|
///
|
||||||
|
enum Contrast = vec4(1.2, 1.2, 1.2, 1);
|
||||||
|
|
||||||
///
|
///
|
||||||
this(LobbyWorld lobby, ProgramSet program) {
|
this(sjplayer.PostEffect posteffect, LobbyWorld lobby, ProgramSet program) {
|
||||||
|
posteffect_ = posteffect;
|
||||||
lobby_ = lobby;
|
lobby_ = lobby;
|
||||||
title_ = program.Get!TitleTextProgram;
|
title_ = program.Get!TitleTextProgram;
|
||||||
}
|
}
|
||||||
@ -54,6 +59,8 @@ class TitleScene : SceneInterface {
|
|||||||
bg_outer_ease_ = Easing!vec4(lobby_.background.outer_color, BgOuterColor);
|
bg_outer_ease_ = Easing!vec4(lobby_.background.outer_color, BgOuterColor);
|
||||||
|
|
||||||
cube_interval_ease_ = Easing!float(lobby_.cube_interval, CubeInterval);
|
cube_interval_ease_ = Easing!float(lobby_.cube_interval, CubeInterval);
|
||||||
|
|
||||||
|
contrast_ease_ = Easing!vec4(posteffect_.contrast, Contrast);
|
||||||
}
|
}
|
||||||
override SceneInterface Update(KeyInput input) {
|
override SceneInterface Update(KeyInput input) {
|
||||||
const ratio = anime_.Update();
|
const ratio = anime_.Update();
|
||||||
@ -65,6 +72,8 @@ class TitleScene : SceneInterface {
|
|||||||
|
|
||||||
lobby_.cube_interval = cube_interval_ease_.Calculate(ratio);
|
lobby_.cube_interval = cube_interval_ease_.Calculate(ratio);
|
||||||
|
|
||||||
|
posteffect_.contrast = contrast_ease_.Calculate(ratio);
|
||||||
|
|
||||||
if (anime_.isFinished && input.down) {
|
if (anime_.isFinished && input.down) {
|
||||||
select_scene_.Initialize();
|
select_scene_.Initialize();
|
||||||
return select_scene_;
|
return select_scene_;
|
||||||
@ -80,6 +89,8 @@ class TitleScene : SceneInterface {
|
|||||||
private:
|
private:
|
||||||
SelectScene select_scene_;
|
SelectScene select_scene_;
|
||||||
|
|
||||||
|
sjplayer.PostEffect posteffect_;
|
||||||
|
|
||||||
LobbyWorld lobby_;
|
LobbyWorld lobby_;
|
||||||
|
|
||||||
TitleTextProgram title_;
|
TitleTextProgram title_;
|
||||||
@ -89,4 +100,6 @@ class TitleScene : SceneInterface {
|
|||||||
Easing!vec4 bg_inner_ease_;
|
Easing!vec4 bg_inner_ease_;
|
||||||
Easing!vec4 bg_outer_ease_;
|
Easing!vec4 bg_outer_ease_;
|
||||||
Easing!float cube_interval_ease_;
|
Easing!float cube_interval_ease_;
|
||||||
|
|
||||||
|
Easing!vec4 contrast_ease_;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user