2021-10-29 21:04:45 +02:00
|
|
|
#version 460 core
|
|
|
|
#extension GL_EXT_nonuniform_qualifier : enable
|
|
|
|
#extension GL_GOOGLE_include_directive : require
|
|
|
|
|
|
|
|
#include "ray_common.glsl"
|
|
|
|
#include "ray_kusochki.glsl"
|
|
|
|
|
|
|
|
layout (set = 0, binding = 6) uniform sampler2D textures[MAX_TEXTURES];
|
|
|
|
|
2021-10-31 20:51:10 +01:00
|
|
|
layout (push_constant) uniform PC_ {
|
|
|
|
PushConstants push_constants;
|
|
|
|
};
|
|
|
|
|
2021-10-29 21:04:45 +02:00
|
|
|
layout(location = PAYLOAD_LOCATION_ADDITIVE) rayPayloadInEXT RayPayloadAdditive payload_additive;
|
|
|
|
|
|
|
|
hitAttributeEXT vec2 bary;
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
const int instance_kusochki_offset = gl_InstanceCustomIndexEXT;
|
|
|
|
const int kusok_index = instance_kusochki_offset + gl_GeometryIndexEXT;
|
2022-10-29 23:01:14 +02:00
|
|
|
const uint first_index_offset = getKusok(kusok_index).index_offset + gl_PrimitiveID * 3;
|
2021-10-29 21:04:45 +02:00
|
|
|
|
2022-10-29 23:01:14 +02:00
|
|
|
const uint vi1 = uint(getIndex(first_index_offset+0)) + getKusok(kusok_index).vertex_offset;
|
|
|
|
const uint vi2 = uint(getIndex(first_index_offset+1)) + getKusok(kusok_index).vertex_offset;
|
|
|
|
const uint vi3 = uint(getIndex(first_index_offset+2)) + getKusok(kusok_index).vertex_offset;
|
2021-10-29 21:04:45 +02:00
|
|
|
|
2023-02-26 03:41:01 +01:00
|
|
|
const vec2 texture_uv = GET_VERTEX(vi1).gl_tc * (1. - bary.x - bary.y) + GET_VERTEX(vi2).gl_tc * bary.x + GET_VERTEX(vi3).gl_tc * bary.y + push_constants.time * getKusok(kusok_index).uv_speed;
|
2021-11-14 22:53:50 +01:00
|
|
|
// TODO mips
|
2022-10-29 23:01:14 +02:00
|
|
|
const uint tex_index = getKusok(kusok_index).tex_base_color;
|
2021-10-29 21:04:45 +02:00
|
|
|
const vec4 texture_color = texture(textures[nonuniformEXT(tex_index)], texture_uv);
|
2022-10-29 23:01:14 +02:00
|
|
|
const vec3 color = texture_color.rgb * getKusok(kusok_index).color.rgb * texture_color.a * getKusok(kusok_index).color.a;
|
2021-10-29 21:04:45 +02:00
|
|
|
|
2021-10-31 20:37:09 +01:00
|
|
|
const float overshoot = gl_HitTEXT - payload_additive.ray_distance;
|
|
|
|
|
|
|
|
payload_additive.color += color * smoothstep(additive_soft_overshoot, 0., overshoot);
|
2021-10-29 21:04:45 +02:00
|
|
|
|
|
|
|
ignoreIntersectionEXT;
|
|
|
|
}
|