Skip to content

Instantly share code, notes, and snippets.

@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>
@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 )
/*
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 / 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 );
@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);
}
All credits to http://wind.cs.purdue.edu/doc/adhoc.html
=======================================================
I tried creating an Ad-Hoc network in the raspberry pi and it works.
In that way you can connect from your Mac/PC to the RPI directly.
I think this might be of intereset for the wind people so I have added
them to the conversation.
Here is the website were it is described.
#include <d3dx9.h>
//UV with intensity over framerate-time
static const char PixelShaderCode[] = \
"ps_3_0\n"
"def c1, 500.0, 500.0, .0, .0\n"
"dcl vPos.xy\n"
"rcp r0.x, c1.x\n"
"mov r0.y, c1.z\n"
"mul r1.xyz, r0.xxy, vPos.xyy\n"
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Protoype of Free-Form Deformation based on http://faculty.cs.tamu.edu/schaefer/teaching/689_Fall2006/p151-sederberg.pdf
public class FFDModifier : MonoBehaviour
{
public GameObject modelObject;
public GameObject ffdGizmo;
public int divX;
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
Shader "Unlit/VolumeMarching"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{