Skip to content

Instantly share code, notes, and snippets.

View benanil's full-sized avatar
🏠
Working from home

Anılcan Gülkaya benanil

🏠
Working from home
View GitHub Profile
@benanil
benanil / GenerateMetallicRoughness.cpp
Created June 22, 2024 23:03
given albedo texture, creates metallic roughness texture, outputs: inputMRT.png which R component is metallic and G component is roughness
#include <stdio.h>
#include "../../../ASTL/Math/Vector.hpp"
#include "../../../ASTL/IO.hpp"
#include "../../../ASTL/Memory.hpp"
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "../../../External/stb_image.h"
#include "../../../External/stb_image_write.h"
@benanil
benanil / RandomSSAOKernelGen.cpp
Last active February 3, 2024 20:40
Script, that generates random noise for SSAO algorithms
// g++ -std=c++14 -O3 -mavx2 -march=native -msse4.2 -fno-rtti -fno-stack-protector -fno-exceptions -static-libstdc++ -static-libgcc RandomSSAOKernelGen.cpp -o RandomSSAOKernelGen.exe
#include <stdio.h>
// https://github.com/benanil/ASTL/blob/master/Random.hpp
#include "../ASTL/Random.hpp"
// https://github.com/benanil/ASTL/blob/master/Math/Vector.hpp
#include "../ASTL/Math/Vector.hpp"
Vector3f GenKernelVec(uint64_t xoro[2], float i, float kernelSize)
{
Vector3f vec;
@benanil
benanil / FastSSAO.glsl
Last active February 7, 2024 12:56
Custom SSAO for performance, works fine with android devices.
// random noise
const vec2 Noise[32] = vec2[32](
vec2(0.195175, 0.736741),
vec2(0.244343, -0.188865),
vec2(0.625741, 0.937121),
vec2(-0.050130, -0.450137),
vec2(-0.931756, 0.560139),
vec2(0.918269, 0.652424),
vec2(0.194104, -0.404106),
vec2(-0.936278, 0.118957),
@benanil
benanil / GTAO.glsl
Created February 3, 2024 20:21
Screen Space ambient ocullussion shader from original paper. GTAO technique
// Jimenez et al. / Practical Real-Time Strategies for Accurate Indirect Occlusion
// https://www.activision.com/cdn/research/Practical_Real_Time_Strategies_for_Accurate_Indirect_Occlusion_NEW%20VERSION_COLOR.pdf
out float Result;
in vec2 texCoord;
uniform sampler2D depthMap;
uniform sampler2D normalTex;
uniform mat4 Proj;
uniform mat4 View;
@benanil
benanil / LZ77.c
Last active December 21, 2023 21:52
LZ77 compressor and decompressor
#ifdef _MSC_VER
#include <intrin.h> // __movsb
#endif
#include <memory.h>
#include <stdint.h>
#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
@benanil
benanil / WindowsKeyboardMouseInput.cpp
Last active November 20, 2023 15:58
Windows Keyboard & Mouse Input like glfw
enum KeyboardKey_
{
Key_BACK = 0x08,
Key_TAB = 0x09,
Key_CLEAR = 0x0C,
Key_RETURN = 0x0D,
Key_SHIFT = 0x10,
Key_CONTROL = 0x11,
Key_MENU = 0x12,
Key_PAUSE = 0x13,
@benanil
benanil / GLTFParser.cpp
Last active March 1, 2024 10:30
GLTF Parser
#ifndef __cplusplus
extern "C" {
#endif
/*****************************************************************
* ASTL COMMON *
*****************************************************************/
#ifndef ASTL_COMMON
#define ASTL_COMMON
@benanil
benanil / UniquenessCheck.cpp
Created September 29, 2023 17:39
Uniqueness Check for ToolKit Classes
// you should have ASTL header only library inorder to use this
// you should compile this and place exe into the toolkit folder
#include "String.hpp"
#include "Array.hpp"
#include "IO.hpp"
bool IsRealClass(char* curr)
{
// return false if template
if (curr[-1] == '<' || curr[-2] == 'm') // is enum class?
@benanil
benanil / MemCpyMemSet.cpp
Last active June 12, 2023 15:51
simd optimized memcpy and memset
#ifndef AXGLOBALCONST
# if _MSC_VER
# define AXGLOBALCONST extern const __declspec(selectany)
# elif defined(__GNUC__) && !defined(__MINGW32__)
# define AXGLOBALCONST extern const __attribute__((weak))
# else
# define AXGLOBALCONST
# endif
#endif
#include <math.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <fcntl.h>
#include "Timer.hpp"
// #include <dlfcn.h>