Skip to content

Instantly share code, notes, and snippets.

View dariomanesku's full-sized avatar

Dario Manesku dariomanesku

View GitHub Profile
@dariomanesku
dariomanesku / helpers.sh.diff
Last active April 22, 2016 08:19
Fix diff for examples/xx_arealights/helpers.sh to avoid " error C7528: OpenGL reserves names containing '__' ".
164c164
< vec3 FetchDiffuseFilteredTexture(sampler2D texLightFiltered, vec3 _p1, vec3 _p2, vec3 _p3, vec3 _p4)
---
> vec3 FetchDiffuseFilteredTexture(sampler2D texLightFiltered, vec3 p1_, vec3 p2_, vec3 p3_, vec3 p4_)
167,168c167,168
< vec3 V1 = _p2 - _p1;
< vec3 V2 = _p4 - _p1;
---
> vec3 V1 = p2_ - p1_;
> vec3 V2 = p4_ - p1_;
@dariomanesku
dariomanesku / main.cpp
Last active June 5, 2017 20:17
Different output between GCC and MSVC. What is going on here?
#include <stdio.h>
#include <stdint.h>
#include <new>
struct Empty { }; // implicitly-defined default ctor
struct Foo : Empty
{
uint8_t a;
uint8_t b;
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <string.h>
#define streq(a, b) (!strcmp((a), (b)))
#ifndef __USE_GNU
#define __USE_GNU
@dariomanesku
dariomanesku / Tex2DCatmullRom.hlsl
Created September 19, 2016 09:11 — forked from TheRealMJP/Tex2DCatmullRom.hlsl
An HLSL function for sampling a 2D texture with Catmull-Rom filtering, using 9 texture samples instead of 16
// Samples a texture with Catmull-Rom filtering, using 9 texture fetches instead of 16.
// See http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details
float4 SampleTextureCatmullRom(in Texture2D<float4> tex, in SamplerState linearSampler, in float2 uv, in float2 texSize)
{
// We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding
// down the sample location to get the exact center of our "starting" texel. The starting texel will be at
// location [1, 1] in the grid, where [0, 0] is the top left corner.
float2 samplePos = uv * texSize;
float2 texPos1 = floor(samplePos - 0.5f) + 0.5f;
@dariomanesku
dariomanesku / WorldNormalFromDepthTexture.shader
Created March 5, 2023 03:50 — forked from bgolus/WorldNormalFromDepthTexture.shader
Different methods for getting World Normal from Depth Texture, without any external script dependencies.
Shader "WorldNormalFromDepthTexture"
{
Properties {
[KeywordEnum(3 Tap, 4 Tap, Improved, Accurate)] _ReconstructionMethod ("Normal Reconstruction Method", Float) = 0
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 100