Skip to content

Instantly share code, notes, and snippets.

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

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / GrabRawTextureData.cs
Created March 15, 2021 07:55
pvrtc file format read loadrawtexturedata
// https://forum.unity.com/threads/texture2d-loadrawtexturedata.223997/
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class GrabTextureFromAsset
{
@unitycoder
unitycoder / index.html
Created March 15, 2021 08:03
Unity WebGL Full Screen Minimal Template (no scrollbar)
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
@unitycoder
unitycoder / InternalScreenShotting.cs
Created March 19, 2021 08:49
Unity internal ScreenShotting tool
using UnityEditor;
using UnityEngine;
namespace NoiseCrimeStudios.Editor.Internal
{
/// <summary>
/// Exposes the native Unity 'ScreenShotting' methods to Unity Menu & Shortcut keys.
/// </summary>
/// <remarks>
@unitycoder
unitycoder / TriangleDebugLines.cs
Created March 19, 2021 15:26
Draw Debug Lines on Mesh Triangle
// related topic https://forum.unity.com/threads/create-grid-in-mesh-triangle.1078211/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriangleDebugLines : MonoBehaviour
{
void Start()
{
@unitycoder
unitycoder / ToggleGoogleVROnOff.cs
Created March 22, 2021 09:44
toggle between 2d and Google Cardboard (2020 Unity XR)
https://forum.unity.com/threads/toggle-between-2d-and-google-cardboard.902378/#post-6959573
Coroutine StartVR()
{
return StartCoroutine(startVRRoutine());
IEnumerator startVRRoutine()
{
// Add error handlers for both Instance and Manager
var xrManager = XRGeneralSettings.Instance.Manager;
if (!xrManager.isInitializationComplete)
@unitycoder
unitycoder / SineWave.cs
Created March 26, 2021 10:10
OnAudioFilterRead generate sinewave
// https://forum.unity.com/threads/onaudiofilterread-question.170273/#post-1164846
using UnityEngine;
using System; // Needed for Math
public class SineWave : MonoBehaviour
{
// un-optimized version
public double frequency = 440;
public double gain = 0.05;
private double increment;
@unitycoder
unitycoder / GPU Compute Model Terminology.md
Last active September 19, 2024 04:12
GPU Compute Model Terminology / Quick Reference / CheatSheet

from Landom Thomas https://landonthomas.net/docs/gpu_compute_model_terms_quick_ref.pdf

Compute Abstraction Hierarchy Microsoft HLSL Khronos GLSL Khronos OpenCL C Nvidia,CUDA C AMD,HIP Apple,MSL
Entire Kernel/Shader Compute Space Dispatch Dispatch, Compute Space NDRange, Index Space Grid Grid Grid
Major Compute Group Group, Thread Group Workgroup, Local Workgroup Work-group Block, Thread Block Block Threadgroup
Minor Compute Group (& Device Minor SIMD Unit) Wave Subgroup Sub-group Warp Wavefront, Wave, Warp SIMD-group
Quad Compute Object Quad Wave Subgroup Quad ? Quad Quad Quad-group
Single Compute Object Thread Invocation Work-item Thread Thread Thread
@unitycoder
unitycoder / RtpPacket.cs
Last active March 31, 2021 14:19
RtpPacket
// https://stackoverflow.com/a/61267482/5452781
// ffplay rtp://0.0.0.0:your_port
using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using UnityEngine;
public static class RtpPacket
@unitycoder
unitycoder / unity-openxr.md
Last active November 27, 2026 09:21
unity openxr notes and tips
@unitycoder
unitycoder / Bake Vertex Color Map.shader
Created April 6, 2021 13:25
bake vertex color from mesh to texture
Shader "Bake Vertex Color Map"
{
SubShader
{
Pass
{
ZTest Off
ZWrite Off
Cull Off
CGPROGRAM