#version 450 #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable layout(location = 0) in struct { //mat3 BTN; vec4 vertColor; //vec3 localSpacePosition; //vec2 uv; //vec3 localLightPosition; //vec3 localEyePosition; } In; //layout(std140, push_constant) uniform TestPushConstant //{ // mat4 pvMat; // vec4 lightPosition; // vec4 eyePosition; // vec4 ambientColor; // vec4 lightColor; // //} testPushConstant; layout(location = 0) out vec4 outColor; //layout(binding = 0) uniform sampler2D diffuseMap; //layout(binding = 1) uniform sampler2D normalMap; //layout(binding = 2) uniform sampler2D aoMap; //layout(binding = 3) uniform sampler2D glossinessMap; //layout(binding = 4) uniform sampler2D samplerRoughnessMap; void main() { //vec3 normal; //// Get the tangent space normal from normal map. It is a BC5 texture and therefore only use red and green //normal.xy = (texture (normalMap, In.uv).gr * 2.0f) - 1.0f; //// z value is derived (TODO: Find out what this does) //normal.z = sqrt(1.0f - dot(normal.xy, normal.xy)); //// Transform the normal from tangent space to local space //normal = In.BTN * normal; //// Get the vector from fragment to light //vec3 localLightDir = normalize(In.localLightPosition - In.localSpacePosition); //// get the value of dot between normal from texture and frag to light //float diffuse = max(0, dot(normal, localLightDir)); //// sample the diffuse texture //vec4 diffuseColor = texture (diffuseMap, In.uv) * In.vertColor; //vec3 eyeDirection = normalize(In.localSpacePosition - In.localEyePosition); //const float shininess = mix(1, 100, 1 - texture (samplerRoughnessMap, In.uv).r); //float specular = pow(max(0, dot(normal, normalize(localLightDir - eyeDirection))), shininess); //outColor.rgb = testPushConstant.ambientColor.rgb * diffuseColor.rgb * texture (aoMap, In.uv).rgb; //outColor.rgb += testPushConstant.lightColor.rgb * (specular.rrr * 0.4 + diffuse.rrr * diffuseColor.rgb); //const float gamma = testPushConstant.eyePosition.w; //outColor.rgb = pow(outColor.rgb, vec3(1.0f / gamma)); //outColor.a = diffuseColor.a; outColor = vec4 (1.0f); }