refactor shader types

This commit is contained in:
Tim Caldwell
2019-06-09 11:44:46 +02:00
parent 17293824d3
commit 7d4ecc3c93
17 changed files with 30 additions and 29 deletions

View File

@@ -76,7 +76,7 @@ class Actions(object):
print('is selected shader: {}'.format(is_selected_shader))
if is_selected_shader and selected_shader['param_number'] > 0:
self.set_shader_param_mode()
elif is_shader and selected_shader['shad_type'] == 'gen' and self.shaders.selected_status == '':
elif is_shader and selected_shader['shad_type'] == '0in' and self.shaders.selected_status == '':
self.video_driver.current_player.toggle_pause()
def clear_all_slots(self):
@@ -269,11 +269,11 @@ class Actions(object):
def toggle_shaders(self):
if self.shaders.selected_status == '':
self.shaders.stop_selected_shader()
if self.shaders.selected_shader['shad_type'] == 'gen':
if self.shaders.selected_shader['shad_type'] == '0in':
self.video_driver.current_player.toggle_pause()
elif self.shaders.selected_status == '':
self.shaders.start_selected_shader()
if self.shaders.selected_shader['shad_type'] == 'gen':
if self.shaders.selected_shader['shad_type'] == '0in':
self.video_driver.current_player.toggle_pause()
else:
self.message_handler.set_message('INFO', 'no shader loaded')

View File

