-
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.
In-progress effort towards cooler rendering
- This still works as the previous commit, but some files have been renamed and code has been restructured in some places. - Notably, you can now toggle between rendering modes by pressing the "M" key while the program is running. - However, the more sophisticated rendering mode doesn't currently work. Just don't press 'M' for now; the rest of it still works as before. - Committing so I can try some different geometry shader stuff
- Loading branch information
Showing
13 changed files
with
205 additions
and
18 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#version 330 core | ||
|
||
in GS_OUT { | ||
vec3 frag_position; | ||
vec3 forward; | ||
vec3 up; | ||
vec3 right; | ||
vec4 color; | ||
} fs_in; | ||
|
||
|
||
out vec4 frag_color; | ||
|
||
//INCLUDE_SHARED_UNIFORMS | ||
|
||
void main() { | ||
frag_color = fs_in.color; | ||
} |
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,57 @@ | ||
#version 330 core | ||
layout (lines) in; | ||
layout (triangle_strip, max_vertices = 4) out; | ||
|
||
in VS_OUT { | ||
vec3 position; | ||
vec3 forward; | ||
vec3 up; | ||
vec3 right; | ||
vec4 color; | ||
} gs_in[]; | ||
|
||
out GS_OUT { | ||
vec3 frag_position; | ||
vec3 forward; | ||
vec3 up; | ||
vec3 right; | ||
vec4 color; | ||
} gs_out; | ||
|
||
//INCLUDE_SHARED_UNIFORMS | ||
|
||
void main() { | ||
vec3 right = gs_in[0].right; | ||
vec3 forward = gs_in[0].forward; | ||
vec3 bottom = gs_in[0].position; | ||
vec3 top = gs_in[0].position; | ||
// NOTE: verify this is in the correct order. | ||
mat4 projView = shared_uniforms.projection * shared_uniforms.view; | ||
// The normal vectors don't change. | ||
gs_out.forward = forward; | ||
gs_out.up = gs_in[0].up; | ||
gs_out.right = right; | ||
//gs_out.color = gs_in[1].color; | ||
gs_out.color = vec4(0.5, 0.3, 1.0, 1.0); | ||
|
||
float half_rect_width = 0.5 * shared_uniforms.geometry_thickness * | ||
shared_uniforms.size_scale; | ||
|
||
// Bottom left | ||
gs_out.frag_position = bottom - (right * half_rect_width); | ||
gl_Position = projView * vec4(gs_out.frag_position, 1.0); | ||
EmitVertex(); | ||
// Bottom right | ||
gs_out.frag_position = bottom + (right * half_rect_width); | ||
gl_Position = projView * vec4(gs_out.frag_position, 1.0); | ||
EmitVertex(); | ||
// Top right | ||
gs_out.frag_position = top + (right * half_rect_width); | ||
gl_Position = projView * vec4(gs_out.frag_position, 1.0); | ||
EmitVertex(); | ||
// Top left | ||
gs_out.frag_position = top - (right * half_rect_width); | ||
gl_Position = projView * vec4(gs_out.frag_position, 1.0); | ||
EmitVertex(); | ||
EndPrimitive(); | ||
} |
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,29 @@ | ||
#version 330 core | ||
layout (location = 0) in vec3 position_in; | ||
layout (location = 1) in vec3 forward_in; | ||
layout (location = 2) in vec3 up_in; | ||
layout (location = 3) in vec4 color_in; | ||
|
||
// Added to the location of each vertex to center the overall mesh on 0,0,0. | ||
uniform vec3 location_offset; | ||
|
||
uniform mat4 model; | ||
uniform mat3 normal; | ||
|
||
out VS_OUT { | ||
vec3 position; | ||
vec3 forward; | ||
vec3 up; | ||
vec3 right; | ||
vec4 color; | ||
} vs_out; | ||
|
||
//INCLUDE_SHARED_UNIFORMS | ||
|
||
void main() { | ||
vs_out.position = (model * vec4(position_in + location_offset, 1.0)).xyz; | ||
vs_out.forward = normalize(normal * forward_in); | ||
vs_out.up = normalize(normal * up_in); | ||
vs_out.right = normalize(cross(vs_out.forward, vs_out.up)); | ||
vs_out.color = color_in; | ||
} |
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 |
---|---|---|
|
@@ -2,6 +2,9 @@ | |
|
||
in VS_OUT { | ||
vec3 frag_position; | ||
vec3 forward; | ||
vec3 up; | ||
vec3 right; | ||
vec4 color; | ||
} fs_in; | ||
|
||
|
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
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