adjust & layout codes.
This commit is contained in:
parent
1b5d4aabb0
commit
09e9e71d59
@ -1 +1 @@
|
|||||||
Subproject commit 8d091ebfb0fb02c320789357f66bf84d1c80682f
|
Subproject commit 3b769e692b3e2dc43dba9c682f7e899d2115eac7
|
@ -1,43 +0,0 @@
|
|||||||
#Material
|
|
||||||
Name Billboard2DWay
|
|
||||||
Base Std3D/Billboard
|
|
||||||
|
|
||||||
#VertexInput
|
|
||||||
vec2 TexCoord
|
|
||||||
|
|
||||||
#Vertex
|
|
||||||
Output
|
|
||||||
{
|
|
||||||
vec2 TexCoord
|
|
||||||
}
|
|
||||||
|
|
||||||
Code
|
|
||||||
{
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
Output.TexCoord=TexCoord;
|
|
||||||
|
|
||||||
vec4 pos=GetPosition3D()
|
|
||||||
+camera.camera_right*TexCoord.x*Billboard.Size.x
|
|
||||||
+camera.camera_up *TexCoord.y*Billboard.Size.y;
|
|
||||||
|
|
||||||
gl_Position=GetPosition3D();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#Fragment
|
|
||||||
|
|
||||||
sampler2D TextureBaseColor
|
|
||||||
|
|
||||||
Output
|
|
||||||
{
|
|
||||||
vec4 FragColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
Code
|
|
||||||
{
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
FragColor=texture(TextureBaseColor,Input.TexCoord);
|
|
||||||
}
|
|
||||||
}
|
|
82
ShaderLibrary/Std3D/Billboard/FixedSize.mtl
Normal file
82
ShaderLibrary/Std3D/Billboard/FixedSize.mtl
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#Material
|
||||||
|
Name BillboardFixedSize
|
||||||
|
Base Std3D/Billboard
|
||||||
|
|
||||||
|
#VertexInput
|
||||||
|
vec2 TexCoord
|
||||||
|
|
||||||
|
#MaterialInstance
|
||||||
|
Length 8
|
||||||
|
Stage Vertex
|
||||||
|
|
||||||
|
Code
|
||||||
|
{
|
||||||
|
uvec2 BillboardSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
#Vertex
|
||||||
|
Output
|
||||||
|
{
|
||||||
|
vec2 BillboardSize
|
||||||
|
}
|
||||||
|
|
||||||
|
Code
|
||||||
|
{
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
MaterialInstance mi=GetMI();
|
||||||
|
|
||||||
|
Output.BillboardSize=mi.BillboardSize/viewport.canvas_resolution;
|
||||||
|
|
||||||
|
gl_Position=GetPosition3D();
|
||||||
|
gl_Position/=gl_Position.w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Geometry
|
||||||
|
Output
|
||||||
|
{
|
||||||
|
vec2 TexCoord
|
||||||
|
}
|
||||||
|
|
||||||
|
Code
|
||||||
|
{
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
const vec2 BillboardVertex[4]=vec2[]
|
||||||
|
(
|
||||||
|
vec2(-0.5,-0.5),
|
||||||
|
vec2(-0.5, 0.5),
|
||||||
|
vec2( 0.5,-0.5),
|
||||||
|
vec2( 0.5, 0.5)
|
||||||
|
);
|
||||||
|
|
||||||
|
for(int i=0;i<4;i++)
|
||||||
|
{
|
||||||
|
gl_Position=gl_in[0].gl_Position;
|
||||||
|
gl_Position.xy+=BillboardVertex[i]*Input[0].BillboardSize;
|
||||||
|
|
||||||
|
Output.TexCoord=BillboardVertex[i]+vec2(0.5);
|
||||||
|
|
||||||
|
EmitVertex();
|
||||||
|
}
|
||||||
|
EndPrimitive();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Fragment
|
||||||
|
|
||||||
|
sampler2D TextureBaseColor
|
||||||
|
|
||||||
|
Output
|
||||||
|
{
|
||||||
|
vec4 FragColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
Code
|
||||||
|
{
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragColor=texture(TextureBaseColor,Input.TexCoord);
|
||||||
|
}
|
||||||
|
}
|
@ -81,7 +81,7 @@ Code
|
|||||||
|
|
||||||
#ifndef HAVE_SPECULAR
|
#ifndef HAVE_SPECULAR
|
||||||
FragColor=vec4(direct_color,1.0);
|
FragColor=vec4(direct_color,1.0);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
vec3 spec_color=vec3(0.0);
|
vec3 spec_color=vec3(0.0);
|
||||||
|
|
||||||
|
@ -129,8 +129,8 @@ private:
|
|||||||
|
|
||||||
struct PlaneGridCreateInfo pgci;
|
struct PlaneGridCreateInfo pgci;
|
||||||
|
|
||||||
pgci.grid_size.Set(32,32);
|
pgci.grid_size.Set(500,500);
|
||||||
pgci.sub_count.Set(8,8);
|
pgci.sub_count.Set(5,5);
|
||||||
|
|
||||||
pgci.lum=0.5;
|
pgci.lum=0.5;
|
||||||
pgci.sub_lum=0.75;
|
pgci.sub_lum=0.75;
|
||||||
@ -203,5 +203,5 @@ public:
|
|||||||
|
|
||||||
int main(int,char **)
|
int main(int,char **)
|
||||||
{
|
{
|
||||||
return RunApp<TestApp>(1280,720);
|
return RunApp<TestApp>(1920,1080);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ namespace
|
|||||||
const int shader_count=shader_maps->GetCount();
|
const int shader_count=shader_maps->GetCount();
|
||||||
shader_stage_list.SetCount(shader_count);
|
shader_stage_list.SetCount(shader_count);
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo *p=shader_stage_list.GetData();
|
VkPipelineShaderStageCreateInfo *p=shader_stage_list.GetData();
|
||||||
|
|
||||||
auto **itp=shader_maps->GetDataList();
|
auto **itp=shader_maps->GetDataList();
|
||||||
for(int i=0;i<shader_count;i++)
|
for(int i=0;i<shader_count;i++)
|
||||||
|
@ -39,8 +39,8 @@ void main()
|
|||||||
}
|
}
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
})";
|
})";
|
||||||
|
|
||||||
constexpr const char fs_main[]=R"(
|
constexpr const char fs_main[]=R"(
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor=texture(TextureBaseColor,Input.TexCoord);
|
FragColor=texture(TextureBaseColor,Input.TexCoord);
|
||||||
@ -90,7 +90,7 @@ MaterialCreateInfo *CreateBillboard2DDynamic(mtl::BillboardMaterialCreateConfig
|
|||||||
{
|
{
|
||||||
if(!cfg)
|
if(!cfg)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
cfg->shader_stage_flag_bit|=VK_SHADER_STAGE_GEOMETRY_BIT;
|
cfg->shader_stage_flag_bit|=VK_SHADER_STAGE_GEOMETRY_BIT;
|
||||||
|
|
||||||
cfg->local_to_world=true;
|
cfg->local_to_world=true;
|
||||||
|
@ -40,8 +40,8 @@ void main()
|
|||||||
}
|
}
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
})";
|
})";
|
||||||
|
|
||||||
constexpr const char fs_main[]=R"(
|
constexpr const char fs_main[]=R"(
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor=texture(TextureBaseColor,Input.TexCoord);
|
FragColor=texture(TextureBaseColor,Input.TexCoord);
|
||||||
@ -87,9 +87,9 @@ void main()
|
|||||||
|
|
||||||
bool EndCustomShader() override
|
bool EndCustomShader() override
|
||||||
{
|
{
|
||||||
mci->SetMaterialInstance( mi_codes, //材质实例glsl代码
|
mci->SetMaterialInstance(mi_codes, //材质实例glsl代码
|
||||||
mi_bytes, //材质实例数据大小
|
mi_bytes, //材质实例数据大小
|
||||||
VK_SHADER_STAGE_VERTEX_BIT); //只在Vertex Shader中使用材质实例最终数据
|
VK_SHADER_STAGE_VERTEX_BIT); //只在Vertex Shader中使用材质实例最终数据
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ MaterialCreateInfo *CreateBillboard2DFixedSize(mtl::BillboardMaterialCreateConfi
|
|||||||
{
|
{
|
||||||
if(!cfg)
|
if(!cfg)
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
cfg->shader_stage_flag_bit|=VK_SHADER_STAGE_GEOMETRY_BIT;
|
cfg->shader_stage_flag_bit|=VK_SHADER_STAGE_GEOMETRY_BIT;
|
||||||
|
|
||||||
cfg->local_to_world=true;
|
cfg->local_to_world=true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user