cyberarm_engine 0.25.0 → 0.30.0

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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +9 -8
  3. data/.rubocop.yml +7 -7
  4. data/.travis.yml +5 -5
  5. data/Gemfile +6 -6
  6. data/Gemfile.lock +37 -25
  7. data/LICENSE.txt +21 -21
  8. data/README.md +74 -74
  9. data/Rakefile +10 -10
  10. data/assets/shaders/fragment/g_buffer.glsl +30 -30
  11. data/assets/shaders/fragment/lighting.glsl +115 -115
  12. data/assets/shaders/include/light_struct.glsl +11 -11
  13. data/assets/shaders/include/material_struct.glsl +16 -16
  14. data/assets/shaders/vertex/g_buffer.glsl +28 -28
  15. data/assets/shaders/vertex/lighting.glsl +24 -24
  16. data/assets/textures/ui/circle.png +0 -0
  17. data/assets/textures/ui/circle_small.png +0 -0
  18. data/assets/textures/ui/rounded.png +0 -0
  19. data/assets/textures/ui/rounded_bottom.png +0 -0
  20. data/assets/textures/ui/rounded_left.png +0 -0
  21. data/assets/textures/ui/rounded_left_bottom.png +0 -0
  22. data/assets/textures/ui/rounded_left_top.png +0 -0
  23. data/assets/textures/ui/rounded_right.png +0 -0
  24. data/assets/textures/ui/rounded_right_bottom.png +0 -0
  25. data/assets/textures/ui/rounded_right_top.png +0 -0
  26. data/assets/textures/ui/rounded_small.png +0 -0
  27. data/assets/textures/ui/rounded_tiny.png +0 -0
  28. data/assets/textures/ui/rounded_top.png +0 -0
  29. data/assets/textures/ui/square.png +0 -0
  30. data/bin/console +14 -14
  31. data/bin/setup +8 -8
  32. data/cyberarm_engine.gemspec +35 -36
  33. data/lib/cyberarm_engine/animator.rb +219 -219
  34. data/lib/cyberarm_engine/background.rb +156 -158
  35. data/lib/cyberarm_engine/background_image.rb +93 -93
  36. data/lib/cyberarm_engine/background_nine_slice.rb +182 -142
  37. data/lib/cyberarm_engine/bounding_box.rb +150 -150
  38. data/lib/cyberarm_engine/builtin/intro_state.rb +130 -130
  39. data/lib/cyberarm_engine/cache/download_manager.rb +123 -123
  40. data/lib/cyberarm_engine/cache.rb +4 -4
  41. data/lib/cyberarm_engine/common.rb +133 -131
  42. data/lib/cyberarm_engine/config_file.rb +46 -46
  43. data/lib/cyberarm_engine/console/command.rb +157 -157
  44. data/lib/cyberarm_engine/console/commands/help_command.rb +43 -43
  45. data/lib/cyberarm_engine/console/subcommand.rb +99 -99
  46. data/lib/cyberarm_engine/console.rb +248 -248
  47. data/lib/cyberarm_engine/event_bus.rb +39 -0
  48. data/lib/cyberarm_engine/game_object.rb +244 -244
  49. data/lib/cyberarm_engine/game_state.rb +134 -124
  50. data/lib/cyberarm_engine/gosu_ext/draw_arc.rb +111 -111
  51. data/lib/cyberarm_engine/gosu_ext/draw_circle.rb +30 -30
  52. data/lib/cyberarm_engine/gosu_ext/draw_path.rb +17 -17
  53. data/lib/cyberarm_engine/model/material.rb +21 -21
  54. data/lib/cyberarm_engine/model/mesh.rb +131 -131
  55. data/lib/cyberarm_engine/model/parser.rb +74 -74
  56. data/lib/cyberarm_engine/model/parsers/collada_parser.rb +138 -138
  57. data/lib/cyberarm_engine/model/parsers/wavefront_parser.rb +154 -154
  58. data/lib/cyberarm_engine/model.rb +216 -216
  59. data/lib/cyberarm_engine/model_cache.rb +31 -31
  60. data/lib/cyberarm_engine/notification.rb +82 -82
  61. data/lib/cyberarm_engine/notification_manager.rb +241 -241
  62. data/lib/cyberarm_engine/opengl/light.rb +52 -52
  63. data/lib/cyberarm_engine/opengl/orthographic_camera.rb +46 -46
  64. data/lib/cyberarm_engine/opengl/perspective_camera.rb +41 -41
  65. data/lib/cyberarm_engine/opengl/renderer/bounding_box_renderer.rb +249 -249
  66. data/lib/cyberarm_engine/opengl/renderer/g_buffer.rb +167 -167
  67. data/lib/cyberarm_engine/opengl/renderer/opengl_renderer.rb +307 -307
  68. data/lib/cyberarm_engine/opengl/renderer/renderer.rb +33 -33
  69. data/lib/cyberarm_engine/opengl/shader.rb +408 -408
  70. data/lib/cyberarm_engine/opengl/texture.rb +69 -69
  71. data/lib/cyberarm_engine/opengl.rb +53 -53
  72. data/lib/cyberarm_engine/pathfinding/graph.rb +64 -0
  73. data/lib/cyberarm_engine/pathfinding/graph_search.rb +6 -0
  74. data/lib/cyberarm_engine/pathfinding/graph_searches/astar_search.rb +6 -0
  75. data/lib/cyberarm_engine/pathfinding/graph_searches/breadth_first_search.rb +27 -0
  76. data/lib/cyberarm_engine/pathfinding/graph_searches/dijkstra_search.rb +6 -0
  77. data/lib/cyberarm_engine/pathfinding/graphs/grid.rb +52 -0
  78. data/lib/cyberarm_engine/ray.rb +56 -56
  79. data/lib/cyberarm_engine/result.rb +19 -0
  80. data/lib/cyberarm_engine/stats.rb +200 -200
  81. data/lib/cyberarm_engine/text.rb +288 -260
  82. data/lib/cyberarm_engine/timer.rb +27 -23
  83. data/lib/cyberarm_engine/transform.rb +296 -296
  84. data/lib/cyberarm_engine/trees/aabb_node.rb +126 -126
  85. data/lib/cyberarm_engine/trees/aabb_tree.rb +55 -55
  86. data/lib/cyberarm_engine/trees/aabb_tree_debug.rb +29 -29
  87. data/lib/cyberarm_engine/ui/border_canvas.rb +102 -102
  88. data/lib/cyberarm_engine/ui/dialog.rb +24 -0
  89. data/lib/cyberarm_engine/ui/dsl.rb +170 -142
  90. data/lib/cyberarm_engine/ui/element.rb +664 -662
  91. data/lib/cyberarm_engine/ui/elements/button.rb +99 -100
  92. data/lib/cyberarm_engine/ui/elements/check_box.rb +58 -54
  93. data/lib/cyberarm_engine/ui/elements/container.rb +413 -407
  94. data/lib/cyberarm_engine/ui/elements/edit_box.rb +200 -179
  95. data/lib/cyberarm_engine/ui/elements/edit_line.rb +299 -297
  96. data/lib/cyberarm_engine/ui/elements/flow.rb +15 -15
  97. data/lib/cyberarm_engine/ui/elements/image.rb +78 -72
  98. data/lib/cyberarm_engine/ui/elements/list_box.rb +79 -79
  99. data/lib/cyberarm_engine/ui/elements/menu.rb +27 -27
  100. data/lib/cyberarm_engine/ui/elements/menu_item.rb +6 -6
  101. data/lib/cyberarm_engine/ui/elements/progress.rb +95 -93
  102. data/lib/cyberarm_engine/ui/elements/radio.rb +6 -6
  103. data/lib/cyberarm_engine/ui/elements/slider.rb +111 -107
  104. data/lib/cyberarm_engine/ui/elements/stack.rb +11 -11
  105. data/lib/cyberarm_engine/ui/elements/text_block.rb +236 -222
  106. data/lib/cyberarm_engine/ui/elements/toggle_button.rb +71 -67
  107. data/lib/cyberarm_engine/ui/elements/widget.rb +45 -0
  108. data/lib/cyberarm_engine/ui/event.rb +54 -54
  109. data/lib/cyberarm_engine/ui/gui_state.rb +402 -326
  110. data/lib/cyberarm_engine/ui/page.rb +39 -0
  111. data/lib/cyberarm_engine/ui/style.rb +94 -61
  112. data/lib/cyberarm_engine/ui/theme.rb +237 -225
  113. data/lib/cyberarm_engine/vector.rb +312 -312
  114. data/lib/cyberarm_engine/version.rb +4 -4
  115. data/lib/cyberarm_engine/window.rb +234 -195
  116. data/lib/cyberarm_engine.rb +88 -76
  117. data/mrbgem.rake +29 -29
  118. metadata +30 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbc09f82118fdefb70fa12a4322beb094d02a6b359c72775bede0d38de911f1a
