Commit for 2022.07.27 00-01-19.7z
This commit is contained in:
parent
61cd2a6b5c
commit
40e346f71c
@ -61,24 +61,28 @@
|
|||||||
"vulkan": {
|
"vulkan": {
|
||||||
"validation": { "enabled": false,
|
"validation": { "enabled": false,
|
||||||
"filters": [
|
"filters": [
|
||||||
"MessageID = 0x35d7ea98", // VUID-vkUpdateDescriptorSets-None-03047 ()
|
"0x35d7ea98", // VUID-vkUpdateDescriptorSets-None-03047 ()
|
||||||
|
|
||||||
"MessageID = 0x4dae5635", // UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout (false positive for cubemaps)
|
"0x4dae5635", // UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout (false positive for cubemaps)
|
||||||
"MessageID = 0x609a13b", // UNASSIGNED-CoreValidation-Shader-OutputNotConsumed (from depth-only calls)
|
"0x609a13b", // UNASSIGNED-CoreValidation-Shader-OutputNotConsumed (from depth-only calls)
|
||||||
"MessageID = 0x23e43bb7", // UNASSIGNED-CoreValidation-Shader-InputNotProduced (from depth-only calls)
|
"0x23e43bb7", // UNASSIGNED-CoreValidation-Shader-InputNotProduced (from depth-only calls)
|
||||||
|
|
||||||
"MessageID = 0x71500fba", // VUID-vkDestroyDevice-device-00378 (don't care about a clean cleanup)
|
"0x71500fba", // VUID-vkDestroyDevice-device-00378 (don't care about a clean cleanup)
|
||||||
"MessageID = 0x7d560045" // VUID-vkCmdPipelineBarrier-dstStageMask-06462 (false positive, pipeline barrier for BLAS)
|
"0x7d560045", // VUID-vkCmdPipelineBarrier-dstStageMask-06462 (false positive, pipeline barrier for BLAS)
|
||||||
// "MessageID = 0x9cacd67a" // UNASSIGNED-CoreValidation-DrawState-QueryNotReset (false positive)
|
|
||||||
|
|
||||||
// "MessageID = 0xe91b58a0" // VUID-vkCmdDrawIndexed-None-02686 (?)
|
"0xde55a405", // VUID-VkDescriptorImageInfo-imageLayout-00344 (bitches because )
|
||||||
|
"0x9410d614" // VUID-vkCmdDrawIndexedIndirect-None-02699 (same as above)
|
||||||
|
|
||||||
// "MessageID = 0x124ffb34", // VUID-VkImageMemoryBarrier-oldLayout-01197 (hacky bloom-shit)
|
// "0x9cacd67a" // UNASSIGNED-CoreValidation-DrawState-QueryNotReset (false positive)
|
||||||
// "MessageID = 0x8ab1932c", // VUID-VkImageViewCreateInfo-imageViewType-04973 (hacky bloom-shit)
|
|
||||||
|
|
||||||
// "MessageID = 0x8e1000ad", // VUID-vkCmdDrawIndexedIndirect-None-04008 (bitches without nullDescriptor)
|
// "0xe91b58a0" // VUID-vkCmdDrawIndexed-None-02686 (?)
|
||||||
// "MessageID = 0x9dd97212", // VUID-vkCmdDrawIndexedIndirect-None-02721 (bitches without nullDescriptor)
|
|
||||||
// "MessageID = 0x36481fcb", // VUID-vkCmdBindVertexBuffers-pBuffers-04001 (bitches without nullDescriptor)
|
// "0x124ffb34", // VUID-VkImageMemoryBarrier-oldLayout-01197 (hacky bloom-shit)
|
||||||
|
// "0x8ab1932c", // VUID-VkImageViewCreateInfo-imageViewType-04973 (hacky bloom-shit)
|
||||||
|
|
||||||
|
// "0x8e1000ad", // VUID-vkCmdDrawIndexedIndirect-None-04008 (bitches without nullDescriptor)
|
||||||
|
// "0x9dd97212", // VUID-vkCmdDrawIndexedIndirect-None-02721 (bitches without nullDescriptor)
|
||||||
|
// "0x36481fcb", // VUID-vkCmdBindVertexBuffers-pBuffers-04001 (bitches without nullDescriptor)
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"framebuffer": {
|
"framebuffer": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
// "import": "./rp_downtown_v2.json"
|
// "import": "./rp_downtown_v2.json"
|
||||||
// "import": "./ss2_medsci1.json"
|
"import": "./ss2_medsci1.json"
|
||||||
// "import": "./sh2_mcdonalds.json"
|
// "import": "./sh2_mcdonalds.json"
|
||||||
"import": "./gm_construct.json"
|
// "import": "./gm_construct.json"
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"import": "./base_sourceengine.json",
|
"import": "./base_sourceengine.json",
|
||||||
"assets": [
|
"assets": [
|
||||||
// { "filename": "./models/ss2_medsci1.glb" }
|
{ "filename": "./models/ss2_medsci1.glb" }
|
||||||
{ "filename": "./models/ss2_medsci1/graph.json" }
|
// { "filename": "./models/ss2_medsci1/graph.json" }
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"graph": {
|
"graph": {
|
||||||
|
@ -7,11 +7,11 @@
|
|||||||
// { "filename": "./models/tiny_msci.glb" }
|
// { "filename": "./models/tiny_msci.glb" }
|
||||||
// { "filename": "./models/tiny_msci/graph.json" }
|
// { "filename": "./models/tiny_msci/graph.json" }
|
||||||
|
|
||||||
// { "filename": "./models/micro_sci.glb" }
|
{ "filename": "./models/micro_sci.glb" }
|
||||||
// { "filename": "./models/micro_sci/graph.json" }
|
// { "filename": "./models/micro_sci/graph.json" }
|
||||||
|
|
||||||
// { "filename": "./models/msci.glb" }
|
// { "filename": "./models/msci.glb" }
|
||||||
{ "filename": "./models/msci/graph.json" }
|
// { "filename": "./models/msci/graph.json" }
|
||||||
|
|
||||||
// { "filename": "./models/medsci.glb" }
|
// { "filename": "./models/medsci.glb" }
|
||||||
// { "filename": "./models/medsci/graph.json" }
|
// { "filename": "./models/medsci/graph.json" }
|
||||||
@ -28,14 +28,13 @@
|
|||||||
"tags": {
|
"tags": {
|
||||||
"/^worldspawn/": {
|
"/^worldspawn/": {
|
||||||
"physics": { "type": "mesh", "static": true },
|
"physics": { "type": "mesh", "static": true },
|
||||||
"grid": { "size": [3,1,3], "epsilon": 0.0001, "cleanup": true, "print": true },
|
// "grid": { "size": [3,1,3], "epsilon": 0.0001, "cleanup": true, "print": true },
|
||||||
"optimize mesh": { "simplify": 0 },
|
"optimize mesh": { "simplify": 0 },
|
||||||
"unwrap mesh": true
|
"unwrap mesh": true
|
||||||
},
|
},
|
||||||
"info_player_spawn": {
|
"info_player_spawn": {
|
||||||
"action": "attach",
|
"action": "attach",
|
||||||
"filename": "./player.json",
|
"filename": "./player.json"
|
||||||
"preserve orientation": true
|
|
||||||
},
|
},
|
||||||
"ambience_xerxes": { "action": "load", "payload": { "import": "./ambience.json", "assets": [ "./audio/soundscape/xerxes.ogg" ], "metadata": { "audio": { "rolloffFactor": 0.5, "volume": 1.0 } } } },
|
"ambience_xerxes": { "action": "load", "payload": { "import": "./ambience.json", "assets": [ "./audio/soundscape/xerxes.ogg" ], "metadata": { "audio": { "rolloffFactor": 0.5, "volume": 1.0 } } } },
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ struct Surface {
|
|||||||
#if MULTISAMPLING
|
#if MULTISAMPLING
|
||||||
struct MSAA {
|
struct MSAA {
|
||||||
int currentID;
|
int currentID;
|
||||||
uvec3 IDs[MAX_MSAA_SAMPLES];
|
uvec2 IDs[MAX_MSAA_SAMPLES];
|
||||||
vec4 fragment;
|
vec4 fragment;
|
||||||
vec4 fragments[MAX_MSAA_SAMPLES];
|
vec4 fragments[MAX_MSAA_SAMPLES];
|
||||||
} msaa;
|
} msaa;
|
||||||
|
@ -26,18 +26,12 @@ layout (constant_id = 1) const uint CUBEMAPS = 128;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !MULTISAMPLING
|
#if !MULTISAMPLING
|
||||||
layout(binding = 0) uniform usampler2D /*texture2D*/ samplerId;
|
layout(binding = 0) uniform utexture2D samplerId;
|
||||||
layout(binding = 1) uniform sampler2D /*texture2D*/ samplerBary;
|
layout(binding = 1) uniform texture2D samplerBary;
|
||||||
layout(binding = 2) uniform sampler2D /*texture2D*/ samplerMips;
|
layout(binding = 5) uniform texture2D samplerDepth;
|
||||||
layout(binding = 3) uniform sampler2D /*texture2D*/ samplerNormal;
|
|
||||||
layout(binding = 4) uniform sampler2D /*texture2D*/ samplerUv;
|
|
||||||
layout(binding = 5) uniform sampler2D /*texture2D*/ samplerDepth;
|
|
||||||
#else
|
#else
|
||||||
layout(binding = 0) uniform utexture2DMS samplerId;
|
layout(binding = 0) uniform utexture2DMS samplerId;
|
||||||
layout(binding = 1) uniform texture2DMS samplerBary;
|
layout(binding = 1) uniform texture2DMS samplerBary;
|
||||||
layout(binding = 2) uniform texture2DMS samplerMips;
|
|
||||||
layout(binding = 3) uniform texture2DMS samplerNormal;
|
|
||||||
layout(binding = 4) uniform texture2DMS samplerUv;
|
|
||||||
layout(binding = 5) uniform texture2DMS samplerDepth;
|
layout(binding = 5) uniform texture2DMS samplerDepth;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -110,7 +104,7 @@ layout(buffer_reference, scalar) buffer VID { uint v[]; };
|
|||||||
#include "../../common/vxgi.h"
|
#include "../../common/vxgi.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define IMAGE_LOAD(X) texture( X, inUv ) //texelFetch( X, ivec2(gl_GlobalInvocationID.xy), 0 )
|
#define IMAGE_LOAD(X) texelFetch( X, ivec2(gl_GlobalInvocationID.xy), 0 ) //texelFetch( X, ivec2(gl_GlobalInvocationID.xy), 0 )
|
||||||
#define IMAGE_LOAD_MS(X, I) texelFetch( X, ivec2(gl_GlobalInvocationID.xy), I )
|
#define IMAGE_LOAD_MS(X, I) texelFetch( X, ivec2(gl_GlobalInvocationID.xy), I )
|
||||||
|
|
||||||
#define IMAGE_STORE(X, Y) imageStore( X, ivec2(gl_GlobalInvocationID.xy), Y )
|
#define IMAGE_STORE(X, Y) imageStore( X, ivec2(gl_GlobalInvocationID.xy), Y )
|
||||||
@ -160,27 +154,6 @@ void populateSurface() {
|
|||||||
surface.position.eye = positionEye.xyz;
|
surface.position.eye = positionEye.xyz;
|
||||||
surface.position.world = vec3( ubo.eyes[surface.pass].iView * positionEye );
|
surface.position.world = vec3( ubo.eyes[surface.pass].iView * positionEye );
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
{
|
|
||||||
const vec4 near4 = ubo.eyes[surface.pass].iProjectionView * (vec4(2.0 * inUv - 1.0, -1.0, 1.0));
|
|
||||||
const vec4 far4 = ubo.eyes[surface.pass].iProjectionView * (vec4(2.0 * inUv - 1.0, 1.0, 1.0));
|
|
||||||
const vec3 near3 = near4.xyz / near4.w;
|
|
||||||
const vec3 far3 = far4.xyz / far4.w;
|
|
||||||
|
|
||||||
surface.ray.origin = near3;
|
|
||||||
surface.ray.direction = normalize( far3 - near3 );
|
|
||||||
}
|
|
||||||
// separate our ray direction due to floating point precision problems
|
|
||||||
{
|
|
||||||
const mat4 iProjectionView = inverse( ubo.eyes[surface.pass].projection * mat4(mat3(ubo.eyes[surface.pass].view)) );
|
|
||||||
const vec4 near4 = iProjectionView * (vec4(2.0 * inUv - 1.0, -1.0, 1.0));
|
|
||||||
const vec4 far4 = iProjectionView * (vec4(2.0 * inUv - 1.0, 1.0, 1.0));
|
|
||||||
const vec3 near3 = near4.xyz / near4.w;
|
|
||||||
const vec3 far3 = far4.xyz / far4.w;
|
|
||||||
|
|
||||||
surface.ray.direction = normalize( far3 - near3 );
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
{
|
{
|
||||||
const mat4 iProjectionView = inverse( ubo.eyes[surface.pass].projection * mat4(mat3(ubo.eyes[surface.pass].view)) );
|
const mat4 iProjectionView = inverse( ubo.eyes[surface.pass].projection * mat4(mat3(ubo.eyes[surface.pass].view)) );
|
||||||
const vec4 near4 = iProjectionView * (vec4(2.0 * inUv - 1.0, -1.0, 1.0));
|
const vec4 near4 = iProjectionView * (vec4(2.0 * inUv - 1.0, -1.0, 1.0));
|
||||||
@ -191,16 +164,15 @@ void populateSurface() {
|
|||||||
surface.ray.direction = normalize( far3 - near3 );
|
surface.ray.direction = normalize( far3 - near3 );
|
||||||
surface.ray.origin = ubo.eyes[surface.pass].eyePos.xyz;
|
surface.ray.origin = ubo.eyes[surface.pass].eyePos.xyz;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !MULTISAMPLING
|
#if !MULTISAMPLING
|
||||||
const uvec3 ID = uvec3(IMAGE_LOAD(samplerId).xyz);
|
const uvec2 ID = uvec2(IMAGE_LOAD(samplerId).xy);
|
||||||
#else
|
#else
|
||||||
const uvec3 ID = msaa.IDs[msaa.currentID]; // IMAGE_LOAD_MS(samplerId, msaa.currentID).xy; //resolve(samplerId, ubo.settings.mode.msaa).xy;
|
const uvec2 ID = msaa.IDs[msaa.currentID]; // IMAGE_LOAD_MS(samplerId, msaa.currentID).xy; //resolve(samplerId, ubo.settings.mode.msaa).xy;
|
||||||
#endif
|
#endif
|
||||||
surface.motion = vec2(0);
|
surface.motion = vec2(0);
|
||||||
|
|
||||||
if ( ID.x == 0 || ID.y == 0 || ID.z == 0 ) {
|
if ( ID.x == 0 || ID.y == 0 ) {
|
||||||
if ( 0 <= ubo.settings.lighting.indexSkybox && ubo.settings.lighting.indexSkybox < CUBEMAPS ) {
|
if ( 0 <= ubo.settings.lighting.indexSkybox && ubo.settings.lighting.indexSkybox < CUBEMAPS ) {
|
||||||
surface.fragment.rgb = texture( samplerCubemaps[ubo.settings.lighting.indexSkybox], surface.ray.direction ).rgb;
|
surface.fragment.rgb = texture( samplerCubemaps[ubo.settings.lighting.indexSkybox], surface.ray.direction ).rgb;
|
||||||
}
|
}
|
||||||
@ -208,116 +180,92 @@ void populateSurface() {
|
|||||||
//postProcess();
|
//postProcess();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const uint drawID = ID.x - 1;
|
|
||||||
const uint triangleID = ID.y - 1;
|
|
||||||
const uint instanceID = ID.z - 1;
|
|
||||||
|
|
||||||
#if !MULTISAMPLING
|
#if !MULTISAMPLING
|
||||||
surface.barycentrics = IMAGE_LOAD(samplerBary).xyz;
|
// surface.barycentrics = IMAGE_LOAD(samplerBary).xyz;
|
||||||
#else
|
{
|
||||||
surface.barycentrics = IMAGE_LOAD_MS(samplerBary, msaa.currentID).xyz; // resolve(samplerBary, ubo.settings.mode.msaa).xy;
|
vec2 encodedBarycentrics = IMAGE_LOAD(samplerBary).xy;
|
||||||
#endif
|
surface.barycentrics = vec3(
|
||||||
{
|
1.0 - encodedBarycentrics.x - encodedBarycentrics.y,
|
||||||
#if !MULTISAMPLING
|
encodedBarycentrics.x,
|
||||||
const vec4 uv = IMAGE_LOAD(samplerUv);
|
encodedBarycentrics.y
|
||||||
const vec2 mips = IMAGE_LOAD(samplerMips).xy;
|
);
|
||||||
surface.normal.world = decodeNormals( IMAGE_LOAD(samplerNormal).xy );
|
|
||||||
#else
|
|
||||||
const vec4 uv = IMAGE_LOAD_MS(samplerUv, msaa.currentID); // resolve(samplerUv, ubo.settings.mode.msaa);
|
|
||||||
const vec2 mips = IMAGE_LOAD_MS(samplerMips, msaa.currentID).xy; // resolve(samplerUv, ubo.settings.mode.msaa);
|
|
||||||
surface.normal.world = decodeNormals( IMAGE_LOAD_MS(samplerNormal, msaa.currentID).xy ); // decodeNormals( resolve(samplerNormal, ubo.settings.mode.msaa).xy );
|
|
||||||
#endif
|
|
||||||
surface.uv.xy = uv.xy;
|
|
||||||
surface.uv.z = mips.x;
|
|
||||||
surface.st.xy = uv.zw;
|
|
||||||
surface.st.z = mips.y;
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// surface.barycentrics = IMAGE_LOAD_MS(samplerBary, msaa.currentID).xyz; // resolve(samplerBary, ubo.settings.mode.msaa).xy;
|
||||||
|
{
|
||||||
|
vec2 encodedBarycentrics = IMAGE_LOAD_MS(samplerBary, msaa.currentID).xy; // resolve(samplerBary, ubo.settings.mode.msaa).xy;
|
||||||
|
surface.barycentrics = vec3(
|
||||||
|
1.0 - encodedBarycentrics.x - encodedBarycentrics.y,
|
||||||
|
encodedBarycentrics.x,
|
||||||
|
encodedBarycentrics.y
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const uint drawID = ID.x - 1;
|
||||||
const DrawCommand drawCommand = drawCommands[drawID];
|
const DrawCommand drawCommand = drawCommands[drawID];
|
||||||
|
const uint instanceID = drawID;
|
||||||
const Instance instance = instances[instanceID];
|
const Instance instance = instances[instanceID];
|
||||||
surface.instance = instance;
|
surface.instance = instance;
|
||||||
|
|
||||||
{
|
{
|
||||||
vec4 pNDC = ubo.eyes[surface.pass].previous * instance.previous * vec4(surface.position.world, 1);
|
const uint triangleID = ID.y - 1;
|
||||||
vec4 cNDC = ubo.eyes[surface.pass].model * instance.model * vec4(surface.position.world, 1);
|
|
||||||
pNDC /= pNDC.w;
|
|
||||||
cNDC /= cNDC.w;
|
|
||||||
|
|
||||||
surface.motion = cNDC.xy - pNDC.xy;
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
const InstanceAddresses instanceAddresses = instanceAddresses[instanceID];
|
const InstanceAddresses instanceAddresses = instanceAddresses[instanceID];
|
||||||
|
|
||||||
if ( 0 < instanceAddresses.index ) {
|
Triangle triangle;
|
||||||
Triangle triangle;
|
|
||||||
const DrawCommand drawCommand = Indirects(nonuniformEXT(instanceAddresses.indirect)).dc[instanceAddresses.drawID];
|
|
||||||
const vec3 bary = surface.barycentrics;
|
|
||||||
|
|
||||||
Vertex points[3];
|
Vertex points[3];
|
||||||
uvec3 indices = uvec3( triangleID * 3 + 0, triangleID * 3 + 1, triangleID * 3 + 2 );
|
uvec3 indices = uvec3( triangleID * 3 + 0, triangleID * 3 + 1, triangleID * 3 + 2 );
|
||||||
|
|
||||||
if ( 0 < instanceAddresses.vertex ) {
|
if ( 0 < instanceAddresses.vertex ) {
|
||||||
Vertices vertices = Vertices(nonuniformEXT(instanceAddresses.vertex));
|
Vertices vertices = Vertices(nonuniformEXT(instanceAddresses.vertex));
|
||||||
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_] = vertices.v[/*triangle.*/indices[_]];
|
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_] = vertices.v[/*triangle.*/indices[_]];
|
||||||
} else {
|
|
||||||
if ( 0 < instanceAddresses.position ) {
|
|
||||||
VPos buf = VPos(nonuniformEXT(instanceAddresses.position));
|
|
||||||
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_].position = buf.v[/*triangle.*/indices[_]];
|
|
||||||
}
|
|
||||||
if ( 0 < instanceAddresses.uv ) {
|
|
||||||
VUv buf = VUv(nonuniformEXT(instanceAddresses.uv));
|
|
||||||
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_].uv = buf.v[/*triangle.*/indices[_]];
|
|
||||||
}
|
|
||||||
if ( 0 < instanceAddresses.st ) {
|
|
||||||
VSt buf = VSt(nonuniformEXT(instanceAddresses.st));
|
|
||||||
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_].st = buf.v[/*triangle.*/indices[_]];
|
|
||||||
}
|
|
||||||
if ( 0 < instanceAddresses.normal ) {
|
|
||||||
VNormal buf = VNormal(nonuniformEXT(instanceAddresses.normal));
|
|
||||||
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_].normal = buf.v[/*triangle.*/indices[_]];
|
|
||||||
}
|
|
||||||
if ( 0 < instanceAddresses.tangent ) {
|
|
||||||
VTangent buf = VTangent(nonuniformEXT(instanceAddresses.tangent));
|
|
||||||
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_].tangent = buf.v[/*triangle.*/indices[_]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
triangle.point.position = /*triangle.*/points[0].position * bary[0] + /*triangle.*/points[1].position * bary[1] + /*triangle.*/points[2].position * bary[2];
|
|
||||||
triangle.point.uv = /*triangle.*/points[0].uv * bary[0] + /*triangle.*/points[1].uv * bary[1] + /*triangle.*/points[2].uv * bary[2];
|
|
||||||
triangle.point.st = /*triangle.*/points[0].st * bary[0] + /*triangle.*/points[1].st * bary[1] + /*triangle.*/points[2].st * bary[2];
|
|
||||||
triangle.point.normal = /*triangle.*/points[0].normal * bary[0] + /*triangle.*/points[1].normal * bary[1] + /*triangle.*/points[2].normal * bary[2];
|
|
||||||
triangle.point.tangent = /*triangle.*/points[0].tangent * bary[0] + /*triangle.*/points[1].tangent * bary[1] + /*triangle.*/points[2].tangent * bary[2];
|
|
||||||
|
|
||||||
{
|
|
||||||
surface.position.world = vec3( instance.model * vec4(triangle.point.position, 1.0 ) );
|
|
||||||
surface.position.eye = vec3( ubo.eyes[surface.pass].view * vec4(surface.position.world, 1.0) );
|
|
||||||
}
|
|
||||||
// bind normals
|
|
||||||
{
|
|
||||||
surface.normal.world = normalize(vec3( instance.model * vec4(triangle.point.normal, 0.0 ) ));
|
|
||||||
surface.normal.eye = vec3( ubo.eyes[surface.pass].view * vec4(surface.normal.world, 0.0) );
|
|
||||||
}
|
|
||||||
// bind UVs
|
|
||||||
{
|
|
||||||
surface.uv.xy = triangle.point.uv;
|
|
||||||
surface.st.xy = triangle.point.st;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
#if !MULTISAMPLING
|
if ( 0 < instanceAddresses.position ) {
|
||||||
const vec4 uv = IMAGE_LOAD(samplerUv);
|
VPos buf = VPos(nonuniformEXT(instanceAddresses.position));
|
||||||
const vec2 mips = IMAGE_LOAD(samplerMips).xy;
|
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_].position = buf.v[/*triangle.*/indices[_]];
|
||||||
surface.normal.world = decodeNormals( IMAGE_LOAD(samplerNormal).xy );
|
}
|
||||||
#else
|
if ( 0 < instanceAddresses.uv ) {
|
||||||
const vec4 uv = IMAGE_LOAD_MS(samplerUv, msaa.currentID); // resolve(samplerUv, ubo.settings.mode.msaa);
|
VUv buf = VUv(nonuniformEXT(instanceAddresses.uv));
|
||||||
const vec2 mips = IMAGE_LOAD_MS(samplerMips, msaa.currentID).xy; // resolve(samplerUv, ubo.settings.mode.msaa);
|
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_].uv = buf.v[/*triangle.*/indices[_]];
|
||||||
surface.normal.world = decodeNormals( IMAGE_LOAD_MS(samplerNormal, msaa.currentID).xy ); // decodeNormals( resolve(samplerNormal, ubo.settings.mode.msaa).xy );
|
}
|
||||||
#endif
|
if ( 0 < instanceAddresses.st ) {
|
||||||
|
VSt buf = VSt(nonuniformEXT(instanceAddresses.st));
|
||||||
|
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_].st = buf.v[/*triangle.*/indices[_]];
|
||||||
|
}
|
||||||
|
if ( 0 < instanceAddresses.normal ) {
|
||||||
|
VNormal buf = VNormal(nonuniformEXT(instanceAddresses.normal));
|
||||||
|
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_].normal = buf.v[/*triangle.*/indices[_]];
|
||||||
|
}
|
||||||
|
if ( 0 < instanceAddresses.tangent ) {
|
||||||
|
VTangent buf = VTangent(nonuniformEXT(instanceAddresses.tangent));
|
||||||
|
for ( uint _ = 0; _ < 3; ++_ ) /*triangle.*/points[_].tangent = buf.v[/*triangle.*/indices[_]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
triangle.point.position = /*triangle.*/points[0].position * surface.barycentrics[0] + /*triangle.*/points[1].position * surface.barycentrics[1] + /*triangle.*/points[2].position * surface.barycentrics[2];
|
||||||
|
triangle.point.uv = /*triangle.*/points[0].uv * surface.barycentrics[0] + /*triangle.*/points[1].uv * surface.barycentrics[1] + /*triangle.*/points[2].uv * surface.barycentrics[2];
|
||||||
|
triangle.point.st = /*triangle.*/points[0].st * surface.barycentrics[0] + /*triangle.*/points[1].st * surface.barycentrics[1] + /*triangle.*/points[2].st * surface.barycentrics[2];
|
||||||
|
triangle.point.normal = /*triangle.*/points[0].normal * surface.barycentrics[0] + /*triangle.*/points[1].normal * surface.barycentrics[1] + /*triangle.*/points[2].normal * surface.barycentrics[2];
|
||||||
|
triangle.point.tangent = /*triangle.*/points[0].tangent * surface.barycentrics[0] + /*triangle.*/points[1].tangent * surface.barycentrics[1] + /*triangle.*/points[2].tangent * surface.barycentrics[2];
|
||||||
|
|
||||||
|
// bind position
|
||||||
|
if ( false ) {
|
||||||
|
surface.position.world = vec3( instance.model * vec4(triangle.point.position, 1.0 ) );
|
||||||
|
surface.position.eye = vec3( ubo.eyes[surface.pass].view * vec4(surface.position.world, 1.0) );
|
||||||
|
}
|
||||||
|
// bind normals
|
||||||
|
{
|
||||||
|
surface.normal.world = normalize(vec3( instance.model * vec4(triangle.point.normal, 0.0 ) ));
|
||||||
surface.normal.eye = vec3( ubo.eyes[surface.pass].view * vec4(surface.normal.world, 0.0) );
|
surface.normal.eye = vec3( ubo.eyes[surface.pass].view * vec4(surface.normal.world, 0.0) );
|
||||||
surface.uv.xy = uv.xy;
|
}
|
||||||
surface.uv.z = mips.x;
|
// bind UVs
|
||||||
surface.st.xy = uv.zw;
|
{
|
||||||
surface.st.z = mips.y;
|
surface.uv.xy = triangle.point.uv;
|
||||||
|
surface.uv.z = 0;
|
||||||
|
surface.st.xy = triangle.point.st;
|
||||||
|
surface.st.z = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,6 +312,15 @@ void populateSurface() {
|
|||||||
surface.material.metallic = samp.r;
|
surface.material.metallic = samp.r;
|
||||||
surface.material.roughness = samp.g;
|
surface.material.roughness = samp.g;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
vec4 pNDC = ubo.eyes[surface.pass].previous * instance.previous * vec4(surface.position.world, 1);
|
||||||
|
vec4 cNDC = ubo.eyes[surface.pass].model * instance.model * vec4(surface.position.world, 1);
|
||||||
|
pNDC /= pNDC.w;
|
||||||
|
cNDC /= cNDC.w;
|
||||||
|
|
||||||
|
surface.motion = cNDC.xy - pNDC.xy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void directLighting() {
|
void directLighting() {
|
||||||
@ -383,7 +340,7 @@ void directLighting() {
|
|||||||
void resolveSurfaceFragment() {
|
void resolveSurfaceFragment() {
|
||||||
for ( int i = 0; i < ubo.settings.mode.msaa; ++i ) {
|
for ( int i = 0; i < ubo.settings.mode.msaa; ++i ) {
|
||||||
msaa.currentID = i;
|
msaa.currentID = i;
|
||||||
msaa.IDs[i] = uvec3(IMAGE_LOAD_MS(samplerId, msaa.currentID)).xyz;
|
msaa.IDs[i] = uvec3(IMAGE_LOAD_MS(samplerId, msaa.currentID)).xy;
|
||||||
|
|
||||||
// check if ID is already used
|
// check if ID is already used
|
||||||
bool unique = true;
|
bool unique = true;
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
#version 450
|
|
||||||
#pragma shader_stage(fragment)
|
|
||||||
|
|
||||||
#define DEFERRED_SAMPLING 1
|
|
||||||
#define MULTISAMPLING 0
|
|
||||||
#include "./frag.h"
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
populateSurface();
|
|
||||||
directLighting();
|
|
||||||
postProcess();
|
|
||||||
}
|
|
@ -1,313 +0,0 @@
|
|||||||
#extension GL_EXT_samplerless_texture_functions : require
|
|
||||||
#extension GL_EXT_nonuniform_qualifier : enable
|
|
||||||
|
|
||||||
#if RAYTRACE
|
|
||||||
#extension GL_EXT_ray_query : require
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TONE_MAP 0
|
|
||||||
#define GAMMA_CORRECT 0
|
|
||||||
#define DEFERRED 1
|
|
||||||
#define MAX_TEXTURES TEXTURES
|
|
||||||
//#define TEXTURE_WORKAROUND 0
|
|
||||||
|
|
||||||
#include "../../common/macros.h"
|
|
||||||
|
|
||||||
layout (constant_id = 0) const uint TEXTURES = 512;
|
|
||||||
layout (constant_id = 1) const uint CUBEMAPS = 128;
|
|
||||||
#if VXGI
|
|
||||||
layout (constant_id = 2) const uint CASCADES = 16;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !MULTISAMPLING
|
|
||||||
layout (input_attachment_index = 0, binding = 0) uniform usubpassInput samplerId;
|
|
||||||
layout (input_attachment_index = 1, binding = 1) uniform usubpassInput samplerBary;
|
|
||||||
layout (input_attachment_index = 2, binding = 2) uniform subpassInput samplerMips;
|
|
||||||
layout (input_attachment_index = 3, binding = 3) uniform subpassInput samplerNormal;
|
|
||||||
layout (input_attachment_index = 4, binding = 4) uniform subpassInput samplerUv;
|
|
||||||
layout (input_attachment_index = 5, binding = 5) uniform subpassInput samplerDepth;
|
|
||||||
#else
|
|
||||||
layout (input_attachment_index = 0, binding = 0) uniform usubpassInputMS samplerId;
|
|
||||||
layout (input_attachment_index = 1, binding = 1) uniform usubpassInputMS samplerBary;
|
|
||||||
layout (input_attachment_index = 2, binding = 2) uniform subpassInputMS samplerMips;
|
|
||||||
layout (input_attachment_index = 3, binding = 3) uniform subpassInputMS samplerNormal;
|
|
||||||
layout (input_attachment_index = 4, binding = 4) uniform subpassInputMS samplerUv;
|
|
||||||
layout (input_attachment_index = 5, binding = 5) uniform subpassInputMS samplerDepth;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../../common/structs.h"
|
|
||||||
|
|
||||||
layout (binding = 6) uniform UBO {
|
|
||||||
EyeMatrices eyes[2];
|
|
||||||
|
|
||||||
Settings settings;
|
|
||||||
} ubo;
|
|
||||||
/*
|
|
||||||
*/
|
|
||||||
layout (std140, binding = 7) readonly buffer DrawCommands {
|
|
||||||
DrawCommand drawCommands[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 8) readonly buffer Instances {
|
|
||||||
Instance instances[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 9) readonly buffer InstanceAddresseses {
|
|
||||||
InstanceAddresses instanceAddresses[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 10) readonly buffer Materials {
|
|
||||||
Material materials[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 11) readonly buffer Textures {
|
|
||||||
Texture textures[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 12) readonly buffer Lights {
|
|
||||||
Light lights[];
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (binding = 13) uniform sampler2D samplerTextures[TEXTURES];
|
|
||||||
layout (binding = 14) uniform samplerCube samplerCubemaps[CUBEMAPS];
|
|
||||||
layout (binding = 15) uniform sampler3D samplerNoise;
|
|
||||||
#if VXGI
|
|
||||||
layout (binding = 16) uniform usampler3D voxelId[CASCADES];
|
|
||||||
layout (binding = 17) uniform sampler3D voxelNormal[CASCADES];
|
|
||||||
layout (binding = 18) uniform sampler3D voxelRadiance[CASCADES];
|
|
||||||
#endif
|
|
||||||
#if RAYTRACE
|
|
||||||
layout (binding = 19) uniform accelerationStructureEXT tlas;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
layout (location = 0) in vec2 inUv;
|
|
||||||
layout (location = 1) in flat uvec2 inPushConstantPass;
|
|
||||||
|
|
||||||
layout (location = 0) out vec4 outFragColor;
|
|
||||||
layout (location = 1) out vec4 outFragBright;
|
|
||||||
layout (location = 2) out vec2 outFragMotion;
|
|
||||||
|
|
||||||
layout(buffer_reference, scalar) buffer Vertices { Vertex v[]; };
|
|
||||||
layout(buffer_reference, scalar) buffer Indices { uvec3 i[]; };
|
|
||||||
layout(buffer_reference, scalar) buffer Indirects { DrawCommand dc[]; };
|
|
||||||
|
|
||||||
layout(buffer_reference, scalar) buffer VPos { vec3 v[]; };
|
|
||||||
layout(buffer_reference, scalar) buffer VUv { vec2 v[]; };
|
|
||||||
layout(buffer_reference, scalar) buffer VColor { uint v[]; };
|
|
||||||
layout(buffer_reference, scalar) buffer VSt { vec2 v[]; };
|
|
||||||
layout(buffer_reference, scalar) buffer VNormal { vec3 v[]; };
|
|
||||||
layout(buffer_reference, scalar) buffer VTangent { vec3 v[]; };
|
|
||||||
layout(buffer_reference, scalar) buffer VID { uint v[]; };
|
|
||||||
|
|
||||||
#include "../../common/functions.h"
|
|
||||||
#include "../../common/fog.h"
|
|
||||||
#include "../../common/light.h"
|
|
||||||
#include "../../common/shadows.h"
|
|
||||||
#if VXGI
|
|
||||||
#include "../../common/vxgi.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void postProcess() {
|
|
||||||
float brightness = dot(surface.fragment.rgb, vec3(0.2126, 0.7152, 0.0722));
|
|
||||||
outFragBright = brightness > ubo.settings.bloom.brightnessThreshold ? vec4(surface.fragment.rgb, 1.0) : vec4(0, 0, 0, 1);
|
|
||||||
outFragMotion = surface.motion;
|
|
||||||
|
|
||||||
#if FOG
|
|
||||||
fog( surface.ray, surface.fragment.rgb, surface.fragment.a );
|
|
||||||
#endif
|
|
||||||
#if TONE_MAP
|
|
||||||
surface.fragment.rgb = vec3(1.0) - exp(-surface.fragment.rgb * ubo.settings.bloom.exposure);
|
|
||||||
#endif
|
|
||||||
#if GAMMA_CORRECT
|
|
||||||
surface.fragment.rgb = pow(surface.fragment.rgb, vec3(1.0 / ubo.settings.bloom.gamma));
|
|
||||||
#endif
|
|
||||||
#if WHITENOISE
|
|
||||||
if ( enabled(ubo.settings.mode.type, 1) ) whitenoise(surface.fragment.rgb, ubo.settings.mode.parameters);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// outFragColor = vec4(surface.fragment.rgb, 1.0);
|
|
||||||
outFragColor = vec4(surface.normal.world, 1.0);
|
|
||||||
outFragBright = vec4( abs(surface.normal.eye), 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
void populateSurface() {
|
|
||||||
surface.fragment = vec4(0);
|
|
||||||
surface.pass = inPushConstantPass.x;
|
|
||||||
|
|
||||||
{
|
|
||||||
#if !MULTISAMPLING
|
|
||||||
const float depth = subpassLoad(samplerDepth).r;
|
|
||||||
#else
|
|
||||||
const float depth = subpassLoad(samplerDepth, msaa.currentID).r; // resolve(samplerDepth, ubo.settings.mode.msaa).r;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
vec4 positionEye = ubo.eyes[surface.pass].iProjection * vec4(inUv * 2.0 - 1.0, depth, 1.0);
|
|
||||||
positionEye /= positionEye.w;
|
|
||||||
surface.position.eye = positionEye.xyz;
|
|
||||||
surface.position.world = vec3( ubo.eyes[surface.pass].iView * positionEye );
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
{
|
|
||||||
const vec4 near4 = ubo.eyes[surface.pass].iProjectionView * (vec4(2.0 * inUv - 1.0, -1.0, 1.0));
|
|
||||||
const vec4 far4 = ubo.eyes[surface.pass].iProjectionView * (vec4(2.0 * inUv - 1.0, 1.0, 1.0));
|
|
||||||
const vec3 near3 = near4.xyz / near4.w;
|
|
||||||
const vec3 far3 = far4.xyz / far4.w;
|
|
||||||
|
|
||||||
surface.ray.origin = near3;
|
|
||||||
surface.ray.direction = normalize( far3 - near3 );
|
|
||||||
}
|
|
||||||
// separate our ray direction due to floating point precision problems
|
|
||||||
{
|
|
||||||
const mat4 iProjectionView = inverse( ubo.eyes[surface.pass].projection * mat4(mat3(ubo.eyes[surface.pass].view)) );
|
|
||||||
const vec4 near4 = iProjectionView * (vec4(2.0 * inUv - 1.0, -1.0, 1.0));
|
|
||||||
const vec4 far4 = iProjectionView * (vec4(2.0 * inUv - 1.0, 1.0, 1.0));
|
|
||||||
const vec3 near3 = near4.xyz / near4.w;
|
|
||||||
const vec3 far3 = far4.xyz / far4.w;
|
|
||||||
|
|
||||||
surface.ray.direction = normalize( far3 - near3 );
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
{
|
|
||||||
const mat4 iProjectionView = inverse( ubo.eyes[surface.pass].projection * mat4(mat3(ubo.eyes[surface.pass].view)) );
|
|
||||||
const vec4 near4 = iProjectionView * (vec4(2.0 * inUv - 1.0, -1.0, 1.0));
|
|
||||||
const vec4 far4 = iProjectionView * (vec4(2.0 * inUv - 1.0, 1.0, 1.0));
|
|
||||||
const vec3 near3 = near4.xyz / near4.w;
|
|
||||||
const vec3 far3 = far4.xyz / far4.w;
|
|
||||||
|
|
||||||
surface.ray.direction = normalize( far3 - near3 );
|
|
||||||
surface.ray.origin = ubo.eyes[surface.pass].eyePos.xyz;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !MULTISAMPLING
|
|
||||||
surface.normal.world = decodeNormals( subpassLoad(samplerNormal).xy );
|
|
||||||
const uvec3 ID = subpassLoad(samplerId).xyz;
|
|
||||||
#else
|
|
||||||
surface.normal.world = decodeNormals( subpassLoad(samplerNormal, msaa.currentID).xy ); // decodeNormals( resolve(samplerNormal, ubo.settings.mode.msaa).xy );
|
|
||||||
const uvec3 ID = msaa.IDs[msaa.currentID]; // subpassLoad(samplerId, msaa.currentID).xy; //resolve(samplerId, ubo.settings.mode.msaa).xy;
|
|
||||||
#endif
|
|
||||||
surface.normal.eye = vec3( ubo.eyes[surface.pass].view * vec4(surface.normal.world, 0.0) );
|
|
||||||
surface.motion = vec2(0);
|
|
||||||
|
|
||||||
if ( ID.x == 0 || ID.y == 0 || ID.z == 0 ) {
|
|
||||||
if ( 0 <= ubo.settings.lighting.indexSkybox && ubo.settings.lighting.indexSkybox < CUBEMAPS ) {
|
|
||||||
surface.fragment.rgb = texture( samplerCubemaps[ubo.settings.lighting.indexSkybox], surface.ray.direction ).rgb;
|
|
||||||
}
|
|
||||||
surface.fragment.a = 0.0;
|
|
||||||
// postProcess();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const uint drawID = ID.x - 1;
|
|
||||||
const uint triangleID = ID.y - 1;
|
|
||||||
const uint instanceID = ID.z - 1;
|
|
||||||
|
|
||||||
const DrawCommand drawCommand = drawCommands[drawID];
|
|
||||||
const Instance instance = instances[instanceID];
|
|
||||||
surface.instance = instance;
|
|
||||||
|
|
||||||
{
|
|
||||||
vec4 pNDC = ubo.eyes[surface.pass].previous * instance.previous * vec4(surface.position.world, 1);
|
|
||||||
vec4 cNDC = ubo.eyes[surface.pass].model * instance.model * vec4(surface.position.world, 1);
|
|
||||||
pNDC /= pNDC.w;
|
|
||||||
cNDC /= cNDC.w;
|
|
||||||
|
|
||||||
surface.motion = cNDC.xy - pNDC.xy;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Material material = materials[surface.instance.materialID];
|
|
||||||
surface.material.albedo = material.colorBase;
|
|
||||||
surface.material.metallic = material.factorMetallic;
|
|
||||||
surface.material.roughness = material.factorRoughness;
|
|
||||||
surface.material.occlusion = material.factorOcclusion;
|
|
||||||
surface.fragment = material.colorEmissive;
|
|
||||||
|
|
||||||
{
|
|
||||||
#if !MULTISAMPLING
|
|
||||||
const vec4 uv = subpassLoad(samplerUv);
|
|
||||||
const vec2 mips = subpassLoad(samplerMips).xy;
|
|
||||||
#else
|
|
||||||
const vec4 uv = subpassLoad(samplerUv, msaa.currentID); // resolve(samplerUv, ubo.settings.mode.msaa);
|
|
||||||
const vec2 mips = subpassLoad(samplerMips, msaa.currentID).xy; // resolve(samplerUv, ubo.settings.mode.msaa);
|
|
||||||
#endif
|
|
||||||
surface.uv.xy = uv.xy;
|
|
||||||
surface.uv.z = mips.x;
|
|
||||||
surface.st.xy = uv.zw;
|
|
||||||
surface.st.z = mips.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( validTextureIndex( material.indexAlbedo ) ) {
|
|
||||||
surface.material.albedo *= sampleTexture( material.indexAlbedo );
|
|
||||||
}
|
|
||||||
// OPAQUE
|
|
||||||
if ( material.modeAlpha == 0 ) {
|
|
||||||
surface.material.albedo.a = 1;
|
|
||||||
// BLEND
|
|
||||||
} else if ( material.modeAlpha == 1 ) {
|
|
||||||
|
|
||||||
// MASK
|
|
||||||
} else if ( material.modeAlpha == 2 ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
// Lightmap
|
|
||||||
if ( bool(ubo.settings.lighting.useLightmaps) && validTextureIndex( surface.instance.lightmapID ) ) {
|
|
||||||
vec4 light = sampleTexture( surface.instance.lightmapID, surface.st );
|
|
||||||
surface.material.lightmapped = light.a > 0.001;
|
|
||||||
if ( surface.material.lightmapped ) surface.light += surface.material.albedo * light;
|
|
||||||
} else {
|
|
||||||
surface.material.lightmapped = false;
|
|
||||||
}
|
|
||||||
// Emissive textures
|
|
||||||
if ( validTextureIndex( material.indexEmissive ) ) {
|
|
||||||
surface.light += sampleTexture( material.indexEmissive );
|
|
||||||
}
|
|
||||||
// Occlusion map
|
|
||||||
if ( validTextureIndex( material.indexOcclusion ) ) {
|
|
||||||
surface.material.occlusion = sampleTexture( material.indexOcclusion ).r;
|
|
||||||
}
|
|
||||||
// Metallic/Roughness map
|
|
||||||
if ( validTextureIndex( material.indexMetallicRoughness ) ) {
|
|
||||||
vec4 samp = sampleTexture( material.indexMetallicRoughness );
|
|
||||||
surface.material.metallic = samp.r;
|
|
||||||
surface.material.roughness = samp.g;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void directLighting() {
|
|
||||||
surface.light.rgb += surface.material.albedo.rgb * ubo.settings.lighting.ambient.rgb * surface.material.occlusion; // add ambient lighting
|
|
||||||
surface.light.rgb += surface.material.indirect.rgb; // add indirect lighting
|
|
||||||
#if PBR
|
|
||||||
pbr();
|
|
||||||
#elif LAMBERT
|
|
||||||
lambert();
|
|
||||||
#elif PHONG
|
|
||||||
phong();
|
|
||||||
#endif
|
|
||||||
surface.fragment.rgb += surface.light.rgb;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MULTISAMPLING
|
|
||||||
void resolveSurfaceFragment() {
|
|
||||||
for ( int i = 0; i < ubo.settings.mode.msaa; ++i ) {
|
|
||||||
msaa.currentID = i;
|
|
||||||
msaa.IDs[i] = subpassLoad(samplerId, msaa.currentID).xyz;
|
|
||||||
|
|
||||||
// check if ID is already used
|
|
||||||
bool unique = true;
|
|
||||||
for ( int j = msaa.currentID - 1; j >= 0; --j ) {
|
|
||||||
if ( msaa.IDs[j] == msaa.IDs[i] ) {
|
|
||||||
surface.fragment = msaa.fragments[j];
|
|
||||||
unique = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( unique ) {
|
|
||||||
populateSurface();
|
|
||||||
#if VXGI
|
|
||||||
indirectLighting();
|
|
||||||
#endif
|
|
||||||
directLighting();
|
|
||||||
}
|
|
||||||
|
|
||||||
msaa.fragment += surface.fragment;
|
|
||||||
msaa.fragments[msaa.currentID] = surface.fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
surface.fragment = msaa.fragment / ubo.settings.mode.msaa;
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,12 +0,0 @@
|
|||||||
#version 450
|
|
||||||
#pragma shader_stage(fragment)
|
|
||||||
|
|
||||||
#define DEFERRED_SAMPLING 1
|
|
||||||
#define MULTISAMPLING 1
|
|
||||||
#include "./frag.h"
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
resolveSurfaceFragment();
|
|
||||||
|
|
||||||
postProcess();
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
#version 450
|
|
||||||
#pragma shader_stage(fragment)
|
|
||||||
|
|
||||||
#define VXGI 0
|
|
||||||
#define DEFERRED_SAMPLING 1
|
|
||||||
#define MULTISAMPLING 0
|
|
||||||
#include "./frag.h"
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
populateSurface();
|
|
||||||
directLighting();
|
|
||||||
postProcess();
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
#version 450
|
|
||||||
#pragma shader_stage(vertex)
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
layout (location = 0) in vec2 inPos;
|
|
||||||
layout (location = 1) in vec2 inUv;
|
|
||||||
#endif
|
|
||||||
layout (location = 0) out vec2 outUv;
|
|
||||||
layout (location = 1) out flat uvec2 outPushConstantPass;
|
|
||||||
|
|
||||||
layout( push_constant ) uniform PushBlock {
|
|
||||||
uint pass;
|
|
||||||
uint draw;
|
|
||||||
} PushConstant;
|
|
||||||
|
|
||||||
out gl_PerVertex {
|
|
||||||
vec4 gl_Position;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
outPushConstantPass = uvec2(PushConstant.pass, PushConstant.draw);
|
|
||||||
outUv = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
|
|
||||||
gl_Position = vec4(outUv * 2.0f + -1.0f, 0.0f, 1.0f);
|
|
||||||
#if 0
|
|
||||||
outUv = inUv;
|
|
||||||
gl_Position = vec4(inPos.xy, 0.0, 1.0);
|
|
||||||
#endif
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
#version 450
|
|
||||||
#pragma shader_stage(fragment)
|
|
||||||
|
|
||||||
#define VXGI 1
|
|
||||||
#define DEFERRED_SAMPLING 1
|
|
||||||
#define MULTISAMPLING 0
|
|
||||||
#include "./frag.h"
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
populateSurface();
|
|
||||||
indirectLighting();
|
|
||||||
directLighting();
|
|
||||||
postProcess();
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
#version 450
|
|
||||||
#pragma shader_stage(fragment)
|
|
||||||
|
|
||||||
#define VXGI 1
|
|
||||||
#define DEFERRED_SAMPLING 1
|
|
||||||
#define MULTISAMPLING 1
|
|
||||||
#include "./frag.h"
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
resolveSurfaceFragment();
|
|
||||||
postProcess();
|
|
||||||
}
|
|
@ -72,44 +72,12 @@ void main() {
|
|||||||
imageStore(voxelRadiance[CASCADE], ivec3(tUvw), vec4(0));
|
imageStore(voxelRadiance[CASCADE], ivec3(tUvw), vec4(0));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// const DrawCommand drawCommand = drawCommands[drawID];
|
const DrawCommand drawCommand = drawCommands[drawID];
|
||||||
surface.instance = instances[instanceID];
|
surface.instance = instances[instanceID];
|
||||||
const Material material = materials[surface.instance.materialID];
|
const Material material = materials[surface.instance.materialID];
|
||||||
surface.material.albedo = material.colorBase;
|
surface.material.albedo = material.colorBase;
|
||||||
surface.fragment = material.colorEmissive;
|
surface.fragment = material.colorEmissive;
|
||||||
/*
|
|
||||||
#if DEFERRED_SAMPLING
|
|
||||||
{
|
|
||||||
vec4 uv = imageLoad(voxelUv[CASCADE], ivec3(tUvw) );
|
|
||||||
surface.uv.xy = uv.xy;
|
|
||||||
surface.st.xy = uv.zw;
|
|
||||||
}
|
|
||||||
if ( validTextureIndex( material.indexAlbedo ) ) {
|
|
||||||
surface.material.albedo = sampleTexture( material.indexAlbedo );
|
|
||||||
}
|
|
||||||
|
|
||||||
// OPAQUE
|
|
||||||
if ( material.modeAlpha == 0 ) {
|
|
||||||
surface.material.albedo.a = 1;
|
|
||||||
// BLEND
|
|
||||||
} else if ( material.modeAlpha == 1 ) {
|
|
||||||
|
|
||||||
// MASK
|
|
||||||
} else if ( material.modeAlpha == 2 ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
// Lightmap
|
|
||||||
if ( validTextureIndex( surface.instance.lightmapID ) ) {
|
|
||||||
surface.material.albedo.rgb *= sampleTexture( surface.instance.lightmapID, surface.st ).rgb;
|
|
||||||
}
|
|
||||||
// Emissive textures
|
|
||||||
if ( validTextureIndex( material.indexEmissive ) ) {
|
|
||||||
surface.material.albedo += sampleTexture( material.indexEmissive, mip );
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
surface.material.albedo = imageLoad(voxelRadiance[CASCADE], ivec3(tUvw) );
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
surface.material.albedo = imageLoad(voxelRadiance[CASCADE], ivec3(tUvw) );
|
surface.material.albedo = imageLoad(voxelRadiance[CASCADE], ivec3(tUvw) );
|
||||||
surface.material.metallic = material.factorMetallic;
|
surface.material.metallic = material.factorMetallic;
|
||||||
surface.material.roughness = material.factorRoughness;
|
surface.material.roughness = material.factorRoughness;
|
||||||
@ -152,12 +120,6 @@ void main() {
|
|||||||
const vec3 specular = (F * D * G) / max(EPSILON, 4.0 * cosLi * cosLo);
|
const vec3 specular = (F * D * G) / max(EPSILON, 4.0 * cosLi * cosLo);
|
||||||
#endif
|
#endif
|
||||||
// lightmapped, compute only specular
|
// lightmapped, compute only specular
|
||||||
/*
|
|
||||||
if ( light.type >= 0 && validTextureIndex( surface.instance.lightmapID ) ) surface.light.rgb += (specular) * Lr * cosLi;
|
|
||||||
// point light, compute only diffuse
|
|
||||||
// else if ( abs(light.type) == 1 ) surface.light.rgb += (diffuse) * Lr * cosLi;
|
|
||||||
else surface.light.rgb += (diffuse + specular) * Lr * cosLi;
|
|
||||||
*/
|
|
||||||
surface.light.rgb += (diffuse + specular) * Lr * cosLi;
|
surface.light.rgb += (diffuse + specular) * Lr * cosLi;
|
||||||
surface.light.a += light.power * La * Ls;
|
surface.light.a += light.power * La * Ls;
|
||||||
}
|
}
|
||||||
|
@ -46,25 +46,29 @@ layout (binding = 13, rgba8) uniform volatile coherent image3D outAlbedos;
|
|||||||
#include "../../common/pbr.h"
|
#include "../../common/pbr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
layout (location = 0) in vec3 inPosition;
|
layout (location = 0) flat in uvec4 inId;
|
||||||
layout (location = 1) flat in vec3 inPositionRaw;
|
layout (location = 1) flat in vec4 inPOS0;
|
||||||
layout (location = 2) in vec2 inUv;
|
layout (location = 2) in vec4 inPOS1;
|
||||||
layout (location = 3) in vec2 inSt;
|
|
||||||
layout (location = 4) in vec4 inColor;
|
layout (location = 3) in vec3 inPosition;
|
||||||
layout (location = 5) in vec3 inNormal;
|
layout (location = 4) in vec2 inUv;
|
||||||
layout (location = 6) in vec3 inTangent;
|
layout (location = 5) in vec4 inColor;
|
||||||
layout (location = 7) flat in uvec4 inId;
|
layout (location = 6) in vec2 inSt;
|
||||||
layout (location = 8) flat in uint inLayer;
|
layout (location = 7) in vec3 inNormal;
|
||||||
|
layout (location = 8) in vec3 inTangent;
|
||||||
|
|
||||||
layout (location = 0) out vec4 outAlbedo;
|
layout (location = 0) out vec4 outAlbedo;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
const uint drawID = uint(inId.x);
|
const uint drawID = uint(inId.x);
|
||||||
const uint instanceID = uint(inId.y);
|
const uint triangleID = uint(inId.y);
|
||||||
const uint materialID = uint(inId.z);
|
const uint instanceID = uint(inId.z);
|
||||||
|
|
||||||
|
const DrawCommand drawCommand = drawCommands[drawID];
|
||||||
|
const Instance instance = instances[instanceID];
|
||||||
|
|
||||||
vec3 T = inTangent;
|
|
||||||
vec3 N = inNormal;
|
vec3 N = inNormal;
|
||||||
|
vec3 T = inTangent;
|
||||||
T = normalize(T - dot(T, N) * N);
|
T = normalize(T - dot(T, N) * N);
|
||||||
vec3 B = cross(T, N);
|
vec3 B = cross(T, N);
|
||||||
// mat3 TBN = mat3(T, B, N);
|
// mat3 TBN = mat3(T, B, N);
|
||||||
@ -73,7 +77,7 @@ void main() {
|
|||||||
surface.uv.xy = wrap(inUv.xy);
|
surface.uv.xy = wrap(inUv.xy);
|
||||||
surface.uv.z = mipLevel(dFdx(inUv), dFdy(inUv));
|
surface.uv.z = mipLevel(dFdx(inUv), dFdy(inUv));
|
||||||
surface.position.world = inPosition;
|
surface.position.world = inPosition;
|
||||||
const Material material = materials[materialID];
|
const Material material = materials[instance.materialID];
|
||||||
|
|
||||||
if ( T != vec3(0) && validTextureIndex( material.indexNormal ) ) {
|
if ( T != vec3(0) && validTextureIndex( material.indexNormal ) ) {
|
||||||
surface.normal.world = TBN * normalize( sampleTexture( material.indexNormal ).xyz * 2.0 - 1.0 );
|
surface.normal.world = TBN * normalize( sampleTexture( material.indexNormal ).xyz * 2.0 - 1.0 );
|
||||||
@ -182,7 +186,7 @@ void main() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
const vec2 st = inSt.xy * imageSize(outAlbedos).xy;
|
const vec2 st = inSt.xy * imageSize(outAlbedos).xy;
|
||||||
const ivec3 uvw = ivec3(int(st.x), int(st.y), int(inLayer));
|
const ivec3 uvw = ivec3(int(st.x), int(st.y), int(drawCommand.auxID));
|
||||||
imageStore(outAlbedos, uvw, vec4(surface.light.rgb, 1) );
|
imageStore(outAlbedos, uvw, vec4(surface.light.rgb, 1) );
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,49 +0,0 @@
|
|||||||
#version 450
|
|
||||||
#pragma shader_stage(geometry)
|
|
||||||
|
|
||||||
layout(triangles) in;
|
|
||||||
layout(triangle_strip, max_vertices = 3) out;
|
|
||||||
|
|
||||||
layout (location = 0) in vec3 inPosition[];
|
|
||||||
layout (location = 1) flat in vec4 inPOS0[];
|
|
||||||
layout (location = 2) in vec4 inPOS1[];
|
|
||||||
layout (location = 3) in vec2 inUv[];
|
|
||||||
layout (location = 4) in vec2 inSt[];
|
|
||||||
layout (location = 5) in vec4 inColor[];
|
|
||||||
layout (location = 6) in vec3 inNormal[];
|
|
||||||
layout (location = 7) in vec3 inTangent[];
|
|
||||||
layout (location = 8) flat in uvec4 inId[];
|
|
||||||
layout (location = 9) flat in uint inLayer[];
|
|
||||||
|
|
||||||
layout (location = 0) out vec3 outPosition;
|
|
||||||
layout (location = 1) flat out vec4 outPOS0;
|
|
||||||
layout (location = 2) out vec4 outPOS1;
|
|
||||||
layout (location = 3) out vec2 outUv;
|
|
||||||
layout (location = 4) out vec2 outSt;
|
|
||||||
layout (location = 5) out vec4 outColor;
|
|
||||||
layout (location = 6) out vec3 outNormal;
|
|
||||||
layout (location = 7) out vec3 outTangent;
|
|
||||||
layout (location = 8) flat out uvec4 outId;
|
|
||||||
layout (location = 9) flat out uint outLayer;
|
|
||||||
|
|
||||||
|
|
||||||
void main(){
|
|
||||||
for( uint i = 0; i < 3; ++i ){
|
|
||||||
outPosition = inPosition[i];
|
|
||||||
outPOS0 = inPOS0[i];
|
|
||||||
outPOS1 = inPOS1[i];
|
|
||||||
outUv = inUv[i];
|
|
||||||
outSt = inSt[i];
|
|
||||||
outColor = inColor[i];
|
|
||||||
outNormal = inNormal[i];
|
|
||||||
outTangent = inTangent[i];
|
|
||||||
outId = inId[i];
|
|
||||||
outLayer = inLayer[i];
|
|
||||||
|
|
||||||
gl_Position = vec4(inSt[i] * 2.0 - 1.0, 0.0, 1.0);
|
|
||||||
gl_Layer = int(inLayer[i]);
|
|
||||||
|
|
||||||
EmitVertex();
|
|
||||||
}
|
|
||||||
EndPrimitive();
|
|
||||||
}
|
|
@ -5,5 +5,6 @@
|
|||||||
#define SKINNED 0
|
#define SKINNED 0
|
||||||
#define BAKING 1
|
#define BAKING 1
|
||||||
#define LAYERED 1
|
#define LAYERED 1
|
||||||
|
#define EXTRA_ATTRIBUTES 1
|
||||||
|
|
||||||
#include "../base/vert.h"
|
#include "../base/vert.h"
|
||||||
|
@ -1,6 +1,155 @@
|
|||||||
#version 450
|
#version 450
|
||||||
#pragma shader_stage(fragment)
|
#pragma shader_stage(fragment)
|
||||||
|
|
||||||
|
//#extension GL_EXT_nonuniform_qualifier : enable
|
||||||
|
#extension GL_EXT_fragment_shader_barycentric : enable
|
||||||
|
#extension GL_AMD_shader_explicit_vertex_parameter : enable
|
||||||
|
|
||||||
|
#define STABILIZE_BARY 1
|
||||||
#define DEFERRED_SAMPLING 1
|
#define DEFERRED_SAMPLING 1
|
||||||
#define QUERY_MIPMAP 0
|
#define QUERY_MIPMAP 0
|
||||||
#include "./frag.h"
|
#define EXTRA_ATTRIBUTES 1
|
||||||
|
#define CUBEMAPS 1
|
||||||
|
#define FRAGMENT 1
|
||||||
|
#define CAN_DISCARD 1
|
||||||
|
// #define MAX_TEXTURES TEXTURES
|
||||||
|
#define MAX_TEXTURES textures.length()
|
||||||
|
layout (constant_id = 0) const uint TEXTURES = 1;
|
||||||
|
|
||||||
|
#include "../../common/macros.h"
|
||||||
|
#include "../../common/structs.h"
|
||||||
|
|
||||||
|
layout (binding = 5) uniform sampler2D samplerTextures[TEXTURES];
|
||||||
|
layout (std140, binding = 6) readonly buffer DrawCommands {
|
||||||
|
DrawCommand drawCommands[];
|
||||||
|
};
|
||||||
|
layout (std140, binding = 7) readonly buffer Instances {
|
||||||
|
Instance instances[];
|
||||||
|
};
|
||||||
|
layout (std140, binding = 8) readonly buffer InstanceAddresseses {
|
||||||
|
InstanceAddresses instanceAddresses[];
|
||||||
|
};
|
||||||
|
layout (std140, binding = 9) readonly buffer Materials {
|
||||||
|
Material materials[];
|
||||||
|
};
|
||||||
|
layout (std140, binding = 10) readonly buffer Textures {
|
||||||
|
Texture textures[];
|
||||||
|
};
|
||||||
|
layout (std140, binding = 11) readonly buffer Lights {
|
||||||
|
Light lights[];
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "../../common/functions.h"
|
||||||
|
|
||||||
|
layout (location = 0) flat in uvec4 inId;
|
||||||
|
layout (location = 1) flat in vec4 inPOS0;
|
||||||
|
layout (location = 2) __explicitInterpAMD in vec4 inPOS1;
|
||||||
|
#if EXTRA_ATTRIBUTES
|
||||||
|
layout (location = 3) in vec3 inPosition;
|
||||||
|
layout (location = 4) in vec2 inUv;
|
||||||
|
layout (location = 5) in vec4 inColor;
|
||||||
|
layout (location = 6) in vec2 inSt;
|
||||||
|
layout (location = 7) in vec3 inNormal;
|
||||||
|
layout (location = 8) in vec3 inTangent;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
layout (location = 0) out uvec2 outId;
|
||||||
|
layout (location = 1) out vec2 outBary;
|
||||||
|
#if 0 && EXTRA_ATTRIBUTES
|
||||||
|
layout (location = 2) out vec2 outMips;
|
||||||
|
layout (location = 3) out vec2 outNormals;
|
||||||
|
layout (location = 4) out vec4 outUvs;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
const uint drawID = uint(inId.x);
|
||||||
|
const uint triangleID = uint(inId.y);
|
||||||
|
const uint instanceID = uint(inId.z);
|
||||||
|
|
||||||
|
const DrawCommand drawCommand = drawCommands[drawID];
|
||||||
|
const Instance instance = instances[instanceID];
|
||||||
|
const Material material = materials[instance.materialID];
|
||||||
|
|
||||||
|
#if EXTRA_ATTRIBUTES
|
||||||
|
#if CAN_DISCARD
|
||||||
|
{
|
||||||
|
surface.uv.xy = wrap(inUv.xy);
|
||||||
|
surface.uv.z = mipLevel(dFdx(inUv), dFdy(inUv));
|
||||||
|
|
||||||
|
vec4 A = inColor * material.colorBase;
|
||||||
|
// sample albedo
|
||||||
|
if ( validTextureIndex( material.indexAlbedo ) ) {
|
||||||
|
A = sampleTexture( material.indexAlbedo );
|
||||||
|
// alpha mode OPAQUE
|
||||||
|
if ( material.modeAlpha == 0 ) {
|
||||||
|
A.a = 1;
|
||||||
|
// alpha mode BLEND
|
||||||
|
} else if ( material.modeAlpha == 1 ) {
|
||||||
|
|
||||||
|
// alpha mode MASK
|
||||||
|
} else if ( material.modeAlpha == 2 ) {
|
||||||
|
if ( A.a < abs(material.factorAlphaCutoff) ) discard;
|
||||||
|
A.a = 1;
|
||||||
|
}
|
||||||
|
if ( A.a < 1 ) discard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
vec3 T = inTangent;
|
||||||
|
vec3 N = inNormal;
|
||||||
|
T = normalize(T - dot(T, N) * N);
|
||||||
|
vec3 B = cross(T, N);
|
||||||
|
mat3 TBN = mat3(T, B, N);
|
||||||
|
// mat3 TBN = mat3(N, B, T);
|
||||||
|
// sample normal
|
||||||
|
if ( T != vec3(0) && validTextureIndex( material.indexNormal ) ) {
|
||||||
|
N = TBN * normalize( sampleTexture( material.indexNormal ).xyz * 2.0 - 1.0 );
|
||||||
|
}
|
||||||
|
outUvs.xy = surface.uv.xy;
|
||||||
|
outUvs.zw = surface.st.xy;
|
||||||
|
outMips.x = surface.uv.z;
|
||||||
|
outMips.y = surface.st.z;
|
||||||
|
outNormals = encodeNormals( normalize( N ) );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
outId = uvec2(drawID + 1, triangleID + 1);
|
||||||
|
|
||||||
|
#if STABILIZE_BARY
|
||||||
|
vec4 v0 = interpolateAtVertexAMD(inPOS1, 0);
|
||||||
|
vec4 v1 = interpolateAtVertexAMD(inPOS1, 1);
|
||||||
|
vec4 v2 = interpolateAtVertexAMD(inPOS1, 2);
|
||||||
|
#if 0
|
||||||
|
vec3 bary;
|
||||||
|
if (v0 == inPOS0) {
|
||||||
|
bary.y = gl_BaryCoordSmoothAMD.x;
|
||||||
|
bary.z = gl_BaryCoordSmoothAMD.y;
|
||||||
|
bary.x = 1 - bary.y - bary.z;
|
||||||
|
}
|
||||||
|
else if (v1 == inPOS0) {
|
||||||
|
bary.x = gl_BaryCoordSmoothAMD.x;
|
||||||
|
bary.y = gl_BaryCoordSmoothAMD.y;
|
||||||
|
bary.z = 1 - bary.y - bary.x;
|
||||||
|
}
|
||||||
|
else if (v2 == inPOS0) {
|
||||||
|
bary.z = gl_BaryCoordSmoothAMD.x;
|
||||||
|
bary.x = gl_BaryCoordSmoothAMD.y;
|
||||||
|
bary.y = 1 - bary.z - bary.x;
|
||||||
|
}
|
||||||
|
outBary = bary.yz;
|
||||||
|
#else
|
||||||
|
if (v0 == inPOS0)
|
||||||
|
outBary = (gl_BaryCoordEXT.yzx).yz;
|
||||||
|
else if (v1 == inPOS0)
|
||||||
|
outBary = (gl_BaryCoordEXT.zxy).yz;
|
||||||
|
else if (v2 == inPOS0)
|
||||||
|
outBary = (gl_BaryCoordEXT.xyz).yz;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
outBary = gl_BaryCoordEXT.yz;
|
||||||
|
#endif
|
||||||
|
}
|
@ -1,145 +0,0 @@
|
|||||||
//#extension GL_EXT_nonuniform_qualifier : enable
|
|
||||||
// #extension GL_EXT_fragment_shader_barycentric : enable
|
|
||||||
#extension GL_AMD_shader_explicit_vertex_parameter : enable
|
|
||||||
|
|
||||||
#define CUBEMAPS 1
|
|
||||||
#define FRAGMENT 1
|
|
||||||
// #define MAX_TEXTURES TEXTURES
|
|
||||||
#define MAX_TEXTURES textures.length()
|
|
||||||
layout (constant_id = 0) const uint TEXTURES = 1;
|
|
||||||
|
|
||||||
#include "../../common/macros.h"
|
|
||||||
#include "../../common/structs.h"
|
|
||||||
|
|
||||||
|
|
||||||
layout (binding = 5) uniform sampler2D samplerTextures[TEXTURES];
|
|
||||||
layout (std140, binding = 6) readonly buffer DrawCommands {
|
|
||||||
DrawCommand drawCommands[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 7) readonly buffer Instances {
|
|
||||||
Instance instances[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 8) readonly buffer InstanceAddresseses {
|
|
||||||
InstanceAddresses instanceAddresses[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 9) readonly buffer Materials {
|
|
||||||
Material materials[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 10) readonly buffer Textures {
|
|
||||||
Texture textures[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 11) readonly buffer Lights {
|
|
||||||
Light lights[];
|
|
||||||
};
|
|
||||||
|
|
||||||
#include "../../common/functions.h"
|
|
||||||
|
|
||||||
layout (location = 0) in vec3 inPosition;
|
|
||||||
layout (location = 1) flat in vec4 inPOS0;
|
|
||||||
layout (location = 2) __explicitInterpAMD in vec4 inPOS1;
|
|
||||||
layout (location = 3) in vec2 inUv;
|
|
||||||
layout (location = 4) in vec2 inSt;
|
|
||||||
layout (location = 5) in vec4 inColor;
|
|
||||||
layout (location = 6) in vec3 inNormal;
|
|
||||||
layout (location = 7) in vec3 inTangent;
|
|
||||||
layout (location = 8) flat in uvec4 inId;
|
|
||||||
|
|
||||||
layout (location = 0) out uvec4 outId;
|
|
||||||
layout (location = 1) out vec4 outBary;
|
|
||||||
layout (location = 2) out vec2 outMips;
|
|
||||||
layout (location = 3) out vec2 outNormals;
|
|
||||||
layout (location = 4) out vec4 outUvs;
|
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
const uint drawID = uint(inId.x);
|
|
||||||
const uint triangleID = uint(inId.y);
|
|
||||||
const uint instanceID = uint(inId.z);
|
|
||||||
const vec2 uv = wrap(inUv.xy);
|
|
||||||
const vec3 P = inPosition;
|
|
||||||
|
|
||||||
surface.uv.xy = uv;
|
|
||||||
surface.uv.z = mipLevel(dFdx(inUv), dFdy(inUv));
|
|
||||||
surface.st.xy = inSt;
|
|
||||||
surface.st.z = mipLevel(dFdx(inSt), dFdy(inSt));
|
|
||||||
vec3 T = inTangent;
|
|
||||||
vec3 N = inNormal;
|
|
||||||
T = normalize(T - dot(T, N) * N);
|
|
||||||
vec3 B = cross(T, N);
|
|
||||||
// mat3 TBN = mat3(T, B, N);
|
|
||||||
mat3 TBN = mat3(N, B, T);
|
|
||||||
vec4 A = vec4(0, 0, 0, 0);
|
|
||||||
|
|
||||||
#if CAN_DISCARD
|
|
||||||
const DrawCommand drawCommand = drawCommands[drawID];
|
|
||||||
const Instance instance = instances[instanceID];
|
|
||||||
const Material material = materials[instance.materialID];
|
|
||||||
|
|
||||||
A = material.colorBase;
|
|
||||||
float M = material.factorMetallic;
|
|
||||||
float R = material.factorRoughness;
|
|
||||||
float AO = material.factorOcclusion;
|
|
||||||
|
|
||||||
// sample albedo
|
|
||||||
if ( validTextureIndex( material.indexAlbedo ) ) {
|
|
||||||
A = sampleTexture( material.indexAlbedo );
|
|
||||||
// alpha mode OPAQUE
|
|
||||||
if ( material.modeAlpha == 0 ) {
|
|
||||||
A.a = 1;
|
|
||||||
// alpha mode BLEND
|
|
||||||
} else if ( material.modeAlpha == 1 ) {
|
|
||||||
|
|
||||||
// alpha mode MASK
|
|
||||||
} else if ( material.modeAlpha == 2 ) {
|
|
||||||
if ( A.a < abs(material.factorAlphaCutoff) ) discard;
|
|
||||||
A.a = 1;
|
|
||||||
}
|
|
||||||
if ( A.a == 0 ) discard;
|
|
||||||
}
|
|
||||||
#if USE_LIGHTMAP && !DEFERRED_SAMPLING
|
|
||||||
if ( validTextureIndex( instance.lightmapID ) ) {
|
|
||||||
vec4 light = sampleTexture( instance.lightmapID, surface.st );
|
|
||||||
if ( light.a > 0.001 ) A.rgb *= light.rgb;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
// sample normal
|
|
||||||
if ( T != vec3(0) && validTextureIndex( material.indexNormal ) ) {
|
|
||||||
N = TBN * normalize( sampleTexture( material.indexNormal ).xyz * 2.0 - 1.0 );
|
|
||||||
}
|
|
||||||
outUvs.xy = surface.uv.xy;
|
|
||||||
outUvs.zw = surface.st.xy;
|
|
||||||
|
|
||||||
outMips.x = surface.uv.z;
|
|
||||||
outMips.y = surface.st.z;
|
|
||||||
|
|
||||||
outNormals = encodeNormals( normalize( N ) );
|
|
||||||
outId = uvec4(drawID + 1, triangleID + 1, instanceID + 1, 0);
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
vec4 v0 = interpolateAtVertexAMD(inPOS1, 0);
|
|
||||||
vec4 v1 = interpolateAtVertexAMD(inPOS1, 1);
|
|
||||||
vec4 v2 = interpolateAtVertexAMD(inPOS1, 2);
|
|
||||||
if (v0 == inPOS0) {
|
|
||||||
outBary.y = gl_BaryCoordSmoothAMD.x;
|
|
||||||
outBary.z = gl_BaryCoordSmoothAMD.y;
|
|
||||||
outBary.x = 1 - outBary.z - outBary.y;
|
|
||||||
}
|
|
||||||
else if (v1 == inPOS0) {
|
|
||||||
outBary.x = gl_BaryCoordSmoothAMD.x;
|
|
||||||
outBary.y = gl_BaryCoordSmoothAMD.y;
|
|
||||||
outBary.z = 1 - outBary.x - outBary.y;
|
|
||||||
}
|
|
||||||
else if (v2 == inPOS0) {
|
|
||||||
outBary.z = gl_BaryCoordSmoothAMD.x;
|
|
||||||
outBary.x = gl_BaryCoordSmoothAMD.y;
|
|
||||||
outBary.y = 1 - outBary.x - outBary.z;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// outBary = gl_BaryCoordEXT.xyz;
|
|
||||||
outBary.x = 1 - gl_BaryCoordSmoothAMD.x - gl_BaryCoordSmoothAMD.y;
|
|
||||||
outBary.y = gl_BaryCoordSmoothAMD.x;
|
|
||||||
outBary.z = gl_BaryCoordSmoothAMD.y;
|
|
||||||
#endif
|
|
||||||
}
|
|
@ -4,6 +4,8 @@ layout (constant_id = 0) const uint PASSES = 6;
|
|||||||
#extension GL_ARB_shader_viewport_layer_array : enable
|
#extension GL_ARB_shader_viewport_layer_array : enable
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define EXTRA_ATTRIBUTES 1
|
||||||
|
|
||||||
#include "../../common/macros.h"
|
#include "../../common/macros.h"
|
||||||
#include "../../common/structs.h"
|
#include "../../common/structs.h"
|
||||||
|
|
||||||
@ -42,17 +44,17 @@ layout (std140, binding = 2) readonly buffer Instances {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
layout (location = 0) out vec3 outPosition;
|
layout (location = 0) out uvec4 outId;
|
||||||
layout (location = 1) flat out vec4 outPOS0;
|
layout (location = 1) flat out vec4 outPOS0;
|
||||||
layout (location = 2) out vec4 outPOS1;
|
layout (location = 2) out vec4 outPOS1;
|
||||||
layout (location = 3) out vec2 outUv;
|
|
||||||
layout (location = 4) out vec2 outSt;
|
#if EXTRA_ATTRIBUTES
|
||||||
layout (location = 5) out vec4 outColor;
|
layout (location = 3) out vec3 outPosition;
|
||||||
layout (location = 6) out vec3 outNormal;
|
layout (location = 4) out vec2 outUv;
|
||||||
layout (location = 7) out vec3 outTangent;
|
layout (location = 5) out vec4 outColor;
|
||||||
layout (location = 8) out uvec4 outId;
|
layout (location = 6) out vec2 outSt;
|
||||||
#if LAYERED
|
layout (location = 7) out vec3 outNormal;
|
||||||
layout (location = 9) out uint outLayer;
|
layout (location = 8) out vec3 outTangent;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec4 snap(vec4 vertex, vec2 resolution) {
|
vec4 snap(vec4 vertex, vec2 resolution) {
|
||||||
@ -64,8 +66,6 @@ vec4 snap(vec4 vertex, vec2 resolution) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
outUv = inUv;
|
|
||||||
outSt = inSt;
|
|
||||||
const uint drawID = gl_DrawIDARB;
|
const uint drawID = gl_DrawIDARB;
|
||||||
const uint triangleID = gl_VertexIndex / 3;
|
const uint triangleID = gl_VertexIndex / 3;
|
||||||
const uint instanceID = gl_InstanceIndex;
|
const uint instanceID = gl_InstanceIndex;
|
||||||
@ -90,21 +90,22 @@ void main() {
|
|||||||
// const mat4 model = instances.length() <= 0 ? skinned : (instance.model * skinned);
|
// const mat4 model = instances.length() <= 0 ? skinned : (instance.model * skinned);
|
||||||
const mat4 model = instance.model * skinned;
|
const mat4 model = instance.model * skinned;
|
||||||
|
|
||||||
outId = uvec4(drawID, triangleID, instanceID, PushConstant.pass);
|
|
||||||
outColor = instance.color;
|
|
||||||
outPosition = vec3(model * vec4(inPos.xyz, 1.0));
|
|
||||||
outNormal = normalize(vec3(model * vec4(inNormal.xyz, 0.0)));
|
|
||||||
outTangent = normalize(vec3(view * model * vec4(inTangent.xyz, 0.0)));
|
|
||||||
#if BAKING
|
#if BAKING
|
||||||
gl_Position = vec4(inSt * 2.0 - 1.0, 0.0, 1.0);
|
gl_Position = vec4(inSt * 2.0 - 1.0, 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
gl_Position = projection * view * model * vec4(inPos.xyz, 1.0);
|
gl_Position = projection * view * model * vec4(inPos.xyz, 1.0);
|
||||||
#endif
|
#endif
|
||||||
|
outId = uvec4(drawID, triangleID, instanceID, PushConstant.pass);
|
||||||
outPOS0 = gl_Position;
|
outPOS0 = gl_Position;
|
||||||
outPOS1 = gl_Position;
|
outPOS1 = gl_Position;
|
||||||
|
|
||||||
#if LAYERED
|
#if EXTRA_ATTRIBUTES
|
||||||
// gl_Layer = int(drawCommand.auxID);
|
outPosition = vec3(model * vec4(inPos.xyz, 1.0));
|
||||||
outLayer = int(drawCommand.auxID);
|
outUv = inUv;
|
||||||
|
outSt = inSt;
|
||||||
|
outColor = inColor * instance.color;
|
||||||
|
outNormal = normalize(vec3(model * vec4(inNormal.xyz, 0.0)));
|
||||||
|
outTangent = normalize(vec3(view * model * vec4(inTangent.xyz, 0.0)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
#version 450
|
#version 450
|
||||||
#pragma shader_stage(fragment)
|
#pragma shader_stage(fragment)
|
||||||
|
|
||||||
|
#define EXTRA_ATTRIBUTES 1
|
||||||
#define FRAGMENT 1
|
#define FRAGMENT 1
|
||||||
#define CUBEMAPS 1
|
#define CUBEMAPS 1
|
||||||
// #define MAX_TEXTURES TEXTURES
|
// #define MAX_TEXTURES TEXTURES
|
||||||
@ -32,13 +33,17 @@ layout (std140, binding = 11) readonly buffer Lights {
|
|||||||
|
|
||||||
#include "../../common/functions.h"
|
#include "../../common/functions.h"
|
||||||
|
|
||||||
layout (location = 0) in vec2 inUv;
|
layout (location = 0) flat in uvec4 inId;
|
||||||
layout (location = 1) in vec2 inSt;
|
layout (location = 1) flat in vec4 inPOS0;
|
||||||
layout (location = 2) in vec4 inColor;
|
layout (location = 2) in vec4 inPOS1;
|
||||||
layout (location = 3) in vec3 inNormal;
|
#if EXTRA_ATTRIBUTES
|
||||||
layout (location = 4) in mat3 inTBN;
|
layout (location = 3) in vec3 inPosition;
|
||||||
layout (location = 7) in vec3 inPosition;
|
layout (location = 4) in vec2 inUv;
|
||||||
layout (location = 8) flat in uvec4 inId;
|
layout (location = 5) in vec4 inColor;
|
||||||
|
layout (location = 6) in vec2 inSt;
|
||||||
|
layout (location = 7) in vec3 inNormal;
|
||||||
|
layout (location = 8) in vec3 inTangent;
|
||||||
|
#endif
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
const uint drawID = uint(inId.x);
|
const uint drawID = uint(inId.x);
|
||||||
@ -52,22 +57,19 @@ void main() {
|
|||||||
surface.uv.z = mipLevel(dFdx(inUv), dFdy(inUv));
|
surface.uv.z = mipLevel(dFdx(inUv), dFdy(inUv));
|
||||||
|
|
||||||
// sample albedo
|
// sample albedo
|
||||||
// if ( !validTextureIndex( material.indexAlbedo ) ) discard; {
|
|
||||||
if ( validTextureIndex( material.indexAlbedo ) ) {
|
if ( validTextureIndex( material.indexAlbedo ) ) {
|
||||||
// const Texture t = textures[material.indexAlbedo];
|
|
||||||
// A = textureLod( samplerTextures[nonuniformEXT(t.index)], mix( t.lerp.xy, t.lerp.zw, uv ), mip );
|
|
||||||
A = sampleTexture( material.indexAlbedo );
|
A = sampleTexture( material.indexAlbedo );
|
||||||
// alpha mode OPAQUE
|
|
||||||
if ( material.modeAlpha == 0 ) {
|
|
||||||
A.a = 1;
|
|
||||||
// alpha mode BLEND
|
|
||||||
} else if ( material.modeAlpha == 1 ) {
|
|
||||||
|
|
||||||
// alpha mode MASK
|
|
||||||
} else if ( material.modeAlpha == 2 ) {
|
|
||||||
if ( A.a < abs(material.factorAlphaCutoff) ) discard;
|
|
||||||
A.a = 1;
|
|
||||||
}
|
|
||||||
// if ( A.a < 1 - 0.00001 ) discard;
|
|
||||||
}
|
}
|
||||||
|
// alpha mode OPAQUE
|
||||||
|
if ( material.modeAlpha == 0 ) {
|
||||||
|
A.a = 1;
|
||||||
|
// alpha mode BLEND
|
||||||
|
} else if ( material.modeAlpha == 1 ) {
|
||||||
|
|
||||||
|
// alpha mode MASK
|
||||||
|
} else if ( material.modeAlpha == 2 ) {
|
||||||
|
if ( A.a < abs(material.factorAlphaCutoff) ) discard;
|
||||||
|
A.a = 1;
|
||||||
|
}
|
||||||
|
// if ( A.a < 1 - 0.00001 ) discard;
|
||||||
}
|
}
|
@ -3,4 +3,138 @@
|
|||||||
//#extension GL_EXT_nonuniform_qualifier : enable
|
//#extension GL_EXT_nonuniform_qualifier : enable
|
||||||
|
|
||||||
#define DEFERRED_SAMPLING 0
|
#define DEFERRED_SAMPLING 0
|
||||||
#include "./frag.h"
|
#define FRAGMENT 1
|
||||||
|
#define BLEND 1
|
||||||
|
#define DEPTH_TEST 0
|
||||||
|
#define CUBEMAPS 1
|
||||||
|
#define TEXTURE_WORKAROUND 1
|
||||||
|
layout (constant_id = 0) const uint TEXTURES = 512;
|
||||||
|
layout (constant_id = 1) const uint CASCADES = 16;
|
||||||
|
|
||||||
|
#define MAX_TEXTURES textures.length()
|
||||||
|
#include "../../common/macros.h"
|
||||||
|
#include "../../common/structs.h"
|
||||||
|
|
||||||
|
layout (binding = 5) uniform sampler2D samplerTextures[TEXTURES];
|
||||||
|
layout (std140, binding = 6) readonly buffer DrawCommands {
|
||||||
|
DrawCommand drawCommands[];
|
||||||
|
};
|
||||||
|
layout (std140, binding = 7) readonly buffer Instances {
|
||||||
|
Instance instances[];
|
||||||
|
};
|
||||||
|
layout (std140, binding = 8) readonly buffer InstanceAddresseses {
|
||||||
|
InstanceAddresses instanceAddresses[];
|
||||||
|
};
|
||||||
|
|
||||||
|
layout (std140, binding = 9) readonly buffer Materials {
|
||||||
|
Material materials[];
|
||||||
|
};
|
||||||
|
layout (std140, binding = 10) readonly buffer Textures {
|
||||||
|
Texture textures[];
|
||||||
|
};
|
||||||
|
layout (std140, binding = 11) readonly buffer Lights {
|
||||||
|
Light lights[];
|
||||||
|
};
|
||||||
|
|
||||||
|
layout (binding = 12, rg16ui) uniform volatile coherent uimage3D voxelId[CASCADES];
|
||||||
|
layout (binding = 13, rg16f) uniform volatile coherent image3D voxelNormal[CASCADES];
|
||||||
|
#if VXGI_HDR
|
||||||
|
layout (binding = 14, rgba16f) uniform volatile coherent image3D voxelRadiance[CASCADES];
|
||||||
|
#else
|
||||||
|
layout (binding = 14, rgba8) uniform volatile coherent image3D voxelRadiance[CASCADES];
|
||||||
|
#endif
|
||||||
|
#if DEPTH_TEST
|
||||||
|
layout (binding = 15, r16f) uniform volatile coherent image3D voxelDepth[CASCADES];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
layout (location = 0) flat in uvec4 inId;
|
||||||
|
layout (location = 1) flat in vec4 inPOS0;
|
||||||
|
layout (location = 2) /*__explicitInterpAMD*/ in vec4 inPOS1;
|
||||||
|
|
||||||
|
layout (location = 3) in vec3 inPosition;
|
||||||
|
layout (location = 4) in vec2 inUv;
|
||||||
|
layout (location = 5) in vec4 inColor;
|
||||||
|
layout (location = 6) in vec2 inSt;
|
||||||
|
layout (location = 7) in vec3 inNormal;
|
||||||
|
layout (location = 8) in vec3 inTangent;
|
||||||
|
|
||||||
|
#include "../../common/functions.h"
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
const uint CASCADE = inId.w;
|
||||||
|
if ( CASCADES <= CASCADE ) discard;
|
||||||
|
const vec3 P = inPosition.xzy * 0.5 + 0.5;
|
||||||
|
if ( abs(P.x) > 1 || abs(P.y) > 1 || abs(P.z) > 1 ) discard;
|
||||||
|
|
||||||
|
const uint drawID = uint(inId.x);
|
||||||
|
const uint triangleID = uint(inId.y);
|
||||||
|
const uint instanceID = uint(inId.z);
|
||||||
|
const vec2 uv = wrap(inUv.xy);
|
||||||
|
|
||||||
|
surface.uv.xy = uv;
|
||||||
|
surface.uv.z = mipLevel(dFdx(inUv), dFdy(inUv));
|
||||||
|
surface.st.xy = inSt;
|
||||||
|
surface.st.z = mipLevel(dFdx(inSt), dFdy(inSt));
|
||||||
|
|
||||||
|
vec3 T = inTangent;
|
||||||
|
vec3 N = inNormal;
|
||||||
|
T = normalize(T - dot(T, N) * N);
|
||||||
|
vec3 B = cross(T, N);
|
||||||
|
// mat3 TBN = mat3(T, B, N);
|
||||||
|
mat3 TBN = mat3(N, B, T);
|
||||||
|
|
||||||
|
const Instance instance = instances[instanceID];
|
||||||
|
const Material material = materials[instance.materialID];
|
||||||
|
surface.instance = instance;
|
||||||
|
|
||||||
|
vec4 A = material.colorBase;
|
||||||
|
float M = material.factorMetallic;
|
||||||
|
float R = material.factorRoughness;
|
||||||
|
float AO = material.factorOcclusion;
|
||||||
|
|
||||||
|
// sample albedo
|
||||||
|
if ( validTextureIndex( material.indexAlbedo ) ) {
|
||||||
|
A = sampleTexture( material.indexAlbedo );
|
||||||
|
// alpha mode OPAQUE
|
||||||
|
if ( material.modeAlpha == 0 ) {
|
||||||
|
A.a = 1;
|
||||||
|
// alpha mode BLEND
|
||||||
|
} else if ( material.modeAlpha == 1 ) {
|
||||||
|
|
||||||
|
// alpha mode MASK
|
||||||
|
} else if ( material.modeAlpha == 2 ) {
|
||||||
|
if ( A.a < abs(material.factorAlphaCutoff) ) discard;
|
||||||
|
A.a = 1;
|
||||||
|
}
|
||||||
|
if ( A.a == 0 ) discard;
|
||||||
|
}
|
||||||
|
#if USE_LIGHTMAP && !DEFERRED_SAMPLING
|
||||||
|
if ( validTextureIndex( instance.lightmapID ) ) {
|
||||||
|
A.rgb *= sampleTexture( instance.lightmapID, inSt ).rgb;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// sample normal
|
||||||
|
if ( T != vec3(0) && validTextureIndex( material.indexNormal ) ) {
|
||||||
|
N = TBN * normalize( sampleTexture( material.indexNormal ).xyz * 2.0 - 1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
const ivec3 uvw = ivec3(P * imageSize(voxelRadiance[CASCADE]));
|
||||||
|
|
||||||
|
#if DEPTH_TEST
|
||||||
|
const float outDepth = length(inPosition.xzy);
|
||||||
|
const float inDepth = imageLoad(voxelDepth[CASCADE], uvw).r;
|
||||||
|
if ( inDepth != 0 && inDepth < outDepth ) discard;
|
||||||
|
imageStore(voxelDepth[CASCADE], uvw, vec4(inDepth, 0, 0, 0));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
imageStore(voxelId[CASCADE], uvw, uvec4(uvec2(drawID + 1, instanceID + 1), 0, 0));
|
||||||
|
imageStore(voxelNormal[CASCADE], uvw, vec4(encodeNormals( normalize( N ) ), 0, 0));
|
||||||
|
#if BLEND
|
||||||
|
// GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
|
||||||
|
const vec4 src = A * inColor;
|
||||||
|
const vec4 dst = imageLoad(voxelRadiance[CASCADE], uvw);
|
||||||
|
imageStore(voxelRadiance[CASCADE], uvw, blend( src, dst, src.a ) );
|
||||||
|
#else
|
||||||
|
imageStore(voxelRadiance[CASCADE], uvw, A );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -1,133 +0,0 @@
|
|||||||
#define FRAGMENT 1
|
|
||||||
#define BLEND 1
|
|
||||||
#define DEPTH_TEST 0
|
|
||||||
#define CUBEMAPS 1
|
|
||||||
#define TEXTURE_WORKAROUND 1
|
|
||||||
layout (constant_id = 0) const uint TEXTURES = 512;
|
|
||||||
layout (constant_id = 1) const uint CASCADES = 16;
|
|
||||||
|
|
||||||
#define MAX_TEXTURES textures.length()
|
|
||||||
#include "../../common/macros.h"
|
|
||||||
#include "../../common/structs.h"
|
|
||||||
|
|
||||||
layout (binding = 5) uniform sampler2D samplerTextures[TEXTURES];
|
|
||||||
layout (std140, binding = 6) readonly buffer DrawCommands {
|
|
||||||
DrawCommand drawCommands[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 7) readonly buffer Instances {
|
|
||||||
Instance instances[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 8) readonly buffer InstanceAddresseses {
|
|
||||||
InstanceAddresses instanceAddresses[];
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (std140, binding = 9) readonly buffer Materials {
|
|
||||||
Material materials[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 10) readonly buffer Textures {
|
|
||||||
Texture textures[];
|
|
||||||
};
|
|
||||||
layout (std140, binding = 11) readonly buffer Lights {
|
|
||||||
Light lights[];
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (binding = 12, rg16ui) uniform volatile coherent uimage3D voxelId[CASCADES];
|
|
||||||
layout (binding = 13, rg16f) uniform volatile coherent image3D voxelNormal[CASCADES];
|
|
||||||
#if VXGI_HDR
|
|
||||||
layout (binding = 14, rgba16f) uniform volatile coherent image3D voxelRadiance[CASCADES];
|
|
||||||
#else
|
|
||||||
layout (binding = 14, rgba8) uniform volatile coherent image3D voxelRadiance[CASCADES];
|
|
||||||
#endif
|
|
||||||
#if DEPTH_TEST
|
|
||||||
layout (binding = 15, r16f) uniform volatile coherent image3D voxelDepth[CASCADES];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
layout (location = 0) in vec3 inPosition;
|
|
||||||
layout (location = 1) flat in vec3 inPositionRaw;
|
|
||||||
layout (location = 2) in vec2 inUv;
|
|
||||||
layout (location = 3) in vec2 inSt;
|
|
||||||
layout (location = 4) in vec4 inColor;
|
|
||||||
layout (location = 5) in vec3 inNormal;
|
|
||||||
layout (location = 6) in vec3 inTangent;
|
|
||||||
layout (location = 7) flat in uvec4 inId;
|
|
||||||
|
|
||||||
#include "../../common/functions.h"
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
const uint CASCADE = inId.w;
|
|
||||||
if ( CASCADES <= CASCADE ) discard;
|
|
||||||
const vec3 P = inPosition.xzy * 0.5 + 0.5;
|
|
||||||
if ( abs(P.x) > 1 || abs(P.y) > 1 || abs(P.z) > 1 ) discard;
|
|
||||||
|
|
||||||
const uint drawID = uint(inId.x);
|
|
||||||
const uint triangleID = uint(inId.y);
|
|
||||||
const uint instanceID = uint(inId.z);
|
|
||||||
const vec2 uv = wrap(inUv.xy);
|
|
||||||
|
|
||||||
surface.uv.xy = uv;
|
|
||||||
surface.uv.z = mipLevel(dFdx(inUv), dFdy(inUv));
|
|
||||||
surface.st.xy = inSt;
|
|
||||||
surface.st.z = mipLevel(dFdx(inSt), dFdy(inSt));
|
|
||||||
|
|
||||||
vec3 T = inTangent;
|
|
||||||
vec3 N = inNormal;
|
|
||||||
T = normalize(T - dot(T, N) * N);
|
|
||||||
vec3 B = cross(T, N);
|
|
||||||
// mat3 TBN = mat3(T, B, N);
|
|
||||||
mat3 TBN = mat3(N, B, T);
|
|
||||||
|
|
||||||
const Instance instance = instances[instanceID];
|
|
||||||
const Material material = materials[instance.materialID];
|
|
||||||
surface.instance = instance;
|
|
||||||
|
|
||||||
vec4 A = material.colorBase;
|
|
||||||
float M = material.factorMetallic;
|
|
||||||
float R = material.factorRoughness;
|
|
||||||
float AO = material.factorOcclusion;
|
|
||||||
|
|
||||||
// sample albedo
|
|
||||||
if ( validTextureIndex( material.indexAlbedo ) ) {
|
|
||||||
A = sampleTexture( material.indexAlbedo );
|
|
||||||
// alpha mode OPAQUE
|
|
||||||
if ( material.modeAlpha == 0 ) {
|
|
||||||
A.a = 1;
|
|
||||||
// alpha mode BLEND
|
|
||||||
} else if ( material.modeAlpha == 1 ) {
|
|
||||||
|
|
||||||
// alpha mode MASK
|
|
||||||
} else if ( material.modeAlpha == 2 ) {
|
|
||||||
if ( A.a < abs(material.factorAlphaCutoff) ) discard;
|
|
||||||
A.a = 1;
|
|
||||||
}
|
|
||||||
if ( A.a == 0 ) discard;
|
|
||||||
}
|
|
||||||
#if USE_LIGHTMAP && !DEFERRED_SAMPLING
|
|
||||||
if ( validTextureIndex( instance.lightmapID ) ) {
|
|
||||||
A.rgb *= sampleTexture( instance.lightmapID, inSt ).rgb;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// sample normal
|
|
||||||
if ( T != vec3(0) && validTextureIndex( material.indexNormal ) ) {
|
|
||||||
N = TBN * normalize( sampleTexture( material.indexNormal ).xyz * 2.0 - 1.0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
const ivec3 uvw = ivec3(P * imageSize(voxelRadiance[CASCADE]));
|
|
||||||
|
|
||||||
#if DEPTH_TEST
|
|
||||||
const float outDepth = length(inPosition.xzy);
|
|
||||||
const float inDepth = imageLoad(voxelDepth[CASCADE], uvw).r;
|
|
||||||
if ( inDepth != 0 && inDepth < outDepth ) discard;
|
|
||||||
imageStore(voxelDepth[CASCADE], uvw, vec4(inDepth, 0, 0, 0));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
imageStore(voxelId[CASCADE], uvw, uvec4(uvec2(drawID + 1, instanceID + 1), 0, 0));
|
|
||||||
imageStore(voxelNormal[CASCADE], uvw, vec4(encodeNormals( normalize( N ) ), 0, 0));
|
|
||||||
#if BLEND
|
|
||||||
// GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
|
|
||||||
const vec4 src = A * inColor;
|
|
||||||
const vec4 dst = imageLoad(voxelRadiance[CASCADE], uvw);
|
|
||||||
imageStore(voxelRadiance[CASCADE], uvw, blend( src, dst, src.a ) );
|
|
||||||
#else
|
|
||||||
imageStore(voxelRadiance[CASCADE], uvw, A );
|
|
||||||
#endif
|
|
||||||
}
|
|
@ -4,25 +4,25 @@
|
|||||||
layout(triangles) in;
|
layout(triangles) in;
|
||||||
layout(triangle_strip, max_vertices = 3) out;
|
layout(triangle_strip, max_vertices = 3) out;
|
||||||
|
|
||||||
layout (location = 0) in vec3 inPosition[];
|
layout (location = 0) flat in uvec4 inId[];
|
||||||
layout (location = 1) flat in vec4 inPOS0[];
|
layout (location = 1) flat in vec4 inPOS0[];
|
||||||
layout (location = 2) in vec4 inPOS1[];
|
layout (location = 2) in vec4 inPOS1[];
|
||||||
layout (location = 3) in vec2 inUv[];
|
layout (location = 3) in vec3 inPosition[];
|
||||||
layout (location = 4) in vec2 inSt[];
|
layout (location = 4) in vec2 inUv[];
|
||||||
layout (location = 5) in vec4 inColor[];
|
layout (location = 5) in vec4 inColor[];
|
||||||
layout (location = 6) in vec3 inNormal[];
|
layout (location = 6) in vec2 inSt[];
|
||||||
layout (location = 7) in vec3 inTangent[];
|
layout (location = 7) in vec3 inNormal[];
|
||||||
layout (location = 8) flat in uvec4 inId[];
|
layout (location = 8) in vec3 inTangent[];
|
||||||
|
|
||||||
layout (location = 0) out vec3 outPosition;
|
layout (location = 0) flat out uvec4 outId;
|
||||||
layout (location = 1) flat out vec4 outPOS0;
|
layout (location = 1) flat out vec4 outPOS0;
|
||||||
layout (location = 2) out vec4 outPOS1;
|
layout (location = 2) out vec4 outPOS1;
|
||||||
layout (location = 3) out vec2 outUv;
|
layout (location = 3) out vec3 outPosition;
|
||||||
layout (location = 4) out vec2 outSt;
|
layout (location = 4) out vec2 outUv;
|
||||||
layout (location = 5) out vec4 outColor;
|
layout (location = 5) out vec4 outColor;
|
||||||
layout (location = 6) out vec3 outNormal;
|
layout (location = 6) out vec2 outSt;
|
||||||
layout (location = 7) out vec3 outTangent;
|
layout (location = 7) out vec3 outNormal;
|
||||||
layout (location = 8) flat out uvec4 outId;
|
layout (location = 8) out vec3 outTangent;
|
||||||
|
|
||||||
layout (binding = 4) uniform UBO {
|
layout (binding = 4) uniform UBO {
|
||||||
mat4 voxel;
|
mat4 voxel;
|
||||||
|
@ -23,10 +23,10 @@ namespace pod {
|
|||||||
struct Matrices{
|
struct Matrices{
|
||||||
pod::Matrix4f view;
|
pod::Matrix4f view;
|
||||||
pod::Matrix4f projection;
|
pod::Matrix4f projection;
|
||||||
|
|
||||||
pod::Matrix4f previous;
|
|
||||||
} matrices[uf::camera::maxViews];
|
} matrices[uf::camera::maxViews];
|
||||||
} viewport;
|
} viewport;
|
||||||
|
|
||||||
|
pod::Matrix4f previous[uf::camera::maxViews];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
struct Metadata {
|
struct Metadata {
|
||||||
|
@ -1460,6 +1460,7 @@ void uf::graph::render() {
|
|||||||
auto& camera = controller.getComponent<uf::Camera>();
|
auto& camera = controller.getComponent<uf::Camera>();
|
||||||
|
|
||||||
auto viewport = camera.data().viewport;
|
auto viewport = camera.data().viewport;
|
||||||
|
|
||||||
#if UF_USE_FFX_FSR
|
#if UF_USE_FFX_FSR
|
||||||
auto jitter = ext::fsr::getJitterMatrix();
|
auto jitter = ext::fsr::getJitterMatrix();
|
||||||
for ( auto i = 0; i < uf::camera::maxViews; ++i ) {
|
for ( auto i = 0; i < uf::camera::maxViews; ++i ) {
|
||||||
|
@ -14,19 +14,6 @@
|
|||||||
#include <uf/ext/vulkan/graphic.h>
|
#include <uf/ext/vulkan/graphic.h>
|
||||||
#include <uf/engine/graph/graph.h>
|
#include <uf/engine/graph/graph.h>
|
||||||
|
|
||||||
#define UF_USE_COMPUTE_SHADER 1
|
|
||||||
namespace {
|
|
||||||
enum DEFERRED_TYPE {
|
|
||||||
FRAGMENT,
|
|
||||||
COMPUTE
|
|
||||||
}
|
|
||||||
#if !UF_USE_COMPUTE_SHADER
|
|
||||||
deferredMode = DEFERRED_TYPE::FRAGMENT;
|
|
||||||
#else
|
|
||||||
deferredMode = DEFERRED_TYPE::COMPUTE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
const uf::stl::string ext::vulkan::DeferredRenderMode::getType() const {
|
const uf::stl::string ext::vulkan::DeferredRenderMode::getType() const {
|
||||||
return "Deferred";
|
return "Deferred";
|
||||||
}
|
}
|
||||||
@ -41,22 +28,6 @@ uf::stl::vector<ext::vulkan::Graphic*> ext::vulkan::DeferredRenderMode::getBlitt
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
||||||
#if 0
|
|
||||||
if ( metadata.eyes == 0 ) metadata.eyes = 1;
|
|
||||||
{
|
|
||||||
float width = this->width > 0 ? this->width : ext::vulkan::settings::width;
|
|
||||||
float height = this->height > 0 ? this->height : ext::vulkan::settings::height;
|
|
||||||
auto& swapchainRender = ext::vulkan::getRenderMode("Swapchain");
|
|
||||||
if ( swapchainRender.renderTarget.width != width || swapchainRender.renderTarget.height != height ) {
|
|
||||||
settings::invariant::deferredAliasOutputToSwapchain = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( settings::pipelines::bloom ) settings::invariant::deferredAliasOutputToSwapchain = false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// buffers.emplace_back().initialize( NULL, sizeof(pod::Camera::Viewports), uf::renderer::enums::Buffer::UNIFORM );
|
|
||||||
|
|
||||||
|
|
||||||
auto HDR_FORMAT = VK_FORMAT_R32G32B32A32_SFLOAT;
|
auto HDR_FORMAT = VK_FORMAT_R32G32B32A32_SFLOAT;
|
||||||
auto SDR_FORMAT = VK_FORMAT_R16G16B16A16_SFLOAT;
|
auto SDR_FORMAT = VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||||
|
|
||||||
@ -70,46 +41,22 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
|||||||
} attachments = {};
|
} attachments = {};
|
||||||
|
|
||||||
bool blend = true; // !ext::vulkan::settings::invariant::deferredSampling;
|
bool blend = true; // !ext::vulkan::settings::invariant::deferredSampling;
|
||||||
|
|
||||||
|
// input g-buffers
|
||||||
attachments.id = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
attachments.id = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
||||||
/*.format = */VK_FORMAT_R32G32B32A32_UINT,
|
/*.format = */VK_FORMAT_R32G32_UINT,
|
||||||
/*.layout = */VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
/*.layout = */VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
/*.usage = */VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
|
/*.usage = */VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
|
||||||
/*.blend = */false,
|
/*.blend = */false,
|
||||||
/*.samples = */msaa,
|
/*.samples = */msaa,
|
||||||
});
|
});
|
||||||
attachments.bary = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
attachments.bary = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
||||||
// /*.format = */VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
||||||
// /*.format = */VK_FORMAT_R16G16_SNORM,
|
|
||||||
/*.format = */VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
||||||
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
|
||||||
/*.usage = */VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
|
|
||||||
/*.blend = */false,
|
|
||||||
/*.samples = */msaa,
|
|
||||||
});
|
|
||||||
attachments.mips = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
|
||||||
// /*.format = */VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
||||||
/*.format = */VK_FORMAT_R16G16_SFLOAT,
|
/*.format = */VK_FORMAT_R16G16_SFLOAT,
|
||||||
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
/*.usage = */VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
|
/*.usage = */VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
|
||||||
/*.blend = */false,
|
/*.blend = */false,
|
||||||
/*.samples = */msaa,
|
/*.samples = */msaa,
|
||||||
});
|
});
|
||||||
attachments.normals = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
|
||||||
// /*.format = */VK_FORMAT_R16G16_SFLOAT,
|
|
||||||
/*.format = */VK_FORMAT_R16G16_SNORM,
|
|
||||||
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
|
||||||
/*.usage = */VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
|
|
||||||
/*.blend = */false,
|
|
||||||
/*.samples = */msaa,
|
|
||||||
});
|
|
||||||
attachments.uvs = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
|
||||||
// /*.format = */VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
||||||
/*.format = */VK_FORMAT_R16G16B16A16_SFLOAT,
|
|
||||||
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
|
||||||
/*.usage = */VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT,
|
|
||||||
/*.blend = */false,
|
|
||||||
/*.samples = */msaa,
|
|
||||||
});
|
|
||||||
attachments.depth = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
attachments.depth = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
||||||
/*.format = */ext::vulkan::settings::formats::depth,
|
/*.format = */ext::vulkan::settings::formats::depth,
|
||||||
/*.layout = */VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
/*.layout = */VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
|
||||||
@ -117,23 +64,25 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
|||||||
/*.blend = */false,
|
/*.blend = */false,
|
||||||
/*.samples = */msaa,
|
/*.samples = */msaa,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// output buffers
|
||||||
attachments.color = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
attachments.color = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
||||||
/*.format =*/ ext::vulkan::settings::pipelines::hdr ? HDR_FORMAT : SDR_FORMAT,
|
/*.format =*/ ext::vulkan::settings::pipelines::hdr ? HDR_FORMAT : SDR_FORMAT,
|
||||||
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // ::deferredMode == ::DEFERRED_TYPE::FRAGMENT ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
/*.usage =*/ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
/*.usage =*/ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||||
/*.blend =*/ blend,
|
/*.blend =*/ blend,
|
||||||
/*.samples =*/ 1,
|
/*.samples =*/ 1,
|
||||||
});
|
});
|
||||||
attachments.bright = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
attachments.bright = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
||||||
/*.format =*/ ext::vulkan::settings::pipelines::hdr ? HDR_FORMAT : SDR_FORMAT,
|
/*.format =*/ ext::vulkan::settings::pipelines::hdr ? HDR_FORMAT : SDR_FORMAT,
|
||||||
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // ::deferredMode == ::DEFERRED_TYPE::FRAGMENT ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
/*.usage =*/ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
/*.usage =*/ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||||
/*.blend =*/ blend,
|
/*.blend =*/ blend,
|
||||||
/*.samples =*/ 1,
|
/*.samples =*/ 1,
|
||||||
});
|
});
|
||||||
attachments.scratch = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
attachments.scratch = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
||||||
/*.format =*/ ext::vulkan::settings::pipelines::hdr ? HDR_FORMAT : SDR_FORMAT,
|
/*.format =*/ ext::vulkan::settings::pipelines::hdr ? HDR_FORMAT : SDR_FORMAT,
|
||||||
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // ::deferredMode == ::DEFERRED_TYPE::FRAGMENT ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
/*.usage =*/ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
/*.usage =*/ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||||
/*.blend =*/ blend,
|
/*.blend =*/ blend,
|
||||||
/*.samples =*/ 1,
|
/*.samples =*/ 1,
|
||||||
@ -141,7 +90,7 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
|||||||
attachments.motion = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
attachments.motion = renderTarget.attach(RenderTarget::Attachment::Descriptor{
|
||||||
// /*.format = */VK_FORMAT_R32G32B32A32_SFLOAT,
|
// /*.format = */VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||||
/*.format = */VK_FORMAT_R16G16_SFLOAT,
|
/*.format = */VK_FORMAT_R16G16_SFLOAT,
|
||||||
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // ::deferredMode == ::DEFERRED_TYPE::FRAGMENT ? VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
/*.layout = */ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
|
||||||
/*.usage = */VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
/*.usage = */VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||||
/*.blend = */false,
|
/*.blend = */false,
|
||||||
/*.samples = */msaa,
|
/*.samples = */msaa,
|
||||||
@ -149,9 +98,6 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
|||||||
|
|
||||||
metadata.attachments["id"] = attachments.id;
|
metadata.attachments["id"] = attachments.id;
|
||||||
metadata.attachments["bary"] = attachments.bary;
|
metadata.attachments["bary"] = attachments.bary;
|
||||||
metadata.attachments["mips"] = attachments.mips;
|
|
||||||
metadata.attachments["normals"] = attachments.normals;
|
|
||||||
metadata.attachments["uvs"] = attachments.uvs;
|
|
||||||
metadata.attachments["depth"] = attachments.depth;
|
metadata.attachments["depth"] = attachments.depth;
|
||||||
|
|
||||||
metadata.attachments["color"] = attachments.color;
|
metadata.attachments["color"] = attachments.color;
|
||||||
@ -161,31 +107,17 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
|||||||
|
|
||||||
metadata.attachments["output"] = attachments.color;
|
metadata.attachments["output"] = attachments.color;
|
||||||
|
|
||||||
|
// First pass: fill the G-Buffer
|
||||||
for ( size_t eye = 0; eye < metadata.eyes; ++eye ) {
|
for ( size_t eye = 0; eye < metadata.eyes; ++eye ) {
|
||||||
// First pass: fill the G-Buffer
|
renderTarget.addPass(
|
||||||
{
|
/*.*/ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
||||||
renderTarget.addPass(
|
/*.colors =*/ { attachments.id, attachments.bary },
|
||||||
/*.*/ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
|
/*.inputs =*/ {},
|
||||||
/*.colors =*/ { attachments.id, attachments.bary, attachments.mips, attachments.normals, attachments.uvs },
|
/*.resolve =*/{},
|
||||||
/*.inputs =*/ {},
|
/*.depth = */ attachments.depth,
|
||||||
/*.resolve =*/{},
|
/*.layer = */eye,
|
||||||
/*.depth = */ attachments.depth,
|
/*.autoBuildPipeline =*/ true
|
||||||
/*.layer = */eye,
|
);
|
||||||
/*.autoBuildPipeline =*/ true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Second pass: write to color
|
|
||||||
if ( ::deferredMode == ::DEFERRED_TYPE::FRAGMENT ) {
|
|
||||||
renderTarget.addPass(
|
|
||||||
/*.*/ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
|
|
||||||
/*.colors =*/ { attachments.color, attachments.bright, attachments.motion },
|
|
||||||
/*.inputs =*/ { attachments.id, attachments.bary, attachments.mips, attachments.normals, attachments.uvs, attachments.depth },
|
|
||||||
/*.resolve =*/{},
|
|
||||||
/*.depth = */attachments.depth,
|
|
||||||
/*.layer = */eye,
|
|
||||||
/*.autoBuildPipeline =*/ false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// metadata.outputs.emplace_back(metadata.attachments["output"]);
|
// metadata.outputs.emplace_back(metadata.attachments["output"]);
|
||||||
@ -194,18 +126,7 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
|||||||
{
|
{
|
||||||
uf::Mesh mesh;
|
uf::Mesh mesh;
|
||||||
mesh.vertex.count = 3;
|
mesh.vertex.count = 3;
|
||||||
/*
|
|
||||||
mesh.bind<pod::Vertex_2F2F, uint16_t>();
|
|
||||||
mesh.insertVertices<pod::Vertex_2F2F>({
|
|
||||||
{ {-1.0f, 1.0f}, {0.0f, 1.0f}, },
|
|
||||||
{ {-1.0f, -1.0f}, {0.0f, 0.0f}, },
|
|
||||||
{ {1.0f, -1.0f}, {1.0f, 0.0f}, },
|
|
||||||
{ {1.0f, 1.0f}, {1.0f, 1.0f}, }
|
|
||||||
});
|
|
||||||
mesh.insertIndices<uint16_t>({
|
|
||||||
0, 1, 2, 2, 3, 0
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
auto& scene = uf::scene::getCurrentScene();
|
auto& scene = uf::scene::getCurrentScene();
|
||||||
auto& sceneMetadataJson = scene.getComponent<uf::Serializer>();
|
auto& sceneMetadataJson = scene.getComponent<uf::Serializer>();
|
||||||
|
|
||||||
@ -240,33 +161,17 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
|||||||
shader.textures.emplace_back().aliasAttachment( renderTarget.attachments[index] ); // attachments.color
|
shader.textures.emplace_back().aliasAttachment( renderTarget.attachments[index] ); // attachments.color
|
||||||
}
|
}
|
||||||
if ( settings::pipelines::deferred ) {
|
if ( settings::pipelines::deferred ) {
|
||||||
if ( ::deferredMode == ::DEFERRED_TYPE::COMPUTE ) {
|
uf::stl::string computeShaderFilename = "comp.spv"; {
|
||||||
uf::stl::string computeShaderFilename = "comp.spv"; {
|
std::pair<bool, uf::stl::string> settings[] = {
|
||||||
std::pair<bool, uf::stl::string> settings[] = {
|
{ uf::renderer::settings::pipelines::vxgi, "vxgi.comp" },
|
||||||
{ uf::renderer::settings::pipelines::vxgi, "vxgi.comp" },
|
{ msaa > 1, "msaa.comp" },
|
||||||
{ msaa > 1, "msaa.comp" },
|
{ uf::renderer::settings::pipelines::rt, "rt.comp" },
|
||||||
{ uf::renderer::settings::pipelines::rt, "rt.comp" },
|
};
|
||||||
};
|
FOR_ARRAY( settings ) if ( settings[i].first ) computeShaderFilename = uf::string::replace( computeShaderFilename, "comp", settings[i].second );
|
||||||
FOR_ARRAY( settings ) if ( settings[i].first ) computeShaderFilename = uf::string::replace( computeShaderFilename, "comp", settings[i].second );
|
|
||||||
}
|
|
||||||
computeShaderFilename = uf::io::root+"/shaders/display/deferred-compute/" + computeShaderFilename;
|
|
||||||
blitter.material.attachShader(uf::io::resolveURI(computeShaderFilename), uf::renderer::enums::Shader::COMPUTE, "deferred-compute");
|
|
||||||
UF_MSG_DEBUG("Using deferred shader: {}", computeShaderFilename);
|
|
||||||
} else {
|
|
||||||
uf::stl::string vertexShaderFilename = uf::io::root+"/shaders/display/deferred/vert.spv";
|
|
||||||
uf::stl::string fragmentShaderFilename = uf::io::root+"/shaders/display/deferred/frag.spv"; {
|
|
||||||
std::pair<bool, uf::stl::string> settings[] = {
|
|
||||||
{ uf::renderer::settings::pipelines::vxgi, "vxgi.frag" },
|
|
||||||
{ msaa > 1, "msaa.frag" },
|
|
||||||
{ uf::renderer::settings::pipelines::rt, "rt.frag" },
|
|
||||||
};
|
|
||||||
FOR_ARRAY( settings ) if ( settings[i].first ) fragmentShaderFilename = uf::string::replace( fragmentShaderFilename, "frag", settings[i].second );
|
|
||||||
}
|
|
||||||
|
|
||||||
blitter.material.attachShader(uf::io::resolveURI(vertexShaderFilename), uf::renderer::enums::Shader::VERTEX, "deferred");
|
|
||||||
blitter.material.attachShader(uf::io::resolveURI(fragmentShaderFilename), uf::renderer::enums::Shader::FRAGMENT, "deferred");
|
|
||||||
UF_MSG_DEBUG("Using deferred shader: {}", fragmentShaderFilename);
|
|
||||||
}
|
}
|
||||||
|
computeShaderFilename = uf::io::root+"/shaders/display/deferred-compute/" + computeShaderFilename;
|
||||||
|
blitter.material.attachShader(uf::io::resolveURI(computeShaderFilename), uf::renderer::enums::Shader::COMPUTE, "deferred-compute");
|
||||||
|
UF_MSG_DEBUG("Using deferred shader: {}", computeShaderFilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( settings::pipelines::bloom ) {
|
if ( settings::pipelines::bloom ) {
|
||||||
@ -285,7 +190,7 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( settings::pipelines::deferred ) {
|
if ( settings::pipelines::deferred ) {
|
||||||
auto& shader = blitter.material.hasShader("compute", "deferred-compute") ? blitter.material.getShader("compute", "deferred-compute") : blitter.material.getShader("fragment", "deferred");
|
auto& shader = blitter.material.getShader("compute", "deferred-compute");
|
||||||
|
|
||||||
size_t maxLights = sceneMetadataJson["system"]["config"]["engine"]["scenes"]["lights"]["max"].as<size_t>(512);
|
size_t maxLights = sceneMetadataJson["system"]["config"]["engine"]["scenes"]["lights"]["max"].as<size_t>(512);
|
||||||
size_t maxTextures2D = sceneMetadataJson["system"]["config"]["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512);
|
size_t maxTextures2D = sceneMetadataJson["system"]["config"]["engine"]["scenes"]["textures"]["max"]["2D"].as<size_t>(512);
|
||||||
@ -344,29 +249,31 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
|||||||
this->textures.clear();
|
this->textures.clear();
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["id"]] );
|
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["id"]] );
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["bary"]] );
|
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["bary"]] );
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["mips"]] );
|
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["normals"]] );
|
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["uvs"]] );
|
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["depth"]] );
|
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["depth"]] );
|
||||||
{
|
{
|
||||||
auto& texture = this->textures.emplace_back();
|
auto& texture = this->textures.emplace_back();
|
||||||
|
texture.sampler.descriptor.filter.min = VK_FILTER_NEAREST;
|
||||||
|
texture.sampler.descriptor.filter.mag = VK_FILTER_NEAREST;
|
||||||
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["color"]] );
|
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["color"]] );
|
||||||
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto& texture = this->textures.emplace_back();
|
auto& texture = this->textures.emplace_back();
|
||||||
|
texture.sampler.descriptor.filter.min = VK_FILTER_NEAREST;
|
||||||
|
texture.sampler.descriptor.filter.mag = VK_FILTER_NEAREST;
|
||||||
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["bright"]] );
|
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["bright"]] );
|
||||||
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto& texture = this->textures.emplace_back();
|
auto& texture = this->textures.emplace_back();
|
||||||
|
texture.sampler.descriptor.filter.min = VK_FILTER_NEAREST;
|
||||||
|
texture.sampler.descriptor.filter.mag = VK_FILTER_NEAREST;
|
||||||
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["motion"]] );
|
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["motion"]] );
|
||||||
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
}
|
}
|
||||||
// for ( auto& attachment : renderTarget.attachments ) this->textures.emplace_back().aliasAttachment( attachment );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !blitter.hasPipeline( blitter.descriptor ) ){
|
if ( !blitter.hasPipeline( blitter.descriptor ) ){
|
||||||
@ -377,22 +284,11 @@ void ext::vulkan::DeferredRenderMode::initialize( Device& device ) {
|
|||||||
ext::vulkan::GraphicDescriptor descriptor = blitter.descriptor;
|
ext::vulkan::GraphicDescriptor descriptor = blitter.descriptor;
|
||||||
descriptor.renderMode = "";
|
descriptor.renderMode = "";
|
||||||
|
|
||||||
if ( settings::pipelines::deferred && blitter.material.hasShader("fragment", "deferred") ) {
|
|
||||||
for ( size_t eye = 0; eye < metadata.eyes; ++eye ) {
|
|
||||||
descriptor.pipeline = "deferred";
|
|
||||||
descriptor.subpass = 1; // (renderTarget.passes.size() / metadata.eyes) * eye + 1;
|
|
||||||
if ( !blitter.hasPipeline( descriptor ) ) {
|
|
||||||
blitter.initializePipeline( descriptor );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( settings::pipelines::deferred && blitter.material.hasShader("compute", "deferred-compute") ) {
|
if ( settings::pipelines::deferred && blitter.material.hasShader("compute", "deferred-compute") ) {
|
||||||
for ( size_t eye = 0; eye < metadata.eyes; ++eye ) {
|
descriptor.pipeline = "deferred-compute";
|
||||||
descriptor.pipeline = "deferred-compute";
|
descriptor.subpass = 0;
|
||||||
descriptor.subpass = 0;
|
if ( !blitter.hasPipeline( descriptor ) ) {
|
||||||
if ( !blitter.hasPipeline( descriptor ) ) {
|
blitter.initializePipeline( descriptor );
|
||||||
blitter.initializePipeline( descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,27 +339,30 @@ void ext::vulkan::DeferredRenderMode::tick() {
|
|||||||
}
|
}
|
||||||
if ( settings::pipelines::deferred && blitter.material.hasShader("compute", "deferred-compute") ) {
|
if ( settings::pipelines::deferred && blitter.material.hasShader("compute", "deferred-compute") ) {
|
||||||
this->textures.clear();
|
this->textures.clear();
|
||||||
// for ( auto& attachment : renderTarget.attachments ) this->textures.emplace_back().aliasAttachment( attachment );
|
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["id"]] );
|
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["id"]] );
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["bary"]] );
|
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["bary"]] );
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["mips"]] );
|
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["normals"]] );
|
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["uvs"]] );
|
|
||||||
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["depth"]] );
|
this->textures.emplace_back().aliasAttachment( renderTarget.attachments[metadata.attachments["depth"]] );
|
||||||
{
|
{
|
||||||
auto& texture = this->textures.emplace_back();
|
auto& texture = this->textures.emplace_back();
|
||||||
|
texture.sampler.descriptor.filter.min = VK_FILTER_NEAREST;
|
||||||
|
texture.sampler.descriptor.filter.mag = VK_FILTER_NEAREST;
|
||||||
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["color"]] );
|
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["color"]] );
|
||||||
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto& texture = this->textures.emplace_back();
|
auto& texture = this->textures.emplace_back();
|
||||||
|
texture.sampler.descriptor.filter.min = VK_FILTER_NEAREST;
|
||||||
|
texture.sampler.descriptor.filter.mag = VK_FILTER_NEAREST;
|
||||||
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["bright"]] );
|
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["bright"]] );
|
||||||
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto& texture = this->textures.emplace_back();
|
auto& texture = this->textures.emplace_back();
|
||||||
|
texture.sampler.descriptor.filter.min = VK_FILTER_NEAREST;
|
||||||
|
texture.sampler.descriptor.filter.mag = VK_FILTER_NEAREST;
|
||||||
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["motion"]] );
|
texture.aliasAttachment( renderTarget.attachments[metadata.attachments["motion"]] );
|
||||||
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
texture.descriptor.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
@ -485,22 +384,11 @@ void ext::vulkan::DeferredRenderMode::tick() {
|
|||||||
{
|
{
|
||||||
ext::vulkan::GraphicDescriptor descriptor = blitter.descriptor;
|
ext::vulkan::GraphicDescriptor descriptor = blitter.descriptor;
|
||||||
descriptor.renderMode = "";
|
descriptor.renderMode = "";
|
||||||
if ( settings::pipelines::deferred && blitter.material.hasShader("fragment", "deferred") ) {
|
|
||||||
for ( size_t eye = 0; eye < metadata.eyes; ++eye ) {
|
|
||||||
descriptor.pipeline = "deferred";
|
|
||||||
descriptor.subpass = 1; // (renderTarget.passes.size() / metadata.eyes) * eye + 1;
|
|
||||||
if ( blitter.hasPipeline( descriptor ) ) {
|
|
||||||
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( settings::pipelines::deferred && blitter.material.hasShader("compute", "deferred-compute") ) {
|
if ( settings::pipelines::deferred && blitter.material.hasShader("compute", "deferred-compute") ) {
|
||||||
for ( size_t eye = 0; eye < metadata.eyes; ++eye ) {
|
descriptor.pipeline = "deferred-compute";
|
||||||
descriptor.pipeline = "deferred-compute";
|
descriptor.subpass = 0;
|
||||||
descriptor.subpass = 0;
|
if ( blitter.hasPipeline( descriptor ) ) {
|
||||||
if ( blitter.hasPipeline( descriptor ) ) {
|
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
||||||
blitter.getPipeline( descriptor ).update( blitter, descriptor );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,7 +555,7 @@ void ext::vulkan::DeferredRenderMode::createCommandBuffers( const uf::stl::vecto
|
|||||||
vkCmdSetViewport(commands[i], 0, 1, &viewport);
|
vkCmdSetViewport(commands[i], 0, 1, &viewport);
|
||||||
vkCmdSetScissor(commands[i], 0, 1, &scissor);
|
vkCmdSetScissor(commands[i], 0, 1, &scissor);
|
||||||
// render to geometry buffers
|
// render to geometry buffers
|
||||||
for ( size_t eye = 0; eye < metadata.eyes; ++eye ) {
|
for ( size_t eye = 0; eye < metadata.eyes; ++eye ) {
|
||||||
size_t currentPass = 0;
|
size_t currentPass = 0;
|
||||||
size_t currentDraw = 0;
|
size_t currentDraw = 0;
|
||||||
if ( !settings::pipelines::rt ) for ( auto graphic : graphics ) {
|
if ( !settings::pipelines::rt ) for ( auto graphic : graphics ) {
|
||||||
@ -676,22 +564,10 @@ void ext::vulkan::DeferredRenderMode::createCommandBuffers( const uf::stl::vecto
|
|||||||
ext::vulkan::GraphicDescriptor descriptor = bindGraphicDescriptor(graphic->descriptor, currentSubpass);
|
ext::vulkan::GraphicDescriptor descriptor = bindGraphicDescriptor(graphic->descriptor, currentSubpass);
|
||||||
graphic->record( commands[i], descriptor, eye, currentDraw++ );
|
graphic->record( commands[i], descriptor, eye, currentDraw++ );
|
||||||
}
|
}
|
||||||
if ( ::deferredMode == ::DEFERRED_TYPE::FRAGMENT ) {
|
|
||||||
vkCmdNextSubpass(commands[i], VK_SUBPASS_CONTENTS_INLINE); ++currentPass; ++currentSubpass;
|
|
||||||
// deferred post-processing lighting pass
|
|
||||||
if ( !settings::pipelines::rt ) {
|
|
||||||
ext::vulkan::GraphicDescriptor descriptor = blitter.descriptor; // = bindGraphicDescriptor(blitter.descriptor, currentSubpass);
|
|
||||||
descriptor.renderMode = "";
|
|
||||||
descriptor.pipeline = "deferred";
|
|
||||||
descriptor.subpass = 1;
|
|
||||||
blitter.record(commands[i], descriptor, eye, currentDraw++);
|
|
||||||
}
|
|
||||||
if ( eye + 1 < metadata.eyes ) vkCmdNextSubpass(commands[i], VK_SUBPASS_CONTENTS_INLINE); ++currentSubpass;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
vkCmdEndRenderPass(commands[i]);
|
vkCmdEndRenderPass(commands[i]);
|
||||||
|
|
||||||
if ( /*::deferredMode == ::DEFERRED_TYPE::COMPUTE*/ settings::pipelines::deferred && blitter.material.hasShader("compute", "deferred-compute") ) {
|
if ( !settings::pipelines::rt && settings::pipelines::deferred && blitter.material.hasShader("compute", "deferred-compute") ) {
|
||||||
ext::vulkan::GraphicDescriptor descriptor = blitter.descriptor;
|
ext::vulkan::GraphicDescriptor descriptor = blitter.descriptor;
|
||||||
descriptor.renderMode = "";
|
descriptor.renderMode = "";
|
||||||
descriptor.pipeline = "deferred-compute";
|
descriptor.pipeline = "deferred-compute";
|
||||||
@ -699,64 +575,48 @@ void ext::vulkan::DeferredRenderMode::createCommandBuffers( const uf::stl::vecto
|
|||||||
descriptor.subpass = 0;
|
descriptor.subpass = 0;
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
|
imageMemoryBarrier.subresourceRange.layerCount = metadata.eyes;
|
||||||
for ( auto& attachment : this->textures ) {
|
for ( auto& attachment : this->textures ) {
|
||||||
// if ( !(attachment.usage & VK_IMAGE_USAGE_STORAGE_BIT) ) continue;
|
|
||||||
if ( attachment.imageLayout != VK_IMAGE_LAYOUT_GENERAL ) continue;
|
|
||||||
/*
|
|
||||||
switch ( attachment.imageLayout ) {
|
switch ( attachment.imageLayout ) {
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
|
case VK_IMAGE_LAYOUT_GENERAL:
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
|
// UF_MSG_DEBUG("Converting {} to {}", "VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL", "VK_IMAGE_LAYOUT_GENERAL");
|
||||||
imageMemoryBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
uf::renderer::Texture::setImageLayout( commands[i], attachment.image, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, imageMemoryBarrier.subresourceRange );
|
||||||
break;
|
break;
|
||||||
default:
|
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
|
||||||
imageMemoryBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
// UF_MSG_DEBUG("Converting {} to {}", "VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL", "VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL");
|
||||||
|
// uf::renderer::Texture::setImageLayout( commands[i], attachment.image, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, imageMemoryBarrier.subresourceRange );
|
||||||
|
break;
|
||||||
|
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
|
||||||
|
// UF_MSG_DEBUG("Converting {} to {}", "VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL", "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL");
|
||||||
|
// uf::renderer::Texture::setImageLayout( commands[i], attachment.image, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL, imageMemoryBarrier.subresourceRange );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
uf::renderer::Texture::setImageLayout( commands[i], attachment.image, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, imageMemoryBarrier.subresourceRange );
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
blitter.record(commands[i], descriptor, 0, 1);
|
|
||||||
|
for ( size_t eye = 0; eye < metadata.eyes; ++eye ) {
|
||||||
|
blitter.record(commands[i], descriptor, eye, 0);
|
||||||
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
for ( auto& attachment : this->textures ) {
|
for ( auto& attachment : this->textures ) {
|
||||||
// if ( !(attachment.usage & VK_IMAGE_USAGE_STORAGE_BIT) ) continue;
|
|
||||||
if ( attachment.imageLayout != VK_IMAGE_LAYOUT_GENERAL ) continue;
|
|
||||||
/*
|
|
||||||
switch ( attachment.imageLayout ) {
|
switch ( attachment.imageLayout ) {
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
|
case VK_IMAGE_LAYOUT_GENERAL:
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL:
|
// UF_MSG_DEBUG("Converting {} to {}", "VK_IMAGE_LAYOUT_GENERAL", "VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL");
|
||||||
imageMemoryBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
uf::renderer::Texture::setImageLayout( commands[i], attachment.image, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, imageMemoryBarrier.subresourceRange );
|
||||||
break;
|
break;
|
||||||
default:
|
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
|
||||||
imageMemoryBarrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
// UF_MSG_DEBUG("Converting {} to {}", "VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL", "VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL");
|
||||||
|
// uf::renderer::Texture::setImageLayout( commands[i], attachment.image, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, imageMemoryBarrier.subresourceRange );
|
||||||
|
break;
|
||||||
|
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
|
||||||
|
// UF_MSG_DEBUG("Converting {} to {}", "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL", "VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL");
|
||||||
|
// uf::renderer::Texture::setImageLayout( commands[i], attachment.image, VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, imageMemoryBarrier.subresourceRange );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
uf::renderer::Texture::setImageLayout( commands[i], attachment.image, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, imageMemoryBarrier.subresourceRange );
|
|
||||||
}
|
}
|
||||||
|
imageMemoryBarrier.subresourceRange.layerCount = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
|
|
||||||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT;
|
|
||||||
|
|
||||||
for ( auto& attachment : this->textures ) {
|
|
||||||
imageMemoryBarrier.oldLayout = attachment.imageLayout; // VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
|
||||||
imageMemoryBarrier.newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
imageMemoryBarrier.image = attachment.image;
|
|
||||||
vkCmdPipelineBarrier( commands[i], VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_FLAGS_NONE, 0, NULL, 0, NULL, 1, &imageMemoryBarrier );
|
|
||||||
}
|
|
||||||
|
|
||||||
blitter.record(commands[i], descriptor, 0, 1);
|
|
||||||
|
|
||||||
|
|
||||||
for ( auto& attachment : this->textures ) {
|
|
||||||
imageMemoryBarrier.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
imageMemoryBarrier.newLayout = attachment.imageLayout; // VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
|
||||||
imageMemoryBarrier.image = attachment.image;
|
|
||||||
vkCmdPipelineBarrier( commands[i], VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_FLAGS_NONE, 0, NULL, 0, NULL, 1, &imageMemoryBarrier );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// post-renderpass commands
|
// post-renderpass commands
|
||||||
|
@ -174,7 +174,7 @@ void ext::vulkan::RenderTarget::initialize( Device& device ) {
|
|||||||
description.storeOp = attachment.descriptor.usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT ? VK_ATTACHMENT_STORE_OP_DONT_CARE : VK_ATTACHMENT_STORE_OP_STORE;
|
description.storeOp = attachment.descriptor.usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT ? VK_ATTACHMENT_STORE_OP_DONT_CARE : VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
description.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
description.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||||
description.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
description.initialLayout = attachment.descriptor.layout; // VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
description.finalLayout = ext::vulkan::Texture::remapRenderpassLayout( attachment.descriptor.layout );
|
description.finalLayout = ext::vulkan::Texture::remapRenderpassLayout( attachment.descriptor.layout );
|
||||||
description.flags = 0;
|
description.flags = 0;
|
||||||
|
|
||||||
|
@ -13,6 +13,56 @@ VkFormat ext::vulkan::Texture::DefaultFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
|||||||
|
|
||||||
uf::stl::vector<ext::vulkan::Sampler> ext::vulkan::Sampler::samplers;
|
uf::stl::vector<ext::vulkan::Sampler> ext::vulkan::Sampler::samplers;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
void enforceFilterFromFormat( ext::vulkan::Sampler::Descriptor& descriptor, VkFormat format ) {
|
||||||
|
switch ( format ) {
|
||||||
|
case VK_FORMAT_R8_UINT:
|
||||||
|
case VK_FORMAT_R8_SINT:
|
||||||
|
case VK_FORMAT_R8G8_UINT:
|
||||||
|
case VK_FORMAT_R8G8_SINT:
|
||||||
|
case VK_FORMAT_R8G8B8_UINT:
|
||||||
|
case VK_FORMAT_R8G8B8_SINT:
|
||||||
|
case VK_FORMAT_B8G8R8_UINT:
|
||||||
|
case VK_FORMAT_B8G8R8_SINT:
|
||||||
|
case VK_FORMAT_R8G8B8A8_UINT:
|
||||||
|
case VK_FORMAT_R8G8B8A8_SINT:
|
||||||
|
case VK_FORMAT_B8G8R8A8_UINT:
|
||||||
|
case VK_FORMAT_B8G8R8A8_SINT:
|
||||||
|
case VK_FORMAT_R16_UINT:
|
||||||
|
case VK_FORMAT_R16_SINT:
|
||||||
|
case VK_FORMAT_R16G16_UINT:
|
||||||
|
case VK_FORMAT_R16G16_SINT:
|
||||||
|
case VK_FORMAT_R16G16B16_UINT:
|
||||||
|
case VK_FORMAT_R16G16B16_SINT:
|
||||||
|
case VK_FORMAT_R16G16B16A16_UINT:
|
||||||
|
case VK_FORMAT_R16G16B16A16_SINT:
|
||||||
|
case VK_FORMAT_R32_UINT:
|
||||||
|
case VK_FORMAT_R32_SINT:
|
||||||
|
case VK_FORMAT_R32G32_UINT:
|
||||||
|
case VK_FORMAT_R32G32_SINT:
|
||||||
|
case VK_FORMAT_R32G32B32_UINT:
|
||||||
|
case VK_FORMAT_R32G32B32_SINT:
|
||||||
|
case VK_FORMAT_R32G32B32A32_UINT:
|
||||||
|
case VK_FORMAT_R32G32B32A32_SINT:
|
||||||
|
case VK_FORMAT_R64_UINT:
|
||||||
|
case VK_FORMAT_R64_SINT:
|
||||||
|
case VK_FORMAT_R64G64_UINT:
|
||||||
|
case VK_FORMAT_R64G64_SINT:
|
||||||
|
case VK_FORMAT_R64G64B64_UINT:
|
||||||
|
case VK_FORMAT_R64G64B64_SINT:
|
||||||
|
case VK_FORMAT_R64G64B64A64_UINT:
|
||||||
|
case VK_FORMAT_R64G64B64A64_SINT:
|
||||||
|
case VK_FORMAT_S8_UINT:
|
||||||
|
case VK_FORMAT_D16_UNORM_S8_UINT:
|
||||||
|
case VK_FORMAT_D24_UNORM_S8_UINT:
|
||||||
|
case VK_FORMAT_D32_SFLOAT_S8_UINT:
|
||||||
|
descriptor.filter.min = VK_FILTER_NEAREST;
|
||||||
|
descriptor.filter.mag = VK_FILTER_NEAREST;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ext::vulkan::Sampler ext::vulkan::Sampler::retrieve( const ext::vulkan::Sampler::Descriptor& info ) {
|
ext::vulkan::Sampler ext::vulkan::Sampler::retrieve( const ext::vulkan::Sampler::Descriptor& info ) {
|
||||||
ext::vulkan::Sampler sampler;
|
ext::vulkan::Sampler sampler;
|
||||||
for ( auto& s : samplers ) {
|
for ( auto& s : samplers ) {
|
||||||
@ -496,6 +546,7 @@ void ext::vulkan::Texture::fromBuffers(
|
|||||||
sampler.descriptor.mip.min = 0;
|
sampler.descriptor.mip.min = 0;
|
||||||
sampler.descriptor.mip.max = static_cast<float>(this->mips);
|
sampler.descriptor.mip.max = static_cast<float>(this->mips);
|
||||||
// sampler.initialize( device );
|
// sampler.initialize( device );
|
||||||
|
::enforceFilterFromFormat( sampler.descriptor, format );
|
||||||
sampler = ext::vulkan::Sampler::retrieve( sampler.descriptor );
|
sampler = ext::vulkan::Sampler::retrieve( sampler.descriptor );
|
||||||
|
|
||||||
// Create image view
|
// Create image view
|
||||||
@ -591,6 +642,7 @@ void ext::vulkan::Texture::asRenderTarget( Device& device, uint32_t width, uint3
|
|||||||
|
|
||||||
// Create sampler
|
// Create sampler
|
||||||
// sampler.initialize( device );
|
// sampler.initialize( device );
|
||||||
|
::enforceFilterFromFormat( sampler.descriptor, format );
|
||||||
sampler = ext::vulkan::Sampler::retrieve( sampler.descriptor );
|
sampler = ext::vulkan::Sampler::retrieve( sampler.descriptor );
|
||||||
|
|
||||||
// Create image view
|
// Create image view
|
||||||
@ -652,10 +704,12 @@ void ext::vulkan::Texture::aliasAttachment( const RenderTarget::Attachment& atta
|
|||||||
view = attachment.view;
|
view = attachment.view;
|
||||||
imageLayout = ext::vulkan::Texture::remapRenderpassLayout( attachment.descriptor.layout );
|
imageLayout = ext::vulkan::Texture::remapRenderpassLayout( attachment.descriptor.layout );
|
||||||
deviceMemory = attachment.mem;
|
deviceMemory = attachment.mem;
|
||||||
|
format = attachment.descriptor.format;
|
||||||
|
|
||||||
// Create sampler
|
// Create sampler
|
||||||
if ( createSampler ) {
|
if ( createSampler ) {
|
||||||
// sampler.initialize( ext::vulkan::device );
|
// sampler.initialize( ext::vulkan::device );
|
||||||
|
::enforceFilterFromFormat( sampler.descriptor, format );
|
||||||
sampler = ext::vulkan::Sampler::retrieve( sampler.descriptor );
|
sampler = ext::vulkan::Sampler::retrieve( sampler.descriptor );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,10 +722,12 @@ void ext::vulkan::Texture::aliasAttachment( const RenderTarget::Attachment& atta
|
|||||||
view = attachment.views[layer];
|
view = attachment.views[layer];
|
||||||
imageLayout = ext::vulkan::Texture::remapRenderpassLayout( attachment.descriptor.layout );
|
imageLayout = ext::vulkan::Texture::remapRenderpassLayout( attachment.descriptor.layout );
|
||||||
deviceMemory = attachment.mem;
|
deviceMemory = attachment.mem;
|
||||||
|
format = attachment.descriptor.format;
|
||||||
|
|
||||||
// Create sampler
|
// Create sampler
|
||||||
if ( createSampler ) {
|
if ( createSampler ) {
|
||||||
// sampler.initialize( ext::vulkan::device );
|
// sampler.initialize( ext::vulkan::device );
|
||||||
|
::enforceFilterFromFormat( sampler.descriptor, format );
|
||||||
sampler = ext::vulkan::Sampler::retrieve( sampler.descriptor );
|
sampler = ext::vulkan::Sampler::retrieve( sampler.descriptor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,10 +118,9 @@ VKAPI_ATTR VkBool32 VKAPI_CALL ext::vulkan::debugCallback(
|
|||||||
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
||||||
void* pUserData
|
void* pUserData
|
||||||
) {
|
) {
|
||||||
// if ( messageSeverity <= VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT ) return VK_FALSE;
|
|
||||||
uf::stl::string message = pCallbackData->pMessage;
|
uf::stl::string message = pCallbackData->pMessage;
|
||||||
for ( auto& filter : ext::vulkan::settings::validationFilters ) {
|
for ( auto& filter : ext::vulkan::settings::validationFilters ) {
|
||||||
if ( message.find(filter) != uf::stl::string::npos ) return VK_FALSE;
|
if ( message.find(::fmt::format("MessageID = {}", filter)) != uf::stl::string::npos ) return VK_FALSE;
|
||||||
}
|
}
|
||||||
UF_MSG_ERROR("[Validation Layer] {}", message);
|
UF_MSG_ERROR("[Validation Layer] {}", message);
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
|
@ -22,12 +22,12 @@ pod::Vector3f uf::camera::eye( const pod::Camera& camera, uint_fast8_t i ) {
|
|||||||
void uf::camera::view( pod::Camera& camera, const pod::Matrix4f& mat, uint_fast8_t i ) {
|
void uf::camera::view( pod::Camera& camera, const pod::Matrix4f& mat, uint_fast8_t i ) {
|
||||||
if ( i >= uf::camera::maxViews ) {
|
if ( i >= uf::camera::maxViews ) {
|
||||||
for ( i = 0; i < uf::camera::maxViews; ++i ) {
|
for ( i = 0; i < uf::camera::maxViews; ++i ) {
|
||||||
camera.viewport.matrices[i].previous = camera.viewport.matrices[i].projection * camera.viewport.matrices[i].view;
|
camera.previous[i] = camera.viewport.matrices[i].projection * camera.viewport.matrices[i].view;
|
||||||
camera.viewport.matrices[i].view = mat;
|
camera.viewport.matrices[i].view = mat;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
camera.viewport.matrices[i].previous = camera.viewport.matrices[i].projection * camera.viewport.matrices[i].view;
|
camera.previous[i] = camera.viewport.matrices[i].projection * camera.viewport.matrices[i].view;
|
||||||
camera.viewport.matrices[i].view = mat;
|
camera.viewport.matrices[i].view = mat;
|
||||||
}
|
}
|
||||||
void uf::camera::projection( pod::Camera& camera, const pod::Matrix4f& mat, uint_fast8_t i ) {
|
void uf::camera::projection( pod::Camera& camera, const pod::Matrix4f& mat, uint_fast8_t i ) {
|
||||||
@ -66,7 +66,7 @@ uf::Camera::Camera() {
|
|||||||
for ( uint_fast8_t i = 0; i < uf::camera::maxViews; ++i ) {
|
for ( uint_fast8_t i = 0; i < uf::camera::maxViews; ++i ) {
|
||||||
this->m_pod.viewport.matrices[i].view = uf::matrix::identity();
|
this->m_pod.viewport.matrices[i].view = uf::matrix::identity();
|
||||||
this->m_pod.viewport.matrices[i].projection = uf::matrix::identity();
|
this->m_pod.viewport.matrices[i].projection = uf::matrix::identity();
|
||||||
this->m_pod.viewport.matrices[i].previous = uf::matrix::identity();
|
this->m_pod.previous[i] = uf::matrix::identity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,8 +83,8 @@ const pod::Matrix4& uf::Camera::getView( uint_fast8_t i ) const { return this->m
|
|||||||
pod::Matrix4& uf::Camera::getProjection( uint_fast8_t i ) { return this->m_pod.viewport.matrices[MIN(i, uf::camera::maxViews)].projection; }
|
pod::Matrix4& uf::Camera::getProjection( uint_fast8_t i ) { return this->m_pod.viewport.matrices[MIN(i, uf::camera::maxViews)].projection; }
|
||||||
const pod::Matrix4& uf::Camera::getProjection( uint_fast8_t i ) const { return this->m_pod.viewport.matrices[MIN(i, uf::camera::maxViews)].projection; }
|
const pod::Matrix4& uf::Camera::getProjection( uint_fast8_t i ) const { return this->m_pod.viewport.matrices[MIN(i, uf::camera::maxViews)].projection; }
|
||||||
|
|
||||||
pod::Matrix4& uf::Camera::getPrevious( uint_fast8_t i ) { return this->m_pod.viewport.matrices[MIN(i, uf::camera::maxViews)].previous; }
|
pod::Matrix4& uf::Camera::getPrevious( uint_fast8_t i ) { return this->m_pod.previous[MIN(i, uf::camera::maxViews)]; }
|
||||||
const pod::Matrix4& uf::Camera::getPrevious( uint_fast8_t i ) const { return this->m_pod.viewport.matrices[MIN(i, uf::camera::maxViews)].previous; }
|
const pod::Matrix4& uf::Camera::getPrevious( uint_fast8_t i ) const { return this->m_pod.previous[MIN(i, uf::camera::maxViews)]; }
|
||||||
|
|
||||||
bool uf::Camera::modified() const { return this->m_pod.modified; }
|
bool uf::Camera::modified() const { return this->m_pod.modified; }
|
||||||
void uf::Camera::setStereoscopic( bool b ) { this->m_pod.stereoscopic = b; }
|
void uf::Camera::setStereoscopic( bool b ) { this->m_pod.stereoscopic = b; }
|
||||||
|
Loading…
Reference in New Issue
Block a user