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
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] |
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
// 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; // 光的颜色 |
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_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; // 摄像机的光圈大小 |
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
<!-- | |
# 自动为404页面寻找最相关页面——使用字符串编辑距离和站点地图 | |
简要原理:用 `location.pathname` 接口获取当前 URL ,然后从 `sitemap.xml` 中寻找距离最近的 URL | |
以我的网站为例,你可以查看 `sitemap.xml` 的格式(它是由 VuePress 自动生成的): [sitemap.xml](https://shao.fun/sitemap.xml) | |
--> | |
<template> | |
<ParentLayout> |
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
from manimlib import * | |
import wave | |
import numpy as np | |
import queue | |
def my_coord(x, y): | |
return RIGHT * x + UP * y |