rt: simplify bounce computations

use simpler polygon sampling
use smaller texture lods
This commit is contained in:
Ivan 'provod' Avdeev 2023-02-08 10:11:00 -08:00
parent c5a1343fc6
commit 3ecd21a25b
3 changed files with 19 additions and 5 deletions

View File

@ -3,6 +3,7 @@
#extension GL_EXT_nonuniform_qualifier : enable
#extension GL_EXT_ray_query: require
#define RAY_BOUNCE
#define RAY_QUERY
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;

View File

@ -6,6 +6,18 @@
#include "noise.glsl"
#include "utils.glsl"
#define DO_ALL_IN_CLUSTER 1
#ifndef RAY_BOUNCE
#define PROJECTED
//#define SOLID
//#define SIMPLE_SOLID
#else
//#define PROJECTED
//#define SOLID
//#define SIMPLE_SOLID
#endif
struct SampleContext {
mat4x3 world_to_shading;
};
@ -159,11 +171,6 @@ vec4 getPolygonLightSampleSolid(vec3 P, vec3 view_dir, SampleContext ctx, const
return vec4(light_dir, contrib);
}
#define DO_ALL_IN_CLUSTER 1
//#define PROJECTED
//#define SOLID
#define SIMPLE_SOLID
void sampleSinglePolygonLight(in vec3 P, in vec3 N, in vec3 view_dir, in SampleContext ctx, in MaterialProperties material, in PolygonLight poly, inout vec3 diffuse, inout vec3 specular) {
// TODO cull by poly plane

View File

@ -13,7 +13,11 @@ layout(set = 0, binding = 2) uniform UBO { UniformBuffer ubo; } ubo;
layout(set = 0, binding = 7) uniform samplerCube skybox;
vec4 sampleTexture(uint tex_index, vec2 uv, vec4 uv_lods) {
#ifndef RAY_BOUNCE
return textureGrad(textures[nonuniformEXT(tex_index)], uv, uv_lods.xy, uv_lods.zw);
#else
return textureLod(textures[nonuniformEXT(tex_index)], uv, 2.);
#endif
}
void primaryRayHit(rayQueryEXT rq, inout RayPayloadPrimary payload) {
@ -34,6 +38,7 @@ void primaryRayHit(rayQueryEXT rq, inout RayPayloadPrimary payload) {
payload.material_rmxx.r = (kusok.tex_roughness > 0) ? sampleTexture(kusok.tex_roughness, geom.uv, geom.uv_lods).r : kusok.roughness;
payload.material_rmxx.g = (kusok.tex_metalness > 0) ? sampleTexture(kusok.tex_metalness, geom.uv, geom.uv_lods).r : kusok.metalness;
#ifndef RAY_BOUNCE
const uint tex_normal = kusok.tex_normalmap;
vec3 T = geom.tangent;
if (tex_normal > 0 && dot(T,T) > .5) {
@ -43,6 +48,7 @@ void primaryRayHit(rayQueryEXT rq, inout RayPayloadPrimary payload) {
const vec3 tnorm = sampleTexture(tex_normal, geom.uv, geom.uv_lods).xyz * 2. - 1.; // TODO is this sampling correct for normal data?
geom.normal_shading = normalize(TBN * tnorm);
}
#endif
}
payload.normals_gs.xy = normalEncode(geom.normal_geometry);