[ Video ]
[ About ]
危険が危ない飲料フォーナイン!
99.99 is Dangerous Drink .
[ Source ]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#pragma once #include "ofMain.h" class ofApp : public ofBaseApp { public: void setup(); void update(); void draw(); void keyPressed(int key) {}; void keyReleased(int key) {}; void mouseMoved(int x, int y) {}; void mouseDragged(int x, int y, int button) {}; void mousePressed(int x, int y, int button) {}; void mouseReleased(int x, int y, int button) {}; void mouseEntered(int x, int y) {}; void mouseExited(int x, int y) {}; void windowResized(int w, int h) {}; void dragEvent(ofDragInfo dragInfo) {}; void gotMessage(ofMessage msg) {}; ofImage image; vector<glm::vec3> y_noise; ofShader shader; }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(239); ofSetColor(39); this->image.load("images/chu-hi.png"); for (int i = 0; i < ofGetHeight(); i++) { this->y_noise.push_back(glm::vec3(0.f, 0.f, 0.f)); } this->shader.load("shader/shader.vert", "shader/shader.frag"); } //-------------------------------------------------------------- void ofApp::update() { glm::vec3 noise_value; for (int y = 0; y < this->y_noise.size(); y++) { if (y % 25 == 0) { for (int i = 0; i < 3; i++) { noise_value[i] = ofMap(ofNoise(i * 10, y * 0.05, ofGetFrameNum() * 0.03), 0, 1, -1, 1); if (noise_value[i] > 0.5) { noise_value[i] -= 0.5; } else if (noise_value[i] < -0.5) { noise_value[i] += 0.5; } else { noise_value[i] = 0.0; } } } this->y_noise[y] = noise_value; } } //-------------------------------------------------------------- void ofApp::draw() { this->shader.begin(); this->shader.setUniform1f("time", ofGetElapsedTimef()); this->shader.setUniform2f("resolution", ofGetWidth(), ofGetHeight()); this->shader.setUniformTexture("tex", this->image, 1); this->shader.setUniform3fv("y_noise", &this->y_noise[0].x, ofGetHeight()); ofDrawRectangle(0, 0, ofGetWidth(), ofGetHeight()); this->shader.end(); } //-------------------------------------------------------------- int main() { ofGLWindowSettings settings; settings.setGLVersion(3, 2); settings.setSize(720, 720); ofCreateWindow(settings); ofRunApp(new ofApp()); } |
1 2 3 4 5 6 7 8 |
#version 150 uniform mat4 modelViewProjectionMatrix; in vec4 position; void main(){ gl_Position = modelViewProjectionMatrix * position; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#version 150 uniform float time; uniform vec2 resolution; uniform sampler2DRect tex; uniform vec3 y_noise[720]; out vec4 outputColor; void main() { float drift = 360.0; float r = texture(tex, vec2(gl_FragCoord.x + drift * y_noise[int(gl_FragCoord.y)].r, (resolution.y - gl_FragCoord.y))).r; float g = texture(tex, vec2(gl_FragCoord.x + drift * y_noise[int(gl_FragCoord.y)].g, (resolution.y - gl_FragCoord.y))).g; float b = texture(tex, vec2(gl_FragCoord.x + drift * y_noise[int(gl_FragCoord.y)].b, (resolution.y - gl_FragCoord.y))).b; outputColor = vec4(r, g, b, 1.0); } |