Skip to content

Instantly share code, notes, and snippets.

View HK-SHAO's full-sized avatar
🎯
Focusing

HK-SHAO HK-SHAO

🎯
Focusing
View GitHub Profile
@HK-SHAO
HK-SHAO / sdf_cornell_box.py
Last active January 29, 2023 13:28
sdf_cornell_box.py
import taichi as ti
from taichi.math import *
ti.init(arch=ti.gpu, default_ip=ti.i32, default_fp=ti.f32)
image_resolution = (512, 512)
image_buffer = ti.Vector.field(4, float, image_resolution)
image_pixels = ti.Vector.field(3, float, image_resolution)
SCREEN_PIXEL_SIZE = 1.0 / vec2(image_resolution)
aspect_ratio = image_resolution[0] / image_resolution[1]
@HK-SHAO
HK-SHAO / PBRT.glsl
Last active January 17, 2023 14:10
RayTracing PBR with Free Camera in ShaderToy
// Copyright © 2019-2023 HK-SHAO
// MIT Licensed: https://shao.fun/blog/w/taichi-ray-tracing.html
#define load(P) texelFetch(iChannel1, ivec2(P), 0)
// 光线
struct ray {
vec3 origin; // 光的起点
vec3 direction; // 光的方向
vec3 color; // 光的颜色
@HK-SHAO
HK-SHAO / RayTracingPBR.glsl
Last active December 13, 2022 20:39
Godot Ray Tracing PBR Shader
shader_type canvas_item;
// 传入统一值
uniform vec3 camera_position = vec3(0.0, 0.0, 4.0); // 传入摄像机的位置
uniform mat3 camera_rotation = mat3(1); // 摄像机的旋转
uniform float camera_aspect = 2.0; // 画布长宽比
uniform float camera_vfov = 30.0; // 摄像机的纵向视野
uniform float camera_focus = 2.0; // 摄像机的对焦距离
uniform float camera_aperture = 0.005; // 摄像机的光圈大小
@HK-SHAO
HK-SHAO / PageNotFound.vue
Last active November 20, 2022 09:50
自动为404页面寻找最相关页面——使用字符串编辑距离和站点地图
<!--
# 自动为404页面寻找最相关页面——使用字符串编辑距离和站点地图
简要原理:用 `location.pathname` 接口获取当前 URL ,然后从 `sitemap.xml` 中寻找距离最近的 URL
以我的网站为例,你可以查看 `sitemap.xml` 的格式(它是由 VuePress 自动生成的): [sitemap.xml](https://shao.fun/sitemap.xml)
-->
<template>
<ParentLayout>
@HK-SHAO
HK-SHAO / wave-anim2.py
Created April 25, 2022 08:53
manim music visualization demo 2
from manimlib import *
import wave
import numpy as np
import queue
def my_coord(x, y):
return RIGHT * x + UP * y