Skip to content

Instantly share code, notes, and snippets.

vec3 hbao(){
vec3 posc = texture(worldPosTex, UV).rgb;
vec3 norm = texture(normalsTex, UV).rgb;
float buf = 0, counter = 0, div = 1.0/(length(posc)+1.0);
for(float g = 0; g < mPI2; g+=0.52){
for(float g2 = 0.1; g2 < 1.0; g2+=0.29){
vec3 pos = texture(worldPosTex, UV + (vec2(sin(g + g2)*ratio, cos(g + g2)) * (getRand() * 4.09)) * div).rgb;
buf += max(0, sign(length(posc) - length(pos))) * (dot(norm, normalize(pos - posc))) * max(0, (10.0 - length(pos - posc))/10.0);
counter+=0.3;
}
vec2 projdir(vec3 start, vec3 end)
{
vec4 clipspace = (ProjectionMatrix * ViewMatrix) * vec4((start), 1.0);
vec2 sspace1 = ((clipspace.xyz / clipspace.w).xy + 1.0) / 2.0;
clipspace = (ProjectionMatrix * ViewMatrix) * vec4((end), 1.0);
vec2 sspace2 = ((clipspace.xyz / clipspace.w).xy + 1.0) / 2.0;
return (sspace2 - sspace1);
}
bool testVisibility3d(vec2 cuv, vec3 w1, vec3 w2)
@adrian-afl
adrian-afl / MSAA shader resolving
Created March 23, 2015 16:05
MSAA shader resolving
#version 430 core
in vec2 UV;
layout(binding = 0) uniform sampler2DMS texColor;
layout(binding = 1) uniform sampler2DMS texDepth;
const int samples = 8;
float samplesInverted = 1.0 / samples;
vec3 blurWhitening(){
vec3 outc = vec3(0);
for(float g = 0; g < mPI2; g+=0.6){
for(float g2 = 0; g2 < 14.0; g2+=2.0){
vec2 gauss = vec2(sin(g)*ratio, cos(g)) * (g2 * 0.001);
vec3 color = fetchColor(UV + gauss);
float luminance = length(color); // luminance from 1.4 to 1.7320
if(luminance > 1.0){
luminance = (luminance - 1.0) / 0.320;
outc += 0.042857142 * luminance;
using System;
namespace ConsoleApplication4
{
internal class Program
{
private static void Main(string[] args)
{
float test = 666.6666666f;
DateTime now = DateTime.Now;