Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updates for #2

  • Loading branch information...
commit 7d00b8cce248f65069110884b46d33720a14ec2f 2 parents 3735ab9 + 1dd9e5d
Daniel Holden authored
Showing with 651 additions and 279 deletions.
  1. +2 −2 LICENCE.md
  2. +3 −3 Makefile
  3. +0 −1  TODO.md
  4. +0 −5 core_assets/shaders/collision_mesh.fs
  5. +0 −2  core_assets/shaders/collision_mesh.prog
  6. +0 −7 core_assets/shaders/collision_mesh.vs
  7. +0 −3  core_assets/shaders/deferred.prog
  8. +3 −0  core_assets/shaders/deferred/animated.prog
  9. 0  core_assets/shaders/{deferred_animated.vs → deferred/animated.vs}
  10. 0  core_assets/shaders/{deferred_clear.fs → deferred/clear.fs}
  11. +2 −0  core_assets/shaders/deferred/clear.prog
  12. 0  core_assets/shaders/{deferred_clear.vs → deferred/clear.vs}
  13. 0  core_assets/shaders/{deferred_screen.fs → deferred/compose.fs}
  14. +6 −0 core_assets/shaders/deferred/compose.prog
  15. 0  core_assets/shaders/{deferred_screen.vs → deferred/compose.vs}
  16. 0  core_assets/shaders/{deferred_post.fs → deferred/post.fs}
  17. +2 −2 core_assets/shaders/{deferred_post.prog → deferred/post.prog}
  18. 0  core_assets/shaders/{deferred_ssao.vs → deferred/post.vs}
  19. 0  core_assets/shaders/{deferred_ssao.fs → deferred/ssao.fs}
  20. +3 −0  core_assets/shaders/deferred/ssao.prog
  21. 0  core_assets/shaders/{deferred_post.vs → deferred/ssao.vs}
  22. 0  core_assets/shaders/{deferred.fs → deferred/static.fs}
  23. +3 −0  core_assets/shaders/deferred/static.prog
  24. 0  core_assets/shaders/{deferred.vs → deferred/static.vs}
  25. 0  core_assets/shaders/{deferred_tonemap.fs → deferred/tonemap.fs}
  26. +3 −0  core_assets/shaders/deferred/tonemap.prog
  27. 0  core_assets/shaders/{deferred_tonemap.vs → deferred/tonemap.vs}
  28. +20 −0 core_assets/shaders/deferred/ui.fs
  29. +2 −0  core_assets/shaders/deferred/ui.prog
  30. +4 −0 core_assets/shaders/deferred/ui.vs
  31. +0 −3  core_assets/shaders/deferred_animated.prog
  32. +0 −2  core_assets/shaders/deferred_clear.prog
  33. +0 −6 core_assets/shaders/deferred_screen.prog
  34. +0 −3  core_assets/shaders/deferred_ssao.prog
  35. +0 −3  core_assets/shaders/deferred_tonemap.prog
  36. +5 −0 core_assets/shaders/forward/animated.prog
  37. 0  core_assets/shaders/{norm_spec_env_animated.vs → forward/animated.vs}
  38. +52 −0 core_assets/shaders/forward/post.fs
  39. +5 −0 core_assets/shaders/forward/post.prog
  40. +4 −0 core_assets/shaders/forward/post.vs
  41. 0  core_assets/shaders/{norm_spec_env.fs → forward/static.fs}
  42. +2 −2 core_assets/shaders/{norm_spec_env.prog → forward/static.prog}
  43. 0  core_assets/shaders/{norm_spec_env.vs → forward/static.vs}
  44. 0  core_assets/shaders/{ → forward}/terrain.fs
  45. +5 −0 core_assets/shaders/forward/terrain.prog
  46. 0  core_assets/shaders/{ → forward}/terrain.vs
  47. +17 −0 core_assets/shaders/forward/tonemap.fs
  48. +3 −0  core_assets/shaders/forward/tonemap.prog
  49. +4 −0 core_assets/shaders/forward/tonemap.vs
  50. +0 −5 core_assets/shaders/norm_spec_env_animated.prog
  51. +0 −5 core_assets/shaders/terrain.prog
  52. +1 −1  demos/lut_gen/Makefile
  53. +1 −1  demos/metaballs/Makefile
  54. +1 −1  demos/noise/Makefile
  55. BIN  demos/noise/lib/libcorange.a
  56. +1 −1  demos/platformer/Makefile
  57. BIN  demos/platformer/lib/libcorange.a
  58. +1 −1  demos/renderers/Makefile
  59. BIN  demos/renderers/lib/libcorange.a
  60. BIN  demos/renderers/renderers
  61. +2 −2 demos/renderers/resources/cello/cello.mat
  62. +11 −11 demos/renderers/resources/dino/dino.mmat
  63. +2 −2 demos/renderers/resources/imrod/imrod_animated.mat
  64. +2 −2 demos/renderers/resources/imrod/imrod_static.mat
  65. +2 −2 demos/renderers/resources/piano/piano.mat
  66. +2 −2 demos/renderers/resources/podium/podium.mat
  67. +1 −1  demos/scotland/Makefile
  68. BIN  demos/scotland/lib/libcorange.a
  69. BIN  demos/scotland/scotland
  70. +1 −1  demos/sea/Makefile
  71. BIN  demos/sea/lib/libcorange.a
  72. +69 −69 demos/sea/resources/corvette/corvette.mmat
  73. +4 −3 include/corange.h
  74. +3 −0  include/{ → rendering}/deferred_renderer.h
  75. +22 −0 include/rendering/depth_mapper.h
  76. +0 −3  include/{ → rendering}/forward_renderer.h
  77. 0  include/{ → rendering}/shadow_mapper.h
  78. BIN  libcorange.so
  79. +4 −2 src/asset_manager.c
  80. +37 −39 src/{ → rendering}/deferred_renderer.c
  81. +310 −0 src/rendering/depth_mapper.c
  82. +21 −78 src/{ → rendering}/forward_renderer.c
  83. +3 −3 src/{ → rendering}/shadow_mapper.c
