Skip to content

Instantly share code, notes, and snippets.

View longde123's full-sized avatar
:octocat:
Working from home

paling longde123

:octocat:
Working from home
View GitHub Profile
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active May 19, 2024 07:09
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@MangelMaxime
MangelMaxime / Async.hx
Last active May 13, 2024 09:43
Demonstrate how to use native async/await from JavaScript with haxe.
package async;
#if macro
import haxe.macro.Context;
#end
class Async {
public static macro function async(expr:haxe.macro.Expr) {
expr = Context.storeTypedExpr(Context.typeExpr(expr));
return macro untyped __js__("(async {0})", ${expr})();
@deandob
deandob / livestream
Created February 26, 2014 22:31
Node.JS function to remux mp4/h.264 video from an IP camera to a HTML5 video tag using FFMPEG
// Live video stream management for HTML5 video. Uses FFMPEG to connect to H.264 camera stream,
// Camera stream is remuxed to a MP4 stream for HTML5 video compatibility and segments are recorded for later playback
var liveStream = function (req, resp) { // handle each client request by instantiating a new FFMPEG instance
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var reqUrl = url.parse(req.url, true)
var cameraName = typeof reqUrl.pathname === "string" ? reqUrl.pathname.substring(1) : undefined;
if (cameraName) {
try {
cameraName = decodeURIComponent(cameraName);
@mstevenson
mstevenson / SaveFBX.cs
Created August 5, 2013 20:05
ASCII FBX file exporter for Unity. Extracted from Michal Mandrysz's Unity Summer of Code 2009 external lightmapping project.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using UnityEditor;
using UnityEngine;
/*
@Cyanilux
Cyanilux / DrawGrass.cs
Last active January 27, 2024 07:55
Experiments with DrawMeshInstanced and DrawMeshInstancedIndirect for drawing grass (over terrain)
// https://twitter.com/Cyanilux/status/1396848736022802435
// Requires a specific shader to read the _PerInstanceData buffer at SV_InstanceID
// I use a shader made in Shader Graph, See : https://gist.github.com/Cyanilux/4046e7bf3725b8f64761bf6cf54a16eb
// Also note, there's no frustum culling involved in this example. Typically a compute shader is used for this.
using UnityEngine;
public class DrawGrass : MonoBehaviour {
@favoyang
favoyang / BuildAddressables.cs
Last active August 14, 2023 06:29
Build addressable bundles when clicking the build button
/// <summary>
/// The script gives you choice to whether to build addressable bundles when clicking the build button.
/// For custom build script, call PreExport method yourself.
/// For cloud build, put BuildAddressablesProcessor.PreExport as PreExport command.
/// Discussion: https://forum.unity.com/threads/how-to-trigger-build-player-content-when-build-unity-project.689602/
///
/// License: The MIT License https://opensource.org/licenses/MIT
/// </summary>
using UnityEditor;
using UnityEditor.AddressableAssets;
@runette
runette / FlyingCam.cs
Created April 14, 2020 11:28
Movement and Interaction script
//https://stackoverflow.com/questions/58328209/how-to-make-a-free-fly-camera-script-in-unity-with-acceleration-and-decceleratio
// copyright Runette Software Ltd, 2020. All rights reserved
using UnityEngine;
using UnityEngine.InputSystem;
using Zinnia.Pointer;
using Zinnia.Cast;
public class FlyingCam : MonoBehaviour
{
[Header("Constants")]
@erikbern
erikbern / install-tensorflow.sh
Last active June 26, 2023 00:40
Installing TensorFlow on EC2
# Note – this is not a bash script (some of the steps require reboot)
# I named it .sh just so Github does correct syntax highlighting.
#
# This is also available as an AMI in us-east-1 (virginia): ami-cf5028a5
#
# The CUDA part is mostly based on this excellent blog post:
# http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/
# Install various packages
sudo apt-get update
@jimfleming
jimfleming / UnityDiffuseLightmap.shader
Last active June 21, 2023 00:44
Example depicting applying Unity lightmapping data to a simple diffuse shader.
Shader "Diffuse Lightmap" {
Properties {
_MainTex ("Texture 1", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
Pass {