Skip to content

Instantly share code, notes, and snippets.

// https://light11.hatenadiary.com/entry/2022/04/25/190849
Shader "PBRExample"
{
Properties
{
_BaseMap("Base Map", 2D) = "white" {}
_BaseColor("Base Color", Color) = (1, 1, 1, 1)
[Normal] _NormalMap("Normal Map", 2D) = "bump" {}
_Metallic("Metallic", Range(0.0, 1.0)) = 0.0
_Smoothness("Smoothness", Range(0.0, 1.0)) = 0.0
@komietty
komietty / three-react-template.tsx
Last active April 13, 2022 07:51
three.js react hooks template
import { useEffect, useRef } from "react";
import * as THREE from "three";
const App = () => {
const ref = useRef<HTMLDivElement>(null);
const scn = new THREE.Scene();
const cam = new THREE.PerspectiveCamera(75, 1, 0.1, 1000);
const rnd = new THREE.WebGLRenderer();
useEffect(() => {
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import { fade } from 'svelte/transition';
export let x: number;
export let y: number;
let self: HTMLElement;
const dsp = createEventDispatcher();
const hide = (e) => { if (e.target !== self && !self.contains(e.target)) dsp('clickoutside'); }
$: ((x, y) => {
@komietty
komietty / renderer.svelte
Last active April 13, 2022 07:50
svelte-three-renderer-template
<script lang="ts">
import * as rndr from './renderer'
import { onMount } from 'svelte';
export let onstart: () => void = () => {};
export let onupdate: () => void = () => {};
let cvs: HTMLElement;
onMount(() => {
cvs.appendChild( rndr.rnd.domElement );
onstart();
#ifndef NOISE4D_INCLUDED
#define NOISE4D_INCLUDED
float4 mod289(float4 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
float mod289(float x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
@komietty
komietty / canvas.vue
Created November 11, 2017 09:16
pixi in vue
<template lang="html">
<div :class="'img-'+this.mainImgID" id="cvs_thumnails_box">
<canvas id="cvs">
</canvas>
<div id="thumbnails">
<div v-for="t in thumbnails" @click="changeImg(t.id)" :class="'thumbnail-'+ t.id" class="thumbnail">
</div>
</div>
</div>
</template>
let cvs = document.getElementById('cvs')
cvs.width = 800
cvs.height = 600
let renderer = new PIXI.WebGLRenderer(cvs.width, cvs.height, {view: cvs, antialias: true} )
let container = new PIXI.Container()
let img = new Image()
img.src = "/images/detail/" + imgID + ".jpg";
using UnityEngine;
namespace kmty.Util
{
public class MeanShift
{
public float Threshold { get; private set; }
public int LoopLimit { get; private set; }
public Vector2[] Samples { get; private set; }