Skip to content

Instantly share code, notes, and snippets.

View antoinefortin's full-sized avatar

Antoine Fortin antoinefortin

  • Montreal, Canada
View GitHub Profile
/* SDF */
float sdSphere( vec3 p, float s )
{
return length(p)-s;
}
float sdBox( vec3 p, vec3 b )
{
vec3 q = abs(p) - b;
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = (2.0 * fragCoord- iResolution.xy) / iResolution.y;
vec3 ro = vec3(0., 2.0, -5.);
vec3 rd = normalize(vec3(uv.x, uv.y, 1.));
vec3 col = vec3(0.25, .15, .2); // Sky color
PVector location;
PVector velocity;
Mover mover;
void setup()
{
size(640, 360);
location = new PVector(100,100);
velocity = new PVector(2.5, 5.);
mover = new Mover();
/* Use this to clear GBuffer like...*/
float3 GetNormalWorldSpace(float2 uv, float depth)
{
float3 normalWS = 0.0f;
if (depth > 0.0f)
{
NormalData normalData;
const float4 normalBuffer = LOAD_TEXTURE2D_X(_NormalBufferTexture, uv);
DecodeFromNormalBuffer(normalBuffer, uv, normalData);
float3 normalWS = GetNormalWorldSpace(positionSSRegular, depth);
float GetDepth(int2 SSRegular)
{
return LOAD_TEXTURE2D_X(_CameraDepthTexture, SSRegular).x;
}
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
float4 CustomPostProcess(Varyings input) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
uint2 positionSSRegular = input.texcoord* _ScreenSize.xy;...
#include <iostream>
#include <cmath>
#include <fstream>
#define M_PI 3.1415926
using namespace std;
const int sampleRate = 44100;
const int bitDepth = 16;
class SineOscillator {
#include <conio.h>
void print(const char* s)
{
for (; *s != 0; s++)
{
_putch(*s);
}
}