Skip to content

Instantly share code, notes, and snippets.

View jdolan's full-sized avatar

Jay Dolan jdolan

View GitHub Profile
@jdolan
jdolan / index.html
Created July 23, 2015 18:42
Bassdrive HTML5 player
<audio controls autoplay="autoplay"><source src="http:///shouthost.com.17.streams.bassdrive.com:8200/;stream.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
@jdolan
jdolan / r_occlude.c
Created January 10, 2023 14:29
Decoupling renderer framerate from occlusion query framerate.
/**
* @brief Updates and re-draws active occlusion queries for the current frame.
*/
void R_UpdateOcclusionQueries(r_view_t *view) {
if (!r_occlude->integer) {
return;
}
if (view->flags & VIEW_FLAG_NO_DELTA) {
@jdolan
jdolan / r_occlude_wrong.c
Created January 10, 2023 14:32
Naive OpenGL Occlusion Query implementation (don't do this).
glBeginQuery(GL_ANY_SAMPLES_PASSED, query->name);
glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, query->elements); // draw the AABB
glEndQuery(GL_ANY_SAMPLES_PASSED);
glGetQueryObjectiv(query->name, GL_QUERY_RESULT, &query->result);
if (query->result) {
// draw the object(s) the query was guarding
}
@jdolan
jdolan / shadow_gs.glsl
Created January 10, 2023 14:34
Point shadows geometry shader using cubemap array texture
void main() {
light_t light = lights[light_index];
vec4 translate = vec4(-light.model.xyz, 0.0);
for (int i = 0; i < 6; i++) {
gl_Layer = light_index * 6 + i;
for (int j = 0; j < 3; j++) {
@jdolan
jdolan / shadowmapping.glsl
Created January 10, 2023 14:35
Shadow sampler of a cubemap array texture in GLSL
uniform samplerCubeArrayShadow texture_shadowmap_cube;
/**
* @return The fraction of the sample that is _not_ shadowed (0.0 - 1.0).
*/
float sample_shadowmap(in light_t light, in int index) {
// the position of the fragment in light space
vec4 position = vec4(light.model.xyz - vertex.model, 1.0);
@jdolan
jdolan / render_loop.c
Last active January 10, 2023 14:45
This won't work, either..
drawDepthPass();
drawOcclusionQueries();
populateScene();
updateOcclusionQueries();
drawScene();