Skip to content

Instantly share code, notes, and snippets.

@josemorval
josemorval / GLSL-Noise.md
Created November 6, 2017 07:52 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@josemorval
josemorval / fragment.c
Created June 8, 2017 06:57 — forked from Santarh/fragment.c
raymarching
#ifdef GL_ES
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
vec3 y_up = vec3( 0.0, 1.0, 0.0 );
vec3 eye_pos = vec3( 0.0, 0.0, -3.0 );
/*
a shader executes per pixel
so every thing you see here is he function for every pixel
raymarching is in principe a function that finds the closest point to any surface in the world
then we move our point by that distance and use the same function,
the function will probably be closer to an object in the world every time
and after about 40 to 200 iterations you'll either have found an object or
missed them all into infinity
/*
a shader executes per pixel
so every thing you see here is he function for every pixel
raymarching is in principe a function that finds the closest point to any surface in the world
then we move our point by that distance and use the same function,
the function will probably be closer to an object in the world every time
and after about 40 to 200 iterations you'll either have found an object or
missed them all into infinity
@josemorval
josemorval / BitonicSortCS.fx
Created December 27, 2016 11:26 — forked from 43x2/BitonicSortCS.fx
Bitonic sorting in compute shaders
//
// Debug: fxc /E cs_main /T cs_5_0 /Fh (output) /Od /Vn g_BitonicSortCS /Zi (this)
// Release: fxc /E cs_main /T cs_5_0 /Fh (output) /O1 /Vn g_BitonicSortCS (this)
//
// スレッド数
#define THREADS_X 512
// ソート要素数
#define ELEMENTS_TO_SORT ( 1 << 10 )
@josemorval
josemorval / bitonic_sort.cu
Created December 27, 2016 11:23 — forked from mre/bitonic_sort.cu
Bitonic Sort on CUDA. On a quick benchmark it was 10x faster than the CPU version.
/*
* Parallel bitonic sort using CUDA.
* Compile with
* nvcc -arch=sm_11 bitonic_sort.cu
* Based on http://www.tools-of-computing.com/tc/CS/Sorts/bitonic_sort.htm
* License: BSD 3
*/
#include <stdlib.h>
#include <stdio.h>