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 )
{
vec3 snoiseVec3( vec3 x ){
x += u_transform;
float s = TDSimplexNoise(vec3( x ));
float s1 = TDSimplexNoise(vec3( x.y - 19.1 , x.z + 33.4 , x.x + 47.2 ));
float s2 = TDSimplexNoise(vec3( x.z + 74.2 , x.x - 124.5 , x.y + 99.4 ));
vec3 c = vec3( s , s1 , s2 );
return c;
@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 / 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 / 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 / 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 / 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 / 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 / td-module-logging-example
Last active July 26, 2021 02:30
An example of logging with a module rather than with an extension
import datetime
log_file = op( 'text_log' )
full_text = '''{now}
Current Year | {year}
Current Month | {month}
Current Day | {day}
Current Hour | {hour}