Skip to content

Instantly share code, notes, and snippets.

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

mika unitycoder

✅
‏‏‎
View GitHub Profile
@unitycoder
unitycoder / ffmpeg.md
Created August 10, 2022 06:36 — forked from whizkydee/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@unitycoder
unitycoder / ffmpeg-commands.sh
Created August 11, 2022 19:24 — forked from 44213/ffmpeg-commands.sh
ffmpeg commands.
# To extract the sound from a video and save it as MP3:
ffmpeg -i <video.mp4> -vn <sound>.mp3
# To convert frames from a video or GIF into individual numbered images:
ffmpeg -i <video.mpg|video.gif> <frame_%d.png>
# To combine numbered images (frame_1.jpg, frame_2.jpg, etc) into a video or GIF:
ffmpeg -i <frame_%d.jpg> -f image2 <video.mpg|video.gif>
# To quickly extract a single frame from a video at time mm:ss and save it as a 128x128 resolution image:
@unitycoder
unitycoder / VoronoiNoise.shader
Created August 16, 2022 20:52 — forked from josephbk117/VoronoiNoise.shader
Voronoi shader in unity
/*Please do support www.bitshiftprogrammer.com by joining the facebook page : fb.com/BitshiftProgrammer
Legal Stuff:
This code is free to use no restrictions but attribution would be appreciated.
Any damage caused either partly or completly due to usage of this stuff is not my responsibility*/
Shader "BitShiftProductions/VoronoiMagic2"
{
Properties
{
}
@unitycoder
unitycoder / GazeRays.cs
Created August 17, 2022 10:06 — forked from qxxxb/GazeRays.cs
Render gaze rays for each eye on the HTC Vive Pro Eye.
using System.Runtime.InteropServices;
using UnityEngine;
using ViveSR.anipal.Eye;
public class GazeRays : MonoBehaviour
{
private static EyeData eyeData = new EyeData();
private bool eye_callback_registered = false;
// Render gaze rays.
@unitycoder
unitycoder / geometric specular aliasing.shader
Created August 19, 2022 06:52
geometric specular aliasing shader
// https://forum.unity.com/threads/trying-to-create-custom-standard-shader-with-geometric-specular-aliasing.494588/#post-3217303
Shader "bgolus/VRStandard(AA)"
{
    Properties {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
        [NoScaleOffset] _MetallicGlossMap("Metallic", 2D) = "white" {}
        _BumpScale("Scale", Float) = 1.0
        [NoScaleOffset] _BumpMap("Normal Map", 2D) = "bump" {}
@unitycoder
unitycoder / UnityGraphicsBullshit.cs
Created August 19, 2022 07:56 — forked from JimmyCushnie/UnityGraphicsBullshit.cs
Exposes some Unity URP graphics settings that are (for some stupid fucking bullshit reason) private.
using System.Reflection;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using ShadowResolution = UnityEngine.Rendering.Universal.ShadowResolution;
/// <summary>
/// Enables getting/setting URP graphics settings properties that don't have built-in getters and setters.
@unitycoder
unitycoder / UnityStencilMask.shader
Created August 19, 2022 12:00 — forked from ewandennis/UnityStencilMask.shader
A simple stencil buffer masking shader for Unity
Shader "Custom/StencilMask" {
Properties {
_StencilMask("Stencil mask", Int) = 0
}
SubShader {
Tags {
"RenderType" = "Opaque"
"Queue" = "Geometry-100"
}
@unitycoder
unitycoder / TriplanarWorld.shader
Created August 22, 2022 07:46 — forked from radiatoryang/TriplanarWorld.shader
a triplanar / procedural UV / world space UV shader for Unity, cobbled together bits from @quickfingerz and @Farfarer
Shader "Tri-Planar World" {
Properties {
_Side("Side", 2D) = "white" {}
_Top("Top", 2D) = "white" {}
_Bottom("Bottom", 2D) = "white" {}
_SideScale("Side Scale", Float) = 2
_TopScale("Top Scale", Float) = 2
_BottomScale ("Bottom Scale", Float) = 2
}
@unitycoder
unitycoder / SaveTextureToFileUtility.cs
Created August 24, 2022 16:08
Unity Save Texture To File
// https://forum.unity.com/threads/save-rendertexture-or-texture2d-as-image-file-utility.1325130/
using UnityEngine;
 
public class SaveTextureToFileUtility
{
   public enum SaveTextureFileFormat
   {
       EXR, JPG, PNG, TGA
   };
 
@unitycoder
unitycoder / QuaternionSlerp.cpp
Last active August 29, 2022 13:39
Unity Slerp C++ Source Code
// https://forum.unity.com/threads/slerp-demystified.1328832/#post-8398689
Quaternionf Slerp(const Quaternionf& q1, const Quaternionf& q2, float t)
{
    float dot = Dot(q1, q2);
 
    // dot = cos(theta)
    // if (dot < 0), q1 and q2 are more than 90 degrees apart,
    // so we can invert one to reduce spinning
    Quaternionf tmpQuat;
    if (dot < 0.0f)