Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
✅
‏‏‎

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / simd-c.txt
Last active March 11, 2020 10:06
SIMD Unity Notes
// using instrinsics
__m128 ValueA = _mm_set1_ps(1.0f);
__m128 ValueB = _mm_set1_ps(2.0f);
__m128 Sum = _mm_add_ps(ValueA, ValueB);
_mm_set1_ps : take this float value, replicate it into all 4 lanes in simd
@unitycoder
unitycoder / asm resources web.md
Last active December 31, 2025 18:45
ASM Assembly Notes
@unitycoder
unitycoder / rayTriangleIntersection.cs
Created March 10, 2020 06:23
Ray Triangle Intersection Moller/Trumbore intersection algorithm
// https://forum.unity.com/threads/visual-raycasts-non-physics.843322/#post-5569870
// adaptation of
// https://forum.unity.com/threads/a-solution-for-accurate-raycasting-without-mesh-colliders.134554/
//
// Moller/Trumbore intersection algorithm
// Vec2NaN means new Vector2(float.NaN, float.NaN)
// a.ToPoint(b) means (b - a)
// a.IsCloseToZero() means Mathf.Abs(a) < 1E-6f
// a.IsZeroOrNegative() means a < 0f || a.IsCloseToZero()
@unitycoder
unitycoder / OculusLaserPointer.cs
Created March 9, 2020 13:07
Oculus VR Laser Pointer
// https://forums.oculusvr.com/developer/discussion/comment/555891/#Comment_555891
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class OculusLaserPointer : MonoBehaviour
{
// Input module
@unitycoder
unitycoder / unity-workflow-issues.md
Last active May 9, 2024 15:52
Unity WorkFlow Issues And Bugs

RANDOM (TO BE SORTED..Latest issues at bottom, maybe more relevant)

  • Folded box colliders keep unfolding here and there
  • No alpha in generated Sprite (circle) when assigned to UI Image
  • Never know for sure what version works best with VR and post processing..
  • Sprite slicer doesnt work with small sprites (support said wont fix)
  • Shadergraph: how to move node with all its connected parent nodes?
  • Tried to update oculus package, failed due to dll in use, restarting didnt help, deleted whole oculus folder, alt tab and back, deleted folder appread back! (multiple tiles, until deleted library and some other folder also)
  • Cannot drag objects to another folder, if target folder already contains same filename, but there is no info to user that its the case
  • More than once a week, sign into unity dialog
  • Doing multiselect DeSelect in project window, it jumps to first item on every deselect
@unitycoder
unitycoder / DriftingWaves.shader
Last active June 4, 2025 11:52
Drifting Waves Shader
// idea from https://twitter.com/akivaw/status/1226681850564956160
// blog post https://unitycoder.com/blog/2020/03/01/waves-shader/
Shader "UnityLibrary/Mesh/DriftingWaves"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_FoamTex ("Foam", 2D) = "white" {}
@unitycoder
unitycoder / Base64ToTexture.cs
Created February 26, 2020 10:43
Base64 image into Texture2D
// https://github.com/Unity-Technologies/2d-extras/blob/master/Editor/Tiles/RuleTile/RuleTileEditor.cs
public static Texture2D Base64ToTexture(string base64)
{
Texture2D t = new Texture2D(1, 1);
t.hideFlags = HideFlags.HideAndDontSave;
t.LoadImage(System.Convert.FromBase64String(base64));
return t;
}
@unitycoder
unitycoder / interior.shader
Created February 24, 2020 17:20
unity interior mapping shader
// https://www.youtube.com/watch?v=9zq3mcFcofk
#ifndef INTERRIOR_UV_FUNCTION_INCLUDED
#define INTERRIOR_UV_FUNCTION_INCLUDED
//bgolus's original source code: https://forum.unity.com/threads/interior-mapping.424676/#post-2751518
//this reusable InteriorUVFunction.hlsl is created base on bgolus's original source code
//for param "roomMaxDepth01Define": input 0.0001 if room is a "near 0 volume" room, input 0.9999 if room is a "near inf depth" room
float2 ConvertOriginalRawUVToInteriorUV(float2 originalRawUV, float3 viewDirTangentSpace, float roomMaxDepth01Define)
@unitycoder
unitycoder / ColorLUT.cs
Created February 18, 2020 11:00
LUT Color Remap 0 - 255 to 0 - 1
// remap byte color (0-255) into float color value 0-1
float[] LUT255 = new float[] { 0f, 0.00392156862745098f, 0.00784313725490196f, 0.011764705882352941f, 0.01568627450980392f, 0.0196078431372549f, 0.023529411764705882f, 0.027450980392156862f, 0.03137254901960784f, 0.03529411764705882f, 0.0392156862745098f, 0.043137254901960784f, 0.047058823529411764f, 0.050980392156862744f, 0.054901960784313725f, 0.058823529411764705f, 0.06274509803921569f, 0.06666666666666667f, 0.07058823529411765f, 0.07450980392156863f, 0.0784313725490196f, 0.08235294117647059f, 0.08627450980392157f, 0.09019607843137255f, 0.09411764705882353f, 0.09803921568627451f, 0.10196078431372549f, 0.10588235294117647f, 0.10980392156862745f, 0.11372549019607843f, 0.11764705882352941f, 0.12156862745098039f, 0.12549019607843137f, 0.12941176470588237f, 0.13333333333333333f, 0.13725490196078433f, 0.1411764705882353f, 0.1450980392156863f, 0.14901960784313725f, 0.15294117647058825f, 0.1568627450980392f, 0.1607843137254902f, 0.16470588235294117f, 0.1686274
@unitycoder
unitycoder / DebugLogColor.cs
Created February 18, 2020 09:49
Debug.Log with Color
Debug.Log("<color=#" + ColorUtility.ToHtmlStringRGB(col) + ">████████████</color> = " + col);