Hackpads are smart collaborative documents. .

Defne Onen

1084 days ago
Jason L Shaders are fun
Nathan R Check out typing.io!
 
Jason L The following code goes in your bin/data folder
 
Here is the code for the vertex shader "bin/data/shader.vert"
 
  • void main(void)
  • {
  •     gl_TexCoord[0] = gl_MultiTexCoord0;
  •     gl_Position    = ftransform();
  • }
 
here is the code for the fragment(pixel) shader "bin/data/shader.frag"
 
Jason L
  • void main( void )
  • {
  •     float width = 1024.0;
  •     float height = 768.0;
  •         float x = gl_FragCoord.x / width;
  •     float y = gl_FragCoord.y / height;
Jason L
  •     
Jason L
  •     float gray = (x * y);
  •     
  •     
  •     gl_FragColor = vec4(gray, gray, gray, 1.0);
for Defne:
  •  
  • //--------------------------------------------------------------
  •  
  • void ofApp::setup(){
  •  
  •     shader.load("shader");
  •  
  •  
  •  
  • }
  •  
  •  
  •  
  • //--------------------------------------------------------------
  •  
  • void ofApp::update(){
  •  
  •     ofSetWindowTitle("FPS: " + ofToString(ofGetFrameRate()));
  •  
  •  
  •  
  • }
  •  
  •  
  •  
  • //--------------------------------------------------------------
  •  
  • void ofApp::draw(){
  •  
  •     shader.begin();
  •  
  •     ofRect(0, 0, ofGetWidth(), ofGetHeight());
  •  
  •     shader.end();   
  •  
  •  
  •  
  • }
  • Examples:
  •  
  • void main(void)
  • {
  •         float width = 1024.0;
  •         float height = 768.0;
  •         float x = gl_FragCoord.x / width;
  •         float y = gl_FragCoord.y / height;
  •  
  •         float gray;
  •  
  •         if (sin(x * 80) > cos(y * 50)) {
  •                 gray = tan(sin((x * y) * 40.0) * 34.0);
  •         } else {
  •                 gray = tan(y + x);
  •         }
  •  
  •         gl_FragColor = vec4(gray, gray, gray, 1.0);
  •         //gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
  • }
 
 
Defne O Defne's Shader:
code:
 
...
1084 days ago
Unfiled. Edited by Defne Onen 1084 days ago
1119 days ago
Unfiled. Edited by Rachel Rose Ulgado , defne onen 1119 days ago
Rachel U
  • introspection, navelgazers
  • "we are a way for the cosmos to know itself"
  • (How) Could I simulate exploring other galaxies, planets (finding life on other planets, each with their own creatures exhibiting different behaviors?) (How) Could I move this from 2D to 3D? Is this an impossible endeavor?!
 
 
defne o Link's from Defne, check it out:
 
my vimeo account, likes page:
I dont have any of my own videos posted, just use it as a way to gather inspiration!
 
 
1119 days ago
Taeyoon C Oct 30 check in 
Taeyoon's class in two parts
Today. sign up
1pm  -full for 1pm!
 
Yuki Y Yuki Yoshida
 
Defne O Defne Onen
 
Taeyoon C Silent Barn visit
10.30 7~8:30pm 
(everyone welcome) 
Yuki Y Yuki Yoshida (might be late, so directly come to the place)
Lauren G Lauren Gardner (have to leave after, no tacos or rock show for me)
 
Taeyoon C Ida and Taeyoon Brainstorming session 
11.1 
Saturday 12pm 
meeting about Ida's week of exploration and SB event in November . students welcome to join 
 
New Inc mixer sign up
presenting: (4 people limit) 
 
Zan A attending: 
Andrew K Andrew Kleindolph (willing to present if needed)
Defne O Defne Onen(Willing to present too but will decide depending on how my workday today goes)
 
Taeyoon C Christine Sun Kim 1:1 meeting 
11.5 
(6 people limit) 
Andrew K Andrew Kleindolph (if more than 6 people are interested I'm flexible and can give my space)
Defne O Defne Onen
 
 
Taeyoon C ITP mixer sign up 
11.7 
(no limit) 
 
Andrew K Andrew Kleindolph
Defne O Defne Onen
 
 

Contact Support



Please check out our How-to Guide and FAQ first to see if your question is already answered! :)

If you have a feature request, please add it to this pad. Thanks!


Log in