]> git.tdb.fi Git - libs/gl.git/commitdiff
Refactor the builtin occluder shader
authorMikko Rasa <tdb@tdb.fi>
Sun, 10 Oct 2021 13:09:10 +0000 (16:09 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 10 Oct 2021 15:35:28 +0000 (18:35 +0300)
It's now stored in shaderlib and considered available for custom shaders
to import.

blender/io_mspgl/export_material.py
builtin_data/_occluder.glsl [deleted file]
demos/desertpillars/data/sphere_shadow.glsl
shaderlib/occluder.glsl [new file with mode: 0644]
source/render/occludedscene.cpp

index e7c1a50d49838523e3ae991d4c3c62952a7d4393..19c22d1fba598bb89449032e2cff2e950efe988a 100644 (file)
@@ -38,7 +38,7 @@ def create_technique_resource(material, resources):
                                shader += ".shader"
                        st.sub.append(Statement("shader", shader))
                else:
-                       st.sub.append(Statement("shader", "_occluder.glsl.shader"))
+                       st.sub.append(Statement("shader", "occluder.glsl.shader"))
                tech_res.statements.append(st)
 
        return tech_res
diff --git a/builtin_data/_occluder.glsl b/builtin_data/_occluder.glsl
deleted file mode 100644 (file)
index b8846c4..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-import msp_interface;
-#pragma MSP stage(vertex)
-void main()
-{
-       gl_Position = clip_eye_matrix*eye_world_matrix*world_obj_matrix*vertex;
-}
index 1064389c6b8ab286aa53c970a27020a9311b0b30..c76106ec0b42b581fd28cb7bd5aaea2154e018ff 100644 (file)
@@ -1,8 +1,2 @@
-import common;
+import occluder;
 import sphere_morph;
-
-#pragma MSP stage(fragment)
-void main()
-{
-       frag_color = vec4(1.0);
-}
diff --git a/shaderlib/occluder.glsl b/shaderlib/occluder.glsl
new file mode 100644 (file)
index 0000000..84f667a
--- /dev/null
@@ -0,0 +1,17 @@
+import msp_interface;
+
+#pragma MSP stage(vertex)
+virtual vec4 get_vertex_position()
+{
+       return vertex;
+}
+
+virtual mat4 get_vertex_transform()
+{
+       return world_obj_matrix;
+}
+
+void main()
+{
+       gl_Position = clip_eye_matrix*eye_world_matrix*get_vertex_transform()*get_vertex_position();
+}
index fd6ea5de13b7c4aebc4b8140145a4d21769c3682..edd45c47ac81f855f06e826c1daf95a6ee536524 100644 (file)
@@ -13,7 +13,7 @@ namespace GL {
 
 OccludedScene::OccludedScene():
        bounding_mesh(Resources::get_global().get<Mesh>("_occluder.mesh")),
-       bounding_shader(Resources::get_global().get<Program>("_occluder.glsl.shader")),
+       bounding_shader(Resources::get_global().get<Program>("occluder.glsl.shader")),
        queries(OCCLUSION_QUERY, 0)
 {
        no_color_write.write_mask = WRITE_NONE;