Skip to content

Instantly share code, notes, and snippets.

View raganmd's full-sized avatar
🚀
do all the things

Matthew Ragan raganmd

🚀
do all the things
View GitHub Profile
@raganmd
raganmd / generating_normals
Created December 11, 2017 04:00
from Mike Walczyk: someone just posted this snippet in the cinder slack channel - a way of procedurally generating normals for a displaced surface, directly inside of the vertex shader
mat3 getTangentBasis( in vec3 tangent_y )
{
vec3 UpVector = vec3(0,1,0);
vec3 tangent_x = normalize( cross( UpVector, tangent_y ) );
vec3 tangent_z = cross( tangent_y, tangent_x );
return mat3( tangent_x, tangent_y, tangent_z );
}
vec3 applyDeformation( in vec3 pos, in vec3 norm )
{
@raganmd
raganmd / presets-cuebuilding-example-cue-structure
Last active December 11, 2017 15:17
Example JSON cue structure for blog post.
{
"cues": {
"cue1": {
"Tox": "Swank",
"Level_1": 0,
"Noise": 1,
"Level3": 4,
"Blacklvl": 0.75
},
"cue2": {
@raganmd
raganmd / presets-cuebuilding-example-cue-structure-unifrom
Last active December 11, 2017 15:18
Example JSON cue structure for blog post.
{
"cues": {
"cue1": {
"Tox": "Swank",
"Par1": 0,
"Par2": 1,
"Par3": 4,
"Par4": 0.75
},
"cue2": {
@raganmd
raganmd / textport-for-performance
Last active December 11, 2017 15:40
Code block from a blog post about using the text port for a live performance.,
'''
author | matthew ragan
web | matthewragan.com
The idea behind the display class comes from a question on the TouchDesiger
slack channel about how to handle displaying text for performance. While you
might choose to display the console, the challenge here is that you'll end
up with another window open on your output machine. Ideally, you only draw
a single openGL context - this results in the best possible performance
from TouchDesigner. With that in mind, how might you approach wanting to use
@raganmd
raganmd / module-example
Created December 11, 2017 16:04
Some sample module code from a TouchDesigner tutorial post
def multi_by_two( value ):
'''Multiplies input value by 2
A simple example function to see how we can use modules on demand.
This module takes a single argument which is multiplied by 2 and
then returned from the function.
Arguments
---------------
value( int / float ) - numeric value to be multiplied by 2
@raganmd
raganmd / learning-extensions-2
Last active December 11, 2017 16:09
A snippet from a blog post about writing extensions - how to write a logger.
import datetime
log_file = op( 'text_log_file' )
log_path = "example_extensions/log_files/log.txt"
full_text = '''{now}
Current Year | {year}
Current Month | {month}
Current Day | {day}
@raganmd
raganmd / learning-extensions-1
Created December 11, 2017 15:47
Sudo code from a blog post about writing extensions.
class Dishes():
def __init__( self ):
return
def Full_cycle( self, list_of_dishes ):
# what if we want to wash and then dry?
self.Wash( list_of_dishes, water_temp )
self.Dry( list_of_dishes )
@raganmd
raganmd / presets-and-cue-building-099-deck-logic
Created December 11, 2017 15:22
Code snippet from a blog post about preset building
# me - this DAT
#
# channel - the Channel object which has changed
# sampleIndex - the index of the changed sample
# val - the numeric value of the changed sample
# prev - the previous sample value
#
# Make sure the corresponding toggle is enabled in the CHOP Execute DAT.
attr = op( 'constant_attr' )
@raganmd
raganmd / td-docstring-example
Last active December 12, 2017 16:02
Example of using doc strings in a module in TouchDesigner
# first let's clear the text port to make sure we're starting fresh
clear()
# Here we're printing out the doc strings for multi_by_two
print( "The Doc Strings for multi_by_two are:" )
print( '\n' )
print( mod( 'text_simple_reutrn' ).multi_by_two.__doc__ )
# Here we're printing out the doc strings for lotic_test
print( "The Doc Strings for logic_test:" )
@raganmd
raganmd / td-looping-through-doc-strings
Created December 12, 2017 16:12
An example of how to loop through doc stirngs using .format()
# first let's clear the text port to make sure we're starting fresh
clear()
# rather than wasting our time writing all the code in the other example,
# instead let's write a for loop to automate that process.
# We'll start by first making a list of all of the methods we want to print
# doc strings for
methods = [
"multi_by_two",
"logic_test",