Skip to content

Instantly share code, notes, and snippets.

View 8bitniksis's full-sized avatar
⚔️
The Witcher's Order

Nikita 8bitniksis

⚔️
The Witcher's Order
View GitHub Profile
@8bitniksis
8bitniksis / AABBIntersection
Created May 6, 2024 23:33
Intersection in 2D space between two rect's
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AABBIntersection : MonoBehaviour
{
/// <summary>
/// The main component that checks for a collision with the second object
/// </summary>
@8bitniksis
8bitniksis / Transparency
Created May 2, 2024 20:28
Shader which fixed issues with standard object if apply fade render query
Shader "Custom/Transparency "
{
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1)
}
SubShader
{
CGPROGRAM
@8bitniksis
8bitniksis / FresnelLazanyi_2019
Last active March 27, 2024 21:07
Function for calculate fresnel terms modified original lazanyi apprx
float Pow5(float x) { return x*x*x*x*x; }
float Pow6(float x) { return x*x*x*x*x*x; }
//Ref: https://diglib.eg.org/bitstream/handle/10.2312/mam20191305/007-011.pdf Eq(2;4)
float3 fresnel_lazanyi_2019(float cos_theta, float3 f0, float3 f82)
{
float3 a = 17.6513846 * (f0 - f82) + 8.16666667 * (1.0 - f0);
float m = Pow5(1.0 - cos_theta);
return clamp((f0 + (1.0 - f0) * m - a * cos_theta * (m - m * cos_theta)), 0, 1);
}
@8bitniksis
8bitniksis / CustomAmbientLights.cs
Created December 17, 2023 00:44 — forked from PeturDarriPeturs/CustomAmbientLights.cs
Unlimited custom directional lights using RenderSettings.ambientProbe.
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
[ExecuteAlways]
public class CustomAmbientLights : MonoBehaviour
{
[ColorUsage(false, true)]
public Color ambientLight;