4
- data.tar.gz: 31d395c32d72a03867ba493470ba803a80eb209066952e2fbf52c8a0134910ad
3
+ metadata.gz: adf885ec549b6b0550708d2b037ebdf15f4ad45a90a6b600bbffb6ca0b2dc9b1
4
+ data.tar.gz: d5f249516e9979e54dbbcbee37e78a5993559e4322f3a18bc734f02c44b7944b
5
5
  SHA512:
6
- metadata.gz: b60db54bf9c4e23842f33d7cbcf867e9c9a3c2e73a135f3af9d38ec71c5a0ac52762869330c57febf1a2ab9b5db49bb0932193a2c3bc580929ccac5d620c9930
7
- data.tar.gz: 6c50e0b0a9aebba3258d648e5959009367284863f8c30de6e567a0923e0922020c5361ac9194f47f9a8e7af8dc5127a06bda2ed8ec7113dadb4c729b9c1353a0
6
+ metadata.gz: 92337be7d3ffe70bd5b3ea87ea7ec4232c92ab60afcf5beb8e3dd9bb62c201afdac06c9da8f1bb21e673b9160a18ac41bdd5b01172c317f86a561d3d62343a6b
7
+ data.tar.gz: 9ca3a2377f3faa7555bb3a8c49cee3b652c356a2ac6c725815e0b9526ab0021f139da24c5cff313a00c01596ea4f98bd35dd781513c71c6cf9de535a35d21bc3
data/.gitignore CHANGED
@@ -1,8 +1,9 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
1
+ /.idea
2
+ /.bundle/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rubocop.yml CHANGED
@@ -1,8 +1,8 @@
1
- Style/StringLiterals:
2
- EnforcedStyle: double_quotes
3
-
4
- Metrics/MethodLength:
5
- Max: 40
6
-
7
- Style/EmptyMethod:
1
+ Style/StringLiterals:
2
+ EnforcedStyle: double_quotes
3
+
4
+ Metrics/MethodLength:
5
+ Max: 40
6
+
7
+ Style/EmptyMethod:
8
8
  EnforcedStyle: expanded
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.0
5
- before_install: gem install bundler -v 1.16.1
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in cyberarm_engine.gemspec
6
- gemspec
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in cyberarm_engine.gemspec
6
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,25 +1,37 @@
1
- PATH
2
- remote: .
3
- specs:
4
- cyberarm_engine (0.24.5)
5
- gosu (~> 1.1)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- gosu (1.4.6)
11
- minitest (5.25.5)
12
- rake (13.2.1)
13
-
14
- PLATFORMS
15
- x64-mingw-ucrt
16
- x86_64-linux
17
-
18
- DEPENDENCIES
19
- bundler (~> 2.2)
20
- cyberarm_engine!
21
- minitest (~> 5.0)
22
- rake (~> 13.0)
23
-
24
- BUNDLED WITH
25
- 2.6.8
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cyberarm_engine (0.30.0)
5
+ gosu (~> 1.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ffi (1.17.4-x86_64-linux-gnu)
11
+ ffi (1.17.4-x86_64-linux-musl)
12
+ gosu (1.5.0-x86_64-linux)
13
+ ffi (~> 1.12)
14
+ minitest (5.27.0)
15
+ rake (13.4.2)
16
+
17
+ PLATFORMS
18
+ x86_64-linux-gnu
19
+ x86_64-linux-musl
20
+
21
+ DEPENDENCIES
22
+ bundler (~> 4)
23
+ cyberarm_engine!
24
+ minitest (~> 5.0)
25
+ rake (~> 13.0)
26
+
27
+ CHECKSUMS
28
+ bundler (4.1.0.beta1) sha256=8a2dac8ca276ff4eff5efc2c6457b0044080fc1e431534ad7c5cc6187232b800
29
+ cyberarm_engine (0.30.0)
30
+ ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
31
+ ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e
32
+ gosu (1.5.0-x86_64-linux)
33
+ minitest (5.27.0) sha256=2d3b17f8a36fe7801c1adcffdbc38233b938eb0b4966e97a6739055a45fa77d5
34
+ rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
35
+
36
+ BUNDLED WITH
37
+ 4.1.0.beta1
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 Cyberarm
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Cyberarm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,74 +1,74 @@
1
- ![CyberarmEngine](https://raw.githubusercontent.com/cyberarm/cyberarm_engine/master/assets/textures/logo.png)
2
-
3
- Yet Another Game Engine On Top Of Gosu
4
-
5
- ## Features
6
- * [Shoes-like](http://shoesrb.com) GUI support
7
- * OpenGL Shader support (requires [opengl-bindings](https://github.com/vaiorabbit/ruby-opengl) gem)
8
- * Includes classes for handling Vectors, Rays, Bounding Boxes, and Transforms
9
- * GameState system
10
- * Monolithic GameObjects
11
-
12
- ## Installation
13
-
14
- Add this line to your application's Gemfile:
15
-
16
- ```ruby
17
- gem 'cyberarm_engine'
18
- ```
19
-
20
- And then execute:
21
-
22
- $ bundle
23
-
24
- Or install it yourself as:
25
-
26
- $ gem install cyberarm_engine
27
-
28
- ## Usage
29
-
30
- ```ruby
31
- require "cyberarm_engine"
32
-
33
- class Hello < CyberarmEngine::GuiState
34
- def setup
35
- background Gosu::Color::GRAY
36
-
37
- stack do
38
- label "Hello World!"
39
-
40
- button "close" do
41
- window.close
42
- end
43
- end
44
- end
45
- end
46
-
47
- class Window < CyberarmEngine::Window
48
- def setup
49
- self.show_cursor = true
50
-
51
- push_state(Hello)
52
- end
53
- end
54
-
55
- Window.new(width: 800, height: 600, fullscreen: false, resizable: true).show
56
- ```
57
-
58
- ## Development
59
-
60
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
61
-
62
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
-
64
- ## Contributing
65
-
66
- Bug reports and pull requests are welcome on GitHub at https://github.com/cyberarm/cyberarm_engine.
67
-
68
- ## License
69
-
70
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
71
-
72
- ## Code of Conduct
73
-
74
- Everyone interacting in the CyberarmEngine project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the ruby moto of "Matz is nice so we are nice."
1
+ ![CyberarmEngine](https://raw.githubusercontent.com/cyberarm/cyberarm_engine/master/assets/textures/logo.png)
2
+
3
+ Yet Another Game Engine On Top Of Gosu
4
+
5
+ ## Features
6
+ * [Shoes-like](http://shoesrb.com) GUI support
7
+ * OpenGL Shader support (requires [opengl-bindings](https://github.com/vaiorabbit/ruby-opengl) gem)
8
+ * Includes classes for handling Vectors, Rays, Bounding Boxes, and Transforms
9
+ * GameState system
10
+ * Monolithic GameObjects
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'cyberarm_engine'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install cyberarm_engine
27
+
28
+ ## Usage
29
+
30
+ ```ruby
31
+ require "cyberarm_engine"
32
+
33
+ class Hello < CyberarmEngine::GuiState
34
+ def setup
35
+ background Gosu::Color::GRAY
36
+
37
+ stack do
38
+ banner "Hello World!"
39
+
40
+ button "close" do
41
+ window.close
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ class Window < CyberarmEngine::Window
48
+ def setup
49
+ self.show_cursor = true
50
+
51
+ push_state(Hello)
52
+ end
53
+ end
54
+
55
+ Window.new(width: 800, height: 600, fullscreen: false, resizable: true).show
56
+ ```
57
+
58
+ ## Development
59
+
60
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
61
+
62
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cyberarm/cyberarm_engine.
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
71
+
72
+ ## Code of Conduct
73
+
74
+ Everyone interacting in the CyberarmEngine project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the ruby moto of "Matz is nice so we are nice."
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
9
-
10
- task default: :test
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task default: :test
@@ -1,30 +1,30 @@
1
- # version 330 core
2
-
3
- layout(location = 0) out vec3 fragPosition;
4
- layout (location = 1) out vec4 fragColor;
5
- layout (location = 2) out vec3 fragNormal;
6
- layout (location = 3) out vec3 fragUV;
7
-
8
- in vec3 out_position, out_color, out_normal, out_uv, out_frag_pos, out_camera_pos;
9
- out vec4 outputFragColor;
10
- flat in int out_has_texture;
11
-
12
- uniform sampler2D diffuse_texture;
13
-
14
- void main() {
15
- vec3 result;
16
-
17
- if (out_has_texture == 0) {
18
- result = out_color;
19
- } else {
20
- result = texture(diffuse_texture, out_uv.xy).xyz + 0.25;
21
- }
22
-
23
- fragPosition = out_position;
24
- fragColor = vec4(result, 1.0);
25
- fragNormal = out_normal;
26
- fragUV = out_uv;
27
-
28
- float gamma = 2.2;
29
- outputFragColor.rgb = pow(fragColor.rgb, vec3(1.0 / gamma));
30
- }
1
+ # version 330 core
2
+
3
+ layout(location = 0) out vec3 fragPosition;
4
+ layout (location = 1) out vec4 fragColor;
5
+ layout (location = 2) out vec3 fragNormal;
6
+ layout (location = 3) out vec3 fragUV;
7
+
8
+ in vec3 out_position, out_color, out_normal, out_uv, out_frag_pos, out_camera_pos;
9
+ out vec4 outputFragColor;
10
+ flat in int out_has_texture;
11
+
12
+ uniform sampler2D diffuse_texture;
13
+
14
+ void main() {
15
+ vec3 result;
16
+
17
+ if (out_has_texture == 0) {
18
+ result = out_color;
19
+ } else {
20
+ result = texture(diffuse_texture, out_uv.xy).xyz + 0.25;
21
+ }
22
+
23
+ fragPosition = out_position;
24
+ fragColor = vec4(result, 1.0);
25
+ fragNormal = out_normal;
26
+ fragUV = out_uv;
27
+
28
+ float gamma = 2.2;
29
+ outputFragColor.rgb = pow(fragColor.rgb, vec3(1.0 / gamma));
30
+ }
@@ -1,115 +1,115 @@
1
- #version 330 core
2
- @include "light_struct"
3
-
4
- out vec4 frag_color;
5
-
6
- const int DIRECTIONAL = 0;
7
- const int POINT = 1;
8
- const int SPOT = 2;
9
-
10
- in vec2 out_tex_coords;
11
- flat in int out_light_count;
12
- flat in Light out_lights[7];
13
-
14
- uniform sampler2D diffuse, position, texcoord, normal, depth;
15
-
16
- vec4 directionalLight(Light light) {
17
- vec3 norm = normalize(texture(normal, out_tex_coords).rgb);
18
- vec3 diffuse_color = texture(diffuse, out_tex_coords).rgb;
19
- vec3 frag_pos = texture(position, out_tex_coords).rgb;
20
-
21
- vec3 lightDir = normalize(light.position - frag_pos);
22
- float diff = max(dot(norm, lightDir), 0);
23
-
24
- vec3 _ambient = light.ambient;
25
- vec3 _diffuse = light.diffuse * diff;
26
- vec3 _specular = light.specular;
27
-
28
- return vec4(_diffuse + _ambient + _specular, 1.0);
29
- }
30
-
31
- void main() {
32
- Light light;
33
- light.type = DIRECTIONAL;
34
-
35
- light.position = vec3(100, 100, 100);
36
-
37
- light.diffuse = vec3(0.5, 0.5, 0.5);
38
- light.ambient = vec3(0.8, 0.8, 0.8);
39
- light.specular = vec3(0.2, 0.2, 0.2);
40
-
41
- light.intensity = 1.0;
42
-
43
- frag_color = texture(diffuse, out_tex_coords) * directionalLight(light);
44
- }
45
-
46
- // #version 330 core
47
- // @include "light_struct"
48
-
49
- // out vec4 frag_color;
50
-
51
- // const int DIRECTIONAL = 0;
52
- // const int POINT = 1;
53
- // const int SPOT = 2;
54
-
55
- // in vec2 out_tex_coords;
56
- // flat in int out_light_count;
57
- // flat in Light out_lights[7];
58
-
59
- // uniform sampler2D diffuse, position, texcoord, normal, depth;
60
-
61
- // vec4 directionalLight(Light light) {
62
- // vec3 norm = normalize(texture(normal, out_tex_coords).rgb);
63
- // vec3 diffuse_color = texture(diffuse, out_tex_coords).rgb;
64
- // vec3 frag_pos = texture(position, out_tex_coords).rgb;
65
-
66
- // vec3 lightDir = normalize(light.position - frag_pos);
67
- // float diff = max(dot(norm, lightDir), 0);
68
-
69
- // vec3 _ambient = light.ambient;
70
- // vec3 _diffuse = light.diffuse * diff;
71
- // vec3 _specular = light.specular;
72
-
73
- // return vec4(_diffuse + _ambient + _specular, 1.0);
74
- // }
75
-
76
- // vec4 pointLight(Light light) {
77
- // return vec4(0.25, 0.25, 0.25, 1);
78
- // }
79
-
80
- // vec4 spotLight(Light light) {
81
- // return vec4(0.5, 0.5, 0.5, 1);
82
- // }
83
-
84
- // vec4 calculateLighting(Light light) {
85
- // vec4 result;
86
-
87
- // // switch(light.type) {
88
- // // case DIRECTIONAL: {
89
- // // result = directionalLight(light);
90
- // // }
91
- // // case SPOT: {
92
- // // result = spotLight(light);
93
- // // }
94
- // // default: {
95
- // // result = pointLight(light);
96
- // // }
97
- // // }
98
-
99
- // if (light.type == DIRECTIONAL) {
100
- // result = directionalLight(light);
101
- // } else {
102
- // result = pointLight(light);
103
- // }
104
-
105
- // return result;
106
- // }
107
-
108
- // void main() {
109
- // frag_color = vec4(0.0);
110
-
111
- // for(int i = 0; i < out_light_count; i++)
112
- // {
113
- // frag_color += texture(diffuse, out_tex_coords) * calculateLighting(out_lights[i]);
114
- // }
115
- // }
1
+ #version 330 core
2
+ @include "light_struct"
3
+
4
+ out vec4 frag_color;
5
+
6
+ const int DIRECTIONAL = 0;
7
+ const int POINT = 1;
8
+ const int SPOT = 2;
9
+
10
+ in vec2 out_tex_coords;
11
+ flat in int out_light_count;
12
+ flat in Light out_lights[7];
13
+
14
+ uniform sampler2D diffuse, position, texcoord, normal, depth;
15
+
16
+ vec4 directionalLight(Light light) {
17
+ vec3 norm = normalize(texture(normal, out_tex_coords).rgb);
18
+ vec3 diffuse_color = texture(diffuse, out_tex_coords).rgb;
19
+ vec3 frag_pos = texture(position, out_tex_coords).rgb;
20
+
21
+ vec3 lightDir = normalize(light.position - frag_pos);
22
+ float diff = max(dot(norm, lightDir), 0);
23
+
24
+ vec3 _ambient = light.ambient;
25
+ vec3 _diffuse = light.diffuse * diff;
26
+ vec3 _specular = light.specular;
27
+
28
+ return vec4(_diffuse + _ambient + _specular, 1.0);
29
+ }
30
+
31
+ void main() {
32
+ Light light;
33
+ light.type = DIRECTIONAL;
34
+
35
+ light.position = vec3(100, 100, 100);
36
+
37
+ light.diffuse = vec3(0.5, 0.5, 0.5);
38
+ light.ambient = vec3(0.8, 0.8, 0.8);
39
+ light.specular = vec3(0.2, 0.2, 0.2);
40
+
41
+ light.intensity = 1.0;
42
+
43
+ frag_color = texture(diffuse, out_tex_coords) * directionalLight(light);
44
+ }
45
+
46
+ // #version 330 core
47
+ // @include "light_struct"
48
+
49
+ // out vec4 frag_color;
50
+
51
+ // const int DIRECTIONAL = 0;
52
+ // const int POINT = 1;
53
+ // const int SPOT = 2;
54
+
55
+ // in vec2 out_tex_coords;
56
+ // flat in int out_light_count;
57
+ // flat in Light out_lights[7];
58
+
59
+ // uniform sampler2D diffuse, position, texcoord, normal, depth;
60
+
61
+ // vec4 directionalLight(Light light) {
62
+ // vec3 norm = normalize(texture(normal, out_tex_coords).rgb);
63
+ // vec3 diffuse_color = texture(diffuse, out_tex_coords).rgb;
64
+ // vec3 frag_pos = texture(position, out_tex_coords).rgb;
65
+
66
+ // vec3 lightDir = normalize(light.position - frag_pos);
67
+ // float diff = max(dot(norm, lightDir), 0);
68
+
69
+ // vec3 _ambient = light.ambient;
70
+ // vec3 _diffuse = light.diffuse * diff;
71
+ // vec3 _specular = light.specular;
72
+
73
+ // return vec4(_diffuse + _ambient + _specular, 1.0);
74
+ // }
75
+
76
+ // vec4 pointLight(Light light) {
77
+ // return vec4(0.25, 0.25, 0.25, 1);
78
+ // }
79
+
80
+ // vec4 spotLight(Light light) {
81
+ // return vec4(0.5, 0.5, 0.5, 1);
82
+ // }
83
+
84
+ // vec4 calculateLighting(Light light) {
85
+ // vec4 result;
86
+
87
+ // // switch(light.type) {
88
+ // // case DIRECTIONAL: {
89
+ // // result = directionalLight(light);
90
+ // // }
91
+ // // case SPOT: {
92
+ // // result = spotLight(light);
93
+ // // }
94
+ // // default: {
95
+ // // result = pointLight(light);
96
+ // // }
97
+ // // }
98
+
99
+ // if (light.type == DIRECTIONAL) {
100
+ // result = directionalLight(light);
101
+ // } else {
102
+ // result = pointLight(light);
103
+ // }
104
+
105
+ // return result;
106
+ // }
107
+
108
+ // void main() {
109
+ // frag_color = vec4(0.0);
110
+
111
+ // for(int i = 0; i < out_light_count; i++)
112
+ // {
113
+ // frag_color += texture(diffuse, out_tex_coords) * calculateLighting(out_lights[i]);
114
+ // }
115
+ // }
@@ -1,11 +1,11 @@
1
- struct Light {
2
- int type;
3
- vec3 direction;
4
- vec3 position;
5
-
6
- vec3 diffuse;
7
- vec3 ambient;
8
- vec3 specular;
9
-
10
- float intensity;
11
- };
1
+ struct Light {
2
+ int type;
3
+ vec3 direction;
4
+ vec3 position;
5
+
6
+ vec3 diffuse;
7
+ vec3 ambient;
8
+ vec3 specular;
9
+
10
+ float intensity;
11
+ };