Skip to content

Instantly share code, notes, and snippets.

@sakrist
sakrist / homeNAS
Created November 26, 2023 16:05
Building home NAS
Here I will list my components, software setup and some steps that I did.
@sakrist
sakrist / TextureResource+extension.swift
Last active March 26, 2023 21:53
Extension to TextureResource of RealityKit. This is the way how to control multiple materials in RealityKit
//
// TextureResource+extension.swift
//
// Created by Volodymyr Boichentsov on 24/03/2023.
//
import Foundation
import Metal
import MetalKit
import RealityKit
@sakrist
sakrist / pbr.glsl
Created July 24, 2017 08:14 — 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
@sakrist
sakrist / AppDelegate.m
Created February 9, 2017 14:29 — forked from mattrajca/AppDelegate.m
MetalComputeOSX
//
// AppDelegate.m
// MetalComputeOSX
//
#import "AppDelegate.h"
@import Metal;
#define IMAGE_SIZE 128
@sakrist
sakrist / writePixel.glsl
Created January 31, 2017 15:09
part of DefaultRenderer_OIT_writePixel.glsl from G3D
// colorData[0] - accum (Ar, Ag, Ab, Aa)
// colorData[2] - modulate (Br, Bg, Bb, D^2)
// colorData[3] - refraction (deltax, deltay)
void writePixel (vec3 premultipliedReflectionAndEmission, float coverage, vec3 transmissionCoefficient) {
/*
,
float collimation,
float etaRatio,
vec3 csPosition,
vec3 csNormal) {
@sakrist
sakrist / Compositing_OIT.fsh
Created January 31, 2017 14:58
composite shader for OIT
void main()
{
ivec2 C = ivec2(gl_FragCoord.xy);
vec4 backgroundModulationAndDiffusion = texelFetch(modulationSampler, C, 0);
vec3 backgroundModulation = backgroundModulationAndDiffusion.rgb;
vec4 background = texelFetch(backgroundSampler, C, 0);
@sakrist
sakrist / build_macOS.sh
Last active February 18, 2017 22:52
Build script for G3D on macOS
#!/bin/sh
# locate file next to `buildg3d`
local_path=`pwd`
g3d="${local_path}/../"
export G3D10DATA=$g3d/G3D10/data-files:$g3d/data10/common:$g3d/data10/game:$g3d/data10/research:$g3d/G3D10/data-files
export PATH=$PATH:$g3d/G3D10/bin
static __inline__ GLKMatrix4 GLKMatrix4Invert(GLKMatrix4 matrix, bool *isInvertable) {
float b00 = matrix.m[0] * matrix.m[5] - matrix.m[1] * matrix.m[4];
float b01 = matrix.m[0] * matrix.m[6] - matrix.m[2] * matrix.m[4];
float b02 = matrix.m[0] * matrix.m[7] - matrix.m[3] * matrix.m[4];
float b03 = matrix.m[1] * matrix.m[6] - matrix.m[2] * matrix.m[5];
float b04 = matrix.m[1] * matrix.m[7] - matrix.m[3] * matrix.m[5];
float b05 = matrix.m[2] * matrix.m[7] - matrix.m[3] * matrix.m[6];
float b06 = matrix.m[8] * matrix.m[13] - matrix.m[9] * matrix.m[12];
float b07 = matrix.m[8] * matrix.m[14] - matrix.m[10] * matrix.m[12];
@sakrist
sakrist / createTouchEvent.js
Created January 25, 2016 11:12 — forked from basecss/createTouchEvent.js
createTouchEvent
(function() {
var ua = /iPhone|iP[oa]d/.test(navigator.userAgent) ? 'iOS' : /Android/.test(navigator.userAgent) ? 'Android' : 'PC';
document.addEventListener('DOMContentLoaded', function(event) {
if(ua === 'PC') {
return;
}
# Builds a Libpng framework for the iPhone and the iPhone Simulator.
# Creates a set of universal libraries that can be used on an iPhone and in the
# iPhone simulator. Then creates a pseudo-framework to make using libpng in Xcode
# less painful.
#
# To configure the script, define:
# IPHONE_SDKVERSION: iPhone SDK version (e.g. 8.1)
#
# Then go get the source tar.bz of the libpng you want to build, shove it in the
# same directory as this script, and run "./libpng.sh".