Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
sindresorhus / esm-package.md
Last active July 31, 2024 14:18
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@TiliSleepStealer
TiliSleepStealer / DoomGlow.cs
Created June 13, 2017 21:45
Doom glow - fake volumetric light glow effect in Unity by Tili_us
// This file is in the public domain. Where
// a public domain declaration is not recognized, you are granted
// a license to freely use, modify, and redistribute this file in
// any way you choose.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Unity remake of a fake volumetric light glow effect
@AlcaDesign
AlcaDesign / index.html
Last active November 16, 2023 17:14
[OUTDATED] An almost complete tmi.js example (browser)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Chat</title>
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
<link href="style.css" rel="stylesheet" type="text/css">
<script src="https://d2g2wobxbkulb1.cloudfront.net/0.0.19/tmi.js"></script> <!--For developement-->
<!--<script src="https://d2g2wobxbkulb1.cloudfront.net/0.0.19/tmi.min.js"></script>--> <!--For "production"-->
</head>
@JakobOvrum
JakobOvrum / listclasses.d
Last active August 29, 2015 14:20
List classes in a module at CT
alias Identity(alias sym) = sym;
template ClassesInModule(alias mod)
{
import std.typetuple : Filter, staticMap;
enum isAccessibleClassDeclaration(string member) = __traits(compiles, __traits(getMember, mod, member)) &&
is(Identity!(__traits(getMember, mod, member)) == class);
alias LookupMemberType(string member) = Identity!(__traits(getMember, mod, member));
@aras-p
aras-p / custom_brdf.md
Last active April 27, 2020 11:13
Custom BRDFs in deferred shading/lighting in Unity

So, https://twitter.com/sunjammer/status/569925239989256192 and https://twitter.com/sunjammer/status/569983534368206848

Now, depends on whether you want custom BRDF in deferred on 1) all your objects (easy) or 2) only some of your objects (harder).

1. change BRDF for everything

That's fairly easy. The actual object shaders more or less just fill the g-buffer (and in Unity 4.x deferred lighting, combine textures with the lighting buffer in the final pass). The actual BRDF is in the "light shader". Start by copying the built-in light shader (4.x deferred lighting: Internal-PrePassLighting.shader; 5.0 deferred shading: Internal-DeferredShading.shader) into your project. In 4.x, put it into Resources folder so it's included into the build; in 5.0 point Unity to use that shader under Project Settings -> Graphics.

Change the shader to do different BRDF.

@mattbenic
mattbenic / SpecificInstanceOfGameExample.cs
Last active June 11, 2023 14:40
Example of using Win32 API to get specific window instance in Unity. This is useful for when running multiple instances of the same application, as the window handle can then be used to correctly position and size the different windows for multi screen use.
using UnityEngine;
using System;
using System.Runtime.InteropServices;
using System.Text;
public class SpecificInstanceOfGameExample : MonoBehaviour
{
#region DLL Imports
private const string UnityWindowClassName = "UnityWndClass";