Skip to content

Instantly share code, notes, and snippets.

View shinmai's full-sized avatar
😫
coping admirably

Shi Saaristo shinmai

😫
coping admirably
View GitHub Profile
@shinmai
shinmai / Curved.shader
Created October 17, 2017 12:58 — forked from grimmdev/Curved.shader
Subway Surfer like Curved World Shader for Unity
Shader "Custom/Curved" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_QOffset ("Offset", Vector) = (0,0,0,0)
_Dist ("Distance", Float) = 100.0
}
SubShader {
Tags { "RenderType"="Opaque" }
Pass
{
//http://iquilezles.org/www/articles/distfunctions/distfunctions.htm
// -- Distant functions
float sdPlane( vec3 p ) {return p.y+0.2;}
float sdSphere( vec3 p, float s ) {return length(p)-s;}
float sdCylinder( vec3 p, vec3 c ){ return length(p.xz-c.xy)-c.z; }
float udRoundBox( vec3 p, vec3 b, float r ){return length(max(abs(p)-b,0.0))-r;}
float udRoundBoxInf( vec3 p, vec2 b, float r ){return length(max(vec3(abs(p.xz)-b,0.0),0.0))-r;}
float maxcomp( vec3 p ) {return max(p.x,max(p.y,p.z));}
@shinmai
shinmai / sdfexample.glsl
Created November 13, 2017 21:37 — forked from kchapelier/sdfexample.glsl
hg_sdf + antialiase raymarch by iq + ashima noise
////////////////////////////////////////////////////////////////
//
// HG_SDF
//
// GLSL LIBRARY FOR BUILDING SIGNED DISTANCE BOUNDS
//
// version 2015-12-15 (initial release)
//
// Check http://mercury.sexy/hg_sdf for updates
// and usage examples. Send feedback to spheretracing@mercury.sexy.
@shinmai
shinmai / DeferredRenderer.cpp
Created November 14, 2017 08:18 — forked from heisters/DeferredRenderer.cpp
Deferred Renderer for Cinder (glNext)
#include "DeferredRenderer.h"
#include "cinder/gl/gl.h"
#include "cinder/Log.h"
#include "cinder/Buffer.h"
#include "DeferredRendererShaders.h"
#include "DeferredRenderer_random_png.h"
using namespace ci;
using namespace std;
@shinmai
shinmai / box.glsl
Created November 14, 2017 08:18 — forked from Gitmoko/box.glsl
#ifdef GL_ES
precision mediump float;
#endif
#extension GL_OES_standard_derivatives : enable
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
@shinmai
shinmai / q.glsl
Created November 14, 2017 08:18 — forked from galek/q.glsl
#ifndef PHONG_LIGHTING_INC
#define PHONG_LIGHTING_INC 1
#define USE_OPTIMIZATION 1
#include "BRDF.h"
float GetAngleAttenuation(vec3 _l, vec3 _lightDir, float _angleScale, float _angleOffset)
{
float cosa = -dot(_l, _lightDir);
@shinmai
shinmai / pbr.glsl
Created November 14, 2017 08:18 — forked from galek/pbr.glsl
PBR GLSL SHADER
in vec2 v_texcoord; // texture coords
in vec3 v_normal; // normal
in vec3 v_binormal; // binormal (for TBN basis calc)
in vec3 v_pos; // pixel view space position
out vec4 color;
layout(std140) uniform Transforms
{
mat4x4 world_matrix; // object's world position
@shinmai
shinmai / clearbrdf.glsl
Created November 14, 2017 08:18
GLTracy brdf
// brdf
vec3 radiance(
vec3 n, // macro surface normal
vec3 l, // direction from vertex to light
vec3 v, // direction from vertex to view
// matt
float m, // roughness
vec3 cdiff, // diffuse reflectance
vec3 cspec, // specular reflectance : F0
// light
@shinmai
shinmai / AO.frag
Created November 14, 2017 08:19 — forked from tmpvar/AO.frag
a few raymarching fx that I've found
uniform float aoIntensity; // {"label":"AO intensity", "min":0, "max":1, "step":0.01, "default":0.15, "group":"Shading", "group_label":"Ambient occlusion"}
uniform float aoSpread; // {"label":"AO spread", "min":0, "max":20, "step":0.01, "default":9, "group":"Shading"}
// Ambient occlusion approximation.
// Based upon boxplorer's implementation which is derived from:
// http://www.iquilezles.org/www/material/nvscene2008/rwwtt.pdf
float ambientOcclusion(vec3 p, vec3 n, float eps)
{
float o = 1.0; // Start at full output colour intensity
eps *= aoSpread; // Spread diffuses the effect
#define PI 3.14159265359
#define PI2 6.28318530718
// Comment or uncomment
// (Leave commented if in shadergif)
// (uncomment if in shadertoy)
//#define shadertoy 1
#ifdef shadertoy
// time is iGlobalTime in shadertoy