Skip to content

Instantly share code, notes, and snippets.

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

mika unitycoder

✅
‏‏‎
View GitHub Profile
Shader "Test/SmoothZoomTexture"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[KeywordEnum(Basic,Manual,Blend,Compare)]Mode("Mode", Int) = 0
_Blend("Blend", Range(0,1)) = 1
[Header(Mip Map)]
_MipMapMin("MipMap Min", Int) = 4
@unitycoder
unitycoder / Matrix.hlsl
Created September 1, 2021 18:38 — forked from mattatz/Matrix.hlsl
Matrix operations for HLSL
#ifndef __MATRIX_INCLUDED__
#define __MATRIX_INCLUDED__
#define IDENTITY_MATRIX float4x4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
float4x4 inverse(float4x4 m) {
float n11 = m[0][0], n12 = m[1][0], n13 = m[2][0], n14 = m[3][0];
float n21 = m[0][1], n22 = m[1][1], n23 = m[2][1], n24 = m[3][1];
float n31 = m[0][2], n32 = m[1][2], n33 = m[2][2], n34 = m[3][2];
float n41 = m[0][3], n42 = m[1][3], n43 = m[2][3], n44 = m[3][3];
@unitycoder
unitycoder / Translucent.shader
Created September 3, 2021 05:18
translucent-shader-unity3d
// https://farfarer.com/blog/2012/09/11/translucent-shader-unity3d/
Shader "Custom/Translucent" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_BumpMap ("Normal (Normal)", 2D) = "bump" {}
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
//_Thickness = Thickness texture (invert normals, bake AO).
@unitycoder
unitycoder / NamedPipeClient.cs
Created September 5, 2021 17:54
Unity IPC, Pipe Connection to Dotnet Pipe
// https://forum.unity.com/threads/unity-vs-ipc.1162754/#post-7474082
using System;
using UnityEngine;
using TMPro;
using System.Diagnostics;
using System.IO.Pipes;
using System.IO;
using System.Threading;
public class NamedPipeClient : MonoBehaviour
@unitycoder
unitycoder / RaindropTextureBomber.shader
Created September 11, 2021 07:24
Unity Texture Bombing (rain drops)
// https://forum.unity.com/threads/texture-bombing-lets-tackle-this-one.185724/#post-1278100
Shader "Annihlator/Raindrop TextureBomber" {
    Properties {
        _MainTex("Texture (RGB)", 2D) = "black" {}
        _BumpMap ("Normalmap", 2D) = "bump" {}
        _BombTex("Bomb Texture (RGB)", 2D) = "black" {}
        _RandomTex("Random Texture (RGB)", 2D) = "black" {}
        _Slider("Slider", Range(0,1)) = 1
        _Params("Params, Z = Scale",Vector) = (0.037, 0.119, 5, 0)
        _ReflectionTex ("Reflection", 2D) = "white" { TexGen ObjectLinear }
@unitycoder
unitycoder / StandardSurfaceVertex.shader
Last active August 14, 2025 17:12
Standard Surface Shader with Vertex Pass and Vertex Color
Shader "Custom/StandardSurfaceVertex"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader
@unitycoder
unitycoder / StandardSurfaceShaderWithVertexColor.shader
Created September 16, 2021 08:31 — forked from phest/StandardSurfaceShaderWithVertexColor.shader
unity standard shader modified to display vertex colors
Shader "Custom/StandardSurfaceShaderWithVertexColor" {
Properties {
_MainTint("Global Color Tint", Color) = (1,1,1,1)
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert
@unitycoder
unitycoder / tex2Dlod.shader
Created September 16, 2021 12:45
unity read texture inside vertex pass using tex2Dlod
//#if !defined(SHADER_API_OPENGL)
float4 tex = tex2Dlod (_MainTex, float4(v.texcoord.xy,0,0));
v.vertex.y += tex.r * 2.0;
//#endif
https://forum.unity.com/threads/how-to-use-vertex-texture-fetch.63231/#post-405266
@unitycoder
unitycoder / RubikCube.cs
Created September 23, 2021 09:15
unity rubiks cube script
// // https://answers.unity.com/questions/1479418/how-to-rotate-columns-of-a-rubiks-cube.html
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum ELayer
{
F, // front face (around z axis)
R, // right face (around x axis)
U, // upper face (around y axis)
@unitycoder
unitycoder / DragRigidbody.cs
Last active February 22, 2026 19:00
Old standard assets draggable rigidbody (with spring)
using System;
using System.Collections;
using UnityEngine;
namespace UnityStandardAssets.Utility
{
public class DragRigidbody : MonoBehaviour
{
public LayerMask draggableLayerMask;