This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Unlit/CompareMipSelection" | |
{ | |
Properties | |
{ | |
_MainTex ("Main color texture", 2D) = "white" {} | |
_MipTexture ("Texture with different color mips", 2D) = "white" {} | |
_AnisoLevel ("Aniso Level (must set manually to match texture)", Range(0, 16)) = 0 | |
[ToggleUI] _VisualizeMipLevels ("Visualize Mip Levels", Integer) = 0 | |
} | |
SubShader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void EllipsoidTransformDerivatives(inout float2 dx, inout float2 dy) | |
{ | |
bool anyZero = length(dx) == 0 || length(dy) == 0; | |
bool parallel = (dx.x * dy.y - dx.y * dy.x) == 0; | |
bool perpendicular = dot(dx, dy) == 0; | |
bool nonFinite = isinf(dx) || isinf(dy) || isnan(dx) || isnan(dy); | |
if (!anyZero && !parallel && !perpendicular && !nonFinite) | |
{ | |
float A = dx.y*dx.y + dy.y*dy.y; | |
float B = -2.0 * (dx.x * dx.y + dy.x * dy.y); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MakeWeirdMips : MonoBehaviour | |
{ | |
[MenuItem("Pema/MakeWeirdMips")] | |
public static void MakeWeirdMipsAsset() | |
{ | |
Texture2D tex = new Texture2D(1024, 1024, GraphicsFormat.R32G32B32A32_SFloat, TextureCreationFlags.MipChain); | |
FillMip(tex, Color.magenta, 0); // 1024 | |
FillMip(tex, Color.green, 1); // 512 | |
FillMip(tex, Color.blue, 2); // 256 | |
FillMip(tex, Color.red, 3); // 128 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "pema99/SSR" | |
{ | |
Properties | |
{ | |
_MaxDistance("Max Distance", Range(0, 100)) = 10 | |
_Sparsity("Ray Sparsity", Range(0, 1)) = 1.0 | |
_Thickness("Thickness", Range(0, 1)) = 0.1 | |
_EdgeFade("Edge Fade", Range(0, 1)) = 0.1 | |
_Steps("Refinement Steps", Range(1, 20)) = 5 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "pema99/SSR" | |
{ | |
Properties | |
{ | |
_MaxDistance("Max Distance", Range(0, 100)) = 100 | |
_Steps("Steps", Range(1, 1000)) = 1 | |
_Thickness("Thickness", Range(0, 1)) = 0.1 | |
_EdgeFade("Edge Fade", Range(0, 1)) = 0.1 | |
} | |
SubShader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paper: ZH3: Quadratic Zonal Harmonics, i3D 2024. https://torust.me/ZH3.pdf | |
// Code based on paper and demo https://www.shadertoy.com/view/Xfj3RK | |
#include "UnityCG.cginc" | |
// L0 radiance = L0 irradiance * PI / Y_0 / AHat_0 | |
// PI / (sqrt(1 / PI) / 2) / PI = 2 * sqrt(PI) | |
const static float L0IrradianceToRadiance = 2 * sqrt(UNITY_PI); | |
// L1 radiance = L1 irradiance * PI / Y_1 / AHat_1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "pema99/SlangMarcher" | |
{ | |
Properties | |
{ | |
_Iterations ("Max iterations", Float) = 128 | |
_MaxDist ("Max distance", Float) = 50 | |
_MinDist ("Min distance", Float) = 0.001 | |
} | |
SubShader | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
[ExecuteAlways] | |
public class QuadLightEmitter : MonoBehaviour | |
{ | |
[ColorUsage(false, true)] | |
public Color color = Color.white; | |
public Transform[] verts; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
// Author: pema99 | |
// This file contains an implementation of a data structure I've named a BufferMap. | |
// It works as a map from 'handles' to values, where handles are just integers. | |
// You insert values into the map, and are returned an automatically generated handle. | |
// You can then use this handle to retrieve the value, or remove it from the map. | |
// Handles are never invalidated until they are explicitly removed. | |
// Amortized time complexities for adding, removing and getting a value from | |
// the map are all O(1). Additionally, the data structure has the property that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
// Author: pema99 | |
// This file contains functions that simulate Quad and Wave Intrinsics without access to either. | |
// For more information on those, see: https://github.com/Microsoft/DirectXShaderCompiler/wiki/Wave-Intrinsics | |
// To use the functions, you must call SETUP_QUAD_INTRINSICS(pos) at the start of your fragment shader, | |
// where 'pos' is the pixel position, ie. the fragment input variable with the SV_Position semantic. | |
// Note that some functions will require SM 5.0, ie. #pragma target 5.0. |
NewerOlder