Skip to content

Instantly share code, notes, and snippets.

View aras-p's full-sized avatar

Aras Pranckevičius aras-p

View GitHub Profile
@aras-p
aras-p / preprocessor_fun.h
Last active February 28, 2024 08:38
Things to commit just before leaving your job
View preprocessor_fun.h
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@aras-p
aras-p / DebugNode.hlsl
Created January 3, 2020 10:37
"Print a value" custom function node code for Unity ShaderGraph
View DebugNode.hlsl
// Quick try at doing a "print value" node for Unity ShaderGraph.
// Tested on Unity 2019.2.17 with ShaderGraph 6.9.2.
//
// Use with CustomFunction node, with two inputs:
// - Vector1 Value, the value to display,
// - Vector2 UV, the UVs of area to display at.
// And one output:
// - Vector4 Color, the color.
// Function name is DoDebug.
@aras-p
aras-p / fbx_visibility_export.diff
Created February 8, 2023 10:10
Blender FBX Visibility export
View fbx_visibility_export.diff
diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py
index c5cd93a7..f15b3a8a 100644
--- a/io_scene_fbx/export_fbx_bin.py
+++ b/io_scene_fbx/export_fbx_bin.py
@@ -1688,7 +1688,8 @@ def fbx_data_object_elements(root, ob_obj, scene_data):
animatable=True, animated=((ob_obj.key, "Lcl Rotation") in scene_data.animated))
elem_props_template_set(tmpl, props, "p_lcl_scaling", b"Lcl Scaling", scale,
animatable=True, animated=((ob_obj.key, "Lcl Scaling") in scene_data.animated))
- elem_props_template_set(tmpl, props, "p_visibility", b"Visibility", float(not ob_obj.hide))
+ elem_props_template_set(tmpl, props, "p_visibility", b"Visibility", float(not ob_obj.hide),
@aras-p
aras-p / D3D9ByteCode.cpp
Last active January 27, 2024 09:53
D3D9 Shader Bytecode Patching for Half-Pixel Fixup
View D3D9ByteCode.cpp
#include "UnityPrefix.h"
#include "D3D9ByteCode.h"
// D3D9 shader bytecode format on MSDN: https://msdn.microsoft.com/en-us/library/windows/hardware/ff552891.aspx
const UInt32 kD3D9ShaderTypeVertex = 0xFFFE0000;
const UInt32 kD3D9SwizzleShift = 16;
const UInt32 kD3D9NoSwizzle = ((0 << kD3D9SwizzleShift) | (1 << (kD3D9SwizzleShift + 2)) | (2 << (kD3D9SwizzleShift + 4)) | (3 << (kD3D9SwizzleShift + 6)));
@aras-p
aras-p / package_builds_vs2017.cmd
Created April 9, 2019 19:36
Packaging up Visual Studio & Windows 10 SDK for in-repository usage
View package_builds_vs2017.cmd
@echo off
@rem Packages up VS2017 toolchain into builds.7z archive
@set TOOLS_VERSION=14.13.26128
@cd "%~dp0"
@set VC_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\VC\
@if not exist "%VC_PATH%" goto error_no_vs
@if not exist "%VC_PATH%"Tools\MSVC\%TOOLS_VERSION% goto error_no_vs
@aras-p
aras-p / SkyboxBackgroundTexture.shader
Last active January 9, 2024 00:28
Unity flat skybox picture shader
View SkyboxBackgroundTexture.shader
// Skybox shader that just draws flat texture in the background
Shader "Skybox/Background Texture"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
@aras-p
aras-p / CreateOneMeshFromWholeScene.cs
Last active December 26, 2023 05:41
Mesh.MeshData example
View CreateOneMeshFromWholeScene.cs
using System.Collections.Generic;
using System.Diagnostics;
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Profiling;
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
@aras-p
aras-p / fbfetch.shader
Created May 11, 2015 09:39
Framebuffer fetch shader in Unity
View fbfetch.shader
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
// in practice: only compile for gles2,gles3,metal
#pragma only_renderers framebufferfetch
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
@aras-p
aras-p / Projector Light.shader
Last active October 3, 2023 12:11
Projector shaders without fixed function
View Projector Light.shader
Shader "Projector/Light" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_ShadowTex ("Cookie", 2D) = "" {}
_FalloffTex ("FallOff", 2D) = "" {}
}
Subshader {
Pass {
ZWrite Off
@aras-p
aras-p / building_oiio.md
Last active September 7, 2023 07:59
Building OpenImageIO from source locally
View building_oiio.md

Windows

OIIO build instructions currently just say this for Windows:

Method 1 - from source I really need someone to write correct, modern docs about how to build from source on Windows.

So I decided to figure that out.

Easiest: get Blender first :)