glitch3d 0.2.3.6 → 0.2.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -4
- data/bin/glitch3d +3 -0
- data/fixtures/examples/demo.jpg +0 -0
- data/fixtures/textures/nice_glasses.jpg +0 -0
- data/lib/glitch3d/bpy/canvas/dreamatorium.py +1 -0
- data/lib/glitch3d/bpy/helpers.py +12 -18
- data/lib/glitch3d/bpy/main.py +5 -0
- data/lib/glitch3d/bpy/post-processing/mosaic.py +3 -3
- data/lib/glitch3d/bpy/post-processing/optimize.py +15 -0
- data/lib/glitch3d/strategies/duplication.rb +1 -17
- data/lib/glitch3d/version.rb +1 -1
- data/lib/glitch3d.rb +8 -21
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20f5ab3ec12f63cb4c39a2a8f4b5a9d49968c4e3
|
4
|
+
data.tar.gz: c4a9d2cd5b3776335c357f5475da4b2fb17ef8ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 912b55785ce3b9c2155c13b91e3db396d1e49d8b5c55e67a01fb5d06a4f539f363ccbd4b48b4b7b6f516eacf0b6bb83931512b7e9f23c279239bcff79bf9599f
|
7
|
+
data.tar.gz: d204670ff1ff5e430caaf19a82f661cf20fe7a5506dae6380e48d24b8d0e1857941aed571931f6f5a6fbe7c601a8534a8dd08504dbe7854354b9e85afae81211
|
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Glitch3d
|
2
2
|
|
3
|
-
Glitch3d is an automated render library that uses glitching techniques applied to 3D meshes.
|
3
|
+
Glitch3d is an automated render library that uses glitching techniques applied to 3D meshes. The original intent was to focus on 3D glitching techniques and morphed into a render bot.
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
You can read a bit more about where it come from [here](http://pascal.cc/blog/glitches) and see it living [there](https://twitter.com/glitchdemon).
|
6
|
+
|
7
|
+
<img src="https://raw.githubusercontent.com/pskl/glitch3d/master/fixtures/examples/demo.jpg" width="400">
|
7
8
|
|
8
9
|
This gem uses the Blender Python API to produces renders headlessly.
|
9
10
|
|
@@ -39,6 +40,8 @@ Options:
|
|
39
40
|
- `animate` : (true) default: false => Render .avi file
|
40
41
|
- `frame_numbers` : (default: 200) => number of frames
|
41
42
|
|
43
|
+
Renders (wether it is video or an image) will be output to `./renders` along with an export of the `.scene` file so that you can potentially fiddle with the existing setup.
|
44
|
+
|
42
45
|
## Development
|
43
46
|
|
44
47
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -49,7 +52,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
49
52
|
|
50
53
|
Bug reports and pull requests are welcome on GitHub at https://github.com/pskl/glitch3d. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
51
54
|
|
52
|
-
|
53
55
|
## License
|
54
56
|
|
55
57
|
Copyright © 217 PSKL <hello@pascal.cc>
|
data/bin/glitch3d
CHANGED
@@ -2,9 +2,12 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'glitch3d'
|
5
|
+
require 'pry' if ENV['RACK_ENV'] == 'development'
|
6
|
+
|
5
7
|
include Glitch3d
|
6
8
|
|
7
9
|
args = Hash[ARGV.join(' ').scan(/--?([^=\s]+)(?:=(\S+))?/)] if args.nil?
|
10
|
+
args.default = false
|
8
11
|
|
9
12
|
if ARGV[0] && !ARGV[0].start_with?('--')
|
10
13
|
source_file = ARGV[0]
|
Binary file
|
Binary file
|
data/lib/glitch3d/bpy/helpers.py
CHANGED
@@ -389,26 +389,18 @@ def build_pyramid(width=random.uniform(1,3), length=random.uniform(1,3), height=
|
|
389
389
|
faces.append([3,0,4])
|
390
390
|
return create_mesh('Pyramid ' + str(uuid.uuid1()), verts, faces, location)
|
391
391
|
|
392
|
-
def move_ocean(ocean):
|
393
|
-
if animate:
|
394
|
-
ocean.modifiers['Ocean'].time += 0.01
|
395
|
-
else:
|
396
|
-
ocean.modifiers['Ocean'].time += 2
|
397
|
-
ocean.modifiers['Ocean'].random_seed = round(random.uniform(0, 100))
|
398
|
-
ocean.modifers['Ocean'].choppiness += random.uniform(0, 1.15)
|
399
|
-
|
400
392
|
def camera_path(pitch = 0.01):
|
401
393
|
res = []
|
402
394
|
initial_z = INITIAL_CAMERA_LOCATION[2]
|
403
395
|
initial_x = INITIAL_CAMERA_LOCATION[0]
|
404
396
|
for y in pitched_array(initial_x, -initial_x, pitch):
|
405
|
-
res.append((initial_x, y,
|
397
|
+
res.append((initial_x, y, math.sin(0.5*y) + 0.5))
|
406
398
|
for x in pitched_array(initial_x, -initial_x, pitch):
|
407
|
-
res.append((x,-initial_x,
|
399
|
+
res.append((x,-initial_x, math.sin(0.5*x) + 0.5))
|
408
400
|
for y in pitched_array(-initial_x, initial_x, pitch):
|
409
|
-
res.append((-initial_x, y,
|
401
|
+
res.append((-initial_x, y, math.sin(0.5*y) + 0.5))
|
410
402
|
for x in pitched_array(-initial_x, initial_x, pitch):
|
411
|
-
res.append((x, initial_x,
|
403
|
+
res.append((x, initial_x, math.sin(0.5*x) + 0.5))
|
412
404
|
return res
|
413
405
|
|
414
406
|
def pitched_array(minimum, maximum, pitch):
|
@@ -417,10 +409,12 @@ def pitched_array(minimum, maximum, pitch):
|
|
417
409
|
def still_routine(index = 1):
|
418
410
|
CAMERA.location = mathutils.Vector(INITIAL_CAMERA_LOCATION) + mathutils.Vector((round(random.uniform(-3, 3), 10),round(random.uniform(-3, 3), 10),round(random.uniform(-1, 1), 10)))
|
419
411
|
randomize_reflectors_colors()
|
420
|
-
|
421
|
-
map(make_object_glossy, OCEAN)
|
412
|
+
make_object_glossy(OCEAN[0])
|
422
413
|
rotate(SUBJECT, index)
|
423
414
|
CAMERA.rotation_euler.y += math.radians(round(random.uniform(-50, +50)))
|
415
|
+
for ocean in OCEAN:
|
416
|
+
ocean.modifiers['Ocean'].random_seed = round(random.uniform(0, 100))
|
417
|
+
ocean.modifiers['Ocean'].choppiness += random.uniform(0, 1)
|
424
418
|
if bpy.data.groups['Lines'].objects:
|
425
419
|
for l in bpy.data.groups['Lines'].objects:
|
426
420
|
rotation = rand_rotation()
|
@@ -444,10 +438,10 @@ def animation_routine(frame):
|
|
444
438
|
look_at(SUBJECT)
|
445
439
|
randomize_reflectors_colors()
|
446
440
|
displace(SUBJECT)
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
SUBJECT.rotation_euler.z += math.radians(
|
441
|
+
for ocean in OCEAN:
|
442
|
+
ocean.modifiers['Ocean'].time += 0.5
|
443
|
+
make_object_glossy(OCEAN[0])
|
444
|
+
SUBJECT.rotation_euler.z += math.radians(1)
|
451
445
|
for l in bpy.data.groups['Lines'].objects:
|
452
446
|
l.rotation_euler.x += math.radians(5)
|
453
447
|
l.rotation_euler.z += math.radians(5)
|
data/lib/glitch3d/bpy/main.py
CHANGED
@@ -33,6 +33,7 @@ shots_number = int(args.shots_number)
|
|
33
33
|
#####################################
|
34
34
|
|
35
35
|
import os, bpy, datetime, random, math, mathutils, random, uuid, sys, logging, string, colorsys, code
|
36
|
+
from subprocess import call
|
36
37
|
|
37
38
|
# Create directory for renders
|
38
39
|
directory = os.path.dirname('./renders')
|
@@ -134,4 +135,8 @@ bpy.ops.wm.save_as_mainfile(filepath=output_name(model_path) + '.blend')
|
|
134
135
|
print("Files rendered:")
|
135
136
|
for p in RENDER_OUTPUT_PATHS:
|
136
137
|
print(p)
|
138
|
+
|
139
|
+
call(["python", os.path.join(path + '/glitch3d/bpy/post-processing/optimize.py')])
|
140
|
+
call(["python", os.path.join(path + '/glitch3d/bpy/post-processing/mosaic.py')])
|
141
|
+
|
137
142
|
print('FINISHED ¯\_(ツ)_/¯')
|
@@ -3,8 +3,8 @@ import os, sys
|
|
3
3
|
from PIL import Image
|
4
4
|
|
5
5
|
print("Mosaicing")
|
6
|
-
path = '
|
7
|
-
files = [path + f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
|
6
|
+
path = os.environ['RENDER_PATH']
|
7
|
+
files = [path + f for f in os.listdir(path) if (os.path.isfile(os.path.join(path, f)) and os.path.join(path, f).endswith(".png"))]
|
8
8
|
images = map(Image.open, files)
|
9
9
|
widths, heights = zip(*(i.size for i in images))
|
10
10
|
|
@@ -27,4 +27,4 @@ for file in files:
|
|
27
27
|
y_offset += image.size[1]
|
28
28
|
x_offset = 0
|
29
29
|
|
30
|
-
res.save('
|
30
|
+
res.save(path + 'mosaic.png')
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Resize and compress high quality renders to be able to send it around
|
2
|
+
import os, sys
|
3
|
+
from PIL import Image
|
4
|
+
|
5
|
+
print("Optimizing size of files")
|
6
|
+
|
7
|
+
path = os.environ['RENDER_PATH']
|
8
|
+
files = [path + f for f in os.listdir(path) if (os.path.isfile(os.path.join(path, f)) and os.path.join(path, f).endswith(".png"))]
|
9
|
+
|
10
|
+
for img in files:
|
11
|
+
print("file being optimized -> " + img)
|
12
|
+
image = Image.open(img)
|
13
|
+
image = image.resize((2000,2000),Image.ANTIALIAS)
|
14
|
+
image.save(img, quality=95)
|
15
|
+
image.save(img, optimize=True, quality=65)
|
@@ -2,12 +2,6 @@
|
|
2
2
|
module Glitch3d
|
3
3
|
module Duplication
|
4
4
|
def alter_vertices(vertices_objects_array)
|
5
|
-
# iteration_number = 2
|
6
|
-
# res = []
|
7
|
-
# iteration_number.times do |_|
|
8
|
-
# res = copy_random_element(vertices_objects_array, iteration_number, CHUNK_SIZE)
|
9
|
-
# end
|
10
|
-
# res
|
11
5
|
shuffle_vertices(vertices_objects_array)
|
12
6
|
end
|
13
7
|
|
@@ -16,22 +10,12 @@ module Glitch3d
|
|
16
10
|
end
|
17
11
|
|
18
12
|
def shuffle_vertices(array)
|
19
|
-
|
13
|
+
rand(3).times do
|
20
14
|
rand_index1 = rand(0..array.size - 1)
|
21
15
|
rand_index2 = rand(0..array.size - 1)
|
22
16
|
array[rand_index1], array[rand_index2] = array[rand_index2], array[rand_index1]
|
23
17
|
end
|
24
18
|
array
|
25
19
|
end
|
26
|
-
|
27
|
-
def copy_random_element(collection, iteration_number, chunk_size)
|
28
|
-
new_array = collection
|
29
|
-
iteration_number.times do
|
30
|
-
rand1 = rand(0..collection.size - 1)
|
31
|
-
rand2 = rand(0..collection.size - 1)
|
32
|
-
new_array[rand1..rand1 + chunk_size] = new_array[rand2..rand2 + chunk_size]
|
33
|
-
end
|
34
|
-
new_array
|
35
|
-
end
|
36
20
|
end
|
37
21
|
end
|
data/lib/glitch3d/version.rb
CHANGED
data/lib/glitch3d.rb
CHANGED
@@ -31,24 +31,7 @@ module Glitch3d
|
|
31
31
|
raise 'Make sure Blender is correctly installed' if BLENDER_EXECUTABLE_PATH.nil?
|
32
32
|
return clean_model(source_file) if args['clean']
|
33
33
|
source_file = random_fixture if source_file.nil?
|
34
|
-
|
35
|
-
if args.has_key?('version')
|
36
|
-
puts Glitch3d::VERSION
|
37
|
-
return nil
|
38
|
-
end
|
39
|
-
|
40
|
-
if args.has_key?('animate')
|
41
|
-
args['animate'] = 'true'
|
42
|
-
else
|
43
|
-
args['animate'] = 'false'
|
44
|
-
end
|
45
|
-
|
46
|
-
if args.has_key?('debug')
|
47
|
-
args['debug'] = 'true'
|
48
|
-
else
|
49
|
-
args['debug'] = 'false'
|
50
|
-
end
|
51
|
-
|
34
|
+
print_version if args.has_key?('version')
|
52
35
|
raise 'Set Blender executable path in your env variables before using glitch3d' if BLENDER_EXECUTABLE_PATH.nil?
|
53
36
|
self.class.include infer_strategy(args['mode'] || 'default')
|
54
37
|
@quality = args['quality'] || 'low'
|
@@ -60,6 +43,11 @@ module Glitch3d
|
|
60
43
|
render(args, target_file, args['shots-number'] || 6) unless args['no-render']
|
61
44
|
end
|
62
45
|
|
46
|
+
def print_version
|
47
|
+
puts Glitch3d::VERSION
|
48
|
+
return nil
|
49
|
+
end
|
50
|
+
|
63
51
|
def random_fixture
|
64
52
|
@fixtures_path = File.dirname(__FILE__) + '/../fixtures'
|
65
53
|
fixtures = []
|
@@ -159,7 +147,6 @@ module Glitch3d
|
|
159
147
|
end
|
160
148
|
|
161
149
|
def render(initial_args, file_path, shots_number)
|
162
|
-
raise 'Animation arg not boolean' unless eval(initial_args['animate']).is_a?(FalseClass) || eval(initial_args['animate']).is_a?(TrueClass)
|
163
150
|
args = [
|
164
151
|
BLENDER_EXECUTABLE_PATH,
|
165
152
|
'-b',
|
@@ -175,9 +162,9 @@ module Glitch3d
|
|
175
162
|
'-p',
|
176
163
|
File.dirname(__FILE__).to_s,
|
177
164
|
'-a',
|
178
|
-
initial_args['animate'].capitalize,
|
165
|
+
initial_args['animate'].to_s.capitalize,
|
179
166
|
'-d',
|
180
|
-
initial_args['debug'].capitalize
|
167
|
+
initial_args['debug'].to_s.capitalize
|
181
168
|
]
|
182
169
|
system(*args)
|
183
170
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glitch3d
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.3.
|
4
|
+
version: 0.2.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pskl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- bin/setup
|
91
91
|
- fixtures/brain.obj
|
92
92
|
- fixtures/cube.obj
|
93
|
+
- fixtures/examples/demo.jpg
|
93
94
|
- fixtures/face.obj
|
94
95
|
- fixtures/hand.obj
|
95
96
|
- fixtures/m4a1.obj
|
@@ -108,6 +109,7 @@ files:
|
|
108
109
|
- fixtures/textures/kago.jpg
|
109
110
|
- fixtures/textures/kawai.jpg
|
110
111
|
- fixtures/textures/mario.jpg
|
112
|
+
- fixtures/textures/nice_glasses.jpg
|
111
113
|
- fixtures/textures/rug.jpg
|
112
114
|
- fixtures/textures/slavs.jpg
|
113
115
|
- fixtures/textures/spiral.jpg
|
@@ -123,6 +125,7 @@ files:
|
|
123
125
|
- lib/glitch3d/bpy/lighting.py
|
124
126
|
- lib/glitch3d/bpy/main.py
|
125
127
|
- lib/glitch3d/bpy/post-processing/mosaic.py
|
128
|
+
- lib/glitch3d/bpy/post-processing/optimize.py
|
126
129
|
- lib/glitch3d/bpy/render_settings.py
|
127
130
|
- lib/glitch3d/objects/face.rb
|
128
131
|
- lib/glitch3d/objects/vertex.rb
|