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