增加部分资源
This commit is contained in:
parent
9f8171f8c0
commit
2e42bc0d0f
@ -14,6 +14,10 @@
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
Texture2D *LoadTGATexture(const OSString &filename,Device *device);
|
||||
VK_NAMESPACE_END
|
||||
|
||||
constexpr uint32_t GBUFFER_WIDTH=1024;
|
||||
constexpr uint32_t GBUFFER_HEIGHT=1024;
|
||||
|
||||
@ -76,7 +80,14 @@ private:
|
||||
SubpassParam sp_gbuffer;
|
||||
SubpassParam sp_composition;
|
||||
|
||||
vulkan::Renderable *ro_sphere;
|
||||
vulkan::Renderable * ro_cube;
|
||||
|
||||
vulkan::Sampler * sampler;
|
||||
|
||||
struct
|
||||
{
|
||||
vulkan::Texture2D *color,*normal,*specular;
|
||||
}texture;
|
||||
|
||||
private:
|
||||
|
||||
@ -224,12 +235,18 @@ private:
|
||||
if(!InitGBufferPipeline(&sp_gbuffer))return(false);
|
||||
if(!InitCompositionPipeline(&sp_composition))return(false);
|
||||
|
||||
texture.color =vulkan::LoadTGATexture(OS_TEXT("cardboardPlainStain.tga"),device);
|
||||
texture.normal =vulkan::LoadTGATexture(OS_TEXT("APOCWALL029_NRM.tga"),device);
|
||||
texture.specular=vulkan::LoadTGATexture(OS_TEXT("APOCWALL029_SPEC.tga"),device);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void CreateRenderObject(vulkan::Material *mtl)
|
||||
{
|
||||
ro_sphere=CreateRenderableSphere(db,mtl,128);
|
||||
struct CubeCreateInfo cci;
|
||||
|
||||
ro_cube=CreateRenderableCube(db,mtl,&cci);
|
||||
}
|
||||
|
||||
bool InitUBO(SubpassParam *sp)
|
||||
@ -248,7 +265,7 @@ private:
|
||||
|
||||
CreateRenderObject(sp->material);
|
||||
|
||||
render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_sphere),scale(1000));
|
||||
render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_cube),scale(1000));
|
||||
|
||||
render_root.RefreshMatrix();
|
||||
render_root.ExpendToList(&render_list);
|
||||
|
BIN
res/image/APOCWALL029_NRM.tga
Normal file
BIN
res/image/APOCWALL029_NRM.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 768 KiB |
BIN
res/image/APOCWALL029_SPEC.tga
Normal file
BIN
res/image/APOCWALL029_SPEC.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 768 KiB |
Binary file not shown.
Before Width: | Height: | Size: 90 KiB |
BIN
res/image/brdflut.tga
Normal file
BIN
res/image/brdflut.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 768 KiB |
BIN
res/image/cardboardPlainStain.tga
Normal file
BIN
res/image/cardboardPlainStain.tga
Normal file
Binary file not shown.
After Width: | Height: | Size: 768 KiB |
@ -121,7 +121,7 @@ vec3 atmosphere(vec3 r, vec3 r0, vec3 pSun, float iSun, float rPlanet, float rAt
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 nrd=vec3(.x,-FragmentVertex.y,FragmentVertex.z); //vulkan coord to opengl(shader from opengl sample)
|
||||
vec3 nrd=vec3(FragmentVertex.x,-FragmentVertex.y,FragmentVertex.z); //vulkan coord to opengl(shader from opengl sample)
|
||||
|
||||
vec3 color=atmosphere(
|
||||
nrd, // normalized ray direction
|
||||
|
27
res/shader/gbuffer_opaque.frag
Normal file
27
res/shader/gbuffer_opaque.frag
Normal file
@ -0,0 +1,27 @@
|
||||
#version 450
|
||||
|
||||
layout (binding = 1) uniform sampler2D TextureColor;
|
||||
layout (binding = 2) uniform sampler2D TextureNormal;
|
||||
|
||||
layout(location = 0) in vec3 FragmentNormal;
|
||||
layout(location = 1) in vec3 FragmentTangent;
|
||||
layout(location = 2) in vec3 FragmentPosition;
|
||||
layout(location = 3) in vec2 FragmentTexCoord;
|
||||
|
||||
layout (location = 0) out vec4 outPosition;
|
||||
layout (location = 1) out vec4 outNormal;
|
||||
layout (location = 2) out vec4 outColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
outPosition=vec4(FragmentPosition,1.0);
|
||||
|
||||
vec3 N = normalize(FragmentNormal);
|
||||
vec3 T = normalize(FragmentTangent);
|
||||
vec3 B = cross(N,T);
|
||||
mat3 TBN = mat3(T,B,N);
|
||||
vec3 tnorm = TBN * normalize(texture(TextureNormal,FragmentTexCoord).xyz*2.0-vec3(1.0));
|
||||
|
||||
outNormal=vec4(tnorm,1.0);
|
||||
outColor=texture(TextureColor,FragmentTexCoord);
|
||||
}
|
38
res/shader/gbuffer_opaque.vert
Normal file
38
res/shader/gbuffer_opaque.vert
Normal file
@ -0,0 +1,38 @@
|
||||
#version 450 core
|
||||
|
||||
layout(location = 0) in vec3 Vertex;
|
||||
layout(location = 1) in vec2 TexCoord;
|
||||
layout(location = 2) in vec3 Normal;
|
||||
layout(location = 3) in vec3 Tangent;
|
||||
|
||||
layout(binding = 0) uniform WorldMatrix
|
||||
{
|
||||
mat4 two_dim;
|
||||
mat4 projection;
|
||||
mat4 modelview;
|
||||
mat4 mvp;
|
||||
} world;
|
||||
|
||||
layout(push_constant) uniform Consts {
|
||||
mat4 local_to_world;
|
||||
} pc;
|
||||
|
||||
layout(location = 0) out vec3 FragmentNormal;
|
||||
layout(location = 1) out vec3 FragmentTangent;
|
||||
layout(location = 2) out vec3 FragmentPosition;
|
||||
layout(location = 3) out vec2 FragmentTexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pos=vec4(Vertex,1.0)*pc.local_to_world;
|
||||
|
||||
gl_Position=pos*world.mvp;
|
||||
|
||||
FragmentPosition=pos.xyz;
|
||||
FragmentTexCoord=TexCoord;
|
||||
|
||||
mat3 n=transpose(inverse(mat3(pc.local_to_world)));
|
||||
|
||||
FragmentNormal=n*normalize(Normal);
|
||||
FragmentTangent=n*normalize(Tangent);
|
||||
}
|
@ -14,3 +14,6 @@ glslangValidator -V -o c_gbuffer.frag.spv c_gbuffer.frag
|
||||
|
||||
glslangValidator -V -o Atomsphere.vert.spv Atomsphere.vert
|
||||
glslangValidator -V -o Atomsphere.frag.spv Atomsphere.frag
|
||||
|
||||
glslangValidator -V -o gbuffer_opaque.vert.spv gbuffer_opaque.vert
|
||||
glslangValidator -V -o gbuffer_opaque.frag.spv gbuffer_opaque.frag
|
||||
|
Loading…
x
Reference in New Issue
Block a user