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
@longde123
longde123 / AsyncHttpWebRequest.cs
Created March 14, 2023 07:44 — forked from r2d2rigo/AsyncHttpWebRequest.cs
An elegant way of asynchronously requesting web sites on Windows Phone.
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Threading.Tasks;
public class AsyncHttpWebRequest
{
private HttpWebRequest webRequest;
using UnityEngine;
using System.Collections;
public class RaycastOBB : MonoBehaviour {
public Vector3 rayOrigin = new Vector3(5.0f, 10.0f, 7.0f);
public Vector3 rayDirection = new Vector3(-15.0f, 33.0f, 10.0f);
public Vector3 obbRotation = new Vector3(10.0f, 260.0f, 170.0f);
public Vector3 obbPosition = new Vector3(0.0f, 20.0f, 10.0f);
public Vector3 obbHalfSize = new Vector3(1.0f, 1.0f, 1.0f);
@longde123
longde123 / GrassInstanced.hlsl
Created November 9, 2021 13:14 — forked from Cyanilux/GrassInstanced.hlsl
Experiments with using DrawMeshInstancedIndirect with Shader Graph
// https://twitter.com/Cyanilux/status/1396848736022802435?s=20
#ifndef GRASS_INSTANCED_INCLUDED
#define GRASS_INSTANCED_INCLUDED
// ----------------------------------------------------------------------------------
// Graph should contain Boolean Keyword, "PROCEDURAL_INSTANCING_ON", Global, Multi-Compile.
// Must have two Custom Functions in vertex stage. One is used to attach this file (see Instancing_float below),
// and another to set #pragma instancing_options :
@longde123
longde123 / DrawGrass.cs
Created November 9, 2021 13:14 — forked from Cyanilux/DrawGrass.cs
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 {
@longde123
longde123 / TreeReplacerS.cs
Created October 19, 2021 06:44 — forked from st4rdog/TreeReplacerS.cs
Replaces trees on a terrain with prefab.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
// Replaces Unity terrain trees with prefab GameObject.
// http://answers.unity3d.com/questions/723266/converting-all-terrain-trees-to-gameobjects.html
[ExecuteInEditMode]
public class TreeReplacerS : EditorWindow {
@longde123
longde123 / Main.hx
Created September 27, 2021 04:17 — forked from deltaluca/Main.hx
Occlusion culling minecraft 2d
import nape.util.BitmapDebug;
import nape.geom.Vec2;
class Perlin3D {
public static inline function noise(x:Float, y:Float = 0.0, z:Float = 0.0) {
var X:Int = untyped __int__(x); x -= X; X &= 0xff;
var Y:Int = untyped __int__(y); y -= Y; Y &= 0xff;
var Z:Int = untyped __int__(z); z -= Z; Z &= 0xff;
var u = fade(x); var v = fade(y); var w = fade(z);
var A = p(X) +Y; var AA = p(A)+Z; var AB = p(A+1)+Z;
@longde123
longde123 / ColliderGizmo.cs
Created September 25, 2021 09:49
Draw gizmo for colliders
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MyBox
{
public class ColliderGizmo : MonoBehaviour
/*
Generates a trail that is always facing upwards using the scriptable mesh interface.
vertex colors and uv's are generated similar to the builtin Trail Renderer.
To use it
1. create an empty game object
2. attach this script and a MeshRenderer
3. Then assign a particle material to the mesh renderer
*/
var height = 2.0;
var time = 2.0;
@longde123
longde123 / EdgeDetectNormals.shader
Created July 8, 2021 04:42 — forked from MattRix/EdgeDetectNormals.shader
Unity edge detect normals shader for reference
Shader "Hidden/EdgeDetect" {
Properties {
_MainTex ("Base (RGB)", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
@longde123
longde123 / QualityManager.cs
Created June 29, 2021 03:42 — forked from SachinGanesh/QualityManager.cs
Unity3D Dynamic Quality Settings based on FPS. Runtime reduction of quality based on device performance
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class QualityManager : Singleton<QualityManager> {
private int QUALITY_INDEX = 0;
public int MIN_FPS = 28;
public Text qualityUIText;