[ Video ]
[ About ]
Day 25 Screwdriver
スクリュードライバー(ウォッカ+オレンジ)を買ってきて「酔っちゃった」とするつもりが、3件酒屋をハシゴするも取り扱いがなく、本家・スクリュードライバーの画像で「酔っちゃった」をしなければならなくなった図
[ 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 |
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup() { ofSetFrameRate(60); ofSetWindowTitle("openframeworks"); ofBackground(239); ofSetColor(39); this->image.load("image/drivers.jpg"); 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++) { for (int i = 0; i < 3; i++) { noise_value[i] = ofMap(ofNoise(i, y * 0.005 + ofGetFrameNum() * 0.01), 0, 1, -1, 1); } 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 = 50.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); } |
[ Link ]