Skip to content

Instantly share code, notes, and snippets.

@BeRo1985
BeRo1985 / octahedralmap.glsl
Last active December 3, 2023 05:01
GLSL Octahedral Texture Mapping with Edge Mirroring and Bilinear Interpolation
// GLSL Octahedral Texture Mapping with Edge Mirroring and Bilinear Interpolation (by Benjamin 'BeRo' Rosseaux)
ivec2 wrapOctahedralTexelCoordinates(const in ivec2 texel, const in ivec2 texSize) {
ivec2 wrapped = ((texel % texSize) + texSize) % texSize;
return ((((abs(texel.x / texSize.x) + int(texel.x < 0)) ^ (abs(texel.y / texSize.y) + int(texel.y < 0))) & 1) != 0) ? (texSize - (wrapped + ivec2(1))) : wrapped;
}
vec4 textureOctahedralMap(const in sampler2D tex, vec3 direction) {
direction = normalize(direction); // just for to make sure that it is normalized
vec2 uv = direction.xy / (abs(direction.x) + abs(direction.y) + abs(direction.z));
@gkaerts
gkaerts / bindless.hlsl
Last active August 12, 2023 15:19
Vulkan and D3D12 typed bindless resources in one shader-side API
// This file should be compiled with DXC against shader model 6.6
// Change the TARGET_API define here to either D3D or VK and switch compiler output formats (DXIL or SPIR-V) to match
#define D3D 1
#define VK 2
#define TARGET_API D3D
// Begin macro magic
#if TARGET_API == D3D
// No special root signature needed!
@PROGrand
PROGrand / FileExtensions.cs
Last active April 22, 2024 13:39
Enable file extensions view in Unity Project window.
using UnityEditor;
using UnityEngine;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Reflection;
[InitializeOnLoad]
public class FileExtensionGUI
{