54 lines
1.2 KiB
GLSL
54 lines
1.2 KiB
GLSL
#version 450
|
|
#extension GL_ARB_separate_shader_objects : enable
|
|
|
|
layout(location = 0) in vec4 position;
|
|
layout(location = 1) in vec4 normal;
|
|
layout(location = 2) in vec4 color;
|
|
layout(location = 3) in float weight;
|
|
layout(location = 0) out vec4 outColor;
|
|
|
|
layout(set = 0, binding = 0) uniform NodeData
|
|
{
|
|
mat4 world;
|
|
} node;
|
|
|
|
layout(set = 1, binding = 0) uniform CameraData
|
|
{
|
|
mat4 viewProjection;
|
|
mat4 view;
|
|
mat4 projection;
|
|
vec4 camPos;
|
|
float nearPlane;
|
|
float farPlane;
|
|
float width;
|
|
float height;
|
|
float fov;
|
|
float aspect;
|
|
float scaleFactor;
|
|
float pixelScaleFactor;
|
|
} cam;
|
|
|
|
void main()
|
|
{
|
|
//vec4 worldPos = node.world * position;
|
|
vec4 worldPos = node.world[3] + position;
|
|
worldPos.w = 1;
|
|
|
|
//float discardHelper = 0;
|
|
float discardHelper = normal.a * 3;
|
|
vec3 camDir = (worldPos - cam.camPos).xyz;
|
|
// normal culling
|
|
if (dot(normal.xyz, camDir) > 0)
|
|
{
|
|
discardHelper += 3;
|
|
}
|
|
|
|
outColor = color;
|
|
//outColor = normal / 2 + 0.5f;
|
|
//outColor = vec4(weight/10, weight / 50, weight / 100, 1);
|
|
//gl_Position = normalize(cam.viewProjection * worldPos);
|
|
gl_Position = cam.viewProjection * worldPos;
|
|
gl_PointSize = clamp((cam.pixelScaleFactor / length(camDir)) / 256, 1, 10);
|
|
|
|
gl_Position.z += discardHelper;
|
|
} |