time diversifasdasdsad

This commit is contained in:
serk 2017-01-22 05:03:56 +01:00
parent e6234333a6
commit 5e8d22d51e
3 changed files with 23 additions and 3 deletions

View file

@ -1,5 +1,6 @@
uniform vec2 resolution; uniform vec2 resolution;
uniform float time; uniform float time;
uniform float night;
float rand(vec2 n) { float rand(vec2 n) {
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453); return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
@ -36,8 +37,11 @@ void main(void) {
if (uv.y < umuv.y) uv.y += abs(time * 0.1); if (uv.y < umuv.y) uv.y += abs(time * 0.1);
else uv.y -= abs(time * 0.1); else uv.y -= abs(time * 0.1);
vec3 colorPink = vec3(255.,0.,255.);
vec4 color = vec4(255, 120, 153, 255) / 255.; vec3 colorBlue = vec3(0.,255.,255.);
vec4 colorB = vec4(255,255,255,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.;
gl_FragColor = (grid(fract(uv))) * color - line(umuv.y, 0., 0.175, 0.025) * color * 2.; gl_FragColor = (grid(fract(uv))) * color - line(umuv.y, 0., 0.175, 0.025) * color * 2.;
} }

View file

@ -61,13 +61,24 @@ void Combat::updateHalo() {
} }
float isNight() {
time_t rawtime;
struct tm * ptm;
time ( &rawtime );
ptm = gmtime ( &rawtime );
return (float ((ptm->tm_hour+UTC)%24))/(23.);
}
void Combat::initShader() { void Combat::initShader() {
time = 0; time = 0;
aux = 0;
_text.create(W_WIDTH, W_HEIGHT); _text.create(W_WIDTH, W_HEIGHT);
_background.setTexture(_text); _background.setTexture(_text);
_shader.loadFromFile(WORK_DIR+"Resources/shader.frag", sf::Shader::Fragment); _shader.loadFromFile(WORK_DIR+"Resources/shader.frag", sf::Shader::Fragment);
_shader.setParameter("resolution", sf::Vector2f(W_WIDTH, W_HEIGHT)); _shader.setParameter("resolution", sf::Vector2f(W_WIDTH, W_HEIGHT));
_shader.setParameter("time", time); _shader.setParameter("time", time);
_shader.setParameter("night", isNight());
ASSERT(_haloT.loadFromFile(WORK_DIR+"Resources/platform-halo.png")); ASSERT(_haloT.loadFromFile(WORK_DIR+"Resources/platform-halo.png"));
_halo.setTexture(_haloT); _halo.setTexture(_haloT);

View file

@ -10,6 +10,10 @@
#include "soundmanager.hpp" #include "soundmanager.hpp"
#include "score.hpp" #include "score.hpp"
#include "wave.hpp" #include "wave.hpp"
#include <time.h>
#define UTC (0)
class Combat : public Scene { class Combat : public Scene {
public: public:
@ -40,6 +44,7 @@ class Combat : public Scene {
bool isPlayerOne() const; bool isPlayerOne() const;
void updateHalo(); void updateHalo();
void doMahWaves(bool p); void doMahWaves(bool p);
int aux;
}; };