Skip to content

Instantly share code, notes, and snippets.

View cmbruns's full-sized avatar

Christopher Bruns cmbruns

View GitHub Profile
#version 450 core
// Vertex shader for rendering an infinite plane.
void main() {} // vertex shader does nothing. All the work is done in the geometry shader
#version 450 core
// Simplified vertex shader for rendering an infinite plane.
layout(location = 1) uniform mat4 projection = mat4(1);
layout(location = 2) uniform mat4 view = mat4(1);
layout(location = 3) uniform mat4 model = mat4(
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
#version 450 core
in vec4 intersection_model; // in model space
out vec4 frag_color;
void main()
{
// simple but expensive 2: discard pixels not on the plane
if (intersection_model.w > 0)
discard;
#version 450 core
// Simplified vertex shader for rendering an infinite plane.
layout(location = 1) uniform mat4 projection = mat4(1);
layout(location = 2) uniform mat4 view = mat4(1);
uniform mat4 model = mat4(1);
// simple but expensive 1: vertices cover the entire screen
// projected screen quad - this is our hard-coded "vertex buffer"
@cmbruns
cmbruns / custom_iterator.cpp
Last active August 3, 2018 16:51 — forked from jeetsukumaran/custom_iterator.cpp
Sample C++/STL custom iterator
// Sample custom iterator.
// By perfectly.insane (http://www.dreamincode.net/forums/index.php?showuser=76558)
// From: http://www.dreamincode.net/forums/index.php?showtopic=58468
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cassert>