diff --git a/example/Vulkan/SceneTree.cpp b/example/Vulkan/SceneTree.cpp index f1393083..9a512743 100644 --- a/example/Vulkan/SceneTree.cpp +++ b/example/Vulkan/SceneTree.cpp @@ -17,6 +17,8 @@ constexpr uint32_t SCREEN_HEIGHT=128; class TestApp:public CameraAppFramework { + Color4f color; + private: double start_time; @@ -27,6 +29,8 @@ private: vulkan::Material * material =nullptr; vulkan::MaterialInstance * material_instance =nullptr; + vulkan::Buffer * ubo_color =nullptr; + vulkan::Renderable * renderable_object =nullptr; vulkan::Pipeline * pipeline_line =nullptr; @@ -67,6 +71,11 @@ private: { if(!InitCameraUBO(material_instance,"world")) return(false); + + color.Set(1,1,0,1); + ubo_color=device->CreateUBO(sizeof(Color4f),&color); + + material_instance->BindUBO("color_material",ubo_color); material_instance->Update(); return(true); diff --git a/res/shader/OnlyPosition3D.vert b/res/shader/OnlyPosition3D.vert index bc46aa1f..c6d3b259 100644 --- a/res/shader/OnlyPosition3D.vert +++ b/res/shader/OnlyPosition3D.vert @@ -2,24 +2,28 @@ layout(location = 0) in vec3 Vertex; -layout(binding = 0) uniform WorldMatrix +layout(binding=0) uniform WorldMatrix // hgl/math/Math.h { mat4 ortho; + mat4 projection; + mat4 inverse_projection; + mat4 modelview; + mat4 inverse_modelview; + mat4 mvp; + mat4 inverse_mvp; + vec4 view_pos; + vec2 resolution; } world; layout(push_constant) uniform Consts { mat4 local_to_world; } pc; -layout(location = 0) out vec4 FragmentColor; - void main() { - FragmentColor=vec4(1.0); - gl_Position=vec4(Vertex,1.0)*(pc.local_to_world*world.mvp); }