Skip to content

Instantly share code, notes, and snippets.

View unitycoder's full-sized avatar
‏‏‎

mika unitycoder

‏‏‎
View GitHub Profile
@unitycoder
unitycoder / color primaries mp4 unity.md
Created January 7, 2025 09:43
warning about color primaries when importing an mp4 video in Unity
@unitycoder
unitycoder / UnityRendering.md
Created January 7, 2025 08:38
Unity: Forward, Forward+, Deferred, Deferred+

https://discussions.unity.com/t/deferred/1579636/3

Forward

Render both, transparent and opaque objects, one at a time. For each object, we bind a list of lights that affect that it. On the GPU, we iterate over this list and accumulate lighting.

The upside of this approach is that this is dead-simple, and has a low CPU cost. For very simple scenes, this is a win.

Downsides are (a) overdraw, i.e. you pay for lighting pixels that will be later occluded by other geometry, (b) a smaller light limit, (c) incompatibility with GPU-driven rendering and GPU occlusion culling.

@unitycoder
unitycoder / MeshExtruder.cs
Created January 6, 2025 20:51
Extrude 2D Outline to 3D Mesh
// https://discussions.unity.com/t/solution-found-and-the-code-is-free-and-cc0-a-better-3d-model-generator-for-simple-unrealistic-outblock-meshes/1579115/109
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class MeshExtruder : EditorWindow
{
private List<Vector2> linePoints = new List<Vector2>();
private bool isDrawing = false;
@unitycoder
unitycoder / fixchatgpt.js
Last active January 6, 2025 17:43
[GreaseMonkey] Fix ChatGPT PageUp/Down and Home/End keys for scrolling the page
// ==UserScript==
// @name Fix Page Scrolling
// @namespace http://unitycoder.com
// @version 1.0
// @description Allow using PageUp/Down and Home/End keys in chatgpt
// @match https://chatgpt.com/*
// @grant none
// ==/UserScript==
(function () {
@unitycoder
unitycoder / Shadows.cginc
Created January 1, 2025 21:33 — forked from runevision/Shadows.cginc
Water Foam Particle Shader
UNITY_DECLARE_SHADOWMAP(_SunCascadedShadowMap);
float4 _SunCascadedShadowMap_TexelSize;
#define GET_CASCADE_WEIGHTS(wpos, z) getCascadeWeights_splitSpheres(wpos)
#define GET_SHADOW_FADE(wpos, z) getShadowFade_SplitSpheres(wpos)
#define GET_SHADOW_COORDINATES(wpos,cascadeWeights) getShadowCoord(wpos,cascadeWeights)
/**
* Gets the cascade weights based on the world position of the fragment and the poisitions of the split spheres for each cascade.
@unitycoder
unitycoder / ProjectionViewer.cs
Created January 1, 2025 21:33 — forked from runevision/ProjectionViewer.cs
Script to create visual illusion of rotating wireframe object that tricks the eye into switching orientation and rotation direction
using UnityEngine;
// Visual effect/illusion where a rotating model alternates between
// seeming to rotate one way around and the other.
// Unlike many similar effects, the eyes are nudged/forced to see it
// in alternating ways by oscillating between regular perspective and
// inverse perspective, changing which parts of the model appear
// bigger or smaller on the screen.
// Attach this script on the GameObject with the Camera component.
@unitycoder
unitycoder / BurstSDFGenerator.cs
Created January 1, 2025 21:33 — forked from runevision/BurstSDFGenerator.cs
Signed Distance Field generator for Unity with Burst support
/*
Based on the Anti-aliased Euclidean distance transform described by Stefan Gustavson and
Robin Strand. For further information, see https://contourtextures.wikidot.com/ and
https://web.archive.org/web/20220503051209/https://weber.itn.liu.se/~stegu/edtaa/
The algorithm is an adapted version of Stefan Gustavson's code, it inherits the copyright
statement below, which applies to this file only.
The rewrite with Unity Burst support makes the execution 40 times faster by default,
and 75 times faster if the passed in textures are both of type TextureFormat.RGBAFloat.
@unitycoder
unitycoder / valheim_plus.cfg
Created December 29, 2024 15:08
valmeim plus mod settings (more drops, bigger inventory etc)
[ValheimPlus]
; Change false to true to enable this section.
enabled = true
; Display the Valheim Plus logo in the main menu
mainMenuLogo = true
; Display the advertisement of our server hosting partner on the server browser menu
serverBrowserAdvertisement = true
@unitycoder
unitycoder / Edge Detection.shader
Created December 20, 2024 18:20
Edge Detection shader
// https://ameye.dev/notes/edge-detection-outlines/
Shader "Custom/Edge Detection"
{
Properties
{
_OutlineThickness ("Outline Thickness", Float) = 1
_OutlineColor ("Outline Color", Color) = (0, 0, 0, 1)
}
SubShader
@unitycoder
unitycoder / win-commandline.md
Created December 19, 2024 08:45
windows cmd prompt commandline batch

install telnet

run as admin> dism /online /Enable-Feature /FeatureName:TelnetClient