2022-09-19 00:00:07 +08:00
|
|
|
#version 450
|
|
|
|
#extension GL_ARB_separate_shader_objects : enable
|
|
|
|
#extension GL_ARB_shading_language_420pack : enable
|
2022-09-27 19:18:45 +08:00
|
|
|
#extension GL_EXT_nonuniform_qualifier : require
|
2022-09-19 00:00:07 +08:00
|
|
|
|
|
|
|
layout(location = 0) in struct
|
|
|
|
{
|
|
|
|
//mat3 BTN;
|
|
|
|
vec4 vertColor;
|
|
|
|
//vec3 localSpacePosition;
|
2022-09-27 19:18:45 +08:00
|
|
|
vec2 uv;
|
2022-09-19 00:00:07 +08:00
|
|
|
//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;
|
|
|
|
|
2022-09-27 21:06:14 +08:00
|
|
|
struct MatPropData
|
|
|
|
{
|
|
|
|
vec4 color;
|
|
|
|
float alpha;
|
|
|
|
vec3 beta;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout(set = 3, binding = 0) buffer MaterialProperties
|
|
|
|
{
|
|
|
|
MatPropData data[];
|
|
|
|
} MatProp;
|
|
|
|
|
2022-09-19 00:00:07 +08:00
|
|
|
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;
|
|
|
|
|
2022-09-27 21:06:14 +08:00
|
|
|
outColor = MatProp.data[0].color;
|
|
|
|
//outColor = vec4 (1.0f);
|
2022-09-19 00:00:07 +08:00
|
|
|
}
|