@@ -73,7 +73,7 @@ also, i have noticed occasionally the openframeworks app will crash (usually wit
cycling `DSPY` now also has a `SHADERS` mode. this gives a similar folder_nav view as BROWSER but is used for selecting glsl-fragment-shader files (usaully .frag). entering (`square`) on a shader file loads it (first line of DSPLY). the loaded shader can now be toggled on and off by pressing `FN + 6`
if a shader is marked 'gen' it will replace currently playing sample (similar to captur's preview), if it is marked 'pro' the sample will become processed through the shader.
if a shader is marked '0in' it will replace currently playing sample (similar to captur's preview), if it is marked 'pro' the sample will become processed through the shader.
if a shader has parameters that can be set by recur these will be displayed next to the loaded shaders name and type in SHADER display mode. (eg `x0:00 x1:78`). params are best controlled with continuos inputs (cv/pots/midi-cc) but can also be set on numpad:
@@ -83,11 +83,11 @@ see [this page] for more info on writing shaders for conjur. if a shader output
## c_o_n_j_u_r + c_a_p_t_u_r
running live input through a processing shader is an exciting possibility once you have live input and processing shaders already. this also is responsible for aprox half my time/stress while at SC !
running live input through a 1-input shader is an exciting possibility once you have live input and 1-input shaders already. this also is responsible for aprox half my time/stress while at SC !
to process the captur input with a glsl-shader it needs to be read from openframeworks using ofxRPiCameraGrabber addon rather than the piCapture python package. for all other sampling / previewing uses ~~i recommend using the python (default) option ,~~ both options seem to work - not sure if one is better than other... (even if you are in openframeworks-backend mode, you can still capture/sample as before, and process these samples etc)
- to truely process live input you need to switch the USE_OF_CAPTURE to on, (and make sure VIDEO_BACKEND is openframeworks ) , ~~depending on the capture state before this you might also need a soft reset (RESTART_PROGRAM in OTHER )~~ <-- this should be fixed. , now when you start capture preview it should be running through openframeworks ! any processing shaders run now will effect this input !
- to truely process live input you need to switch the USE_OF_CAPTURE to on, (and make sure VIDEO_BACKEND is openframeworks ) , ~~depending on the capture state before this you might also need a soft reset (RESTART_PROGRAM in OTHER )~~ <-- this should be fixed. , now when you start capture preview it should be running through openframeworks ! any 1-input shaders run now will effect this input !
- ~~if you are using piCaptureSd1 this will probably only work on composite output, and even there it may have some weird artifacts (like a glitchy line down the right side of screen) , i am working on getting some of those optimized settings into the openframeworks addon which should improve this.~~ piCaptureSd1 + openframeworks is working smoothly together now !

View File

@@ -49,9 +49,9 @@ having defined these different areas of the __r_e_c_u_r__ video instrument, we a
- _i_n_c_u_r_ + _c_o_n_j_u_r_ : shaders can be written to respond in real time based on user input. usually this is in the form of the mouse-x&y position. for recur i have defined normalized parameter inputs that can be used to manipulate any portion of the glsl code. having knobs or cv control over these parameters greatly increases the playablity of the shaders.
- _r_e_c_u_r_ + _c_o_n_j_u_r_ : at first i was thinking of video-files and glsl-shaders as separate sources for creating video. however then i discovered how you can also _use_ a glsl-shader to process a video-file (shaders can take textures as input, one of which can be a video), leading me to make the distinction in recur between _generating shaders_ and _processing shaders_ .
- _r_e_c_u_r_ + _c_o_n_j_u_r_ : at first i was thinking of video-files and glsl-shaders as separate sources for creating video. however then i discovered how you can also _use_ a glsl-shader to process a video-file (shaders can take textures as input, one of which can be a video), leading me to make the distinction in recur between _0-input shaders_ and _1-input shaders_ .
- c_a_p_t_u_r_ + _c_o_n_j_u_r_ : not only can _processing shaders_ accept video as a texture-input, they can also take texture from a live input (a camera or capture card for example). this means recur can also be used to process live video input in (almost) real time.
- c_a_p_t_u_r_ + _c_o_n_j_u_r_ : not only can _1-input shaders_ accept video as a texture-input, they can also take texture from a live input (a camera or capture card for example). this means recur can also be used to process live video input in (almost) real time.
## direction

View File

@@ -1,4 +1,4 @@
//gen-shader
//0-input
//written by Tim Caldwell
// a simple example of how to use continuous parameters to perform switching functions
#ifdef GL_ES

View File

@@ -1,5 +1,5 @@
// copied from http://glslsandbox.com/e#47821.0
//gen-shader
//0-input
#ifdef GL_ES
precision mediump float;
#endif

View File

@@ -1,4 +1,4 @@
//gen-shader
//0-input
//written by Ben Caldwell
#ifdef GL_ES
precision mediump float;

View File

@@ -1,4 +1,4 @@
//gen-shader
//0-input
//written by Ben Caldwell
#ifdef GL_ES
precision mediump float;

View File

@@ -1,4 +1,4 @@
//gen-shader
//0-input
//written by Ben Caldwell
#ifdef GL_ES
precision mediump float;

View File

@@ -1,4 +1,4 @@
//pro-shader
//1-input
//written by Tim Caldwell
#ifdef GL_ES
precision mediump float;

View File

@@ -1,4 +1,4 @@
//pro-shader
//1-input
#ifdef GL_ES
precision mediump float;
#endif

View File

@@ -1,4 +1,4 @@
//pro-shader
//1-input
//written by Tim Caldwell
// this is a simple example of how to change incoming textures colour
varying vec2 v_texcoord;

View File

@@ -1,4 +1,4 @@
//pro-shader
//1-input
#ifdef GL_ES
precision mediump float;

View File

@@ -1,4 +1,4 @@
//pro-shader
//1-input
//written by Tim Caldwell
//this is a basic example of how to effect input textures position
#ifdef GL_ES

View File

@@ -1,4 +1,4 @@
//pro-shader
//1-input
//written by Tim Caldwell
#ifdef GL_ES
precision highp float;

View File

@@ -1,4 +1,4 @@
//pro-shader
//1-input
//written by Tim Caldwell
#ifdef GL_ES
precision mediump float;

View File

@@ -1,4 +1,4 @@
//pro-shader
//1-input
//written by Tim Caldwell
#ifdef GL_ES
precision mediump float;

View File

@@ -28,7 +28,7 @@ class Shaders(object):
if line['is_shader']:
stripped_name = line['name'].lstrip()
has_path, path = self.get_path_for_shader(stripped_name)
shad_type = self.determine_if_shader_file_is_processing(path)
shad_type = self.determine_shader_type(path)
parameter_number = self.determine_shader_parameter_number(path)
#print('shader index is {}'.format(shad_i))
shaders_menu_list.append(dict(name=line['name'],is_shader=True,shad_type=shad_type,param_number=parameter_number,path=path,shad_index=shad_i))
@@ -46,13 +46,15 @@ class Shaders(object):
return True, '{}/{}'.format(root, file_name)
return False, ''
def determine_if_shader_file_is_processing(self, path):
def determine_shader_type(self, path):
with open(path, 'r') as selected_shader:
shader_text = selected_shader.read()
if '//pro-shader' in shader_text:
return 'pro'
elif '//gen-shader' in shader_text:
return 'gen'
if '//0-input' in shader_text:
return '0in'
elif '//1-input' in shader_text:
return '1in'
elif '//2-input' in shader_text:
return '2in'
else:
return '-'
@@ -68,8 +70,7 @@ class Shaders(object):
def load_selected_shader(self):
self.selected_param_values = [0.0,0.0,0.0,0.0]
is_pro = self.selected_shader['shad_type'] == 'pro'
self.osc_client.send_message("/shader/load", [self.selected_shader['path'],is_pro,self.selected_shader['param_number']])
self.osc_client.send_message("/shader/load", [self.selected_shader['path'],True,self.selected_shader['param_number']])
if not self.selected_status == '':
self.selected_status = ''