-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Finish adding color buffer to the shaders * Full assignement, except bonus, finished * Fix code such that it defines a camera rather than moving the objects * formatting * linting * add pdf --------- Co-authored-by: CraZyB1336 <[email protected]>
- Loading branch information
1 parent
b762370
commit 510f75a
Showing
5 changed files
with
289 additions
and
109 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Position for spiral, circle, and triangle. | ||
vec2 p = vec2(2.0 * gl_FragCoord.xy) / 750.0; | ||
|
||
// Spiral | ||
// float theta = atan(p.y, p.x); | ||
// color = spiral(p, 5.0, 12.0) < 0.6 ? pastel_night_sky : moon_white; | ||
|
||
// Burgundy-red | ||
// color = vec4(0.5, 0.0, 0.13, 1.0); | ||
|
||
//Checker-pattern | ||
//int x = int(gl_FragCoord.x); | ||
//int y = int(gl_FragCoord.y); | ||
//color = checkerbox(x, y, 30); | ||
|
||
// Drawn Circle | ||
// float r = 0.3; | ||
// color = sdCircle(p, r); | ||
|
||
// Color over time | ||
// color = vec4(cos(time+24), sin(time * 0.2), atan(time+24, time), 1.0); | ||
|
||
// Manual triangle | ||
// vec2 pos1 = 2.0 * vec2(120.0, 200.0) / 750.0; | ||
// vec2 pos2 = 2.0 * vec2(630.0, 200.0) / 750.0; | ||
// vec2 pos3 = 2.0 * vec2(375.0, 550.0) / 750.0; | ||
// float d = sdTriangle(pos1, pos2, pos3, p); | ||
|
||
// color = mix(night_sky, moon_white, cos(160.0 * d)); | ||
// color *= exp(-2.3 * abs(d)); | ||
|
||
// color = d > 0.0 ? color : mix(color1, vec4(0.5, 0.0, 0.13, 1.0), 1.0 - smoothstep(0.01, 0.3, abs(d))); | ||
|
||
// if (d >= -0.005 && d <= 0.005) | ||
// { | ||
// color = color1; | ||
// } | ||
|
||
// A sine wave | ||
float y = 0.05*sin(10*p.x - PI*time/2) + 0.7; | ||
float white_wave = 0.01*sin(30*p.x - PI*time/1.5) + 0.7; | ||
float blue_wave = 0.02*cos(12*p.x + PI*time) + 0.63; | ||
float light_wave = 0.03*cos(7*p.x - PI*time/1.8) + 0.58; | ||
|
||
if (y > p.y) | ||
{ | ||
color = waves; | ||
if (p.y > light_wave - 0.06) | ||
{ | ||
color = vec4( 84, 136, 200, 255) / 255; | ||
} | ||
if (p.y > blue_wave) | ||
{ | ||
color = vec4( 143, 182, 228, 255) / 255; | ||
} | ||
if (p.y > white_wave) | ||
{ | ||
color = color1; | ||
} | ||
} | ||
else | ||
{ | ||
color = night_sky; | ||
} | ||
|
||
vec2 moon_p = vec2(p.x - 1.0, p.y - 1.2); | ||
float sd = sdCircle(moon_p, 0.15); | ||
vec2 moon_rp = vec2(p.x - 0.92, p.y - 1.24); | ||
float sdrp = sdCircle(moon_rp, 0.09); | ||
|
||
if (sd < 0.0 && sdrp > 0.0) | ||
{ | ||
color = vec4( 243, 249, 169, 255) / 255; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
#version 410 core | ||
|
||
in vec3 position; | ||
layout(location=0) in vec3 position; | ||
layout(location=1) in vec4 color; | ||
|
||
uniform float oscVal; | ||
uniform mat4 matrix; | ||
|
||
out vec4 vertColor; | ||
|
||
void main() | ||
{ | ||
// vec3 flipped_position = vec3(position.x * -1, position.y * -1, position.z); | ||
gl_Position = vec4(position, 1.0f); | ||
vec4 pos = vec4(position, 1.0); | ||
|
||
// When defining our matrix like this | ||
vec4 transformed_position = matrix * pos; | ||
|
||
|
||
gl_Position = transformed_position; | ||
vertColor = color; | ||
} |
Oops, something went wrong.