Skip to content

Commit d870cd8

Browse files
author
monkstone
committed
add autorun rake
Former-commit-id: 1cd9220
1 parent f703ea5 commit d870cd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1533
-28
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*~

.gitignore.REMOVED.git-id

Lines changed: 0 additions & 1 deletion
This file was deleted.

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Contributing
2+
In the spirit of [free software][free-sw], **everyone** is encouraged to help improve this project.
3+
4+
Here are some ways *you* can contribute:
5+
6+
* by reporting bugs or problems [here][]
7+
* by writing or editing documentation
8+
* by [contributing examples][] ( _show your creativity, or translate someone elses masterpiece, you could learn a lot_ )
9+
10+
## Submitting an Issue
11+
We use the [GitHub issue tracker][issues] to track bugs and features. Before
12+
submitting a bug report or feature request, check to make sure it hasn't
13+
already been submitted. When submitting a bug report, ideally include a [Gist][]
14+
that includes a stack trace and any details that may be necessary to reproduce
15+
the bug, including your gem version, Ruby version, and operating system.
16+
17+
## Submitting a Pull Request
18+
1. [Fork the repository.][fork]
19+
2. [Submit a pull request.][pr]
20+
21+
[free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
22+
[here]: https://github.com/jashkenas/ruby-processing/issues
23+
[issues]: https://github.com/jashkenas/ruby-processing/issues
24+
[gist]: https://gist.github.com/
25+
[fork]: http://help.github.com/fork-a-repo/
26+
[pr]: http://help.github.com/send-pull-requests/
27+
[processing.org]: http://processing.org/foundation/
28+
[contributing examples]: https://github.com/ruby-processing/filters4ruby-processing/CONTRIBUTING.md

CONTRIBUTING.md.REMOVED.git-id

Lines changed: 0 additions & 1 deletion
This file was deleted.

LICENSE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
This work is very much a translation of original and derived work by Raphaël de Courville. All shaders from Shadertoy belong to there respective authors. Unless otherwise specified in the shader file, they are licensed under Creative Commons (CC BY-NC-SA 3.0). Otherwise as with ruby-processing MIT license applies:-
2+
3+
The MIT License (MIT)
4+
5+
Copyright (c) 2015 Ruby-Processing
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.

LICENSE.md.REMOVED.git-id

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
filters4ruby-processing
2+
==================
3+
A port of [Filters4Processing][] to ruby-processing
4+
A growing collection of pixel shaders ported to Processing to be used with the `filter()` function. Most of these shaders come from the excellent [Shadertoy](https://www.shadertoy.com) by Iñigo Quilez.
5+
6+
### To run shader sketches
7+
```bash
8+
rp5 --nojruby run/watch sketch.rb # Need to use jruby-complete
9+
```
10+
or in `.rp5rc` add following (if pure yaml)
11+
```yaml
12+
JRUBY: 'false'
13+
```
14+
or if you used our configRP5.pde tool (emits json)
15+
```json
16+
{
17+
"JRUBY": "false",
18+
....
19+
}
20+
```
21+
to avoid need for `--nojruby` flag, NB: delete line, or change back to 'true' when you need to use gems....
22+
23+
This is a java/jruby permission thing, and beyond our control
24+
## Filters
25+
26+
### Barrel Blur Chroma
27+
![screenshot](https://github.com/SableRaf/Filters4Processing/blob/master/screenshots/BarrelBlurChroma.jpg)
28+
29+
### Barrel & Pincushion
30+
![screenshot](https://github.com/SableRaf/Filters4Processing/blob/master/screenshots/BarrelPincushion.png)
31+
32+
### Bicubic Filter
33+
![screenshot](https://github.com/SableRaf/Filters4Processing/blob/master/screenshots/Bicubic.jpg)
34+
35+
### Bilateral Filter (denoise)
36+
![screenshot](https://github.com/SableRaf/Filters4Processing/blob/master/screenshots/Bilateral.jpg)
37+
38+
### Contrast, Saturation, Brightness
39+
![screenshot](https://github.com/SableRaf/Filters4Processing/blob/master/screenshots/ConSatBri.jpg)
40+
41+
### Dithering
42+
![screenshot](https://github.com/SableRaf/Filters4Processing/blob/master/screenshots/Dithering.jpg)
43+
44+
### Edge filter
45+
![screenshot](https://github.com/SableRaf/Filters4Processing/blob/master/screenshots/Edge.jpg)
46+
47+
## Usage
48+
49+
This is a minimal example showing how to import shader file in ruby-processing and use it as a filter.
50+
51+
*Note: Some shaders require additional uniforms. For details, refer to the example sketches included.*
52+
53+
```ruby
54+
attr_reader :my_filter, :my_image
55+
56+
def setup
57+
size(512, 512, P2D)
58+
# import an image object
59+
@my_image = load_image('texture.jpg')
60+
# load a shader object
61+
@my_filter = load_shader('shader.glsl')
62+
# pass the window size to the shader
63+
my_filter.set('sketchSize', width.to_f, height.to_f)
64+
end
65+
66+
def draw
67+
background(0)
68+
# Draw the image on the scene
69+
image(my_image, 0, 0)
70+
# Applies the shader to everything that has already been drawn
71+
return if mouse_pressed?
72+
filter(my_filter)
73+
end
74+
```
75+
76+
## Notes about porting filters from Shadertoy
77+
78+
Shadertoy and Processing both have their own quirks when it comes to shader programming. We need to make some changes in order to make Shadertoy code work with Processing/ruby-processing.
79+
80+
Replace:
81+
`void mainImage( out vec4 fragColor, in vec2 fragCoord )` -> `void main( void )`
82+
83+
Replace all:
84+
* `iChannel0` -> `texture`
85+
* `fragCoord` -> `gl_FragCoord`
86+
* `fragColor` -> `gl_FragColor`
87+
88+
There is more to it than this but these tips should cover most basic filters.
89+
90+
Now go dig for some [shaders](https://www.shadertoy.com/results?query=filter) and help us extend the library of filters available for Processing/ruby-processing!
91+
92+
*Note: It is possible to port other types of shaders, but this repository focuses on filters.*
93+
94+
## Acknowledgments
95+
Port to processing by Raphaël de Courville.
96+
Thanks to all the Shadertoy contributors for their hard work. This collection wouldn't exist without them. Thanks to Andres Colubri for his work on the Processing Shader API.
97+
98+
## License
99+
All shaders from Shadertoy belong to there respective authors. Unless otherwise specified in the shader file, they are licensed under Creative Commons ([CC BY-NC-SA 3.0](http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US))
100+
101+
[Filters4Processing]:https://github.com/SableRaf/Filters4Processing

README.md.REMOVED.git-id

Lines changed: 0 additions & 1 deletion
This file was deleted.

Rakefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# -*- encoding: utf-8 -*-
2+
3+
root = File.expand_path(__dir__)
4+
5+
desc 'run contributed samples'
6+
task :default => [:demo]
7+
8+
desc 'run all autorun samples'
9+
task :demo do
10+
Rake::Task[:image_filters].execute
11+
Rake::Task[:video_filters].execute
12+
end
13+
14+
desc 'run image samples'
15+
task :image_filters do
16+
sh "cd #{root}/image_filtering && rake"
17+
end
18+
19+
desc 'run video samples'
20+
task :shaders do
21+
sh "cd #{root}/video_filtering && rake"
22+
end
23+

image_filtering/Rakefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Simple demo Rakefile to autorun samples in current directory
2+
# adjust path to rp5 executable, and or opts as required
3+
4+
SAMPLES_DIR="./"
5+
6+
desc 'run demo'
7+
task :default => [:demo]
8+
9+
desc 'demo'
10+
task :demo do
11+
samples_list.shuffle.each{|sample| run_sample sample}
12+
end
13+
14+
def samples_list
15+
files = []
16+
Dir.chdir(SAMPLES_DIR)
17+
Dir.glob("*.rb").each do |file|
18+
files << File.join(SAMPLES_DIR, file)
19+
end
20+
return files
21+
end
22+
23+
def run_sample(sample_name)
24+
puts "Running #{sample_name}...quit to run next sample"
25+
open("|rp5 --nojruby run #{sample_name}", "r") do |io|
26+
while l = io.gets
27+
puts(l.chop)
28+
end
29+
end
30+
end

0 commit comments

Comments
 (0)