diff --git a/example/Vulkan/Deferred.cpp b/example/Vulkan/Deferred.cpp index 087c6d08..be6075de 100644 --- a/example/Vulkan/Deferred.cpp +++ b/example/Vulkan/Deferred.cpp @@ -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); diff --git a/res/shader/gbuffer_composition.frag b/res/shader/gbuffer_composition.frag index caa0b04e..85454b6e 100644 --- a/res/shader/gbuffer_composition.frag +++ b/res/shader/gbuffer_composition.frag @@ -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); } diff --git a/res/shader/gbuffer_debug.frag b/res/shader/gbuffer_debug.frag index 4392a63d..0392bc87 100644 --- a/res/shader/gbuffer_debug.frag +++ b/res/shader/gbuffer_debug.frag @@ -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); } diff --git a/res/shader/gbuffer_debug.vert b/res/shader/gbuffer_debug.vert index dbdff199..83bd7966 100644 --- a/res/shader/gbuffer_debug.vert +++ b/res/shader/gbuffer_debug.vert @@ -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; - } } diff --git a/res/shader/gbuffer_opaque.frag b/res/shader/gbuffer_opaque.frag index bf2e6393..7ee64be9 100644 --- a/res/shader/gbuffer_opaque.frag +++ b/res/shader/gbuffer_opaque.frag @@ -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); } diff --git a/src/SceneGraph/InlineGeometry.cpp b/src/SceneGraph/InlineGeometry.cpp index cb124c9c..55825a84 100644 --- a/src/SceneGraph/InlineGeometry.cpp +++ b/src/SceneGraph/InlineGeometry.cpp @@ -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)