Skip to content

Instantly share code, notes, and snippets.

@UnaNancyOwen
UnaNancyOwen / CMakeLists.txt
Last active January 16, 2020 09:22
Drawing the Point Cloud retrieved from Kinect v2 using Point Cloud Library without Grabber
cmake_minimum_required( VERSION 2.8 )
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" ${CMAKE_MODULE_PATH} )
project( sample )
add_executable( sample main.cpp )
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "sample" )
# Find Packages
find_package( PCL 1.8 REQUIRED )
find_package( KinectSDK2 REQUIRED )
@aras-p
aras-p / TextureArray.md
Last active February 29, 2020 08:12
Basic texture array usage in shaders in Unity 5.4

You generally want this compilation target:

// uses texture arrays, so needs DX10/ES3 which is 3.5 target
#pragma target 3.5

Inside Properties block: _MyArr ("Tex", 2DArray) = "" {}

Declare the texture array sampler inside CGPROGRAM: UNITY_DECLARE_TEX2DARRAY(_MyArr);

@5agado
5agado / gp_animate.py
Last active February 15, 2021 08:35
Snippets for Grease Pencil Scripting Post
import bpy
NUM_FRAMES = 30
FRAMES_SPACING = 1 # distance between frames
bpy.context.scene.frame_start = 0
bpy.context.scene.frame_end = NUM_FRAMES*FRAMES_SPACING
for frame in range(NUM_FRAMES):
gp_frame = gp_layer.frames.new(frame*FRAMES_SPACING)
# do something with your frame
def draw_line(gp_frame, p0: tuple, p1: tuple):
# Init new stroke
gp_stroke = gp_frame.strokes.new()
gp_stroke.display_mode = '3DSPACE' # allows for editing
# Define stroke geometry
gp_stroke.points.add(count=2)
gp_stroke.points[0].co = p0
gp_stroke.points[1].co = p1
return gp_stroke
@jmpinit
jmpinit / blender_grease_pencil_drawing.py
Created September 22, 2019 21:48
Starting point for using Python to draw with the Grease Pencil in Blender 2.8.
# https://towardsdatascience.com/blender-2-8-grease-pencil-scripting-and-generative-art-cbbfd3967590
import bpy
import math
import numpy as np
def get_grease_pencil(gpencil_obj_name='GPencil') -> bpy.types.GreasePencil:
"""
Return the grease-pencil object with the given name. Initialize one if not already present.
:param gpencil_obj_name: name/key of the grease pencil object in the scene
def draw_circle(gp_frame, center: tuple, radius: float, segments: int):
# Init new stroke
gp_stroke = gp_frame.strokes.new()
gp_stroke.display_mode = '3DSPACE' # allows for editing
gp_stroke.draw_cyclic = True # closes the stroke
# Define stroke geometry
angle = 2*math.pi/segments # angle in radians
gp_stroke.points.add(count=segments)
for i in range(segments):
@5agado
5agado / grease_pencil_init.py
Last active May 5, 2022 11:03
Init method for Blender 2.8 Grease Pencil
import bpy
def get_grease_pencil(gpencil_obj_name='GPencil') -> bpy.types.GreasePencil:
"""
Return the grease-pencil object with the given name. Initialize one if not already present.
:param gpencil_obj_name: name/key of the grease pencil object in the scene
"""
# If not present already, create grease pencil object
if gpencil_obj_name not in bpy.context.scene.objects:
@LotteMakesStuff
LotteMakesStuff / EditorCoroutineRunner.cs
Last active May 20, 2022 10:21
Run stuff in the editor with all the convenience of co-routines! Add a status UI super easily to see readouts what your long running code is actually doing! nice~ There is a short API demo at the top of the class. This is a prefect companion for my inspector buttons https://gist.github.com/LotteMakesStuff/dd785ff49b2a5048bb60333a6a125187
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
public class EditorCoroutineRunner
{
[MenuItem("Window/Lotte's Coroutine Runner: Demo")]
from math import sin, cos
def rotate_stroke(stroke, angle, axis='z'):
# Define rotation matrix based on axis
if axis.lower() == 'x':
transform_matrix = np.array([[1, 0, 0],
[0, cos(angle), -sin(angle)],
[0, sin(angle), cos(angle)]])
elif axis.lower() == 'y':
transform_matrix = np.array([[cos(angle), 0, -sin(angle)],
@dondragmer
dondragmer / CuteSort.hlsl
Created December 5, 2020 00:11
A very fast GPU sort for sorting values within a wavefront
Buffer<uint> Input;
RWBuffer<uint> Output;
//returns the index that this value should be moved to to sort the array
uint CuteSort(uint value, uint laneIndex)
{
uint smallerValuesMask = 0;
uint equalValuesMask = ~0;
//don't need to test every bit if your value is constrained to a smaller range