Skip to content

Instantly share code, notes, and snippets.

View BlurryLight's full-sized avatar
🎯
Focusing on RealtimeRendering

BlurryLight BlurryLight

🎯
Focusing on RealtimeRendering
View GitHub Profile
@jdupuy
jdupuy / SampleVndf_GGX.cpp
Last active April 15, 2024 20:09
Sampling Visible GGX Normals with Spherical Caps
// Helper function: sample the visible hemisphere from a spherical cap
vec3 SampleVndf_Hemisphere(vec2 u, vec3 wi)
{
// sample a spherical cap in (-wi.z, 1]
float phi = 2.0f * M_PI * u.x;
float z = fma((1.0f - u.y), (1.0f + wi.z), -wi.z);
float sinTheta = sqrt(clamp(1.0f - z * z, 0.0f, 1.0f));
float x = sinTheta * cos(phi);
float y = sinTheta * sin(phi);
vec3 c = vec3(x, y, z);
@CarlLee
CarlLee / Bloom.shader
Last active May 16, 2023 10:28
UE4 bloom for unity
Shader "Hidden/Bloom"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
HLSLINCLUDE
#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Core.hlsl"
struct appdata
@kevinkreiser
kevinkreiser / filesystem.hpp
Last active March 5, 2024 15:39
a replacement for std::filesystem when its not available to your compiler
#include <functional>
#include <iostream>
#ifdef use_std_filesystem
#include <experimental/filesystem>
namespace filesystem = std::experimental::filesystem;
#else
#include <cstring>
#include <memory>
@rjloura
rjloura / xfce_caps_to_escape.md
Last active January 15, 2021 10:22
How to set capslock to escape key in xfce4

My chromebook doesn't have a caps lock key, it has a "search" key. When running crouton xfce4 is unaware of this key in the keybaord mappings GUI. This is how I ended up mapping the search/capslock key to escape.

  1. Run xev(1)
  2. Strike the capslock (aka search, or super_L key) and ook for entries like the following:
KeyPress event, serial 28, synthetic NO, window 0x2600001,
    root 0xd3, subw 0x0, time 16308538, (449,411), root:(1043,703),
    state 0x0, keycode 133 (keysym 0xff1b, Escape), same_screen YES,
    XKeysymToKeycode returns keycode: 9
 XLookupString gives 1 bytes: (1b)
  • void glEnableVertexAttribArray​(GLuint attribIndex);
  • void glDisableVertexAttribArray​(GLuint attribIndex);
  • void glVertexAttribPointer(GLuint attribIndex, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer);
  • void glVertexAttribFormat(GLuint attribIndex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
  • void glVertexAttribBinding(GLuint attribIndex, GLuint bindingIndex);
  • void glBindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset, GLintptr stride);
parameter Details
attribIndex the location for the vertex attribute to which the vertex array will feed data
@hillin
hillin / integrating-fastbuild-with-ue4.md
Last active August 1, 2023 22:21
Integrating FASTBuild with Unreal Engine 4

FASTBuild is an open-source distributed build system, which could be a free alternative to Incredibuild. Unreal Engine 4 (UE4) does not support FASTBuild natively, however it's not hard to integrate it manually.

Integrate FASTBuild with UE4

Install FASTBuild

We assume you already have the full UE4 source code. First you'll need to grab the latest FASTBuild tools from here. We use v0.93 Windows x64 version in this tutorial. Download it and extract all the files. Here you have several choices:

  • Place the files under any folder which could be found with your system's PATH environment variable. To see where these folders are, run the PATH command in a command prompt window;
  • Place the files under the Engine\Binaries\ThirdParty\FASTBuild folder of your engine. This is the recommended place;
  • Place the files anywhere you like. This is not recommended because you'll have to hard-code the path later.
@SilverBut
SilverBut / haproxy.cfg
Last active May 19, 2023 20:45
[Haproxy cfg checking Socks5] Haproxy cfg to check the Socks5 connection #tags: GFW, network, haproxy, config
#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------
global
log 127.0.0.1 local2
@solidsnack
solidsnack / ssh-srv
Last active November 27, 2019 11:49
SSH to servers that have SRV records
#!/bin/bash
set -o errexit -o nounset -o pipefail
function --help {
cat <<USAGE
USAGE: ssh-srv <DNS name> <SSH options and args>*
Allows SSH to nodes referenced by SRV records. The SRV records can be
referenced in a "plain style":
service.example.com
@Redchards
Redchards / Bind.cxx
Last active December 5, 2023 13:54
Simple implementation of a function like std::bind.
#include <iostream>
#include <functional>
#include <tuple>
#include <type_traits>
// Actually, a subtle bug may arise when the function is using index_constant as parameter.
// For this reason, a more correct implementation should define a specialized class, hidden in a namespace,
// and forbid the use in other places.
// An easier, more correct, but more verbose way would be to just define two different classes for the argument list
// and the bounded arguments, to avoid the confusion with the index_constant bracket operator overload.
@rickyah
rickyah / MonoBehaviourSingleton.cs
Created June 3, 2015 08:59
MonoBehaviour Singleton
using System;
using UnityEngine;
/// <summary>
/// This is a generic Singleton implementation for Monobehaviours.
/// Create a derived class where the type T is the script you want to "Singletonize"
/// Upon loading it will call DontDestroyOnLoad on the gameobject where this script is contained
/// so it persists upon scene changes.
/// </summary>
/// <remarks>