延迟渲染测试成功(内置几何体法不正确,待修正)
This commit is contained in:
parent
4d51417f2b
commit
39db360b4a
@ -279,7 +279,7 @@ private:
|
||||
bool InitMaterial()
|
||||
{
|
||||
if(!InitSubpass(&sp_gbuffer, OS_TEXT("res/shader/gbuffer_opaque.vert.spv"),OS_TEXT("res/shader/gbuffer_opaque.frag.spv")))return(false);
|
||||
if(!InitSubpass(&sp_composition,OS_TEXT("res/shader/gbuffer_debug.vert.spv"),OS_TEXT("res/shader/gbuffer_debug.frag.spv")))return(false);
|
||||
if(!InitSubpass(&sp_composition,OS_TEXT("res/shader/gbuffer_composition.vert.spv"),OS_TEXT("res/shader/gbuffer_composition.frag.spv")))return(false);
|
||||
|
||||
if(!InitGBufferPipeline(&sp_gbuffer))return(false);
|
||||
if(!InitCompositionPipeline(&sp_composition))return(false);
|
||||
|
@ -28,21 +28,9 @@ void main()
|
||||
vec3 normal =texture(GB_Normal, FragmentPosition).xyz;
|
||||
vec3 color =texture(GB_Color, FragmentPosition).xyz;
|
||||
|
||||
vec3 light_pos=vec3(1,1,1);
|
||||
vec3 light_halfVector=vec3(1,1,1);
|
||||
vec3 sun_light_direction=vec3(1,1,1);
|
||||
|
||||
float sun_light_intensity=max(dot(normal,sun_light_direction),0.0);
|
||||
|
||||
float pf;
|
||||
|
||||
float nDotVP=max(0.0,dot(normal,normalize(light_pos)));
|
||||
float nDotHV=max(0.0,dot(normal,normalize(light_halfVector)));
|
||||
|
||||
if(nDotVP==0.0)
|
||||
{
|
||||
pf=0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pf=pow(nDotHV,
|
||||
}
|
||||
FragColor=vec4(color*sun_light_intensity,1.0);
|
||||
}
|
||||
|
@ -17,24 +17,13 @@ layout(binding = 0) uniform sampler2D GB_Position;
|
||||
layout(binding = 1) uniform sampler2D GB_Normal;
|
||||
layout(binding = 2) uniform sampler2D GB_Color;
|
||||
|
||||
layout(location = 0) in vec2 FragmentPosition;
|
||||
layout(location = 1) flat in uint FragmentTexID;
|
||||
layout(location = 2) in vec2 FragmentTexCoord;
|
||||
layout(location = 0) flat in uint FragmentTexID;
|
||||
layout(location = 1) in vec2 FragmentTexCoord;
|
||||
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor=vec4(normalize(FragmentPosition),0.0,1.0);
|
||||
/* vec3 components[3];
|
||||
|
||||
components[0]=texture(GB_Position, FragmentTexCoord).xyz;
|
||||
components[1]=texture(GB_Normal, FragmentTexCoord).xyz;
|
||||
components[2]=texture(GB_Color, FragmentTexCoord).xyz;
|
||||
|
||||
if(FragmentTexID<3)
|
||||
FragColor=vec4(components[FragmentTexID],1.0);
|
||||
else
|
||||
FragColor=vec4(0.0,0.0,0.0,1.0);*/
|
||||
FragColor=texture(GB_Normal,FragmentTexCoord);
|
||||
}
|
||||
|
||||
|
@ -2,30 +2,12 @@
|
||||
|
||||
layout(location = 0) in vec2 Vertex;
|
||||
|
||||
layout(location = 0) out vec2 FragmentPosition;
|
||||
|
||||
layout(location = 1) out uint FragmentTexID;
|
||||
layout(location = 2) out vec2 FragmentTexCoord;
|
||||
layout(location = 0) out uint FragmentTexID;
|
||||
layout(location = 1) out vec2 FragmentTexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position=vec4(Vertex,0.0,1.0);
|
||||
|
||||
FragmentPosition=Vertex;
|
||||
FragmentTexCoord=(Vertex+1.0)/2.0;
|
||||
|
||||
if(Vertex.x<0)
|
||||
{
|
||||
if(Vertex.y<0)
|
||||
FragmentTexID=0;
|
||||
else
|
||||
FragmentTexID=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Vertex.y<0)
|
||||
FragmentTexID=2;
|
||||
else
|
||||
FragmentTexID=3;
|
||||
}
|
||||
}
|
||||
|
@ -16,14 +16,14 @@ void main()
|
||||
{
|
||||
outPosition=vec4(normalize(FragmentPosition*2.0-vec3(1.0)),1.0);
|
||||
|
||||
/*vec3 N = normalize(FragmentNormal);
|
||||
vec3 N = normalize(FragmentNormal);
|
||||
vec3 T = normalize(FragmentTangent);
|
||||
vec3 B = cross(N,T);
|
||||
mat3 TBN = mat3(T,B,N);
|
||||
vec3 tnorm = (texture(TextureNormal,FragmentTexCoord).xyz*2.0-vec3(1.0))*TBN;
|
||||
|
||||
outNormal=vec4(normalize(tnorm),1.0);*/
|
||||
outNormal=vec4(normalize(FragmentNormal),1.0);
|
||||
outNormal=vec4(normalize(tnorm),1.0);
|
||||
//outNormal=vec4(normalize(FragmentNormal),1.0);
|
||||
|
||||
outColor=texture(TextureColor,FragmentTexCoord);
|
||||
}
|
||||
|
@ -1098,8 +1098,8 @@ namespace hgl
|
||||
if(np)
|
||||
{
|
||||
*np = 0.0f;++np;
|
||||
*np = -1.0f;++np;
|
||||
*np = 0.0f;++np;
|
||||
*np = 1.0f;++np;
|
||||
}
|
||||
|
||||
if(tp)
|
||||
@ -1126,8 +1126,8 @@ namespace hgl
|
||||
if(np)
|
||||
{
|
||||
*np = 0.0f;++np;
|
||||
*np = -1.0f;++np;
|
||||
*np = 0.0f;++np;
|
||||
*np = 1.0f;++np;
|
||||
}
|
||||
|
||||
if(tp)
|
||||
@ -1159,8 +1159,8 @@ namespace hgl
|
||||
if(np)
|
||||
{
|
||||
*np = h / l * cosf(currentAngle); ++np;
|
||||
*np = r / l; ++np;
|
||||
*np = h / l * -sinf(currentAngle); ++np;
|
||||
*np =-r / l; ++np;
|
||||
}
|
||||
|
||||
if(tp)
|
||||
|
Loading…
x
Reference in New Issue
Block a user