Starting to refactor into mesh shading

This commit is contained in:
Dynamitos
2023-10-07 19:29:53 +02:00
parent fcc4fc12d4
commit 1b6e1a8453
42 changed files with 488 additions and 1577 deletions
-34
View File
@@ -1,34 +0,0 @@
import Common;
struct DebugVertex
{
float3 position;
float3 color;
};
struct VertexStageOutput
{
float3 color : VERTEX_COLOR;
float4 position : SV_Position;
};
[shader("vertex")]
VertexStageOutput vertexMain(
DebugVertex input)
{
VertexStageOutput output;
float4 viewpos = mul(gViewParams.viewMatrix, float4(input.position, 1.0f));
output.position = mul(gViewParams.projectionMatrix, viewpos);
output.color = input.color;
return output;
}
[shader("fragment")]
float4 fragmentMain(
float3 color : VERTEX_COLOR,
float4 position : SV_Position
) : SV_Target
{
return float4(color, 1.0f);
}
-80
View File
@@ -1,80 +0,0 @@
import InputGeometry;
import LightEnv;
import BRDF;
import Material;
import TexturedMaterial;
import FlatColorMaterial;
struct ViewParameter
{
float4x4 viewMatrix;
float4x4 projectionMatrix;
float4 cameraPos_WS;
}
layout(set = 0, binding = 0, std430)
ConstantBuffer<ViewParameter> gViewParams;
layout(set = 0, binding = 1, std430)
ConstantBuffer<Lights> gLightEnv;
layout(set = 1, std430)
type_param TMaterial : IMaterial;
ParameterBlock<TMaterial> gMaterial;
struct ModelParameter
{
float4x4 modelMatrix;
}
[[vk::push_constant]]
ConstantBuffer<ModelParameter> gModelParams;
struct VertexStageOutput
{
MaterialPixelParameter materialParameter : MaterialParameter;
float4 sv_position : SV_Position;
};
[shader("vertex")]
VertexStageOutput vertexMain(
InputGeometry inputGeometry)
{
VertexStageOutput output;
MaterialPixelParameter pixelParams;
float4 worldPosition = mul(gModelParams.modelMatrix, float4(inputGeometry.getVertexPosition(), 1));
pixelParams.position = worldPosition.xyz;
pixelParams.texCoord = inputGeometry.texCoord;
float4 viewPosition = mul(gViewParams.viewMatrix, worldPosition);
pixelParams.viewDir = gViewParams.cameraPos_WS.xyz - worldPosition.xyz;
pixelParams.normal = mul(gModelParams.modelMatrix, float4(inputGeometry.getNormal(), 0)).xyz;
pixelParams.tangent = mul(gModelParams.modelMatrix, float4(inputGeometry.getTangent(), 0)).xyz;
pixelParams.biTangent = mul(gModelParams.modelMatrix, float4(inputGeometry.getBiTangent(), 0)).xyz;
pixelParams.clipPosition = mul(gViewParams.projectionMatrix, viewPosition);
output.materialParameter = pixelParams;
output.sv_position = pixelParams.clipPosition;
return output;
}
[shader("fragment")]
float4 fragmentMain(MaterialPixelParameter input : MaterialParameter) : SV_Target
{
TMaterial.BRDF brdf = gMaterial.prepare(input);
float3 viewDir = normalize(input.viewDir);
float3 result = float3(0, 0, 0);
for (int i = 0; i < gLightEnv.numDirectionalLights; ++i)
{
result += gLightEnv.directionalLights[i].illuminate(input, brdf, viewDir);
}
for (int i = 0; i < gLightEnv.numPointLights; ++i)
{
result += gLightEnv.pointLights[i].illuminate(input, brdf, viewDir);
}
return float4(result, 0);
}
-68
View File
@@ -1,68 +0,0 @@
import Common;
import LightEnv;
import BRDF;
import Material;
import StaticMeshVertexInput;
import PrimitiveSceneData;
import MaterialParameter;
layout(set = INDEX_LIGHT_ENV, binding = 4)
ShaderBuffer<uint> lightIndexList;
layout(set = INDEX_LIGHT_ENV, binding = 5)
RWTexture2D<uint2> lightGrid;
struct VertexStageOutput
{
VertexValueCache cache : ShaderCache;
float4 position : SV_Position;
};
[shader("vertex")]
VertexStageOutput vertexMain(
VertexShaderInput input)
{
VertexStageOutput output;
VertexValueCache cache = input.getVertexCache();
float3 worldPosition = input.getWorldPosition();
//worldPosition += gMaterial.getWorldOffset();
float4 viewSpacePosition = mul(gViewParams.viewMatrix, float4(worldPosition, 1));
MaterialVertexParameter vertexParams = input.getMaterialVertexParameters(cache, worldPosition, viewSpacePosition.xyz);
float4 clipSpacePosition = mul(gViewParams.projectionMatrix, viewSpacePosition);
output.position = clipSpacePosition;
output.cache = cache;
return output;
}
[shader("fragment")]
float4 fragmentMain(
VertexValueCache cache : ShaderCache,
float4 position : SV_Position
) : SV_Target
{
MaterialFragmentParameter materialParams = cache.getFragmentParameters();
let brdf = gMaterial.prepare(materialParams);
float3 result = float3(0, 0, 0);
for (int i = 0; i < numDirectionalLights; i++)
{
result += directionalLights[i].illuminate(materialParams, brdf);
}
uint2 tileIndex = uint2(floor(position.xy / BLOCK_SIZE));
uint2 gridValue = lightGrid[tileIndex];
uint startOffset = gridValue.x;
uint lightCount = gridValue.y;
for (int j = 0; j < numPointLights; ++j)
{
//uint lightIndex = lightIndexList[startOffset + j];
PointLight pointLight = pointLights[j];
result += pointLight.illuminate(materialParams, brdf);
}
return float4(result + float3(0.4f, 0.4f, 0), 0.7f);
}
-7
View File
@@ -1,7 +0,0 @@
interface IMaterial
{
float4 sample(float2 texCoord);
}
type_param TMaterial : IMaterial;
ParameterBlock<TMaterial> gMaterial;
-58
View File
@@ -1,58 +0,0 @@
{
"name": "Placeholder",
"profile": "BlinnPhong",
"params": {
"diffuseTexture": {
"type": "Texture2D"
},
"specularTexture": {
"type": "Texture2D"
},
"normalTexture": {
"type": "Texture2D"
},
"uvScale": {
"type": "float",
"default": "0.0f"
},
"metallic": {
"type": "float",
"default": "0.0f"
},
"roughness": {
"type": "float",
"default": "0.5f"
},
"sheen": {
"type": "float",
"default": "0.0f"
},
"worldOffset": {
"type": "float3",
"default": "float3(0, 0, 0)"
},
"textureSampler": {
"type": "SamplerState"
}
},
"code": [
{
"exp": "Sample",
"texture": "diffuseTexture",
"sampler": "textureSampler",
"coords": "input.texCoords[0]"
},
{
"exp": "Swizzle",
"target": 0,
"comp": [0, 1, 2]
},
{
"exp": "BRDF",
"profile": "BlinnPhong",
"values": {
"baseColor": 1
}
}
]
}
-10
View File
@@ -1,10 +0,0 @@
import Mat;
struct SimpleMaterial : IMaterial
{
float4 sample(float2 texCoord)
{
return float4(1, 0, 1, 1);
}
}
+93
View File
@@ -0,0 +1,93 @@
import Common;
import BRDF;
import Meshlet;
import Scene;
import VertexData;
import StaticMeshVertexData;
layout(push_constant)
ConstantBuffer<uint> meshId;
struct MeshShaderPayload
{
uint instanceId;
uint meshletId;
};
struct PrimitiveAttributes
{
uint cull: SV_CullPrimitive;
};
groupshared StaticMeshVertexAttributes gs_vertices[MAX_VERTICES];
groupshared uint3 gs_indices[MAX_PRIMITIVES];
groupshared uint gs_numVertices = 0;
groupshared uint gs_numPrimitives = 0;
[numthreads(GROUP_SIZE, 1, 1)]
[shader("amplification")]
void taskMain(
uint3 threadID: SV_GroupIndex,
uint3 groupID: SV_GroupID
){
}
[numthreads(GROUP_SIZE, 1, 1)]
[outputtopology("triangle")]
[shader("mesh")]
void meshMain(
uint3 threadID: SV_GroupIndex,
uint3 groupID: SV_GroupID,
out vertices StaticMeshVertexAttributes vertices[MAX_VERTICES],
out indices uint3 indices[MAX_PRIMITIVES]
){
MeshShaderPayload p;
InstanceData inst = scene.instances[p.instanceId];
MeshletDescription m = meshlets.meshletInfos[p.meshletId];
const uint vertexLoops = (MAX_VERTICES + GROUP_SIZE - 1) / GROUP_SIZE;
for(uint loop = 0; loop < vertexLoops; ++loop)
{
uint v = threadID.x + loop * GROUP_SIZE;
v = min(v, m.vertexCount - 1);
InterlockedMax(gs_numVertices, v + 1);
{
int vertexIndex = meshlets.vertexIndices[m.vertexOffset + v];
gs_vertices[v] = vertexData.getAttributes(vertexIndex, inst);
}
}
const uint primitiveLoops = (MAX_PRIMITIVES + GROUP_SIZE - 1) / GROUP_SIZE;
for(uint loop = 0; loop < primitiveLoops; ++loop)
{
uint p = threadID.x + loop * GROUP_SIZE;
p = min(p, m.primitiveCount - 1);
InterlockedMax(gs_numPrimitives, p + 1);
{
uint8_t local_idx0 = meshlets.primitiveIndices[m.primitiveOffset + (p * 3) + 0];
uint8_t local_idx1 = meshlets.primitiveIndices[m.primitiveOffset + (p * 3) + 1];
uint8_t local_idx2 = meshlets.primitiveIndices[m.primitiveOffset + (p * 3) + 2];
uint32_t idx0 = meshlets.vertexIndices[m.vertexOffset + local_idx0];
uint32_t idx1 = meshlets.vertexIndices[m.vertexOffset + local_idx1];
uint32_t idx2 = meshlets.vertexIndices[m.vertexOffset + local_idx2];
gs_indices[p * 3 + 0] = idx0;
gs_indices[p * 3 + 1] = idx1;
gs_indices[p * 3 + 2] = idx2;
}
}
GroupMemoryBarrierWithGroupSync();
SetMeshOutputCounts(gs_numVertices, gs_numPrimitives);
GroupMemoryBarrierWithGroupSync();
for(uint loop = 0; loop < vertexLoops; ++loop)
{
uint v = threadID.x + loop * GROUP_SIZE;
v = min(v, m.vertexCount - 1);
vertices[v] = gs_vertices[v];
}
for(uint loop = 0; loop < primitiveLoops; ++loop)
{
uint p = threadID.x + loop * GROUP_SIZE;
p = min(p, m.primitiveCount - 1);
indices[p] = gs_indices[p];
}
}
+235
View File
@@ -0,0 +1,235 @@
#pragma pack_matrix(column_major)
#ifdef SLANG_HLSL_ENABLE_NVAPI
#include "nvHLSLExtns.h"
#endif
#pragma warning(disable: 3557)
#line 1 "lib/Scene.slang"
struct InstanceData_0
{
matrix<float,int(4),int(4)> transformMatrix_0;
};
#line 46 "./StaticMeshBasePass.slang"
StructuredBuffer<InstanceData_0 > scene_instances_0 : register(t0, space3);
#line 1 "lib/Meshlet.slang"
struct MeshletDescription_0
{
uint vertexCount_0;
uint primitiveCount_0;
uint vertexOffset_0;
uint primitiveOffset_0;
};
#line 47 "./StaticMeshBasePass.slang"
StructuredBuffer<MeshletDescription_0 > meshlets_meshletInfos_0 : register(t0, space2);
#line 9 "lib/Meshlet.slang"
StructuredBuffer<uint8_t > meshlets_primitiveIndices_0 : register(t1, space2);
#line 9
StructuredBuffer<uint > meshlets_vertexIndices_0 : register(t2, space2);
#line 24 "lib/StaticMeshVertexData.slang"
StructuredBuffer<float4 > vertexData_positions_0 : register(t0, space4);
#line 24
StructuredBuffer<float2 > vertexData_texCoords_0 : register(t1, space4);
#line 24
StructuredBuffer<float3 > vertexData_normals_0 : register(t2, space4);
#line 5 "lib/Common.slang"
struct ViewParameter_0
{
matrix<float,int(4),int(4)> viewMatrix_0;
matrix<float,int(4),int(4)> projectionMatrix_0;
float4 cameraPos_WS_0;
float2 screenDimensions_0;
};
cbuffer viewParams_0 : register(b0, space1)
{
ViewParameter_0 viewParams_0;
}
#line 24 "./StaticMeshBasePass.slang"
uint gs_numVertices_0_init()
{
#line 24
return 0U;
}
static groupshared uint gs_numVertices_0 = gs_numVertices_0_init();
#line 5 "lib/StaticMeshVertexData.slang"
struct StaticMeshVertexAttributes_0
{
float4 position_0 : SV_Position;
float2 texCoords_0 : TEXCOORD0;
float3 normal_0 : NORMAL0;
};
#line 22 "./StaticMeshBasePass.slang"
static groupshared StaticMeshVertexAttributes_0 gs_vertices_0[int(64)];
#line 26 "lib/StaticMeshVertexData.slang"
StaticMeshVertexAttributes_0 StaticMeshVertexData_getAttributes_0(StructuredBuffer<float4 > this_positions_0, StructuredBuffer<float2 > this_texCoords_0, StructuredBuffer<float3 > this_normals_0, uint index_0, InstanceData_0 inst_0)
{
StaticMeshVertexAttributes_0 attr_0;
attr_0.position_0 = mul(viewParams_0.projectionMatrix_0, mul(viewParams_0.viewMatrix_0, mul(inst_0.transformMatrix_0, this_positions_0.Load(index_0))));
attr_0.texCoords_0 = this_texCoords_0.Load(index_0);
attr_0.normal_0 = this_normals_0.Load(index_0);
return attr_0;
}
#line 25 "./StaticMeshBasePass.slang"
uint gs_numPrimitives_0_init()
{
#line 25
return 0U;
}
static groupshared uint gs_numPrimitives_0 = gs_numPrimitives_0_init();
#line 23
static groupshared uint3 gs_indices_0[int(126)];
#line 11
struct MeshShaderPayload_0
{
uint instanceId_0;
uint meshletId_0;
};
#line 39
[shader("mesh")][numthreads(32, 1, 1)]
[outputtopology("triangle")]
void meshMain(uint3 threadID_0 : SV_GROUPINDEX, uint3 groupID_0 : SV_GROUPID, vertices vertices out StaticMeshVertexAttributes_0 vertices_0[int(64)], indices indices out uint3 indices_0[int(126)])
{
#line 39
MeshShaderPayload_0 p_0;
#line 46
InstanceData_0 _S1 = scene_instances_0.Load(p_0.instanceId_0);
MeshletDescription_0 _S2 = meshlets_meshletInfos_0.Load(p_0.meshletId_0);
uint _S3 = threadID_0.x;
uint _S4 = _S2.vertexCount_0 - 1U;
#line 64
uint _S5 = _S2.primitiveCount_0 - 1U;
#line 64
uint loop_0 = 0U;
#line 64
for(;;)
{
#line 52
uint v_0 = min(_S3 + loop_0 * 32U, _S4);
InterlockedMax(gs_numVertices_0, v_0 + 1U);
gs_vertices_0[v_0] = StaticMeshVertexData_getAttributes_0(vertexData_positions_0, vertexData_texCoords_0, vertexData_normals_0, uint(int(meshlets_vertexIndices_0.Load(_S2.vertexOffset_0 + v_0))), _S1);
#line 49
uint loop_1 = loop_0 + 1U;
#line 49
if(loop_1 < 2U)
{
}
else
{
#line 49
break;
}
#line 49
loop_0 = loop_1;
#line 49
}
#line 49
loop_0 = 0U;
#line 49
for(;;)
{
#line 64
uint p_1 = min(_S3 + loop_0 * 32U, _S5);
InterlockedMax(gs_numPrimitives_0, p_1 + 1U);
uint _S6 = p_1 * 3U;
#line 67
uint _S7 = _S2.primitiveOffset_0 + _S6;
uint idx1_0 = meshlets_vertexIndices_0.Load(_S2.vertexOffset_0 + uint(meshlets_primitiveIndices_0.Load(_S7 + 1U)));
uint idx2_0 = meshlets_vertexIndices_0.Load(_S2.vertexOffset_0 + uint(meshlets_primitiveIndices_0.Load(_S7 + 2U)));
gs_indices_0[_S6] = (uint3)meshlets_vertexIndices_0.Load(_S2.vertexOffset_0 + uint(meshlets_primitiveIndices_0.Load(_S7)));
gs_indices_0[_S6 + 1U] = (uint3)idx1_0;
gs_indices_0[_S6 + 2U] = (uint3)idx2_0;
#line 61
uint loop_2 = loop_0 + 1U;
#line 61
if(loop_2 < 4U)
{
}
else
{
#line 61
break;
}
#line 61
loop_0 = loop_2;
#line 61
}
#line 78
GroupMemoryBarrierWithGroupSync();
SetMeshOutputCounts(gs_numVertices_0, gs_numPrimitives_0);
GroupMemoryBarrierWithGroupSync();
#line 93
return;
}
-2
View File
@@ -1,2 +0,0 @@
slangc TextPass.slang -target glsl -entry vertexMain -profile vs_6_0 -o vertex.glsl -I lib/ -D INDEX_VIEW_PARAMS=0
slangc TextPass.slang -target glsl -entry fragmentMain -profile ps_6_0 -o fragment.glsl -I lib/ -D INDEX_VIEW_PARAMS=0
-424
View File
@@ -1,424 +0,0 @@
#version 450
#extension GL_EXT_samplerless_texture_functions : require
layout(row_major) uniform;
layout(row_major) buffer;
#line 21 0
layout(binding = 2)
uniform texture2D depthTextureVS_0;
#line 46
shared uint uMinDepth_0;
#line 47
shared uint uMaxDepth_0;
shared uint oLightCount_0;
shared uint tLightCount_0;
#line 12
struct SLANG_ParameterGroup_DispatchParams_0
{
uvec3 numThreadGroups_0;
uint pad0_0;
uvec3 numThreads_0;
uint pad1_0;
};
#line 12
layout(binding = 1)
layout(std140) uniform _S1
{
SLANG_ParameterGroup_DispatchParams_0 _data;
} DispatchParams_0;
#line 39 1
struct Plane_0
{
vec3 n_0;
float d_0;
};
struct Frustum_0
{
Plane_0 planes_0[4];
};
#line 23 0
layout(std430, binding = 3) readonly buffer _S2 {
Frustum_0 _data[];
} frustums_0;
#line 49
shared Frustum_0 groupFrustum_0;
#line 5 1
struct ViewParameter_0
{
mat4x4 viewMatrix_0;
mat4x4 projectionMatrix_0;
mat4x4 inverseProjection_0;
vec4 cameraPos_WS_0;
vec2 screenDimensions_0;
};
layout(binding = 0)
layout(std140) uniform _S3
{
ViewParameter_0 _data;
} gViewParams_0;
#line 17
vec4 clipToView_0(vec4 clip_0)
{
vec4 view_0 = (((clip_0) * (gViewParams_0._data.inverseProjection_0)));
vec4 view_1 = view_0 / view_0.w;
return view_1;
}
#line 71 2
layout(binding = 3, set = 1)
layout(std140) uniform _S4
{
uint _data;
} numPointLights_0;
#line 22
struct PointLight_0
{
vec4 positionWS_0;
vec4 colorRange_0;
};
#line 69
layout(std430, binding = 2, set = 1) readonly buffer _S5 {
PointLight_0 _data[];
} pointLights_0;
#line 57 0
shared uint tLightList_0[1024];
#line 70
void tAppendLight_0(uint lightIndex_0)
{
uint index_0;
((index_0) = atomicAdd((tLightCount_0), (uint(1))));
if(index_0 < uint(1024))
{
tLightList_0[index_0] = lightIndex_0;
#line 74
}
else
{
#line 74
}
return;
}
#line 58 2
vec3 PointLight_getViewPos_0(PointLight_0 this_0)
{
vec4 _S6 = (((this_0.positionWS_0) * (gViewParams_0._data.viewMatrix_0)));
#line 60
return _S6.xyz;
}
#line 36
bool PointLight_insidePlane_0(PointLight_0 this_1, Plane_0 plane_0)
{
#line 36
vec3 _S7 = plane_0.n_0;
vec3 _S8 = PointLight_getViewPos_0(this_1);
#line 38
float _S9 = dot(_S7, _S8.xyz);
#line 38
return _S9 - plane_0.d_0 < - this_1.colorRange_0.w;
}
#line 53 0
shared uint oLightList_0[1024];
#line 60
void oAppendLight_0(uint lightIndex_1)
{
uint index_1;
((index_1) = atomicAdd((oLightCount_0), (uint(1))));
if(index_1 < uint(1024))
{
oLightList_0[index_1] = lightIndex_1;
#line 64
}
else
{
#line 64
}
return;
}
#line 26
layout(std430, binding = 4) buffer _S10 {
uint _data[];
} oLightIndexCounter_0;
#line 52
shared uint oLightIndexStartOffset_0;
#line 36
layout(rg32ui)
layout(binding = 8)
uniform uimage2D oLightGrid_0;
#line 28
layout(std430, binding = 5) buffer _S11 {
uint _data[];
} tLightIndexCounter_0;
#line 56
shared uint tLightIndexStartOffset_0;
#line 38
layout(rg32ui)
layout(binding = 9)
uniform uimage2D tLightGrid_0;
#line 31
layout(std430, binding = 6) buffer _S12 {
uint _data[];
} oLightIndexList_0;
#line 33
layout(std430, binding = 7) buffer _S13 {
uint _data[];
} tLightIndexList_0;
#line 4
struct ComputeShaderInput_0
{
uvec3 groupID_0;
uvec3 groupThreadID_0;
uvec3 dispatchThreadID_0;
uint groupIndex_0;
};
#line 82
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
void main()
{
uint i_0;
uint j_0;
uint k_0;
#line 82
ComputeShaderInput_0 _S14 = ComputeShaderInput_0(gl_WorkGroupID, gl_LocalInvocationID, gl_GlobalInvocationID, gl_LocalInvocationIndex);
ivec3 _S15 = ivec3(ivec2(_S14.dispatchThreadID_0.xy), 0);
#line 85
vec4 _S16 = (texelFetch((depthTextureVS_0), ((_S15)).xy, ((_S15)).z));
uint uDepth_0 = floatBitsToUint(_S16.x);
if(_S14.groupIndex_0 == uint(0))
{
uMinDepth_0 = uint(-1);
uMaxDepth_0 = uint(0);
oLightCount_0 = uint(0);
tLightCount_0 = uint(0);
Frustum_0 _S17 = ((frustums_0)._data[(_S14.groupID_0.x + _S14.groupID_0.y * DispatchParams_0._data.numThreadGroups_0.x)]);
#line 94
groupFrustum_0 = _S17;
#line 88
}
else
{
#line 88
}
#line 97
groupMemoryBarrier(), barrier();
atomicMin((uMinDepth_0), (uDepth_0));
atomicMax((uMaxDepth_0), (uDepth_0));
groupMemoryBarrier(), barrier();
float fMinDepth_0 = uintBitsToFloat(uMinDepth_0);
float fMaxDepth_0 = uintBitsToFloat(uMaxDepth_0);
vec4 _S18 = clipToView_0(vec4(float(0), float(0), fMinDepth_0, float(1)));
#line 107
float minDepthVS_0 = _S18.z;
vec4 _S19 = clipToView_0(vec4(float(0), float(0), fMaxDepth_0, float(1)));
vec4 _S20 = clipToView_0(vec4(float(0), float(0), float(0), 1.00000000000000000000));
Plane_0 _S21 = { vec3(float(0), float(0), float(-1)), - minDepthVS_0 };
#line 111
uint _S22 = _S14.groupIndex_0;
i_0 = _S22;
for(;;)
{
#line 113
if(i_0 < numPointLights_0._data)
{
}
else
{
break;
}
#line 115
PointLight_0 light_0 = ((pointLights_0)._data[(i_0)]);
tAppendLight_0(i_0);
bool _S23 = PointLight_insidePlane_0(light_0, _S21);
#line 120
if(!_S23)
{
oAppendLight_0(i_0);
#line 120
}
else
{
#line 120
}
#line 113
uint i_1 = i_0 + uint(32) * uint(32);
#line 113
i_0 = i_1;
}
#line 127
groupMemoryBarrier(), barrier();
if(_S14.groupIndex_0 == uint(0))
{
((oLightIndexStartOffset_0) = atomicAdd((((oLightIndexCounter_0)._data[(uint(0))])), (oLightCount_0)));
imageStore((oLightGrid_0), ivec2((_S14.groupID_0.xy)), uvec4(uvec2(oLightIndexStartOffset_0, oLightCount_0), uint(0), uint(0)));
((tLightIndexStartOffset_0) = atomicAdd((((tLightIndexCounter_0)._data[(uint(0))])), (tLightCount_0)));
imageStore((tLightGrid_0), ivec2((_S14.groupID_0.xy)), uvec4(uvec2(tLightIndexStartOffset_0, tLightCount_0), uint(0), uint(0)));
#line 129
}
else
{
#line 129
}
#line 137
groupMemoryBarrier(), barrier();
#line 137
uint _S24 = _S14.groupIndex_0;
j_0 = _S24;
for(;;)
{
#line 139
if(j_0 < oLightCount_0)
{
}
else
{
break;
}
#line 141
((oLightIndexList_0)._data[(oLightIndexStartOffset_0 + j_0)]) = oLightList_0[j_0];
#line 139
uint j_1 = j_0 + uint(32) * uint(32);
#line 139
j_0 = j_1;
}
#line 139
uint _S25 = _S14.groupIndex_0;
#line 145
k_0 = _S25;
for(;;)
{
#line 145
if(k_0 < tLightCount_0)
{
}
else
{
break;
}
#line 147
((tLightIndexList_0)._data[(tLightIndexStartOffset_0 + k_0)]) = tLightList_0[k_0];
#line 145
uint k_1 = k_0 + uint(32) * uint(32);
#line 145
k_0 = k_1;
}
#line 151
return;
}
-44
View File
@@ -1,44 +0,0 @@
#version 450
#extension GL_EXT_nonuniform_qualifier : require
layout(row_major) uniform;
layout(row_major) buffer;
#line 18 0
layout(binding = 1, set = 1)
uniform texture2D glyphTextures_0[];
#line 14
layout(binding = 1)
uniform sampler glyphSampler_0;
#line 14
layout(location = 0)
out vec4 _S1;
#line 62
layout(location = 0)
in vec2 _S2;
#line 62
flat layout(location = 1)
in uint _S3;
#line 62
void main()
{
#line 68
vec4 _S4 = (texture(sampler2D(glyphTextures_0[_S3],glyphSampler_0), (_S2)));
#line 68
_S1 = _S4;
#line 68
return;
}
-197
View File
@@ -1,197 +0,0 @@
#version 450
layout(row_major) uniform;
layout(row_major) buffer;
#line 5 0
struct ViewParameter_0
{
mat4x4 viewMatrix_0;
mat4x4 projectionMatrix_0;
mat4x4 inverseProjection_0;
vec4 cameraPos_WS_0;
vec2 screenDimensions_0;
};
layout(binding = 0)
layout(std140) uniform _S1
{
ViewParameter_0 _data;
} gViewParams_0;
#line 17
vec4 clipToView_0(vec4 clip_0)
{
vec4 view_0 = (((clip_0) * (gViewParams_0._data.inverseProjection_0)));
vec4 view_1 = view_0 / view_0.w;
return view_1;
}
vec4 screenToView_0(vec4 screen_0)
{
vec2 texCoord_0 = screen_0.xy / gViewParams_0._data.screenDimensions_0;
#line 36
vec4 _S2 = clipToView_0(vec4(vec2(texCoord_0.x, 1.00000000000000000000 - texCoord_0.y) * 2.00000000000000000000 - 1.00000000000000000000, screen_0.z, screen_0.w));
#line 36
return _S2;
}
struct Plane_0
{
vec3 n_0;
float d_0;
};
#line 49
Plane_0 computePlane_0(vec3 p0_0, vec3 p1_0, vec3 p2_0)
{
Plane_0 plane_0;
#line 56
vec3 _S3 = cross(p1_0 - p0_0, p2_0 - p0_0);
#line 56
vec3 _S4 = normalize(_S3);
#line 56
plane_0.n_0 = _S4;
float _S5 = dot(plane_0.n_0, p0_0);
#line 58
plane_0.d_0 = _S5;
return plane_0;
}
#line 12 1
struct SLANG_ParameterGroup_DispatchParams_0
{
uvec3 numThreadGroups_0;
uint pad0_0;
uvec3 numThreads_0;
uint pad1_0;
};
#line 12
layout(binding = 1)
layout(std140) uniform _S6
{
SLANG_ParameterGroup_DispatchParams_0 _data;
} DispatchParams_0;
#line 45 0
struct Frustum_0
{
Plane_0 planes_0[4];
};
#line 20 1
layout(std430, binding = 2) buffer _S7 {
Frustum_0 _data[];
} out_Frustums_0;
#line 3
struct ComputeShaderInput_0
{
uvec3 groupID_0;
uvec3 groupThreadID_0;
uvec3 dispatchThreadID_0;
uint groupIndex_0;
};
#line 25
layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;
void main()
{
int i_0;
#line 25
ComputeShaderInput_0 _S8 = ComputeShaderInput_0(gl_WorkGroupID, gl_LocalInvocationID, gl_GlobalInvocationID, gl_LocalInvocationIndex);
const vec3 eyePos_0 = vec3(float(0), float(0), float(0));
vec4 screenSpace_0[4];
screenSpace_0[0] = vec4(vec2(_S8.dispatchThreadID_0.xy * uint(32)), -1.00000000000000000000, 1.00000000000000000000);
screenSpace_0[1] = vec4(vec2(float(_S8.dispatchThreadID_0.x + uint(1)), float(_S8.dispatchThreadID_0.y)) * float(uint(32)), -1.00000000000000000000, 1.00000000000000000000);
screenSpace_0[2] = vec4(vec2(float(_S8.dispatchThreadID_0.x), float(_S8.dispatchThreadID_0.y + uint(1))) * float(uint(32)), -1.00000000000000000000, 1.00000000000000000000);
screenSpace_0[3] = vec4(vec2(float(_S8.dispatchThreadID_0.x + uint(1)), float(_S8.dispatchThreadID_0.y + uint(1))) * float(uint(32)), -1.00000000000000000000, 1.00000000000000000000);
vec3 viewSpace_0[4];
i_0 = 0;
for(;;)
{
#line 39
if(i_0 < 4)
{
}
else
{
break;
}
#line 41
vec4 _S9 = screenToView_0(screenSpace_0[i_0]);
#line 41
viewSpace_0[i_0] = _S9.xyz;
#line 39
int _S10 = i_0 + int(1);
#line 39
i_0 = _S10;
}
#line 45
Frustum_0 frustum_0;
Plane_0 _S11 = computePlane_0(eyePos_0, viewSpace_0[2], viewSpace_0[0]);
#line 47
frustum_0.planes_0[0] = _S11;
Plane_0 _S12 = computePlane_0(eyePos_0, viewSpace_0[1], viewSpace_0[3]);
#line 48
frustum_0.planes_0[1] = _S12;
Plane_0 _S13 = computePlane_0(eyePos_0, viewSpace_0[0], viewSpace_0[1]);
#line 49
frustum_0.planes_0[2] = _S13;
Plane_0 _S14 = computePlane_0(eyePos_0, viewSpace_0[3], viewSpace_0[2]);
#line 50
frustum_0.planes_0[3] = _S14;
if(_S8.dispatchThreadID_0.x < DispatchParams_0._data.numThreads_0.x && _S8.dispatchThreadID_0.y < DispatchParams_0._data.numThreads_0.y)
{
((out_Frustums_0)._data[(_S8.dispatchThreadID_0.x + _S8.dispatchThreadID_0.y * DispatchParams_0._data.numThreads_0.x)]) = frustum_0;
#line 52
}
else
{
#line 52
}
#line 57
return;
}
+3 -3
View File
@@ -9,15 +9,15 @@ struct ViewParameter
float4 cameraPos_WS;
float2 screenDimensions;
}
layout(set = INDEX_VIEW_PARAMS, binding = 0, std430)
ConstantBuffer<ViewParameter> gViewParams;
//layout(set = INDEX_VIEW_PARAMS, binding = 0, std430)
ParameterBlock<ViewParameter> viewParams;
// Convert screen space coordinates to view space.
float4 screenToClip( float4 screen )
{
// Convert to normalized texture coordinates
float2 texCoord = screen.xy / gViewParams.screenDimensions;
float2 texCoord = screen.xy / viewParams.screenDimensions;
// Convert to clip space
return float4( float2( texCoord.x, 1.0f-texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w );
-27
View File
@@ -1,27 +0,0 @@
import LightEnv;
import Material;
import BRDF;
import MaterialParameter;
struct FlatColorMaterial : IMaterial
{
float3 diffuseColor;
float specularity;
typedef BlinnPhong BRDF;
BlinnPhong prepare(MaterialFragmentParameter input)
{
BlinnPhong result;
result.baseColor = diffuseColor;
result.specular = specularity;
result.normal = normalize(input.worldNormal);
result.roughness = 0.5;
result.specularTint = 0;
result.anisotropic = 1;
result.sheen = 1;
result.sheenTint = 0.5;
result.clearCoat = 0;
result.clearCoatGloss = 0;
return result;
}
};
+18 -8
View File
@@ -61,11 +61,21 @@ struct PointLight : ILightEnv
}
};
layout(set = INDEX_LIGHT_ENV, binding = 0, std430)
ShaderBuffer<DirectionalLight> directionalLights;
layout(set = INDEX_LIGHT_ENV, binding = 1, std430)
ConstantBuffer<uint> numDirectionalLights;
layout(set = INDEX_LIGHT_ENV, binding = 2, std430)
ShaderBuffer<PointLight> pointLights;
layout(set = INDEX_LIGHT_ENV, binding = 3, std430)
ConstantBuffer<uint> numPointLights;
struct LightEnv
{
StructuredBuffer<DirectionalLight> directionalLights;
uint numDirectionalLights;
StructureBuffer<PointLight> pointLights;
uint numPointLights;
};
ParameterBlock<LightEnv> gLightEnv;
//layout(set = INDEX_LIGHT_ENV, binding = 0, std430)
//ShaderBuffer<DirectionalLight> directionalLights;
//layout(set = INDEX_LIGHT_ENV, binding = 1, std430)
//ConstantBuffer<uint> numDirectionalLights;
//layout(set = INDEX_LIGHT_ENV, binding = 2, std430)
//ShaderBuffer<PointLight> pointLights;
//layout(set = INDEX_LIGHT_ENV, binding = 3, std430)
//ConstantBuffer<uint> numPointLights;
-1
View File
@@ -8,5 +8,4 @@ interface IMaterial
BRDF prepare(MaterialFragmentParameter input);
};
layout(set = INDEX_MATERIAL, binding = 0, std430)
ParameterBlock<IMaterial> gMaterial;
-37
View File
@@ -1,37 +0,0 @@
struct MaterialVertexParameter
{
float3 worldPosition;
float3 viewPosition;
float3x3 worldToTangent;
#if NUM_MATERIAL_TEXCOORDS
float2 texCoords[NUM_MATERIAL_TEXCOORDS];
#endif
#ifdef USE_INSTANCING
float4x4 instanceLocalToWorld;
float3 instanceLocalPosition;
float4 perInstanceParams;
uint instanceId;
#endif
//float3 preSkinnedPosition;
//float3 perSkinnedNormal;
float4 vertexColor;
};
struct MaterialFragmentParameter
{
float3 position_TS;
float3 viewDir_TS;
float4 vertexColor;
float3x3 worldToTangent;
#ifdef USE_INSTANCING
float3 perInstanceParams;
#endif
#if NUM_MATERIAL_TEXCOORDS
float2 texCoords[NUM_MATERIAL_TEXCOORDS];
#endif
float3 transformWorldToTangent(float3 vec)
{
return mul(worldToTangent, vec);
}
};
+21
View File
@@ -0,0 +1,21 @@
struct MeshletDescription
{
uint32_t vertexCount;
uint32_t primitiveCount;
uint32_t vertexOffset;
uint32_t primitiveOffset;
};
struct MeshletData
{
StructuredBuffer<MeshletDescription> meshletInfos;
StructuredBuffer<uint8_t> primitiveIndices;
StructuredBuffer<uint32_t> vertexIndices;
};
static const uint MAX_VERTICES = 64;
static const uint MAX_PRIMITIVES = 126;
static const uint GROUP_SIZE = 32;
ParameterBlock<MeshletData> meshlets;
-21
View File
@@ -1,21 +0,0 @@
import Material;
import InputGeometry;
struct ParallaxMaterial : IMaterial
{
Texture2D<float4> diffuseTexture;
Texture2D<float4> specularTexture;
Texture2D<float4> displacementTexture;
SamplerState textureSampler;
float specularity;
typedef BlinnPhong BRDF;
BlinnPhong prepare(InputGeometry geometry)
{
BlinnPhong blinn;
blinn.baseColor = diffuseTexture.Sample(textureSampler, geometry.getTexCoords()).xyz;
blinn.specularColor = specularTexture.Sample(textureSampler, geometry.getTexCoords()).xyz;
blinn.specular = specularity;
return blinn;
}
};
-12
View File
@@ -1,12 +0,0 @@
struct Particle
{
float3 position;
float mass;
float3 velocity;
float age;
float3 forceAccumulator;
float life;
float color;
float3 pad;
};
-17
View File
@@ -1,17 +0,0 @@
struct PrimitiveSceneData
{
float4x4 modelToWorld;
float4x4 worldToModel;
float4 actorLocation;
};
layout(set = INDEX_SCENE_DATA, binding = 0, std430)
ShaderBuffer<PrimitiveSceneData> gSceneData;
[[vk::push_constant]]
ConstantBuffer<uint> gSceneDataIndex;
PrimitiveSceneData getSceneData()
{
return gSceneData[gSceneDataIndex];
}
+20
View File
@@ -0,0 +1,20 @@
struct InstanceData
{
float4x4 transformMatrix;
};
struct MeshData
{
uint numMeshlets;
uint meshletOffset;
uint numInstances;
uint instanceOffset;
};
struct Scene
{
StructuredBuffer<InstanceData> instances;
StructuredBuffer<MeshData> meshData;
};
ParameterBlock<Scene> scene;
@@ -0,0 +1,41 @@
import VertexData;
import Common;
import Scene;
struct StaticMeshVertexAttributes : VertexAttributes
{
float4 position: SV_Position;
float2 texCoords: TEXCOORD0;
float3 normal: NORMAL0;
float4 getPosition()
{
return position;
}
float2 getTexCoord()
{
return texCoords;
}
float3 getNormal()
{
return normal;
}
}
struct StaticMeshVertexData : VertexData
{
StaticMeshVertexAttributes getAttributes(uint index, InstanceData inst)
{
StaticMeshVertexAttributes attr;
float4 worldPos = mul(inst.transformMatrix, positions[index]);
float4 viewPos = mul(viewParams.viewMatrix, worldPos);
float4 clipPos = mul(viewParams.projectionMatrix, viewPos);
attr.position = clipPos;
attr.texCoords = texCoords[index];
attr.normal = normals[index];
return attr;
}
StructuredBuffer<float4> positions;
StructuredBuffer<float2> texCoords;
StructuredBuffer<float3> normals;
}
ParameterBlock<StaticMeshVertexData> vertexData;
-173
View File
@@ -1,173 +0,0 @@
import Common;
import MaterialParameter;
import PrimitiveSceneData;
struct VertexValueCache
{
//This struct is passed between vertex and fragment stage
//which means, that it is passed as out mat3x3 in glsl
//but Slang for some reason puts a layout(row_major) above
//every attribute, including this matrix, but matrix layout
//qualifiers are illegal for non-uniform and buffer fields,
//leading to a compiler error
float3 position_MS;
float3 tangent;
float3 biTangent;
float3 normal;
float4 color;
#if NUM_MATERIAL_TEXCOORDS
float2 texCoords[NUM_MATERIAL_TEXCOORDS];
#endif
float4x4 getModelToTangent()
{
return transpose(float4x4(
float4(normalize(tangent), 0.0f),
float4(normalize(biTangent), 0.0f),
float4(normalize(normal), 0.0f),
float4(0, 0, 0, 1)
));
}
float4x4 getWorldToTangent()
{
return transpose(float4x4(
normalize(mul(getSceneData().worldToModel, float4(tangent, 0))),
normalize(mul(getSceneData().worldToModel, float4(biTangent, 0))),
normalize(mul(getSceneData().worldToModel, float4(normal, 0))),
float4(0, 0, 0, 1)
));
}
MaterialFragmentParameter getFragmentParameters()
{
MaterialFragmentParameter result = (MaterialFragmentParameter)0;
float4x4 worldToTangent = getWorldToTangent();
float4 cameraPos_TS = mul(worldToTangent, gViewParams.cameraPos_WS);
float4 position_TS = mul(getModelToTangent(), float4(position_MS, 1.0f));
result.worldToTangent = float3x3(worldToTangent);
result.position_TS = position_TS.xyz;
result.viewDir_TS = normalize((cameraPos_TS - position_TS).xyz);
result.vertexColor = color;
for(uint i = 0; i < NUM_MATERIAL_TEXCOORDS; ++i)
{
result.texCoords[i] = texCoords[i];
}
return result;
}
#if USE_INSTANCING
float4 instanceOrigin;
float3 instanceTransform1;
float3 instanceTransform2;
float3 instanceTransform3;
float4x4 getInstanceTransform()
{
return float4x4(
float4(instanceTransform1.xyz, 0.0f),
float4(instanceTransform2.xyz, 0.0f),
float4(instanceTransform3.xyz, 0.0f),
float4(instanceOrigin.xyz, 1.0f)
);
}
#endif // USE_INSTANCING
};
struct VertexShaderInput
{
float3 position;
float3 normal;
float3 tangent;
float3 biTangent;
float4 color;
#if NUM_MATERIAL_TEXCOORDS
#if NUM_MATERIAL_TEXCOORDS > 1
float4 packedTexCoords[NUM_MATERIAL_TEXCOORDS / 2];
#endif
#if NUM_MATERIAL_TEXCOORDS == 1
float2 packedTexCoords2;
#endif
#if NUM_MATERIAL_TEXCOORDS == 3
float2 packedTexCoords2;
#endif
#if NUM_MATERIAL_TEXCOORDS == 5
float2 packedTexCoords2;
#endif
#if NUM_MATERIAL_TEXCOORDS == 7
float2 packedTexCoords2;
#endif
#endif // NUM_MATERIAL_TEXCOORDS
#if USE_INSTANCING
float4 instanceOrigin;
float3 instanceTransform1;
float3 instanceTransform2;
float3 instanceTransform3;
#endif // USE_INSTANCING
float3 getModelPosition()
{
return position;
}
float3 getWorldPosition()
{
return mul(getSceneData().modelToWorld, float4(position, 1.0f)).xyz;
}
VertexValueCache getVertexCache()
{
VertexValueCache cache;
cache.position_MS = position;
cache.tangent = tangent;
cache.biTangent = biTangent;
cache.normal = normal;
cache.color = color;
#if USE_INSTANCING
cache.instanceTransform1 = instanceTransform1;
cache.instanceTransform2 = instanceTransform2;
cache.instanceTransform3 = instanceTransform3;
cache.instanceOrigin = instanceOrigin;
#endif
cache.texCoords[0] = packedTexCoords2;
return cache;
}
MaterialVertexParameter getMaterialVertexParameters(VertexValueCache cache, float3 worldPosition, float3 viewPosition)
{
MaterialVertexParameter result;
result.worldPosition = worldPosition;
result.viewPosition = viewPosition;
result.vertexColor = cache.color;
result.worldToTangent = float3x3(cache.getWorldToTangent());
// TODO instancing
/*for(int i = 0; i < NUM_MATERIAL_TEXCOORDS-1; i+=2)
{
result.texCoords[i] = packedTexCoords[i/2].xy;
if(i+1 < NUM_MATERIAL_TEXCOORDS)
{
result.texCoords = packedTexCoords[i / 2].zw;
}
}*/
result.texCoords[0] = packedTexCoords2;
return result;
}
};
struct PositionOnlyVertexShaderInput
{
float3 position;
#if USE_INSTANCING
float4 instanceOrigin;
float3 instanceTransform1;
float3 instanceTransform2;
float3 instanceTransform3;
#endif // USE_INSTANCING
float3 getWorldPosition()
{
return mul(getSceneData().modelToWorld, float4(position, 1.0f)).xyz;
}
};
-42
View File
@@ -1,42 +0,0 @@
import LightEnv;
import Material;
import BRDF;
import MaterialParameter;
struct TexturedMaterial : IMaterial
{
Texture2D diffuseTexture;
Texture2D specularTexture;
Texture2D normalTexture;
float uvScale;
float metallic = 0;
float subsurface = 0;
float roughness = 0.5;
float specularTint = 0;
float anisotropic = 0;
float sheen = 0;
float sheenTint = 0.5f;
float clearCoat = 0;
float clearCoatGloss = 1;
SamplerState textureSampler;
typedef BlinnPhong BRDF;
BlinnPhong prepare(MaterialFragmentParameter geometry)
{
BlinnPhong result;
result.baseColor = diffuseTexture.Sample(textureSampler, geometry.texCoords[0] * uvScale).xyz;
result.metallic = 0;
float3 bumpMapNormal = normalTexture.Sample(textureSampler, geometry.texCoords[0] * uvScale).xyz;
bumpMapNormal = 2.0 * bumpMapNormal - float3(1.0, 1.0, 1.0);
result.normal = geometry.transformNormalToWorld(bumpMapNormal);
result.specular = specularTexture.Sample(textureSampler, geometry.texCoords[0] * uvScale).x;
result.roughness = roughness;
result.specularTint = specularTint;
result.anisotropic = anisotropic;
result.sheen = sheen;
result.sheenTint = sheenTint;
result.clearCoat = clearCoat;
result.clearCoatGloss = clearCoatGloss;
return result;
}
};
+13
View File
@@ -0,0 +1,13 @@
import Scene;
interface VertexAttributes
{
float4 getPosition();
float2 getTexCoord();
float3 getNormal();
}
interface VertexData
{
VertexAttributes getAttributes(uint index, InstanceData inst);
};
-8
View File
@@ -1,8 +0,0 @@
import Mat;
import Simple;
[shader("fragment")]
float4 fragmentMain(float2 texCoord)
{
return gMaterial.sample(texCoord);
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12
View File
@@ -0,0 +1,12 @@
struct Payload
{
uint num;
};
[shader("mesh")]
[numthreads(32, 1, 1)]
[outputtopology("triangle")]
void taskMain(uint threadID: SV_DispatchThreadID)
{
SetOutputMeshCounts(64, 126);
}
-103
View File
@@ -1,103 +0,0 @@
#version 450
#extension GL_EXT_nonuniform_qualifier : require
layout(row_major) uniform;
layout(row_major) buffer;
#line 30 0
layout(binding = 2)
layout(std140) uniform _S1
{
uint _data;
} numBackgroundTextures_0;
#line 33
layout(binding = 3)
uniform texture2D backgroundTextures_0[];
#line 27
layout(binding = 1)
uniform sampler backgroundSampler_0;
#line 27
layout(location = 0)
out vec4 _S2;
#line 63
layout(location = 0)
in vec2 _S3;
#line 1
layout(location = 1)
in vec3 _S4;
#line 1
flat layout(location = 2)
in uint _S5;
#line 1
layout(location = 3)
in vec3 _S6;
#line 1
layout(location = 4)
in float _S7;
#line 1
layout(location = 5)
in vec2 _S8;
#line 1
struct RenderElementStyle_0
{
vec3 position_0;
uint backgroundImageIndex_0;
vec3 backgroundColor_0;
float opacity_0;
vec2 dimensions_0;
};
#line 63
void main()
{
vec4 bgTextureColor_0;
#line 63
RenderElementStyle_0 _S9 = RenderElementStyle_0(_S4, _S5, _S6, _S7, _S8);
#line 69
const vec4 _S10 = vec4(float(1), float(1), float(1), float(1));
#line 69
uint imageIndex_0 = _S9.backgroundImageIndex_0;
if(imageIndex_0 < numBackgroundTextures_0._data)
{
vec4 _S11 = (texture(sampler2D(backgroundTextures_0[imageIndex_0],backgroundSampler_0), (_S3)));
#line 71
bgTextureColor_0 = _S11;
}
else
{
#line 71
bgTextureColor_0 = _S10;
}
#line 71
_S2 = vec4(_S9.backgroundColor_0, _S9.opacity_0) * bgTextureColor_0;
#line 71
return;
}
-83
View File
@@ -1,83 +0,0 @@
#version 450
layout(row_major) uniform;
layout(row_major) buffer;
#line 1 0
struct RenderElementStyle_0
{
vec3 position_0;
uint backgroundImageIndex_0;
vec3 backgroundColor_0;
float opacity_0;
vec4 borderBottomColor_0;
vec4 borderLeftColor_0;
vec4 borderRightColor_0;
vec4 borderTopColor_0;
float borderBottomLeftRadius_0;
float borderBottomRightRadius_0;
float borderTopLeftRadius_0;
float borderTopRightRadius_0;
vec2 dimensions_0;
};
#line 33
layout(std430, binding = 3) readonly buffer _S1 {
RenderElementStyle_0 _data[];
} elements_0;
#line 33
layout(location = 0)
out vec2 _S2;
#line 33
layout(location = 1)
out uint _S3;
struct VertexStageOutput_0
{
vec4 position_1;
vec2 texCoords_0;
uint elementId_0;
};
void main()
{
#line 46
uint _S4 = uint(gl_VertexIndex);
#line 46
uint _S5 = uint(gl_InstanceIndex);
RenderElementStyle_0 style_0 = ((elements_0)._data[(_S5)]);
float xMin_0 = style_0.position_0.x;
float xMax_0 = xMin_0 + style_0.dimensions_0.x;
float yMin_0 = style_0.position_0.y;
float yMax_0 = yMin_0 + style_0.dimensions_0.y;
vec4 coordinates_0[4] = { vec4(xMin_0, yMin_0, float(0), float(0)), vec4(xMin_0, yMax_0, float(0), float(1)), vec4(xMax_0, yMin_0, float(1), float(0)), vec4(xMax_0, yMax_0, float(1), float(1)) };
#line 59
VertexStageOutput_0 output_0;
output_0.position_1 = vec4(coordinates_0[_S4].xy, style_0.position_0.z, float(1));
output_0.texCoords_0 = coordinates_0[_S4].zw;
output_0.elementId_0 = _S5;
VertexStageOutput_0 _S6 = output_0;
#line 63
gl_Position = _S6.position_1;
#line 63
_S2 = _S6.texCoords_0;
#line 63
_S3 = _S6.elementId_0;
#line 63
return;
}
-113
View File
@@ -1,113 +0,0 @@
#version 450
layout(row_major) uniform;
layout(row_major) buffer;
#line 2 0
struct GlyphData_0
{
vec2 bearing_0;
vec2 size_0;
};
#line 16
layout(std430, binding = 0, set = 1) readonly buffer _S1 {
GlyphData_0 _data[];
} glyphData_0;
layout(push_constant)
layout(std140) uniform _S2
{
float _data;
} scale_0;
#line 7
struct ViewData_0
{
mat4x4 projectionMatrix_0;
};
layout(binding = 0)
layout(std140) uniform _S3
{
ViewData_0 _data;
} viewData_0;
#line 12
layout(location = 0)
out vec2 _S4;
#line 12
layout(location = 1)
out uint _S5;
#line 12
layout(location = 0)
in uint _S6;
#line 12
layout(location = 1)
in vec2 _S7;
#line 22
struct VertexStageInput_0
{
uint glyphIndex_0;
vec2 position_0;
uint vertexId_0;
};
struct VertexStageOutput_0
{
vec4 position_1;
vec2 uvCoords_0;
uint glyphIndex_1;
};
void main()
{
#line 37
VertexStageInput_0 _S8 = VertexStageInput_0(_S6, _S7, uint(gl_VertexIndex));
GlyphData_0 glyph_0 = ((glyphData_0)._data[(_S8.glyphIndex_0)]);
float xpos_0 = _S8.position_0.x + glyph_0.bearing_0.x * scale_0._data;
float ypos_0 = _S8.position_0.y - (glyph_0.size_0.y - glyph_0.bearing_0.y) * scale_0._data;
float w_0 = glyph_0.size_0.x * scale_0._data;
float h_0 = glyph_0.size_0.y * scale_0._data;
vec4 coordinates_0[4] = { vec4(xpos_0, ypos_0 + h_0, float(0), float(0)), vec4(xpos_0, ypos_0, float(0), float(1)), vec4(xpos_0 + w_0, ypos_0, float(1), float(0)), vec4(xpos_0 + w_0, ypos_0 + h_0, float(1), float(1)) };
#line 47
vec4 vertex_0 = coordinates_0[_S8.vertexId_0];
#line 54
VertexStageOutput_0 output_0;
output_0.uvCoords_0 = vertex_0.zw;
vec4 _S9 = (((vec4(vertex_0.xy, float(0), float(1))) * (viewData_0._data.projectionMatrix_0)));
#line 56
output_0.position_1 = _S9;
output_0.glyphIndex_1 = _S8.glyphIndex_0;
VertexStageOutput_0 _S10 = output_0;
#line 58
gl_Position = _S10.position_1;
#line 58
_S4 = _S10.uvCoords_0;
#line 58
_S5 = _S10.glyphIndex_1;
#line 58
return;
}