From 8323eb754769cb6db7e02f4226cc9eedc5e614cf Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 10 Oct 2021 16:09:10 +0300 Subject: [PATCH] Refactor the builtin occluder shader It's now stored in shaderlib and considered available for custom shaders to import. --- blender/io_mspgl/export_material.py | 2 +- builtin_data/_occluder.glsl | 6 ------ demos/desertpillars/data/sphere_shadow.glsl | 8 +------- shaderlib/occluder.glsl | 17 +++++++++++++++++ source/render/occludedscene.cpp | 2 +- 5 files changed, 20 insertions(+), 15 deletions(-) delete mode 100644 builtin_data/_occluder.glsl create mode 100644 shaderlib/occluder.glsl diff --git a/blender/io_mspgl/export_material.py b/blender/io_mspgl/export_material.py index e7c1a50d..19c22d1f 100644 --- a/blender/io_mspgl/export_material.py +++ b/blender/io_mspgl/export_material.py @@ -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 index b8846c47..00000000 --- a/builtin_data/_occluder.glsl +++ /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; -} diff --git a/demos/desertpillars/data/sphere_shadow.glsl b/demos/desertpillars/data/sphere_shadow.glsl index 1064389c..c76106ec 100644 --- a/demos/desertpillars/data/sphere_shadow.glsl +++ b/demos/desertpillars/data/sphere_shadow.glsl @@ -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 index 00000000..84f667a8 --- /dev/null +++ b/shaderlib/occluder.glsl @@ -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(); +} diff --git a/source/render/occludedscene.cpp b/source/render/occludedscene.cpp index fd6ea5de..edd45c47 100644 --- a/source/render/occludedscene.cpp +++ b/source/render/occludedscene.cpp @@ -13,7 +13,7 @@ namespace GL { OccludedScene::OccludedScene(): bounding_mesh(Resources::get_global().get("_occluder.mesh")), - bounding_shader(Resources::get_global().get("_occluder.glsl.shader")), + bounding_shader(Resources::get_global().get("occluder.glsl.shader")), queries(OCCLUSION_QUERY, 0) { no_color_write.write_mask = WRITE_NONE; -- 2.45.2