fixed 3 samples that are texture_quad, texture_rect and texture_rect_array

This commit is contained in:
hyzboy 2024-05-31 23:17:08 +08:00
parent c780662ff6
commit aa853fbdfb
5 changed files with 32 additions and 22 deletions

View File

@ -23,7 +23,7 @@ Code
#Fragment #Fragment
sampler2D TextureColor sampler2D TextureBaseColor
Output Output
{ {
@ -34,6 +34,6 @@ Code
{ {
void main() void main()
{ {
FragColor=texture(TextureColor,Input.TexCoord); FragColor=texture(TextureBaseColor,Input.TexCoord);
} }
} }

View File

@ -52,7 +52,7 @@ Code
#Fragment #Fragment
sampler2D TextureColor sampler2D TextureBaseColor
Output Output
{ {
@ -63,6 +63,6 @@ Code
{ {
void main() void main()
{ {
FragColor=texture(TextureColor,Input.TexCoord); FragColor=texture(TextureBaseColor,Input.TexCoord);
} }
} }

View File

@ -4,7 +4,7 @@
#include<hgl/graph/VKTexture.h> #include<hgl/graph/VKTexture.h>
#include<hgl/graph/VKSampler.h> #include<hgl/graph/VKSampler.h>
#include<hgl/graph/VKInlinePipeline.h> #include<hgl/graph/VKInlinePipeline.h>
#include<hgl/graph/VKRenderablePrimitiveCreater.h> #include<hgl/graph/PrimitiveCreater.h>
#include<hgl/graph/mtl/Material2DCreateConfig.h> #include<hgl/graph/mtl/Material2DCreateConfig.h>
#include<hgl/math/Math.h> #include<hgl/math/Math.h>
@ -73,7 +73,7 @@ private:
sampler=db->CreateSampler(); sampler=db->CreateSampler();
if(!material->BindImageSampler( DescriptorSetType::PerMaterial, ///<描述符合集 if(!material->BindImageSampler( DescriptorSetType::PerMaterial, ///<描述符合集
mtl::SamplerName::Color, ///<采样器名称 mtl::SamplerName::BaseColor, ///<采样器名称
texture, ///<纹理 texture, ///<纹理
sampler)) ///<采样器 sampler)) ///<采样器
return(false); return(false);
@ -85,12 +85,14 @@ private:
bool InitVBO() bool InitVBO()
{ {
RenderablePrimitiveCreater rpc(db,"Quad",VERTEX_COUNT); PrimitiveCreater rpc(device,material_instance->GetVIL());
if(!rpc.SetVAB(VAN::Position, VF_V2F, position_data))return(false); rpc.Init("Quad",VERTEX_COUNT);
if(!rpc.SetVAB(VAN::TexCoord, VF_V2F, tex_coord_data))return(false);
render_obj=rpc.Create(material_instance,pipeline); if(!rpc.WriteVAB(VAN::Position, VF_V2F, position_data))return(false);
if(!rpc.WriteVAB(VAN::TexCoord, VF_V2F, tex_coord_data))return(false);
render_obj=db->CreateRenderable(&rpc,material_instance,pipeline);
return(render_obj); return(render_obj);
} }

View File

@ -4,7 +4,7 @@
#include<hgl/graph/VKTexture.h> #include<hgl/graph/VKTexture.h>
#include<hgl/graph/VKSampler.h> #include<hgl/graph/VKSampler.h>
#include<hgl/graph/VKInlinePipeline.h> #include<hgl/graph/VKInlinePipeline.h>
#include<hgl/graph/VKRenderablePrimitiveCreater.h> #include<hgl/graph/PrimitiveCreater.h>
#include<hgl/graph/mtl/Material2DCreateConfig.h> #include<hgl/graph/mtl/Material2DCreateConfig.h>
#include<hgl/math/Math.h> #include<hgl/math/Math.h>
@ -69,7 +69,7 @@ private:
sampler=db->CreateSampler(); sampler=db->CreateSampler();
if(!material->BindImageSampler( DescriptorSetType::PerMaterial, ///<描述符合集 if(!material->BindImageSampler( DescriptorSetType::PerMaterial, ///<描述符合集
mtl::SamplerName::Color, ///<采样器名称 mtl::SamplerName::BaseColor, ///<采样器名称
texture, ///<纹理 texture, ///<纹理
sampler)) ///<采样器 sampler)) ///<采样器
return(false); return(false);
@ -81,12 +81,14 @@ private:
bool InitVBO() bool InitVBO()
{ {
RenderablePrimitiveCreater rpc(db,"Rectangle",1); PrimitiveCreater rpc(device,material_instance->GetVIL());
if(!rpc.SetVAB(VAN::Position,VF_V4F,position_data))return(false); rpc.Init("Rectangle",1);
if(!rpc.SetVAB(VAN::TexCoord,VF_V4F,tex_coord_data))return(false);
render_obj=rpc.Create(material_instance,pipeline); if(!rpc.WriteVAB(VAN::Position,VF_V4F,position_data))return(false);
if(!rpc.WriteVAB(VAN::TexCoord,VF_V4F,tex_coord_data))return(false);
render_obj=db->CreateRenderable(&rpc,material_instance,pipeline);
return(render_obj); return(render_obj);
} }

View File

@ -4,7 +4,7 @@
#include<hgl/graph/VKTexture.h> #include<hgl/graph/VKTexture.h>
#include<hgl/graph/VKSampler.h> #include<hgl/graph/VKSampler.h>
#include<hgl/graph/VKInlinePipeline.h> #include<hgl/graph/VKInlinePipeline.h>
#include<hgl/graph/VKRenderablePrimitiveCreater.h> #include<hgl/graph/PrimitiveCreater.h>
#include<hgl/graph/mtl/Material2DCreateConfig.h> #include<hgl/graph/mtl/Material2DCreateConfig.h>
#include<hgl/math/Math.h> #include<hgl/math/Math.h>
#include<hgl/filesystem/Filename.h> #include<hgl/filesystem/Filename.h>
@ -56,6 +56,7 @@ private:
Pipeline * pipeline =nullptr; Pipeline * pipeline =nullptr;
DeviceBuffer * tex_id_ubo =nullptr; DeviceBuffer * tex_id_ubo =nullptr;
Primitive * prim_rectangle =nullptr;
struct struct
{ {
@ -108,7 +109,7 @@ private:
sampler=db->CreateSampler(); sampler=db->CreateSampler();
if(!material->BindImageSampler( DescriptorSetType::PerMaterial, ///<描述符合集 if(!material->BindImageSampler( DescriptorSetType::PerMaterial, ///<描述符合集
mtl::SamplerName::Color, ///<采样器名称 mtl::SamplerName::BaseColor, ///<采样器名称
texture, ///<纹理 texture, ///<纹理
sampler)) ///<采样器 sampler)) ///<采样器
return(false); return(false);
@ -128,18 +129,22 @@ private:
bool InitVBOAndRenderList() bool InitVBOAndRenderList()
{ {
RenderablePrimitiveCreater rpc(db,"Rectangle",1); PrimitiveCreater rpc(device,material->GetDefaultVIL());
rpc.Init("Rectangle",1);
position_data[2]=1.0f/float(TexCount); position_data[2]=1.0f/float(TexCount);
if(!rpc.SetVAB(VAN::Position,VF_V4F,position_data))return(false); if(!rpc.WriteVAB(VAN::Position,VF_V4F,position_data))return(false);
if(!rpc.SetVAB(VAN::TexCoord,VF_V4F,tex_coord_data))return(false); if(!rpc.WriteVAB(VAN::TexCoord,VF_V4F,tex_coord_data))return(false);
prim_rectangle=rpc.Create();
Vector3f offset(1.0f/float(TexCount),0,0); Vector3f offset(1.0f/float(TexCount),0,0);
for(uint32_t i=0;i<TexCount;i++) for(uint32_t i=0;i<TexCount;i++)
{ {
render_obj[i].r=rpc.Create(render_obj[i].mi,pipeline); render_obj[i].r=db->CreateRenderable(prim_rectangle,render_obj[i].mi,pipeline);
if(!render_obj[i].r) if(!render_obj[i].r)
return(false); return(false);
@ -160,6 +165,7 @@ public:
~TestApp() ~TestApp()
{ {
SAFE_CLEAR(prim_rectangle);
SAFE_CLEAR(render_list); SAFE_CLEAR(render_list);
} }