48 lines
2.0 KiB
Plaintext
48 lines
2.0 KiB
Plaintext
#version 460 core
|
|
#extension GL_EXT_nonuniform_qualifier : enable
|
|
#extension GL_GOOGLE_include_directive : require
|
|
#extension GL_EXT_shader_16bit_storage : require
|
|
|
|
#define GLSL
|
|
#include "ray_interop.h"
|
|
#undef GLSL
|
|
|
|
layout (set = 0, binding = 6) uniform sampler2D textures[MAX_TEXTURES];
|
|
|
|
layout(set = 0, binding = 30, std430) readonly buffer ModelHeaders { ModelHeader a[]; } model_headers;
|
|
layout(set = 0, binding = 31, std430) readonly buffer Kusochki { Kusok a[]; } kusochki;
|
|
layout(set = 0, binding = 32, std430) readonly buffer Indices { uint16_t a[]; } indices;
|
|
layout(set = 0, binding = 33, std430) readonly buffer Vertices { Vertex a[]; } vertices;
|
|
|
|
#include "ray_common.glsl"
|
|
#include "ray_kusochki.glsl"
|
|
|
|
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;
|
|
const uint first_index_offset = getKusok(kusok_index).index_offset + gl_PrimitiveID * 3;
|
|
|
|
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;
|
|
|
|
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;
|
|
|
|
const Kusok kusok = getKusok(kusok_index);
|
|
// TODO mips
|
|
const uint tex_index = kusok.material.tex_base_color;
|
|
const vec4 texture_color = texture(textures[nonuniformEXT(tex_index)], texture_uv);
|
|
const vec4 mm_color = getModelHeader(gl_InstanceID).color * kusok.material.base_color;
|
|
const vec3 color = texture_color.rgb * mm_color.rgb * texture_color.a * mm_color.a;
|
|
|
|
const float overshoot = gl_HitTEXT - payload_additive.ray_distance;
|
|
|
|
payload_additive.color += color * smoothstep(additive_soft_overshoot, 0., overshoot);
|
|
|
|
ignoreIntersectionEXT;
|
|
}
|