4 LICENCE.md
View
@@ -13,8 +13,8 @@ Corange is licensed under a basic BSD license.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 Makefile
View
@@ -23,10 +23,10 @@ endif
$(OUT): $(OBJ_FILES)
$(CC) $(OBJ_FILES) $(LFLAGS) -o $@
-obj/%.o: src/%.c obj
+obj/%.o: src/%.c | obj
$(CC) $< -c $(CFLAGS) -o $@
-obj/%.o: src/*/%.c obj
+obj/%.o: src/*/%.c | obj
$(CC) $< -c $(CFLAGS) -o $@
obj:
@@ -36,4 +36,4 @@ corange.res: corange.rc
windres $< -O coff -o $@
clean:
- rm $(OBJ_FILES)
+ rm $(OBJ_FILES)
1  TODO.md
View
@@ -12,7 +12,6 @@ Tweaks/Cleanup
* Optimise SDL_ReadLine to read more than one character at once.
* const stuff where needed (including asset stuff)
* Convert skeleton stuff to quaternions - though not sure if I trust my quaternion code. Slerp them nicely.
-* Reorganize shaders into component specific and general sections. Make them unload and load correctly on init/finish of components.
* Remove all fixed function stuff inc builtins from all shaders.
In the Future
5 core_assets/shaders/collision_mesh.fs
View
@@ -1,5 +0,0 @@
-uniform vec3 color;
-
-void main() {
- gl_FragColor = vec4(color, 0.25);
-}
2  core_assets/shaders/collision_mesh.prog
View
@@ -1,2 +0,0 @@
-vertex_shader : $CORANGE/shaders/collision_mesh.vs
-fragment_shader : $CORANGE/shaders/collision_mesh.fs
7 core_assets/shaders/collision_mesh.vs
View
@@ -1,7 +0,0 @@
-uniform mat4 world_matrix;
-uniform mat4 view_matrix;
-uniform mat4 proj_matrix;
-
-void main() {
- gl_Position = proj_matrix * view_matrix * world_matrix * gl_Vertex;
-}
3  core_assets/shaders/deferred.prog
View
@@ -1,3 +0,0 @@
-vertex_shader : $CORANGE/shaders/deferred.vs
-fragment_shader : $CORANGE/shaders/deferred.fs
-fragment_shader : $CORANGE/shaders/colors.fs
3  core_assets/shaders/deferred/animated.prog
View
@@ -0,0 +1,3 @@
+vertex_shader : $CORANGE/shaders/deferred/animated.vs
+fragment_shader : $CORANGE/shaders/deferred/static.fs
+fragment_shader : $CORANGE/shaders/colors.fs
0  core_assets/shaders/deferred_animated.vs → core_assets/shaders/deferred/animated.vs
View
File renamed without changes
0  core_assets/shaders/deferred_clear.fs → core_assets/shaders/deferred/clear.fs
View
File renamed without changes
2  core_assets/shaders/deferred/clear.prog
View
@@ -0,0 +1,2 @@
+vertex_shader : $CORANGE/shaders/deferred/clear.vs
+fragment_shader : $CORANGE/shaders/deferred/clear.fs
0  core_assets/shaders/deferred_clear.vs → core_assets/shaders/deferred/clear.vs
View
File renamed without changes
0  core_assets/shaders/deferred_screen.fs → core_assets/shaders/deferred/compose.fs
View
File renamed without changes
6 core_assets/shaders/deferred/compose.prog
View
@@ -0,0 +1,6 @@
+vertex_shader : $CORANGE/shaders/deferred/compose.vs
+fragment_shader : $CORANGE/shaders/deferred/compose.fs
+fragment_shader : $CORANGE/shaders/shadows.fs
+fragment_shader : $CORANGE/shaders/colors.fs
+fragment_shader : $CORANGE/shaders/screen_ao.fs
+fragment_shader : $CORANGE/shaders/fog.fs
0  core_assets/shaders/deferred_screen.vs → core_assets/shaders/deferred/compose.vs
View
File renamed without changes
0  core_assets/shaders/deferred_post.fs → core_assets/shaders/deferred/post.fs
View
File renamed without changes
4 core_assets/shaders/deferred_post.prog → core_assets/shaders/deferred/post.prog
View
@@ -1,5 +1,5 @@
-vertex_shader : $CORANGE/shaders/deferred_post.vs
-fragment_shader : $CORANGE/shaders/deferred_post.fs
+vertex_shader : $CORANGE/shaders/deferred/post.vs
+fragment_shader : $CORANGE/shaders/deferred/post.fs
fragment_shader : $CORANGE/shaders/colors.fs
fragment_shader : $CORANGE/shaders/anti_aliasing.fs
fragment_shader : $CORANGE/shaders/post_effects.fs
0  core_assets/shaders/deferred_ssao.vs → core_assets/shaders/deferred/post.vs
View
File renamed without changes
0  core_assets/shaders/deferred_ssao.fs → core_assets/shaders/deferred/ssao.fs
View
File renamed without changes
3  core_assets/shaders/deferred/ssao.prog
View
@@ -0,0 +1,3 @@
+vertex_shader : $CORANGE/shaders/deferred/ssao.vs
+fragment_shader : $CORANGE/shaders/deferred/ssao.fs
+fragment_shader : $CORANGE/shaders/screen_ao.fs
0  core_assets/shaders/deferred_post.vs → core_assets/shaders/deferred/ssao.vs
View
File renamed without changes
0  core_assets/shaders/deferred.fs → core_assets/shaders/deferred/static.fs
View
File renamed without changes
3  core_assets/shaders/deferred/static.prog
View
@@ -0,0 +1,3 @@
+vertex_shader : $CORANGE/shaders/deferred/static.vs
+fragment_shader : $CORANGE/shaders/deferred/static.fs
+fragment_shader : $CORANGE/shaders/colors.fs
0  core_assets/shaders/deferred.vs → core_assets/shaders/deferred/static.vs
View
File renamed without changes
0  core_assets/shaders/deferred_tonemap.fs → core_assets/shaders/deferred/tonemap.fs
View
File renamed without changes
3  core_assets/shaders/deferred/tonemap.prog
View
@@ -0,0 +1,3 @@
+vertex_shader : $CORANGE/shaders/deferred/tonemap.vs
+fragment_shader : $CORANGE/shaders/deferred/tonemap.fs
+fragment_shader : $CORANGE/shaders/colors.fs
0  core_assets/shaders/deferred_tonemap.vs → core_assets/shaders/deferred/tonemap.vs
View
File renamed without changes
20 core_assets/shaders/deferred/ui.fs
View
@@ -0,0 +1,20 @@
+uniform sampler2D diffuse;
+
+uniform float alpha_test;
+
+void main() {
+
+ vec4 color = texture2D(diffuse, gl_TexCoord[0].xy);
+ if (color.a < alpha_test) {
+ discard;
+ }
+
+ gl_FragData[0].rgb = color.rgb;
+ gl_FragData[0].a = 0.0;
+
+ gl_FragData[1].rgb = vec3(0,0,0);
+ gl_FragData[1].a = float(1);
+
+ gl_FragData[2].rgb = vec3(0,0,0);
+ gl_FragData[2].a = 0.0;
+}
2  core_assets/shaders/deferred/ui.prog
View
@@ -0,0 +1,2 @@
+vertex_shader : $CORANGE/shaders/deferred/ui.vs
+fragment_shader : $CORANGE/shaders/deferred/ui.fs
4 core_assets/shaders/deferred/ui.vs
View
@@ -0,0 +1,4 @@
+void main() {
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+}
3  core_assets/shaders/deferred_animated.prog
View
@@ -1,3 +0,0 @@
-vertex_shader : $CORANGE/shaders/deferred_animated.vs
-fragment_shader : $CORANGE/shaders/deferred.fs
-fragment_shader : $CORANGE/shaders/colors.fs
2  core_assets/shaders/deferred_clear.prog
View
@@ -1,2 +0,0 @@
-vertex_shader : $CORANGE/shaders/deferred_clear.vs
-fragment_shader : $CORANGE/shaders/deferred_clear.fs
6 core_assets/shaders/deferred_screen.prog
View
@@ -1,6 +0,0 @@
-vertex_shader : $CORANGE/shaders/deferred_screen.vs
-fragment_shader : $CORANGE/shaders/deferred_screen.fs
-fragment_shader : $CORANGE/shaders/shadows.fs
-fragment_shader : $CORANGE/shaders/colors.fs
-fragment_shader : $CORANGE/shaders/screen_ao.fs
-fragment_shader : $CORANGE/shaders/fog.fs
3  core_assets/shaders/deferred_ssao.prog
View
@@ -1,3 +0,0 @@
-vertex_shader : $CORANGE/shaders/deferred_ssao.vs
-fragment_shader : $CORANGE/shaders/deferred_ssao.fs
-fragment_shader : $CORANGE/shaders/screen_ao.fs
3  core_assets/shaders/deferred_tonemap.prog
View
@@ -1,3 +0,0 @@
-vertex_shader : $CORANGE/shaders/deferred_tonemap.vs
-fragment_shader : $CORANGE/shaders/deferred_tonemap.fs
-fragment_shader : $CORANGE/shaders/colors.fs
5 core_assets/shaders/forward/animated.prog
View
@@ -0,0 +1,5 @@
+vertex_shader : $CORANGE/shaders/forward/animated.vs
+fragment_shader : $CORANGE/shaders/forward/static.fs
+fragment_shader : $CORANGE/shaders/shadows.fs
+fragment_shader : $CORANGE/shaders/colors.fs
+fragment_shader : $CORANGE/shaders/fog.fs
0  core_assets/shaders/norm_spec_env_animated.vs → core_assets/shaders/forward/animated.vs
View
File renamed without changes
52 core_assets/shaders/forward/post.fs
View
@@ -0,0 +1,52 @@
+uniform int width;
+uniform int height;
+uniform int aa_type;
+
+uniform sampler2D ldr_texture;
+uniform sampler2D vignetting_texture;
+
+uniform sampler3D lut;
+
+/* Headers */
+
+vec3 color_correction(vec3 color, sampler3D lut, int lut_size);
+vec3 fxaa(sampler2D tex, vec2 uvs, int width, int height);
+vec3 fxaa_unsharp(sampler2D tex, vec2 uvs, int width, int height);
+vec3 unsharp_mask(sampler2D screen, vec2 coords, float strength, int width, int height);
+vec3 chromatic_aberration(sampler2D screen, vec2 coords, float offset);
+
+/* End */
+
+#define BLOOM_SIZE 4.0
+#define BLOOM_AMOUNT 5.0
+#define BLOOM_COLOR 3.0
+
+vec3 pow3(vec3 col, float exponent) {
+ vec3 ret;
+ ret.r = pow(col.r, exponent);
+ ret.g = pow(col.g, exponent);
+ ret.b = pow(col.b, exponent);
+ return ret;
+}
+
+void main() {
+
+ vec3 color;
+ if (aa_type == 1) {
+ color = fxaa_unsharp(ldr_texture, gl_TexCoord[0].xy, width, height);
+ } else {
+ //color = texture2D(ldr_texture, gl_TexCoord[0].xy).rgb;
+ //color = chromatic_aberration(ldr_texture, gl_TexCoord[0].xy, 1.0);
+ color = unsharp_mask(ldr_texture, gl_TexCoord[0].xy, 0.5, width, height);
+ }
+
+ vec3 vignetting = texture2D(vignetting_texture, gl_TexCoord[0].xy).rgb;
+
+ vec4 bloom_s = texture2DLod(ldr_texture, gl_TexCoord[0].xy, BLOOM_SIZE);
+ vec3 bloom = BLOOM_AMOUNT * bloom_s.a * pow3(bloom_s.rgb, BLOOM_COLOR);
+
+ color = (color + bloom) * mix(vignetting, vec3(1.0,1.0,1.0), 0.5);
+
+ gl_FragColor.rgb = color_correction(color, lut, 64);
+ gl_FragColor.a = 1.0;
+}
5 core_assets/shaders/forward/post.prog
View
@@ -0,0 +1,5 @@
+vertex_shader : $CORANGE/shaders/deferred/post.vs
+fragment_shader : $CORANGE/shaders/deferred/post.fs
+fragment_shader : $CORANGE/shaders/colors.fs
+fragment_shader : $CORANGE/shaders/anti_aliasing.fs
+fragment_shader : $CORANGE/shaders/post_effects.fs
4 core_assets/shaders/forward/post.vs
View
@@ -0,0 +1,4 @@
+void main() {
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+}
0  core_assets/shaders/norm_spec_env.fs → core_assets/shaders/forward/static.fs
View
File renamed without changes
4 core_assets/shaders/norm_spec_env.prog → core_assets/shaders/forward/static.prog
View
@@ -1,5 +1,5 @@
-vertex_shader : $CORANGE/shaders/norm_spec_env.vs
-fragment_shader : $CORANGE/shaders/norm_spec_env.fs
+vertex_shader : $CORANGE/shaders/forward/static.vs
+fragment_shader : $CORANGE/shaders/forward/static.fs
fragment_shader : $CORANGE/shaders/shadows.fs
fragment_shader : $CORANGE/shaders/colors.fs
fragment_shader : $CORANGE/shaders/fog.fs
0  core_assets/shaders/norm_spec_env.vs → core_assets/shaders/forward/static.vs
View
File renamed without changes
0  core_assets/shaders/terrain.fs → core_assets/shaders/forward/terrain.fs
View
File renamed without changes
5 core_assets/shaders/forward/terrain.prog
View
@@ -0,0 +1,5 @@
+vertex_shader : $CORANGE/shaders/forward/terrain.vs
+fragment_shader : $CORANGE/shaders/forward/terrain.fs
+fragment_shader : $CORANGE/shaders/shadows.fs
+fragment_shader : $CORANGE/shaders/colors.fs
+fragment_shader : $CORANGE/shaders/fog.fs
0  core_assets/shaders/terrain.vs → core_assets/shaders/forward/terrain.vs
View
File renamed without changes
17 core_assets/shaders/forward/tonemap.fs
View
@@ -0,0 +1,17 @@
+uniform sampler2D hdr_texture;
+
+uniform float exposure;
+
+vec3 filmic_tonemap(vec3 color, float exposure);
+
+void main() {
+
+ vec4 color = texture2D(hdr_texture, gl_TexCoord[0].xy);
+
+ color.rgb = filmic_tonemap(color.rgb, exposure);
+
+ float intensity = (color.r + color.g + color.b) / 3.0;
+ color.a = max(intensity - 1.0, 0.0);
+
+ gl_FragColor = color;
+}
3  core_assets/shaders/forward/tonemap.prog
View
@@ -0,0 +1,3 @@
+vertex_shader : $CORANGE/shaders/deferred/tonemap.vs
+fragment_shader : $CORANGE/shaders/deferred/tonemap.fs
+fragment_shader : $CORANGE/shaders/colors.fs
4 core_assets/shaders/forward/tonemap.vs
View
@@ -0,0 +1,4 @@
+void main() {
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+}
5 core_assets/shaders/norm_spec_env_animated.prog
View
@@ -1,5 +0,0 @@
-vertex_shader : $CORANGE/shaders/norm_spec_env_animated.vs
-fragment_shader : $CORANGE/shaders/norm_spec_env.fs
-fragment_shader : $CORANGE/shaders/shadows.fs
-fragment_shader : $CORANGE/shaders/colors.fs
-fragment_shader : $CORANGE/shaders/fog.fs
5 core_assets/shaders/terrain.prog
View
@@ -1,5 +0,0 @@
-vertex_shader : $CORANGE/shaders/terrain.vs
-fragment_shader : $CORANGE/shaders/terrain.fs
-fragment_shader : $CORANGE/shaders/shadows.fs
-fragment_shader : $CORANGE/shaders/colors.fs
-fragment_shader : $CORANGE/shaders/fog.fs
2  demos/lut_gen/Makefile
View
@@ -26,7 +26,7 @@ endif
$(OUT): $(OBJ_FILES) corange
$(CC) -g $(OBJ_FILES) $(LFLAGS) -o $@
-obj/%.o: src/%.c obj
+obj/%.o: src/%.c | obj
$(CC) $< -c $(CFLAGS) -o $@
obj:
2  demos/metaballs/Makefile
View
@@ -28,7 +28,7 @@ endif
$(OUT): $(OBJ_FILES) corange
$(CC) -g $(OBJ_FILES) $(LFLAGS) -o $@
-obj/%.o: src/%.c obj
+obj/%.o: src/%.c | obj
$(CC) $< -c $(CFLAGS) -o $@
obj:
2  demos/noise/Makefile
View
@@ -26,7 +26,7 @@ endif
$(OUT): $(OBJ_FILES) corange
$(CC) -g $(OBJ_FILES) $(LFLAGS) -o $@
-obj/%.o: src/%.c obj
+obj/%.o: src/%.c | obj
$(CC) $< -c $(CFLAGS) -o $@
obj:
BIN  demos/noise/lib/libcorange.a
View
Binary file not shown
2  demos/platformer/Makefile
View
@@ -26,7 +26,7 @@ endif
$(OUT): $(OBJ_FILES) corange
$(CC) -g $(OBJ_FILES) $(LFLAGS) -o $@
-obj/%.o: src/%.c obj
+obj/%.o: src/%.c | obj
$(CC) $< -c $(CFLAGS) -o $@
obj:
BIN  demos/platformer/lib/libcorange.a
View
Binary file not shown
2  demos/renderers/Makefile
View
@@ -26,7 +26,7 @@ endif
$(OUT): $(OBJ_FILES) corange
$(CC) -g $(OBJ_FILES) $(LFLAGS) -o $@
-obj/%.o: src/%.c obj
+obj/%.o: src/%.c | obj
$(CC) $< -c $(CFLAGS) -o $@
obj:
BIN  demos/renderers/lib/libcorange.a
View
Binary file not shown
BIN  demos/renderers/renderers
View
Binary file not shown
4 demos/renderers/resources/cello/cello.mat
View
@@ -1,5 +1,5 @@
string name = cello
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/cello/cello.dds
texture bump_map = ./resources/cello/cello_nm.dds
texture spec_map = ./resources/cello/cello_s.dds
@@ -8,4 +8,4 @@ float glossiness = 35
float bumpiness = 1.5
float specular_level = 8
float env_amount = 1.5
-int mat_id = 2
+int mat_id = 2
22 demos/renderers/resources/dino/dino.mmat
View
@@ -1,5 +1,5 @@
submaterial shell
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/dino/shell.dds
texture bump_map = ./resources/dino/shell_nm.dds
texture spec_map = ./resources/dino/shell_s.dds
@@ -10,7 +10,7 @@ float specular_level = 1.5
float env_amount = 3.0
submaterial bands
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/dino/bands.dds
texture bump_map = ./resources/dino/bands_nm.dds
texture spec_map = ./resources/dino/bands_s.dds
@@ -21,7 +21,7 @@ float specular_level = 1.5
float env_amount = 1.0
submaterial gun
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/dino/gun.dds
texture bump_map = ./resources/dino/gun_nm.dds
texture spec_map = ./resources/dino/gun_s.dds
@@ -32,7 +32,7 @@ float specular_level = 1.5
float env_amount = 3.0
submaterial gunbox
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/dino/gunbox.dds
texture bump_map = ./resources/dino/gunbox_nm.dds
texture spec_map = ./resources/dino/gunbox_s.dds
@@ -43,7 +43,7 @@ float specular_level = 1.5
float env_amount = 3.0
submaterial ammo_box
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/dino/ammo_box.dds
texture bump_map = ./resources/dino/ammo_box_nm.dds
texture spec_map = ./resources/dino/ammo_box_s.dds
@@ -55,7 +55,7 @@ float env_amount = 3.0
float alpha_test = 0.5
submaterial main_platform
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/dino/main_platform.dds
texture bump_map = ./resources/dino/main_platform_nm.dds
texture spec_map = ./resources/dino/main_platform_s.dds
@@ -67,7 +67,7 @@ float env_amount = 3.0
int mat_id = 3
submaterial flag
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/dino/flag.dds
texture bump_map = ./resources/dino/flag_nm.dds
texture spec_map = ./resources/dino/flag_s.dds
@@ -80,7 +80,7 @@ float alpha_test = 0.5
int mat_id = 3
submaterial gunturret
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/dino/gunturret.dds
texture bump_map = ./resources/dino/gunturret_nm.dds
texture spec_map = ./resources/dino/gunturret_s.dds
@@ -92,7 +92,7 @@ float env_amount = 3.0
int mat_id = 3
submaterial neck_ring
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/dino/neck_ring.dds
texture bump_map = ./resources/dino/neck_ring_nm.dds
texture spec_map = ./resources/dino/neck_ring_s.dds
@@ -104,7 +104,7 @@ float env_amount = 3.0
int mat_id = 3
submaterial body
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/dino/body.dds
texture bump_map = ./resources/dino/body_nm.dds
texture spec_map = ./resources/dino/body_s.dds
@@ -113,4 +113,4 @@ float glossiness = 5.0
float bumpiness = 1.75
float specular_level = 0.25
float env_amount = 0.5
-int mat_id = 2
+int mat_id = 2
4 demos/renderers/resources/imrod/imrod_animated.mat
View
@@ -1,5 +1,5 @@
string name = imrod
-program prog = $CORANGE/shaders/norm_spec_env_animated.prog
+program prog = $CORANGE/shaders/forward/animated.prog
texture diffuse_map = ./resources/imrod/imrod.dds
texture bump_map = ./resources/imrod/imrod_nm.dds
texture spec_map = ./resources/imrod/imrod_s.dds
@@ -8,4 +8,4 @@ float glossiness = 20.0
float bumpiness = 3.0
float specular_level = 5.0
float env_amount = 1.25
-int mat_id = 2
+int mat_id = 2
4 demos/renderers/resources/imrod/imrod_static.mat
View
@@ -1,5 +1,5 @@
string name = imrod
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/imrod/imrod.dds
texture bump_map = ./resources/imrod/imrod_nm.dds
texture spec_map = ./resources/imrod/imrod_s.dds
@@ -7,4 +7,4 @@ texture env_map = ./resources/imrod/imrod_env.dds
float glossiness = 30.0
float bumpiness = 2.5
float specular_level = 1.5
-float env_amount = 1.25
+float env_amount = 1.25
4 demos/renderers/resources/piano/piano.mat
View
@@ -1,5 +1,5 @@
string name = piano
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/piano/piano.dds
texture bump_map = ./resources/piano/piano_nm.dds
texture spec_map = ./resources/piano/piano_s.dds
@@ -8,4 +8,4 @@ float glossiness = 30
float bumpiness = 1.75
float specular_level = 3.0
float env_amount = 1.0
-int mat_id = 2
+int mat_id = 2
4 demos/renderers/resources/podium/podium.mat
View
@@ -1,5 +1,5 @@
string name = podium
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/podium/podium.dds
texture bump_map = ./resources/podium/podium_nm.dds
texture spec_map = ./resources/podium/podium_s.dds
@@ -8,4 +8,4 @@ float glossiness = 20
float bumpiness = 0.75
float specular_level = 0.75
float env_amount = 1.0
-int mat_id = 3
+int mat_id = 3
2  demos/scotland/Makefile
View
@@ -26,7 +26,7 @@ endif
$(OUT): $(OBJ_FILES) corange
$(CC) -g $(OBJ_FILES) $(LFLAGS) -o $@
-obj/%.o: src/%.c obj
+obj/%.o: src/%.c | obj
$(CC) $< -c $(CFLAGS) -o $@
obj:
BIN  demos/scotland/lib/libcorange.a
View
Binary file not shown
BIN  demos/scotland/scotland
View
Binary file not shown
2  demos/sea/Makefile
View
@@ -26,7 +26,7 @@ endif
$(OUT): $(OBJ_FILES) corange
$(CC) -g $(OBJ_FILES) $(LFLAGS) -o $@
-obj/%.o: src/%.c obj
+obj/%.o: src/%.c | obj
$(CC) $< -c $(CFLAGS) -o $@
obj:
BIN  demos/sea/lib/libcorange.a
View
Binary file not shown
138 demos/sea/resources/corvette/corvette.mmat
View
@@ -1,5 +1,5 @@
submaterial corvette_rudder
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_rudder.dds
texture bump_map = ./resources/corvette/corvette_rudder_nm.dds
texture spec_map = ./resources/corvette/corvette_rudder_s.dds
@@ -10,7 +10,7 @@ float specular_level = 2.0
float env_amount = 4.0
submaterial rigging_board
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rigging_board.dds
texture bump_map = ./resources/corvette/rigging_board_nm.dds
texture spec_map = ./resources/corvette/rigging_board_s.dds
@@ -21,7 +21,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial rigging_board
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rigging_board.dds
texture bump_map = ./resources/corvette/rigging_board_nm.dds
texture spec_map = ./resources/corvette/rigging_board_s.dds
@@ -32,7 +32,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial anchor_port
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/anchor_port.dds
texture bump_map = ./resources/corvette/anchor_port_nm.dds
texture spec_map = ./resources/corvette/anchor_port_s.dds
@@ -43,7 +43,7 @@ float specular_level = 2.0
float env_amount = 4.0
submaterial ship_loader_hook
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/ship_loader_hook.dds
texture bump_map = ./resources/corvette/ship_loader_hook_nm.dds
texture spec_map = ./resources/corvette/ship_loader_hook_s.dds
@@ -54,7 +54,7 @@ float specular_level = 2.0
float env_amount = 4.0
submaterial rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -65,7 +65,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial corvette_mast
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_mast.dds
texture bump_map = ./resources/corvette/corvette_mast_nm.dds
texture spec_map = ./resources/corvette/corvette_mast_s.dds
@@ -76,7 +76,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_mast
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_mast.dds
texture bump_map = ./resources/corvette/corvette_mast_nm.dds
texture spec_map = ./resources/corvette/corvette_mast_s.dds
@@ -87,7 +87,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_banister
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_banister.dds
texture bump_map = ./resources/corvette/corvette_banister_nm.dds
texture spec_map = ./resources/corvette/corvette_banister_s.dds
@@ -98,7 +98,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial corvette_banister
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_banister.dds
texture bump_map = ./resources/corvette/corvette_banister_nm.dds
texture spec_map = ./resources/corvette/corvette_banister_s.dds
@@ -109,7 +109,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial captains_wheel
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/captains_wheel.dds
texture bump_map = ./resources/corvette/captains_wheel_nm.dds
texture spec_map = ./resources/corvette/captains_wheel_s.dds
@@ -120,7 +120,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_rigging
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_rigging.dds
texture bump_map = ./resources/corvette/corvette_rigging_nm.dds
texture spec_map = ./resources/corvette/corvette_rigging_s.dds
@@ -131,7 +131,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_rigging
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_rigging.dds
texture bump_map = ./resources/corvette/corvette_rigging_nm.dds
texture spec_map = ./resources/corvette/corvette_rigging_s.dds
@@ -142,7 +142,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_rigging
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_rigging.dds
texture bump_map = ./resources/corvette/corvette_rigging_nm.dds
texture spec_map = ./resources/corvette/corvette_rigging_s.dds
@@ -153,7 +153,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial ship_ladder
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/ship_ladder.dds
texture bump_map = ./resources/corvette/ship_ladder_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -164,7 +164,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial corvette_figurehead
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_figurehead.dds
texture bump_map = ./resources/corvette/corvette_figurehead_nm.dds
texture spec_map = ./resources/corvette/corvette_figurehead_s.dds
@@ -175,7 +175,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial black_rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/black_rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -186,7 +186,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial rigging_bits
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rigging_bits.dds
texture bump_map = ./resources/corvette/rigging_bits_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -197,7 +197,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -208,7 +208,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial wire
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/wire.dds
texture bump_map = ./resources/corvette/wire_nm.dds
texture spec_map = ./resources/corvette/wire_s.dds
@@ -219,7 +219,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial black_rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/black_rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -230,7 +230,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial rigging_bits
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rigging_bits.dds
texture bump_map = ./resources/corvette/rigging_bits_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -241,7 +241,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -252,7 +252,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial wire
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/wire.dds
texture bump_map = ./resources/corvette/wire_nm.dds
texture spec_map = ./resources/corvette/wire_s.dds
@@ -263,7 +263,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial black_rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/black_rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -274,7 +274,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial rigging_bits
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rigging_bits.dds
texture bump_map = ./resources/corvette/rigging_bits_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -285,7 +285,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -296,7 +296,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial wire
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/wire.dds
texture bump_map = ./resources/corvette/wire_nm.dds
texture spec_map = ./resources/corvette/wire_s.dds
@@ -307,7 +307,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial black_rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/black_rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -318,7 +318,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial rigging_bits
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rigging_bits.dds
texture bump_map = ./resources/corvette/rigging_bits_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -329,7 +329,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -340,7 +340,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial wire
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/wire.dds
texture bump_map = ./resources/corvette/wire_nm.dds
texture spec_map = ./resources/corvette/wire_s.dds
@@ -351,7 +351,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial black_rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/black_rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -362,7 +362,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial rigging_bits
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rigging_bits.dds
texture bump_map = ./resources/corvette/rigging_bits_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -373,7 +373,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -384,7 +384,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial wire
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/wire.dds
texture bump_map = ./resources/corvette/wire_nm.dds
texture spec_map = ./resources/corvette/wire_s.dds
@@ -395,7 +395,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial black_rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/black_rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -406,7 +406,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial rigging_bits
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rigging_bits.dds
texture bump_map = ./resources/corvette/rigging_bits_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -417,7 +417,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial rope
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/rope.dds
texture bump_map = ./resources/corvette/rope_nm.dds
texture spec_map = ./resources/corvette/rope_s.dds
@@ -428,7 +428,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial wire
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/wire.dds
texture bump_map = ./resources/corvette/wire_nm.dds
texture spec_map = ./resources/corvette/wire_s.dds
@@ -439,7 +439,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial furled_sails
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/furled_sails.dds
texture bump_map = ./resources/corvette/furled_sails_nm.dds
texture spec_map = ./resources/corvette/furled_sails_s.dds
@@ -450,7 +450,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial mast_cross_beam
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/mast_cross_beam.dds
texture bump_map = ./resources/corvette/mast_cross_beam_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -461,7 +461,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial furled_sails
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/furled_sails.dds
texture bump_map = ./resources/corvette/furled_sails_nm.dds
texture spec_map = ./resources/corvette/furled_sails_s.dds
@@ -472,7 +472,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial mast_cross_beam
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/mast_cross_beam.dds
texture bump_map = ./resources/corvette/mast_cross_beam_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -483,7 +483,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial furled_sails
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/furled_sails.dds
texture bump_map = ./resources/corvette/furled_sails_nm.dds
texture spec_map = ./resources/corvette/furled_sails_s.dds
@@ -494,7 +494,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial mast_cross_beam
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/mast_cross_beam.dds
texture bump_map = ./resources/corvette/mast_cross_beam_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -505,7 +505,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial furled_sails
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/furled_sails.dds
texture bump_map = ./resources/corvette/furled_sails_nm.dds
texture spec_map = ./resources/corvette/furled_sails_s.dds
@@ -516,7 +516,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial mast_cross_beam
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/mast_cross_beam.dds
texture bump_map = ./resources/corvette/mast_cross_beam_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -527,7 +527,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial corvette_mast
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_mast.dds
texture bump_map = ./resources/corvette/corvette_mast_nm.dds
texture spec_map = ./resources/corvette/corvette_mast_s.dds
@@ -538,7 +538,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_front_mast
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_front_mast.dds
texture bump_map = ./resources/corvette/corvette_front_mast_nm.dds
texture spec_map = ./resources/corvette/corvette_front_mast_s.dds
@@ -549,7 +549,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_decoration
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_decoration.dds
texture bump_map = ./resources/corvette/corvette_decoration_nm.dds
texture spec_map = ./resources/corvette/corvette_decoration_s.dds
@@ -560,7 +560,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial captains_wheel
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/captains_wheel.dds
texture bump_map = ./resources/corvette/captains_wheel_nm.dds
texture spec_map = ./resources/corvette/captains_wheel_s.dds
@@ -571,7 +571,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial ship_ladder
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/ship_ladder.dds
texture bump_map = ./resources/corvette/ship_ladder_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -582,7 +582,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial capstan
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/capstan.dds
texture bump_map = ./resources/corvette/capstan_nm.dds
texture spec_map = ./resources/corvette/capstan_s.dds
@@ -593,7 +593,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial mast_turner
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/mast_turner.dds
texture bump_map = ./resources/corvette/mast_turner_nm.dds
texture spec_map = ./resources/corvette/mast_turner_s.dds
@@ -604,7 +604,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial anchor
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/anchor.dds
texture bump_map = ./resources/corvette/anchor_nm.dds
texture spec_map = ./resources/corvette/anchor_s.dds
@@ -615,7 +615,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial anchor
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/anchor.dds
texture bump_map = ./resources/corvette/anchor_nm.dds
texture spec_map = ./resources/corvette/anchor_s.dds
@@ -626,7 +626,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial ship_below_area
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/ship_below_area.dds
texture bump_map = ./resources/corvette/ship_below_area_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -637,7 +637,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial ships_grate_medium
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/ships_grate_medium.dds
texture bump_map = ./resources/corvette/ships_grate_medium_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -648,7 +648,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial lantern
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/lantern.dds
texture bump_map = ./resources/corvette/lantern_nm.dds
texture spec_map = ./resources/corvette/lantern_s.dds
@@ -659,7 +659,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial lantern_glass
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/lantern_glass.dds
texture bump_map = ./resources/corvette/lantern_glass_nm.dds
texture spec_map = ./resources/corvette/lantern_glass_s.dds
@@ -670,7 +670,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial ship_below_area
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/ship_below_area.dds
texture bump_map = ./resources/corvette/ship_below_area_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -681,7 +681,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial ship_below_area
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/ship_below_area.dds
texture bump_map = ./resources/corvette/ship_below_area_nm.dds
texture spec_map = ./resources/corvette/black.dds
@@ -692,7 +692,7 @@ float specular_level = 2.0
float env_amount = 1.0
submaterial corvette_hull
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_hull.dds
texture bump_map = ./resources/corvette/corvette_hull_nm.dds
texture spec_map = ./resources/corvette/corvette_hull_s.dds
@@ -703,7 +703,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_cabin
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_cabin.dds
texture bump_map = ./resources/corvette/corvette_cabin_nm.dds
texture spec_map = ./resources/corvette/corvette_cabin_s.dds
@@ -714,7 +714,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_floor
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_floor.dds
texture bump_map = ./resources/corvette/corvette_floor_nm.dds
texture spec_map = ./resources/corvette/corvette_floor_s.dds
@@ -725,7 +725,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_border
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_border.dds
texture bump_map = ./resources/corvette/corvette_border_nm.dds
texture spec_map = ./resources/corvette/corvette_border_s.dds
@@ -736,7 +736,7 @@ float specular_level = 2.0
float env_amount = 2.0
submaterial corvette_rudder
-program prog = $CORANGE/shaders/norm_spec_env.prog
+program prog = $CORANGE/shaders/forward/static.prog
texture diffuse_map = ./resources/corvette/corvette_rudder.dds
texture bump_map = ./resources/corvette/corvette_rudder_nm.dds
texture spec_map = ./resources/corvette/corvette_rudder_s.dds
@@ -744,4 +744,4 @@ texture env_map = ./resources/corvette/ocean_env_map.dds
float glossiness = 25.0
float bumpiness = 2.0
float specular_level = 2.0
-float env_amount = 2.0
+float env_amount = 2.0
7 include/corange.h
View
@@ -62,9 +62,10 @@ void corange_finish();
/* Rendering */
-#include "forward_renderer.h"
-#include "deferred_renderer.h"
-#include "shadow_mapper.h"
+#include "rendering/forward_renderer.h"
+#include "rendering/deferred_renderer.h"
+#include "rendering/shadow_mapper.h"
+#include "rendering/depth_mapper.h"
/* Data Structures */
3  include/deferred_renderer.h → include/rendering/deferred_renderer.h
View
@@ -6,6 +6,8 @@
#include "entities/camera.h"
#include "entities/light.h"
#include "entities/static_object.h"
+#include "entities/animated_object.h"
+#include "entities/landscape.h"
void deferred_renderer_init();
void deferred_renderer_finish();
@@ -24,6 +26,7 @@ void deferred_renderer_end();
void deferred_renderer_render_static(static_object* s);
void deferred_renderer_render_animated(animated_object* ao);
+void deferred_renderer_render_landscape(landscape* l);
void deferred_renderer_render_light(light* l);
void deferred_renderer_render_axis(matrix_4x4 world);
22 include/rendering/depth_mapper.h
View
@@ -0,0 +1,22 @@
+#ifndef shadow_mapper_h
+#define shadow_mapper_h
+
+#include "assets/texture.h"
+
+#include "entities/static_object.h"
+#include "entities/animated_object.h"
+#include "entities/landscape.h"
+#include "entities/camera.h"
+
+void depth_mapper_init(camera* c);
+void depth_mapper_finish();
+
+void depth_mapper_begin();
+void depth_mapper_end();
+void depth_mapper_render_static(static_object* s);
+void depth_mapper_render_animated(animated_object* ao);
+void depth_mapper_render_landscape(landscape* ls);
+
+texture* depth_mapper_depth_texture();
+
+#endif
3  include/forward_renderer.h → include/rendering/forward_renderer.h
View
@@ -24,8 +24,6 @@ void forward_renderer_set_color_correction(texture* t);
void forward_renderer_add_light(light* l);
void forward_renderer_remove_light(light* l);
-void forward_renderer_setup_camera();
-
void forward_renderer_begin();
void forward_renderer_end();
@@ -36,7 +34,6 @@ void forward_renderer_render_animated(animated_object* ao);
void forward_renderer_render_skeleton(skeleton* s);
void forward_renderer_render_axis(matrix_4x4 position);
void forward_renderer_render_light(light* l);
-void forward_renderer_render_collision_body(collision_body* cb);
void forward_renderer_render_landscape(landscape* ls);
#endif
0  include/shadow_mapper.h → include/rendering/shadow_mapper.h
View
File renamed without changes
BIN  libcorange.so
View
Binary file not shown
6 src/asset_manager.c
View
@@ -218,7 +218,7 @@ void load_folder(char* folder) {
struct dirent* ent;
if (dir == NULL) {
- error("Could not open directory %s.", folder_map);
+ error("Could not open directory %s to load.", folder_map);
}
while ((ent = readdir(dir)) != NULL) {
@@ -280,11 +280,13 @@ void unload_folder(char* folder) {
char* folder_map = asset_map_filename(folder);
+ debug("Unloading Folder: %s", folder_map);
+
DIR* dir = opendir(folder_map);
struct dirent* ent;
if (dir == NULL) {
- error("Could not open directory %s\n", folder_map);
+ error("Could not open directory %s to unload.\n", folder_map);
}
while ((ent = readdir(dir)) != NULL) {
76 src/deferred_renderer.c → src/rendering/deferred_renderer.c
View
@@ -11,9 +11,7 @@
#include "asset_manager.h"
#include "graphics_manager.h"
-#include "shadow_mapper.h"
-
-#include "deferred_renderer.h"
+#include "rendering/deferred_renderer.h"
static camera* CAMERA = NULL;
@@ -24,14 +22,14 @@ static float WORLD_MATRIX[16];
static float LIGHT_VIEW_MATRIX[16];
static float LIGHT_PROJ_MATRIX[16];
-static shader_program* PROGRAM;
+static shader_program* PROGRAM_STATIC;
static shader_program* PROGRAM_ANIMATED;
static shader_program* PROGRAM_CLEAR;
+static shader_program* PROGRAM_UI;
static shader_program* PROGRAM_SSAO;
-
-static shader_program* SCREEN_PROGRAM;
-static shader_program* SCREEN_TONEMAP;
-static shader_program* SCREEN_POST;
+static shader_program* PROGRAM_COMPOSE;
+static shader_program* PROGRAM_TONEMAP;
+static shader_program* PROGRAM_POST;
static int NORMAL;
static int TANGENT;
@@ -104,18 +102,20 @@ void deferred_renderer_init() {
ENVIRONMENT = asset_load_get("$CORANGE/resources/envmap.dds");
VIGNETTING = asset_load_get("$CORANGE/resources/vignetting.dds");
- PROGRAM = asset_load_get("$CORANGE/shaders/deferred.prog");
- PROGRAM_ANIMATED = asset_load_get("$CORANGE/shaders/deferred_animated.prog");
- PROGRAM_CLEAR = asset_load_get("$CORANGE/shaders/deferred_clear.prog");
- PROGRAM_SSAO = asset_load_get("$CORANGE/shaders/deferred_ssao.prog");
+ load_folder("$CORANGE/shaders/deferred/");
- SCREEN_TONEMAP = asset_load_get("$CORANGE/shaders/deferred_tonemap.prog");
- SCREEN_PROGRAM = asset_load_get("$CORANGE/shaders/deferred_screen.prog");
- SCREEN_POST = asset_load_get("$CORANGE/shaders/deferred_post.prog");
+ PROGRAM_STATIC = asset_get("$CORANGE/shaders/deferred/static.prog");
+ PROGRAM_ANIMATED = asset_get("$CORANGE/shaders/deferred/animated.prog");
+ PROGRAM_CLEAR = asset_get("$CORANGE/shaders/deferred/clear.prog");
+ PROGRAM_SSAO = asset_get("$CORANGE/shaders/deferred/ssao.prog");
+ PROGRAM_TONEMAP = asset_get("$CORANGE/shaders/deferred/tonemap.prog");
+ PROGRAM_COMPOSE = asset_get("$CORANGE/shaders/deferred/compose.prog");
+ PROGRAM_POST = asset_get("$CORANGE/shaders/deferred/post.prog");
+ PROGRAM_UI = asset_get("$CORANGE/shaders/deferred/ui.prog");
- NORMAL = glGetAttribLocation(shader_program_handle(PROGRAM), "normal");
- TANGENT = glGetAttribLocation(shader_program_handle(PROGRAM), "tangent");
- BINORMAL = glGetAttribLocation(shader_program_handle(PROGRAM), "binormal");
+ NORMAL = glGetAttribLocation(shader_program_handle(PROGRAM_STATIC), "normal");
+ TANGENT = glGetAttribLocation(shader_program_handle(PROGRAM_STATIC), "tangent");
+ BINORMAL = glGetAttribLocation(shader_program_handle(PROGRAM_STATIC), "binormal");
NORMAL_ANIMATED = glGetAttribLocation(shader_program_handle(PROGRAM_ANIMATED), "normal");
TANGENT_ANIMATED = glGetAttribLocation(shader_program_handle(PROGRAM_ANIMATED), "tangent");
@@ -267,6 +267,8 @@ void deferred_renderer_finish() {
glDeleteRenderbuffers(1, &ldr_buffer);
glDeleteTextures(1,&ldr_texture);
+ unload_folder("$CORANGE/shaders/deferred/");
+
}
void deferred_renderer_add_light(light* l) {
@@ -413,10 +415,10 @@ void deferred_renderer_begin() {
glClearDepth(1.0f);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
- glUseProgram(*PROGRAM_CLEAR);
+ glUseProgram(shader_program_handle(PROGRAM_CLEAR));
- GLint start = glGetUniformLocation(*PROGRAM_CLEAR, "start");
- GLint end = glGetUniformLocation(*PROGRAM_CLEAR, "end");
+ GLint start = glGetUniformLocation(shader_program_handle(PROGRAM_CLEAR), "start");
+ GLint end = glGetUniformLocation(shader_program_handle(PROGRAM_CLEAR), "end");
glUniform4f(start, 0.5, 0.5, 0.5, 1.0);
glUniform4f(end, 0.0, 0.0, 0.0, 1.0);
@@ -512,7 +514,7 @@ void deferred_renderer_end() {
glViewport(0, 0, graphics_viewport_width(), graphics_viewport_height());
- GLuint screen_handle = shader_program_handle(SCREEN_PROGRAM);
+ GLuint screen_handle = shader_program_handle(PROGRAM_COMPOSE);
glUseProgram(screen_handle);
glMatrixMode(GL_PROJECTION);
@@ -637,7 +639,7 @@ void deferred_renderer_end() {
glBindFramebuffer(GL_FRAMEBUFFER, ldr_fbo);
- GLuint screen_tonemap_handle = shader_program_handle(SCREEN_TONEMAP);
+ GLuint screen_tonemap_handle = shader_program_handle(PROGRAM_TONEMAP);
glUseProgram(screen_tonemap_handle);
glMatrixMode(GL_PROJECTION);
@@ -709,7 +711,7 @@ void deferred_renderer_end() {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
- GLuint screen_post_handle = shader_program_handle(SCREEN_POST);
+ GLuint screen_post_handle = shader_program_handle(PROGRAM_POST);
glUseProgram(screen_post_handle);
glMatrixMode(GL_PROJECTION);
@@ -788,10 +790,10 @@ void deferred_renderer_render_static(static_object* so) {
error("Renderable for static object is rigged!");
}
- GLuint program_handle = shader_program_handle(PROGRAM);
+ GLuint program_handle = shader_program_handle(PROGRAM_STATIC);
glUseProgram(program_handle);
- deferred_renderer_use_material(s->base, PROGRAM);
+ deferred_renderer_use_material(s->base, PROGRAM_STATIC);
GLsizei stride = sizeof(float) * 18;
@@ -925,8 +927,6 @@ void deferred_renderer_render_animated(animated_object* ao) {
}
-/* TODO: This could do with a proper shader attached to it */
-
void deferred_renderer_render_light(light* l) {
matrix_4x4 viewm = camera_view_matrix(CAMERA);
@@ -938,6 +938,8 @@ void deferred_renderer_render_light(light* l) {
light_pos = v4_div(light_pos, light_pos.w);
+ glUseProgram(shader_program_handle(PROGRAM_UI));
+
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
@@ -952,36 +954,32 @@ void deferred_renderer_render_light(light* l) {
float left = ((light_pos.x + 1) / 2) * graphics_viewport_width() - 8;
float right = ((light_pos.x + 1) / 2) * graphics_viewport_width() + 8;
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.25);
-
texture* lightbulb = asset_load_get("$CORANGE/ui/lightbulb.dds");
glActiveTexture(GL_TEXTURE0 + 0 );
glBindTexture(GL_TEXTURE_2D, texture_handle(lightbulb));
glEnable(GL_TEXTURE_2D);
+ glUniform1i(glGetUniformLocation(shader_program_handle(PROGRAM_UI), "diffuse"), 0);
+
+ glUniform1f(glGetUniformLocation(shader_program_handle(PROGRAM_UI), "alpha_test"), 0.5);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(left, top, -light_pos.z);
- glTexCoord2f(1.0f, 0.0f); glVertex3f(right, top, -light_pos.z);
- glTexCoord2f(1.0f, 1.0f); glVertex3f(right, bot, -light_pos.z);
glTexCoord2f(0.0f, 1.0f); glVertex3f(left, bot, -light_pos.z);
+ glTexCoord2f(1.0f, 1.0f); glVertex3f(right, bot, -light_pos.z);
+ glTexCoord2f(1.0f, 0.0f); glVertex3f(right, top, -light_pos.z);
glEnd();
glActiveTexture(GL_TEXTURE0 + 0 );
glDisable(GL_TEXTURE_2D);
- glDisable(GL_ALPHA_TEST);
- glDisable(GL_BLEND);
-
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
+ glUseProgram(0);
+
}
void deferred_renderer_render_axis(matrix_4x4 world) {
310 src/rendering/depth_mapper.c
View
@@ -0,0 +1,310 @@
+#include <math.h>
+
+#include "SDL/SDL.h"
+#include "SDL/SDL_opengl.h"
+#include "SDL/SDL_local.h"
+
+#include "error.h"
+
+#include "assets/shader.h"
+
+#include "graphics_manager.h"
+#include "asset_manager.h"
+
+#include "rendering/depth_mapper.h"
+
+static shader_program* depth_shader;
+static shader_program* depth_shader_animated;
+static texture* texture_ptr;
+
+static GLuint fbo;
+static GLuint depth_buffer;
+static GLuint depth_texture;
+
+static camera* CAMERA;
+
+static float proj_matrix[16];
+static float view_matrix[16];
+static float world_matrix[16];
+
+static int BONE_INDICIES;
+static int BONE_WEIGHTS;
+
+void depth_mapper_init(camera* c) {
+
+ CAMERA = c;
+
+ depth_shader = asset_load_get("$CORANGE/shaders/depth.prog");
+ depth_shader_animated = asset_load_get("$CORANGE/shaders/depth_animated.prog");
+
+ BONE_INDICIES = glGetAttribLocation(*depth_shader_animated, "bone_indicies");
+ BONE_WEIGHTS = glGetAttribLocation(*depth_shader_animated, "bone_weights");
+
+ glGenFramebuffers(1, &fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+ int width = graphics_viewport_width();
+ int height = graphics_viewport_height();
+
+ glGenRenderbuffers(1, &depth_buffer);
+ glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer);
+ glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
+ glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_buffer);
+
+ glGenTextures(1, &depth_texture);
+ glBindTexture(GL_TEXTURE_2D, depth_texture);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth_texture, 0);
+
+ texture_ptr = malloc(sizeof(texture));
+ *texture_ptr = depth_texture;
+
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+
+}
+
+void depth_mapper_finish() {
+
+ texture_delete(texture_ptr);
+
+ glDeleteFramebuffers(1, &fbo);
+
+ glDeleteRenderbuffers(1, &depth_buffer);
+ glDeleteTextures(1,&depth_texture);
+
+}
+
+void depth_mapper_begin() {
+
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+ glClearDepth(1.0f);
+ glClear(GL_DEPTH_BUFFER_BIT);
+
+ glViewport( 0, 0, graphics_viewport_width(), graphics_viewport_height());
+
+ matrix_4x4 viewm = camera_view_matrix(CAMERA);
+ matrix_4x4 projm = camera_proj_matrix(CAMERA, graphics_viewport_ratio());
+
+ m44_to_array(viewm, view_matrix);
+ m44_to_array(projm, proj_matrix);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadMatrixf(view_matrix);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadMatrixf(proj_matrix);
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_CULL_FACE);
+ glCullFace(GL_FRONT);
+
+}
+
+void depth_mapper_end() {
+
+ glCullFace(GL_BACK);
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+
+ glViewport( 0, 0, graphics_viewport_width(), graphics_viewport_height());
+
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+
+}
+
+void depth_mapper_render_static(static_object* s) {
+
+ matrix_4x4 r_world_matrix = m44_world( s->position, s->scale, s->rotation );
+ m44_to_array(r_world_matrix, world_matrix);
+
+ glUseProgram(*depth_shader);
+
+ GLint world_matrix_u = glGetUniformLocation(*depth_shader, "world_matrix");
+ glUniformMatrix4fv(world_matrix_u, 1, 0, world_matrix);
+
+ GLint proj_matrix_u = glGetUniformLocation(*depth_shader, "proj_matrix");
+ glUniformMatrix4fv(proj_matrix_u, 1, 0, proj_matrix);
+
+ GLint view_matrix_u = glGetUniformLocation(*depth_shader, "view_matrix");
+ glUniformMatrix4fv(view_matrix_u, 1, 0, view_matrix);
+
+ GLint alpha_test_u = glGetUniformLocation(*depth_shader, "alpha_test");
+ GLint diffuse_u = glGetUniformLocation(*depth_shader, "diffuse");
+
+ renderable* r = s->renderable;
+
+ for(int i=0; i < r->num_surfaces; i++) {
+
+ renderable_surface* s = r->surfaces[i];
+
+ if(s->is_rigged) {
+ error("Static Object is rigged!");
+ }
+
+ float* alpha_test = dictionary_get(s->base->properties, "alpha_test");
+ if (alpha_test != NULL) {
+ glUniform1f(alpha_test_u, *alpha_test);
+ } else {
+ glUniform1f(alpha_test_u, 0.0);
+ }
+
+ texture* diffuse_texture = dictionary_get(s->base->properties, "diffuse_texture");
+ if (diffuse_texture != NULL) {
+ glUniform1i(diffuse_u, 0);
+ glActiveTexture(GL_TEXTURE0 + 0);
+ glBindTexture(GL_TEXTURE_2D, *diffuse_texture);
+ glEnable(GL_TEXTURE_2D);
+ }
+
+ GLsizei stride = sizeof(float) * 18;
+
+ glBindBuffer(GL_ARRAY_BUFFER, s->vertex_vbo);
+
+ glVertexPointer(3, GL_FLOAT, stride, (void*)0);
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->triangle_vbo);
+ glDrawElements(GL_TRIANGLES, s->num_triangles * 3, GL_UNSIGNED_INT, (void*)0);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ if (diffuse_texture != NULL) {
+ glActiveTexture(GL_TEXTURE0 + 0);
+ glDisable(GL_TEXTURE_2D);
+ }
+
+ }
+
+ glUseProgram(0);
+
+}
+
+#define MAX_BONES 32
+static matrix_4x4 bone_matrices[MAX_BONES];
+static float bone_matrix_data[4 * 4 * MAX_BONES];
+
+void depth_mapper_render_animated(animated_object* ao) {
+
+ if (ao->skeleton->num_bones > MAX_BONES) {
+ error("animated object skeleton has too many bones (over %i)", MAX_BONES);
+ }
+
+ matrix_4x4 r_world_matrix = m44_world( ao->position, ao->scale, ao->rotation );
+ m44_to_array(r_world_matrix, world_matrix);
+
+ for(int i = 0; i < ao->skeleton->num_bones; i++) {
+ matrix_4x4 base, ani;
+ base = bone_transform(ao->skeleton->bones[i]);
+ ani = bone_transform(ao->pose->bones[i]);
+
+ bone_matrices[i] = m44_mul_m44(ani, m44_inverse(base));
+ m44_to_array(bone_matrices[i], bone_matrix_data + (i * 4 * 4));
+ }
+
+ glUseProgram(*depth_shader_animated);
+
+ GLint bone_world_matrices_u = glGetUniformLocation(*depth_shader_animated, "bone_world_matrices");
+ glUniformMatrix4fv(bone_world_matrices_u, ao->skeleton->num_bones, GL_FALSE, bone_matrix_data);
+
+ GLint bone_count_u = glGetUniformLocation(*depth_shader_animated, "bone_count");
+ glUniform1i(bone_count_u, ao->skeleton->num_bones);
+
+ GLint world_matrix_u = glGetUniformLocation(*depth_shader_animated, "world_matrix");
+ glUniformMatrix4fv(world_matrix_u, 1, 0, world_matrix);
+
+ GLint proj_matrix_u = glGetUniformLocation(*depth_shader_animated, "proj_matrix");
+ glUniformMatrix4fv(proj_matrix_u, 1, 0, proj_matrix);
+
+ GLint view_matrix_u = glGetUniformLocation(*depth_shader_animated, "view_matrix");
+ glUniformMatrix4fv(view_matrix_u, 1, 0, view_matrix);
+
+ renderable* r = ao->renderable;
+
+ for(int i = 0; i < r->num_surfaces; i++) {
+
+ renderable_surface* s = r->surfaces[i];
+ if(s->is_rigged) {
+
+ GLsizei stride = sizeof(float) * 24;
+
+ glBindBuffer(GL_ARRAY_BUFFER, s->vertex_vbo);
+
+ glVertexPointer(3, GL_FLOAT, stride, (void*)0);
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ glVertexAttribPointer(BONE_INDICIES, 3, GL_FLOAT, GL_FALSE, stride, (void*)(sizeof(float) * 18));
+ glEnableVertexAttribArray(BONE_INDICIES);
+
+ glVertexAttribPointer(BONE_WEIGHTS, 3, GL_FLOAT, GL_FALSE, stride, (void*)(sizeof(float) * 21));
+ glEnableVertexAttribArray(BONE_WEIGHTS);
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, s->triangle_vbo);
+ glDrawElements(GL_TRIANGLES, s->num_triangles * 3, GL_UNSIGNED_INT, (void*)0);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableVertexAttribArray(BONE_INDICIES);
+ glDisableVertexAttribArray(BONE_WEIGHTS);
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ } else {
+ error("animated object is not rigged");
+ }
+
+ }
+
+ glUseProgram(0);
+
+}
+
+void depth_mapper_render_landscape(landscape* ls) {
+
+ matrix_4x4 r_world_matrix = m44_world( ls->position, ls->scale, ls->rotation );
+ m44_to_array(r_world_matrix, world_matrix);
+
+ glUseProgram(*depth_shader);
+
+ GLint world_matrix_u = glGetUniformLocation(*depth_shader, "world_matrix");
+ glUniformMatrix4fv(world_matrix_u, 1, 0, world_matrix);
+
+ GLint proj_matrix_u = glGetUniformLocation(*depth_shader, "proj_matrix");
+ glUniformMatrix4fv(proj_matrix_u, 1, 0, proj_matrix);
+
+ GLint view_matrix_u = glGetUniformLocation(*depth_shader, "view_matrix");
+ glUniformMatrix4fv(view_matrix_u, 1, 0, view_matrix);
+
+ GLint alpha_test_u = glGetUniformLocation(*depth_shader, "alpha_test");
+ glUniform1f(alpha_test_u, 0.0);
+
+ for(int i = 0; i < ls->terrain->num_chunks; i++) {
+
+ terrain_chunk* tc = ls->terrain->chunks[i];
+
+ glBindBuffer(GL_ARRAY_BUFFER, tc->vertex_buffer);
+
+ glVertexPointer(3, GL_FLOAT, 0, (void*)0);
+ glEnableClientState(GL_VERTEX_ARRAY);
+
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, tc->index_buffers[NUM_TERRAIN_BUFFERS-2]);
+ glDrawElements(GL_TRIANGLES, tc->num_indicies[NUM_TERRAIN_BUFFERS-2], GL_UNSIGNED_INT, (void*)0);
+
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ }
+
+ glUseProgram(0);
+
+}
+
+texture* depth_mapper_depth_texture() {
+ return texture_ptr;
+}
99 src/forward_renderer.c → src/rendering/forward_renderer.c
View
@@ -15,14 +15,15 @@
#include "graphics_manager.h"
#include "asset_manager.h"
-#include "forward_renderer.h"
+#include "rendering/forward_renderer.h"
-static int use_shadows;
+static bool use_shadows;
static camera* CAMERA = NULL;
static light* SHADOW_LIGHT = NULL;
static texture* SHADOW_TEX = NULL;
+static texture* DEPTH_TEX = NULL;
static texture* COLOR_CORRECTION = NULL;
static texture* VIGNETTING = NULL;
@@ -89,8 +90,11 @@ void forward_renderer_init() {
COLOR_CORRECTION = asset_load_get("$CORANGE/resources/identity.lut");
VIGNETTING = asset_load_get("$CORANGE/resources/vignetting.dds");
GRADIENT = asset_load_get("$CORANGE/shaders/gradient.prog");
- SCREEN_TONEMAP = asset_load_get("$CORANGE/shaders/deferred_tonemap.prog");
- SCREEN_POST = asset_load_get("$CORANGE/shaders/deferred_post.prog");
+
+ load_folder("$CORANGE/shaders/forward/");
+
+ SCREEN_TONEMAP = asset_load_get("$CORANGE/shaders/forward/tonemap.prog");
+ SCREEN_POST = asset_load_get("$CORANGE/shaders/forward/post.prog");
glClearColor(0.2, 0.2, 0.2, 1.0f);
glClearDepth(1.0f);
@@ -154,6 +158,8 @@ void forward_renderer_finish() {
glDeleteRenderbuffers(1, &ldr_buffer);
glDeleteTextures(1,&ldr_texture);
+ unload_folder("$CORANGE/shaders/forward/");
+
}
void forward_renderer_add_light(light* l) {
@@ -199,14 +205,19 @@ void forward_renderer_set_shadow_light(light* l) {
void forward_renderer_set_shadow_texture(texture* t) {
if ( t == NULL) {
- use_shadows = 0;
+ use_shadows = false;
} else {
- use_shadows = 1;
+ use_shadows = true;
SHADOW_TEX = t;
}
}
+void forward_renderer_set_depth_texture(texture* t) {
+ DEPTH_TEX = t;
+}
+
+
void forward_renderer_set_color_correction(texture* t) {
COLOR_CORRECTION = t;
}
@@ -257,15 +268,6 @@ void forward_renderer_begin() {
render_gradient();
- forward_renderer_setup_camera();
-
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_CULL_FACE);
-
-}
-
-void forward_renderer_setup_camera() {
-
if (CAMERA == NULL) {
error("Camera not set yet!");
}
@@ -293,6 +295,9 @@ void forward_renderer_setup_camera() {
m44_to_array(lviewm, lview_matrix);
m44_to_array(lprojm, lproj_matrix);
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_CULL_FACE);
+
}
void forward_renderer_end() {
@@ -606,61 +611,6 @@ static void forward_renderer_disuse_material() {
}
-static void render_collision_mesh(collision_mesh* cm) {
-
- if (cm->is_leaf) {
-
- shader_program* collision_prog = asset_load_get("$CORANGE/shaders/collision_mesh.prog");
- GLuint collision_handle = shader_program_handle(collision_prog);
- glUseProgram(collision_handle);
-
- GLint color = glGetUniformLocation(collision_handle, "color");
- glUniform3f(color, 1, 1, 1);
-
- GLint world_matrix_u = glGetUniformLocation(collision_handle, "world_matrix");
- glUniformMatrix4fv(world_matrix_u, 1, 0, world_matrix);
-
- GLint proj_matrix_u = glGetUniformLocation(collision_handle, "proj_matrix");
- glUniformMatrix4fv(proj_matrix_u, 1, 0, proj_matrix);
-
- GLint view_matrix_u = glGetUniformLocation(collision_handle, "view_matrix");
- glUniformMatrix4fv(view_matrix_u, 1, 0, view_matrix);
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- glEnable(GL_POLYGON_OFFSET_FILL);
- glPolygonOffset(-1, 1.0);
-
- glVertexPointer(3, GL_FLOAT, 0, cm->verticies);
- glEnableClientState(GL_VERTEX_ARRAY);
-
- glDrawArrays(GL_TRIANGLES, 0, cm->num_verticies);
-
- glDisableClientState(GL_VERTEX_ARRAY);
-
- glDisable(GL_BLEND);
-
- glDisable(GL_POLYGON_OFFSET_FILL);
- glPolygonOffset(0, 0);
-
- glUseProgram(0);
-
- } else {
- render_collision_mesh(cm->front);
- render_collision_mesh(cm->back);
- }
-
-}
-
-void forward_renderer_render_collision_body(collision_body* cb) {
-
- if (cb->collision_type == collision_type_mesh) {
- render_collision_mesh(cb->collision_mesh);
- }
-
-}
-
void forward_renderer_render_static(static_object* so) {
matrix_4x4 r_world_matrix = m44_world( so->position, so->scale, so->rotation );
@@ -731,13 +681,6 @@ void forward_renderer_render_static(static_object* so) {
}
- /*
- if (so->collision_body != NULL) {
- bsp_counter = 0;
- render_bsp_mesh(so->collision_body->collision_mesh);
- }
- */
-
}
void forward_renderer_render_instance(instance_object* io) {
@@ -1114,7 +1057,7 @@ void forward_renderer_render_landscape(landscape* ls) {
matrix_4x4 r_world_matrix = m44_world(ls->position, ls->scale, ls->rotation);
m44_to_array(r_world_matrix, world_matrix);
- shader_program* terrain = asset_load_get("$CORANGE/shaders/terrain.prog");
+ shader_program* terrain = asset_get("$CORANGE/shaders/forward/terrain.prog");
GLuint terrain_handle = shader_program_handle(terrain);
glUseProgram(terrain_handle);
6 src/shadow_mapper.c → src/rendering/shadow_mapper.c
View
@@ -11,7 +11,7 @@
#include "graphics_manager.h"
#include "asset_manager.h"
-#include "shadow_mapper.h"
+#include "rendering/shadow_mapper.h"
static shader_program* depth_shader;
static shader_program* depth_shader_animated;
@@ -54,8 +54,8 @@ void shadow_mapper_init(light* l) {
glGenTextures(1, &depth_texture);
glBindTexture(GL_TEXTURE_2D, depth_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth_texture, 0);
Please sign in to comment.
Something went wrong with that request. Please try again.