Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devshgraphicsprogramming/ee4701a3512d8fd090c46a85f2ab1709 to your computer and use it in GitHub Desktop.
Save devshgraphicsprogramming/ee4701a3512d8fd090c46a85f2ab1709 to your computer and use it in GitHub Desktop.
Dump of a preprocessed shader from Nabla
#version 460 core
#extension GL_GOOGLE_include_directive : enable
#line 1 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/shadeVBuffer.comp"
#define NBL_IMPL_GL_NV_viewport_array2
#define NBL_IMPL_GL_NV_stereo_view_rendering
#define NBL_IMPL_GL_NV_sample_mask_override_coverage
#define NBL_IMPL_GL_NV_geometry_shader_passthrough
#define NBL_IMPL_GL_NV_shader_subgroup_partitioned
#define NBL_IMPL_GL_NV_compute_shader_derivatives
#define NBL_IMPL_GL_NV_fragment_shader_barycentric
#define NBL_IMPL_GL_NV_mesh_shader
#define NBL_IMPL_GL_NV_shading_rate_image
#define NBL_IMPL_GL_ARB_shading_language_include
#define NBL_IMPL_GL_ARB_enhanced_layouts
#define NBL_IMPL_GL_ARB_bindless_texture
#define NBL_IMPL_GL_ARB_shader_draw_parameters
#define NBL_IMPL_GL_ARB_shader_group_vote
#define NBL_IMPL_GL_ARB_cull_distance
#define NBL_IMPL_GL_ARB_derivative_control
#define NBL_IMPL_GL_ARB_shader_texture_image_samples
#define NBL_IMPL_GL_KHR_blend_equation_advanced
#define NBL_IMPL_GL_KHR_blend_equation_advanced_coherent
#define NBL_IMPL_GL_ARB_fragment_shader_interlock
#define NBL_IMPL_GL_ARB_gpu_shader_int64
#define NBL_IMPL_GL_ARB_post_depth_coverage
#define NBL_IMPL_GL_ARB_shader_ballot
#define NBL_IMPL_GL_ARB_shader_clock
#define NBL_IMPL_GL_ARB_shader_viewport_layer_array
#define NBL_IMPL_GL_ARB_sparse_texture2
#define NBL_IMPL_GL_ARB_sparse_texture_clamp
#define NBL_IMPL_GL_ARB_gl_spirv
#define NBL_IMPL_GL_ARB_spirv_extensions
#define NBL_IMPL_GL_AMD_vertex_shader_viewport_index
#define NBL_IMPL_GL_AMD_vertex_shader_layer
#define NBL_IMPL_GL_NV_bindless_texture
#define NBL_IMPL_GL_NV_shader_atomic_float
#define NBL_IMPL_GL_EXT_shader_integer_mix
#define NBL_IMPL_GL_NV_shader_thread_group
#define NBL_IMPL_GL_NV_shader_thread_shuffle
#define NBL_IMPL_GL_EXT_shader_image_load_formatted
#define NBL_IMPL_GL_NV_shader_atomic_int64
#define NBL_IMPL_GL_EXT_post_depth_coverage
#define NBL_IMPL_GL_EXT_sparse_texture2
#define NBL_IMPL_GL_NV_fragment_shader_interlock
#define NBL_IMPL_GL_NV_sample_locations
#define NBL_IMPL_GL_NV_shader_atomic_fp16_vector
#define NBL_IMPL_GL_NV_command_list
#define NBL_IMPL_GL_OVR_multiview
#define NBL_IMPL_GL_OVR_multiview2
#define NBL_IMPL_GL_NV_shader_atomic_float64
#define NBL_IMPL_GL_NV_conservative_raster_pre_snap
#define NBL_IMPL_GL_NV_shader_texture_footprint
#define NBL_IMPL_GL_NV_gpu_shader5
#ifdef NBL_IMPL_GL_AMD_gpu_shader_half_float
#define NBL_GL_EXT_shader_explicit_arithmetic_types_float16
#endif
#ifdef NBL_IMPL_GL_NV_gpu_shader5
#define NBL_GL_EXT_shader_explicit_arithmetic_types_float16
#define NBL_GL_EXT_nonuniform_qualifier
#define NBL_GL_KHR_shader_subgroup_vote_subgroup_any_all_equal_bool
#endif
#ifdef NBL_IMPL_GL_AMD_gpu_shader_int16
#define NBL_GL_EXT_shader_explicit_arithmetic_types_int16
#endif
#ifdef NBL_IMPL_GL_NV_shader_thread_group
#define NBL_GL_KHR_shader_subgroup_ballot_subgroup_mask
#define NBL_GL_KHR_shader_subgroup_basic_subgroup_size
#define NBL_GL_KHR_shader_subgroup_basic_subgroup_invocation_id
#define NBL_GL_KHR_shader_subgroup_ballot_subgroup_ballot
#define NBL_GL_KHR_shader_subgroup_ballot_inverse_ballot_bit_count
#endif
#if defined(NBL_IMPL_GL_ARB_shader_ballot)&& defined(NBL_IMPL_GL_ARB_shader_int64)
#define NBL_GL_KHR_shader_subgroup_ballot_subgroup_mask
#define NBL_GL_KHR_shader_subgroup_basic_subgroup_size
#define NBL_GL_KHR_shader_subgroup_basic_subgroup_invocation_id
#define NBL_GL_KHR_shader_subgroup_ballot_subgroup_broadcast_first
#define NBL_GL_KHR_shader_subgroup_ballot_subgroup_ballot
#define NBL_GL_KHR_shader_subgroup_ballot_inverse_ballot_bit_count
#endif
#if defined(NBL_IMPL_GL_AMD_gcn_shader)&& (defined(NBL_IMPL_GL_AMD_gpu_shader_int64)|| defined(NBL_IMPL_GL_NV_gpu_shader5))
#define NBL_GL_KHR_shader_subgroup_basic_subgroup_size
#define NBL_GL_KHR_shader_subgroup_vote_subgroup_any_all_equal_bool
#endif
#ifdef NBL_IMPL_GL_NV_shader_thread_shuffle
#define NBL_GL_KHR_shader_subgroup_ballot_subgroup_broadcast_first
#endif
#ifdef NBL_IMPL_GL_ARB_shader_group_vote
#define NBL_GL_KHR_shader_subgroup_vote_subgroup_any_all_equal_bool
#endif
#if defined(NBL_GL_KHR_shader_subgroup_ballot_subgroup_broadcast_first)&& defined(NBL_GL_KHR_shader_subgroup_vote_subgroup_any_all_equal_bool)
#define NBL_GL_KHR_shader_subgroup_vote_subgroup_all_equal_T
#endif
#if defined(NBL_GL_KHR_shader_subgroup_ballot_subgroup_ballot)&& defined(NBL_GL_KHR_shader_subgroup_basic_subgroup_invocation_id)
#define NBL_GL_KHR_shader_subgroup_basic_subgroup_elect
#endif
#ifdef NBL_GL_KHR_shader_subgroup_ballot_subgroup_mask
#define NBL_GL_KHR_shader_subgroup_ballot_inverse_ballot
#define NBL_GL_KHR_shader_subgroup_ballot_inclusive_bit_count
#define NBL_GL_KHR_shader_subgroup_ballot_exclusive_bit_count
#endif
#ifdef NBL_GL_KHR_shader_subgroup_ballot_subgroup_ballot
#define NBL_GL_KHR_shader_subgroup_ballot_bit_count
#endif
#ifdef NBL_IMPL_GL_KHR_shader_subgroup_basic
#define NBL_GL_KHR_shader_subgroup_basic
#define NBL_GL_KHR_shader_subgroup_basic_subgroup_size
#define NBL_GL_KHR_shader_subgroup_basic_subgroup_invocation_id
#define NBL_GL_KHR_shader_subgroup_basic_subgroup_elect
#endif
#ifdef NBL_IMPL_GL_KHR_shader_subgroup_vote
#define NBL_GL_KHR_shader_subgroup_vote
#define NBL_GL_KHR_shader_subgroup_vote_subgroup_any_all_equal_bool
#define NBL_GL_KHR_shader_subgroup_vote_subgroup_all_equal_T
#endif
#ifdef NBL_IMPL_GL_KHR_shader_subgroup_ballot
#define NBL_GL_KHR_shader_subgroup_ballot
#define NBL_GL_KHR_shader_subgroup_ballot_bit_count
#define NBL_GL_KHR_shader_subgroup_ballot_subgroup_mask
#define NBL_GL_KHR_shader_subgroup_ballot_subgroup_ballot
#define NBL_GL_KHR_shader_subgroup_ballot_inclusive_bit_count
#define NBL_GL_KHR_shader_subgroup_ballot_exclusive_bit_count
#define NBL_GL_KHR_shader_subgroup_ballot_inverse_ballot_bit_count
#define NBL_GL_KHR_shader_subgroup_ballot_subgroup_broadcast_first
#endif
#ifdef NBL_IMPL_GL_KHR_shader_subgroup_shuffle
#define NBL_GL_KHR_shader_subgroup_shuffle
#endif
#ifdef NBL_IMPL_GL_KHR_shader_subgroup_shuffle_relative
#define NBL_GL_KHR_shader_subgroup_shuffle_relative
#endif
#ifdef NBL_IMPL_GL_KHR_shader_subgroup_arithmetic
#define NBL_GL_KHR_shader_subgroup_arithmetic
#endif
#ifdef NBL_IMPL_GL_KHR_shader_subgroup_clustered
#define NBL_GL_KHR_shader_subgroup_clustered
#endif
#ifdef NBL_IMPL_GL_KHR_shader_subgroup_quad
#define NBL_GL_KHR_shader_subgroup_quad
#endif
#line 2
#define _NBL_VG_USE_SSBO
#define _NBL_VG_SSBO_DESCRIPTOR_SET 1
#define _NBL_VG_USE_SSBO_UINT
#define _NBL_VG_SSBO_UINT_BINDING 1
#define _NBL_VG_USE_SSBO_UVEC2
#define _NBL_VG_SSBO_UVEC2_BINDING 2
#define _NBL_VG_USE_SSBO_UVEC3
#define _NBL_VG_SSBO_UVEC3_BINDING 3
#define _NBL_VG_USE_SSBO_INDEX
#define _NBL_VG_SSBO_INDEX_BINDING 5
#line 1 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/common.glsl"
#line 1 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/common.glsl"
#ifndef _COMMON_GLSL_INCLUDED_
#define _COMMON_GLSL_INCLUDED_
#extension GL_EXT_shader_16bit_storage : require
#line 1 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/common.h"
#line 1 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/common.h"
#ifndef _COMMON_H_INCLUDED_
#define _COMMON_H_INCLUDED_
#define PAGE_SZ_LOG2 7
#define PAGE_PADDING 8
#define _NBL_VT_PAGE_TABLE_BINDING 0
#define _NBL_VT_FLOAT_VIEWS_BINDING 1
#define USED_ATTRIBUTES 3
#define MAX_TRIANGLES_IN_BATCH 1024
#define SHADING_WG_SIZE_X 16
#define SHADING_WG_SIZE_Y 16
#endif
#line 7 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/common.glsl"
#define NBL_GLSL_BARYCENTRIC_VERT_POS_OUTPUT_LOC 1
#define NBL_GLSL_BARYCENTRIC_VERT_PROVOKINGPOS_OUTPUT_LOC 2
#define NBL_GLSL_BARYCENTRIC_FRAG_POS_INPUT_LOC NBL_GLSL_BARYCENTRIC_VERT_POS_OUTPUT_LOC
#define NBL_GLSL_BARYCENTRIC_FRAG_PROVOKINGPOS_INPUT_LOC NBL_GLSL_BARYCENTRIC_VERT_PROVOKINGPOS_OUTPUT_LOC
#line 1 "nbl/builtin/glsl/virtual_geometry/virtual_attribute.glsl"
#line 1 "nbl/builtin/glsl/virtual_geometry/virtual_attribute.glsl"
#ifndef _NBL_BUILTIN_GLSL_VIRTUAL_GEOMETRY_VIRTUAL_ATTRIBUTE_INCLUDED_
#define _NBL_BUILTIN_GLSL_VIRTUAL_GEOMETRY_VIRTUAL_ATTRIBUTE_INCLUDED_
#line 1 "nbl/builtin/glsl/virtual_geometry/descriptors.glsl"
#line 1 "nbl/builtin/glsl/virtual_geometry/descriptors.glsl"
#ifndef _NBL_BUILTIN_GLSL_VIRTUAL_GEOMETRY_DESCRIPTORS_INCLUDED_
#define _NBL_BUILTIN_GLSL_VIRTUAL_GEOMETRY_DESCRIPTORS_INCLUDED_
#ifndef _NBL_VG_USE_SSBO
#ifndef _NBL_VG_DESCRIPTOR_SET
#define _NBL_VG_DESCRIPTOR_SET 0
#endif
#ifndef _NBL_VG_UINT_BUFFERS
#define _NBL_VG_UINT_BUFFERS_BINDING 0
#define _NBL_VG_UINT_BUFFERS_COUNT 1
#endif
#ifndef _NBL_VG_FLOAT_BUFFERS
#define _NBL_VG_FLOAT_BUFFERS_BINDING 1
#define _NBL_VG_FLOAT_BUFFERS_COUNT 4
#endif
#ifndef _NBL_VG_INT_BUFFERS
#define _NBL_VG_INT_BUFFERS_BINDING 2
#define _NBL_VG_INT_BUFFERS_COUNT 0
#endif
#if _NBL_VG_UINT_BUFFERS_COUNT
layout(set = _NBL_VG_DESCRIPTOR_SET, binding = _NBL_VG_UINT_BUFFERS_BINDING)uniform usamplerBuffer MeshPackedDataUintSample[_NBL_VG_UINT_BUFFERS_COUNT];
uint nbl_glsl_VG_fetchTriangleVertexIndex(in uint baseVertex, in uint triangleVx)
{
return texelFetch(MeshPackedDataUintSample[_NBL_VG_UINT_BUFFERS_COUNT - 1u], int(baseVertex + triangleVx)). x;
}
#endif
#if _NBL_VG_FLOAT_BUFFERS_COUNT
layout(set = _NBL_VG_DESCRIPTOR_SET, binding = _NBL_VG_FLOAT_BUFFERS_BINDING)uniform samplerBuffer MeshPackedDataFloatSample[_NBL_VG_FLOAT_BUFFERS_COUNT];
#endif
#if _NBL_VG_INT_BUFFERS_COUNT
layout(set = _NBL_VG_DESCRIPTOR_SET, binding = _NBL_VG_INT_BUFFERS_BINDING)uniform isamplerBuffer MeshPackedDataIntSample[_NBL_VG_INT_BUFFERS_COUNT];
#endif
#else
#ifndef _NBL_VG_SSBO_DESCRIPTOR_SET
#define _NBL_VG_SSBO_DESCRIPTOR_SET 0
#endif
#ifndef _NBL_VG_USE_SSBO_UINT
#ifndef _NBL_VG_SSBO_UINT_BINDING
#define _NBL_VG_SSBO_UINT_BINDING 0
#endif
#endif
#ifndef _NBL_VG_USE_SSBO_UVEC2
#ifndef _NBL_VG_SSBO_UVEC2_BINDING
#define _NBL_VG_SSBO_UVEC2_BINDING 1
#endif
#endif
#ifndef _NBL_VG_USE_SSBO_UVEC3
#ifndef _NBL_VG_SSBO_UVEC3_BINDING
#define _NBL_VG_SSBO_UVEC3_BINDING 2
#endif
#endif
#ifndef _NBL_VG_USE_SSBO_UVEC4
#ifndef _NBL_VG_SSBO_UVEC4_BINDING
#define _NBL_VG_SSBO_UVEC4_BINDING 3
#endif
#endif
#ifndef _NBL_VG_USE_SSBO_INDEX
#ifndef _NBL_VG_SSBO_INDEX_BINDING
#define _NBL_VG_SSBO_INDEX_BINDING 4
#endif
#endif
#ifdef _NBL_VG_USE_SSBO_UINT
layout(set = _NBL_VG_SSBO_DESCRIPTOR_SET, binding = _NBL_VG_SSBO_UINT_BINDING, std430)readonly buffer MeshPackedDataAsUint
{
uint attribData[];
} meshPackedDataUintBuffer;
#endif
#ifdef _NBL_VG_USE_SSBO_UVEC2
layout(set = _NBL_VG_SSBO_DESCRIPTOR_SET, binding = _NBL_VG_SSBO_UVEC2_BINDING, std430)readonly buffer MeshPackedDataAsUvec2
{
uvec2 attribData[];
} meshPackedDataUvec2Buffer;
#endif
#ifdef _NBL_VG_USE_SSBO_UVEC3
struct Packed_uvec3_t
{
uint x, y, z;
};
layout(set = _NBL_VG_SSBO_DESCRIPTOR_SET, binding = _NBL_VG_SSBO_UVEC3_BINDING, std430)readonly buffer MeshPackedDataAsUvec3
{
Packed_uvec3_t attribData[];
} meshPackedDataUvec3Buffer;
#endif
#ifdef _NBL_VG_USE_SSBO_UVEC4
layout(set = _NBL_VG_SSBO_DESCRIPTOR_SET, binding = _NBL_VG_SSBO_UVEC4_BINDING, std430)readonly buffer MeshPackedDataAsUvec4
{
uvec4 attribData[];
} meshPackedDataUvec4Buffer;
#endif
#ifdef _NBL_VG_USE_SSBO_INDEX
layout(set = _NBL_VG_SSBO_DESCRIPTOR_SET, binding = _NBL_VG_SSBO_INDEX_BINDING, std430)readonly buffer TrianglePackedData
{
uint16_t indices[];
} trianglePackedData;
uint nbl_glsl_VG_fetchTriangleVertexIndex(in uint baseVertex, in uint triangleVx)
{
return uint(trianglePackedData . indices[baseVertex + triangleVx]);
}
#endif
#endif
#endif
#line 9 "nbl/builtin/glsl/virtual_geometry/virtual_attribute.glsl"
#define nbl_glsl_VG_VirtualAttributePacked_t uint
#ifndef _NBL_VG_USE_SSBO
struct nbl_glsl_VG_VirtualAttribute
{
uint binding;
int offset;
};
#else
#define nbl_glsl_VG_VirtualAttribute uint
#endif
nbl_glsl_VG_VirtualAttribute nbl_glsl_VG_unpackVirtualAttribute(in nbl_glsl_VG_VirtualAttributePacked_t vaPacked)
{
#ifndef _NBL_VG_USE_SSBO
nbl_glsl_VG_VirtualAttribute result;
result . binding = vaPacked >> 28;
result . offset = int(vaPacked & 0x0FFFFFFF);
return result;
#else
return vaPacked & 0x0FFFFFFF;
#endif
}
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC4))|| defined(_NBL_VG_FLOAT_BUFFERS_COUNT)
vec4 nbl_glsl_VG_attribFetch4f(in nbl_glsl_VG_VirtualAttributePacked_t attr, uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
uvec4 attrLocal = meshPackedDataUvec4Buffer . attribData[va + vertexID];
return vec4(uintBitsToFloat(attrLocal . x), uintBitsToFloat(attrLocal . y), uintBitsToFloat(attrLocal . z), uintBitsToFloat(attrLocal . w));
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataFloatSample[va . binding], addr);
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC3))|| _NBL_VG_FLOAT_BUFFERS_COUNT
vec3 nbl_glsl_VG_attribFetch3f(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
Packed_uvec3_t attrLocal = meshPackedDataUvec3Buffer . attribData[va + vertexID];
return vec3(uintBitsToFloat(attrLocal . x), uintBitsToFloat(attrLocal . y), uintBitsToFloat(attrLocal . z));
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataFloatSample[va . binding], addr). xyz;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_FLOAT_BUFFERS_COUNT
vec2 nbl_glsl_VG_attribFetch2f(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
uvec2 attrLocal = meshPackedDataUvec2Buffer . attribData[va + vertexID];
return vec2(uintBitsToFloat(attrLocal . x), uintBitsToFloat(attrLocal . y));
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataFloatSample[va . binding], addr). xy;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UINT))|| _NBL_VG_FLOAT_BUFFERS_COUNT
float nbl_glsl_VG_attribFetch1f(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return uintBitsToFloat(meshPackedDataUintBuffer . attribData[va + vertexID]);
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataFloatSample[va . binding], addr). x;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC4))|| _NBL_VG_INT_BUFFERS_COUNT
ivec4 nbl_glsl_VG_attribFetch4i(in nbl_glsl_VG_VirtualAttributePacked_t attr, uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return ivec4(meshPackedDataUvec4Buffer . attribData[va + vertexID]);
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataIntSample[va . binding], addr);
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC3))|| _NBL_VG_INT_BUFFERS_COUNT
ivec3 nbl_glsl_VG_attribFetch3i(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
Packed_uvec3_t attrLocal = meshPackedDataUvec3Buffer . attribData[va + vertexID];
return ivec3(int(attrLocal . x), int(attrLocal . y), int(attrLocal . z));
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataIntSample[va . binding], addr). xyz;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_INT_BUFFERS_COUNT
ivec2 nbl_glsl_VG_attribFetch2i(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return ivec2(meshPackedDataUvec2Buffer . attribData[va + vertexID]);
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataIntSample[va . binding], addr). xy;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UINT))|| _NBL_VG_INT_BUFFERS_COUNT
int nbl_glsl_VG_attribFetch1i(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return int(meshPackedDataUintBuffer . attribData[va + vertexID]);
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataIntSample[va . binding], addr). x;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC4))|| _NBL_VG_UINT_BUFFERS_COUNT
uvec4 nbl_glsl_VG_attribFetch4u(in nbl_glsl_VG_VirtualAttributePacked_t attr, uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return meshPackedDataUvec4Buffer . attribData[va + vertexID];
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataUintSample[va . binding], addr);
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC3))|| _NBL_VG_UINT_BUFFERS_COUNT
uvec3 nbl_glsl_VG_attribFetch3u(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
Packed_uvec3_t attrLocal = meshPackedDataUvec3Buffer . attribData[va + vertexID];
return uvec3(attrLocal . x, attrLocal . y, attrLocal . z);
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataUintSample[va . binding], addr). xyz;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_UINT_BUFFERS_COUNT
uvec2 nbl_glsl_VG_attribFetch2u(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return meshPackedDataUvec2Buffer . attribData[va + vertexID];
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataUintSample[va . binding], addr). xy;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UINT))|| _NBL_VG_UINT_BUFFERS_COUNT
uint nbl_glsl_VG_attribFetch1u(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return meshPackedDataUintBuffer . attribData[va + vertexID];
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataUintSample[va . binding], addr). x;
#endif
}
#endif
#endif
#line 15 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/common.glsl"
struct BatchInstanceData
{
vec3 Ka;
uint firstIndex;
vec3 Kd;
nbl_glsl_VG_VirtualAttributePacked_t vAttrPos;
vec3 Ks;
nbl_glsl_VG_VirtualAttributePacked_t vAttrUV;
vec3 Ke;
nbl_glsl_VG_VirtualAttributePacked_t vAttrNormal;
uvec2 map_Ka_data;
uvec2 map_Kd_data;
uvec2 map_Ks_data;
uvec2 map_Ns_data;
uvec2 map_d_data;
uvec2 map_bump_data;
float Ns;
float d;
float Ni;
uint extra;
};
layout(set = 1, binding = 0, std430)readonly buffer BatchInstanceBuffer
{
BatchInstanceData batchInstanceData[];
};
#line 1 "nbl/builtin/glsl/utils/common.glsl"
#line 1 "nbl/builtin/glsl/utils/common.glsl"
#ifndef _NBL_BUILTIN_GLSL_UTILS_COMMON_INCLUDED_
#define _NBL_BUILTIN_GLSL_UTILS_COMMON_INCLUDED_
#line 1 "nbl/builtin/glsl/math/functions.glsl"
#line 1 "nbl/builtin/glsl/math/functions.glsl"
#ifndef _NBL_MATH_FUNCTIONS_INCLUDED_
#define _NBL_MATH_FUNCTIONS_INCLUDED_
#line 1 "nbl/builtin/glsl/math/constants.glsl"
#line 1 "nbl/builtin/glsl/math/constants.glsl"
#ifndef _NBL_MATH_CONSTANTS_INCLUDED_
#define _NBL_MATH_CONSTANTS_INCLUDED_
#line 1 "nbl/builtin/glsl/limits/numeric.glsl"
#line 1 "nbl/builtin/glsl/limits/numeric.glsl"
#ifndef _NBL_LIMITS_NUMERIC_INCLUDED_
#define _NBL_LIMITS_NUMERIC_INCLUDED_
#ifndef INT_MIN
#define INT_MIN - 2147483648
#endif
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef UINT_MIN
#define UINT_MIN 0u
#endif
#ifndef UINT_MAX
#define UINT_MAX 4294967295u
#endif
#ifndef FLT_MIN
#define FLT_MIN 1.175494351e-38
#endif
#ifndef FLT_MAX
#define FLT_MAX 3.402823466e+38
#endif
#ifndef FLT_INF
#define FLT_INF (1.0 / 0.0)
#endif
#endif
#line 9 "nbl/builtin/glsl/math/constants.glsl"
#define nbl_glsl_PI 3.14159265359
#define nbl_glsl_RECIPROCAL_PI 0.318309886183
#define nbl_glsl_SQRT_RECIPROCAL_PI 0.56418958354
#define nbl_glsl_FLT_INF float(1.0 / 0.0)
#ifndef nbl_glsl_FLT_NAN
#define nbl_glsl_FLT_NAN uintBitsToFloat(0xFFffFFffu)
#endif
#endif
#line 9 "nbl/builtin/glsl/math/functions.glsl"
int nbl_glsl_dot(in ivec2 a, in ivec2 b){ return a . x * b . x + a . y * b . y;}
uint nbl_glsl_dot(in uvec2 a, in uvec2 b){ return a . x * b . x + a . y * b . y;}
int nbl_glsl_dot(in ivec3 a, in ivec3 b){ return a . x * b . x + a . y * b . y + a . z * b . z;}
uint nbl_glsl_dot(in uvec3 a, in uvec3 b){ return a . x * b . x + a . y * b . y + a . z * b . z;}
int nbl_glsl_dot(in ivec4 a, in ivec4 b){ return a . x * b . x + a . y * b . y + a . z * b . z + a . w * b . w;}
uint nbl_glsl_dot(in uvec4 a, in uvec4 b){ return a . x * b . x + a . y * b . y + a . z * b . z + a . w * b . w;}
float nbl_glsl_erf(in float _x)
{
const float a1 = 0.254829592;
const float a2 = - 0.284496736;
const float a3 = 1.421413741;
const float a4 = - 1.453152027;
const float a5 = 1.061405429;
const float p = 0.3275911;
float sign = sign(_x);
float x = abs(_x);
float t = 1.0 / (1.0 + p * x);
float y = 1.0 - (((((a5 * t + a4)* t)+ a3)* t + a2)* t + a1)* t * exp(- x * x);
return sign * y;
}
float nbl_glsl_erfInv(in float _x)
{
float x = clamp(_x, - 0.99999, 0.99999);
float w = - log((1.0 - x)* (1.0 + x));
float p;
if (w < 5.0)
{
w -= 2.5;
p = 2.81022636e-08;
p = 3.43273939e-07 + p * w;
p = - 3.5233877e-06 + p * w;
p = - 4.39150654e-06 + p * w;
p = 0.00021858087 + p * w;
p = - 0.00125372503 + p * w;
p = - 0.00417768164 + p * w;
p = 0.246640727 + p * w;
p = 1.50140941 + p * w;
}
else
{
w = sqrt(w)- 3.0;
p = - 0.000200214257;
p = 0.000100950558 + p * w;
p = 0.00134934322 + p * w;
p = - 0.00367342844 + p * w;
p = 0.00573950773 + p * w;
p = - 0.0076224613 + p * w;
p = 0.00943887047 + p * w;
p = 1.00167406 + p * w;
p = 2.83297682 + p * w;
}
return p * x;
}
float nbl_glsl_lengthManhattan(float v)
{
return abs(v);
}
float nbl_glsl_lengthManhattan(vec2 v)
{
v = abs(v);
return v . x + v . y;
}
float nbl_glsl_lengthManhattan(vec3 v)
{
v = abs(v);
return v . x + v . y + v . z;
}
float nbl_glsl_lengthManhattan(vec4 v)
{
v = abs(v);
return v . x + v . y + v . z + v . w;
}
float nbl_glsl_lengthSq(in float v)
{
return v * v;
}
float nbl_glsl_lengthSq(in vec2 v)
{
return dot(v, v);
}
float nbl_glsl_lengthSq(in vec3 v)
{
return dot(v, v);
}
float nbl_glsl_lengthSq(in vec4 v)
{
return dot(v, v);
}
vec3 nbl_glsl_reflect(in vec3 I, in vec3 N, in float NdotI)
{
return N * 2.0 * NdotI - I;
}
vec3 nbl_glsl_reflect(in vec3 I, in vec3 N)
{
float NdotI = dot(N, I);
return nbl_glsl_reflect(I, N, NdotI);
}
bool nbl_glsl_getOrientedEtas(out float orientedEta, out float rcpOrientedEta, in float NdotI, in float eta)
{
const bool backside = NdotI < 0.0;
const float rcpEta = 1.0 / eta;
orientedEta = backside ? rcpEta : eta;
rcpOrientedEta = backside ? eta : rcpEta;
return backside;
}
bool nbl_glsl_getOrientedEtas(out vec3 orientedEta, out vec3 rcpOrientedEta, in float NdotI, in vec3 eta)
{
const bool backside = NdotI < 0.0;
const vec3 rcpEta = vec3(1.0)/ eta;
orientedEta = backside ? rcpEta : eta;
rcpOrientedEta = backside ? eta : rcpEta;
return backside;
}
float nbl_glsl_refract_compute_NdotT2(in float NdotI2, in float rcpOrientedEta2)
{
return rcpOrientedEta2 * NdotI2 + 1.0 - rcpOrientedEta2;
}
float nbl_glsl_refract_compute_NdotT(in bool backside, in float NdotI2, in float rcpOrientedEta2)
{
const float abs_NdotT = sqrt(nbl_glsl_refract_compute_NdotT2(NdotI2, rcpOrientedEta2));
return backside ? abs_NdotT :(- abs_NdotT);
}
vec3 nbl_glsl_refract(in vec3 I, in vec3 N, in bool backside, in float NdotI, in float NdotI2, in float rcpOrientedEta, in float rcpOrientedEta2)
{
return N *(NdotI * rcpOrientedEta + nbl_glsl_refract_compute_NdotT(backside, NdotI2, rcpOrientedEta2))- rcpOrientedEta * I;
}
vec3 nbl_glsl_refract(in vec3 I, in vec3 N, in float NdotI, in float eta)
{
float orientedEta, rcpOrientedEta;
const bool backside = nbl_glsl_getOrientedEtas(orientedEta, rcpOrientedEta, NdotI, eta);
return nbl_glsl_refract(I, N, backside, NdotI, NdotI * NdotI, rcpOrientedEta, rcpOrientedEta * rcpOrientedEta);
}
vec3 nbl_glsl_refract(in vec3 I, in vec3 N, in float eta)
{
const float NdotI = dot(N, I);
return nbl_glsl_refract(I, N, NdotI, eta);
}
vec3 nbl_glsl_reflect_refract_impl(in bool _refract, in vec3 I, in vec3 N, in float NdotI, in float NdotTorR, in float rcpOrientedEta)
{
return N *(NdotI *(_refract ? rcpOrientedEta : 1.0)+ NdotTorR)- I *(_refract ? rcpOrientedEta : 1.0);
}
vec3 nbl_glsl_reflect_refract(in bool _refract, in vec3 I, in vec3 N, in bool backside, in float NdotI, in float NdotI2, in float rcpOrientedEta, in float rcpOrientedEta2)
{
const float NdotTorR = _refract ? nbl_glsl_refract_compute_NdotT(backside, NdotI2, rcpOrientedEta2): NdotI;
return nbl_glsl_reflect_refract_impl(_refract, I, N, NdotI, NdotTorR, rcpOrientedEta);
}
vec3 nbl_glsl_reflect_refract(in bool _refract, in vec3 I, in vec3 N, in float NdotI, in float NdotI2, in float eta)
{
float orientedEta, rcpOrientedEta;
const bool backside = nbl_glsl_getOrientedEtas(orientedEta, rcpOrientedEta, NdotI, eta);
return nbl_glsl_reflect_refract(_refract, I, N, backside, NdotI, NdotI2, rcpOrientedEta, rcpOrientedEta * rcpOrientedEta);
}
vec3 nbl_glsl_computeUnnormalizedMicrofacetNormal(in bool _refract, in vec3 V, in vec3 L, in float orientedEta)
{
const float etaFactor = (_refract ? orientedEta : 1.0);
const vec3 tmpH = V + L * etaFactor;
return _refract ? (- tmpH): tmpH;
}
vec3 nbl_glsl_computeMicrofacetNormal(in bool _refract, in vec3 V, in vec3 L, in float orientedEta)
{
const vec3 H = nbl_glsl_computeUnnormalizedMicrofacetNormal(_refract, V, L, orientedEta);
const float unnormRcpLen = inversesqrt(dot(H, H));
return H * unnormRcpLen;
}
bool nbl_glsl_isTransmissionPath(in float NdotV, in float NdotL)
{
return ((floatBitsToUint(NdotV)^ floatBitsToUint(NdotL))& 0x80000000u)!= 0u;
}
void nbl_glsl_sincos(in float theta, out float s, out float c)
{
c = cos(theta);
s = sqrt(1.0 - c * c);
s = theta < 0.0 ? - s : s;
}
mat2x3 nbl_glsl_frisvad(in vec3 n)
{
const float a = 1.0 /(1.0 + n . z);
const float b = - n . x * n . y * a;
return (n . z < - 0.9999999)? mat2x3(vec3(0.0, - 1.0, 0.0), vec3(- 1.0, 0.0, 0.0)): mat2x3(vec3(1.0 - n . x * n . x * a, b, - n . x), vec3(b, 1.0 - n . y * n . y * a, - n . y));
}
bool nbl_glsl_partitionRandVariable(in float leftProb, inout float xi, out float rcpChoiceProb)
{
const float NEXT_ULP_AFTER_UNITY = uintBitsToFloat(0x3f800001u);
const bool pickRight = xi >= leftProb * NEXT_ULP_AFTER_UNITY;
xi -= pickRight ? leftProb : 0.0;
rcpChoiceProb = 1.0 /(pickRight ? (1.0 - leftProb): leftProb);
xi *= rcpChoiceProb;
return pickRight;
}
float nbl_glsl_conditionalAbsOrMax(in bool cond, in float x, in float limit)
{
const float condAbs = uintBitsToFloat(floatBitsToUint(x)& uint(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
vec2 nbl_glsl_conditionalAbsOrMax(in bool cond, in vec2 x, in vec2 limit)
{
const vec2 condAbs = uintBitsToFloat(floatBitsToUint(x)& uvec2(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
vec3 nbl_glsl_conditionalAbsOrMax(in bool cond, in vec3 x, in vec3 limit)
{
const vec3 condAbs = uintBitsToFloat(floatBitsToUint(x)& uvec3(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
vec4 nbl_glsl_conditionalAbsOrMax(in bool cond, in vec4 x, in vec4 limit)
{
const vec4 condAbs = uintBitsToFloat(floatBitsToUint(x)& uvec4(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
uint nbl_glsl_rotl(in uint x, in uint k)
{
return (x << k)| (x >>(32u - k));
}
uint nbl_glsl_clz(in uint x)
{
return 31u - findMSB(x);
}
uint nbl_glsl_bitfieldOverwrite(in uint base, in uint value, in uint offset, in uint count)
{
return bitfieldInsert(base, value, int(offset), int(count));
}
uint nbl_glsl_bitfieldInsert_impl(in uint base, in uint shifted_masked_value, in uint lo, in uint count)
{
const uint hi = base ^ lo;
return (hi << count)| shifted_masked_value | lo;
}
uint nbl_glsl_bitfieldInsert(in uint base, uint value, in uint offset, in uint count)
{
const uint shifted_masked_value = (value &((0x1u << count)- 1u))<< offset;
return nbl_glsl_bitfieldInsert_impl(base, shifted_masked_value, base &((0x1u << offset)- 1u), count);
}
float nbl_glsl_getArccosSumofABC_minus_PI(in float cosA, in float cosB, in float cosC, in float sinA, in float sinB, in float sinC)
{
const bool something0 = cosA <(- cosB);
const float cosSumAB = cosA * cosB - sinA * sinB;
const bool something1 = cosSumAB <(- cosC);
const bool something2 = cosSumAB < cosC;
const float absArccosSumABC = acos(cosSumAB * cosC -(cosA * sinB + sinA * cosB)* sinC);
return ((something0 ? something2 : something1)? (- absArccosSumABC): absArccosSumABC)+(something0 || something1 ? nbl_glsl_PI :(- nbl_glsl_PI));
}
float nbl_glsl_applyChainRule1D(in float dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule1D(in vec2 dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule1D(in vec3 dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule1D(in vec4 dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in vec2 dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in vec2 dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in vec2 dGdR)
{
return dFdG * dGdR;
}
mat2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in mat2 dGdR)
{
return dFdG * dGdR;
}
mat2x3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in mat2 dGdR)
{
return dFdG * dGdR;
}
mat2x4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in mat2 dGdR)
{
return dFdG * dGdR;
}
mat3x2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in mat3x2 dGdR)
{
return dFdG * dGdR;
}
mat3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in mat3x2 dGdR)
{
return dFdG * dGdR;
}
mat3x4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in mat3x2 dGdR)
{
return dFdG * dGdR;
}
mat4x2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in mat4x2 dGdR)
{
return dFdG * dGdR;
}
mat4x3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in mat4x2 dGdR)
{
return dFdG * dGdR;
}
mat4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in mat4x2 dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in vec3 dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in vec3 dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in vec3 dGdR)
{
return dFdG * dGdR;
}
mat2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in mat2x3 dGdR)
{
return dFdG * dGdR;
}
mat2x3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in mat2x3 dGdR)
{
return dFdG * dGdR;
}
mat2x4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in mat2x3 dGdR)
{
return dFdG * dGdR;
}
mat3x2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in mat3 dGdR)
{
return dFdG * dGdR;
}
mat3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in mat3 dGdR)
{
return dFdG * dGdR;
}
mat3x4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in mat3 dGdR)
{
return dFdG * dGdR;
}
mat4x2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in mat4x3 dGdR)
{
return dFdG * dGdR;
}
mat4x3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in mat4x3 dGdR)
{
return dFdG * dGdR;
}
mat4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in mat4x3 dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in vec4 dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in vec4 dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in vec4 dGdR)
{
return dFdG * dGdR;
}
mat2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in mat2x4 dGdR)
{
return dFdG * dGdR;
}
mat2x3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in mat2x4 dGdR)
{
return dFdG * dGdR;
}
mat2x4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in mat2x4 dGdR)
{
return dFdG * dGdR;
}
mat3x2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in mat3x4 dGdR)
{
return dFdG * dGdR;
}
mat3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in mat3x4 dGdR)
{
return dFdG * dGdR;
}
mat3x4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in mat3x4 dGdR)
{
return dFdG * dGdR;
}
mat4x2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in mat4 dGdR)
{
return dFdG * dGdR;
}
mat4x3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in mat4 dGdR)
{
return dFdG * dGdR;
}
mat4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in mat4 dGdR)
{
return dFdG * dGdR;
}
#endif
#line 9 "nbl/builtin/glsl/utils/common.glsl"
struct nbl_glsl_SBasicViewParameters
{
mat4 MVP;
mat4x3 MV;
mat4x3 NormalMatAndEyePos;
};
mat3 nbl_glsl_SBasicViewParameters_GetNormalMat(in mat4x3 _NormalMatAndEyePos)
{
return mat3(_NormalMatAndEyePos);
}
vec3 nbl_glsl_SBasicViewParameters_GetEyePos(in mat4x3 _NormalMatAndEyePos)
{
return _NormalMatAndEyePos[3];
}
#endif
#line 44 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/common.glsl"
layout(set = 2, binding = 0, row_major, std140)uniform UBO
{
nbl_glsl_SBasicViewParameters params;
} CamData;
#line 1 "nbl/builtin/glsl/virtual_geometry/virtual_attribute_fetch.glsl"
#line 1 "nbl/builtin/glsl/virtual_geometry/virtual_attribute_fetch.glsl"
#ifndef _NBL_BUILTIN_GLSL_VIRTUAL_GEOMETRY_VIRTUAL_ATTRIBUTE_FETCH_INCLUDED_
#define _NBL_BUILTIN_GLSL_VIRTUAL_GEOMETRY_VIRTUAL_ATTRIBUTE_FETCH_INCLUDED_
#line 1 "nbl/builtin/glsl/format/decode.glsl"
#line 1 "nbl/builtin/glsl/format/decode.glsl"
#ifndef _NBL_BUILTIN_GLSL_FORMAT_DECODE_INCLUDED_
#define _NBL_BUILTIN_GLSL_FORMAT_DECODE_INCLUDED_
#line 1 "nbl/builtin/glsl/format/constants.glsl"
#line 1 "nbl/builtin/glsl/format/constants.glsl"
#ifndef _NBL_BUILTIN_GLSL_FORMAT_CONSTANTS_INCLUDED_
#define _NBL_BUILTIN_GLSL_FORMAT_CONSTANTS_INCLUDED_
#define nbl_glsl_RGB19E7_MANTISSA_BITS 19
#define nbl_glsl_RGB19E7_MANTISSA_MASK 0x7ffff
#define nbl_glsl_RGB19E7_EXPONENT_BITS 7
#define nbl_glsl_RGB19E7_EXP_BIAS 63
#define nbl_glsl_MAX_RGB19E7_EXP (nbl_glsl_RGB19E7_EXP_BIAS + 1)
#define nbl_glsl_MAX_RGB19E7_MANTISSA_VALUES (0x1 << nbl_glsl_RGB19E7_MANTISSA_BITS)
#define nbl_glsl_MAX_RGB19E7_MANTISSA (nbl_glsl_MAX_RGB19E7_MANTISSA_VALUES - 1)
#define nbl_glsl_MAX_RGB19E7 float(nbl_glsl_MAX_RGB19E7_MANTISSA)/ float(nbl_glsl_MAX_RGB19E7_MANTISSA_VALUES)* exp2(float(nbl_glsl_MAX_RGB19E7_EXP))
#define nbl_glsl_RGB19E7_COMPONENT_INDICES ivec4(0, 0, 1, 1)
#define nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS ivec4(0, nbl_glsl_RGB19E7_MANTISSA_BITS,(2 * nbl_glsl_RGB19E7_MANTISSA_BITS)& 31,(3 * nbl_glsl_RGB19E7_MANTISSA_BITS)& 31)
#define nbl_glsl_RGB19E7_G_COMPONENT_SPLIT (32 - nbl_glsl_RGB19E7_MANTISSA_BITS)
#define nbl_glsl_RGB18E7S3_MANTISSA_BITS 18
#define nbl_glsl_RGB18E7S3_EXPONENT_BITS nbl_glsl_RGB19E7_EXPONENT_BITS
#define nbl_glsl_RGB18E7S3_EXP_BIAS nbl_glsl_RGB19E7_EXP_BIAS
#define nbl_glsl_MAX_RGB18E7S3_EXP (nbl_glsl_RGB18E7S3_EXP_BIAS + 1)
#define nbl_glsl_MAX_RGB18E7S3_MANTISSA_VALUES (0x1 << nbl_glsl_RGB18E7S3_MANTISSA_BITS)
#define nbl_glsl_MAX_RGB18E7S3_MANTISSA (nbl_glsl_MAX_RGB18E7S3_MANTISSA_VALUES - 1)
#define nbl_glsl_MAX_RGB18E7S3 float(nbl_glsl_MAX_RGB18E7S3_MANTISSA)/ float(nbl_glsl_MAX_RGB18E7S3_MANTISSA_VALUES)* exp2(float(nbl_glsl_MAX_RGB18E7S3_EXP))
#define nbl_glsl_RGB18E7S3_COMPONENT_INDICES nbl_glsl_RGB19E7_COMPONENT_INDICES
#define nbl_glsl_RGB18E7S3_COMPONENT_BITOFFSETS ivec4(0, nbl_glsl_RGB18E7S3_MANTISSA_BITS,(2 * nbl_glsl_RGB18E7S3_MANTISSA_BITS)& 31,(3 * nbl_glsl_RGB18E7S3_MANTISSA_BITS)& 31)
#define nbl_glsl_RGB18E7S3_G_COMPONENT_SPLIT (32 - nbl_glsl_RGB18E7S3_MANTISSA_BITS)
#endif
#line 5 "nbl/builtin/glsl/format/decode.glsl"
#line 1 "nbl/builtin/glsl/math/quaternions.glsl"
#line 1 "nbl/builtin/glsl/math/quaternions.glsl"
#ifndef _NBL_BUILTIN_GLSL_MATH_QUATERNIONS_INCLUDED_
#define _NBL_BUILTIN_GLSL_MATH_QUATERNIONS_INCLUDED_
#line 1 "nbl/builtin/glsl/math/functions.glsl"
#line 1 "nbl/builtin/glsl/math/functions.glsl"
#ifndef _NBL_MATH_FUNCTIONS_INCLUDED_
#define _NBL_MATH_FUNCTIONS_INCLUDED_
#line 1 "nbl/builtin/glsl/math/constants.glsl"
#line 1 "nbl/builtin/glsl/math/constants.glsl"
#ifndef _NBL_MATH_CONSTANTS_INCLUDED_
#define _NBL_MATH_CONSTANTS_INCLUDED_
#line 1 "nbl/builtin/glsl/limits/numeric.glsl"
#line 1 "nbl/builtin/glsl/limits/numeric.glsl"
#ifndef _NBL_LIMITS_NUMERIC_INCLUDED_
#define _NBL_LIMITS_NUMERIC_INCLUDED_
#ifndef INT_MIN
#define INT_MIN - 2147483648
#endif
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef UINT_MIN
#define UINT_MIN 0u
#endif
#ifndef UINT_MAX
#define UINT_MAX 4294967295u
#endif
#ifndef FLT_MIN
#define FLT_MIN 1.175494351e-38
#endif
#ifndef FLT_MAX
#define FLT_MAX 3.402823466e+38
#endif
#ifndef FLT_INF
#define FLT_INF (1.0 / 0.0)
#endif
#endif
#line 9 "nbl/builtin/glsl/math/constants.glsl"
#define nbl_glsl_PI 3.14159265359
#define nbl_glsl_RECIPROCAL_PI 0.318309886183
#define nbl_glsl_SQRT_RECIPROCAL_PI 0.56418958354
#define nbl_glsl_FLT_INF float(1.0 / 0.0)
#ifndef nbl_glsl_FLT_NAN
#define nbl_glsl_FLT_NAN uintBitsToFloat(0xFFffFFffu)
#endif
#endif
#line 9 "nbl/builtin/glsl/math/functions.glsl"
int nbl_glsl_dot(in ivec2 a, in ivec2 b){ return a . x * b . x + a . y * b . y;}
uint nbl_glsl_dot(in uvec2 a, in uvec2 b){ return a . x * b . x + a . y * b . y;}
int nbl_glsl_dot(in ivec3 a, in ivec3 b){ return a . x * b . x + a . y * b . y + a . z * b . z;}
uint nbl_glsl_dot(in uvec3 a, in uvec3 b){ return a . x * b . x + a . y * b . y + a . z * b . z;}
int nbl_glsl_dot(in ivec4 a, in ivec4 b){ return a . x * b . x + a . y * b . y + a . z * b . z + a . w * b . w;}
uint nbl_glsl_dot(in uvec4 a, in uvec4 b){ return a . x * b . x + a . y * b . y + a . z * b . z + a . w * b . w;}
float nbl_glsl_erf(in float _x)
{
const float a1 = 0.254829592;
const float a2 = - 0.284496736;
const float a3 = 1.421413741;
const float a4 = - 1.453152027;
const float a5 = 1.061405429;
const float p = 0.3275911;
float sign = sign(_x);
float x = abs(_x);
float t = 1.0 / (1.0 + p * x);
float y = 1.0 - (((((a5 * t + a4)* t)+ a3)* t + a2)* t + a1)* t * exp(- x * x);
return sign * y;
}
float nbl_glsl_erfInv(in float _x)
{
float x = clamp(_x, - 0.99999, 0.99999);
float w = - log((1.0 - x)* (1.0 + x));
float p;
if (w < 5.0)
{
w -= 2.5;
p = 2.81022636e-08;
p = 3.43273939e-07 + p * w;
p = - 3.5233877e-06 + p * w;
p = - 4.39150654e-06 + p * w;
p = 0.00021858087 + p * w;
p = - 0.00125372503 + p * w;
p = - 0.00417768164 + p * w;
p = 0.246640727 + p * w;
p = 1.50140941 + p * w;
}
else
{
w = sqrt(w)- 3.0;
p = - 0.000200214257;
p = 0.000100950558 + p * w;
p = 0.00134934322 + p * w;
p = - 0.00367342844 + p * w;
p = 0.00573950773 + p * w;
p = - 0.0076224613 + p * w;
p = 0.00943887047 + p * w;
p = 1.00167406 + p * w;
p = 2.83297682 + p * w;
}
return p * x;
}
float nbl_glsl_lengthManhattan(float v)
{
return abs(v);
}
float nbl_glsl_lengthManhattan(vec2 v)
{
v = abs(v);
return v . x + v . y;
}
float nbl_glsl_lengthManhattan(vec3 v)
{
v = abs(v);
return v . x + v . y + v . z;
}
float nbl_glsl_lengthManhattan(vec4 v)
{
v = abs(v);
return v . x + v . y + v . z + v . w;
}
float nbl_glsl_lengthSq(in float v)
{
return v * v;
}
float nbl_glsl_lengthSq(in vec2 v)
{
return dot(v, v);
}
float nbl_glsl_lengthSq(in vec3 v)
{
return dot(v, v);
}
float nbl_glsl_lengthSq(in vec4 v)
{
return dot(v, v);
}
vec3 nbl_glsl_reflect(in vec3 I, in vec3 N, in float NdotI)
{
return N * 2.0 * NdotI - I;
}
vec3 nbl_glsl_reflect(in vec3 I, in vec3 N)
{
float NdotI = dot(N, I);
return nbl_glsl_reflect(I, N, NdotI);
}
bool nbl_glsl_getOrientedEtas(out float orientedEta, out float rcpOrientedEta, in float NdotI, in float eta)
{
const bool backside = NdotI < 0.0;
const float rcpEta = 1.0 / eta;
orientedEta = backside ? rcpEta : eta;
rcpOrientedEta = backside ? eta : rcpEta;
return backside;
}
bool nbl_glsl_getOrientedEtas(out vec3 orientedEta, out vec3 rcpOrientedEta, in float NdotI, in vec3 eta)
{
const bool backside = NdotI < 0.0;
const vec3 rcpEta = vec3(1.0)/ eta;
orientedEta = backside ? rcpEta : eta;
rcpOrientedEta = backside ? eta : rcpEta;
return backside;
}
float nbl_glsl_refract_compute_NdotT2(in float NdotI2, in float rcpOrientedEta2)
{
return rcpOrientedEta2 * NdotI2 + 1.0 - rcpOrientedEta2;
}
float nbl_glsl_refract_compute_NdotT(in bool backside, in float NdotI2, in float rcpOrientedEta2)
{
const float abs_NdotT = sqrt(nbl_glsl_refract_compute_NdotT2(NdotI2, rcpOrientedEta2));
return backside ? abs_NdotT :(- abs_NdotT);
}
vec3 nbl_glsl_refract(in vec3 I, in vec3 N, in bool backside, in float NdotI, in float NdotI2, in float rcpOrientedEta, in float rcpOrientedEta2)
{
return N *(NdotI * rcpOrientedEta + nbl_glsl_refract_compute_NdotT(backside, NdotI2, rcpOrientedEta2))- rcpOrientedEta * I;
}
vec3 nbl_glsl_refract(in vec3 I, in vec3 N, in float NdotI, in float eta)
{
float orientedEta, rcpOrientedEta;
const bool backside = nbl_glsl_getOrientedEtas(orientedEta, rcpOrientedEta, NdotI, eta);
return nbl_glsl_refract(I, N, backside, NdotI, NdotI * NdotI, rcpOrientedEta, rcpOrientedEta * rcpOrientedEta);
}
vec3 nbl_glsl_refract(in vec3 I, in vec3 N, in float eta)
{
const float NdotI = dot(N, I);
return nbl_glsl_refract(I, N, NdotI, eta);
}
vec3 nbl_glsl_reflect_refract_impl(in bool _refract, in vec3 I, in vec3 N, in float NdotI, in float NdotTorR, in float rcpOrientedEta)
{
return N *(NdotI *(_refract ? rcpOrientedEta : 1.0)+ NdotTorR)- I *(_refract ? rcpOrientedEta : 1.0);
}
vec3 nbl_glsl_reflect_refract(in bool _refract, in vec3 I, in vec3 N, in bool backside, in float NdotI, in float NdotI2, in float rcpOrientedEta, in float rcpOrientedEta2)
{
const float NdotTorR = _refract ? nbl_glsl_refract_compute_NdotT(backside, NdotI2, rcpOrientedEta2): NdotI;
return nbl_glsl_reflect_refract_impl(_refract, I, N, NdotI, NdotTorR, rcpOrientedEta);
}
vec3 nbl_glsl_reflect_refract(in bool _refract, in vec3 I, in vec3 N, in float NdotI, in float NdotI2, in float eta)
{
float orientedEta, rcpOrientedEta;
const bool backside = nbl_glsl_getOrientedEtas(orientedEta, rcpOrientedEta, NdotI, eta);
return nbl_glsl_reflect_refract(_refract, I, N, backside, NdotI, NdotI2, rcpOrientedEta, rcpOrientedEta * rcpOrientedEta);
}
vec3 nbl_glsl_computeUnnormalizedMicrofacetNormal(in bool _refract, in vec3 V, in vec3 L, in float orientedEta)
{
const float etaFactor = (_refract ? orientedEta : 1.0);
const vec3 tmpH = V + L * etaFactor;
return _refract ? (- tmpH): tmpH;
}
vec3 nbl_glsl_computeMicrofacetNormal(in bool _refract, in vec3 V, in vec3 L, in float orientedEta)
{
const vec3 H = nbl_glsl_computeUnnormalizedMicrofacetNormal(_refract, V, L, orientedEta);
const float unnormRcpLen = inversesqrt(dot(H, H));
return H * unnormRcpLen;
}
bool nbl_glsl_isTransmissionPath(in float NdotV, in float NdotL)
{
return ((floatBitsToUint(NdotV)^ floatBitsToUint(NdotL))& 0x80000000u)!= 0u;
}
void nbl_glsl_sincos(in float theta, out float s, out float c)
{
c = cos(theta);
s = sqrt(1.0 - c * c);
s = theta < 0.0 ? - s : s;
}
mat2x3 nbl_glsl_frisvad(in vec3 n)
{
const float a = 1.0 /(1.0 + n . z);
const float b = - n . x * n . y * a;
return (n . z < - 0.9999999)? mat2x3(vec3(0.0, - 1.0, 0.0), vec3(- 1.0, 0.0, 0.0)): mat2x3(vec3(1.0 - n . x * n . x * a, b, - n . x), vec3(b, 1.0 - n . y * n . y * a, - n . y));
}
bool nbl_glsl_partitionRandVariable(in float leftProb, inout float xi, out float rcpChoiceProb)
{
const float NEXT_ULP_AFTER_UNITY = uintBitsToFloat(0x3f800001u);
const bool pickRight = xi >= leftProb * NEXT_ULP_AFTER_UNITY;
xi -= pickRight ? leftProb : 0.0;
rcpChoiceProb = 1.0 /(pickRight ? (1.0 - leftProb): leftProb);
xi *= rcpChoiceProb;
return pickRight;
}
float nbl_glsl_conditionalAbsOrMax(in bool cond, in float x, in float limit)
{
const float condAbs = uintBitsToFloat(floatBitsToUint(x)& uint(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
vec2 nbl_glsl_conditionalAbsOrMax(in bool cond, in vec2 x, in vec2 limit)
{
const vec2 condAbs = uintBitsToFloat(floatBitsToUint(x)& uvec2(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
vec3 nbl_glsl_conditionalAbsOrMax(in bool cond, in vec3 x, in vec3 limit)
{
const vec3 condAbs = uintBitsToFloat(floatBitsToUint(x)& uvec3(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
vec4 nbl_glsl_conditionalAbsOrMax(in bool cond, in vec4 x, in vec4 limit)
{
const vec4 condAbs = uintBitsToFloat(floatBitsToUint(x)& uvec4(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
uint nbl_glsl_rotl(in uint x, in uint k)
{
return (x << k)| (x >>(32u - k));
}
uint nbl_glsl_clz(in uint x)
{
return 31u - findMSB(x);
}
uint nbl_glsl_bitfieldOverwrite(in uint base, in uint value, in uint offset, in uint count)
{
return bitfieldInsert(base, value, int(offset), int(count));
}
uint nbl_glsl_bitfieldInsert_impl(in uint base, in uint shifted_masked_value, in uint lo, in uint count)
{
const uint hi = base ^ lo;
return (hi << count)| shifted_masked_value | lo;
}
uint nbl_glsl_bitfieldInsert(in uint base, uint value, in uint offset, in uint count)
{
const uint shifted_masked_value = (value &((0x1u << count)- 1u))<< offset;
return nbl_glsl_bitfieldInsert_impl(base, shifted_masked_value, base &((0x1u << offset)- 1u), count);
}
float nbl_glsl_getArccosSumofABC_minus_PI(in float cosA, in float cosB, in float cosC, in float sinA, in float sinB, in float sinC)
{
const bool something0 = cosA <(- cosB);
const float cosSumAB = cosA * cosB - sinA * sinB;
const bool something1 = cosSumAB <(- cosC);
const bool something2 = cosSumAB < cosC;
const float absArccosSumABC = acos(cosSumAB * cosC -(cosA * sinB + sinA * cosB)* sinC);
return ((something0 ? something2 : something1)? (- absArccosSumABC): absArccosSumABC)+(something0 || something1 ? nbl_glsl_PI :(- nbl_glsl_PI));
}
float nbl_glsl_applyChainRule1D(in float dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule1D(in vec2 dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule1D(in vec3 dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule1D(in vec4 dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in vec2 dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in vec2 dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in vec2 dGdR)
{
return dFdG * dGdR;
}
mat2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in mat2 dGdR)
{
return dFdG * dGdR;
}
mat2x3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in mat2 dGdR)
{
return dFdG * dGdR;
}
mat2x4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in mat2 dGdR)
{
return dFdG * dGdR;
}
mat3x2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in mat3x2 dGdR)
{
return dFdG * dGdR;
}
mat3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in mat3x2 dGdR)
{
return dFdG * dGdR;
}
mat3x4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in mat3x2 dGdR)
{
return dFdG * dGdR;
}
mat4x2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in mat4x2 dGdR)
{
return dFdG * dGdR;
}
mat4x3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in mat4x2 dGdR)
{
return dFdG * dGdR;
}
mat4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in mat4x2 dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in vec3 dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in vec3 dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in vec3 dGdR)
{
return dFdG * dGdR;
}
mat2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in mat2x3 dGdR)
{
return dFdG * dGdR;
}
mat2x3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in mat2x3 dGdR)
{
return dFdG * dGdR;
}
mat2x4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in mat2x3 dGdR)
{
return dFdG * dGdR;
}
mat3x2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in mat3 dGdR)
{
return dFdG * dGdR;
}
mat3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in mat3 dGdR)
{
return dFdG * dGdR;
}
mat3x4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in mat3 dGdR)
{
return dFdG * dGdR;
}
mat4x2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in mat4x3 dGdR)
{
return dFdG * dGdR;
}
mat4x3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in mat4x3 dGdR)
{
return dFdG * dGdR;
}
mat4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in mat4x3 dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in vec4 dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in vec4 dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in vec4 dGdR)
{
return dFdG * dGdR;
}
mat2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in mat2x4 dGdR)
{
return dFdG * dGdR;
}
mat2x3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in mat2x4 dGdR)
{
return dFdG * dGdR;
}
mat2x4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in mat2x4 dGdR)
{
return dFdG * dGdR;
}
mat3x2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in mat3x4 dGdR)
{
return dFdG * dGdR;
}
mat3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in mat3x4 dGdR)
{
return dFdG * dGdR;
}
mat3x4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in mat3x4 dGdR)
{
return dFdG * dGdR;
}
mat4x2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in mat4 dGdR)
{
return dFdG * dGdR;
}
mat4x3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in mat4 dGdR)
{
return dFdG * dGdR;
}
mat4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in mat4 dGdR)
{
return dFdG * dGdR;
}
#endif
#line 7 "nbl/builtin/glsl/math/quaternions.glsl"
struct nbl_glsl_quaternion_t
{
vec4 data;
};
nbl_glsl_quaternion_t nbl_glsl_quaternion_t_constructFromTruncated(in vec3 first3Components)
{
nbl_glsl_quaternion_t quat;
quat . data . xyz = first3Components;
quat . data . w = sqrt(1.0 - dot(first3Components, first3Components));
return quat;
}
nbl_glsl_quaternion_t nbl_glsl_quaternion_t_lerp(in nbl_glsl_quaternion_t start, in nbl_glsl_quaternion_t end, in float fraction, in float totalPseudoAngle)
{
const uint negationMask = floatBitsToUint(totalPseudoAngle)& 0x80000000u;
const vec4 adjEnd = uintBitsToFloat(floatBitsToUint(end . data)^ negationMask);
nbl_glsl_quaternion_t quat;
quat . data = mix(start . data, adjEnd, fraction);
return quat;
}
nbl_glsl_quaternion_t nbl_glsl_quaternion_t_lerp(in nbl_glsl_quaternion_t start, in nbl_glsl_quaternion_t end, in float fraction)
{
return nbl_glsl_quaternion_t_lerp(start, end, fraction, dot(start . data, end . data));
}
float nbl_glsl_quaternion_t_flerp_impl_adj_interpolant(in float angle, in float fraction, in float interpolantPrecalcTerm2, in float interpolantPrecalcTerm3)
{
const float A = 1.0904f + angle * (- 3.2452f + angle * (3.55645f - angle * 1.43519f));
const float B = 0.848013f + angle * (- 1.06021f + angle * 0.215638f);
const float k = A * interpolantPrecalcTerm2 + B;
return fraction + interpolantPrecalcTerm3 * k;
}
nbl_glsl_quaternion_t nbl_glsl_quaternion_t_flerp(in nbl_glsl_quaternion_t start, in nbl_glsl_quaternion_t end, in float fraction)
{
const float pseudoAngle = dot(start . data, end . data);
const float interpolantPrecalcTerm = fraction - 0.5f;
const float interpolantPrecalcTerm3 = fraction * interpolantPrecalcTerm *(fraction - 1.f);
const float adjFrac = nbl_glsl_quaternion_t_flerp_impl_adj_interpolant(abs(pseudoAngle), fraction, interpolantPrecalcTerm * interpolantPrecalcTerm, interpolantPrecalcTerm3);
nbl_glsl_quaternion_t quat = nbl_glsl_quaternion_t_lerp(start, end, adjFrac, pseudoAngle);
quat . data = normalize(quat . data);
return quat;
}
mat3 nbl_glsl_quaternion_t_constructMatrix(in nbl_glsl_quaternion_t quat)
{
mat3 mat;
mat[0]= quat . data . yzx * quat . data . ywz + quat . data . zxy * quat . data . zyw * vec3(1.f, 1.f, - 1.f);
mat[1]= quat . data . yzx * quat . data . xzw + quat . data . zxy * quat . data . wxz * vec3(- 1.f, 1.f, 1.f);
mat[2]= quat . data . yzx * quat . data . wyx + quat . data . zxy * quat . data . xwy * vec3(1.f, - 1.f, 1.f);
mat[0][0]= 0.5f - mat[0][0];
mat[1][1]= 0.5f - mat[1][1];
mat[2][2]= 0.5f - mat[2][2];
mat *= 2.f;
return mat;
}
vec3 nbl_glsl_slerp_impl_impl(in vec3 start, in vec3 preScaledWaypoint, float cosAngleFromStart)
{
vec3 planeNormal = cross(start, preScaledWaypoint);
cosAngleFromStart *= 0.5;
const float sinAngle = sqrt(0.5 - cosAngleFromStart);
const float cosAngle = sqrt(0.5 + cosAngleFromStart);
planeNormal *= sinAngle;
const vec3 precompPart = cross(planeNormal, start)* 2.0;
return start + precompPart * cosAngle + cross(planeNormal, precompPart);
}
#endif
#line 6 "nbl/builtin/glsl/format/decode.glsl"
vec3 nbl_glsl_decodeRGB19E7(in uvec2 x)
{
int exp = int(bitfieldExtract(x[nbl_glsl_RGB19E7_COMPONENT_INDICES[3]], nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[3], nbl_glsl_RGB19E7_EXPONENT_BITS)- nbl_glsl_RGB19E7_EXP_BIAS - nbl_glsl_RGB19E7_MANTISSA_BITS);
float scale = exp2(float(exp));
vec3 v;
v . x = float(bitfieldExtract(x[nbl_glsl_RGB19E7_COMPONENT_INDICES[0]], nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[0], nbl_glsl_RGB19E7_MANTISSA_BITS));
v . y = float(bitfieldInsert(
bitfieldExtract(x[nbl_glsl_RGB19E7_COMPONENT_INDICES[1]], nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[1], nbl_glsl_RGB19E7_G_COMPONENT_SPLIT),
bitfieldExtract(x[nbl_glsl_RGB19E7_COMPONENT_INDICES[2]], 0, nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[2]),
nbl_glsl_RGB19E7_G_COMPONENT_SPLIT,
nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[2]
));
v . z = float(bitfieldExtract(x[nbl_glsl_RGB19E7_COMPONENT_INDICES[2]], nbl_glsl_RGB19E7_COMPONENT_BITOFFSETS[2], nbl_glsl_RGB19E7_MANTISSA_BITS));
return v * scale;
}
vec3 nbl_glsl_decodeRGB18E7S3(in uvec2 x)
{
int exp = int(bitfieldExtract(x[nbl_glsl_RGB18E7S3_COMPONENT_INDICES[3]], nbl_glsl_RGB18E7S3_COMPONENT_BITOFFSETS[3], nbl_glsl_RGB18E7S3_EXPONENT_BITS)- nbl_glsl_RGB18E7S3_EXP_BIAS - nbl_glsl_RGB18E7S3_MANTISSA_BITS);
float scale = exp2(float(exp));
vec3 v;
v . x = float(bitfieldExtract(x[nbl_glsl_RGB18E7S3_COMPONENT_INDICES[0]], nbl_glsl_RGB18E7S3_COMPONENT_BITOFFSETS[0], nbl_glsl_RGB18E7S3_MANTISSA_BITS));
v . y = float(bitfieldInsert(
bitfieldExtract(x[nbl_glsl_RGB18E7S3_COMPONENT_INDICES[1]], nbl_glsl_RGB18E7S3_COMPONENT_BITOFFSETS[1], nbl_glsl_RGB18E7S3_G_COMPONENT_SPLIT),
bitfieldExtract(x[nbl_glsl_RGB18E7S3_COMPONENT_INDICES[2]], 0, nbl_glsl_RGB18E7S3_COMPONENT_BITOFFSETS[2]),
nbl_glsl_RGB18E7S3_G_COMPONENT_SPLIT,
nbl_glsl_RGB18E7S3_COMPONENT_BITOFFSETS[2]
));
v . z = float(bitfieldExtract(x[nbl_glsl_RGB18E7S3_COMPONENT_INDICES[2]], nbl_glsl_RGB18E7S3_COMPONENT_BITOFFSETS[2], nbl_glsl_RGB18E7S3_MANTISSA_BITS));
uvec3 signs = x . yyy << uvec3(2u, 1u, 0u);
signs &= 0x80000000u;
v = uintBitsToFloat(floatBitsToUint(v)^ signs);
return v * scale;
}
vec4 nbl_glsl_decodeRGB10A2_UNORM(in uint x)
{
const uvec3 rgbMask = uvec3(0x3ffu);
const uvec4 shifted = uvec4(x, uvec3(x)>> uvec3(10, 20, 30));
return vec4(vec3(shifted . rgb & rgbMask), shifted . a)/ vec4(vec3(rgbMask), 3.0);
}
vec4 nbl_glsl_decodeRGB10A2_SNORM(in uint x)
{
const ivec4 shifted = ivec4(x, uvec3(x)>> uvec3(10u, 20u, 30u));
const ivec4 rgbaBias = ivec4(ivec3(0x200u), 0x2u);
const ivec4 halfMask = rgbaBias - ivec4(1);
const ivec4 signed = (-(shifted & rgbaBias))| (shifted & halfMask);
return max(vec4(signed)/ vec4(halfMask), vec4(- 1.0));
}
nbl_glsl_quaternion_t nbl_glsl_decode8888Quaternion(in uint x)
{
nbl_glsl_quaternion_t quat;
quat . data = normalize(unpackSnorm4x8(x));
return quat;
}
nbl_glsl_quaternion_t nbl_glsl_decode1010102Quaternion(in uint x)
{
const uvec3 rgbMask = uvec3(0x3ffu);
const uvec4 shifted = uvec4(x, uvec3(x)>> uvec3(10, 20, 30));
const uint maxCompIx = shifted[3];
const ivec3 maxVal = ivec3(0x1ff);
const ivec3 unnorm = max(- maxVal, ivec3(shifted . rgb & rgbMask)- ivec3(maxVal + 1));
const vec3 smallest3Components = vec3(unnorm)* inversesqrt(2.f)/ vec3(maxVal);
nbl_glsl_quaternion_t quat;
quat . data[maxCompIx > 0u ? 0 : 1]= smallest3Components[0];
quat . data[maxCompIx > 1u ? 1 : 2]= smallest3Components[1];
quat . data[maxCompIx > 2u ? 2 : 3]= smallest3Components[2];
quat . data[maxCompIx]= sqrt(1.0 - dot(smallest3Components, smallest3Components));
return quat;
}
#endif
#line 9 "nbl/builtin/glsl/virtual_geometry/virtual_attribute_fetch.glsl"
#line 1 "nbl/builtin/glsl/virtual_geometry/virtual_attribute.glsl"
#line 1 "nbl/builtin/glsl/virtual_geometry/virtual_attribute.glsl"
#ifndef _NBL_BUILTIN_GLSL_VIRTUAL_GEOMETRY_VIRTUAL_ATTRIBUTE_INCLUDED_
#define _NBL_BUILTIN_GLSL_VIRTUAL_GEOMETRY_VIRTUAL_ATTRIBUTE_INCLUDED_
#line 1 "nbl/builtin/glsl/virtual_geometry/descriptors.glsl"
#line 1 "nbl/builtin/glsl/virtual_geometry/descriptors.glsl"
#ifndef _NBL_BUILTIN_GLSL_VIRTUAL_GEOMETRY_DESCRIPTORS_INCLUDED_
#define _NBL_BUILTIN_GLSL_VIRTUAL_GEOMETRY_DESCRIPTORS_INCLUDED_
#ifndef _NBL_VG_USE_SSBO
#ifndef _NBL_VG_DESCRIPTOR_SET
#define _NBL_VG_DESCRIPTOR_SET 0
#endif
#ifndef _NBL_VG_UINT_BUFFERS
#define _NBL_VG_UINT_BUFFERS_BINDING 0
#define _NBL_VG_UINT_BUFFERS_COUNT 1
#endif
#ifndef _NBL_VG_FLOAT_BUFFERS
#define _NBL_VG_FLOAT_BUFFERS_BINDING 1
#define _NBL_VG_FLOAT_BUFFERS_COUNT 4
#endif
#ifndef _NBL_VG_INT_BUFFERS
#define _NBL_VG_INT_BUFFERS_BINDING 2
#define _NBL_VG_INT_BUFFERS_COUNT 0
#endif
#if _NBL_VG_UINT_BUFFERS_COUNT
layout(set = _NBL_VG_DESCRIPTOR_SET, binding = _NBL_VG_UINT_BUFFERS_BINDING)uniform usamplerBuffer MeshPackedDataUintSample[_NBL_VG_UINT_BUFFERS_COUNT];
uint nbl_glsl_VG_fetchTriangleVertexIndex(in uint baseVertex, in uint triangleVx)
{
return texelFetch(MeshPackedDataUintSample[_NBL_VG_UINT_BUFFERS_COUNT - 1u], int(baseVertex + triangleVx)). x;
}
#endif
#if _NBL_VG_FLOAT_BUFFERS_COUNT
layout(set = _NBL_VG_DESCRIPTOR_SET, binding = _NBL_VG_FLOAT_BUFFERS_BINDING)uniform samplerBuffer MeshPackedDataFloatSample[_NBL_VG_FLOAT_BUFFERS_COUNT];
#endif
#if _NBL_VG_INT_BUFFERS_COUNT
layout(set = _NBL_VG_DESCRIPTOR_SET, binding = _NBL_VG_INT_BUFFERS_BINDING)uniform isamplerBuffer MeshPackedDataIntSample[_NBL_VG_INT_BUFFERS_COUNT];
#endif
#else
#ifndef _NBL_VG_SSBO_DESCRIPTOR_SET
#define _NBL_VG_SSBO_DESCRIPTOR_SET 0
#endif
#ifndef _NBL_VG_USE_SSBO_UINT
#ifndef _NBL_VG_SSBO_UINT_BINDING
#define _NBL_VG_SSBO_UINT_BINDING 0
#endif
#endif
#ifndef _NBL_VG_USE_SSBO_UVEC2
#ifndef _NBL_VG_SSBO_UVEC2_BINDING
#define _NBL_VG_SSBO_UVEC2_BINDING 1
#endif
#endif
#ifndef _NBL_VG_USE_SSBO_UVEC3
#ifndef _NBL_VG_SSBO_UVEC3_BINDING
#define _NBL_VG_SSBO_UVEC3_BINDING 2
#endif
#endif
#ifndef _NBL_VG_USE_SSBO_UVEC4
#ifndef _NBL_VG_SSBO_UVEC4_BINDING
#define _NBL_VG_SSBO_UVEC4_BINDING 3
#endif
#endif
#ifndef _NBL_VG_USE_SSBO_INDEX
#ifndef _NBL_VG_SSBO_INDEX_BINDING
#define _NBL_VG_SSBO_INDEX_BINDING 4
#endif
#endif
#ifdef _NBL_VG_USE_SSBO_UINT
layout(set = _NBL_VG_SSBO_DESCRIPTOR_SET, binding = _NBL_VG_SSBO_UINT_BINDING, std430)readonly buffer MeshPackedDataAsUint
{
uint attribData[];
} meshPackedDataUintBuffer;
#endif
#ifdef _NBL_VG_USE_SSBO_UVEC2
layout(set = _NBL_VG_SSBO_DESCRIPTOR_SET, binding = _NBL_VG_SSBO_UVEC2_BINDING, std430)readonly buffer MeshPackedDataAsUvec2
{
uvec2 attribData[];
} meshPackedDataUvec2Buffer;
#endif
#ifdef _NBL_VG_USE_SSBO_UVEC3
struct Packed_uvec3_t
{
uint x, y, z;
};
layout(set = _NBL_VG_SSBO_DESCRIPTOR_SET, binding = _NBL_VG_SSBO_UVEC3_BINDING, std430)readonly buffer MeshPackedDataAsUvec3
{
Packed_uvec3_t attribData[];
} meshPackedDataUvec3Buffer;
#endif
#ifdef _NBL_VG_USE_SSBO_UVEC4
layout(set = _NBL_VG_SSBO_DESCRIPTOR_SET, binding = _NBL_VG_SSBO_UVEC4_BINDING, std430)readonly buffer MeshPackedDataAsUvec4
{
uvec4 attribData[];
} meshPackedDataUvec4Buffer;
#endif
#ifdef _NBL_VG_USE_SSBO_INDEX
layout(set = _NBL_VG_SSBO_DESCRIPTOR_SET, binding = _NBL_VG_SSBO_INDEX_BINDING, std430)readonly buffer TrianglePackedData
{
uint16_t indices[];
} trianglePackedData;
uint nbl_glsl_VG_fetchTriangleVertexIndex(in uint baseVertex, in uint triangleVx)
{
return uint(trianglePackedData . indices[baseVertex + triangleVx]);
}
#endif
#endif
#endif
#line 9 "nbl/builtin/glsl/virtual_geometry/virtual_attribute.glsl"
#define nbl_glsl_VG_VirtualAttributePacked_t uint
#ifndef _NBL_VG_USE_SSBO
struct nbl_glsl_VG_VirtualAttribute
{
uint binding;
int offset;
};
#else
#define nbl_glsl_VG_VirtualAttribute uint
#endif
nbl_glsl_VG_VirtualAttribute nbl_glsl_VG_unpackVirtualAttribute(in nbl_glsl_VG_VirtualAttributePacked_t vaPacked)
{
#ifndef _NBL_VG_USE_SSBO
nbl_glsl_VG_VirtualAttribute result;
result . binding = vaPacked >> 28;
result . offset = int(vaPacked & 0x0FFFFFFF);
return result;
#else
return vaPacked & 0x0FFFFFFF;
#endif
}
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC4))|| defined(_NBL_VG_FLOAT_BUFFERS_COUNT)
vec4 nbl_glsl_VG_attribFetch4f(in nbl_glsl_VG_VirtualAttributePacked_t attr, uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
uvec4 attrLocal = meshPackedDataUvec4Buffer . attribData[va + vertexID];
return vec4(uintBitsToFloat(attrLocal . x), uintBitsToFloat(attrLocal . y), uintBitsToFloat(attrLocal . z), uintBitsToFloat(attrLocal . w));
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataFloatSample[va . binding], addr);
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC3))|| _NBL_VG_FLOAT_BUFFERS_COUNT
vec3 nbl_glsl_VG_attribFetch3f(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
Packed_uvec3_t attrLocal = meshPackedDataUvec3Buffer . attribData[va + vertexID];
return vec3(uintBitsToFloat(attrLocal . x), uintBitsToFloat(attrLocal . y), uintBitsToFloat(attrLocal . z));
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataFloatSample[va . binding], addr). xyz;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_FLOAT_BUFFERS_COUNT
vec2 nbl_glsl_VG_attribFetch2f(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
uvec2 attrLocal = meshPackedDataUvec2Buffer . attribData[va + vertexID];
return vec2(uintBitsToFloat(attrLocal . x), uintBitsToFloat(attrLocal . y));
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataFloatSample[va . binding], addr). xy;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UINT))|| _NBL_VG_FLOAT_BUFFERS_COUNT
float nbl_glsl_VG_attribFetch1f(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return uintBitsToFloat(meshPackedDataUintBuffer . attribData[va + vertexID]);
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataFloatSample[va . binding], addr). x;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC4))|| _NBL_VG_INT_BUFFERS_COUNT
ivec4 nbl_glsl_VG_attribFetch4i(in nbl_glsl_VG_VirtualAttributePacked_t attr, uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return ivec4(meshPackedDataUvec4Buffer . attribData[va + vertexID]);
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataIntSample[va . binding], addr);
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC3))|| _NBL_VG_INT_BUFFERS_COUNT
ivec3 nbl_glsl_VG_attribFetch3i(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
Packed_uvec3_t attrLocal = meshPackedDataUvec3Buffer . attribData[va + vertexID];
return ivec3(int(attrLocal . x), int(attrLocal . y), int(attrLocal . z));
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataIntSample[va . binding], addr). xyz;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_INT_BUFFERS_COUNT
ivec2 nbl_glsl_VG_attribFetch2i(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return ivec2(meshPackedDataUvec2Buffer . attribData[va + vertexID]);
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataIntSample[va . binding], addr). xy;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UINT))|| _NBL_VG_INT_BUFFERS_COUNT
int nbl_glsl_VG_attribFetch1i(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return int(meshPackedDataUintBuffer . attribData[va + vertexID]);
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataIntSample[va . binding], addr). x;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC4))|| _NBL_VG_UINT_BUFFERS_COUNT
uvec4 nbl_glsl_VG_attribFetch4u(in nbl_glsl_VG_VirtualAttributePacked_t attr, uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return meshPackedDataUvec4Buffer . attribData[va + vertexID];
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataUintSample[va . binding], addr);
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC3))|| _NBL_VG_UINT_BUFFERS_COUNT
uvec3 nbl_glsl_VG_attribFetch3u(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
Packed_uvec3_t attrLocal = meshPackedDataUvec3Buffer . attribData[va + vertexID];
return uvec3(attrLocal . x, attrLocal . y, attrLocal . z);
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataUintSample[va . binding], addr). xyz;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_UINT_BUFFERS_COUNT
uvec2 nbl_glsl_VG_attribFetch2u(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return meshPackedDataUvec2Buffer . attribData[va + vertexID];
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataUintSample[va . binding], addr). xy;
#endif
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UINT))|| _NBL_VG_UINT_BUFFERS_COUNT
uint nbl_glsl_VG_attribFetch1u(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
const nbl_glsl_VG_VirtualAttribute va = nbl_glsl_VG_unpackVirtualAttribute(attr);
#ifdef _NBL_VG_USE_SSBO
return meshPackedDataUintBuffer . attribData[va + vertexID];
#else
const int addr = va . offset + int(vertexID);
return texelFetch(MeshPackedDataUintSample[va . binding], addr). x;
#endif
}
#endif
#endif
#line 10 "nbl/builtin/glsl/virtual_geometry/virtual_attribute_fetch.glsl"
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC4))|| _NBL_VG_FLOAT_BUFFERS_COUNT
vec4 nbl_glsl_VG_attribFetch_RGBA32_SFLOAT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch4f(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC3))|| _NBL_VG_FLOAT_BUFFERS_COUNT
vec3 nbl_glsl_VG_attribFetch_RGB32_SFLOAT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch3f(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_FLOAT_BUFFERS_COUNT
vec2 nbl_glsl_VG_attribFetch_RG32_SFLOAT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch2f(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UINT))|| _NBL_VG_FLOAT_BUFFERS_COUNT
float nbl_glsl_VG_attribFetch_R32_SFLOAT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch1f(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_FLOAT_BUFFERS_COUNT
vec4 nbl_glsl_VG_attribFetch_RGBA16_SFLOAT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
#ifdef _NBL_VG_USE_SSBO
uvec2 packed = nbl_glsl_VG_attribFetch2u(attr, vertexID);
vec2 xy = unpackHalf2x16(packed . x). yx;
vec2 zw = unpackHalf2x16(packed . y). yx;
return vec4(xy, zw);
#else
return nbl_glsl_VG_attribFetch4f(attr, vertexID);
#endif
}
vec4 nbl_glsl_VG_attribFetch_RGBA16_SNORM(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch_RGBA16_SFLOAT(attr, vertexID);
}
vec4 nbl_glsl_VG_attribFetch_RGBA16_UNORM(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch_RGBA16_SFLOAT(attr, vertexID);
}
vec4 nbl_glsl_VG_attribFetch_RGBA16_USCALED(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch_RGBA16_SFLOAT(attr, vertexID);
}
vec4 nbl_glsl_VG_attribFetch_RGBA16_SSCALED(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch_RGBA16_SFLOAT(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_FLOAT_BUFFERS_COUNT
vec2 nbl_glsl_VG_attribFetch_RG16_SFLOAT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
#ifdef _NBL_VG_USE_SSBO
return unpackHalf2x16(nbl_glsl_VG_attribFetch1u(attr, vertexID)). yx;
#else
return nbl_glsl_VG_attribFetch2f(attr, vertexID);
#endif
}
vec2 nbl_glsl_VG_attribFetch_RG16_SNORM(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch_RG16_SFLOAT(attr, vertexID);
}
vec2 nbl_glsl_VG_attribFetch_RG16_UNORM(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch_RG16_SFLOAT(attr, vertexID);
}
vec2 nbl_glsl_VG_attribFetch_RG16_USCALED(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch_RG16_SFLOAT(attr, vertexID);
}
vec2 nbl_glsl_VG_attribFetch_RG16_SSCALED(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch_RG16_SFLOAT(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC4))|| _NBL_VG_INT_BUFFERS_COUNT
ivec4 nbl_glsl_VG_attribFetch_RGBA32_SINT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch4i(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC3))|| _NBL_VG_INT_BUFFERS_COUNT
ivec3 nbl_glsl_VG_attribFetch_RGB32_SINT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch3i(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_INT_BUFFERS_COUNT
ivec2 nbl_glsl_VG_attribFetch_RG32_SINT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch2i(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UINT))|| _NBL_VG_INT_BUFFERS_COUNT
int nbl_glsl_VG_attribFetch_R32_SINT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch1i(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC4))|| _NBL_VG_UINT_BUFFERS_COUNT
uvec4 nbl_glsl_VG_attribFetch_RGBA32_UINT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch4u(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC3))|| _NBL_VG_UINT_BUFFERS_COUNT
uvec3 nbl_glsl_VG_attribFetch_RGB32_UINT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch3u(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UVEC2))|| _NBL_VG_UINT_BUFFERS_COUNT
uvec2 nbl_glsl_VG_attribFetch_RG32_UINT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch2u(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UINT))|| _NBL_VG_UINT_BUFFERS_COUNT
uint nbl_glsl_VG_attribFetch_R32_UINT(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_VG_attribFetch1u(attr, vertexID);
}
#endif
#if (defined(_NBL_VG_USE_SSBO)&& defined(_NBL_VG_USE_SSBO_UINT))|| _NBL_VG_UINT_BUFFERS_COUNT
vec4 nbl_glsl_VG_attribFetch_RGB10A2_SNORM(in nbl_glsl_VG_VirtualAttributePacked_t attr, in uint vertexID)
{
return nbl_glsl_decodeRGB10A2_SNORM(nbl_glsl_VG_attribFetch1u(attr, vertexID));
}
#endif
#endif
#line 51 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/common.glsl"
vec3 nbl_glsl_fetchVtxPos(in uint vtxID, in uint drawGUID)
{
nbl_glsl_VG_VirtualAttributePacked_t va = batchInstanceData[drawGUID]. vAttrPos;
return nbl_glsl_VG_attribFetch_RGB32_SFLOAT(va, vtxID);
}
vec2 nbl_glsl_fetchVtxUV(in uint vtxID, in uint drawGUID)
{
nbl_glsl_VG_VirtualAttributePacked_t va = batchInstanceData[drawGUID]. vAttrUV;
return nbl_glsl_VG_attribFetch_RG32_SFLOAT(va, vtxID);
}
vec3 nbl_glsl_fetchVtxNormal(in uint vtxID, in uint drawGUID)
{
nbl_glsl_VG_VirtualAttributePacked_t va = batchInstanceData[drawGUID]. vAttrNormal;
return nbl_glsl_VG_attribFetch_RGB10A2_SNORM(va, vtxID). xyz;
}
#endif
#line 15 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/shadeVBuffer.comp"
layout (local_size_x = SHADING_WG_SIZE_X, local_size_y = SHADING_WG_SIZE_Y)in;
#line 1 "nbl/builtin/glsl/virtual_texturing/extensions.glsl"
#line 1 "nbl/builtin/glsl/virtual_texturing/extensions.glsl"
#ifndef _NBL_BUILTIN_GLSL_VIRTUAL_TEXTURING_EXTENSIONS_INCLUDED_
#define _NBL_BUILTIN_GLSL_VIRTUAL_TEXTURING_EXTENSIONS_INCLUDED_
#ifdef NBL_GL_EXT_nonuniform_qualifier
#extension GL_EXT_nonuniform_qualifier : enable
#else
#extension GL_KHR_shader_subgroup_ballot : enable
#endif
#endif
#line 18 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/shadeVBuffer.comp"
#define _NBL_VT_DESCRIPTOR_SET 0
#define _NBL_VT_FLOAT_VIEWS
#define _NBL_VT_INT_VIEWS_COUNT 0
#define _NBL_VT_INT_VIEWS
#define _NBL_VT_UINT_VIEWS_COUNT 0
#define _NBL_VT_UINT_VIEWS
#line 1 "nbl/builtin/glsl/virtual_texturing/descriptors.glsl"
#line 1 "nbl/builtin/glsl/virtual_texturing/descriptors.glsl"
#ifndef _NBL_BUILTIN_GLSL_VIRTUAL_TEXTURING_DESCRIPTORS_INCLUDED_
#define _NBL_BUILTIN_GLSL_VIRTUAL_TEXTURING_DESCRIPTORS_INCLUDED_
#define _NBL_VT_MAX_PAGE_TABLE_LAYERS 256
#ifndef _NBL_VT_DESCRIPTOR_SET
#define _NBL_VT_DESCRIPTOR_SET 0
#endif
#ifndef _NBL_VT_PAGE_TABLE_BINDING
#define _NBL_VT_PAGE_TABLE_BINDING 0
#endif
#ifndef _NBL_VT_FLOAT_VIEWS
#define _NBL_VT_FLOAT_VIEWS_BINDING 1
#define _NBL_VT_FLOAT_VIEWS_COUNT 15
#endif
#ifndef _NBL_VT_INT_VIEWS
#define _NBL_VT_INT_VIEWS_BINDING 2
#define _NBL_VT_INT_VIEWS_COUNT 0
#endif
#ifndef _NBL_VT_UINT_VIEWS
#define _NBL_VT_UINT_VIEWS_BINDING 3
#define _NBL_VT_UINT_VIEWS_COUNT 0
#endif
layout(set = _NBL_VT_DESCRIPTOR_SET, binding = _NBL_VT_PAGE_TABLE_BINDING)uniform usampler2DArray pageTable;
#if _NBL_VT_FLOAT_VIEWS_COUNT
layout(set = _NBL_VT_DESCRIPTOR_SET, binding = _NBL_VT_FLOAT_VIEWS_BINDING)uniform sampler2DArray physicalTileStorageFormatView[_NBL_VT_FLOAT_VIEWS_COUNT];
#endif
#if _NBL_VT_INT_VIEWS_COUNT
layout(set = _NBL_VT_DESCRIPTOR_SET, binding = _NBL_VT_INT_VIEWS_BINDING)uniform isampler2DArray iphysicalTileStorageFormatView[_NBL_VT_INT_VIEWS_COUNT];
#endif
#if _NBL_VT_UINT_VIEWS_COUNT
layout(set = _NBL_VT_DESCRIPTOR_SET, binding = _NBL_VT_UINT_VIEWS_BINDING)uniform usampler2DArray uphysicalTileStorageFormatView[_NBL_VT_UINT_VIEWS_COUNT];
#endif
#endif
#line 25 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/shadeVBuffer.comp"
layout (set = 0, binding = 2, std430)restrict readonly buffer PrecomputedStuffSSBO
{
uint pgtab_sz_log2;
float vtex_sz_rcp;
float phys_pg_tex_sz_rcp[_NBL_VT_MAX_PAGE_TABLE_LAYERS];
uint layer_to_sampler_ix[_NBL_VT_MAX_PAGE_TABLE_LAYERS];
} precomputed;
layout(set = 3, binding = 0)uniform sampler2D vBuffer;
layout(set = 3, binding = 1, rgba8)uniform image2D frameBuffer;
#line 1 "nbl/builtin/glsl/loader/mtl/common.glsl"
#line 1 "nbl/builtin/glsl/loader/mtl/common.glsl"
#ifndef _NBL_BUILTIN_GLSL_MTL_LOADER_COMMON_INCLUDED_
#define _NBL_BUILTIN_GLSL_MTL_LOADER_COMMON_INCLUDED_
struct nbl_glsl_MTLMaterialParameters
{
vec3 Ka;
vec3 Kd;
vec3 Ks;
vec3 Ke;
vec4 Tf;
float Ns;
float d;
float bm;
float Ni;
float roughness;
float metallic;
float sheen;
float clearcoatThickness;
float clearcoatRoughness;
float anisotropy;
float anisoRotation;
uint extra;
};
#endif
#line 37 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/shadeVBuffer.comp"
BatchInstanceData gBatchInstance;
nbl_glsl_MTLMaterialParameters nbl_glsl_getMaterialParameters()
{
nbl_glsl_MTLMaterialParameters mtl_params;
mtl_params . Ka = gBatchInstance . Ka;
mtl_params . Kd = gBatchInstance . Kd;
mtl_params . Ks = gBatchInstance . Ks;
mtl_params . Ke = gBatchInstance . Ke;
mtl_params . Ns = gBatchInstance . Ns;
mtl_params . d = gBatchInstance . d;
mtl_params . Ni = gBatchInstance . Ni;
mtl_params . extra = gBatchInstance . extra;
return mtl_params;
}
#define _NBL_FRAG_GET_MATERIAL_PARAMETERS_FUNCTION_DEFINED_
uint nbl_glsl_VT_layer2pid(in uint layer)
{
return precomputed . layer_to_sampler_ix[layer];
}
uint nbl_glsl_VT_getPgTabSzLog2()
{
return precomputed . pgtab_sz_log2;
}
float nbl_glsl_VT_getPhysPgTexSzRcp(in uint layer)
{
return precomputed . phys_pg_tex_sz_rcp[layer];
}
float nbl_glsl_VT_getVTexSzRcp()
{
return precomputed . vtex_sz_rcp;
}
#define _NBL_USER_PROVIDED_VIRTUAL_TEXTURING_FUNCTIONS_
#if PAGE_SZ_LOG2 != 7 || PAGE_PADDING != 8
#error
#endif
#line 1 "nbl/builtin/glsl/virtual_texturing/functions.glsl/7/8"
#line 1 "nbl/builtin/glsl/virtual_texturing/functions.glsl/7/8"
#ifndef _NBL_BUILTIN_GLSL_VIRTUAL_TEXTURING_FUNCTIONS_INCLUDED_
#define _NBL_BUILTIN_GLSL_VIRTUAL_TEXTURING_FUNCTIONS_INCLUDED_
#define _NBL_VT_IMPL_PAGE_SZ 128u
#define _NBL_VT_IMPL_PAGE_SZ_LOG2 7u
#define _NBL_VT_IMPL_TILE_PADDING 8u
#define _NBL_VT_IMPL_PADDED_TILE_SIZE uint(_NBL_VT_IMPL_PAGE_SZ + 2 * _NBL_VT_IMPL_TILE_PADDING)
const vec2 packingOffsets[]= vec2[_NBL_VT_IMPL_PAGE_SZ_LOG2 + 1](vec2(8), vec2(8, 8), vec2(8, 88), vec2(88, 8), vec2(56, 88), vec2(88, 40), vec2(80, 88), vec2(88, 60));
#line 1 "nbl/builtin/glsl/virtual_texturing/impl_functions.glsl"
#line 1 "nbl/builtin/glsl/virtual_texturing/impl_functions.glsl"
#ifndef _NBL_BUILTIN_GLSL_VIRTUAL_TEXTURING_IMPL_FUNCTIONS_INCLUDED_
#define _NBL_BUILTIN_GLSL_VIRTUAL_TEXTURING_IMPL_FUNCTIONS_INCLUDED_
#define nbl_glsl_STextureData_WRAP_REPEAT 0u
#define nbl_glsl_STextureData_WRAP_CLAMP 1u
#define nbl_glsl_STextureData_WRAP_MIRROR 2u
#ifndef _NBL_PHYSICAL_ADDR_SPEC_DEFINED_
#define nbl_glsl_ADDR_X_MASK 0xfu
#define nbl_glsl_ADDR_Y_MASK 0xfu
#define nbl_glsl_ADDR_Y_SHIFT 4u
#define nbl_glsl_ADDR_LAYER_SHIFT 8u
#endif
vec3 nbl_glsl_unpackPageID(in uint pageID)
{
uvec2 pageXY = uvec2(pageID, pageID >> nbl_glsl_ADDR_Y_SHIFT)& uvec2(nbl_glsl_ADDR_X_MASK, nbl_glsl_ADDR_Y_MASK);
return vec3(vec2(pageXY), float(pageID >> nbl_glsl_ADDR_LAYER_SHIFT));
}
uvec2 nbl_glsl_unpackWrapModes(in uvec2 texData)
{
return (texData >> uvec2(28u, 30u))& uvec2(0x03u);
}
uint nbl_glsl_unpackMaxMipInVT(in uvec2 texData)
{
return (texData . y >> 24)& 0x0fu;
}
vec3 nbl_glsl_unpackVirtualUV(in uvec2 texData)
{
uvec3 unnormCoords = uvec3(texData . y << _NBL_VT_IMPL_PAGE_SZ_LOG2, texData . yy >> uvec2(8u - _NBL_VT_IMPL_PAGE_SZ_LOG2, 16u))& uvec3(uvec2(0xffu)<< _NBL_VT_IMPL_PAGE_SZ_LOG2, 0xffu);
return vec3(unnormCoords);
}
vec2 nbl_glsl_unpackSize(in uvec2 texData)
{
return vec2(texData . x & 0xffffu, texData . x >> 16u);
}
float nbl_glsl_wrapTexCoord(float tc, in uint mode)
{
switch (mode)
{
case nbl_glsl_STextureData_WRAP_REPEAT : tc = fract(tc);break;
case nbl_glsl_STextureData_WRAP_CLAMP : tc = clamp(tc, 0.0, 1.0);break;
case nbl_glsl_STextureData_WRAP_MIRROR : tc = 1.0 - abs(mod(tc, 2.0)- 1.0);break;
default : break;
}
return tc;
}
#ifndef _NBL_USER_PROVIDED_VIRTUAL_TEXTURING_FUNCTIONS_
#error "You need to define nbl_glsl_VT_getPgTabSzLog2(),nbl_glsl_VT_getPhysPgTexSzRcp(uint layer),nbl_glsl_VT_getVTexSzRcp(),nbl_glsl_VT_layer2pid(uint layer) before including this header"
#endif
vec3 nbl_glsl_vTexture_helper(in uint formatID, in vec3 virtualUV, in int clippedLoD, in int levelInTail)
{
uvec2 pageID = textureLod(pageTable, virtualUV, clippedLoD). xy;
const uint pageTableSizeLog2 = nbl_glsl_VT_getPgTabSzLog2();
const float phys_pg_tex_sz_rcp = nbl_glsl_VT_getPhysPgTexSzRcp(uint(virtualUV . z));
uint thisLevelTableSize = (pageTableSizeLog2 - uint(clippedLoD))<< 23;
vec2 tileCoordinate = uintBitsToFloat(floatBitsToUint(virtualUV . xy)+ thisLevelTableSize);
tileCoordinate = fract(tileCoordinate);
tileCoordinate = uintBitsToFloat(floatBitsToUint(tileCoordinate)+ uint((_NBL_VT_IMPL_PAGE_SZ_LOG2 - levelInTail)<< 23));
tileCoordinate += packingOffsets[levelInTail];
tileCoordinate *= phys_pg_tex_sz_rcp;
vec3 physicalUV = nbl_glsl_unpackPageID(levelInTail != 0 ? pageID . y : pageID . x);
physicalUV . xy *= vec2(_NBL_VT_IMPL_PAGE_SZ + 2 * _NBL_VT_IMPL_TILE_PADDING)* phys_pg_tex_sz_rcp;
physicalUV . xy += tileCoordinate;
return physicalUV;
}
#line 1 "nbl/builtin/glsl/math/functions.glsl"
#line 1 "nbl/builtin/glsl/math/functions.glsl"
#ifndef _NBL_MATH_FUNCTIONS_INCLUDED_
#define _NBL_MATH_FUNCTIONS_INCLUDED_
#line 1 "nbl/builtin/glsl/math/constants.glsl"
#line 1 "nbl/builtin/glsl/math/constants.glsl"
#ifndef _NBL_MATH_CONSTANTS_INCLUDED_
#define _NBL_MATH_CONSTANTS_INCLUDED_
#line 1 "nbl/builtin/glsl/limits/numeric.glsl"
#line 1 "nbl/builtin/glsl/limits/numeric.glsl"
#ifndef _NBL_LIMITS_NUMERIC_INCLUDED_
#define _NBL_LIMITS_NUMERIC_INCLUDED_
#ifndef INT_MIN
#define INT_MIN - 2147483648
#endif
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef UINT_MIN
#define UINT_MIN 0u
#endif
#ifndef UINT_MAX
#define UINT_MAX 4294967295u
#endif
#ifndef FLT_MIN
#define FLT_MIN 1.175494351e-38
#endif
#ifndef FLT_MAX
#define FLT_MAX 3.402823466e+38
#endif
#ifndef FLT_INF
#define FLT_INF (1.0 / 0.0)
#endif
#endif
#line 9 "nbl/builtin/glsl/math/constants.glsl"
#define nbl_glsl_PI 3.14159265359
#define nbl_glsl_RECIPROCAL_PI 0.318309886183
#define nbl_glsl_SQRT_RECIPROCAL_PI 0.56418958354
#define nbl_glsl_FLT_INF float(1.0 / 0.0)
#ifndef nbl_glsl_FLT_NAN
#define nbl_glsl_FLT_NAN uintBitsToFloat(0xFFffFFffu)
#endif
#endif
#line 9 "nbl/builtin/glsl/math/functions.glsl"
int nbl_glsl_dot(in ivec2 a, in ivec2 b){ return a . x * b . x + a . y * b . y;}
uint nbl_glsl_dot(in uvec2 a, in uvec2 b){ return a . x * b . x + a . y * b . y;}
int nbl_glsl_dot(in ivec3 a, in ivec3 b){ return a . x * b . x + a . y * b . y + a . z * b . z;}
uint nbl_glsl_dot(in uvec3 a, in uvec3 b){ return a . x * b . x + a . y * b . y + a . z * b . z;}
int nbl_glsl_dot(in ivec4 a, in ivec4 b){ return a . x * b . x + a . y * b . y + a . z * b . z + a . w * b . w;}
uint nbl_glsl_dot(in uvec4 a, in uvec4 b){ return a . x * b . x + a . y * b . y + a . z * b . z + a . w * b . w;}
float nbl_glsl_erf(in float _x)
{
const float a1 = 0.254829592;
const float a2 = - 0.284496736;
const float a3 = 1.421413741;
const float a4 = - 1.453152027;
const float a5 = 1.061405429;
const float p = 0.3275911;
float sign = sign(_x);
float x = abs(_x);
float t = 1.0 / (1.0 + p * x);
float y = 1.0 - (((((a5 * t + a4)* t)+ a3)* t + a2)* t + a1)* t * exp(- x * x);
return sign * y;
}
float nbl_glsl_erfInv(in float _x)
{
float x = clamp(_x, - 0.99999, 0.99999);
float w = - log((1.0 - x)* (1.0 + x));
float p;
if (w < 5.0)
{
w -= 2.5;
p = 2.81022636e-08;
p = 3.43273939e-07 + p * w;
p = - 3.5233877e-06 + p * w;
p = - 4.39150654e-06 + p * w;
p = 0.00021858087 + p * w;
p = - 0.00125372503 + p * w;
p = - 0.00417768164 + p * w;
p = 0.246640727 + p * w;
p = 1.50140941 + p * w;
}
else
{
w = sqrt(w)- 3.0;
p = - 0.000200214257;
p = 0.000100950558 + p * w;
p = 0.00134934322 + p * w;
p = - 0.00367342844 + p * w;
p = 0.00573950773 + p * w;
p = - 0.0076224613 + p * w;
p = 0.00943887047 + p * w;
p = 1.00167406 + p * w;
p = 2.83297682 + p * w;
}
return p * x;
}
float nbl_glsl_lengthManhattan(float v)
{
return abs(v);
}
float nbl_glsl_lengthManhattan(vec2 v)
{
v = abs(v);
return v . x + v . y;
}
float nbl_glsl_lengthManhattan(vec3 v)
{
v = abs(v);
return v . x + v . y + v . z;
}
float nbl_glsl_lengthManhattan(vec4 v)
{
v = abs(v);
return v . x + v . y + v . z + v . w;
}
float nbl_glsl_lengthSq(in float v)
{
return v * v;
}
float nbl_glsl_lengthSq(in vec2 v)
{
return dot(v, v);
}
float nbl_glsl_lengthSq(in vec3 v)
{
return dot(v, v);
}
float nbl_glsl_lengthSq(in vec4 v)
{
return dot(v, v);
}
vec3 nbl_glsl_reflect(in vec3 I, in vec3 N, in float NdotI)
{
return N * 2.0 * NdotI - I;
}
vec3 nbl_glsl_reflect(in vec3 I, in vec3 N)
{
float NdotI = dot(N, I);
return nbl_glsl_reflect(I, N, NdotI);
}
bool nbl_glsl_getOrientedEtas(out float orientedEta, out float rcpOrientedEta, in float NdotI, in float eta)
{
const bool backside = NdotI < 0.0;
const float rcpEta = 1.0 / eta;
orientedEta = backside ? rcpEta : eta;
rcpOrientedEta = backside ? eta : rcpEta;
return backside;
}
bool nbl_glsl_getOrientedEtas(out vec3 orientedEta, out vec3 rcpOrientedEta, in float NdotI, in vec3 eta)
{
const bool backside = NdotI < 0.0;
const vec3 rcpEta = vec3(1.0)/ eta;
orientedEta = backside ? rcpEta : eta;
rcpOrientedEta = backside ? eta : rcpEta;
return backside;
}
float nbl_glsl_refract_compute_NdotT2(in float NdotI2, in float rcpOrientedEta2)
{
return rcpOrientedEta2 * NdotI2 + 1.0 - rcpOrientedEta2;
}
float nbl_glsl_refract_compute_NdotT(in bool backside, in float NdotI2, in float rcpOrientedEta2)
{
const float abs_NdotT = sqrt(nbl_glsl_refract_compute_NdotT2(NdotI2, rcpOrientedEta2));
return backside ? abs_NdotT :(- abs_NdotT);
}
vec3 nbl_glsl_refract(in vec3 I, in vec3 N, in bool backside, in float NdotI, in float NdotI2, in float rcpOrientedEta, in float rcpOrientedEta2)
{
return N *(NdotI * rcpOrientedEta + nbl_glsl_refract_compute_NdotT(backside, NdotI2, rcpOrientedEta2))- rcpOrientedEta * I;
}
vec3 nbl_glsl_refract(in vec3 I, in vec3 N, in float NdotI, in float eta)
{
float orientedEta, rcpOrientedEta;
const bool backside = nbl_glsl_getOrientedEtas(orientedEta, rcpOrientedEta, NdotI, eta);
return nbl_glsl_refract(I, N, backside, NdotI, NdotI * NdotI, rcpOrientedEta, rcpOrientedEta * rcpOrientedEta);
}
vec3 nbl_glsl_refract(in vec3 I, in vec3 N, in float eta)
{
const float NdotI = dot(N, I);
return nbl_glsl_refract(I, N, NdotI, eta);
}
vec3 nbl_glsl_reflect_refract_impl(in bool _refract, in vec3 I, in vec3 N, in float NdotI, in float NdotTorR, in float rcpOrientedEta)
{
return N *(NdotI *(_refract ? rcpOrientedEta : 1.0)+ NdotTorR)- I *(_refract ? rcpOrientedEta : 1.0);
}
vec3 nbl_glsl_reflect_refract(in bool _refract, in vec3 I, in vec3 N, in bool backside, in float NdotI, in float NdotI2, in float rcpOrientedEta, in float rcpOrientedEta2)
{
const float NdotTorR = _refract ? nbl_glsl_refract_compute_NdotT(backside, NdotI2, rcpOrientedEta2): NdotI;
return nbl_glsl_reflect_refract_impl(_refract, I, N, NdotI, NdotTorR, rcpOrientedEta);
}
vec3 nbl_glsl_reflect_refract(in bool _refract, in vec3 I, in vec3 N, in float NdotI, in float NdotI2, in float eta)
{
float orientedEta, rcpOrientedEta;
const bool backside = nbl_glsl_getOrientedEtas(orientedEta, rcpOrientedEta, NdotI, eta);
return nbl_glsl_reflect_refract(_refract, I, N, backside, NdotI, NdotI2, rcpOrientedEta, rcpOrientedEta * rcpOrientedEta);
}
vec3 nbl_glsl_computeUnnormalizedMicrofacetNormal(in bool _refract, in vec3 V, in vec3 L, in float orientedEta)
{
const float etaFactor = (_refract ? orientedEta : 1.0);
const vec3 tmpH = V + L * etaFactor;
return _refract ? (- tmpH): tmpH;
}
vec3 nbl_glsl_computeMicrofacetNormal(in bool _refract, in vec3 V, in vec3 L, in float orientedEta)
{
const vec3 H = nbl_glsl_computeUnnormalizedMicrofacetNormal(_refract, V, L, orientedEta);
const float unnormRcpLen = inversesqrt(dot(H, H));
return H * unnormRcpLen;
}
bool nbl_glsl_isTransmissionPath(in float NdotV, in float NdotL)
{
return ((floatBitsToUint(NdotV)^ floatBitsToUint(NdotL))& 0x80000000u)!= 0u;
}
void nbl_glsl_sincos(in float theta, out float s, out float c)
{
c = cos(theta);
s = sqrt(1.0 - c * c);
s = theta < 0.0 ? - s : s;
}
mat2x3 nbl_glsl_frisvad(in vec3 n)
{
const float a = 1.0 /(1.0 + n . z);
const float b = - n . x * n . y * a;
return (n . z < - 0.9999999)? mat2x3(vec3(0.0, - 1.0, 0.0), vec3(- 1.0, 0.0, 0.0)): mat2x3(vec3(1.0 - n . x * n . x * a, b, - n . x), vec3(b, 1.0 - n . y * n . y * a, - n . y));
}
bool nbl_glsl_partitionRandVariable(in float leftProb, inout float xi, out float rcpChoiceProb)
{
const float NEXT_ULP_AFTER_UNITY = uintBitsToFloat(0x3f800001u);
const bool pickRight = xi >= leftProb * NEXT_ULP_AFTER_UNITY;
xi -= pickRight ? leftProb : 0.0;
rcpChoiceProb = 1.0 /(pickRight ? (1.0 - leftProb): leftProb);
xi *= rcpChoiceProb;
return pickRight;
}
float nbl_glsl_conditionalAbsOrMax(in bool cond, in float x, in float limit)
{
const float condAbs = uintBitsToFloat(floatBitsToUint(x)& uint(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
vec2 nbl_glsl_conditionalAbsOrMax(in bool cond, in vec2 x, in vec2 limit)
{
const vec2 condAbs = uintBitsToFloat(floatBitsToUint(x)& uvec2(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
vec3 nbl_glsl_conditionalAbsOrMax(in bool cond, in vec3 x, in vec3 limit)
{
const vec3 condAbs = uintBitsToFloat(floatBitsToUint(x)& uvec3(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
vec4 nbl_glsl_conditionalAbsOrMax(in bool cond, in vec4 x, in vec4 limit)
{
const vec4 condAbs = uintBitsToFloat(floatBitsToUint(x)& uvec4(cond ? 0x7fFFffFFu : 0xffFFffFFu));
return max(condAbs, limit);
}
uint nbl_glsl_rotl(in uint x, in uint k)
{
return (x << k)| (x >>(32u - k));
}
uint nbl_glsl_clz(in uint x)
{
return 31u - findMSB(x);
}
uint nbl_glsl_bitfieldOverwrite(in uint base, in uint value, in uint offset, in uint count)
{
return bitfieldInsert(base, value, int(offset), int(count));
}
uint nbl_glsl_bitfieldInsert_impl(in uint base, in uint shifted_masked_value, in uint lo, in uint count)
{
const uint hi = base ^ lo;
return (hi << count)| shifted_masked_value | lo;
}
uint nbl_glsl_bitfieldInsert(in uint base, uint value, in uint offset, in uint count)
{
const uint shifted_masked_value = (value &((0x1u << count)- 1u))<< offset;
return nbl_glsl_bitfieldInsert_impl(base, shifted_masked_value, base &((0x1u << offset)- 1u), count);
}
float nbl_glsl_getArccosSumofABC_minus_PI(in float cosA, in float cosB, in float cosC, in float sinA, in float sinB, in float sinC)
{
const bool something0 = cosA <(- cosB);
const float cosSumAB = cosA * cosB - sinA * sinB;
const bool something1 = cosSumAB <(- cosC);
const bool something2 = cosSumAB < cosC;
const float absArccosSumABC = acos(cosSumAB * cosC -(cosA * sinB + sinA * cosB)* sinC);
return ((something0 ? something2 : something1)? (- absArccosSumABC): absArccosSumABC)+(something0 || something1 ? nbl_glsl_PI :(- nbl_glsl_PI));
}
float nbl_glsl_applyChainRule1D(in float dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule1D(in vec2 dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule1D(in vec3 dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule1D(in vec4 dFdG, in float dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in vec2 dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in vec2 dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in vec2 dGdR)
{
return dFdG * dGdR;
}
mat2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in mat2 dGdR)
{
return dFdG * dGdR;
}
mat2x3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in mat2 dGdR)
{
return dFdG * dGdR;
}
mat2x4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in mat2 dGdR)
{
return dFdG * dGdR;
}
mat3x2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in mat3x2 dGdR)
{
return dFdG * dGdR;
}
mat3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in mat3x2 dGdR)
{
return dFdG * dGdR;
}
mat3x4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in mat3x2 dGdR)
{
return dFdG * dGdR;
}
mat4x2 nbl_glsl_applyChainRule2D(in mat2 dFdG, in mat4x2 dGdR)
{
return dFdG * dGdR;
}
mat4x3 nbl_glsl_applyChainRule2D(in mat2x3 dFdG, in mat4x2 dGdR)
{
return dFdG * dGdR;
}
mat4 nbl_glsl_applyChainRule2D(in mat2x4 dFdG, in mat4x2 dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in vec3 dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in vec3 dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in vec3 dGdR)
{
return dFdG * dGdR;
}
mat2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in mat2x3 dGdR)
{
return dFdG * dGdR;
}
mat2x3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in mat2x3 dGdR)
{
return dFdG * dGdR;
}
mat2x4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in mat2x3 dGdR)
{
return dFdG * dGdR;
}
mat3x2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in mat3 dGdR)
{
return dFdG * dGdR;
}
mat3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in mat3 dGdR)
{
return dFdG * dGdR;
}
mat3x4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in mat3 dGdR)
{
return dFdG * dGdR;
}
mat4x2 nbl_glsl_applyChainRule3D(in mat3x2 dFdG, in mat4x3 dGdR)
{
return dFdG * dGdR;
}
mat4x3 nbl_glsl_applyChainRule3D(in mat3 dFdG, in mat4x3 dGdR)
{
return dFdG * dGdR;
}
mat4 nbl_glsl_applyChainRule3D(in mat3x4 dFdG, in mat4x3 dGdR)
{
return dFdG * dGdR;
}
vec2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in vec4 dGdR)
{
return dFdG * dGdR;
}
vec3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in vec4 dGdR)
{
return dFdG * dGdR;
}
vec4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in vec4 dGdR)
{
return dFdG * dGdR;
}
mat2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in mat2x4 dGdR)
{
return dFdG * dGdR;
}
mat2x3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in mat2x4 dGdR)
{
return dFdG * dGdR;
}
mat2x4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in mat2x4 dGdR)
{
return dFdG * dGdR;
}
mat3x2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in mat3x4 dGdR)
{
return dFdG * dGdR;
}
mat3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in mat3x4 dGdR)
{
return dFdG * dGdR;
}
mat3x4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in mat3x4 dGdR)
{
return dFdG * dGdR;
}
mat4x2 nbl_glsl_applyChainRule4D(in mat4x2 dFdG, in mat4 dGdR)
{
return dFdG * dGdR;
}
mat4x3 nbl_glsl_applyChainRule4D(in mat4x3 dFdG, in mat4 dGdR)
{
return dFdG * dGdR;
}
mat4 nbl_glsl_applyChainRule4D(in mat4 dFdG, in mat4 dGdR)
{
return dFdG * dGdR;
}
#endif
#line 86 "nbl/builtin/glsl/virtual_texturing/impl_functions.glsl"
#if _NBL_VT_FLOAT_VIEWS_COUNT
vec4 nbl_glsl_vTextureGrad_impl(in uint formatID, in vec3 virtualUV, in mat2 dOriginalScaledUV, in int originalMaxFullMip)
{
const float kMaxAnisotropy = float(2u * _NBL_VT_IMPL_TILE_PADDING);
#ifdef _NBL_APPROXIMATE_TEXEL_FOOTPRINT_FROM_DERIVATIVE_CACL_
float p_x_2_log2 = log2(nbl_glsl_lengthManhattan(dOriginalScaledUV[0]));
float p_y_2_log2 = log2(nbl_glsl_lengthManhattan(dOriginalScaledUV[1]));
const float kMaxAnisoLogOffset = log2(kMaxAnisotropy);
#else
float p_x_2_log2 = log2(nbl_glsl_lengthSq(dOriginalScaledUV[0]));
float p_y_2_log2 = log2(nbl_glsl_lengthSq(dOriginalScaledUV[1]));
const float kMaxAnisoLogOffset = log2(kMaxAnisotropy)* 2.0;
#endif
bool xIsMajor = p_x_2_log2 > p_y_2_log2;
float p_min_2_log2 = xIsMajor ? p_y_2_log2 : p_x_2_log2;
float p_max_2_log2 = xIsMajor ? p_x_2_log2 : p_y_2_log2;
float LoD = max(p_min_2_log2, p_max_2_log2 - kMaxAnisoLogOffset);
#ifdef _NBL_APPROXIMATE_TEXEL_FOOTPRINT_FROM_DERIVATIVE_CACL_
LoD += 0.5;
#else
LoD *= 0.5;
#endif
int LoD_high = int(LoD);
bool positiveLoD = LoD > 0.0;
int clippedLoD = positiveLoD ? min(LoD_high, originalMaxFullMip): 0;
int levelInTail = LoD_high - clippedLoD;
bool haveToDoTrilinear = levelInTail < int(_NBL_VT_IMPL_PAGE_SZ_LOG2)&& positiveLoD;
levelInTail = haveToDoTrilinear ? levelInTail :(positiveLoD ? int(_NBL_VT_IMPL_PAGE_SZ_LOG2): 0);
vec3 hiPhysCoord = nbl_glsl_vTexture_helper(formatID, virtualUV, clippedLoD, levelInTail);
vec3 loPhysCoord;
{
bool highNotInLastFull = LoD_high < originalMaxFullMip;
clippedLoD = highNotInLastFull ? (clippedLoD + 1): clippedLoD;
levelInTail = highNotInLastFull ? levelInTail :(levelInTail + 1);
loPhysCoord = nbl_glsl_vTexture_helper(formatID, virtualUV, clippedLoD, levelInTail);
}
vec4 hiMip_retval;
vec4 loMip;
#ifdef NBL_GL_EXT_nonuniform_qualifier
hiMip_retval = textureGrad(physicalTileStorageFormatView[nonuniformEXT(formatID)], hiPhysCoord, dOriginalScaledUV[0], dOriginalScaledUV[1]);
if (haveToDoTrilinear)
loMip = textureGrad(physicalTileStorageFormatView[nonuniformEXT(formatID)], loPhysCoord, dOriginalScaledUV[0], dOriginalScaledUV[1]);
#else
uvec2 outstandingSampleMask = subgroupBallot(true). xy;
while (outstandingSampleMask != uvec2(0u))
{
uvec2 tmp = outstandingSampleMask;
uint subgroupFormatID = subgroupBroadcast(formatID, tmp[1]!= 0u ? 32u : findLSB(tmp[0]));
bool canSample = subgroupFormatID == formatID;
outstandingSampleMask ^= subgroupBallot(canSample). xy;
if (canSample)
{
hiMip_retval = textureGrad(physicalTileStorageFormatView[subgroupFormatID], hiPhysCoord, dOriginalScaledUV[0], dOriginalScaledUV[1]);
if (haveToDoTrilinear)
loMip = textureGrad(physicalTileStorageFormatView[subgroupFormatID], loPhysCoord, dOriginalScaledUV[0], dOriginalScaledUV[1]);
}
}
#endif
if (haveToDoTrilinear)
hiMip_retval = mix(hiMip_retval, loMip, LoD - float(LoD_high));
return hiMip_retval;
}
vec4 nbl_glsl_vTextureGrad(in uvec2 _texData, in vec2 uv, in mat2 dUV)
{
vec2 originalSz = nbl_glsl_unpackSize(_texData);
dUV[0]*= originalSz;
dUV[1]*= originalSz;
uvec2 wrap = nbl_glsl_unpackWrapModes(_texData);
uv . x = nbl_glsl_wrapTexCoord(uv . x, wrap . x);
uv . y = nbl_glsl_wrapTexCoord(uv . y, wrap . y);
vec3 virtualUV = nbl_glsl_unpackVirtualUV(_texData);
uint formatID = nbl_glsl_VT_layer2pid(uint(virtualUV . z));
virtualUV . xy += uv * originalSz;
virtualUV . xy *= nbl_glsl_VT_getVTexSzRcp();
return nbl_glsl_vTextureGrad_impl(formatID, virtualUV, dUV, int(nbl_glsl_unpackMaxMipInVT(_texData)));
}
#endif
#if _NBL_VT_INT_VIEWS_COUNT
ivec4 nbl_glsl_iVTextureLod_impl(in uint formatID, in vec3 virtualUV, in uint lod, in int originalMaxFullMip)
{
int nonnegativeLod = int(lod);
int clippedLoD = min(nonnegativeLod, originalMaxFullMip);
int levelInTail = nonnegativeLod - clippedLoD;
vec3 physCoord = nbl_glsl_vTexture_helper(formatID, virtualUV, clippedLoD, levelInTail);
#ifdef NBL_GL_EXT_nonuniform_qualifier
return textureLod(iphysicalTileStorageFormatView[nonuniformEXT(formatID)], physCoord, lod);
#else
ivec4 retval;
uint64_t outstandingSampleMask = ballotARB(true);
while (outstandingSampleMask != uint64_t(0u))
{
uvec2 tmp = unpackUint2x32(outstandingSampleMask);
uint subgroupFormatID = readInvocationARB(formatID, tmp[1]!= 0u ? 32u : findLSB(tmp[0]));
bool canSample = subgroupFormatID == formatID;
outstandingSampleMask ^= ballotARB(canSample);
if (canSample)
retval = textureLod(iphysicalTileStorageFormatView[subgroupFormatID], physCoord, lod);
}
return retval;
#endif
}
ivec4 nbl_glsl_iVTextureLod(in uvec2 _texData, in vec2 uv, in uint lod)
{
vec2 originalSz = nbl_glsl_unpackSize(_texData);
uvec2 wrap = nbl_glsl_unpackWrapModes(_texData);
uv . x = nbl_glsl_wrapTexCoord(uv . x, wrap . x);
uv . y = nbl_glsl_wrapTexCoord(uv . y, wrap . y);
vec3 virtualUV = nbl_glsl_unpackVirtualUV(_texData);
uint formatID = nbl_glsl_VT_layer2pid(uint(virtualUV . z));
virtualUV . xy += uv * originalSz;
virtualUV . xy *= nbl_glsl_VT_getVTexSzRcp();
return nbl_glsl_iVTextureLod_impl(formatID, virtualUV, lod, int(nbl_glsl_unpackMaxMipInVT(_texData)));
}
#endif
#if _NBL_VT_UINT_VIEWS_COUNT
uvec4 nbl_glsl_uVTextureLod_impl(in uint formatID, in vec3 virtualUV, in uint lod, in int originalMaxFullMip)
{
int nonnegativeLod = int(lod);
int clippedLoD = min(nonnegativeLod, originalMaxFullMip);
int levelInTail = nonnegativeLod - clippedLoD;
vec3 physCoord = nbl_glsl_vTexture_helper(formatID, virtualUV, clippedLoD, levelInTail);
#ifdef NBL_GL_EXT_nonuniform_qualifier
return textureLod(uphysicalTileStorageFormatView[nonuniformEXT(formatID)], physCoord, lod);
#else
uvec4 retval;
uint64_t outstandingSampleMask = ballotARB(true);
while (outstandingSampleMask != uint64_t(0u))
{
uvec2 tmp = unpackUint2x32(outstandingSampleMask);
uint subgroupFormatID = readInvocationARB(formatID, tmp[1]!= 0u ? 32u : findLSB(tmp[0]));
bool canSample = subgroupFormatID == formatID;
outstandingSampleMask ^= ballotARB(canSample);
if (canSample)
retval = textureLod(uphysicalTileStorageFormatView[subgroupFormatID], physCoord, lod);
}
return retval;
#endif
}
uvec4 nbl_glsl_uVTextureLod(in uvec2 _texData, in vec2 uv, in uint lod)
{
vec2 originalSz = nbl_glsl_unpackSize(_texData);
uvec2 wrap = nbl_glsl_unpackWrapModes(_texData);
uv . x = nbl_glsl_wrapTexCoord(uv . x, wrap . x);
uv . y = nbl_glsl_wrapTexCoord(uv . y, wrap . y);
vec3 virtualUV = nbl_glsl_unpackVirtualUV(_texData);
uint formatID = nbl_glsl_VT_layer2pid(uint(virtualUV . z));
virtualUV . xy += uv * originalSz;
virtualUV . xy *= nbl_glsl_VT_getVTexSzRcp();
return nbl_glsl_uVTextureLod_impl(formatID, virtualUV, lod, int(nbl_glsl_unpackMaxMipInVT(_texData)));
}
#endif
#endif
#line 13 "nbl/builtin/glsl/virtual_texturing/functions.glsl/7/8"
#endif
#line 75 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/shadeVBuffer.comp"
#define _NBL_FRAG_SET3_BINDINGS_DEFINED_
#define _NBL_FRAG_PUSH_CONSTANTS_DEFINED_
vec4 nbl_sample_Ka(in vec2 uv, in mat2 dUV){ return nbl_glsl_vTextureGrad(gBatchInstance . map_Ka_data, uv, dUV);}
vec4 nbl_sample_Kd(in vec2 uv, in mat2 dUV){ return nbl_glsl_vTextureGrad(gBatchInstance . map_Kd_data, uv, dUV);}
vec4 nbl_sample_Ks(in vec2 uv, in mat2 dUV){ return nbl_glsl_vTextureGrad(gBatchInstance . map_Ks_data, uv, dUV);}
vec4 nbl_sample_Ns(in vec2 uv, in mat2 dUV){ return nbl_glsl_vTextureGrad(gBatchInstance . map_Ns_data, uv, dUV);}
vec4 nbl_sample_d(in vec2 uv, in mat2 dUV){ return nbl_glsl_vTextureGrad(gBatchInstance . map_d_data, uv, dUV);}
vec4 nbl_sample_bump(in vec2 uv, in mat2 dUV){ return nbl_glsl_vTextureGrad(gBatchInstance . map_bump_data, uv, dUV);}
#define _NBL_TEXTURE_SAMPLE_FUNCTIONS_DEFINED_
mat2x3 dPdBary;
mat2x3 nbl_glsl_perturbNormal_dPdSomething()
{
return dPdBary;
}
mat2 dUVdBary;
mat2 nbl_glsl_perturbNormal_dUVdSomething()
{
return dUVdBary;
}
#define _NBL_BUILTIN_GLSL_BUMP_MAPPING_DERIVATIVES_DECLARED_
#line 1 "nbl/builtin/glsl/colorspace/OETF.glsl"
#line 1 "nbl/builtin/glsl/colorspace/OETF.glsl"
#ifndef _NBL_BUILTIN_GLSL_COLOR_SPACE_OETF_INCLUDED_
#define _NBL_BUILTIN_GLSL_COLOR_SPACE_OETF_INCLUDED_
vec3 nbl_glsl_oetf_identity(in vec3 linear)
{
return linear;
}
vec3 nbl_glsl_oetf_impl_shared_2_4(in vec3 linear, in float vertex)
{
bvec3 right = greaterThan(linear, vec3(vertex));
return mix(linear * 12.92, pow(linear, vec3(1.0 / 2.4))* 1.055 - vec3(0.055), right);
}
vec3 nbl_glsl_oetf_sRGB(in vec3 linear)
{
bvec3 negatif = lessThan(linear, vec3(0.0));
vec3 absVal = nbl_glsl_oetf_impl_shared_2_4(abs(linear), 0.0031308);
return mix(absVal, - absVal, negatif);
}
vec3 nbl_glsl_oetf_Display_P3(in vec3 linear)
{
return nbl_glsl_oetf_impl_shared_2_4(linear, 0.0030186);
}
vec3 nbl_glsl_oetf_DCI_P3_XYZ(in vec3 linear)
{
return pow(linear / 52.37, vec3(1.0 / 2.6));
}
vec3 nbl_glsl_oetf_SMPTE_170M(in vec3 linear)
{
const float alpha = 1.099296826809443;
const vec3 beta = vec3(0.018053968510808);
return mix(linear * 4.5, pow(linear, vec3(0.45))* alpha - vec3(alpha - 1.0), greaterThanEqual(linear, beta));
}
vec3 nbl_glsl_oetf_SMPTE_ST2084(in vec3 linear)
{
const vec3 m1 = vec3(0.1593017578125);
const vec3 m2 = vec3(78.84375);
const float c2 = 18.8515625;
const float c3 = 18.68875;
const vec3 c1 = vec3(c3 - c2 + 1.0);
vec3 L_m1 = pow(linear, m1);
return pow((c1 + L_m1 * c2)/ (vec3(1.0)+ L_m1 * c3), m2);
}
vec3 nbl_glsl_oetf_HDR10_HLG(in vec3 linear)
{
const float a = 0.1239574303172;
const vec3 b = vec3(0.02372241);
const vec3 c = vec3(1.0042934693729);
bvec3 right = greaterThan(linear, vec3(1.0 / 12.0));
return mix(sqrt(linear * 3.0), log2(linear - b)* a + c, right);
}
vec3 nbl_glsl_oetf_AdobeRGB(in vec3 linear)
{
return pow(linear, vec3(1.0 / 2.19921875));
}
vec3 nbl_glsl_oetf_Gamma_2_2(in vec3 linear)
{
return pow(linear, vec3(1.0 / 2.2));
}
vec3 nbl_glsl_oetf_ACEScc(in vec3 linear)
{
bvec3 mid = greaterThanEqual(linear, vec3(0.0));
bvec3 right = greaterThanEqual(linear, vec3(0.000030517578125));
return (log2(mix(vec3(0.0000152587890625), vec3(0.0), right)+ linear * mix(vec3(0.0), mix(vec3(0.5), vec3(1.0), right), mid))+ vec3(9.72))/ 17.52;
}
vec3 nbl_glsl_oetf_ACEScct(in vec3 linear)
{
bvec3 right = greaterThan(linear, vec3(0.0078125));
return mix(10.5402377416545 * linear + 0.0729055341958355, (log2(linear)+ vec3(9.72))/ 17.52, right);
}
#endif
#line 103 "C:/work/Nabla/examples_tests/41.VisibilityBuffer/shadeVBuffer.comp"
void main()
{
const ivec2 fragCoord = ivec2(gl_GlobalInvocationID);
if (any(greaterThanEqual(fragCoord, textureSize(vBuffer, 0))))
return;
const uvec4 triangleIDdrawID_unorm16Bary_dBarydScreenHalf2x2 = texelFetch(vBuffer, fragCoord, 0);
const uint drawGUID = bitfieldExtract(triangleIDdrawID_unorm16Bary_dBarydScreenHalf2x2[0], MAX_TRIANGLES_IN_BATCH, 32 - MAX_TRIANGLES_IN_BATCH);
const uint triangleID = bitfieldExtract(triangleIDdrawID_unorm16Bary_dBarydScreenHalf2x2[0], 0, MAX_TRIANGLES_IN_BATCH);
const vec2 bary = unpackUnorm2x16(triangleIDdrawID_unorm16Bary_dBarydScreenHalf2x2[1]);
const mat2 dBary = mat2(
unpackHalf2x16(triangleIDdrawID_unorm16Bary_dBarydScreenHalf2x2[2]),
unpackHalf2x16(triangleIDdrawID_unorm16Bary_dBarydScreenHalf2x2[3])
);
gBatchInstance = batchInstanceData[drawID];
uvec3 vertexIDs;
const uint baseTriangleVertex = triangleID * 3u + gBatchInstance . firstIndex;
for (uint i = 0u;i < 3u;i ++)
vertexIDs[i]= nbl_glsl_VG_fetchTriangleVertexIndex(baseTriangleVertex, i)
vec3 pos, normal;
vec2 uv;
mat2 dUVdScreen;
{
vec3 positions[3];
vec2 uvs[3];
for (int i = 0;i < 3;i ++)
{
positions[i]= nbl_glsl_fetchVtxPos(vertexIDs[i], drawGUID);
uvs[i]= nbl_glsl_fetchVtxUV(vertexIDs[i], drawGUID);
}
dPdBary[0]= positions[1]- positions[0];
dPdBary[1]= positions[2]- positions[0];
pos = dPdBary * bary + positions[0];
dUVdBary[0]= uvs[1]- uvs[0];
dUVdBary[1]= uvs[2]- uvs[0];
uv = dUVdBary * bary + uvs[0];
dUVdScreen = nbl_glsl_applyChainRule2D(dUVdBary, dBary);
const float lastBary = 1.f - bary . x - bary . y;
normal = nbl_glsl_fetchVtxNormal(vertices[0], drawGUID)* bary . x;
normal += nbl_glsl_fetchVtxNormal(vertices[1], drawGUID)* bary . y;
normal += nbl_glsl_fetchVtxNormal(vertices[2], drawGUID)* lastBary;
}
vec4 color;
imageStore(frameBuffer, fragCoord, vec4(nbl_glsl_oetf_sRGB(color . rgb), color . a));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment