hour fix
This commit is contained in:
parent
0a589d6a11
commit
71c249426b
4 changed files with 12 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
uniform float night;
|
||||
uniform float hour;
|
||||
|
||||
float rand(vec2 n) {
|
||||
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
|
||||
|
@ -39,9 +39,8 @@ void main(void) {
|
|||
else uv.y -= abs(time * 0.1);
|
||||
vec3 colorPink = vec3(255.,0.,255.);
|
||||
vec3 colorBlue = vec3(0.,255.,255.);
|
||||
vec4 color = vec4(((colorPink.x*night) + (colorBlue.x*(1.-night)))/2.,
|
||||
((colorPink.y*night) + (colorBlue.y*(1.-night)))/2.,
|
||||
((colorPink.z*night) + (colorBlue.z*(1.-night)))/2., 255) / 255.;
|
||||
// color = vec4(122.,202.,255.,255.)/ 255.;
|
||||
vec4 color = vec4(((colorBlue.x*hour) + (colorPink.x*(1.-hour)))/2.,
|
||||
((colorBlue.y*hour) + (colorPink.y*(1.-hour)))/2.,
|
||||
((colorBlue.z*hour) + (colorPink.z*(1.-hour)))/2., 255) / 255.;
|
||||
gl_FragColor = (grid(fract(uv))) * color - line(umuv.y, 0., 0.175, 0.025) * color * 2.;
|
||||
}
|
|
@ -66,8 +66,9 @@ float isNight() {
|
|||
struct tm * ptm;
|
||||
time ( &rawtime );
|
||||
ptm = gmtime ( &rawtime );
|
||||
|
||||
return (float ((ptm->tm_hour+UTC)%24))/(23.);
|
||||
float hour = (float ((ptm->tm_hour+UTC)%24))/(23.);
|
||||
float result = (std::cos(hour*(2*PI)) + 1.f)/2.;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Combat::initShader() {
|
||||
|
@ -78,7 +79,7 @@ void Combat::initShader() {
|
|||
_shader.loadFromFile(WORK_DIR+"Resources/shader.frag", sf::Shader::Fragment);
|
||||
_shader.setParameter("resolution", sf::Vector2f(W_WIDTH, W_HEIGHT));
|
||||
_shader.setParameter("time", time);
|
||||
_shader.setParameter("night", isNight());
|
||||
_shader.setParameter("hour", isNight());
|
||||
|
||||
ASSERT(_haloT.loadFromFile(WORK_DIR+"Resources/platform-halo.png"));
|
||||
_halo.setTexture(_haloT);
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
#include "wave.hpp"
|
||||
#include <time.h>
|
||||
|
||||
#define UTC (0)
|
||||
#define PI 3.14159265
|
||||
|
||||
|
||||
class Combat : public Scene {
|
||||
|
||||
|
|
|
@ -16,6 +16,8 @@ const int SCENE_NUM = 4;
|
|||
#define MARGEERR 0.25f
|
||||
#define BLACKVALUE 0.4f
|
||||
#define W_WIDTH 1024
|
||||
|
||||
#define UTC (0)
|
||||
#define W_HEIGHT 768
|
||||
const std::string WORK_DIR(getenv("WORK_DIR"));
|
||||
|
||||
|
|
Reference in a new issue