update SceneTree example, OnlyPosition3D.vert shader

This commit is contained in:
hyzboy 2020-01-20 20:32:09 +08:00
parent 71e9808492
commit c5b5486969
2 changed files with 18 additions and 5 deletions

View File

@ -17,6 +17,8 @@ constexpr uint32_t SCREEN_HEIGHT=128;
class TestApp:public CameraAppFramework class TestApp:public CameraAppFramework
{ {
Color4f color;
private: private:
double start_time; double start_time;
@ -27,6 +29,8 @@ private:
vulkan::Material * material =nullptr; vulkan::Material * material =nullptr;
vulkan::MaterialInstance * material_instance =nullptr; vulkan::MaterialInstance * material_instance =nullptr;
vulkan::Buffer * ubo_color =nullptr;
vulkan::Renderable * renderable_object =nullptr; vulkan::Renderable * renderable_object =nullptr;
vulkan::Pipeline * pipeline_line =nullptr; vulkan::Pipeline * pipeline_line =nullptr;
@ -67,6 +71,11 @@ private:
{ {
if(!InitCameraUBO(material_instance,"world")) if(!InitCameraUBO(material_instance,"world"))
return(false); 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(); material_instance->Update();
return(true); return(true);

View File

@ -2,24 +2,28 @@
layout(location = 0) in vec3 Vertex; layout(location = 0) in vec3 Vertex;
layout(binding = 0) uniform WorldMatrix layout(binding=0) uniform WorldMatrix // hgl/math/Math.h
{ {
mat4 ortho; mat4 ortho;
mat4 projection; mat4 projection;
mat4 inverse_projection;
mat4 modelview; mat4 modelview;
mat4 inverse_modelview;
mat4 mvp; mat4 mvp;
mat4 inverse_mvp;
vec4 view_pos; vec4 view_pos;
vec2 resolution;
} world; } world;
layout(push_constant) uniform Consts { layout(push_constant) uniform Consts {
mat4 local_to_world; mat4 local_to_world;
} pc; } pc;
layout(location = 0) out vec4 FragmentColor;
void main() void main()
{ {
FragmentColor=vec4(1.0);
gl_Position=vec4(Vertex,1.0)*(pc.local_to_world*world.mvp); gl_Position=vec4(Vertex,1.0)*(pc.local_to_world*world.mvp);
} }