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
{
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;
@ -68,6 +72,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);
}

View File

@ -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);
}