增加3D shader
This commit is contained in:
parent
35ebbf9fb6
commit
9bf934ed5c
@ -52,6 +52,16 @@ class Renderable;
|
||||
|
||||
using CharPointerList=hgl::List<const char *>;
|
||||
|
||||
enum class ShaderType
|
||||
{
|
||||
Vertex =VK_SHADER_STAGE_VERTEX_BIT,
|
||||
TessControl =VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
|
||||
TessEval =VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
|
||||
Geometry =VK_SHADER_STAGE_GEOMETRY_BIT,
|
||||
Fragment =VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
Compute =VK_SHADER_STAGE_COMPUTE_BIT
|
||||
};//
|
||||
|
||||
#ifdef _DEBUG
|
||||
bool CheckStrideBytesByFormat(); ///<检验所有数据类型长度数组是否符合规则
|
||||
#endif//_DEBUG
|
||||
|
@ -90,7 +90,10 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
void PushConstants(VkShaderStageFlagBits stage_flags,uint32_t offset,uint32_t size,const void *pValues){vkCmdPushConstants(cmd_buf,pipeline_layout,stage_flags,offset,size,pValues);}
|
||||
void PushConstants(ShaderType shader_type,uint32_t offset,uint32_t size,const void *pValues)
|
||||
{
|
||||
vkCmdPushConstants(cmd_buf,pipeline_layout,(VkShaderStageFlagBits)shader_type,offset,size,pValues);
|
||||
}
|
||||
|
||||
bool Bind(Renderable *);
|
||||
|
||||
|
@ -3,10 +3,18 @@
|
||||
layout(location = 0) in vec3 Vertex;
|
||||
layout(location = 1) in vec3 Color;
|
||||
|
||||
layout(binding = 0) uniform WorldConfig
|
||||
layout(binding = 0) uniform SunLightConfig
|
||||
{
|
||||
vec4 color;
|
||||
vec4 direction;
|
||||
} sun;
|
||||
|
||||
layout(push_constant) uniform Consts {
|
||||
mat4 projection;
|
||||
mat4 modelview;
|
||||
mat4 mvp;
|
||||
} world;
|
||||
mat3 normal;
|
||||
} matrix;
|
||||
|
||||
layout(location = 0) out vec4 FragmentColor;
|
||||
|
||||
|
@ -3,15 +3,12 @@
|
||||
layout(location = 0) in vec3 Vertex;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
|
||||
layout(binding = 0) uniform WorldConfig
|
||||
{
|
||||
layout(push_constant) uniform MatrixConstants {
|
||||
mat4 projection;
|
||||
mat4 modelview;
|
||||
mat4 mvp;
|
||||
} world;
|
||||
|
||||
layout(push_constant) uniform SkyLightConsts {
|
||||
vec4 sun_color;
|
||||
vec4 sun_direction;
|
||||
} skylight;
|
||||
mat3 normal;
|
||||
}matrix;
|
||||
|
||||
layout(location = 0) out vec4 FragmentColor;
|
||||
layout(location = 1) out vec3 FragmentNormal;
|
||||
@ -21,5 +18,5 @@ void main()
|
||||
FragmentColor=vec4(Color,1.0);
|
||||
FragmentNormal=Normal;
|
||||
|
||||
gl_Position=vec4(Vertex,1.0)*world.mvp;
|
||||
gl_Position=vec4(Vertex,1.0)*matrix.mvp;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ Instance *CreateInstance(const UTF8String &app_name)
|
||||
"VK_LAYER_LUNARG_standard_validation",
|
||||
"VK_LAYER_LUNARG_parameter_validation",
|
||||
// "VK_LAYER_LUNARG_vktrace",
|
||||
// "VK_LAYER_RENDERDOC_Capture",
|
||||
"VK_LAYER_RENDERDOC_Capture",
|
||||
|
||||
// "VK_LAYER_KHRONOS_validation",
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user